@wordpress/components 19.8.4 → 19.11.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 (630) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/CONTRIBUTING.md +80 -7
  3. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
  4. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
  5. package/build/border-box-control/border-box-control/component.js +22 -7
  6. package/build/border-box-control/border-box-control/component.js.map +1 -1
  7. package/build/border-box-control/border-box-control-linked-button/hook.js +3 -2
  8. package/build/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
  9. package/build/border-box-control/border-box-control-split-controls/component.js +21 -8
  10. package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  11. package/build/border-box-control/border-box-control-visualizer/hook.js +3 -2
  12. package/build/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
  13. package/build/border-box-control/styles.js +11 -15
  14. package/build/border-box-control/styles.js.map +1 -1
  15. package/build/border-control/border-control/component.js +5 -3
  16. package/build/border-control/border-control/component.js.map +1 -1
  17. package/build/border-control/border-control/hook.js +6 -3
  18. package/build/border-control/border-control/hook.js.map +1 -1
  19. package/build/border-control/border-control-dropdown/component.js +6 -2
  20. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  21. package/build/border-control/border-control-dropdown/hook.js +5 -5
  22. package/build/border-control/border-control-dropdown/hook.js.map +1 -1
  23. package/build/border-control/styles.js +58 -29
  24. package/build/border-control/styles.js.map +1 -1
  25. package/build/box-control/index.js +0 -21
  26. package/build/box-control/index.js.map +1 -1
  27. package/build/box-control/utils.js +1 -8
  28. package/build/box-control/utils.js.map +1 -1
  29. package/build/button/index.js +3 -5
  30. package/build/button/index.js.map +1 -1
  31. package/build/button/index.native.js +16 -2
  32. package/build/button/index.native.js.map +1 -1
  33. package/build/button-group/index.js +24 -7
  34. package/build/button-group/index.js.map +1 -1
  35. package/build/{flyout → button-group}/types.js +0 -0
  36. package/build/button-group/types.js.map +1 -0
  37. package/build/checkbox-control/index.js +34 -7
  38. package/build/checkbox-control/index.js.map +1 -1
  39. package/build/checkbox-control/types.js +6 -0
  40. package/build/checkbox-control/types.js.map +1 -0
  41. package/build/circular-option-picker/index.js +1 -2
  42. package/build/circular-option-picker/index.js.map +1 -1
  43. package/build/color-palette/index.js +5 -12
  44. package/build/color-palette/index.js.map +1 -1
  45. package/build/date-time/date.js +43 -19
  46. package/build/date-time/date.js.map +1 -1
  47. package/build/date-time/index.js +28 -3
  48. package/build/date-time/index.js.map +1 -1
  49. package/build/date-time/time.js +42 -40
  50. package/build/date-time/time.js.map +1 -1
  51. package/build/date-time/timezone.js +4 -3
  52. package/build/date-time/timezone.js.map +1 -1
  53. package/build/date-time/types.js +6 -0
  54. package/build/date-time/types.js.map +1 -0
  55. package/build/date-time/utils.js +6 -4
  56. package/build/date-time/utils.js.map +1 -1
  57. package/build/disabled/index.js +4 -76
  58. package/build/disabled/index.js.map +1 -1
  59. package/build/draggable/index.native.js +223 -0
  60. package/build/draggable/index.native.js.map +1 -0
  61. package/build/dropdown/index.js +7 -5
  62. package/build/dropdown/index.js.map +1 -1
  63. package/build/focal-point-picker/index.native.js +3 -3
  64. package/build/focal-point-picker/index.native.js.map +1 -1
  65. package/build/heading/hook.js +1 -1
  66. package/build/heading/hook.js.map +1 -1
  67. package/build/index.js +0 -8
  68. package/build/index.js.map +1 -1
  69. package/build/index.native.js +16 -0
  70. package/build/index.native.js.map +1 -1
  71. package/build/input-control/index.js +27 -4
  72. package/build/input-control/index.js.map +1 -1
  73. package/build/input-control/styles/input-control-styles.js +42 -30
  74. package/build/input-control/styles/input-control-styles.js.map +1 -1
  75. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
  76. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  77. package/build/mobile/bottom-sheet/index.native.js +1 -1
  78. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  79. package/build/mobile/bottom-sheet-select-control/index.native.js +4 -2
  80. package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  81. package/build/mobile/html-text-input/index.native.js +19 -8
  82. package/build/mobile/html-text-input/index.native.js.map +1 -1
  83. package/build/mobile/keyboard-aware-flat-list/index.android.js +28 -5
  84. package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  85. package/build/mobile/keyboard-aware-flat-list/index.ios.js +47 -24
  86. package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  87. package/build/navigation/styles/navigation-styles.js +12 -12
  88. package/build/navigation/styles/navigation-styles.js.map +1 -1
  89. package/build/notice/index.native.js +44 -40
  90. package/build/notice/index.native.js.map +1 -1
  91. package/build/notice/list.native.js +27 -45
  92. package/build/notice/list.native.js.map +1 -1
  93. package/build/palette-edit/index.js +38 -7
  94. package/build/palette-edit/index.js.map +1 -1
  95. package/build/popover/index.js +223 -323
  96. package/build/popover/index.js.map +1 -1
  97. package/build/resizable-box/resize-tooltip/utils.js +5 -8
  98. package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
  99. package/build/sandbox/index.js +2 -2
  100. package/build/sandbox/index.js.map +1 -1
  101. package/build/sandbox/index.native.js +1 -1
  102. package/build/sandbox/index.native.js.map +1 -1
  103. package/build/select-control/index.js +31 -4
  104. package/build/select-control/index.js.map +1 -1
  105. package/build/select-control/styles/select-control-styles.js +17 -14
  106. package/build/select-control/styles/select-control-styles.js.map +1 -1
  107. package/build/surface/styles.js +8 -8
  108. package/build/surface/styles.js.map +1 -1
  109. package/build/text/hook.js +5 -5
  110. package/build/text/hook.js.map +1 -1
  111. package/build/text/styles/text-mixins.native.js +1 -1
  112. package/build/text/styles/text-mixins.native.js.map +1 -1
  113. package/build/text/styles.js +7 -7
  114. package/build/text/styles.js.map +1 -1
  115. package/build/text-control/index.js +35 -28
  116. package/build/text-control/index.js.map +1 -1
  117. package/build/text-control/types.js +6 -0
  118. package/build/text-control/types.js.map +1 -0
  119. package/build/toggle-group-control/toggle-group-control/component.js +1 -3
  120. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  121. package/build/toggle-group-control/toggle-group-control-option-icon/component.js +6 -4
  122. package/build/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
  123. package/build/tools-panel/tools-panel-header/component.js +52 -36
  124. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  125. package/build/tooltip/index.js +2 -2
  126. package/build/tooltip/index.js.map +1 -1
  127. package/build/ui/spinner/component.js +1 -1
  128. package/build/ui/spinner/component.js.map +1 -1
  129. package/build/unit-control/index.js +3 -3
  130. package/build/unit-control/index.js.map +1 -1
  131. package/build/unit-control/styles/unit-control-styles.js +11 -20
  132. package/build/unit-control/styles/unit-control-styles.js.map +1 -1
  133. package/build/unit-control/utils.js.map +1 -1
  134. package/build/utils/colors-values.js +9 -24
  135. package/build/utils/colors-values.js.map +1 -1
  136. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
  137. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
  138. package/build-module/border-box-control/border-box-control/component.js +22 -7
  139. package/build-module/border-box-control/border-box-control/component.js.map +1 -1
  140. package/build-module/border-box-control/border-box-control-linked-button/hook.js +3 -2
  141. package/build-module/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
  142. package/build-module/border-box-control/border-box-control-split-controls/component.js +21 -8
  143. package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  144. package/build-module/border-box-control/border-box-control-visualizer/hook.js +3 -2
  145. package/build-module/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
  146. package/build-module/border-box-control/styles.js +9 -15
  147. package/build-module/border-box-control/styles.js.map +1 -1
  148. package/build-module/border-control/border-control/component.js +5 -3
  149. package/build-module/border-control/border-control/component.js.map +1 -1
  150. package/build-module/border-control/border-control/hook.js +6 -3
  151. package/build-module/border-control/border-control/hook.js.map +1 -1
  152. package/build-module/border-control/border-control-dropdown/component.js +6 -2
  153. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  154. package/build-module/border-control/border-control-dropdown/hook.js +5 -5
  155. package/build-module/border-control/border-control-dropdown/hook.js.map +1 -1
  156. package/build-module/border-control/styles.js +56 -29
  157. package/build-module/border-control/styles.js.map +1 -1
  158. package/build-module/box-control/index.js +1 -20
  159. package/build-module/box-control/index.js.map +1 -1
  160. package/build-module/box-control/utils.js +0 -6
  161. package/build-module/box-control/utils.js.map +1 -1
  162. package/build-module/button/index.js +3 -4
  163. package/build-module/button/index.js.map +1 -1
  164. package/build-module/button/index.native.js +16 -3
  165. package/build-module/button/index.native.js.map +1 -1
  166. package/build-module/button-group/index.js +27 -7
  167. package/build-module/button-group/index.js.map +1 -1
  168. package/build-module/{flyout → button-group}/types.js +0 -0
  169. package/build-module/{flyout → button-group}/types.js.map +0 -0
  170. package/build-module/checkbox-control/index.js +31 -7
  171. package/build-module/checkbox-control/index.js.map +1 -1
  172. package/build-module/checkbox-control/types.js +2 -0
  173. package/{build/flyout → build-module/checkbox-control}/types.js.map +0 -0
  174. package/build-module/circular-option-picker/index.js +1 -2
  175. package/build-module/circular-option-picker/index.js.map +1 -1
  176. package/build-module/color-palette/index.js +5 -11
  177. package/build-module/color-palette/index.js.map +1 -1
  178. package/build-module/date-time/date.js +44 -19
  179. package/build-module/date-time/date.js.map +1 -1
  180. package/build-module/date-time/index.js +28 -4
  181. package/build-module/date-time/index.js.map +1 -1
  182. package/build-module/date-time/time.js +43 -41
  183. package/build-module/date-time/time.js.map +1 -1
  184. package/build-module/date-time/timezone.js +4 -3
  185. package/build-module/date-time/timezone.js.map +1 -1
  186. package/build-module/date-time/types.js +2 -0
  187. package/build-module/date-time/types.js.map +1 -0
  188. package/build-module/date-time/utils.js +6 -4
  189. package/build-module/date-time/utils.js.map +1 -1
  190. package/build-module/disabled/index.js +5 -76
  191. package/build-module/disabled/index.js.map +1 -1
  192. package/build-module/draggable/index.native.js +206 -0
  193. package/build-module/draggable/index.native.js.map +1 -0
  194. package/build-module/dropdown/index.js +7 -5
  195. package/build-module/dropdown/index.js.map +1 -1
  196. package/build-module/focal-point-picker/index.native.js +3 -3
  197. package/build-module/focal-point-picker/index.native.js.map +1 -1
  198. package/build-module/heading/hook.js +1 -1
  199. package/build-module/heading/hook.js.map +1 -1
  200. package/build-module/index.js +0 -1
  201. package/build-module/index.js.map +1 -1
  202. package/build-module/index.native.js +2 -1
  203. package/build-module/index.native.js.map +1 -1
  204. package/build-module/input-control/index.js +24 -3
  205. package/build-module/input-control/index.js.map +1 -1
  206. package/build-module/input-control/styles/input-control-styles.js +42 -30
  207. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  208. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
  209. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  210. package/build-module/mobile/bottom-sheet/index.native.js +1 -1
  211. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  212. package/build-module/mobile/bottom-sheet-select-control/index.native.js +4 -2
  213. package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  214. package/build-module/mobile/html-text-input/index.native.js +20 -9
  215. package/build-module/mobile/html-text-input/index.native.js.map +1 -1
  216. package/build-module/mobile/keyboard-aware-flat-list/index.android.js +21 -5
  217. package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  218. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +42 -25
  219. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  220. package/build-module/navigation/styles/navigation-styles.js +13 -13
  221. package/build-module/navigation/styles/navigation-styles.js.map +1 -1
  222. package/build-module/notice/index.native.js +45 -41
  223. package/build-module/notice/index.native.js.map +1 -1
  224. package/build-module/notice/list.native.js +28 -46
  225. package/build-module/notice/list.native.js.map +1 -1
  226. package/build-module/palette-edit/index.js +37 -7
  227. package/build-module/palette-edit/index.js.map +1 -1
  228. package/build-module/popover/index.js +225 -325
  229. package/build-module/popover/index.js.map +1 -1
  230. package/build-module/resizable-box/resize-tooltip/utils.js +4 -5
  231. package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
  232. package/build-module/sandbox/index.js +2 -2
  233. package/build-module/sandbox/index.js.map +1 -1
  234. package/build-module/sandbox/index.native.js +1 -1
  235. package/build-module/sandbox/index.native.js.map +1 -1
  236. package/build-module/select-control/index.js +29 -3
  237. package/build-module/select-control/index.js.map +1 -1
  238. package/build-module/select-control/styles/select-control-styles.js +17 -14
  239. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  240. package/build-module/surface/styles.js +8 -8
  241. package/build-module/surface/styles.js.map +1 -1
  242. package/build-module/text/hook.js +5 -5
  243. package/build-module/text/hook.js.map +1 -1
  244. package/build-module/text/styles/text-mixins.native.js +2 -2
  245. package/build-module/text/styles/text-mixins.native.js.map +1 -1
  246. package/build-module/text/styles.js +7 -7
  247. package/build-module/text/styles.js.map +1 -1
  248. package/build-module/text-control/index.js +35 -27
  249. package/build-module/text-control/index.js.map +1 -1
  250. package/build-module/text-control/types.js +2 -0
  251. package/build-module/text-control/types.js.map +1 -0
  252. package/build-module/toggle-group-control/toggle-group-control/component.js +2 -3
  253. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  254. package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js +1 -5
  255. package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
  256. package/build-module/tools-panel/tools-panel-header/component.js +51 -36
  257. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  258. package/build-module/tooltip/index.js +2 -2
  259. package/build-module/tooltip/index.js.map +1 -1
  260. package/build-module/ui/spinner/component.js +1 -1
  261. package/build-module/ui/spinner/component.js.map +1 -1
  262. package/build-module/unit-control/index.js +3 -3
  263. package/build-module/unit-control/index.js.map +1 -1
  264. package/build-module/unit-control/styles/unit-control-styles.js +11 -20
  265. package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
  266. package/build-module/unit-control/utils.js.map +1 -1
  267. package/build-module/utils/colors-values.js +19 -23
  268. package/build-module/utils/colors-values.js.map +1 -1
  269. package/build-style/style-rtl.css +55 -170
  270. package/build-style/style.css +51 -170
  271. package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
  272. package/build-types/border-box-control/border-box-control/hook.d.ts +3 -1
  273. package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
  274. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts.map +1 -1
  275. package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
  276. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +3 -1
  277. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
  278. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts.map +1 -1
  279. package/build-types/border-box-control/styles.d.ts +2 -2
  280. package/build-types/border-box-control/styles.d.ts.map +1 -1
  281. package/build-types/border-box-control/types.d.ts +40 -13
  282. package/build-types/border-box-control/types.d.ts.map +1 -1
  283. package/build-types/border-control/border-control/component.d.ts.map +1 -1
  284. package/build-types/border-control/border-control/hook.d.ts +2 -1
  285. package/build-types/border-control/border-control/hook.d.ts.map +1 -1
  286. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  287. package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -0
  288. package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
  289. package/build-types/border-control/styles.d.ts +2 -1
  290. package/build-types/border-control/styles.d.ts.map +1 -1
  291. package/build-types/border-control/types.d.ts +18 -6
  292. package/build-types/border-control/types.d.ts.map +1 -1
  293. package/build-types/button/index.d.ts.map +1 -1
  294. package/build-types/button-group/index.d.ts +25 -0
  295. package/build-types/button-group/index.d.ts.map +1 -0
  296. package/build-types/button-group/stories/index.d.ts +12 -0
  297. package/build-types/button-group/stories/index.d.ts.map +1 -0
  298. package/build-types/button-group/types.d.ts +11 -0
  299. package/build-types/button-group/types.d.ts.map +1 -0
  300. package/build-types/checkbox-control/index.d.ts +26 -0
  301. package/build-types/checkbox-control/index.d.ts.map +1 -0
  302. package/build-types/checkbox-control/stories/index.d.ts +13 -0
  303. package/build-types/checkbox-control/stories/index.d.ts.map +1 -0
  304. package/build-types/checkbox-control/types.d.ts +35 -0
  305. package/build-types/checkbox-control/types.d.ts.map +1 -0
  306. package/build-types/circular-option-picker/index.d.ts.map +1 -1
  307. package/build-types/color-palette/index.d.ts.map +1 -1
  308. package/build-types/color-picker/styles.d.ts +3 -3
  309. package/build-types/date-time/date.d.ts +24 -0
  310. package/build-types/date-time/date.d.ts.map +1 -0
  311. package/build-types/date-time/index.d.ts +35 -0
  312. package/build-types/date-time/index.d.ts.map +1 -0
  313. package/build-types/date-time/stories/date.d.ts +14 -0
  314. package/build-types/date-time/stories/date.d.ts.map +1 -0
  315. package/build-types/date-time/stories/index.d.ts +14 -0
  316. package/build-types/date-time/stories/index.d.ts.map +1 -0
  317. package/build-types/date-time/stories/time.d.ts +12 -0
  318. package/build-types/date-time/stories/time.d.ts.map +1 -0
  319. package/build-types/date-time/stories/utils.d.ts +3 -0
  320. package/build-types/date-time/stories/utils.d.ts.map +1 -0
  321. package/build-types/date-time/test/date.d.ts +2 -0
  322. package/build-types/date-time/test/date.d.ts.map +1 -0
  323. package/build-types/date-time/test/time.d.ts +2 -0
  324. package/build-types/date-time/test/time.d.ts.map +1 -0
  325. package/build-types/date-time/test/utils.d.ts +2 -0
  326. package/build-types/date-time/test/utils.d.ts.map +1 -0
  327. package/build-types/date-time/time.d.ts +25 -0
  328. package/build-types/date-time/time.d.ts.map +1 -0
  329. package/build-types/date-time/timezone.d.ts +8 -0
  330. package/build-types/date-time/timezone.d.ts.map +1 -0
  331. package/build-types/date-time/types.d.ts +91 -0
  332. package/build-types/date-time/types.d.ts.map +1 -0
  333. package/build-types/date-time/utils.d.ts +15 -0
  334. package/build-types/date-time/utils.d.ts.map +1 -0
  335. package/build-types/disabled/index.d.ts.map +1 -1
  336. package/build-types/dropdown/index.d.ts.map +1 -1
  337. package/build-types/input-control/index.d.ts +23 -3
  338. package/build-types/input-control/index.d.ts.map +1 -1
  339. package/build-types/input-control/input-field.d.ts +1 -1
  340. package/build-types/input-control/input-field.d.ts.map +1 -1
  341. package/build-types/input-control/stories/index.d.ts +5 -5
  342. package/build-types/input-control/stories/index.d.ts.map +1 -1
  343. package/build-types/input-control/styles/input-control-styles.d.ts +1 -0
  344. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  345. package/build-types/input-control/types.d.ts +79 -3
  346. package/build-types/input-control/types.d.ts.map +1 -1
  347. package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
  348. package/build-types/popover/index.d.ts +5 -8
  349. package/build-types/popover/index.d.ts.map +1 -1
  350. package/build-types/resizable-box/index.d.ts +1 -1
  351. package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
  352. package/build-types/resizable-box/resize-tooltip/utils.d.ts.map +1 -1
  353. package/build-types/select-control/index.d.ts +30 -26
  354. package/build-types/select-control/index.d.ts.map +1 -1
  355. package/build-types/select-control/stories/index.d.ts +23 -0
  356. package/build-types/select-control/stories/index.d.ts.map +1 -0
  357. package/build-types/select-control/styles/select-control-styles.d.ts +3 -4
  358. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  359. package/build-types/select-control/test/select-control.d.ts +2 -0
  360. package/build-types/select-control/test/select-control.d.ts.map +1 -0
  361. package/build-types/select-control/types.d.ts +52 -1
  362. package/build-types/select-control/types.d.ts.map +1 -1
  363. package/build-types/text-control/index.d.ts +2 -2
  364. package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
  365. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts.map +1 -1
  366. package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
  367. package/build-types/tools-panel/types.d.ts +0 -1
  368. package/build-types/tools-panel/types.d.ts.map +1 -1
  369. package/build-types/tooltip/index.d.ts.map +1 -1
  370. package/build-types/unit-control/index.d.ts +2 -2
  371. package/build-types/unit-control/index.d.ts.map +1 -1
  372. package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
  373. package/build-types/unit-control/test/index.d.ts +2 -0
  374. package/build-types/unit-control/test/index.d.ts.map +1 -0
  375. package/build-types/unit-control/test/utils.d.ts +2 -0
  376. package/build-types/unit-control/test/utils.d.ts.map +1 -0
  377. package/build-types/unit-control/types.d.ts +1 -1
  378. package/build-types/unit-control/types.d.ts.map +1 -1
  379. package/build-types/unit-control/utils.d.ts +3 -3
  380. package/build-types/unit-control/utils.d.ts.map +1 -1
  381. package/build-types/utils/colors-values.d.ts +6 -146
  382. package/build-types/utils/colors-values.d.ts.map +1 -1
  383. package/package.json +19 -19
  384. package/src/alignment-matrix-control/styles/alignment-matrix-control-styles.js +5 -3
  385. package/src/autocomplete/style.scss +1 -1
  386. package/src/border-box-control/border-box-control/README.md +10 -14
  387. package/src/border-box-control/border-box-control/component.tsx +21 -4
  388. package/src/border-box-control/border-box-control-linked-button/hook.ts +10 -6
  389. package/src/border-box-control/border-box-control-split-controls/component.tsx +24 -7
  390. package/src/border-box-control/border-box-control-visualizer/hook.ts +11 -6
  391. package/src/border-box-control/stories/index.js +1 -0
  392. package/src/border-box-control/styles.ts +15 -8
  393. package/src/border-box-control/types.ts +40 -14
  394. package/src/border-control/border-control/README.md +0 -7
  395. package/src/border-control/border-control/component.tsx +4 -2
  396. package/src/border-control/border-control/hook.ts +5 -2
  397. package/src/border-control/border-control-dropdown/component.tsx +18 -11
  398. package/src/border-control/border-control-dropdown/hook.ts +7 -5
  399. package/src/border-control/stories/index.js +1 -0
  400. package/src/border-control/styles.ts +82 -22
  401. package/src/border-control/types.ts +18 -6
  402. package/src/box-control/README.md +0 -74
  403. package/src/box-control/index.js +0 -15
  404. package/src/box-control/stories/index.js +0 -29
  405. package/src/box-control/utils.js +0 -7
  406. package/src/button/index.js +2 -4
  407. package/src/button/index.native.js +33 -18
  408. package/src/button/test/index.js +16 -1
  409. package/src/button-group/index.tsx +47 -0
  410. package/src/button-group/stories/index.tsx +41 -0
  411. package/src/button-group/types.ts +11 -0
  412. package/src/checkbox-control/README.md +10 -8
  413. package/src/checkbox-control/{index.js → index.tsx} +49 -14
  414. package/src/checkbox-control/stories/{index.js → index.tsx} +49 -27
  415. package/src/checkbox-control/types.ts +36 -0
  416. package/src/circular-option-picker/index.js +1 -2
  417. package/src/circular-option-picker/style.scss +1 -0
  418. package/src/color-palette/README.md +0 -1
  419. package/src/color-palette/index.js +6 -13
  420. package/src/color-palette/style.scss +3 -18
  421. package/src/color-palette/test/__snapshots__/index.js.snap +2 -3
  422. package/src/confirm-dialog/stories/index.js +87 -99
  423. package/src/date-time/README.md +13 -10
  424. package/src/date-time/{date.js → date.tsx} +49 -20
  425. package/src/date-time/{index.js → index.tsx} +31 -5
  426. package/src/date-time/stories/date.tsx +73 -0
  427. package/src/date-time/stories/index.tsx +75 -0
  428. package/src/date-time/stories/time.tsx +51 -0
  429. package/src/date-time/stories/utils.ts +9 -0
  430. package/src/date-time/test/date.tsx +127 -0
  431. package/src/date-time/test/{time.js → time.tsx} +34 -19
  432. package/src/date-time/test/{utils.js → utils.ts} +1 -1
  433. package/src/date-time/{time.js → time.tsx} +57 -46
  434. package/src/date-time/{timezone.js → timezone.tsx} +4 -3
  435. package/src/date-time/types.ts +106 -0
  436. package/src/date-time/utils.ts +20 -0
  437. package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -4
  438. package/src/disabled/index.js +5 -90
  439. package/src/draggable/index.native.js +215 -0
  440. package/src/draggable/style.native.scss +3 -0
  441. package/src/dropdown/index.js +9 -4
  442. package/src/dropdown/style.scss +1 -1
  443. package/src/focal-point-picker/index.native.js +3 -3
  444. package/src/form-file-upload/test/index.js +20 -13
  445. package/src/heading/hook.ts +1 -1
  446. package/src/heading/test/__snapshots__/index.js.snap +3 -3
  447. package/src/index.js +0 -1
  448. package/src/index.native.js +1 -0
  449. package/src/input-control/README.md +3 -3
  450. package/src/input-control/index.tsx +23 -3
  451. package/src/input-control/stories/index.tsx +63 -0
  452. package/src/input-control/styles/input-control-styles.tsx +20 -7
  453. package/src/input-control/types.ts +79 -2
  454. package/src/item-group/stories/index.js +22 -18
  455. package/src/menu-item/style.scss +10 -0
  456. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
  457. package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +9 -2
  458. package/src/mobile/bottom-sheet/index.native.js +1 -1
  459. package/src/mobile/bottom-sheet-select-control/index.native.js +8 -2
  460. package/src/mobile/html-text-input/index.native.js +45 -29
  461. package/src/mobile/html-text-input/style.android.scss +2 -15
  462. package/src/mobile/html-text-input/style.ios.scss +2 -15
  463. package/src/mobile/html-text-input/{style-common.native.scss → style.scss} +16 -0
  464. package/src/mobile/keyboard-aware-flat-list/index.android.js +15 -5
  465. package/src/mobile/keyboard-aware-flat-list/index.ios.js +75 -46
  466. package/src/mobile/link-settings/test/link-settings-navigation.native.js +9 -1
  467. package/src/navigation/styles/navigation-styles.js +5 -5
  468. package/src/navigator/stories/index.js +16 -10
  469. package/src/notice/index.native.js +44 -54
  470. package/src/notice/list.native.js +27 -51
  471. package/src/notice/style.native.scss +1 -0
  472. package/src/palette-edit/index.js +37 -9
  473. package/src/palette-edit/style.scss +0 -7
  474. package/src/palette-edit/test/index.js +63 -0
  475. package/src/panel/README.md +1 -1
  476. package/src/placeholder/test/index.js +7 -0
  477. package/src/popover/README.md +7 -9
  478. package/src/popover/index.js +242 -417
  479. package/src/popover/style.scss +20 -190
  480. package/src/popover/test/__snapshots__/index.js.snap +6 -18
  481. package/src/query-controls/README.md +2 -2
  482. package/src/resizable-box/resize-tooltip/utils.ts +4 -5
  483. package/src/sandbox/index.js +2 -2
  484. package/src/sandbox/index.native.js +1 -1
  485. package/src/select-control/README.md +2 -2
  486. package/src/select-control/index.tsx +30 -29
  487. package/src/select-control/stories/index.tsx +90 -0
  488. package/src/select-control/styles/select-control-styles.ts +16 -12
  489. package/src/select-control/test/{select-control.js → select-control.tsx} +2 -2
  490. package/src/select-control/types.ts +66 -1
  491. package/src/surface/styles.js +1 -1
  492. package/src/tab-panel/style.scss +1 -1
  493. package/src/text/hook.js +1 -1
  494. package/src/text/styles/text-mixins.native.js +2 -2
  495. package/src/text/styles.js +1 -1
  496. package/src/text/test/__snapshots__/{index.js.snap → index.tsx.snap} +16 -0
  497. package/src/text/test/{index.js → index.tsx} +12 -6
  498. package/src/text-control/index.tsx +84 -0
  499. package/src/text-control/stories/index.tsx +66 -0
  500. package/src/text-control/types.ts +29 -0
  501. package/src/toggle-group-control/test/__snapshots__/index.js.snap +4 -10
  502. package/src/toggle-group-control/toggle-group-control/component.tsx +7 -3
  503. package/src/toggle-group-control/toggle-group-control-option-icon/component.tsx +1 -5
  504. package/src/toolbar-group/style.scss +20 -0
  505. package/src/tools-panel/test/__snapshots__/index.js.snap +2 -2
  506. package/src/tools-panel/test/index.js +71 -18
  507. package/src/tools-panel/tools-panel-header/component.tsx +75 -33
  508. package/src/tools-panel/types.ts +0 -1
  509. package/src/tooltip/index.js +8 -2
  510. package/src/tooltip/style.scss +2 -4
  511. package/src/tooltip/test/index.js +6 -0
  512. package/src/tooltip/test/index.native.js +1 -1
  513. package/src/ui/spinner/component.js +1 -1
  514. package/src/ui/spinner/test/__snapshots__/index.js.snap +3 -3
  515. package/src/unit-control/index.tsx +2 -5
  516. package/src/unit-control/styles/unit-control-styles.ts +3 -13
  517. package/src/unit-control/test/__snapshots__/index.tsx.snap +33 -0
  518. package/src/unit-control/test/{index.js → index.tsx} +295 -166
  519. package/src/unit-control/test/{utils.js → utils.ts} +38 -19
  520. package/src/unit-control/types.ts +4 -1
  521. package/src/unit-control/utils.ts +5 -3
  522. package/src/utils/colors-values.js +18 -22
  523. package/tsconfig.json +14 -3
  524. package/tsconfig.tsbuildinfo +1 -1
  525. package/build/box-control/visualizer.js +0 -165
  526. package/build/box-control/visualizer.js.map +0 -1
  527. package/build/flyout/context.js +0 -23
  528. package/build/flyout/context.js.map +0 -1
  529. package/build/flyout/flyout/component.js +0 -106
  530. package/build/flyout/flyout/component.js.map +0 -1
  531. package/build/flyout/flyout/hook.js +0 -53
  532. package/build/flyout/flyout/hook.js.map +0 -1
  533. package/build/flyout/flyout/index.js +0 -24
  534. package/build/flyout/flyout/index.js.map +0 -1
  535. package/build/flyout/flyout-content/component.js +0 -65
  536. package/build/flyout/flyout-content/component.js.map +0 -1
  537. package/build/flyout/flyout-content/index.js +0 -16
  538. package/build/flyout/flyout-content/index.js.map +0 -1
  539. package/build/flyout/index.js +0 -16
  540. package/build/flyout/index.js.map +0 -1
  541. package/build/flyout/styles.js +0 -46
  542. package/build/flyout/styles.js.map +0 -1
  543. package/build/flyout/utils.js +0 -36
  544. package/build/flyout/utils.js.map +0 -1
  545. package/build/mobile/html-text-input/container.android.js +0 -41
  546. package/build/mobile/html-text-input/container.android.js.map +0 -1
  547. package/build/mobile/html-text-input/container.ios.js +0 -60
  548. package/build/mobile/html-text-input/container.ios.js.map +0 -1
  549. package/build/popover/utils.js +0 -322
  550. package/build/popover/utils.js.map +0 -1
  551. package/build-module/box-control/visualizer.js +0 -154
  552. package/build-module/box-control/visualizer.js.map +0 -1
  553. package/build-module/flyout/context.js +0 -11
  554. package/build-module/flyout/context.js.map +0 -1
  555. package/build-module/flyout/flyout/component.js +0 -89
  556. package/build-module/flyout/flyout/component.js.map +0 -1
  557. package/build-module/flyout/flyout/hook.js +0 -44
  558. package/build-module/flyout/flyout/hook.js.map +0 -1
  559. package/build-module/flyout/flyout/index.js +0 -3
  560. package/build-module/flyout/flyout/index.js.map +0 -1
  561. package/build-module/flyout/flyout-content/component.js +0 -51
  562. package/build-module/flyout/flyout-content/component.js.map +0 -1
  563. package/build-module/flyout/flyout-content/index.js +0 -2
  564. package/build-module/flyout/flyout-content/index.js.map +0 -1
  565. package/build-module/flyout/index.js +0 -2
  566. package/build-module/flyout/index.js.map +0 -1
  567. package/build-module/flyout/styles.js +0 -27
  568. package/build-module/flyout/styles.js.map +0 -1
  569. package/build-module/flyout/utils.js +0 -25
  570. package/build-module/flyout/utils.js.map +0 -1
  571. package/build-module/mobile/html-text-input/container.android.js +0 -29
  572. package/build-module/mobile/html-text-input/container.android.js.map +0 -1
  573. package/build-module/mobile/html-text-input/container.ios.js +0 -48
  574. package/build-module/mobile/html-text-input/container.ios.js.map +0 -1
  575. package/build-module/popover/utils.js +0 -308
  576. package/build-module/popover/utils.js.map +0 -1
  577. package/build-types/flyout/context.d.ts +0 -6
  578. package/build-types/flyout/context.d.ts.map +0 -1
  579. package/build-types/flyout/flyout/component.d.ts +0 -21
  580. package/build-types/flyout/flyout/component.d.ts.map +0 -1
  581. package/build-types/flyout/flyout/hook.d.ts +0 -270
  582. package/build-types/flyout/flyout/hook.d.ts.map +0 -1
  583. package/build-types/flyout/flyout/index.d.ts +0 -3
  584. package/build-types/flyout/flyout/index.d.ts.map +0 -1
  585. package/build-types/flyout/flyout-content/component.d.ts +0 -3
  586. package/build-types/flyout/flyout-content/component.d.ts.map +0 -1
  587. package/build-types/flyout/flyout-content/index.d.ts +0 -2
  588. package/build-types/flyout/flyout-content/index.d.ts.map +0 -1
  589. package/build-types/flyout/index.d.ts +0 -2
  590. package/build-types/flyout/index.d.ts.map +0 -1
  591. package/build-types/flyout/styles.d.ts +0 -22
  592. package/build-types/flyout/styles.d.ts.map +0 -1
  593. package/build-types/flyout/types.d.ts +0 -80
  594. package/build-types/flyout/types.d.ts.map +0 -1
  595. package/build-types/flyout/utils.d.ts +0 -8
  596. package/build-types/flyout/utils.d.ts.map +0 -1
  597. package/build-types/popover/utils.d.ts +0 -70
  598. package/build-types/popover/utils.d.ts.map +0 -1
  599. package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts +0 -19
  600. package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts.map +0 -1
  601. package/src/box-control/visualizer.js +0 -116
  602. package/src/button-group/index.js +0 -17
  603. package/src/button-group/stories/index.js +0 -21
  604. package/src/date-time/stories/date.js +0 -17
  605. package/src/date-time/stories/index.js +0 -72
  606. package/src/date-time/stories/time.js +0 -32
  607. package/src/date-time/test/date.js +0 -97
  608. package/src/date-time/utils.js +0 -18
  609. package/src/flyout/context.js +0 -10
  610. package/src/flyout/flyout/README.md +0 -98
  611. package/src/flyout/flyout/component.js +0 -111
  612. package/src/flyout/flyout/hook.js +0 -45
  613. package/src/flyout/flyout/index.js +0 -2
  614. package/src/flyout/flyout-content/component.js +0 -53
  615. package/src/flyout/flyout-content/index.js +0 -1
  616. package/src/flyout/index.js +0 -1
  617. package/src/flyout/stories/index.js +0 -24
  618. package/src/flyout/styles.ts +0 -41
  619. package/src/flyout/test/__snapshots__/index.js.snap +0 -186
  620. package/src/flyout/test/index.js +0 -103
  621. package/src/flyout/types.ts +0 -84
  622. package/src/flyout/utils.js +0 -23
  623. package/src/input-control/stories/index.js +0 -71
  624. package/src/mobile/html-text-input/container.android.js +0 -23
  625. package/src/mobile/html-text-input/container.ios.js +0 -50
  626. package/src/popover/test/utils.js +0 -304
  627. package/src/popover/utils.js +0 -396
  628. package/src/select-control/stories/index.js +0 -104
  629. package/src/text-control/index.js +0 -72
  630. package/src/text-control/stories/index.js +0 -46
