@wordpress/components 28.6.0 → 28.8.1-next.1f6eadc42.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 (652) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/CONTRIBUTING.md +42 -19
  3. package/build/alignment-matrix-control/cell.js +4 -7
  4. package/build/alignment-matrix-control/cell.js.map +1 -1
  5. package/build/alignment-matrix-control/icon.js +31 -19
  6. package/build/alignment-matrix-control/icon.js.map +1 -1
  7. package/build/alignment-matrix-control/index.js +55 -51
  8. package/build/alignment-matrix-control/index.js.map +1 -1
  9. package/build/alignment-matrix-control/styles.js +73 -0
  10. package/build/alignment-matrix-control/styles.js.map +1 -0
  11. package/build/alignment-matrix-control/types.js.map +1 -1
  12. package/build/angle-picker-control/angle-circle.js +9 -9
  13. package/build/angle-picker-control/angle-circle.js.map +1 -1
  14. package/build/border-control/border-control/component.js +18 -13
  15. package/build/border-control/border-control/component.js.map +1 -1
  16. package/build/box-control/utils.js +1 -1
  17. package/build/box-control/utils.js.map +1 -1
  18. package/build/circular-option-picker/circular-option-picker-option.js +15 -9
  19. package/build/circular-option-picker/circular-option-picker-option.js.map +1 -1
  20. package/build/circular-option-picker/circular-option-picker.js +15 -12
  21. package/build/circular-option-picker/circular-option-picker.js.map +1 -1
  22. package/build/circular-option-picker/types.js.map +1 -1
  23. package/build/clipboard-button/index.js +6 -6
  24. package/build/clipboard-button/index.js.map +1 -1
  25. package/build/color-palette/utils.js +1 -2
  26. package/build/color-palette/utils.js.map +1 -1
  27. package/build/color-picker/color-copy-button.js +8 -8
  28. package/build/color-picker/color-copy-button.js.map +1 -1
  29. package/build/color-picker/hex-input.js +8 -8
  30. package/build/color-picker/hex-input.js.map +1 -1
  31. package/build/color-picker/input-with-slider.js +8 -8
  32. package/build/color-picker/input-with-slider.js.map +1 -1
  33. package/build/color-picker/styles.js +8 -8
  34. package/build/color-picker/styles.js.map +1 -1
  35. package/build/combobox-control/types.js.map +1 -1
  36. package/build/composite/context.js +1 -1
  37. package/build/composite/context.js.map +1 -1
  38. package/build/composite/group-label.js +33 -0
  39. package/build/composite/group-label.js.map +1 -0
  40. package/build/composite/group.js +33 -0
  41. package/build/composite/group.js.map +1 -0
  42. package/build/composite/hover.js +33 -0
  43. package/build/composite/hover.js.map +1 -0
  44. package/build/composite/index.js +63 -118
  45. package/build/composite/index.js.map +1 -1
  46. package/build/composite/item.js +33 -0
  47. package/build/composite/item.js.map +1 -0
  48. package/build/composite/legacy/index.js +59 -7
  49. package/build/composite/legacy/index.js.map +1 -1
  50. package/build/composite/row.js +33 -0
  51. package/build/composite/row.js.map +1 -0
  52. package/build/composite/typeahead.js +33 -0
  53. package/build/composite/typeahead.js.map +1 -0
  54. package/build/composite/types.js.map +1 -1
  55. package/build/custom-gradient-picker/gradient-bar/control-points.js +8 -8
  56. package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  57. package/build/custom-select-control-v2/styles.js +12 -14
  58. package/build/custom-select-control-v2/styles.js.map +1 -1
  59. package/build/date-time/date/index.js +1 -1
  60. package/build/date-time/date/index.js.map +1 -1
  61. package/build/date-time/date/styles.js +37 -26
  62. package/build/date-time/date/styles.js.map +1 -1
  63. package/build/date-time/date/use-lilius/index.js +163 -0
  64. package/build/date-time/date/use-lilius/index.js.map +1 -0
  65. package/build/date-time/time/time-input/index.js +17 -19
  66. package/build/date-time/time/time-input/index.js.map +1 -1
  67. package/build/dimension-control/index.js +6 -1
  68. package/build/dimension-control/index.js.map +1 -1
  69. package/build/draggable/index.js +4 -4
  70. package/build/draggable/index.js.map +1 -1
  71. package/build/dropdown-menu-v2/checkbox-item.js +69 -0
  72. package/build/dropdown-menu-v2/checkbox-item.js.map +1 -0
  73. package/build/dropdown-menu-v2/context.js +17 -0
  74. package/build/dropdown-menu-v2/context.js.map +1 -0
  75. package/build/dropdown-menu-v2/group-label.js +40 -0
  76. package/build/dropdown-menu-v2/group-label.js.map +1 -0
  77. package/build/dropdown-menu-v2/group.js +29 -0
  78. package/build/dropdown-menu-v2/group.js.map +1 -0
  79. package/build/dropdown-menu-v2/index.js +58 -146
  80. package/build/dropdown-menu-v2/index.js.map +1 -1
  81. package/build/dropdown-menu-v2/item-help-text.js +27 -0
  82. package/build/dropdown-menu-v2/item-help-text.js.map +1 -0
  83. package/build/dropdown-menu-v2/item-label.js +27 -0
  84. package/build/dropdown-menu-v2/item-label.js.map +1 -0
  85. package/build/dropdown-menu-v2/item.js +53 -0
  86. package/build/dropdown-menu-v2/item.js.map +1 -0
  87. package/build/dropdown-menu-v2/radio-item.js +79 -0
  88. package/build/dropdown-menu-v2/radio-item.js.map +1 -0
  89. package/build/dropdown-menu-v2/separator.js +30 -0
  90. package/build/dropdown-menu-v2/separator.js.map +1 -0
  91. package/build/dropdown-menu-v2/styles.js +54 -78
  92. package/build/dropdown-menu-v2/styles.js.map +1 -1
  93. package/build/dropdown-menu-v2/types.js.map +1 -1
  94. package/build/dropdown-menu-v2/use-temporary-focus-visible-fix.js +27 -0
  95. package/build/dropdown-menu-v2/use-temporary-focus-visible-fix.js.map +1 -0
  96. package/build/focal-point-picker/styles/focal-point-style.js +7 -2
  97. package/build/focal-point-picker/styles/focal-point-style.js.map +1 -1
  98. package/build/form-token-field/types.js.map +1 -1
  99. package/build/index.js +13 -0
  100. package/build/index.js.map +1 -1
  101. package/build/input-control/index.js +2 -2
  102. package/build/input-control/index.js.map +1 -1
  103. package/build/input-control/input-base.js +5 -10
  104. package/build/input-control/input-base.js.map +1 -1
  105. package/build/input-control/input-prefix-wrapper.js +3 -3
  106. package/build/input-control/input-prefix-wrapper.js.map +1 -1
  107. package/build/input-control/input-suffix-wrapper.js +2 -3
  108. package/build/input-control/input-suffix-wrapper.js.map +1 -1
  109. package/build/input-control/reducer/reducer.js +8 -8
  110. package/build/input-control/reducer/reducer.js.map +1 -1
  111. package/build/input-control/styles/input-control-styles.js +75 -45
  112. package/build/input-control/styles/input-control-styles.js.map +1 -1
  113. package/build/input-control/types.js.map +1 -1
  114. package/build/input-control/utils.js +3 -3
  115. package/build/input-control/utils.js.map +1 -1
  116. package/build/item-group/styles.js +10 -10
  117. package/build/item-group/styles.js.map +1 -1
  118. package/build/modal/index.js +16 -9
  119. package/build/modal/index.js.map +1 -1
  120. package/build/navigation/index.js +4 -4
  121. package/build/navigation/index.js.map +1 -1
  122. package/build/navigation/styles/navigation-styles.js +13 -13
  123. package/build/navigation/styles/navigation-styles.js.map +1 -1
  124. package/build/navigator/index.js +12 -13
  125. package/build/navigator/index.js.map +1 -1
  126. package/build/navigator/navigator-back-button/hook.js +2 -2
  127. package/build/navigator/navigator-back-button/hook.js.map +1 -1
  128. package/build/navigator/navigator-button/hook.js +2 -2
  129. package/build/navigator/navigator-button/hook.js.map +1 -1
  130. package/build/navigator/navigator-provider/component.js +99 -67
  131. package/build/navigator/navigator-provider/component.js.map +1 -1
  132. package/build/navigator/navigator-screen/component.js +5 -0
  133. package/build/navigator/navigator-screen/component.js.map +1 -1
  134. package/build/navigator/navigator-to-parent-button/component.js +2 -2
  135. package/build/navigator/navigator-to-parent-button/component.js.map +1 -1
  136. package/build/navigator/types.js.map +1 -1
  137. package/build/navigator/use-navigator.js +1 -2
  138. package/build/navigator/use-navigator.js.map +1 -1
  139. package/build/palette-edit/index.js +2 -2
  140. package/build/palette-edit/index.js.map +1 -1
  141. package/build/private-apis.js +1 -14
  142. package/build/private-apis.js.map +1 -1
  143. package/build/range-control/styles/range-control-styles.js +30 -30
  144. package/build/range-control/styles/range-control-styles.js.map +1 -1
  145. package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +4 -4
  146. package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
  147. package/build/select-control/styles/select-control-styles.js +12 -12
  148. package/build/select-control/styles/select-control-styles.js.map +1 -1
  149. package/build/slot-fill/bubbles-virtually/fill.js +4 -4
  150. package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
  151. package/build/slot-fill/index.js +1 -0
  152. package/build/slot-fill/index.js.map +1 -1
  153. package/build/snackbar/index.js +4 -4
  154. package/build/snackbar/index.js.map +1 -1
  155. package/build/tabs/index.js +4 -4
  156. package/build/tabs/index.js.map +1 -1
  157. package/build/tabs/styles.js +3 -3
  158. package/build/tabs/styles.js.map +1 -1
  159. package/build/tabs/tablist.js +5 -4
  160. package/build/tabs/tablist.js.map +1 -1
  161. package/build/toggle-group-control/toggle-group-control/utils.js +6 -6
  162. package/build/toggle-group-control/toggle-group-control/utils.js.map +1 -1
  163. package/build/tools-panel/tools-panel/hook.js +6 -6
  164. package/build/tools-panel/tools-panel/hook.js.map +1 -1
  165. package/build/unit-control/styles/unit-control-styles.js +7 -7
  166. package/build/unit-control/styles/unit-control-styles.js.map +1 -1
  167. package/build/utils/config-values.js +6 -4
  168. package/build/utils/config-values.js.map +1 -1
  169. package/build/utils/element-rect.js +73 -105
  170. package/build/utils/element-rect.js.map +1 -1
  171. package/build/utils/hooks/use-update-effect.js +4 -4
  172. package/build/utils/hooks/use-update-effect.js.map +1 -1
  173. package/build-module/alignment-matrix-control/cell.js +2 -5
  174. package/build-module/alignment-matrix-control/cell.js.map +1 -1
  175. package/build-module/alignment-matrix-control/icon.js +31 -19
  176. package/build-module/alignment-matrix-control/icon.js.map +1 -1
  177. package/build-module/alignment-matrix-control/index.js +55 -50
  178. package/build-module/alignment-matrix-control/index.js.map +1 -1
  179. package/build-module/alignment-matrix-control/styles.js +70 -0
  180. package/build-module/alignment-matrix-control/styles.js.map +1 -0
  181. package/build-module/alignment-matrix-control/types.js.map +1 -1
  182. package/build-module/angle-picker-control/angle-circle.js +9 -9
  183. package/build-module/angle-picker-control/angle-circle.js.map +1 -1
  184. package/build-module/border-control/border-control/component.js +18 -13
  185. package/build-module/border-control/border-control/component.js.map +1 -1
  186. package/build-module/box-control/utils.js +1 -1
  187. package/build-module/box-control/utils.js.map +1 -1
  188. package/build-module/circular-option-picker/circular-option-picker-option.js +16 -10
  189. package/build-module/circular-option-picker/circular-option-picker-option.js.map +1 -1
  190. package/build-module/circular-option-picker/circular-option-picker.js +16 -13
  191. package/build-module/circular-option-picker/circular-option-picker.js.map +1 -1
  192. package/build-module/circular-option-picker/types.js.map +1 -1
  193. package/build-module/clipboard-button/index.js +6 -6
  194. package/build-module/clipboard-button/index.js.map +1 -1
  195. package/build-module/color-palette/utils.js +1 -2
  196. package/build-module/color-palette/utils.js.map +1 -1
  197. package/build-module/color-picker/color-copy-button.js +8 -8
  198. package/build-module/color-picker/color-copy-button.js.map +1 -1
  199. package/build-module/color-picker/hex-input.js +7 -8
  200. package/build-module/color-picker/hex-input.js.map +1 -1
  201. package/build-module/color-picker/input-with-slider.js +7 -8
  202. package/build-module/color-picker/input-with-slider.js.map +1 -1
  203. package/build-module/color-picker/styles.js +8 -8
  204. package/build-module/color-picker/styles.js.map +1 -1
  205. package/build-module/combobox-control/types.js.map +1 -1
  206. package/build-module/composite/context.js +1 -1
  207. package/build-module/composite/context.js.map +1 -1
  208. package/build-module/composite/group-label.js +25 -0
  209. package/build-module/composite/group-label.js.map +1 -0
  210. package/build-module/composite/group.js +25 -0
  211. package/build-module/composite/group.js.map +1 -0
  212. package/build-module/composite/hover.js +25 -0
  213. package/build-module/composite/hover.js.map +1 -0
  214. package/build-module/composite/index.js +64 -118
  215. package/build-module/composite/index.js.map +1 -1
  216. package/build-module/composite/item.js +25 -0
  217. package/build-module/composite/item.js.map +1 -0
  218. package/build-module/composite/legacy/index.js +57 -8
  219. package/build-module/composite/legacy/index.js.map +1 -1
  220. package/build-module/composite/row.js +25 -0
  221. package/build-module/composite/row.js.map +1 -0
  222. package/build-module/composite/typeahead.js +25 -0
  223. package/build-module/composite/typeahead.js.map +1 -0
  224. package/build-module/composite/types.js.map +1 -1
  225. package/build-module/custom-gradient-picker/gradient-bar/control-points.js +8 -8
  226. package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  227. package/build-module/custom-select-control-v2/styles.js +12 -14
  228. package/build-module/custom-select-control-v2/styles.js.map +1 -1
  229. package/build-module/date-time/date/index.js +1 -2
  230. package/build-module/date-time/date/index.js.map +1 -1
  231. package/build-module/date-time/date/styles.js +33 -26
  232. package/build-module/date-time/date/styles.js.map +1 -1
  233. package/build-module/date-time/date/use-lilius/index.js +158 -0
  234. package/build-module/date-time/date/use-lilius/index.js.map +1 -0
  235. package/build-module/date-time/time/time-input/index.js +17 -19
  236. package/build-module/date-time/time/time-input/index.js.map +1 -1
  237. package/build-module/dimension-control/index.js +6 -1
  238. package/build-module/dimension-control/index.js.map +1 -1
  239. package/build-module/draggable/index.js +4 -4
  240. package/build-module/draggable/index.js.map +1 -1
  241. package/build-module/dropdown-menu-v2/checkbox-item.js +62 -0
  242. package/build-module/dropdown-menu-v2/checkbox-item.js.map +1 -0
  243. package/build-module/dropdown-menu-v2/context.js +11 -0
  244. package/build-module/dropdown-menu-v2/context.js.map +1 -0
  245. package/build-module/dropdown-menu-v2/group-label.js +32 -0
  246. package/build-module/dropdown-menu-v2/group-label.js.map +1 -0
  247. package/build-module/dropdown-menu-v2/group.js +21 -0
  248. package/build-module/dropdown-menu-v2/group.js.map +1 -0
  249. package/build-module/dropdown-menu-v2/index.js +57 -144
  250. package/build-module/dropdown-menu-v2/index.js.map +1 -1
  251. package/build-module/dropdown-menu-v2/item-help-text.js +19 -0
  252. package/build-module/dropdown-menu-v2/item-help-text.js.map +1 -0
  253. package/build-module/dropdown-menu-v2/item-label.js +19 -0
  254. package/build-module/dropdown-menu-v2/item-label.js.map +1 -0
  255. package/build-module/dropdown-menu-v2/item.js +46 -0
  256. package/build-module/dropdown-menu-v2/item.js.map +1 -0
  257. package/build-module/dropdown-menu-v2/radio-item.js +72 -0
  258. package/build-module/dropdown-menu-v2/radio-item.js.map +1 -0
  259. package/build-module/dropdown-menu-v2/separator.js +22 -0
  260. package/build-module/dropdown-menu-v2/separator.js.map +1 -0
  261. package/build-module/dropdown-menu-v2/styles.js +54 -78
  262. package/build-module/dropdown-menu-v2/styles.js.map +1 -1
  263. package/build-module/dropdown-menu-v2/types.js.map +1 -1
  264. package/build-module/dropdown-menu-v2/use-temporary-focus-visible-fix.js +20 -0
  265. package/build-module/dropdown-menu-v2/use-temporary-focus-visible-fix.js.map +1 -0
  266. package/build-module/focal-point-picker/styles/focal-point-style.js +6 -2
  267. package/build-module/focal-point-picker/styles/focal-point-style.js.map +1 -1
  268. package/build-module/form-token-field/types.js.map +1 -1
  269. package/build-module/index.js +3 -1
  270. package/build-module/index.js.map +1 -1
  271. package/build-module/input-control/index.js +2 -2
  272. package/build-module/input-control/index.js.map +1 -1
  273. package/build-module/input-control/input-base.js +6 -11
  274. package/build-module/input-control/input-base.js.map +1 -1
  275. package/build-module/input-control/input-prefix-wrapper.js +4 -3
  276. package/build-module/input-control/input-prefix-wrapper.js.map +1 -1
  277. package/build-module/input-control/input-suffix-wrapper.js +3 -3
  278. package/build-module/input-control/input-suffix-wrapper.js.map +1 -1
  279. package/build-module/input-control/reducer/reducer.js +8 -8
  280. package/build-module/input-control/reducer/reducer.js.map +1 -1
  281. package/build-module/input-control/styles/input-control-styles.js +74 -44
  282. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  283. package/build-module/input-control/types.js.map +1 -1
  284. package/build-module/input-control/utils.js +3 -3
  285. package/build-module/input-control/utils.js.map +1 -1
  286. package/build-module/item-group/styles.js +10 -10
  287. package/build-module/item-group/styles.js.map +1 -1
  288. package/build-module/modal/index.js +17 -9
  289. package/build-module/modal/index.js.map +1 -1
  290. package/build-module/navigation/index.js +4 -4
  291. package/build-module/navigation/index.js.map +1 -1
  292. package/build-module/navigation/styles/navigation-styles.js +14 -14
  293. package/build-module/navigation/styles/navigation-styles.js.map +1 -1
  294. package/build-module/navigator/index.js +6 -6
  295. package/build-module/navigator/index.js.map +1 -1
  296. package/build-module/navigator/navigator-back-button/hook.js +1 -1
  297. package/build-module/navigator/navigator-back-button/hook.js.map +1 -1
  298. package/build-module/navigator/navigator-button/hook.js +1 -1
  299. package/build-module/navigator/navigator-button/hook.js.map +1 -1
  300. package/build-module/navigator/navigator-provider/component.js +99 -67
  301. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  302. package/build-module/navigator/navigator-screen/component.js +4 -0
  303. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  304. package/build-module/navigator/navigator-to-parent-button/component.js +1 -1
  305. package/build-module/navigator/navigator-to-parent-button/component.js.map +1 -1
  306. package/build-module/navigator/types.js.map +1 -1
  307. package/build-module/navigator/use-navigator.js +1 -2
  308. package/build-module/navigator/use-navigator.js.map +1 -1
  309. package/build-module/palette-edit/index.js +2 -2
  310. package/build-module/palette-edit/index.js.map +1 -1
  311. package/build-module/private-apis.js +1 -14
  312. package/build-module/private-apis.js.map +1 -1
  313. package/build-module/range-control/styles/range-control-styles.js +31 -31
  314. package/build-module/range-control/styles/range-control-styles.js.map +1 -1
  315. package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +5 -5
  316. package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
  317. package/build-module/select-control/styles/select-control-styles.js +13 -13
  318. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  319. package/build-module/slot-fill/bubbles-virtually/fill.js +4 -4
  320. package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
  321. package/build-module/slot-fill/index.js +1 -0
  322. package/build-module/slot-fill/index.js.map +1 -1
  323. package/build-module/snackbar/index.js +4 -4
  324. package/build-module/snackbar/index.js.map +1 -1
  325. package/build-module/tabs/index.js +4 -4
  326. package/build-module/tabs/index.js.map +1 -1
  327. package/build-module/tabs/styles.js +4 -4
  328. package/build-module/tabs/styles.js.map +1 -1
  329. package/build-module/tabs/tablist.js +5 -4
  330. package/build-module/tabs/tablist.js.map +1 -1
  331. package/build-module/toggle-group-control/toggle-group-control/utils.js +6 -6
  332. package/build-module/toggle-group-control/toggle-group-control/utils.js.map +1 -1
  333. package/build-module/tools-panel/tools-panel/hook.js +6 -6
  334. package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
  335. package/build-module/unit-control/styles/unit-control-styles.js +7 -7
  336. package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
  337. package/build-module/utils/config-values.js +6 -4
  338. package/build-module/utils/config-values.js.map +1 -1
  339. package/build-module/utils/element-rect.js +74 -105
  340. package/build-module/utils/element-rect.js.map +1 -1
  341. package/build-module/utils/hooks/use-update-effect.js +4 -4
  342. package/build-module/utils/hooks/use-update-effect.js.map +1 -1
  343. package/build-style/style-rtl.css +12 -27
  344. package/build-style/style.css +12 -27
  345. package/build-types/alignment-matrix-control/cell.d.ts +1 -1
  346. package/build-types/alignment-matrix-control/cell.d.ts.map +1 -1
  347. package/build-types/alignment-matrix-control/icon.d.ts +1 -1
  348. package/build-types/alignment-matrix-control/icon.d.ts.map +1 -1
  349. package/build-types/alignment-matrix-control/index.d.ts +16 -6
  350. package/build-types/alignment-matrix-control/index.d.ts.map +1 -1
  351. package/build-types/alignment-matrix-control/stories/index.story.d.ts.map +1 -1
  352. package/build-types/alignment-matrix-control/{styles/alignment-matrix-control-styles.d.ts → styles.d.ts} +9 -10
  353. package/build-types/alignment-matrix-control/styles.d.ts.map +1 -0
  354. package/build-types/alignment-matrix-control/types.d.ts +12 -1
  355. package/build-types/alignment-matrix-control/types.d.ts.map +1 -1
  356. package/build-types/angle-picker-control/angle-circle.d.ts.map +1 -1
  357. package/build-types/border-control/border-control/component.d.ts.map +1 -1
  358. package/build-types/box-control/stories/index.story.d.ts.map +1 -1
  359. package/build-types/box-control/utils.d.ts +1 -1
  360. package/build-types/box-control/utils.d.ts.map +1 -1
  361. package/build-types/circular-option-picker/circular-option-picker-option.d.ts.map +1 -1
  362. package/build-types/circular-option-picker/circular-option-picker.d.ts.map +1 -1
  363. package/build-types/circular-option-picker/types.d.ts +2 -2
  364. package/build-types/circular-option-picker/types.d.ts.map +1 -1
  365. package/build-types/color-palette/utils.d.ts.map +1 -1
  366. package/build-types/color-picker/color-copy-button.d.ts.map +1 -1
  367. package/build-types/color-picker/hex-input.d.ts.map +1 -1
  368. package/build-types/color-picker/input-with-slider.d.ts.map +1 -1
  369. package/build-types/color-picker/styles.d.ts.map +1 -1
  370. package/build-types/combobox-control/types.d.ts +1 -0
  371. package/build-types/combobox-control/types.d.ts.map +1 -1
  372. package/build-types/composite/context.d.ts.map +1 -1
  373. package/build-types/composite/group-label.d.ts +3 -0
  374. package/build-types/composite/group-label.d.ts.map +1 -0
  375. package/build-types/composite/group.d.ts +3 -0
  376. package/build-types/composite/group.d.ts.map +1 -0
  377. package/build-types/composite/hover.d.ts +3 -0
  378. package/build-types/composite/hover.d.ts.map +1 -0
  379. package/build-types/composite/index.d.ts +63 -47
  380. package/build-types/composite/index.d.ts.map +1 -1
  381. package/build-types/composite/item.d.ts +3 -0
  382. package/build-types/composite/item.d.ts.map +1 -0
  383. package/build-types/composite/legacy/index.d.ts +23 -3
  384. package/build-types/composite/legacy/index.d.ts.map +1 -1
  385. package/build-types/composite/legacy/stories/index.story.d.ts.map +1 -1
  386. package/build-types/composite/row.d.ts +3 -0
  387. package/build-types/composite/row.d.ts.map +1 -0
  388. package/build-types/composite/stories/index.story.d.ts +9 -8
  389. package/build-types/composite/stories/index.story.d.ts.map +1 -1
  390. package/build-types/composite/typeahead.d.ts +3 -0
  391. package/build-types/composite/typeahead.d.ts.map +1 -0
  392. package/build-types/composite/types.d.ts +12 -11
  393. package/build-types/composite/types.d.ts.map +1 -1
  394. package/build-types/date-time/date/index.d.ts +0 -3
  395. package/build-types/date-time/date/index.d.ts.map +1 -1
  396. package/build-types/date-time/date/styles.d.ts.map +1 -1
  397. package/build-types/date-time/date/test/use-lilius.d.ts +2 -0
  398. package/build-types/date-time/date/test/use-lilius.d.ts.map +1 -0
  399. package/build-types/date-time/date/use-lilius/index.d.ts +169 -0
  400. package/build-types/date-time/date/use-lilius/index.d.ts.map +1 -0
  401. package/build-types/date-time/time/time-input/index.d.ts.map +1 -1
  402. package/build-types/dimension-control/index.d.ts +1 -1
  403. package/build-types/dimension-control/index.d.ts.map +1 -1
  404. package/build-types/dimension-control/stories/index.story.d.ts +5 -0
  405. package/build-types/dimension-control/stories/index.story.d.ts.map +1 -1
  406. package/build-types/dropdown-menu-v2/checkbox-item.d.ts +3 -0
  407. package/build-types/dropdown-menu-v2/checkbox-item.d.ts.map +1 -0
  408. package/build-types/dropdown-menu-v2/context.d.ts +6 -0
  409. package/build-types/dropdown-menu-v2/context.d.ts.map +1 -0
  410. package/build-types/dropdown-menu-v2/group-label.d.ts +3 -0
  411. package/build-types/dropdown-menu-v2/group-label.d.ts.map +1 -0
  412. package/build-types/dropdown-menu-v2/group.d.ts +3 -0
  413. package/build-types/dropdown-menu-v2/group.d.ts.map +1 -0
  414. package/build-types/dropdown-menu-v2/index.d.ts +39 -18
  415. package/build-types/dropdown-menu-v2/index.d.ts.map +1 -1
  416. package/build-types/dropdown-menu-v2/item-help-text.d.ts +6 -0
  417. package/build-types/dropdown-menu-v2/item-help-text.d.ts.map +1 -0
  418. package/build-types/dropdown-menu-v2/item-label.d.ts +6 -0
  419. package/build-types/dropdown-menu-v2/item-label.d.ts.map +1 -0
  420. package/build-types/dropdown-menu-v2/item.d.ts +3 -0
  421. package/build-types/dropdown-menu-v2/item.d.ts.map +1 -0
  422. package/build-types/dropdown-menu-v2/radio-item.d.ts +3 -0
  423. package/build-types/dropdown-menu-v2/radio-item.d.ts.map +1 -0
  424. package/build-types/dropdown-menu-v2/separator.d.ts +3 -0
  425. package/build-types/dropdown-menu-v2/separator.d.ts.map +1 -0
  426. package/build-types/dropdown-menu-v2/stories/index.story.d.ts +10 -10
  427. package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +1 -1
  428. package/build-types/dropdown-menu-v2/styles.d.ts +14 -6
  429. package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -1
  430. package/build-types/dropdown-menu-v2/types.d.ts +6 -0
  431. package/build-types/dropdown-menu-v2/types.d.ts.map +1 -1
  432. package/build-types/dropdown-menu-v2/use-temporary-focus-visible-fix.d.ts +8 -0
  433. package/build-types/dropdown-menu-v2/use-temporary-focus-visible-fix.d.ts.map +1 -0
  434. package/build-types/focal-point-picker/styles/focal-point-style.d.ts.map +1 -1
  435. package/build-types/form-token-field/types.d.ts +1 -0
  436. package/build-types/form-token-field/types.d.ts.map +1 -1
  437. package/build-types/index.d.ts +4 -1
  438. package/build-types/index.d.ts.map +1 -1
  439. package/build-types/input-control/input-base.d.ts.map +1 -1
  440. package/build-types/input-control/input-prefix-wrapper.d.ts +2 -2
  441. package/build-types/input-control/input-prefix-wrapper.d.ts.map +1 -1
  442. package/build-types/input-control/input-suffix-wrapper.d.ts +2 -2
  443. package/build-types/input-control/input-suffix-wrapper.d.ts.map +1 -1
  444. package/build-types/input-control/reducer/reducer.d.ts.map +1 -1
  445. package/build-types/input-control/stories/index.story.d.ts +9 -0
  446. package/build-types/input-control/stories/index.story.d.ts.map +1 -1
  447. package/build-types/input-control/styles/input-control-styles.d.ts +15 -9
  448. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  449. package/build-types/input-control/types.d.ts +23 -6
  450. package/build-types/input-control/types.d.ts.map +1 -1
  451. package/build-types/modal/index.d.ts.map +1 -1
  452. package/build-types/modal/stories/index.story.d.ts +3 -0
  453. package/build-types/modal/stories/index.story.d.ts.map +1 -1
  454. package/build-types/navigation/styles/navigation-styles.d.ts.map +1 -1
  455. package/build-types/navigator/index.d.ts +6 -6
  456. package/build-types/navigator/index.d.ts.map +1 -1
  457. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  458. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  459. package/build-types/navigator/stories/index.story.d.ts +1 -1
  460. package/build-types/navigator/stories/index.story.d.ts.map +1 -1
  461. package/build-types/navigator/types.d.ts +3 -1
  462. package/build-types/navigator/types.d.ts.map +1 -1
  463. package/build-types/navigator/use-navigator.d.ts +1 -2
  464. package/build-types/navigator/use-navigator.d.ts.map +1 -1
  465. package/build-types/private-apis.d.ts.map +1 -1
  466. package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
  467. package/build-types/resizable-box/resize-tooltip/styles/resize-tooltip.styles.d.ts.map +1 -1
  468. package/build-types/select-control/styles/select-control-styles.d.ts +1 -1
  469. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  470. package/build-types/slot-fill/index.d.ts +3 -0
  471. package/build-types/slot-fill/index.d.ts.map +1 -1
  472. package/build-types/tabs/index.d.ts.map +1 -1
  473. package/build-types/tabs/styles.d.ts.map +1 -1
  474. package/build-types/tabs/tablist.d.ts.map +1 -1
  475. package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
  476. package/build-types/utils/config-values.d.ts +3 -3
  477. package/build-types/utils/element-rect.d.ts +32 -74
  478. package/build-types/utils/element-rect.d.ts.map +1 -1
  479. package/package.json +19 -20
  480. package/src/alignment-matrix-control/README.md +1 -5
  481. package/src/alignment-matrix-control/cell.tsx +3 -9
  482. package/src/alignment-matrix-control/icon.tsx +48 -30
  483. package/src/alignment-matrix-control/index.tsx +60 -50
  484. package/src/alignment-matrix-control/stories/index.story.tsx +3 -12
  485. package/src/alignment-matrix-control/styles.ts +113 -0
  486. package/src/alignment-matrix-control/types.ts +12 -1
  487. package/src/angle-picker-control/angle-circle.tsx +11 -9
  488. package/src/border-control/border-control/component.tsx +23 -16
  489. package/src/box-control/utils.ts +1 -1
  490. package/src/circular-option-picker/circular-option-picker-option.tsx +16 -19
  491. package/src/circular-option-picker/circular-option-picker.tsx +26 -12
  492. package/src/circular-option-picker/types.ts +2 -2
  493. package/src/clipboard-button/index.tsx +6 -6
  494. package/src/color-palette/test/utils.ts +21 -2
  495. package/src/color-palette/utils.ts +1 -3
  496. package/src/color-picker/color-copy-button.tsx +10 -8
  497. package/src/color-picker/hex-input.tsx +6 -10
  498. package/src/color-picker/input-with-slider.tsx +6 -10
  499. package/src/color-picker/styles.ts +1 -1
  500. package/src/combobox-control/types.ts +1 -0
  501. package/src/composite/README.md +5 -24
  502. package/src/composite/{context.ts → context.tsx} +1 -2
  503. package/src/composite/group-label.tsx +30 -0
  504. package/src/composite/group.tsx +30 -0
  505. package/src/composite/hover.tsx +30 -0
  506. package/src/composite/index.tsx +71 -166
  507. package/src/composite/item.tsx +30 -0
  508. package/src/composite/legacy/index.tsx +73 -11
  509. package/src/composite/legacy/stories/index.story.tsx +2 -1
  510. package/src/composite/legacy/test/index.tsx +57 -1
  511. package/src/composite/row.tsx +30 -0
  512. package/src/composite/stories/index.story.tsx +254 -365
  513. package/src/composite/typeahead.tsx +30 -0
  514. package/src/composite/types.ts +14 -16
  515. package/src/custom-gradient-picker/gradient-bar/control-points.tsx +10 -10
  516. package/src/custom-gradient-picker/style.scss +2 -21
  517. package/src/custom-select-control-v2/styles.ts +4 -4
  518. package/src/date-time/date/index.tsx +1 -1
  519. package/src/date-time/date/styles.ts +33 -13
  520. package/src/date-time/date/test/use-lilius.ts +417 -0
  521. package/src/date-time/date/use-lilius/index.ts +394 -0
  522. package/src/date-time/time/test/index.tsx +3 -6
  523. package/src/date-time/time/time-input/index.tsx +25 -25
  524. package/src/date-time/time/time-input/test/index.tsx +6 -7
  525. package/src/dimension-control/README.md +4 -0
  526. package/src/dimension-control/index.tsx +7 -1
  527. package/src/dimension-control/stories/index.story.tsx +7 -2
  528. package/src/dimension-control/test/__snapshots__/index.test.js.snap +16 -16
  529. package/src/dimension-control/test/index.test.js +1 -0
  530. package/src/draggable/index.tsx +4 -4
  531. package/src/dropdown-menu-v2/README.md +73 -60
  532. package/src/dropdown-menu-v2/checkbox-item.tsx +63 -0
  533. package/src/dropdown-menu-v2/context.tsx +13 -0
  534. package/src/dropdown-menu-v2/group-label.tsx +37 -0
  535. package/src/dropdown-menu-v2/group.tsx +26 -0
  536. package/src/dropdown-menu-v2/index.tsx +57 -197
  537. package/src/dropdown-menu-v2/item-help-text.tsx +23 -0
  538. package/src/dropdown-menu-v2/item-label.tsx +23 -0
  539. package/src/dropdown-menu-v2/item.tsx +50 -0
  540. package/src/dropdown-menu-v2/radio-item.tsx +70 -0
  541. package/src/dropdown-menu-v2/separator.tsx +27 -0
  542. package/src/dropdown-menu-v2/stories/index.story.tsx +295 -262
  543. package/src/dropdown-menu-v2/styles.ts +102 -66
  544. package/src/dropdown-menu-v2/test/index.tsx +159 -132
  545. package/src/dropdown-menu-v2/types.ts +7 -0
  546. package/src/dropdown-menu-v2/use-temporary-focus-visible-fix.ts +22 -0
  547. package/src/focal-point-picker/styles/focal-point-style.ts +6 -1
  548. package/src/form-toggle/style.scss +1 -1
  549. package/src/form-token-field/style.scss +2 -3
  550. package/src/form-token-field/types.ts +1 -0
  551. package/src/index.ts +6 -1
  552. package/src/input-control/index.tsx +2 -2
  553. package/src/input-control/input-base.tsx +4 -14
  554. package/src/input-control/input-prefix-wrapper.tsx +8 -4
  555. package/src/input-control/input-suffix-wrapper.tsx +4 -6
  556. package/src/input-control/reducer/reducer.ts +13 -10
  557. package/src/input-control/stories/index.story.tsx +31 -12
  558. package/src/input-control/styles/input-control-styles.tsx +42 -11
  559. package/src/input-control/types.ts +23 -7
  560. package/src/input-control/utils.ts +3 -3
  561. package/src/item-group/styles.ts +3 -3
  562. package/src/item-group/test/__snapshots__/index.js.snap +3 -3
  563. package/src/modal/index.tsx +21 -12
  564. package/src/modal/stories/index.story.tsx +8 -14
  565. package/src/modal/style.scss +5 -9
  566. package/src/navigation/index.tsx +4 -4
  567. package/src/navigation/styles/navigation-styles.tsx +3 -3
  568. package/src/navigator/index.ts +6 -6
  569. package/src/navigator/navigator-back-button/hook.ts +1 -1
  570. package/src/navigator/navigator-button/hook.ts +1 -1
  571. package/src/navigator/navigator-provider/README.md +2 -3
  572. package/src/navigator/navigator-provider/component.tsx +97 -82
  573. package/src/navigator/navigator-screen/component.tsx +7 -0
  574. package/src/navigator/navigator-to-parent-button/component.tsx +1 -1
  575. package/src/navigator/stories/index.story.tsx +82 -253
  576. package/src/navigator/test/index.tsx +8 -0
  577. package/src/navigator/types.ts +3 -1
  578. package/src/navigator/use-navigator.ts +1 -3
  579. package/src/palette-edit/index.tsx +2 -2
  580. package/src/popover/style.scss +2 -1
  581. package/src/private-apis.ts +1 -23
  582. package/src/range-control/styles/range-control-styles.ts +7 -7
  583. package/src/resizable-box/resize-tooltip/styles/resize-tooltip.styles.ts +2 -2
  584. package/src/resizable-box/style.scss +2 -2
  585. package/src/select-control/README.md +2 -2
  586. package/src/select-control/styles/select-control-styles.ts +5 -5
  587. package/src/slot-fill/bubbles-virtually/fill.tsx +4 -4
  588. package/src/slot-fill/index.tsx +1 -0
  589. package/src/snackbar/index.tsx +4 -4
  590. package/src/tab-panel/style.scss +0 -1
  591. package/src/tabs/index.tsx +8 -4
  592. package/src/tabs/styles.ts +42 -14
  593. package/src/tabs/tablist.tsx +5 -4
  594. package/src/text-control/style.scss +3 -2
  595. package/src/toggle-group-control/toggle-group-control/utils.ts +7 -7
  596. package/src/tools-panel/tools-panel/hook.ts +6 -6
  597. package/src/unit-control/styles/unit-control-styles.ts +2 -1
  598. package/src/utils/config-values.js +6 -4
  599. package/src/utils/element-rect.ts +93 -130
  600. package/src/utils/hooks/use-update-effect.js +4 -4
  601. package/tsconfig.tsbuildinfo +1 -1
  602. package/build/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js +0 -66
  603. package/build/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js.map +0 -1
  604. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +0 -77
  605. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +0 -1
  606. package/build/navigator/navigator-back-button/index.js +0 -14
  607. package/build/navigator/navigator-back-button/index.js.map +0 -1
  608. package/build/navigator/navigator-button/index.js +0 -14
  609. package/build/navigator/navigator-button/index.js.map +0 -1
  610. package/build/navigator/navigator-provider/index.js +0 -14
  611. package/build/navigator/navigator-provider/index.js.map +0 -1
  612. package/build/navigator/navigator-screen/index.js +0 -14
  613. package/build/navigator/navigator-screen/index.js.map +0 -1
  614. package/build/navigator/navigator-to-parent-button/index.js +0 -14
  615. package/build/navigator/navigator-to-parent-button/index.js.map +0 -1
  616. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js +0 -63
  617. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js.map +0 -1
  618. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +0 -72
  619. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +0 -1
  620. package/build-module/navigator/navigator-back-button/index.js +0 -2
  621. package/build-module/navigator/navigator-back-button/index.js.map +0 -1
  622. package/build-module/navigator/navigator-button/index.js +0 -2
  623. package/build-module/navigator/navigator-button/index.js.map +0 -1
  624. package/build-module/navigator/navigator-provider/index.js +0 -2
  625. package/build-module/navigator/navigator-provider/index.js.map +0 -1
  626. package/build-module/navigator/navigator-screen/index.js +0 -2
  627. package/build-module/navigator/navigator-screen/index.js.map +0 -1
  628. package/build-module/navigator/navigator-to-parent-button/index.js +0 -2
  629. package/build-module/navigator/navigator-to-parent-button/index.js.map +0 -1
  630. package/build-types/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.d.ts +0 -18
  631. package/build-types/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.d.ts.map +0 -1
  632. package/build-types/alignment-matrix-control/styles/alignment-matrix-control-styles.d.ts.map +0 -1
  633. package/build-types/composite/stories/utils.d.ts +0 -29
  634. package/build-types/composite/stories/utils.d.ts.map +0 -1
  635. package/build-types/navigator/navigator-back-button/index.d.ts +0 -2
  636. package/build-types/navigator/navigator-back-button/index.d.ts.map +0 -1
  637. package/build-types/navigator/navigator-button/index.d.ts +0 -2
  638. package/build-types/navigator/navigator-button/index.d.ts.map +0 -1
  639. package/build-types/navigator/navigator-provider/index.d.ts +0 -2
  640. package/build-types/navigator/navigator-provider/index.d.ts.map +0 -1
  641. package/build-types/navigator/navigator-screen/index.d.ts +0 -2
  642. package/build-types/navigator/navigator-screen/index.d.ts.map +0 -1
  643. package/build-types/navigator/navigator-to-parent-button/index.d.ts +0 -2
  644. package/build-types/navigator/navigator-to-parent-button/index.d.ts.map +0 -1
  645. package/src/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.ts +0 -77
  646. package/src/alignment-matrix-control/styles/alignment-matrix-control-styles.ts +0 -102
  647. package/src/composite/stories/utils.tsx +0 -76
  648. package/src/navigator/navigator-back-button/index.ts +0 -1
  649. package/src/navigator/navigator-button/index.ts +0 -1
  650. package/src/navigator/navigator-provider/index.ts +0 -1
  651. package/src/navigator/navigator-screen/index.ts +0 -1
  652. package/src/navigator/navigator-to-parent-button/index.ts +0 -1
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import { useMemo, useReducer } from '@wordpress/element';
9
9
  import isShallowEqual from '@wordpress/is-shallow-equal';
10
+ import warning from '@wordpress/warning';
10
11
 
11
12
  /**
12
13
  * Internal dependencies
@@ -20,10 +21,14 @@ import { NavigatorContext } from '../context';
20
21
  import * as styles from '../styles';
21
22
  import deprecated from '@wordpress/deprecated';
22
23
  import { jsx as _jsx } from "react/jsx-runtime";
23
- const MAX_HISTORY_LENGTH = 50;
24
24
  function addScreen({
25
25
  screens
26
26
  }, screen) {
27
+ if (screens.some(s => s.path === screen.path)) {
28
+ globalThis.SCRIPT_DEBUG === true ? warning(`Navigator: a screen with path ${screen.path} already exists.
29
+ The screen with id ${screen.id} will not be added.`) : void 0;
30
+ return screens;
31
+ }
27
32
  return [...screens, screen];
28
33
  }
29
34
  function removeScreen({
@@ -31,72 +36,89 @@ function removeScreen({
31
36
  }, screen) {
32
37
  return screens.filter(s => s.id !== screen.id);
33
38
  }
34
- function goBack({
35
- locationHistory
36
- }) {
37
- if (locationHistory.length <= 1) {
38
- return locationHistory;
39
- }
40
- return [...locationHistory.slice(0, -2), {
41
- ...locationHistory[locationHistory.length - 2],
42
- isBack: true,
43
- hasRestoredFocus: false
44
- }];
45
- }
46
39
  function goTo(state, path, options = {}) {
40
+ var _focusSelectorsCopy2;
47
41
  const {
48
- locationHistory
42
+ focusSelectors
49
43
  } = state;
44
+ const currentLocation = {
45
+ ...state.currentLocation,
46
+ isInitial: false
47
+ };
50
48
  const {
51
- focusTargetSelector,
49
+ // Default assignments
52
50
  isBack = false,
53
51
  skipFocus = false,
54
- replace = false,
52
+ // Extract to avoid forwarding
53
+ replace,
54
+ focusTargetSelector,
55
+ // Rest
55
56
  ...restOptions
56
57
  } = options;
57
- const isNavigatingToSamePath = locationHistory.length > 0 && locationHistory[locationHistory.length - 1].path === path;
58
- if (isNavigatingToSamePath) {
59
- return locationHistory;
58
+ if (currentLocation.path === path) {
59
+ return {
60
+ currentLocation,
61
+ focusSelectors
62
+ };
60
63
  }
61
- const isNavigatingToPreviousPath = isBack && locationHistory.length > 1 && locationHistory[locationHistory.length - 2].path === path;
62
- if (isNavigatingToPreviousPath) {
63
- return goBack(state);
64
+ let focusSelectorsCopy;
65
+ function getFocusSelectorsCopy() {
66
+ var _focusSelectorsCopy;
67
+ focusSelectorsCopy = (_focusSelectorsCopy = focusSelectorsCopy) !== null && _focusSelectorsCopy !== void 0 ? _focusSelectorsCopy : new Map(state.focusSelectors);
68
+ return focusSelectorsCopy;
64
69
  }
65
- const newLocation = {
66
- ...restOptions,
67
- path,
68
- isBack,
69
- hasRestoredFocus: false,
70
- skipFocus
71
- };
72
- if (locationHistory.length === 0) {
73
- return replace ? [] : [newLocation];
70
+
71
+ // Set a focus selector that will be used when navigating
72
+ // back to the current location.
73
+ if (focusTargetSelector && currentLocation.path) {
74
+ getFocusSelectorsCopy().set(currentLocation.path, focusTargetSelector);
74
75
  }
75
- const newLocationHistory = locationHistory.slice(locationHistory.length > MAX_HISTORY_LENGTH - 1 ? 1 : 0, -1);
76
- if (!replace) {
77
- newLocationHistory.push(
78
- // Assign `focusTargetSelector` to the previous location in history
79
- // (the one we just navigated from).
80
- {
81
- ...locationHistory[locationHistory.length - 1],
82
- focusTargetSelector
83
- });
76
+
77
+ // Get the focus selector for the new location.
78
+ let currentFocusSelector;
79
+ if (focusSelectors.get(path)) {
80
+ if (isBack) {
81
+ // Use the found focus selector only when navigating back.
82
+ currentFocusSelector = focusSelectors.get(path);
83
+ }
84
+ // Make a copy of the focusSelectors map to remove the focus selector
85
+ // only if necessary (ie. a focus selector was found).
86
+ getFocusSelectorsCopy().delete(path);
84
87
  }
85
- newLocationHistory.push(newLocation);
86
- return newLocationHistory;
88
+ return {
89
+ currentLocation: {
90
+ ...restOptions,
91
+ path,
92
+ isBack,
93
+ hasRestoredFocus: false,
94
+ focusTargetSelector: currentFocusSelector,
95
+ skipFocus
96
+ },
97
+ focusSelectors: (_focusSelectorsCopy2 = focusSelectorsCopy) !== null && _focusSelectorsCopy2 !== void 0 ? _focusSelectorsCopy2 : focusSelectors
98
+ };
87
99
  }
88
100
  function goToParent(state, options = {}) {
89
101
  const {
90
- locationHistory,
91
- screens
102
+ screens,
103
+ focusSelectors
92
104
  } = state;
93
- const currentPath = locationHistory[locationHistory.length - 1].path;
105
+ const currentLocation = {
106
+ ...state.currentLocation,
107
+ isInitial: false
108
+ };
109
+ const currentPath = currentLocation.path;
94
110
  if (currentPath === undefined) {
95
- return locationHistory;
111
+ return {
112
+ currentLocation,
113
+ focusSelectors
114
+ };
96
115
  }
97
116
  const parentPath = findParent(currentPath, screens);
98
117
  if (parentPath === undefined) {
99
- return locationHistory;
118
+ return {
119
+ currentLocation,
120
+ focusSelectors
121
+ };
100
122
  }
101
123
  return goTo(state, parentPath, {
102
124
  ...options,
@@ -106,8 +128,10 @@ function goToParent(state, options = {}) {
106
128
  function routerReducer(state, action) {
107
129
  let {
108
130
  screens,
109
- locationHistory,
110
- matchedPath
131
+ currentLocation,
132
+ matchedPath,
133
+ focusSelectors,
134
+ ...restState
111
135
  } = state;
112
136
  switch (action.type) {
113
137
  case 'add':
@@ -117,20 +141,26 @@ function routerReducer(state, action) {
117
141
  screens = removeScreen(state, action.screen);
118
142
  break;
119
143
  case 'goto':
120
- locationHistory = goTo(state, action.path, action.options);
144
+ ({
145
+ currentLocation,
146
+ focusSelectors
147
+ } = goTo(state, action.path, action.options));
121
148
  break;
122
149
  case 'gotoparent':
123
- locationHistory = goToParent(state, action.options);
150
+ ({
151
+ currentLocation,
152
+ focusSelectors
153
+ } = goToParent(state, action.options));
124
154
  break;
125
155
  }
126
156
 
127
157
  // Return early in case there is no change
128
- if (screens === state.screens && locationHistory === state.locationHistory) {
158
+ if (screens === state.screens && currentLocation === state.currentLocation) {
129
159
  return state;
130
160
  }
131
161
 
132
162
  // Compute the matchedPath
133
- const currentPath = locationHistory.length > 0 ? locationHistory[locationHistory.length - 1].path : undefined;
163
+ const currentPath = currentLocation.path;
134
164
  matchedPath = currentPath !== undefined ? patternMatch(currentPath, screens) : undefined;
135
165
 
136
166
  // If the new match is the same as the previous match,
@@ -139,24 +169,29 @@ function routerReducer(state, action) {
139
169
  matchedPath = state.matchedPath;
140
170
  }
141
171
  return {
172
+ ...restState,
142
173
  screens,
143
- locationHistory,
144
- matchedPath
174
+ currentLocation,
175
+ matchedPath,
176
+ focusSelectors
145
177
  };
146
178
  }
147
179
  function UnconnectedNavigatorProvider(props, forwardedRef) {
148
180
  const {
149
- initialPath,
181
+ initialPath: initialPathProp,
150
182
  children,
151
183
  className,
152
184
  ...otherProps
153
185
  } = useContextSystem(props, 'NavigatorProvider');
154
- const [routerState, dispatch] = useReducer(routerReducer, initialPath, path => ({
186
+ const [routerState, dispatch] = useReducer(routerReducer, initialPathProp, path => ({
155
187
  screens: [],
156
- locationHistory: [{
157
- path
158
- }],
159
- matchedPath: undefined
188
+ currentLocation: {
189
+ path,
190
+ isInitial: true
191
+ },
192
+ matchedPath: undefined,
193
+ focusSelectors: new Map(),
194
+ initialPath: initialPathProp
160
195
  }));
161
196
 
162
197
  // The methods are constant forever, create stable references to them.
@@ -193,21 +228,18 @@ function UnconnectedNavigatorProvider(props, forwardedRef) {
193
228
  })
194
229
  }), []);
195
230
  const {
196
- locationHistory,
231
+ currentLocation,
197
232
  matchedPath
198
233
  } = routerState;
199
234
  const navigatorContextValue = useMemo(() => {
200
235
  var _matchedPath$params;
201
236
  return {
202
- location: {
203
- ...locationHistory[locationHistory.length - 1],
204
- isInitial: locationHistory.length === 1
205
- },
237
+ location: currentLocation,
206
238
  params: (_matchedPath$params = matchedPath?.params) !== null && _matchedPath$params !== void 0 ? _matchedPath$params : {},
207
239
  match: matchedPath?.id,
208
240
  ...methods
209
241
  };
210
- }, [locationHistory, matchedPath, methods]);
242
+ }, [currentLocation, matchedPath, methods]);
211
243
  const cx = useCx();
212
244
  const classes = useMemo(() => cx(styles.navigatorProviderWrapper, className), [className, cx]);
213
245
  return /*#__PURE__*/_jsx(View, {
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","useReducer","isShallowEqual","contextConnect","useContextSystem","useCx","patternMatch","findParent","View","NavigatorContext","styles","deprecated","jsx","_jsx","MAX_HISTORY_LENGTH","addScreen","screens","screen","removeScreen","filter","s","id","goBack","locationHistory","length","slice","isBack","hasRestoredFocus","goTo","state","path","options","focusTargetSelector","skipFocus","replace","restOptions","isNavigatingToSamePath","isNavigatingToPreviousPath","newLocation","newLocationHistory","push","goToParent","currentPath","undefined","parentPath","routerReducer","action","matchedPath","type","params","UnconnectedNavigatorProvider","props","forwardedRef","initialPath","children","className","otherProps","routerState","dispatch","methods","since","alternative","navigatorContextValue","_matchedPath$params","location","isInitial","match","cx","classes","navigatorProviderWrapper","ref","Provider","value","NavigatorProvider"],"sources":["@wordpress/components/src/navigator/navigator-provider/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useReducer } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect, useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport { patternMatch, findParent } from '../utils/router';\nimport { View } from '../../view';\nimport { NavigatorContext } from '../context';\nimport * as styles from '../styles';\nimport type {\n\tNavigatorProviderProps,\n\tNavigatorLocation,\n\tNavigatorContext as NavigatorContextType,\n\tNavigateOptions,\n\tScreen,\n\tNavigateToParentOptions,\n} from '../types';\nimport deprecated from '@wordpress/deprecated';\n\ntype MatchedPath = ReturnType< typeof patternMatch >;\n\ntype RouterAction =\n\t| { type: 'add' | 'remove'; screen: Screen }\n\t| { type: 'goto'; path: string; options?: NavigateOptions }\n\t| { type: 'gotoparent'; options?: NavigateToParentOptions };\n\ntype RouterState = {\n\tscreens: Screen[];\n\tlocationHistory: NavigatorLocation[];\n\tmatchedPath: MatchedPath;\n};\n\nconst MAX_HISTORY_LENGTH = 50;\n\nfunction addScreen( { screens }: RouterState, screen: Screen ) {\n\treturn [ ...screens, screen ];\n}\n\nfunction removeScreen( { screens }: RouterState, screen: Screen ) {\n\treturn screens.filter( ( s ) => s.id !== screen.id );\n}\n\nfunction goBack( { locationHistory }: RouterState ) {\n\tif ( locationHistory.length <= 1 ) {\n\t\treturn locationHistory;\n\t}\n\treturn [\n\t\t...locationHistory.slice( 0, -2 ),\n\t\t{\n\t\t\t...locationHistory[ locationHistory.length - 2 ],\n\t\t\tisBack: true,\n\t\t\thasRestoredFocus: false,\n\t\t},\n\t];\n}\n\nfunction goTo(\n\tstate: RouterState,\n\tpath: string,\n\toptions: NavigateOptions = {}\n) {\n\tconst { locationHistory } = state;\n\tconst {\n\t\tfocusTargetSelector,\n\t\tisBack = false,\n\t\tskipFocus = false,\n\t\treplace = false,\n\t\t...restOptions\n\t} = options;\n\n\tconst isNavigatingToSamePath =\n\t\tlocationHistory.length > 0 &&\n\t\tlocationHistory[ locationHistory.length - 1 ].path === path;\n\tif ( isNavigatingToSamePath ) {\n\t\treturn locationHistory;\n\t}\n\n\tconst isNavigatingToPreviousPath =\n\t\tisBack &&\n\t\tlocationHistory.length > 1 &&\n\t\tlocationHistory[ locationHistory.length - 2 ].path === path;\n\n\tif ( isNavigatingToPreviousPath ) {\n\t\treturn goBack( state );\n\t}\n\n\tconst newLocation = {\n\t\t...restOptions,\n\t\tpath,\n\t\tisBack,\n\t\thasRestoredFocus: false,\n\t\tskipFocus,\n\t};\n\n\tif ( locationHistory.length === 0 ) {\n\t\treturn replace ? [] : [ newLocation ];\n\t}\n\n\tconst newLocationHistory = locationHistory.slice(\n\t\tlocationHistory.length > MAX_HISTORY_LENGTH - 1 ? 1 : 0,\n\t\t-1\n\t);\n\n\tif ( ! replace ) {\n\t\tnewLocationHistory.push(\n\t\t\t// Assign `focusTargetSelector` to the previous location in history\n\t\t\t// (the one we just navigated from).\n\t\t\t{\n\t\t\t\t...locationHistory[ locationHistory.length - 1 ],\n\t\t\t\tfocusTargetSelector,\n\t\t\t}\n\t\t);\n\t}\n\n\tnewLocationHistory.push( newLocation );\n\n\treturn newLocationHistory;\n}\n\nfunction goToParent(\n\tstate: RouterState,\n\toptions: NavigateToParentOptions = {}\n) {\n\tconst { locationHistory, screens } = state;\n\tconst currentPath = locationHistory[ locationHistory.length - 1 ].path;\n\tif ( currentPath === undefined ) {\n\t\treturn locationHistory;\n\t}\n\tconst parentPath = findParent( currentPath, screens );\n\tif ( parentPath === undefined ) {\n\t\treturn locationHistory;\n\t}\n\treturn goTo( state, parentPath, {\n\t\t...options,\n\t\tisBack: true,\n\t} );\n}\n\nfunction routerReducer(\n\tstate: RouterState,\n\taction: RouterAction\n): RouterState {\n\tlet { screens, locationHistory, matchedPath } = state;\n\tswitch ( action.type ) {\n\t\tcase 'add':\n\t\t\tscreens = addScreen( state, action.screen );\n\t\t\tbreak;\n\t\tcase 'remove':\n\t\t\tscreens = removeScreen( state, action.screen );\n\t\t\tbreak;\n\t\tcase 'goto':\n\t\t\tlocationHistory = goTo( state, action.path, action.options );\n\t\t\tbreak;\n\t\tcase 'gotoparent':\n\t\t\tlocationHistory = goToParent( state, action.options );\n\t\t\tbreak;\n\t}\n\n\t// Return early in case there is no change\n\tif (\n\t\tscreens === state.screens &&\n\t\tlocationHistory === state.locationHistory\n\t) {\n\t\treturn state;\n\t}\n\n\t// Compute the matchedPath\n\tconst currentPath =\n\t\tlocationHistory.length > 0\n\t\t\t? locationHistory[ locationHistory.length - 1 ].path\n\t\t\t: undefined;\n\tmatchedPath =\n\t\tcurrentPath !== undefined\n\t\t\t? patternMatch( currentPath, screens )\n\t\t\t: undefined;\n\n\t// If the new match is the same as the previous match,\n\t// return the previous one to keep immutability.\n\tif (\n\t\tmatchedPath &&\n\t\tstate.matchedPath &&\n\t\tmatchedPath.id === state.matchedPath.id &&\n\t\tisShallowEqual( matchedPath.params, state.matchedPath.params )\n\t) {\n\t\tmatchedPath = state.matchedPath;\n\t}\n\n\treturn { screens, locationHistory, matchedPath };\n}\n\nfunction UnconnectedNavigatorProvider(\n\tprops: WordPressComponentProps< NavigatorProviderProps, 'div' >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst { initialPath, children, className, ...otherProps } =\n\t\tuseContextSystem( props, 'NavigatorProvider' );\n\n\tconst [ routerState, dispatch ] = useReducer(\n\t\trouterReducer,\n\t\tinitialPath,\n\t\t( path ) => ( {\n\t\t\tscreens: [],\n\t\t\tlocationHistory: [ { path } ],\n\t\t\tmatchedPath: undefined,\n\t\t} )\n\t);\n\n\t// The methods are constant forever, create stable references to them.\n\tconst methods = useMemo(\n\t\t() => ( {\n\t\t\t// Note: calling goBack calls `goToParent` internally, as it was established\n\t\t\t// that `goBack` should behave like `goToParent`, and `goToParent` should\n\t\t\t// be marked as deprecated.\n\t\t\tgoBack: ( options: NavigateToParentOptions | undefined ) =>\n\t\t\t\tdispatch( { type: 'gotoparent', options } ),\n\t\t\tgoTo: ( path: string, options?: NavigateOptions ) =>\n\t\t\t\tdispatch( { type: 'goto', path, options } ),\n\t\t\tgoToParent: ( options: NavigateToParentOptions | undefined ) => {\n\t\t\t\tdeprecated( `wp.components.useNavigator().goToParent`, {\n\t\t\t\t\tsince: '6.7',\n\t\t\t\t\talternative: 'wp.components.useNavigator().goBack',\n\t\t\t\t} );\n\t\t\t\tdispatch( { type: 'gotoparent', options } );\n\t\t\t},\n\t\t\taddScreen: ( screen: Screen ) =>\n\t\t\t\tdispatch( { type: 'add', screen } ),\n\t\t\tremoveScreen: ( screen: Screen ) =>\n\t\t\t\tdispatch( { type: 'remove', screen } ),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst { locationHistory, matchedPath } = routerState;\n\n\tconst navigatorContextValue: NavigatorContextType = useMemo(\n\t\t() => ( {\n\t\t\tlocation: {\n\t\t\t\t...locationHistory[ locationHistory.length - 1 ],\n\t\t\t\tisInitial: locationHistory.length === 1,\n\t\t\t},\n\t\t\tparams: matchedPath?.params ?? {},\n\t\t\tmatch: matchedPath?.id,\n\t\t\t...methods,\n\t\t} ),\n\t\t[ locationHistory, matchedPath, methods ]\n\t);\n\n\tconst cx = useCx();\n\tconst classes = useMemo(\n\t\t() => cx( styles.navigatorProviderWrapper, className ),\n\t\t[ className, cx ]\n\t);\n\n\treturn (\n\t\t<View ref={ forwardedRef } className={ classes } { ...otherProps }>\n\t\t\t<NavigatorContext.Provider value={ navigatorContextValue }>\n\t\t\t\t{ children }\n\t\t\t</NavigatorContext.Provider>\n\t\t</View>\n\t);\n}\n\n/**\n * The `NavigatorProvider` component allows rendering nested views/panels/menus\n * (via the `NavigatorScreen` component and navigate between these different\n * view (via the `NavigatorButton` and `NavigatorBackButton` components or the\n * `useNavigator` hook).\n *\n * ```jsx\n * import {\n * __experimentalNavigatorProvider as NavigatorProvider,\n * __experimentalNavigatorScreen as NavigatorScreen,\n * __experimentalNavigatorButton as NavigatorButton,\n * __experimentalNavigatorBackButton as NavigatorBackButton,\n * } from '@wordpress/components';\n *\n * const MyNavigation = () => (\n * <NavigatorProvider initialPath=\"/\">\n * <NavigatorScreen path=\"/\">\n * <p>This is the home screen.</p>\n * <NavigatorButton path=\"/child\">\n * Navigate to child screen.\n * </NavigatorButton>\n * </NavigatorScreen>\n *\n * <NavigatorScreen path=\"/child\">\n * <p>This is the child screen.</p>\n * <NavigatorBackButton>\n * Go back\n * </NavigatorBackButton>\n * </NavigatorScreen>\n * </NavigatorProvider>\n * );\n * ```\n */\nexport const NavigatorProvider = contextConnect(\n\tUnconnectedNavigatorProvider,\n\t'NavigatorProvider'\n);\n\nexport default NavigatorProvider;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,UAAU,QAAQ,oBAAoB;AACxD,OAAOC,cAAc,MAAM,6BAA6B;;AAExD;AACA;AACA;;AAEA,SAASC,cAAc,EAAEC,gBAAgB,QAAQ,eAAe;AAChE,SAASC,KAAK,QAAQ,0BAA0B;AAChD,SAASC,YAAY,EAAEC,UAAU,QAAQ,iBAAiB;AAC1D,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,OAAO,KAAKC,MAAM,MAAM,WAAW;AASnC,OAAOC,UAAU,MAAM,uBAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAe/C,MAAMC,kBAAkB,GAAG,EAAE;AAE7B,SAASC,SAASA,CAAE;EAAEC;AAAqB,CAAC,EAAEC,MAAc,EAAG;EAC9D,OAAO,CAAE,GAAGD,OAAO,EAAEC,MAAM,CAAE;AAC9B;AAEA,SAASC,YAAYA,CAAE;EAAEF;AAAqB,CAAC,EAAEC,MAAc,EAAG;EACjE,OAAOD,OAAO,CAACG,MAAM,CAAIC,CAAC,IAAMA,CAAC,CAACC,EAAE,KAAKJ,MAAM,CAACI,EAAG,CAAC;AACrD;AAEA,SAASC,MAAMA,CAAE;EAAEC;AAA6B,CAAC,EAAG;EACnD,IAAKA,eAAe,CAACC,MAAM,IAAI,CAAC,EAAG;IAClC,OAAOD,eAAe;EACvB;EACA,OAAO,CACN,GAAGA,eAAe,CAACE,KAAK,CAAE,CAAC,EAAE,CAAC,CAAE,CAAC,EACjC;IACC,GAAGF,eAAe,CAAEA,eAAe,CAACC,MAAM,GAAG,CAAC,CAAE;IAChDE,MAAM,EAAE,IAAI;IACZC,gBAAgB,EAAE;EACnB,CAAC,CACD;AACF;A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AAM,CAAC2D,wBAAwB,EAAEd,SAAU,CAAC,EACtD,CAAEA,SAAS,EAAEY,EAAE,CAChB,CAAC;EAED,oBACCtD,IAAA,CAACL,IAAI;IAAC8D,GAAG,EAAGlB,YAAc;IAACG,SAAS,EAAGa,OAAS;IAAA,GAAMZ,UAAU;IAAAF,QAAA,eAC/DzC,IAAA,CAACJ,gBAAgB,CAAC8D,QAAQ;MAACC,KAAK,EAAGV,qBAAuB;MAAAR,QAAA,EACvDA;IAAQ,CACgB;EAAC,CACvB,CAAC;AAET;;AAEA;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,OAAO,MAAMmB,iBAAiB,GAAGtE,cAAc,CAC9C+C,4BAA4B,EAC5B,mBACD,CAAC;AAED,eAAeuB,iBAAiB","ignoreList":[]}
1
+ {"version":3,"names":["useMemo","useReducer","isShallowEqual","warning","contextConnect","useContextSystem","useCx","patternMatch","findParent","View","NavigatorContext","styles","deprecated","jsx","_jsx","addScreen","screens","screen","some","s","path","globalThis","SCRIPT_DEBUG","id","removeScreen","filter","goTo","state","options","_focusSelectorsCopy2","focusSelectors","currentLocation","isInitial","isBack","skipFocus","replace","focusTargetSelector","restOptions","focusSelectorsCopy","getFocusSelectorsCopy","_focusSelectorsCopy","Map","set","currentFocusSelector","get","delete","hasRestoredFocus","goToParent","currentPath","undefined","parentPath","routerReducer","action","matchedPath","restState","type","params","UnconnectedNavigatorProvider","props","forwardedRef","initialPath","initialPathProp","children","className","otherProps","routerState","dispatch","methods","goBack","since","alternative","navigatorContextValue","_matchedPath$params","location","match","cx","classes","navigatorProviderWrapper","ref","Provider","value","NavigatorProvider"],"sources":["@wordpress/components/src/navigator/navigator-provider/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useReducer } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect, useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport { patternMatch, findParent } from '../utils/router';\nimport { View } from '../../view';\nimport { NavigatorContext } from '../context';\nimport * as styles from '../styles';\nimport type {\n\tNavigatorProviderProps,\n\tNavigatorLocation,\n\tNavigatorContext as NavigatorContextType,\n\tNavigateOptions,\n\tScreen,\n\tNavigateToParentOptions,\n} from '../types';\nimport deprecated from '@wordpress/deprecated';\n\ntype MatchedPath = ReturnType< typeof patternMatch >;\n\ntype RouterAction =\n\t| { type: 'add' | 'remove'; screen: Screen }\n\t| { type: 'goto'; path: string; options?: NavigateOptions }\n\t| { type: 'gotoparent'; options?: NavigateToParentOptions };\n\ntype RouterState = {\n\tinitialPath: string;\n\tscreens: Screen[];\n\tcurrentLocation: NavigatorLocation;\n\tmatchedPath: MatchedPath;\n\tfocusSelectors: Map< string, string >;\n};\n\nfunction addScreen( { screens }: RouterState, screen: Screen ) {\n\tif ( screens.some( ( s ) => s.path === screen.path ) ) {\n\t\twarning(\n\t\t\t`Navigator: a screen with path ${ screen.path } already exists.\nThe screen with id ${ screen.id } will not be added.`\n\t\t);\n\t\treturn screens;\n\t}\n\treturn [ ...screens, screen ];\n}\n\nfunction removeScreen( { screens }: RouterState, screen: Screen ) {\n\treturn screens.filter( ( s ) => s.id !== screen.id );\n}\n\nfunction goTo(\n\tstate: RouterState,\n\tpath: string,\n\toptions: NavigateOptions = {}\n) {\n\tconst { focusSelectors } = state;\n\tconst currentLocation = { ...state.currentLocation, isInitial: false };\n\n\tconst {\n\t\t// Default assignments\n\t\tisBack = false,\n\t\tskipFocus = false,\n\t\t// Extract to avoid forwarding\n\t\treplace,\n\t\tfocusTargetSelector,\n\t\t// Rest\n\t\t...restOptions\n\t} = options;\n\n\tif ( currentLocation.path === path ) {\n\t\treturn { currentLocation, focusSelectors };\n\t}\n\n\tlet focusSelectorsCopy: typeof focusSelectors | undefined;\n\tfunction getFocusSelectorsCopy() {\n\t\tfocusSelectorsCopy =\n\t\t\tfocusSelectorsCopy ?? new Map( state.focusSelectors );\n\t\treturn focusSelectorsCopy;\n\t}\n\n\t// Set a focus selector that will be used when navigating\n\t// back to the current location.\n\tif ( focusTargetSelector && currentLocation.path ) {\n\t\tgetFocusSelectorsCopy().set(\n\t\t\tcurrentLocation.path,\n\t\t\tfocusTargetSelector\n\t\t);\n\t}\n\n\t// Get the focus selector for the new location.\n\tlet currentFocusSelector;\n\tif ( focusSelectors.get( path ) ) {\n\t\tif ( isBack ) {\n\t\t\t// Use the found focus selector only when navigating back.\n\t\t\tcurrentFocusSelector = focusSelectors.get( path );\n\t\t}\n\t\t// Make a copy of the focusSelectors map to remove the focus selector\n\t\t// only if necessary (ie. a focus selector was found).\n\t\tgetFocusSelectorsCopy().delete( path );\n\t}\n\n\treturn {\n\t\tcurrentLocation: {\n\t\t\t...restOptions,\n\t\t\tpath,\n\t\t\tisBack,\n\t\t\thasRestoredFocus: false,\n\t\t\tfocusTargetSelector: currentFocusSelector,\n\t\t\tskipFocus,\n\t\t},\n\t\tfocusSelectors: focusSelectorsCopy ?? focusSelectors,\n\t};\n}\n\nfunction goToParent(\n\tstate: RouterState,\n\toptions: NavigateToParentOptions = {}\n) {\n\tconst { screens, focusSelectors } = state;\n\tconst currentLocation = { ...state.currentLocation, isInitial: false };\n\tconst currentPath = currentLocation.path;\n\tif ( currentPath === undefined ) {\n\t\treturn { currentLocation, focusSelectors };\n\t}\n\tconst parentPath = findParent( currentPath, screens );\n\tif ( parentPath === undefined ) {\n\t\treturn { currentLocation, focusSelectors };\n\t}\n\treturn goTo( state, parentPath, {\n\t\t...options,\n\t\tisBack: true,\n\t} );\n}\n\nfunction routerReducer(\n\tstate: RouterState,\n\taction: RouterAction\n): RouterState {\n\tlet {\n\t\tscreens,\n\t\tcurrentLocation,\n\t\tmatchedPath,\n\t\tfocusSelectors,\n\t\t...restState\n\t} = state;\n\tswitch ( action.type ) {\n\t\tcase 'add':\n\t\t\tscreens = addScreen( state, action.screen );\n\t\t\tbreak;\n\t\tcase 'remove':\n\t\t\tscreens = removeScreen( state, action.screen );\n\t\t\tbreak;\n\t\tcase 'goto':\n\t\t\t( { currentLocation, focusSelectors } = goTo(\n\t\t\t\tstate,\n\t\t\t\taction.path,\n\t\t\t\taction.options\n\t\t\t) );\n\t\t\tbreak;\n\t\tcase 'gotoparent':\n\t\t\t( { currentLocation, focusSelectors } = goToParent(\n\t\t\t\tstate,\n\t\t\t\taction.options\n\t\t\t) );\n\t\t\tbreak;\n\t}\n\n\t// Return early in case there is no change\n\tif (\n\t\tscreens === state.screens &&\n\t\tcurrentLocation === state.currentLocation\n\t) {\n\t\treturn state;\n\t}\n\n\t// Compute the matchedPath\n\tconst currentPath = currentLocation.path;\n\tmatchedPath =\n\t\tcurrentPath !== undefined\n\t\t\t? patternMatch( currentPath, screens )\n\t\t\t: undefined;\n\n\t// If the new match is the same as the previous match,\n\t// return the previous one to keep immutability.\n\tif (\n\t\tmatchedPath &&\n\t\tstate.matchedPath &&\n\t\tmatchedPath.id === state.matchedPath.id &&\n\t\tisShallowEqual( matchedPath.params, state.matchedPath.params )\n\t) {\n\t\tmatchedPath = state.matchedPath;\n\t}\n\n\treturn {\n\t\t...restState,\n\t\tscreens,\n\t\tcurrentLocation,\n\t\tmatchedPath,\n\t\tfocusSelectors,\n\t};\n}\n\nfunction UnconnectedNavigatorProvider(\n\tprops: WordPressComponentProps< NavigatorProviderProps, 'div' >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst {\n\t\tinitialPath: initialPathProp,\n\t\tchildren,\n\t\tclassName,\n\t\t...otherProps\n\t} = useContextSystem( props, 'NavigatorProvider' );\n\n\tconst [ routerState, dispatch ] = useReducer(\n\t\trouterReducer,\n\t\tinitialPathProp,\n\t\t( path ) => ( {\n\t\t\tscreens: [],\n\t\t\tcurrentLocation: { path, isInitial: true },\n\t\t\tmatchedPath: undefined,\n\t\t\tfocusSelectors: new Map(),\n\t\t\tinitialPath: initialPathProp,\n\t\t} )\n\t);\n\n\t// The methods are constant forever, create stable references to them.\n\tconst methods = useMemo(\n\t\t() => ( {\n\t\t\t// Note: calling goBack calls `goToParent` internally, as it was established\n\t\t\t// that `goBack` should behave like `goToParent`, and `goToParent` should\n\t\t\t// be marked as deprecated.\n\t\t\tgoBack: ( options: NavigateToParentOptions | undefined ) =>\n\t\t\t\tdispatch( { type: 'gotoparent', options } ),\n\t\t\tgoTo: ( path: string, options?: NavigateOptions ) =>\n\t\t\t\tdispatch( { type: 'goto', path, options } ),\n\t\t\tgoToParent: ( options: NavigateToParentOptions | undefined ) => {\n\t\t\t\tdeprecated( `wp.components.useNavigator().goToParent`, {\n\t\t\t\t\tsince: '6.7',\n\t\t\t\t\talternative: 'wp.components.useNavigator().goBack',\n\t\t\t\t} );\n\t\t\t\tdispatch( { type: 'gotoparent', options } );\n\t\t\t},\n\t\t\taddScreen: ( screen: Screen ) =>\n\t\t\t\tdispatch( { type: 'add', screen } ),\n\t\t\tremoveScreen: ( screen: Screen ) =>\n\t\t\t\tdispatch( { type: 'remove', screen } ),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst { currentLocation, matchedPath } = routerState;\n\n\tconst navigatorContextValue: NavigatorContextType = useMemo(\n\t\t() => ( {\n\t\t\tlocation: currentLocation,\n\t\t\tparams: matchedPath?.params ?? {},\n\t\t\tmatch: matchedPath?.id,\n\t\t\t...methods,\n\t\t} ),\n\t\t[ currentLocation, matchedPath, methods ]\n\t);\n\n\tconst cx = useCx();\n\tconst classes = useMemo(\n\t\t() => cx( styles.navigatorProviderWrapper, className ),\n\t\t[ className, cx ]\n\t);\n\n\treturn (\n\t\t<View ref={ forwardedRef } className={ classes } { ...otherProps }>\n\t\t\t<NavigatorContext.Provider value={ navigatorContextValue }>\n\t\t\t\t{ children }\n\t\t\t</NavigatorContext.Provider>\n\t\t</View>\n\t);\n}\n\n/**\n * The `NavigatorProvider` component allows rendering nested views/panels/menus\n * (via the `NavigatorScreen` component and navigate between these different\n * view (via the `NavigatorButton` and `NavigatorBackButton` components or the\n * `useNavigator` hook).\n *\n * ```jsx\n * import {\n * __experimentalNavigatorProvider as NavigatorProvider,\n * __experimentalNavigatorScreen as NavigatorScreen,\n * __experimentalNavigatorButton as NavigatorButton,\n * __experimentalNavigatorBackButton as NavigatorBackButton,\n * } from '@wordpress/components';\n *\n * const MyNavigation = () => (\n * <NavigatorProvider initialPath=\"/\">\n * <NavigatorScreen path=\"/\">\n * <p>This is the home screen.</p>\n * <NavigatorButton path=\"/child\">\n * Navigate to child screen.\n * </NavigatorButton>\n * </NavigatorScreen>\n *\n * <NavigatorScreen path=\"/child\">\n * <p>This is the child screen.</p>\n * <NavigatorBackButton>\n * Go back\n * </NavigatorBackButton>\n * </NavigatorScreen>\n * </NavigatorProvider>\n * );\n * ```\n */\nexport const NavigatorProvider = contextConnect(\n\tUnconnectedNavigatorProvider,\n\t'NavigatorProvider'\n);\n\nexport default NavigatorProvider;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,UAAU,QAAQ,oBAAoB;AACxD,OAAOC,cAAc,MAAM,6BAA6B;AACxD,OAAOC,OAAO,MAAM,oBAAoB;;AAExC;AACA;AACA;;AAEA,SAASC,cAAc,EAAEC,gBAAgB,QAAQ,eAAe;AAChE,SAASC,KAAK,QAAQ,0BAA0B;AAChD,SAASC,YAAY,EAAEC,UAAU,QAAQ,iBAAiB;AAC1D,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,OAAO,KAAKC,MAAM,MAAM,WAAW;AASnC,OAAOC,UAAU,MAAM,uBAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAiB/C,SAASC,SAASA,CAAE;EAAEC;AA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AA4B,EAC5B,mBACD,CAAC;AAED,eAAewB,iBAAiB","ignoreList":[]}
@@ -10,6 +10,7 @@ import { useContext, useEffect, useMemo, useRef, useId } from '@wordpress/elemen
10
10
  import { useMergeRefs } from '@wordpress/compose';
11
11
  import { isRTL as isRTLFn } from '@wordpress/i18n';
12
12
  import { escapeAttribute } from '@wordpress/escape-html';
13
+ import warning from '@wordpress/warning';
13
14
 
14
15
  /**
15
16
  * Internal dependencies
@@ -22,6 +23,9 @@ import { NavigatorContext } from '../context';
22
23
  import * as styles from '../styles';
23
24
  import { jsx as _jsx } from "react/jsx-runtime";
24
25
  function UnconnectedNavigatorScreen(props, forwardedRef) {
26
+ if (!/^\//.test(props.path)) {
27
+ globalThis.SCRIPT_DEBUG === true ? warning('wp.components.NavigatorScreen: the `path` should follow a URL-like scheme; it should start with and be separated by the `/` character.') : void 0;
28
+ }
25
29
  const screenId = useId();
26
30
  const {
27
31
  children,
@@ -1 +1 @@
1
- {"version":3,"names":["focus","useContext","useEffect","useMemo","useRef","useId","useMergeRefs","isRTL","isRTLFn","escapeAttribute","contextConnect","useContextSystem","useCx","View","NavigatorContext","styles","jsx","_jsx","UnconnectedNavigatorScreen","props","forwardedRef","screenId","children","className","path","otherProps","location","match","addScreen","removeScreen","isMatch","wrapperRef","screen","id","isInitial","isBack","cx","classes","navigatorScreen","locationRef","current","isInitialLocation","hasRestoredFocus","skipFocus","activeElement","ownerDocument","contains","elementToFocus","focusTargetSelector","querySelector","firstTabbable","tabbable","find","mergedWrapperRef","ref","NavigatorScreen"],"sources":["@wordpress/components/src/navigator/navigator-screen/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\nimport {\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseId,\n} from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { isRTL as isRTLFn } from '@wordpress/i18n';\nimport { escapeAttribute } from '@wordpress/escape-html';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect, useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport { View } from '../../view';\nimport { NavigatorContext } from '../context';\nimport * as styles from '../styles';\nimport type { NavigatorScreenProps } from '../types';\n\nfunction UnconnectedNavigatorScreen(\n\tprops: WordPressComponentProps< NavigatorScreenProps, 'div', false >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst screenId = useId();\n\tconst { children, className, path, ...otherProps } = useContextSystem(\n\t\tprops,\n\t\t'NavigatorScreen'\n\t);\n\n\tconst { location, match, addScreen, removeScreen } =\n\t\tuseContext( NavigatorContext );\n\tconst isMatch = match === screenId;\n\tconst wrapperRef = useRef< HTMLDivElement >( null );\n\n\tuseEffect( () => {\n\t\tconst screen = {\n\t\t\tid: screenId,\n\t\t\tpath: escapeAttribute( path ),\n\t\t};\n\t\taddScreen( screen );\n\t\treturn () => removeScreen( screen );\n\t}, [ screenId, path, addScreen, removeScreen ] );\n\n\tconst isRTL = isRTLFn();\n\tconst { isInitial, isBack } = location;\n\tconst cx = useCx();\n\tconst classes = useMemo(\n\t\t() =>\n\t\t\tcx(\n\t\t\t\tstyles.navigatorScreen( {\n\t\t\t\t\tisInitial,\n\t\t\t\t\tisBack,\n\t\t\t\t\tisRTL,\n\t\t\t\t} ),\n\t\t\t\tclassName\n\t\t\t),\n\t\t[ className, cx, isInitial, isBack, isRTL ]\n\t);\n\n\tconst locationRef = useRef( location );\n\n\tuseEffect( () => {\n\t\tlocationRef.current = location;\n\t}, [ location ] );\n\n\t// Focus restoration\n\tconst isInitialLocation = location.isInitial && ! location.isBack;\n\tuseEffect( () => {\n\t\t// Only attempt to restore focus:\n\t\t// - if the current location is not the initial one (to avoid moving focus on page load)\n\t\t// - when the screen becomes visible\n\t\t// - if the wrapper ref has been assigned\n\t\t// - if focus hasn't already been restored for the current location\n\t\t// - if the `skipFocus` option is not set to `true`. This is useful when we trigger the navigation outside of NavigatorScreen.\n\t\tif (\n\t\t\tisInitialLocation ||\n\t\t\t! isMatch ||\n\t\t\t! wrapperRef.current ||\n\t\t\tlocationRef.current.hasRestoredFocus ||\n\t\t\tlocation.skipFocus\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst activeElement = wrapperRef.current.ownerDocument.activeElement;\n\n\t\t// If an element is already focused within the wrapper do not focus the\n\t\t// element. This prevents inputs or buttons from losing focus unnecessarily.\n\t\tif ( wrapperRef.current.contains( activeElement ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet elementToFocus: HTMLElement | null = null;\n\n\t\t// When navigating back, if a selector is provided, use it to look for the\n\t\t// target element (assumed to be a node inside the current NavigatorScreen)\n\t\tif ( location.isBack && location.focusTargetSelector ) {\n\t\t\telementToFocus = wrapperRef.current.querySelector(\n\t\t\t\tlocation.focusTargetSelector\n\t\t\t);\n\t\t}\n\n\t\t// If the previous query didn't run or find any element to focus, fallback\n\t\t// to the first tabbable element in the screen (or the screen itself).\n\t\tif ( ! elementToFocus ) {\n\t\t\tconst [ firstTabbable ] = focus.tabbable.find( wrapperRef.current );\n\t\t\telementToFocus = firstTabbable ?? wrapperRef.current;\n\t\t}\n\n\t\tlocationRef.current.hasRestoredFocus = true;\n\t\telementToFocus.focus();\n\t}, [\n\t\tisInitialLocation,\n\t\tisMatch,\n\t\tlocation.isBack,\n\t\tlocation.focusTargetSelector,\n\t\tlocation.skipFocus,\n\t] );\n\n\tconst mergedWrapperRef = useMergeRefs( [ forwardedRef, wrapperRef ] );\n\n\treturn isMatch ? (\n\t\t<View ref={ mergedWrapperRef } className={ classes } { ...otherProps }>\n\t\t\t{ children }\n\t\t</View>\n\t) : null;\n}\n\n/**\n * The `NavigatorScreen` component represents a single view/screen/panel and\n * should be used in combination with the `NavigatorProvider`, the\n * `NavigatorButton` and the `NavigatorBackButton` components (or the `useNavigator`\n * hook).\n *\n * @example\n * ```jsx\n * import {\n * __experimentalNavigatorProvider as NavigatorProvider,\n * __experimentalNavigatorScreen as NavigatorScreen,\n * __experimentalNavigatorButton as NavigatorButton,\n * __experimentalNavigatorBackButton as NavigatorBackButton,\n * } from '@wordpress/components';\n *\n * const MyNavigation = () => (\n * <NavigatorProvider initialPath=\"/\">\n * <NavigatorScreen path=\"/\">\n * <p>This is the home screen.</p>\n * <NavigatorButton path=\"/child\">\n * Navigate to child screen.\n * </NavigatorButton>\n * </NavigatorScreen>\n *\n * <NavigatorScreen path=\"/child\">\n * <p>This is the child screen.</p>\n * <NavigatorBackButton>\n * Go back\n * </NavigatorBackButton>\n * </NavigatorScreen>\n * </NavigatorProvider>\n * );\n * ```\n */\nexport const NavigatorScreen = contextConnect(\n\tUnconnectedNavigatorScreen,\n\t'NavigatorScreen'\n);\n\nexport default NavigatorScreen;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,gBAAgB;AACtC,SACCC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,KAAK,QACC,oBAAoB;AAC3B,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,KAAK,IAAIC,OAAO,QAAQ,iBAAiB;AAClD,SAASC,eAAe,QAAQ,wBAAwB;;AAExD;AACA;AACA;;AAEA,SAASC,cAAc,EAAEC,gBAAgB,QAAQ,eAAe;AAChE,SAASC,KAAK,QAAQ,0BAA0B;AAChD,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,OAAO,KAAKC,MAAM,MAAM,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGpC,SAASC,0BAA0BA,CAClCC,KAAoE,EACpEC,YAAiC,EAChC;EACD,MAAMC,QAAQ,GAAGhB,KAAK,CAAC,CAAC;EACxB,MAAM;IAAEiB,QAAQ;IAAEC,SAAS;IAAEC,IAAI;IAAE,GAAGC;EAAW,CAAC,GAAGd,gBAAgB,CACpEQ,K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IAAI;AACT;;AAEA;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;AACA,OAAO,MAAMiC,eAAe,GAAG7C,cAAc,CAC5CQ,0BAA0B,EAC1B,iBACD,CAAC;AAED,eAAeqC,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["focus","useContext","useEffect","useMemo","useRef","useId","useMergeRefs","isRTL","isRTLFn","escapeAttribute","warning","contextConnect","useContextSystem","useCx","View","NavigatorContext","styles","jsx","_jsx","UnconnectedNavigatorScreen","props","forwardedRef","test","path","globalThis","SCRIPT_DEBUG","screenId","children","className","otherProps","location","match","addScreen","removeScreen","isMatch","wrapperRef","screen","id","isInitial","isBack","cx","classes","navigatorScreen","locationRef","current","isInitialLocation","hasRestoredFocus","skipFocus","activeElement","ownerDocument","contains","elementToFocus","focusTargetSelector","querySelector","firstTabbable","tabbable","find","mergedWrapperRef","ref","NavigatorScreen"],"sources":["@wordpress/components/src/navigator/navigator-screen/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\nimport {\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseId,\n} from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { isRTL as isRTLFn } from '@wordpress/i18n';\nimport { escapeAttribute } from '@wordpress/escape-html';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect, useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport { View } from '../../view';\nimport { NavigatorContext } from '../context';\nimport * as styles from '../styles';\nimport type { NavigatorScreenProps } from '../types';\n\nfunction UnconnectedNavigatorScreen(\n\tprops: WordPressComponentProps< NavigatorScreenProps, 'div', false >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tif ( ! /^\\//.test( props.path ) ) {\n\t\twarning(\n\t\t\t'wp.components.NavigatorScreen: the `path` should follow a URL-like scheme; it should start with and be separated by the `/` character.'\n\t\t);\n\t}\n\n\tconst screenId = useId();\n\tconst { children, className, path, ...otherProps } = useContextSystem(\n\t\tprops,\n\t\t'NavigatorScreen'\n\t);\n\n\tconst { location, match, addScreen, removeScreen } =\n\t\tuseContext( NavigatorContext );\n\tconst isMatch = match === screenId;\n\tconst wrapperRef = useRef< HTMLDivElement >( null );\n\n\tuseEffect( () => {\n\t\tconst screen = {\n\t\t\tid: screenId,\n\t\t\tpath: escapeAttribute( path ),\n\t\t};\n\t\taddScreen( screen );\n\t\treturn () => removeScreen( screen );\n\t}, [ screenId, path, addScreen, removeScreen ] );\n\n\tconst isRTL = isRTLFn();\n\tconst { isInitial, isBack } = location;\n\tconst cx = useCx();\n\tconst classes = useMemo(\n\t\t() =>\n\t\t\tcx(\n\t\t\t\tstyles.navigatorScreen( {\n\t\t\t\t\tisInitial,\n\t\t\t\t\tisBack,\n\t\t\t\t\tisRTL,\n\t\t\t\t} ),\n\t\t\t\tclassName\n\t\t\t),\n\t\t[ className, cx, isInitial, isBack, isRTL ]\n\t);\n\n\tconst locationRef = useRef( location );\n\n\tuseEffect( () => {\n\t\tlocationRef.current = location;\n\t}, [ location ] );\n\n\t// Focus restoration\n\tconst isInitialLocation = location.isInitial && ! location.isBack;\n\tuseEffect( () => {\n\t\t// Only attempt to restore focus:\n\t\t// - if the current location is not the initial one (to avoid moving focus on page load)\n\t\t// - when the screen becomes visible\n\t\t// - if the wrapper ref has been assigned\n\t\t// - if focus hasn't already been restored for the current location\n\t\t// - if the `skipFocus` option is not set to `true`. This is useful when we trigger the navigation outside of NavigatorScreen.\n\t\tif (\n\t\t\tisInitialLocation ||\n\t\t\t! isMatch ||\n\t\t\t! wrapperRef.current ||\n\t\t\tlocationRef.current.hasRestoredFocus ||\n\t\t\tlocation.skipFocus\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst activeElement = wrapperRef.current.ownerDocument.activeElement;\n\n\t\t// If an element is already focused within the wrapper do not focus the\n\t\t// element. This prevents inputs or buttons from losing focus unnecessarily.\n\t\tif ( wrapperRef.current.contains( activeElement ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet elementToFocus: HTMLElement | null = null;\n\n\t\t// When navigating back, if a selector is provided, use it to look for the\n\t\t// target element (assumed to be a node inside the current NavigatorScreen)\n\t\tif ( location.isBack && location.focusTargetSelector ) {\n\t\t\telementToFocus = wrapperRef.current.querySelector(\n\t\t\t\tlocation.focusTargetSelector\n\t\t\t);\n\t\t}\n\n\t\t// If the previous query didn't run or find any element to focus, fallback\n\t\t// to the first tabbable element in the screen (or the screen itself).\n\t\tif ( ! elementToFocus ) {\n\t\t\tconst [ firstTabbable ] = focus.tabbable.find( wrapperRef.current );\n\t\t\telementToFocus = firstTabbable ?? wrapperRef.current;\n\t\t}\n\n\t\tlocationRef.current.hasRestoredFocus = true;\n\t\telementToFocus.focus();\n\t}, [\n\t\tisInitialLocation,\n\t\tisMatch,\n\t\tlocation.isBack,\n\t\tlocation.focusTargetSelector,\n\t\tlocation.skipFocus,\n\t] );\n\n\tconst mergedWrapperRef = useMergeRefs( [ forwardedRef, wrapperRef ] );\n\n\treturn isMatch ? (\n\t\t<View ref={ mergedWrapperRef } className={ classes } { ...otherProps }>\n\t\t\t{ children }\n\t\t</View>\n\t) : null;\n}\n\n/**\n * The `NavigatorScreen` component represents a single view/screen/panel and\n * should be used in combination with the `NavigatorProvider`, the\n * `NavigatorButton` and the `NavigatorBackButton` components (or the `useNavigator`\n * hook).\n *\n * @example\n * ```jsx\n * import {\n * __experimentalNavigatorProvider as NavigatorProvider,\n * __experimentalNavigatorScreen as NavigatorScreen,\n * __experimentalNavigatorButton as NavigatorButton,\n * __experimentalNavigatorBackButton as NavigatorBackButton,\n * } from '@wordpress/components';\n *\n * const MyNavigation = () => (\n * <NavigatorProvider initialPath=\"/\">\n * <NavigatorScreen path=\"/\">\n * <p>This is the home screen.</p>\n * <NavigatorButton path=\"/child\">\n * Navigate to child screen.\n * </NavigatorButton>\n * </NavigatorScreen>\n *\n * <NavigatorScreen path=\"/child\">\n * <p>This is the child screen.</p>\n * <NavigatorBackButton>\n * Go back\n * </NavigatorBackButton>\n * </NavigatorScreen>\n * </NavigatorProvider>\n * );\n * ```\n */\nexport const NavigatorScreen = contextConnect(\n\tUnconnectedNavigatorScreen,\n\t'NavigatorScreen'\n);\n\nexport default NavigatorScreen;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,gBAAgB;AACtC,SACCC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,KAAK,QACC,oBAAoB;AAC3B,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,KAAK,IAAIC,OAAO,QAAQ,iBAAiB;AAClD,SAASC,eAAe,QAAQ,wBAAwB;AACxD,OAAOC,OAAO,MAAM,oBAAoB;;AAExC;AACA;AACA;;AAEA,SAASC,cAAc,EAAEC,gBAAgB,QAAQ,eAAe;AAChE,SAASC,KAAK,QAAQ,0BAA0B;AAChD,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,OAAO,KAAKC,MAAM,MAAM,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGpC,SAASC,0BAA0BA,CAClCC,KAAoE,EACpEC,YAAiC,EAChC;EACD,IAAK,CAAE,KAAK,CAACC,IAAI,CAAEF,KAAK,CAACG,IAAK,CAAC,EAAG;IACjCC,UAAA,CAAAC,YAAA,YAAAf,OAAO,CACN,wIACD,CAAC;EACF;EAEA,MAAMgB,QAAQ,GAAGrB,KAAK,CAAC,CAAC;EACxB,MAAM;IAAEsB,QAAQ;IAAEC,SAAS;IAAEL,IAAI;IAAE,GAAGM;EA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A,EACjEA;EAAQ,CACL,CAAC,GACJ,IAAI;AACT;;AAEA;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;AACA,OAAO,MAAMgC,eAAe,GAAGhD,cAAc,CAC5CQ,0BAA0B,EAC1B,iBACD,CAAC;AAED,eAAewC,eAAe","ignoreList":[]}
@@ -6,7 +6,7 @@ import deprecated from '@wordpress/deprecated';
6
6
  /**
7
7
  * Internal dependencies
8
8
  */
9
- import { NavigatorBackButton } from '../navigator-back-button';
9
+ import { NavigatorBackButton } from '../navigator-back-button/component';
10
10
  import { contextConnect } from '../../context';
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  function UnconnectedNavigatorToParentButton(props, forwardedRef) {
@@ -1 +1 @@
1
- {"version":3,"names":["deprecated","NavigatorBackButton","contextConnect","jsx","_jsx","UnconnectedNavigatorToParentButton","props","forwardedRef","since","alternative","ref","NavigatorToParentButton"],"sources":["@wordpress/components/src/navigator/navigator-to-parent-button/component.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { NavigatorBackButton } from '../navigator-back-button';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport type { NavigatorBackButtonProps } from '../types';\n\nfunction UnconnectedNavigatorToParentButton(\n\tprops: WordPressComponentProps< NavigatorBackButtonProps, 'button' >,\n\tforwardedRef: React.ForwardedRef< any >\n) {\n\tdeprecated( 'wp.components.NavigatorToParentButton', {\n\t\tsince: '6.7',\n\t\talternative: 'wp.components.NavigatorBackButton',\n\t} );\n\n\treturn <NavigatorBackButton ref={ forwardedRef } { ...props } />;\n}\n\n/**\n * _Note: this component is deprecated. Please use the `NavigatorBackButton`\n * component instead._\n *\n * @deprecated\n */\nexport const NavigatorToParentButton = contextConnect(\n\tUnconnectedNavigatorToParentButton,\n\t'NavigatorToParentButton'\n);\n\nexport default NavigatorToParentButton;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AACA,SAASC,mBAAmB,QAAQ,0BAA0B;AAE9D,SAASC,cAAc,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG/C,SAASC,kCAAkCA,CAC1CC,KAAoE,EACpEC,YAAuC,EACtC;EACDP,UAAU,CAAE,uCAAuC,EAAE;IACpDQ,KAAK,EAAE,KAAK;IACZC,WAAW,EAAE;EACd,CAAE,CAAC;EAEH,oBAAOL,IAAA,CAACH,mBAAmB;IAACS,GAAG,EAAGH,YAAc;IAAA,GAAMD;EAAK,CAAI,CAAC;AACjE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMK,uBAAuB,GAAGT,cAAc,CACpDG,kCAAkC,EAClC,yBACD,CAAC;AAED,eAAeM,uBAAuB","ignoreList":[]}
1
+ {"version":3,"names":["deprecated","NavigatorBackButton","contextConnect","jsx","_jsx","UnconnectedNavigatorToParentButton","props","forwardedRef","since","alternative","ref","NavigatorToParentButton"],"sources":["@wordpress/components/src/navigator/navigator-to-parent-button/component.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { NavigatorBackButton } from '../navigator-back-button/component';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport type { NavigatorBackButtonProps } from '../types';\n\nfunction UnconnectedNavigatorToParentButton(\n\tprops: WordPressComponentProps< NavigatorBackButtonProps, 'button' >,\n\tforwardedRef: React.ForwardedRef< any >\n) {\n\tdeprecated( 'wp.components.NavigatorToParentButton', {\n\t\tsince: '6.7',\n\t\talternative: 'wp.components.NavigatorBackButton',\n\t} );\n\n\treturn <NavigatorBackButton ref={ forwardedRef } { ...props } />;\n}\n\n/**\n * _Note: this component is deprecated. Please use the `NavigatorBackButton`\n * component instead._\n *\n * @deprecated\n */\nexport const NavigatorToParentButton = contextConnect(\n\tUnconnectedNavigatorToParentButton,\n\t'NavigatorToParentButton'\n);\n\nexport default NavigatorToParentButton;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AACA,SAASC,mBAAmB,QAAQ,oCAAoC;AAExE,SAASC,cAAc,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG/C,SAASC,kCAAkCA,CAC1CC,KAAoE,EACpEC,YAAuC,EACtC;EACDP,UAAU,CAAE,uCAAuC,EAAE;IACpDQ,KAAK,EAAE,KAAK;IACZC,WAAW,EAAE;EACd,CAAE,CAAC;EAEH,oBAAOL,IAAA,CAACH,mBAAmB;IAACS,GAAG,EAAGH,YAAc;IAAA,GAAMD;EAAK,CAAI,CAAC;AACjE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMK,uBAAuB,GAAGT,cAAc,CACpDG,kCAAkC,EAClC,yBACD,CAAC;AAED,eAAeM,uBAAuB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/components/src/navigator/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { ButtonAsButtonProps } from '../button/types';\n\nexport type MatchParams = Record< string, string | string[] >;\n\nexport type NavigateOptions = {\n\t/**\n\t * Specify the CSS selector used to restore focus on an given element when\n\t * navigating back. When not provided, the component will attempt to restore\n\t * focus on the element that originated the forward navigation.\n\t */\n\tfocusTargetSelector?: string;\n\t/**\n\t * Whether the navigation is a backwards navigation. This enables focus\n\t * restoration (when possible), and causes the animation to be backwards.\n\t */\n\tisBack?: boolean;\n\t/**\n\t * Opt out of focus management. Useful when the consumer of the component\n\t * wants to manage focus themselves.\n\t */\n\tskipFocus?: boolean;\n\t/**\n\t * Whether the navigation should replace the current location in the stack.\n\t */\n\treplace?: boolean;\n};\n\nexport type NavigateToParentOptions = Omit< NavigateOptions, 'isBack' >;\n\nexport type NavigatorLocation = NavigateOptions & {\n\t/**\n\t * Whether the current location is the initial one (ie. first in the stack).\n\t */\n\tisInitial?: boolean;\n\t/**\n\t * The path associated to the location.\n\t */\n\tpath?: string;\n\t/**\n\t * Whether focus was already restored for this location (in case of\n\t * backwards navigation).\n\t */\n\thasRestoredFocus?: boolean;\n};\n\n// Returned by the `useNavigator` hook.\nexport type Navigator = {\n\t/**\n\t * The current location.\n\t */\n\tlocation: NavigatorLocation;\n\t/**\n\t * Params associated with the current location\n\t */\n\tparams: MatchParams;\n\t/**\n\t * Navigate to a new location.\n\t */\n\tgoTo: ( path: string, options?: NavigateOptions ) => void;\n\t/**\n\t * Go back to the parent location (ie. \"/some/path\" will navigate back\n\t * to \"/some\")\n\t */\n\tgoBack: ( options?: NavigateToParentOptions ) => void;\n\t/**\n\t * _Note: This function is deprecated. Please use `goBack` instead._\n\t * @deprecated\n\t * @ignore\n\t */\n\tgoToParent: ( options?: NavigateToParentOptions ) => void;\n};\n\nexport type NavigatorContext = Navigator & {\n\taddScreen: ( screen: Screen ) => void;\n\tremoveScreen: ( screen: Screen ) => void;\n\tmatch?: string;\n};\n\nexport type NavigatorProviderProps = {\n\t/**\n\t * The initial active path.\n\t */\n\tinitialPath: string;\n\t/**\n\t * The children elements.\n\t */\n\tchildren: ReactNode;\n};\n\nexport type NavigatorScreenProps = {\n\t/**\n\t * The screen's path, matched against the current path stored in the navigator.\n\t */\n\tpath: string;\n\t/**\n\t * The children elements.\n\t */\n\tchildren: ReactNode;\n};\n\nexport type NavigatorBackButtonProps = ButtonAsButtonProps;\n\nexport type NavigatorToParentButtonProps = NavigatorBackButtonProps;\n\nexport type NavigatorButtonProps = NavigatorBackButtonProps & {\n\t/**\n\t * The path of the screen to navigate to. The value of this prop needs to be\n\t * a valid value for an HTML attribute.\n\t */\n\tpath: string;\n\t/**\n\t * The HTML attribute used to identify the `NavigatorButton`, which is used\n\t * by `Navigator` to restore focus.\n\t *\n\t * @default 'id'\n\t */\n\tattributeName?: string;\n};\n\nexport type Screen = {\n\tid: string;\n\tpath: string;\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["@wordpress/components/src/navigator/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { ButtonAsButtonProps } from '../button/types';\n\nexport type MatchParams = Record< string, string | string[] >;\n\nexport type NavigateOptions = {\n\t/**\n\t * Specify the CSS selector used to restore focus on an given element when\n\t * navigating back. When not provided, the component will attempt to restore\n\t * focus on the element that originated the forward navigation.\n\t */\n\tfocusTargetSelector?: string;\n\t/**\n\t * Whether the navigation is a backwards navigation. This enables focus\n\t * restoration (when possible), and causes the animation to be backwards.\n\t */\n\tisBack?: boolean;\n\t/**\n\t * Opt out of focus management. Useful when the consumer of the component\n\t * wants to manage focus themselves.\n\t */\n\tskipFocus?: boolean;\n\t/**\n\t * Note: this option is deprecated and currently doesn't have any effect.\n\t * @deprecated\n\t * @ignore\n\t */\n\treplace?: boolean;\n};\n\nexport type NavigateToParentOptions = Omit< NavigateOptions, 'isBack' >;\n\nexport type NavigatorLocation = NavigateOptions & {\n\t/**\n\t * Whether the current location is the initial one (ie. first in the stack).\n\t */\n\tisInitial?: boolean;\n\t/**\n\t * The path associated to the location.\n\t */\n\tpath?: string;\n\t/**\n\t * Whether focus was already restored for this location (in case of\n\t * backwards navigation).\n\t */\n\thasRestoredFocus?: boolean;\n};\n\n// Returned by the `useNavigator` hook.\nexport type Navigator = {\n\t/**\n\t * The current location.\n\t */\n\tlocation: NavigatorLocation;\n\t/**\n\t * Params associated with the current location\n\t */\n\tparams: MatchParams;\n\t/**\n\t * Navigate to a new location.\n\t */\n\tgoTo: ( path: string, options?: NavigateOptions ) => void;\n\t/**\n\t * Go back to the parent location (ie. \"/some/path\" will navigate back\n\t * to \"/some\")\n\t */\n\tgoBack: ( options?: NavigateToParentOptions ) => void;\n\t/**\n\t * _Note: This function is deprecated. Please use `goBack` instead._\n\t * @deprecated\n\t * @ignore\n\t */\n\tgoToParent: ( options?: NavigateToParentOptions ) => void;\n};\n\nexport type NavigatorContext = Navigator & {\n\taddScreen: ( screen: Screen ) => void;\n\tremoveScreen: ( screen: Screen ) => void;\n\tmatch?: string;\n};\n\nexport type NavigatorProviderProps = {\n\t/**\n\t * The initial active path.\n\t */\n\tinitialPath: string;\n\t/**\n\t * The children elements.\n\t */\n\tchildren: ReactNode;\n};\n\nexport type NavigatorScreenProps = {\n\t/**\n\t * The screen's path, matched against the current path stored in the navigator.\n\t */\n\tpath: string;\n\t/**\n\t * The children elements.\n\t */\n\tchildren: ReactNode;\n};\n\nexport type NavigatorBackButtonProps = ButtonAsButtonProps;\n\nexport type NavigatorToParentButtonProps = NavigatorBackButtonProps;\n\nexport type NavigatorButtonProps = NavigatorBackButtonProps & {\n\t/**\n\t * The path of the screen to navigate to. The value of this prop needs to be\n\t * a valid value for an HTML attribute.\n\t */\n\tpath: string;\n\t/**\n\t * The HTML attribute used to identify the `NavigatorButton`, which is used\n\t * by `Navigator` to restore focus.\n\t *\n\t * @default 'id'\n\t */\n\tattributeName?: string;\n};\n\nexport type Screen = {\n\tid: string;\n\tpath: string;\n};\n"],"mappings":"","ignoreList":[]}
@@ -10,7 +10,7 @@ import { NavigatorContext } from './context';
10
10
  /**
11
11
  * Retrieves a `navigator` instance.
12
12
  */
13
- function useNavigator() {
13
+ export function useNavigator() {
14
14
  const {
15
15
  location,
16
16
  params,
@@ -26,5 +26,4 @@ function useNavigator() {
26
26
  params
27
27
  };
28
28
  }
29
- export default useNavigator;
30
29
  //# sourceMappingURL=use-navigator.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useContext","NavigatorContext","useNavigator","location","params","goTo","goBack","goToParent"],"sources":["@wordpress/components/src/navigator/use-navigator.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { NavigatorContext } from './context';\nimport type { Navigator } from './types';\n\n/**\n * Retrieves a `navigator` instance.\n */\nfunction useNavigator(): Navigator {\n\tconst { location, params, goTo, goBack, goToParent } =\n\t\tuseContext( NavigatorContext );\n\n\treturn {\n\t\tlocation,\n\t\tgoTo,\n\t\tgoBack,\n\t\tgoToParent,\n\t\tparams,\n\t};\n}\n\nexport default useNavigator;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,oBAAoB;;AAE/C;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,WAAW;AAG5C;AACA;AACA;AACA,SAASC,YAAYA,CAAA,EAAc;EAClC,MAAM;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,IAAI;IAAEC,MAAM;IAAEC;EAAW,CAAC,GACnDP,UAAU,CAAEC,gBAAiB,CAAC;EAE/B,OAAO;IACNE,QAAQ;IACRE,IAAI;IACJC,MAAM;IACNC,UAAU;IACVH;EACD,CAAC;AACF;AAEA,eAAeF,YAAY","ignoreList":[]}
1
+ {"version":3,"names":["useContext","NavigatorContext","useNavigator","location","params","goTo","goBack","goToParent"],"sources":["@wordpress/components/src/navigator/use-navigator.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { NavigatorContext } from './context';\nimport type { Navigator } from './types';\n\n/**\n * Retrieves a `navigator` instance.\n */\nexport function useNavigator(): Navigator {\n\tconst { location, params, goTo, goBack, goToParent } =\n\t\tuseContext( NavigatorContext );\n\n\treturn {\n\t\tlocation,\n\t\tgoTo,\n\t\tgoBack,\n\t\tgoToParent,\n\t\tparams,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,oBAAoB;;AAE/C;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,WAAW;AAG5C;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAA,EAAc;EACzC,MAAM;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,IAAI;IAAEC,MAAM;IAAEC;EAAW,CAAC,GACnDP,UAAU,CAAEC,gBAAiB,CAAC;EAE/B,OAAO;IACNE,QAAQ;IACRE,IAAI;IACJC,MAAM;IACNC,UAAU;IACVH;EACD,CAAC;AACF","ignoreList":[]}
@@ -202,9 +202,9 @@ function PaletteEditListView({
202
202
  addColorRef
203
203
  }) {
204
204
  // When unmounting the component if there are empty elements (the user did not complete the insertion) clean them.
205
- const elementsReference = useRef();
205
+ const elementsReferenceRef = useRef();
206
206
  useEffect(() => {
207
- elementsReference.current = elements;
207
+ elementsReferenceRef.current = elements;
208
208
  }, [elements]);
209
209
  const debounceOnChange = useDebounce(onChange, 100);
210
210
  return /*#__PURE__*/_jsx(VStack, {