@@ -13,13 +13,13 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
13
13
 
14
14
  var _classnames = _interopRequireDefault(require("classnames"));
15
15
 
16
- var _dom = require("@wordpress/dom");
16
+ var _reactDom = require("@floating-ui/react-dom");
17
17
 
18
18
  var _compose = require("@wordpress/compose");
19
19
 
20
20
  var _icons = require("@wordpress/icons");
21
21
 
22
- var _utils = require("./utils");
22
+ var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
23
23
 
24
24
  var _button = _interopRequireDefault(require("../button"));
25
25
 
@@ -51,368 +51,167 @@ var _animate = require("../animate");
51
51
  const SLOT_NAME = 'Popover';
52
52
  const slotNameContext = (0, _element.createContext)();
53
53
 
54
- function computeAnchorRect(anchorRefFallback, anchorRect, getAnchorRect) {
55
- let anchorRef = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
56
- let shouldAnchorIncludePadding = arguments.length > 4 ? arguments[4] : undefined;
57
- let container = arguments.length > 5 ? arguments[5] : undefined;
54
+ const positionToPlacement = position => {
55
+ const [x, y, z] = position.split(' ');
58
56
 
59
- if (anchorRect) {
60
- return anchorRect;
61
- }
62
-
63
- if (getAnchorRect) {
64
- if (!anchorRefFallback.current) {
65
- return;
66
- }
67
-
68
- const rect = getAnchorRect(anchorRefFallback.current);
69
- return (0, _utils.offsetIframe)(rect, rect.ownerDocument || anchorRefFallback.current.ownerDocument, container);
70
- }
71
-
72
- if (anchorRef !== false) {
73
- if (!anchorRef || !window.Range || !window.Element || !window.DOMRect) {
74
- return;
75
- } // Duck-type to check if `anchorRef` is an instance of Range
76
- // `anchorRef instanceof window.Range` checks will break across document boundaries
77
- // such as in an iframe.
78
-
79
-
80
- if (typeof (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.cloneRange) === 'function') {
81
- return (0, _utils.offsetIframe)((0, _dom.getRectangleFromRange)(anchorRef), anchorRef.endContainer.ownerDocument, container);
82
- } // Duck-type to check if `anchorRef` is an instance of Element
83
- // `anchorRef instanceof window.Element` checks will break across document boundaries
84
- // such as in an iframe.
85
-
86
-
87
- if (typeof (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.getBoundingClientRect) === 'function') {
88
- const rect = (0, _utils.offsetIframe)(anchorRef.getBoundingClientRect(), anchorRef.ownerDocument, container);
89
-
90
- if (shouldAnchorIncludePadding) {
91
- return rect;
92
- }
93
-
94
- return withoutPadding(rect, anchorRef);
95
- }
57
+ if (['top', 'bottom'].includes(x)) {
58
+ let suffix = '';
96
59
 
97
- const {
98
- top,
99
- bottom
100
- } = anchorRef;
101
- const topRect = top.getBoundingClientRect();
102
- const bottomRect = bottom.getBoundingClientRect();
103
- const rect = (0, _utils.offsetIframe)(new window.DOMRect(topRect.left, topRect.top, topRect.width, bottomRect.bottom - topRect.top), top.ownerDocument, container);
104
-
105
- if (shouldAnchorIncludePadding) {
106
- return rect;
60
+ if (!!z && z === 'left' || y === 'right') {
61
+ suffix = '-start';
62
+ } else if (!!z && z === 'right' || y === 'left') {
63
+ suffix = '-end';
107
64
  }
108
65
 
109
- return withoutPadding(rect, anchorRef);
110
- }
111
-
112
- if (!anchorRefFallback.current) {
113
- return;
114
- }
115
-
116
- const {
117
- parentNode
118
- } = anchorRefFallback.current;
119
- const rect = (0, _utils.offsetIframe)(parentNode.getBoundingClientRect(), parentNode.ownerDocument, container);
120
-
121
- if (shouldAnchorIncludePadding) {
122
- return rect;
66
+ return x + suffix;
123
67
  }
124
68
 
125
- return withoutPadding(rect, parentNode);
126
- }
127
-
128
- function getComputedStyle(node) {
129
- return node.ownerDocument.defaultView.getComputedStyle(node);
130
- }
69
+ return y;
70
+ };
131
71
 
132
- function withoutPadding(rect, element) {
133
- const {
134
- paddingTop,
135
- paddingBottom,
136
- paddingLeft,
137
- paddingRight
138
- } = getComputedStyle(element);
139
- const top = paddingTop ? parseInt(paddingTop, 10) : 0;
140
- const bottom = paddingBottom ? parseInt(paddingBottom, 10) : 0;
141
- const left = paddingLeft ? parseInt(paddingLeft, 10) : 0;
142
- const right = paddingRight ? parseInt(paddingRight, 10) : 0;
143
- return {
144
- x: rect.left + left,
145
- y: rect.top + top,
146
- width: rect.width - left - right,
147
- height: rect.height - top - bottom,
148
- left: rect.left + left,
149
- right: rect.right - right,
150
- top: rect.top + top,
151
- bottom: rect.bottom - bottom
152
- };
153
- }
154
- /**
155
- * Sets or removes an element attribute.
156
- *
157
- * @param {Element} element The element to modify.
158
- * @param {string} name The attribute name to set or remove.
159
- * @param {?string} value The value to set. A falsy value will remove the
160
- * attribute.
161
- */
72
+ const placementToAnimationOrigin = placement => {
73
+ const [a, b] = placement.split('-');
74
+ let x, y;
162
75
 
76
+ if (a === 'top' || a === 'bottom') {
77
+ x = a === 'top' ? 'bottom' : 'top';
78
+ y = 'middle';
163
79
 
164
- function setAttribute(element, name, value) {
165
- if (!value) {
166
- if (element.hasAttribute(name)) {
167
- element.removeAttribute(name);
80
+ if (b === 'start') {
81
+ y = 'left';
82
+ } else if (b === 'end') {
83
+ y = 'right';
168
84
  }
169
- } else if (element.getAttribute(name) !== value) {
170
- element.setAttribute(name, value);
171
- }
172
- }
173
- /**
174
- * Sets or removes an element style property.
175
- *
176
- * @param {Element} element The element to modify.
177
- * @param {string} property The property to set or remove.
178
- * @param {?string} value The value to set. A falsy value will remove the
179
- * property.
180
- */
181
-
182
-
183
- function setStyle(element, property) {
184
- let value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
185
-
186
- if (element.style[property] !== value) {
187
- element.style[property] = value;
188
85
  }
189
- }
190
- /**
191
- * Sets or removes an element class.
192
- *
193
- * @param {Element} element The element to modify.
194
- * @param {string} name The class to set or remove.
195
- * @param {boolean} toggle True to set the class, false to remove.
196
- */
197
86
 
87
+ if (a === 'left' || a === 'right') {
88
+ x = 'center';
89
+ y = a === 'left' ? 'right' : 'left';
198
90
 
199
- function setClass(element, name, toggle) {
200
- if (toggle) {
201
- if (!element.classList.contains(name)) {
202
- element.classList.add(name);
91
+ if (b === 'start') {
92
+ x = 'top';
93
+ } else if (b === 'end') {
94
+ x = 'bottom';
203
95
  }
204
- } else if (element.classList.contains(name)) {
205
- element.classList.remove(name);
206
- }
207
- }
208
-
209
- function getAnchorDocument(anchor) {
210
- if (!anchor) {
211
- return;
212
96
  }
213
97
 
214
- if (anchor.endContainer) {
215
- return anchor.endContainer.ownerDocument;
216
- }
217
-
218
- if (anchor.top) {
219
- return anchor.top.ownerDocument;
220
- }
221
-
222
- return anchor.ownerDocument;
223
- }
98
+ return x + ' ' + y;
99
+ };
224
100
 
225
101
  const Popover = (_ref, ref) => {
226
102
  let {
103
+ range,
104
+ animate = true,
227
105
  headerTitle,
228
106
  onClose,
229
107
  children,
230
108
  className,
231
109
  noArrow = true,
232
110
  isAlternate,
233
- // Disable reason: We generate the `...contentProps` rest as remainder
234
- // of props which aren't explicitly handled by this component.
235
-
236
- /* eslint-disable no-unused-vars */
237
- position = 'bottom right',
238
- range,
111
+ position,
112
+ placement = 'bottom-start',
113
+ offset,
239
114
  focusOnMount = 'firstElement',
240
115
  anchorRef,
241
- shouldAnchorIncludePadding,
242
116
  anchorRect,
243
117
  getAnchorRect,
244
118
  expandOnMobile,
245
- animate = true,
246
119
  onFocusOutside,
247
- __unstableStickyBoundaryElement,
248
120
  __unstableSlotName = SLOT_NAME,
249
121
  __unstableObserveElement,
250
- __unstableBoundaryParent,
251
122
  __unstableForcePosition,
252
- __unstableForceXAlignment,
253
- __unstableEditorCanvasWrapper,
254
-
255
- /* eslint-enable no-unused-vars */
256
123
  ...contentProps
257
124
  } = _ref;
258
- const anchorRefFallback = (0, _element.useRef)(null);
259
- const contentRef = (0, _element.useRef)(null);
260
- const containerRef = (0, _element.useRef)();
261
- const isMobileViewport = (0, _compose.useViewportMatch)('medium', '<');
262
- const [animateOrigin, setAnimateOrigin] = (0, _element.useState)();
263
125
 
264
- const slotName = (0, _element.useContext)(slotNameContext) || __unstableSlotName;
126
+ if (range) {
127
+ (0, _deprecated.default)('range prop in Popover component', {
128
+ since: '6.1',
129
+ version: '6.3'
130
+ });
131
+ }
265
132
 
266
- const slot = (0, _slotFill.useSlot)(slotName);
133
+ const arrowRef = (0, _element.useRef)(null);
134
+ const isMobileViewport = (0, _compose.useViewportMatch)('medium', '<');
267
135
  const isExpanded = expandOnMobile && isMobileViewport;
268
- const [containerResizeListener, contentSize] = (0, _compose.useResizeObserver)();
269
- noArrow = isExpanded || noArrow;
270
- (0, _element.useLayoutEffect)(() => {
271
- if (isExpanded) {
272
- setClass(containerRef.current, 'is-without-arrow', noArrow);
273
- setClass(containerRef.current, 'is-alternate', isAlternate);
274
- setAttribute(containerRef.current, 'data-x-axis');
275
- setAttribute(containerRef.current, 'data-y-axis');
276
- setStyle(containerRef.current, 'top');
277
- setStyle(containerRef.current, 'left');
278
- setStyle(contentRef.current, 'maxHeight');
279
- setStyle(contentRef.current, 'maxWidth');
280
- return;
136
+ const hasArrow = !isExpanded && !noArrow;
137
+ const usedPlacement = position ? positionToPlacement(position) : placement;
138
+ /**
139
+ * Offsets the the position of the popover when the anchor is inside an iframe.
140
+ */
141
+
142
+ const frameOffset = (0, _element.useMemo)(() => {
143
+ let ownerDocument = document;
144
+
145
+ if (anchorRef !== null && anchorRef !== void 0 && anchorRef.top) {
146
+ ownerDocument = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.top.ownerDocument;
147
+ } else if (anchorRef !== null && anchorRef !== void 0 && anchorRef.startContainer) {
148
+ ownerDocument = anchorRef.startContainer.ownerDocument;
149
+ } else if (anchorRef !== null && anchorRef !== void 0 && anchorRef.current) {
150
+ ownerDocument = anchorRef.current.ownerDocument;
151
+ } else if (anchorRef) {
152
+ // This one should be deprecated.
153
+ ownerDocument = anchorRef.ownerDocument;
154
+ } else if (anchorRect && anchorRect !== null && anchorRect !== void 0 && anchorRect.ownerDocument) {
155
+ ownerDocument = anchorRect.ownerDocument;
156
+ } else if (getAnchorRect) {
157
+ var _getAnchorRect$ownerD, _getAnchorRect;
158
+
159
+ ownerDocument = (_getAnchorRect$ownerD = (_getAnchorRect = getAnchorRect()) === null || _getAnchorRect === void 0 ? void 0 : _getAnchorRect.ownerDocument) !== null && _getAnchorRect$ownerD !== void 0 ? _getAnchorRect$ownerD : document;
281
160
  }
282
161
 
283
- const refresh = () => {
284
- if (!containerRef.current || !contentRef.current) {
285
- return;
286
- }
287
-
288
- let anchor = computeAnchorRect(anchorRefFallback, anchorRect, getAnchorRect, anchorRef, shouldAnchorIncludePadding, containerRef.current);
289
-
290
- if (!anchor) {
291
- return;
292
- }
293
-
294
- const {
295
- offsetParent,
296
- ownerDocument
297
- } = containerRef.current;
298
- let relativeOffsetTop = 0; // If there is a positioned ancestor element that is not the body,
299
- // subtract the position from the anchor rect. If the position of
300
- // the popover is fixed, the offset parent is null or the body
301
- // element, in which case the position is relative to the viewport.
302
- // See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
303
-
304
- if (offsetParent && offsetParent !== ownerDocument.body) {
305
- const offsetParentRect = offsetParent.getBoundingClientRect();
306
- relativeOffsetTop = offsetParentRect.top;
307
- anchor = new window.DOMRect(anchor.left - offsetParentRect.left, anchor.top - offsetParentRect.top, anchor.width, anchor.height);
308
- }
309
-
310
- let boundaryElement;
311
-
312
- if (__unstableBoundaryParent) {
313
- boundaryElement = containerRef.current.parentElement;
314
- }
315
-
316
- const usedContentSize = !contentSize.height ? contentRef.current.getBoundingClientRect() : contentSize;
317
- const {
318
- popoverTop,
319
- popoverLeft,
320
- xAxis,
321
- yAxis,
322
- contentHeight,
323
- contentWidth
324
- } = (0, _utils.computePopoverPosition)(anchor, usedContentSize, position, __unstableStickyBoundaryElement, containerRef.current, relativeOffsetTop, boundaryElement, __unstableForcePosition, __unstableForceXAlignment, __unstableEditorCanvasWrapper);
325
-
326
- if (typeof popoverTop === 'number' && typeof popoverLeft === 'number') {
327
- setStyle(containerRef.current, 'top', popoverTop + 'px');
328
- setStyle(containerRef.current, 'left', popoverLeft + 'px');
329
- }
330
-
331
- setClass(containerRef.current, 'is-without-arrow', noArrow || xAxis === 'center' && yAxis === 'middle');
332
- setClass(containerRef.current, 'is-alternate', isAlternate);
333
- setAttribute(containerRef.current, 'data-x-axis', xAxis);
334
- setAttribute(containerRef.current, 'data-y-axis', yAxis);
335
- setStyle(contentRef.current, 'maxHeight', typeof contentHeight === 'number' ? contentHeight + 'px' : '');
336
- setStyle(contentRef.current, 'maxWidth', typeof contentWidth === 'number' ? contentWidth + 'px' : ''); // Compute the animation position.
337
-
338
- const yAxisMapping = {
339
- top: 'bottom',
340
- bottom: 'top'
341
- };
342
- const xAxisMapping = {
343
- left: 'right',
344
- right: 'left'
345
- };
346
- const animateYAxis = yAxisMapping[yAxis] || 'middle';
347
- const animateXAxis = xAxisMapping[xAxis] || 'center';
348
- setAnimateOrigin(animateXAxis + ' ' + animateYAxis);
349
- };
350
-
351
- refresh();
352
- const {
353
- ownerDocument
354
- } = containerRef.current;
355
162
  const {
356
163
  defaultView
357
164
  } = ownerDocument;
358
- /*
359
- * There are sometimes we need to reposition or resize the popover that
360
- * are not handled by the resize/scroll window events (i.e. CSS changes
361
- * in the layout that changes the position of the anchor).
362
- *
363
- * For these situations, we refresh the popover every 0.5s
364
- */
365
-
366
- const intervalHandle = defaultView.setInterval(refresh, 500);
367
- let rafId;
368
-
369
- const refreshOnAnimationFrame = () => {
370
- defaultView.cancelAnimationFrame(rafId);
371
- rafId = defaultView.requestAnimationFrame(refresh);
372
- }; // Sometimes a click trigger a layout change that affects the popover
373
- // position. This is an opportunity to immediately refresh rather than
374
- // at the interval.
375
-
376
-
377
- defaultView.addEventListener('click', refreshOnAnimationFrame);
378
- defaultView.addEventListener('resize', refresh);
379
- defaultView.addEventListener('scroll', refresh, true);
380
- const anchorDocument = getAnchorDocument(anchorRef); // If the anchor is within an iframe, the popover position also needs
381
- // to refrest when the iframe content is scrolled or resized.
382
-
383
- if (anchorDocument && anchorDocument !== ownerDocument) {
384
- anchorDocument.defaultView.addEventListener('resize', refresh);
385
- anchorDocument.defaultView.addEventListener('scroll', refresh, true);
165
+ const {
166
+ frameElement
167
+ } = defaultView;
168
+
169
+ if (!frameElement || ownerDocument === document) {
170
+ return undefined;
386
171
  }
387
172
 
388
- let observer;
173
+ const iframeRect = frameElement.getBoundingClientRect();
174
+ return {
175
+ name: 'iframeOffset',
176
+
177
+ fn(_ref2) {
178
+ let {
179
+ x,
180
+ y
181
+ } = _ref2;
182
+ return {
183
+ x: x + iframeRect.left,
184
+ y: y + iframeRect.top
185
+ };
186
+ }
389
187
 
390
- if (__unstableObserveElement) {
391
- observer = new defaultView.MutationObserver(refresh);
392
- observer.observe(__unstableObserveElement, {
393
- attributes: true
188
+ };
189
+ }, [anchorRef, anchorRect, getAnchorRect]);
190
+ const middlewares = [frameOffset, offset ? (0, _reactDom.offset)(offset) : undefined, __unstableForcePosition ? undefined : (0, _reactDom.flip)(), __unstableForcePosition ? undefined : (0, _reactDom.size)({
191
+ apply(_ref3) {
192
+ let {
193
+ width,
194
+ height
195
+ } = _ref3;
196
+ if (!refs.floating.current) return;
197
+ Object.assign(refs.floating.current.firstChild.style, {
198
+ maxWidth: `${width}px`,
199
+ maxHeight: `${height}px`,
200
+ overflow: 'auto'
394
201
  });
395
202
  }
396
203
 
397
- return () => {
398
- defaultView.clearInterval(intervalHandle);
399
- defaultView.removeEventListener('resize', refresh);
400
- defaultView.removeEventListener('scroll', refresh, true);
401
- defaultView.removeEventListener('click', refreshOnAnimationFrame);
402
- defaultView.cancelAnimationFrame(rafId);
403
-
404
- if (anchorDocument && anchorDocument !== ownerDocument) {
405
- var _anchorDocument$defau, _anchorDocument$defau2;
204
+ }),, (0, _reactDom.shift)({
205
+ crossAxis: true,
206
+ limiter: (0, _reactDom.limitShift)()
207
+ }), hasArrow ? (0, _reactDom.arrow)({
208
+ element: arrowRef
209
+ }) : undefined].filter(m => !!m);
210
+ const anchorRefFallback = (0, _element.useRef)(null);
406
211
 
407
- (_anchorDocument$defau = anchorDocument.defaultView) === null || _anchorDocument$defau === void 0 ? void 0 : _anchorDocument$defau.removeEventListener('resize', refresh);
408
- (_anchorDocument$defau2 = anchorDocument.defaultView) === null || _anchorDocument$defau2 === void 0 ? void 0 : _anchorDocument$defau2.removeEventListener('scroll', refresh, true);
409
- }
212
+ const slotName = (0, _element.useContext)(slotNameContext) || __unstableSlotName;
410
213
 
411
- if (observer) {
412
- observer.disconnect();
413
- }
414
- };
415
- }, [isExpanded, anchorRect, getAnchorRect, anchorRef, shouldAnchorIncludePadding, position, contentSize, __unstableStickyBoundaryElement, __unstableObserveElement, __unstableBoundaryParent]);
214
+ const slot = (0, _slotFill.useSlot)(slotName);
416
215
 
417
216
  const onDialogClose = (type, event) => {
418
217
  // Ideally the popover should have just a single onClose prop and
@@ -429,12 +228,104 @@ const Popover = (_ref, ref) => {
429
228
  __unstableOnClose: onDialogClose,
430
229
  onClose: onDialogClose
431
230
  });
432
- const mergedRefs = (0, _compose.useMergeRefs)([containerRef, dialogRef, ref]);
231
+ const {
232
+ x,
233
+ y,
234
+ reference,
235
+ floating,
236
+ strategy,
237
+ refs,
238
+ update,
239
+ placement: placementData,
240
+ middlewareData: {
241
+ arrow: arrowData = {}
242
+ }
243
+ } = (0, _reactDom.useFloating)({
244
+ placement: usedPlacement,
245
+ middleware: middlewares
246
+ });
247
+ const staticSide = {
248
+ top: 'bottom',
249
+ right: 'left',
250
+ bottom: 'top',
251
+ left: 'right'
252
+ }[placementData.split('-')[0]];
253
+ const mergedRefs = (0, _compose.useMergeRefs)([floating, dialogRef, ref]); // Updates references
254
+
255
+ (0, _element.useLayoutEffect)(() => {
256
+ // No ref or position have been passed
257
+ let usedRef;
258
+
259
+ if (anchorRef !== null && anchorRef !== void 0 && anchorRef.top) {
260
+ usedRef = {
261
+ getBoundingClientRect() {
262
+ const topRect = anchorRef.top.getBoundingClientRect();
263
+ const bottomRect = anchorRef.bottom.getBoundingClientRect();
264
+ return new window.DOMRect(topRect.x, topRect.y, topRect.width, bottomRect.bottom - topRect.top);
265
+ }
266
+
267
+ };
268
+ } else if (anchorRef !== null && anchorRef !== void 0 && anchorRef.current) {
269
+ usedRef = anchorRef.current;
270
+ } else if (anchorRef) {
271
+ usedRef = anchorRef;
272
+ } else if (anchorRect) {
273
+ usedRef = {
274
+ getBoundingClientRect() {
275
+ return anchorRect;
276
+ }
277
+
278
+ };
279
+ } else if (getAnchorRect) {
280
+ usedRef = {
281
+ getBoundingClientRect() {
282
+ var _rect$x, _rect$y, _rect$height, _rect$width;
283
+
284
+ const rect = getAnchorRect();
285
+ return { ...rect,
286
+ x: (_rect$x = rect.x) !== null && _rect$x !== void 0 ? _rect$x : rect.left,
287
+ y: (_rect$y = rect.y) !== null && _rect$y !== void 0 ? _rect$y : rect.top,
288
+ height: (_rect$height = rect.height) !== null && _rect$height !== void 0 ? _rect$height : rect.bottom - rect.top,
289
+ width: (_rect$width = rect.width) !== null && _rect$width !== void 0 ? _rect$width : rect.right - rect.left
290
+ };
291
+ }
292
+
293
+ };
294
+ } else if (anchorRefFallback.current) {
295
+ usedRef = anchorRefFallback.current;
296
+ }
297
+
298
+ if (!usedRef) {
299
+ return;
300
+ }
301
+
302
+ reference(usedRef);
303
+
304
+ if (!refs.floating.current) {
305
+ return;
306
+ }
307
+
308
+ return (0, _reactDom.autoUpdate)(usedRef, refs.floating.current, update);
309
+ }, [anchorRef, anchorRect, getAnchorRect]); // This is only needed for a smoth transition when moving blocks.
310
+
311
+ (0, _element.useLayoutEffect)(() => {
312
+ if (!__unstableObserveElement) {
313
+ return;
314
+ }
315
+
316
+ const observer = new window.MutationObserver(update);
317
+ observer.observe(__unstableObserveElement, {
318
+ attributes: true
319
+ });
320
+ return () => {
321
+ observer.disconnect();
322
+ };
323
+ }, [__unstableObserveElement]);
433
324
  /** @type {false | string} */
434
325
 
435
- const animateClassName = Boolean(animate && animateOrigin) && (0, _animate.getAnimateClassName)({
326
+ const animateClassName = !!animate && (0, _animate.getAnimateClassName)({
436
327
  type: 'appear',
437
- origin: animateOrigin
328
+ origin: placementToAnimationOrigin(placementData)
438
329
  }); // Disable reason: We care to capture the _bubbled_ events from inputs
439
330
  // within popover as inferring close intent.
440
331
 
@@ -443,13 +334,17 @@ const Popover = (_ref, ref) => {
443
334
  (0, _element.createElement)("div", (0, _extends2.default)({
444
335
  className: (0, _classnames.default)('components-popover', className, animateClassName, {
445
336
  'is-expanded': isExpanded,
446
- 'is-without-arrow': noArrow,
447
337
  'is-alternate': isAlternate
448
338
  })
449
339
  }, contentProps, {
450
340
  ref: mergedRefs
451
341
  }, dialogProps, {
452
- tabIndex: "-1"
342
+ tabIndex: "-1",
343
+ style: isExpanded ? undefined : {
344
+ position: strategy,
345
+ left: Number.isNaN(x) ? 0 : x,
346
+ top: Number.isNaN(y) ? 0 : y
347
+ }
453
348
  }), isExpanded && (0, _element.createElement)(_scrollLock.default, null), isExpanded && (0, _element.createElement)("div", {
454
349
  className: "components-popover__header"
455
350
  }, (0, _element.createElement)("span", {
@@ -459,13 +354,18 @@ const Popover = (_ref, ref) => {
459
354
  icon: _icons.close,
460
355
  onClick: onClose
461
356
  })), (0, _element.createElement)("div", {
462
- ref: contentRef,
463
357
  className: "components-popover__content"
464
- }, (0, _element.createElement)("div", {
358
+ }, children), hasArrow && (0, _element.createElement)("div", {
359
+ className: "components-popover__arrow",
360
+ ref: arrowRef,
465
361
  style: {
466
- position: 'relative'
362
+ left: !(arrowData !== null && arrowData !== void 0 && arrowData.x) || Number.isNaN(arrowData === null || arrowData === void 0 ? void 0 : arrowData.x) ? 0 : arrowData.x,
363
+ top: !(arrowData !== null && arrowData !== void 0 && arrowData.y) || Number.isNaN(arrowData === null || arrowData === void 0 ? void 0 : arrowData.y) ? 0 : arrowData.y,
364
+ right: undefined,
365
+ bottom: undefined,
366
+ [staticSide]: '-4px'
467
367
  }
468
- }, containerResizeListener, children)));
368
+ }));
469
369
 
470
370
  if (slot.ref) {
471
371
  content = (0, _element.createElement)(_slotFill.Fill, {
@@ -484,10 +384,10 @@ const Popover = (_ref, ref) => {
484
384
 
485
385
  const PopoverContainer = (0, _element.forwardRef)(Popover);
486
386
 
487
- function PopoverSlot(_ref2, ref) {
387
+ function PopoverSlot(_ref4, ref) {
488
388
  let {
489
389
  name = SLOT_NAME
490
- } = _ref2;
390
+ } = _ref4;
491
391
  return (0, _element.createElement)(_slotFill.Slot, {
492
392
  bubblesVirtually: true,
493
393
  name: name,