@wordpress/components 33.1.1-next.v.202605131006.0 → 34.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (435) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/build/autocomplete/index.cjs +5 -4
  3. package/build/autocomplete/index.cjs.map +3 -3
  4. package/build/border-control/border-control-dropdown/component.cjs +33 -33
  5. package/build/border-control/border-control-dropdown/component.cjs.map +3 -3
  6. package/build/box-control/index.cjs +0 -6
  7. package/build/box-control/index.cjs.map +2 -2
  8. package/build/box-control/utils.cjs +0 -38
  9. package/build/box-control/utils.cjs.map +3 -3
  10. package/build/custom-gradient-picker/gradient-bar/index.cjs.map +2 -2
  11. package/build/disabled/index.cjs +1 -1
  12. package/build/disabled/index.cjs.map +2 -2
  13. package/build/draggable/index.cjs +101 -7
  14. package/build/draggable/index.cjs.map +3 -3
  15. package/build/form-token-field/index.cjs +41 -7
  16. package/build/form-token-field/index.cjs.map +2 -2
  17. package/build/higher-order/with-notices/index.cjs +3 -15
  18. package/build/higher-order/with-notices/index.cjs.map +2 -2
  19. package/build/index.cjs +0 -17
  20. package/build/index.cjs.map +2 -2
  21. package/build/input-control/input-base.cjs +31 -34
  22. package/build/input-control/input-base.cjs.map +2 -2
  23. package/build/notice/index.cjs +33 -35
  24. package/build/notice/index.cjs.map +2 -2
  25. package/build/popover/index.cjs +12 -0
  26. package/build/popover/index.cjs.map +2 -2
  27. package/build/responsive-wrapper/index.cjs +4 -3
  28. package/build/responsive-wrapper/index.cjs.map +2 -2
  29. package/build/tabs/styles.cjs +5 -5
  30. package/build/tabs/styles.cjs.map +2 -2
  31. package/build/tooltip/index.cjs +2 -1
  32. package/build/tooltip/index.cjs.map +2 -2
  33. package/build-module/autocomplete/index.mjs +6 -5
  34. package/build-module/autocomplete/index.mjs.map +2 -2
  35. package/build-module/border-control/border-control-dropdown/component.mjs +34 -34
  36. package/build-module/border-control/border-control-dropdown/component.mjs.map +2 -2
  37. package/build-module/box-control/index.mjs +0 -2
  38. package/build-module/box-control/index.mjs.map +2 -2
  39. package/build-module/box-control/utils.mjs +0 -27
  40. package/build-module/box-control/utils.mjs.map +2 -2
  41. package/build-module/custom-gradient-picker/gradient-bar/index.mjs.map +2 -2
  42. package/build-module/disabled/index.mjs +1 -1
  43. package/build-module/disabled/index.mjs.map +2 -2
  44. package/build-module/draggable/index.mjs +101 -7
  45. package/build-module/draggable/index.mjs.map +3 -3
  46. package/build-module/form-token-field/index.mjs +41 -7
  47. package/build-module/form-token-field/index.mjs.map +2 -2
  48. package/build-module/higher-order/with-notices/index.mjs +4 -16
  49. package/build-module/higher-order/with-notices/index.mjs.map +2 -2
  50. package/build-module/index.mjs +87 -99
  51. package/build-module/index.mjs.map +2 -2
  52. package/build-module/input-control/input-base.mjs +31 -34
  53. package/build-module/input-control/input-base.mjs.map +2 -2
  54. package/build-module/notice/index.mjs +34 -36
  55. package/build-module/notice/index.mjs.map +2 -2
  56. package/build-module/popover/index.mjs +12 -0
  57. package/build-module/popover/index.mjs.map +2 -2
  58. package/build-module/responsive-wrapper/index.mjs +4 -3
  59. package/build-module/responsive-wrapper/index.mjs.map +2 -2
  60. package/build-module/tabs/styles.mjs +5 -5
  61. package/build-module/tabs/styles.mjs.map +2 -2
  62. package/build-module/tooltip/index.mjs +2 -1
  63. package/build-module/tooltip/index.mjs.map +2 -2
  64. package/build-style/style-rtl.css +64 -66
  65. package/build-style/style.css +64 -66
  66. package/build-types/autocomplete/index.d.ts.map +1 -1
  67. package/build-types/badge/stories/e2e/index.story.d.ts +7 -0
  68. package/build-types/badge/stories/e2e/index.story.d.ts.map +1 -0
  69. package/build-types/border-box-control/border-box-control/hook.d.ts +24 -10
  70. package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
  71. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +26 -12
  72. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts.map +1 -1
  73. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +24 -10
  74. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
  75. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +25 -11
  76. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts.map +1 -1
  77. package/build-types/border-control/border-control/hook.d.ts +24 -10
  78. package/build-types/border-control/border-control/hook.d.ts.map +1 -1
  79. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  80. package/build-types/border-control/border-control-dropdown/hook.d.ts +23 -9
  81. package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
  82. package/build-types/box-control/index.d.ts +0 -1
  83. package/build-types/box-control/index.d.ts.map +1 -1
  84. package/build-types/box-control/styles/box-control-styles.d.ts +3 -4
  85. package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
  86. package/build-types/box-control/utils.d.ts +0 -13
  87. package/build-types/box-control/utils.d.ts.map +1 -1
  88. package/build-types/button/stories/e2e/index.story.d.ts +1 -0
  89. package/build-types/button/stories/e2e/index.story.d.ts.map +1 -1
  90. package/build-types/card/card/hook.d.ts +25 -11
  91. package/build-types/card/card/hook.d.ts.map +1 -1
  92. package/build-types/card/card-body/hook.d.ts +25 -11
  93. package/build-types/card/card-body/hook.d.ts.map +1 -1
  94. package/build-types/card/card-divider/hook.d.ts +26 -12
  95. package/build-types/card/card-divider/hook.d.ts.map +1 -1
  96. package/build-types/card/card-footer/hook.d.ts +25 -11
  97. package/build-types/card/card-footer/hook.d.ts.map +1 -1
  98. package/build-types/card/card-header/hook.d.ts +25 -11
  99. package/build-types/card/card-header/hook.d.ts.map +1 -1
  100. package/build-types/card/card-media/hook.d.ts +25 -11
  101. package/build-types/card/card-media/hook.d.ts.map +1 -1
  102. package/build-types/color-picker/styles.d.ts +3 -4
  103. package/build-types/color-picker/styles.d.ts.map +1 -1
  104. package/build-types/composite/stories/index.story.d.ts.map +1 -1
  105. package/build-types/custom-gradient-picker/gradient-bar/index.d.ts.map +1 -1
  106. package/build-types/custom-select-control-v2/styles.d.ts +4 -12
  107. package/build-types/custom-select-control-v2/styles.d.ts.map +1 -1
  108. package/build-types/date-time/time-picker/styles.d.ts +4 -4
  109. package/build-types/draggable/index.d.ts.map +1 -1
  110. package/build-types/draggable/stories/index.story.d.ts +4 -5
  111. package/build-types/draggable/stories/index.story.d.ts.map +1 -1
  112. package/build-types/draggable/types.d.ts +4 -0
  113. package/build-types/draggable/types.d.ts.map +1 -1
  114. package/build-types/elevation/hook.d.ts +25 -11
  115. package/build-types/elevation/hook.d.ts.map +1 -1
  116. package/build-types/flex/flex/hook.d.ts +25 -11
  117. package/build-types/flex/flex/hook.d.ts.map +1 -1
  118. package/build-types/flex/flex-block/hook.d.ts +25 -11
  119. package/build-types/flex/flex-block/hook.d.ts.map +1 -1
  120. package/build-types/flex/flex-item/hook.d.ts +25 -11
  121. package/build-types/flex/flex-item/hook.d.ts.map +1 -1
  122. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
  123. package/build-types/form-token-field/index.d.ts.map +1 -1
  124. package/build-types/grid/hook.d.ts +25 -11
  125. package/build-types/grid/hook.d.ts.map +1 -1
  126. package/build-types/h-stack/hook.d.ts +25 -11
  127. package/build-types/h-stack/hook.d.ts.map +1 -1
  128. package/build-types/heading/hook.d.ts +25 -11
  129. package/build-types/heading/hook.d.ts.map +1 -1
  130. package/build-types/higher-order/with-fallback-styles/index.d.ts +1 -3
  131. package/build-types/higher-order/with-filters/index.d.ts +1 -6
  132. package/build-types/higher-order/with-filters/index.d.ts.map +1 -1
  133. package/build-types/higher-order/with-notices/index.d.ts +2 -4
  134. package/build-types/higher-order/with-notices/index.d.ts.map +1 -1
  135. package/build-types/icon/stories/index.story.d.ts +0 -6
  136. package/build-types/icon/stories/index.story.d.ts.map +1 -1
  137. package/build-types/index.d.ts +1 -6
  138. package/build-types/index.d.ts.map +1 -1
  139. package/build-types/input-control/reducer/reducer.d.ts +1 -1
  140. package/build-types/item-group/item/hook.d.ts +25 -11
  141. package/build-types/item-group/item/hook.d.ts.map +1 -1
  142. package/build-types/item-group/item-group/hook.d.ts +25 -11
  143. package/build-types/item-group/item-group/hook.d.ts.map +1 -1
  144. package/build-types/menu/stories/index.story.d.ts.map +1 -1
  145. package/build-types/menu/styles.d.ts +7 -21
  146. package/build-types/menu/styles.d.ts.map +1 -1
  147. package/build-types/modal/use-modal-exit-animation.d.ts +1 -1
  148. package/build-types/navigator/navigator-back-button/hook.d.ts +26 -12
  149. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  150. package/build-types/navigator/navigator-button/hook.d.ts +26 -12
  151. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  152. package/build-types/notice/index.d.ts.map +1 -1
  153. package/build-types/notice/types.d.ts +1 -2
  154. package/build-types/notice/types.d.ts.map +1 -1
  155. package/build-types/number-control/index.d.ts +1 -1
  156. package/build-types/number-control/index.d.ts.map +1 -1
  157. package/build-types/number-control/stories/index.story.d.ts +1 -1
  158. package/build-types/number-control/stories/index.story.d.ts.map +1 -1
  159. package/build-types/popover/index.d.ts.map +1 -1
  160. package/build-types/popover/types.d.ts +2 -2
  161. package/build-types/popover/types.d.ts.map +1 -1
  162. package/build-types/range-control/index.d.ts +2 -3
  163. package/build-types/range-control/index.d.ts.map +1 -1
  164. package/build-types/range-control/stories/index.story.d.ts.map +1 -1
  165. package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
  166. package/build-types/range-control/types.d.ts +1 -5
  167. package/build-types/range-control/types.d.ts.map +1 -1
  168. package/build-types/responsive-wrapper/index.d.ts.map +1 -1
  169. package/build-types/scrollable/hook.d.ts +25 -11
  170. package/build-types/scrollable/hook.d.ts.map +1 -1
  171. package/build-types/snackbar/index.d.ts +2 -2
  172. package/build-types/snackbar/types.d.ts +2 -2
  173. package/build-types/snackbar/types.d.ts.map +1 -1
  174. package/build-types/spacer/hook.d.ts +25 -11
  175. package/build-types/spacer/hook.d.ts.map +1 -1
  176. package/build-types/surface/hook.d.ts +25 -11
  177. package/build-types/surface/hook.d.ts.map +1 -1
  178. package/build-types/tab-panel/stories/index.story.d.ts +0 -6
  179. package/build-types/tab-panel/stories/index.story.d.ts.map +1 -1
  180. package/build-types/tabs/stories/index.story.d.ts +0 -6
  181. package/build-types/tabs/stories/index.story.d.ts.map +1 -1
  182. package/build-types/tabs/styles.d.ts +3 -9
  183. package/build-types/tabs/styles.d.ts.map +1 -1
  184. package/build-types/text/hook.d.ts +25 -11
  185. package/build-types/text/hook.d.ts.map +1 -1
  186. package/build-types/tools-panel/tools-panel/hook.d.ts +25 -11
  187. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  188. package/build-types/tools-panel/tools-panel-header/hook.d.ts +25 -11
  189. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  190. package/build-types/tools-panel/tools-panel-item/hook.d.ts +25 -11
  191. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  192. package/build-types/tooltip/index.d.ts.map +1 -1
  193. package/build-types/truncate/hook.d.ts +25 -11
  194. package/build-types/truncate/hook.d.ts.map +1 -1
  195. package/build-types/unit-control/index.d.ts +1 -1
  196. package/build-types/unit-control/index.d.ts.map +1 -1
  197. package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
  198. package/build-types/utils/get-node-text.d.ts.map +1 -1
  199. package/build-types/v-stack/hook.d.ts +25 -11
  200. package/build-types/v-stack/hook.d.ts.map +1 -1
  201. package/build-types/validated-form-controls/components/number-control.d.ts +1 -1
  202. package/build-types/validated-form-controls/components/number-control.d.ts.map +1 -1
  203. package/build-types/validated-form-controls/components/range-control.d.ts +2 -3
  204. package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -1
  205. package/build-types/validated-form-controls/control-with-error.d.ts +4 -1
  206. package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
  207. package/package.json +27 -25
  208. package/src/autocomplete/README.md +1 -1
  209. package/src/autocomplete/index.tsx +25 -7
  210. package/src/badge/stories/e2e/index.story.tsx +21 -0
  211. package/src/border-control/border-control-dropdown/component.tsx +36 -37
  212. package/src/box-control/index.tsx +0 -1
  213. package/src/box-control/utils.ts +0 -43
  214. package/src/button/stories/e2e/index.story.tsx +11 -0
  215. package/src/composite/stories/index.story.tsx +0 -1
  216. package/src/custom-gradient-picker/gradient-bar/index.tsx +1 -1
  217. package/src/disabled/index.tsx +1 -1
  218. package/src/draggable/index.tsx +32 -10
  219. package/src/draggable/stories/index.story.tsx +11 -6
  220. package/src/draggable/style.module.scss +29 -0
  221. package/src/draggable/types.ts +4 -0
  222. package/src/form-file-upload/README.md +1 -1
  223. package/src/form-token-field/index.tsx +84 -8
  224. package/src/form-token-field/test/index.tsx +189 -0
  225. package/src/h-stack/hook.tsx +1 -1
  226. package/src/higher-order/with-notices/index.tsx +4 -21
  227. package/src/higher-order/with-notices/test/index.tsx +0 -18
  228. package/src/icon/stories/index.story.tsx +2 -14
  229. package/src/index.ts +0 -6
  230. package/src/input-control/input-base.tsx +2 -2
  231. package/src/menu/README.md +7 -7
  232. package/src/menu/stories/index.story.tsx +0 -1
  233. package/src/menu/test/index.tsx +9 -4
  234. package/src/modal/style.scss +2 -1
  235. package/src/notice/README.md +1 -2
  236. package/src/notice/index.tsx +57 -64
  237. package/src/notice/style.scss +49 -41
  238. package/src/notice/test/__snapshots__/index.tsx.snap +23 -23
  239. package/src/notice/test/index.tsx +5 -5
  240. package/src/notice/types.ts +1 -2
  241. package/src/popover/index.tsx +29 -1
  242. package/src/popover/test/index.tsx +138 -1
  243. package/src/popover/types.ts +2 -4
  244. package/src/range-control/stories/index.story.tsx +0 -1
  245. package/src/range-control/types.ts +1 -5
  246. package/src/responsive-wrapper/index.tsx +7 -3
  247. package/src/snackbar/README.md +1 -1
  248. package/src/snackbar/types.ts +2 -2
  249. package/src/style.scss +0 -1
  250. package/src/tab-panel/stories/index.story.tsx +2 -13
  251. package/src/tab-panel/style.scss +36 -14
  252. package/src/tabs/README.md +1 -1
  253. package/src/tabs/stories/index.story.tsx +2 -14
  254. package/src/tabs/styles.ts +3 -8
  255. package/src/tabs/tablist.tsx +1 -1
  256. package/src/tooltip/index.tsx +7 -1
  257. package/src/tree-grid/test/cell.tsx +0 -1
  258. package/src/tree-grid/test/roving-tab-index-item.tsx +0 -1
  259. package/src/tree-select/README.md +1 -1
  260. package/src/utils/get-node-text.ts +7 -1
  261. package/src/validated-form-controls/control-with-error.tsx +6 -1
  262. package/build/navigation/back-button/index.cjs +0 -86
  263. package/build/navigation/back-button/index.cjs.map +0 -7
  264. package/build/navigation/constants.cjs +0 -34
  265. package/build/navigation/constants.cjs.map +0 -7
  266. package/build/navigation/context.cjs +0 -58
  267. package/build/navigation/context.cjs.map +0 -7
  268. package/build/navigation/group/context.cjs +0 -38
  269. package/build/navigation/group/context.cjs.map +0 -7
  270. package/build/navigation/group/index.cjs +0 -88
  271. package/build/navigation/group/index.cjs.map +0 -7
  272. package/build/navigation/index.cjs +0 -113
  273. package/build/navigation/index.cjs.map +0 -7
  274. package/build/navigation/item/base-content.cjs +0 -44
  275. package/build/navigation/item/base-content.cjs.map +0 -7
  276. package/build/navigation/item/base.cjs +0 -66
  277. package/build/navigation/item/base.cjs.map +0 -7
  278. package/build/navigation/item/index.cjs +0 -119
  279. package/build/navigation/item/index.cjs.map +0 -7
  280. package/build/navigation/item/use-navigation-tree-item.cjs +0 -64
  281. package/build/navigation/item/use-navigation-tree-item.cjs.map +0 -7
  282. package/build/navigation/menu/context.cjs +0 -39
  283. package/build/navigation/menu/context.cjs.map +0 -7
  284. package/build/navigation/menu/index.cjs +0 -114
  285. package/build/navigation/menu/index.cjs.map +0 -7
  286. package/build/navigation/menu/menu-title-search.cjs +0 -111
  287. package/build/navigation/menu/menu-title-search.cjs.map +0 -7
  288. package/build/navigation/menu/menu-title.cjs +0 -104
  289. package/build/navigation/menu/menu-title.cjs.map +0 -7
  290. package/build/navigation/menu/search-no-results-found.cjs +0 -48
  291. package/build/navigation/menu/search-no-results-found.cjs.map +0 -7
  292. package/build/navigation/menu/use-navigation-tree-menu.cjs +0 -51
  293. package/build/navigation/menu/use-navigation-tree-menu.cjs.map +0 -7
  294. package/build/navigation/styles/navigation-styles.cjs +0 -170
  295. package/build/navigation/styles/navigation-styles.cjs.map +0 -7
  296. package/build/navigation/types.cjs +0 -19
  297. package/build/navigation/types.cjs.map +0 -7
  298. package/build/navigation/use-create-navigation-tree.cjs +0 -103
  299. package/build/navigation/use-create-navigation-tree.cjs.map +0 -7
  300. package/build/navigation/use-navigation-tree-nodes.cjs +0 -60
  301. package/build/navigation/use-navigation-tree-nodes.cjs.map +0 -7
  302. package/build/navigation/utils.cjs +0 -45
  303. package/build/navigation/utils.cjs.map +0 -7
  304. package/build-module/navigation/back-button/index.mjs +0 -51
  305. package/build-module/navigation/back-button/index.mjs.map +0 -7
  306. package/build-module/navigation/constants.mjs +0 -8
  307. package/build-module/navigation/constants.mjs.map +0 -7
  308. package/build-module/navigation/context.mjs +0 -32
  309. package/build-module/navigation/context.mjs.map +0 -7
  310. package/build-module/navigation/group/context.mjs +0 -12
  311. package/build-module/navigation/group/context.mjs.map +0 -7
  312. package/build-module/navigation/group/index.mjs +0 -53
  313. package/build-module/navigation/group/index.mjs.map +0 -7
  314. package/build-module/navigation/index.mjs +0 -78
  315. package/build-module/navigation/index.mjs.map +0 -7
  316. package/build-module/navigation/item/base-content.mjs +0 -23
  317. package/build-module/navigation/item/base-content.mjs.map +0 -7
  318. package/build-module/navigation/item/base.mjs +0 -35
  319. package/build-module/navigation/item/base.mjs.map +0 -7
  320. package/build-module/navigation/item/index.mjs +0 -84
  321. package/build-module/navigation/item/index.mjs.map +0 -7
  322. package/build-module/navigation/item/use-navigation-tree-item.mjs +0 -39
  323. package/build-module/navigation/item/use-navigation-tree-item.mjs.map +0 -7
  324. package/build-module/navigation/menu/context.mjs +0 -13
  325. package/build-module/navigation/menu/context.mjs.map +0 -7
  326. package/build-module/navigation/menu/index.mjs +0 -79
  327. package/build-module/navigation/menu/index.mjs.map +0 -7
  328. package/build-module/navigation/menu/menu-title-search.mjs +0 -80
  329. package/build-module/navigation/menu/menu-title-search.mjs.map +0 -7
  330. package/build-module/navigation/menu/menu-title.mjs +0 -73
  331. package/build-module/navigation/menu/menu-title.mjs.map +0 -7
  332. package/build-module/navigation/menu/search-no-results-found.mjs +0 -27
  333. package/build-module/navigation/menu/search-no-results-found.mjs.map +0 -7
  334. package/build-module/navigation/menu/use-navigation-tree-menu.mjs +0 -26
  335. package/build-module/navigation/menu/use-navigation-tree-menu.mjs.map +0 -7
  336. package/build-module/navigation/styles/navigation-styles.mjs +0 -124
  337. package/build-module/navigation/styles/navigation-styles.mjs.map +0 -7
  338. package/build-module/navigation/types.mjs +0 -1
  339. package/build-module/navigation/types.mjs.map +0 -7
  340. package/build-module/navigation/use-create-navigation-tree.mjs +0 -78
  341. package/build-module/navigation/use-create-navigation-tree.mjs.map +0 -7
  342. package/build-module/navigation/use-navigation-tree-nodes.mjs +0 -35
  343. package/build-module/navigation/use-navigation-tree-nodes.mjs.map +0 -7
  344. package/build-module/navigation/utils.mjs +0 -9
  345. package/build-module/navigation/utils.mjs.map +0 -7
  346. package/build-types/navigation/back-button/index.d.ts +0 -7
  347. package/build-types/navigation/back-button/index.d.ts.map +0 -1
  348. package/build-types/navigation/constants.d.ts +0 -3
  349. package/build-types/navigation/constants.d.ts.map +0 -1
  350. package/build-types/navigation/context.d.ts +0 -4
  351. package/build-types/navigation/context.d.ts.map +0 -1
  352. package/build-types/navigation/group/context.d.ts +0 -7
  353. package/build-types/navigation/group/context.d.ts.map +0 -1
  354. package/build-types/navigation/group/index.d.ts +0 -7
  355. package/build-types/navigation/group/index.d.ts.map +0 -1
  356. package/build-types/navigation/index.d.ts +0 -46
  357. package/build-types/navigation/index.d.ts.map +0 -1
  358. package/build-types/navigation/item/base-content.d.ts +0 -3
  359. package/build-types/navigation/item/base-content.d.ts.map +0 -1
  360. package/build-types/navigation/item/base.d.ts +0 -3
  361. package/build-types/navigation/item/base.d.ts.map +0 -1
  362. package/build-types/navigation/item/index.d.ts +0 -7
  363. package/build-types/navigation/item/index.d.ts.map +0 -1
  364. package/build-types/navigation/item/use-navigation-tree-item.d.ts +0 -3
  365. package/build-types/navigation/item/use-navigation-tree-item.d.ts.map +0 -1
  366. package/build-types/navigation/menu/context.d.ts +0 -7
  367. package/build-types/navigation/menu/context.d.ts.map +0 -1
  368. package/build-types/navigation/menu/index.d.ts +0 -7
  369. package/build-types/navigation/menu/index.d.ts.map +0 -1
  370. package/build-types/navigation/menu/menu-title-search.d.ts +0 -3
  371. package/build-types/navigation/menu/menu-title-search.d.ts.map +0 -1
  372. package/build-types/navigation/menu/menu-title.d.ts +0 -3
  373. package/build-types/navigation/menu/menu-title.d.ts.map +0 -1
  374. package/build-types/navigation/menu/search-no-results-found.d.ts +0 -3
  375. package/build-types/navigation/menu/search-no-results-found.d.ts.map +0 -1
  376. package/build-types/navigation/menu/use-navigation-tree-menu.d.ts +0 -3
  377. package/build-types/navigation/menu/use-navigation-tree-menu.d.ts.map +0 -1
  378. package/build-types/navigation/stories/index.story.d.ts +0 -23
  379. package/build-types/navigation/stories/index.story.d.ts.map +0 -1
  380. package/build-types/navigation/stories/utils/controlled-state.d.ts +0 -7
  381. package/build-types/navigation/stories/utils/controlled-state.d.ts.map +0 -1
  382. package/build-types/navigation/stories/utils/default.d.ts +0 -10
  383. package/build-types/navigation/stories/utils/default.d.ts.map +0 -1
  384. package/build-types/navigation/stories/utils/group.d.ts +0 -10
  385. package/build-types/navigation/stories/utils/group.d.ts.map +0 -1
  386. package/build-types/navigation/stories/utils/hide-if-empty.d.ts +0 -10
  387. package/build-types/navigation/stories/utils/hide-if-empty.d.ts.map +0 -1
  388. package/build-types/navigation/stories/utils/more-examples.d.ts +0 -10
  389. package/build-types/navigation/stories/utils/more-examples.d.ts.map +0 -1
  390. package/build-types/navigation/stories/utils/search.d.ts +0 -10
  391. package/build-types/navigation/stories/utils/search.d.ts.map +0 -1
  392. package/build-types/navigation/styles/navigation-styles.d.ts +0 -55
  393. package/build-types/navigation/styles/navigation-styles.d.ts.map +0 -1
  394. package/build-types/navigation/test/index.d.ts +0 -2
  395. package/build-types/navigation/test/index.d.ts.map +0 -1
  396. package/build-types/navigation/types.d.ts +0 -266
  397. package/build-types/navigation/types.d.ts.map +0 -1
  398. package/build-types/navigation/use-create-navigation-tree.d.ts +0 -15
  399. package/build-types/navigation/use-create-navigation-tree.d.ts.map +0 -1
  400. package/build-types/navigation/use-navigation-tree-nodes.d.ts +0 -10
  401. package/build-types/navigation/use-navigation-tree-nodes.d.ts.map +0 -1
  402. package/build-types/navigation/utils.d.ts +0 -3
  403. package/build-types/navigation/utils.d.ts.map +0 -1
  404. package/src/draggable/style.scss +0 -21
  405. package/src/navigation/README.md +0 -267
  406. package/src/navigation/back-button/index.tsx +0 -73
  407. package/src/navigation/constants.tsx +0 -2
  408. package/src/navigation/context.tsx +0 -40
  409. package/src/navigation/group/context.tsx +0 -16
  410. package/src/navigation/group/index.tsx +0 -73
  411. package/src/navigation/index.tsx +0 -152
  412. package/src/navigation/item/base-content.tsx +0 -31
  413. package/src/navigation/item/base.tsx +0 -42
  414. package/src/navigation/item/index.tsx +0 -112
  415. package/src/navigation/item/use-navigation-tree-item.tsx +0 -47
  416. package/src/navigation/menu/context.tsx +0 -20
  417. package/src/navigation/menu/index.tsx +0 -105
  418. package/src/navigation/menu/menu-title-search.tsx +0 -99
  419. package/src/navigation/menu/menu-title.tsx +0 -100
  420. package/src/navigation/menu/search-no-results-found.tsx +0 -34
  421. package/src/navigation/menu/use-navigation-tree-menu.tsx +0 -29
  422. package/src/navigation/stories/index.story.tsx +0 -62
  423. package/src/navigation/stories/style.css +0 -25
  424. package/src/navigation/stories/utils/controlled-state.tsx +0 -149
  425. package/src/navigation/stories/utils/default.tsx +0 -92
  426. package/src/navigation/stories/utils/group.tsx +0 -61
  427. package/src/navigation/stories/utils/hide-if-empty.tsx +0 -66
  428. package/src/navigation/stories/utils/more-examples.tsx +0 -162
  429. package/src/navigation/stories/utils/search.tsx +0 -91
  430. package/src/navigation/styles/navigation-styles.tsx +0 -197
  431. package/src/navigation/test/index.tsx +0 -347
  432. package/src/navigation/types.ts +0 -325
  433. package/src/navigation/use-create-navigation-tree.tsx +0 -110
  434. package/src/navigation/use-navigation-tree-nodes.tsx +0 -31
  435. package/src/navigation/utils.tsx +0 -11
@@ -1,11 +1,97 @@
1
1
  // packages/components/src/draggable/index.tsx
2
2
  import { throttle } from "@wordpress/compose";
3
3
  import { useEffect, useRef } from "@wordpress/element";
4
+ import { getWpCompatOverlaySlot } from "@wordpress/ui";
5
+
6
+ // packages/style-runtime/src/index.ts
7
+ var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
8
+ function getRuntime() {
9
+ const globalScope = globalThis;
10
+ if (globalScope.__wpStyleRuntime) {
11
+ return globalScope.__wpStyleRuntime;
12
+ }
13
+ globalScope.__wpStyleRuntime = {
14
+ documents: /* @__PURE__ */ new Map(),
15
+ styles: /* @__PURE__ */ new Map(),
16
+ injectedStyles: /* @__PURE__ */ new WeakMap()
17
+ };
18
+ if (typeof document !== "undefined") {
19
+ registerDocument(document);
20
+ }
21
+ return globalScope.__wpStyleRuntime;
22
+ }
23
+ function documentContainsStyleHash(targetDocument, hash) {
24
+ if (!targetDocument.head) {
25
+ return false;
26
+ }
27
+ for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {
28
+ if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
29
+ return true;
30
+ }
31
+ }
32
+ return false;
33
+ }
34
+ function injectStyle(targetDocument, hash, css) {
35
+ if (!targetDocument.head) {
36
+ return;
37
+ }
38
+ const runtime = getRuntime();
39
+ let injectedStyles = runtime.injectedStyles.get(targetDocument);
40
+ if (!injectedStyles) {
41
+ injectedStyles = /* @__PURE__ */ new Set();
42
+ runtime.injectedStyles.set(targetDocument, injectedStyles);
43
+ }
44
+ if (injectedStyles.has(hash)) {
45
+ return;
46
+ }
47
+ if (documentContainsStyleHash(targetDocument, hash)) {
48
+ injectedStyles.add(hash);
49
+ return;
50
+ }
51
+ const style = targetDocument.createElement("style");
52
+ style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
53
+ style.appendChild(targetDocument.createTextNode(css));
54
+ targetDocument.head.appendChild(style);
55
+ injectedStyles.add(hash);
56
+ }
57
+ function registerDocument(targetDocument) {
58
+ const runtime = getRuntime();
59
+ runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
60
+ for (const [hash, css] of runtime.styles) {
61
+ injectStyle(targetDocument, hash, css);
62
+ }
63
+ return () => {
64
+ const count = runtime.documents.get(targetDocument);
65
+ if (count === void 0) {
66
+ return;
67
+ }
68
+ if (count <= 1) {
69
+ runtime.documents.delete(targetDocument);
70
+ return;
71
+ }
72
+ runtime.documents.set(targetDocument, count - 1);
73
+ };
74
+ }
75
+ function registerStyle(hash, css) {
76
+ const runtime = getRuntime();
77
+ runtime.styles.set(hash, css);
78
+ for (const targetDocument of runtime.documents.keys()) {
79
+ injectStyle(targetDocument, hash, css);
80
+ }
81
+ }
82
+
83
+ // packages/components/src/draggable/style.module.scss
84
+ if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
85
+ registerStyle("f8d1257e92", "._3476c2e530687f96__invisible-drag-image{height:50px;left:-1000px;position:fixed;width:50px}._6f00e51ab7574306__clone{background:#0000;padding:0;pointer-events:none;position:fixed}._6f00e51ab7574306__clone:not(._664ecd37377558df__is-in-compat-slot){z-index:1000000000}body.is-dragging-components-draggable{cursor:move;cursor:grabbing!important}");
86
+ }
87
+ var style_module_default = { "invisible-drag-image": "_3476c2e530687f96__invisible-drag-image", "clone": "_6f00e51ab7574306__clone", "is-in-compat-slot": "_664ecd37377558df__is-in-compat-slot" };
88
+
89
+ // packages/components/src/draggable/index.tsx
4
90
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
5
- var dragImageClass = "components-draggable__invisible-drag-image";
6
- var cloneWrapperClass = "components-draggable__clone";
7
- var clonePadding = 0;
91
+ var dragImageClasses = [style_module_default["invisible-drag-image"], "components-draggable__invisible-drag-image"].filter(Boolean);
92
+ var cloneWrapperClasses = [style_module_default.clone, "components-draggable__clone"].filter(Boolean);
8
93
  var bodyClass = "is-dragging-components-draggable";
94
+ var clonePadding = 0;
9
95
  function Draggable({
10
96
  children,
11
97
  onDragStart,
@@ -32,17 +118,23 @@ function Draggable({
32
118
  const {
33
119
  ownerDocument
34
120
  } = event.target;
121
+ const slot = getWpCompatOverlaySlot();
122
+ const compatSlot = slot?.ownerDocument === ownerDocument ? slot : null;
35
123
  event.dataTransfer.setData(transferDataType, JSON.stringify(transferData));
36
124
  const cloneWrapper = ownerDocument.createElement("div");
37
125
  cloneWrapper.style.top = "0";
38
126
  cloneWrapper.style.left = "0";
39
127
  const dragImage = ownerDocument.createElement("div");
40
128
  if ("function" === typeof event.dataTransfer.setDragImage) {
41
- dragImage.classList.add(dragImageClass);
129
+ dragImage.classList.add(...dragImageClasses);
42
130
  ownerDocument.body.appendChild(dragImage);
43
131
  event.dataTransfer.setDragImage(dragImage, 0, 0);
44
132
  }
45
- cloneWrapper.classList.add(cloneWrapperClass);
133
+ cloneWrapper.classList.add(...cloneWrapperClasses);
134
+ const inSlotClass = style_module_default["is-in-compat-slot"];
135
+ if (compatSlot && inSlotClass) {
136
+ cloneWrapper.classList.add(inSlotClass);
137
+ }
46
138
  if (cloneClassname) {
47
139
  cloneWrapper.classList.add(cloneClassname);
48
140
  }
@@ -55,7 +147,7 @@ function Draggable({
55
147
  const clonedDragComponent = ownerDocument.createElement("div");
56
148
  clonedDragComponent.innerHTML = dragComponentRef.current.innerHTML;
57
149
  cloneWrapper.appendChild(clonedDragComponent);
58
- ownerDocument.body.appendChild(cloneWrapper);
150
+ (compatSlot ?? ownerDocument.body).appendChild(cloneWrapper);
59
151
  } else {
60
152
  const element = ownerDocument.getElementById(elementId);
61
153
  const elementRect = element.getBoundingClientRect();
@@ -70,7 +162,9 @@ function Draggable({
70
162
  cloneWrapper.style.transform = `translate( ${x}px, ${y}px )`;
71
163
  Array.from(clone.querySelectorAll("iframe")).forEach((child) => child.parentNode?.removeChild(child));
72
164
  cloneWrapper.appendChild(clone);
73
- if (appendToOwnerDocument) {
165
+ if (compatSlot) {
166
+ compatSlot.appendChild(cloneWrapper);
167
+ } else if (appendToOwnerDocument) {
74
168
  ownerDocument.body.appendChild(cloneWrapper);
75
169
  } else {
76
170
  elementWrapper?.appendChild(cloneWrapper);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/draggable/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\nimport { throttle } from '@wordpress/compose';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst dragImageClass = 'components-draggable__invisible-drag-image';\nconst cloneWrapperClass = 'components-draggable__clone';\nconst clonePadding = 0;\nconst bodyClass = 'is-dragging-components-draggable';\n\n/**\n * `Draggable` is a Component that provides a way to set up a cross-browser\n * (including IE) customizable drag image and the transfer data for the drag\n * event. It decouples the drag handle and the element to drag: use it by\n * wrapping the component that will become the drag handle and providing the DOM\n * ID of the element to drag.\n *\n * Note that the drag handle needs to declare the `draggable=\"true\"` property\n * and bind the `Draggable`s `onDraggableStart` and `onDraggableEnd` event\n * handlers to its own `onDragStart` and `onDragEnd` respectively. `Draggable`\n * takes care of the logic to setup the drag image and the transfer data, but is\n * not concerned with creating an actual DOM element that is draggable.\n *\n * ```jsx\n * import { Draggable, Panel, PanelBody } from '@wordpress/components';\n * import { Icon, more } from '@wordpress/icons';\n *\n * const MyDraggable = () => (\n * <div id=\"draggable-panel\">\n * <Panel header=\"Draggable panel\">\n * <PanelBody>\n * <Draggable elementId=\"draggable-panel\" transferData={ {} }>\n * { ( { onDraggableStart, onDraggableEnd } ) => (\n * <div\n * className=\"example-drag-handle\"\n * draggable\n * onDragStart={ onDraggableStart }\n * onDragEnd={ onDraggableEnd }\n * >\n * <Icon icon={ more } />\n * </div>\n * ) }\n * </Draggable>\n * </PanelBody>\n * </Panel>\n * </div>\n * );\n * ```\n */\nexport function Draggable({\n children,\n onDragStart,\n onDragOver,\n onDragEnd,\n appendToOwnerDocument = false,\n cloneClassname,\n elementId,\n transferData,\n __experimentalTransferDataType: transferDataType = 'text',\n __experimentalDragComponent: dragComponent\n}) {\n const dragComponentRef = useRef(null);\n const cleanupRef = useRef(() => {});\n\n /**\n * Removes the element clone, resets cursor, and removes drag listener.\n *\n * @param event The non-custom DragEvent.\n */\n function end(event) {\n event.preventDefault();\n cleanupRef.current();\n if (onDragEnd) {\n onDragEnd(event);\n }\n }\n\n /**\n * This method does a couple of things:\n *\n * - Clones the current element and spawns clone over original element.\n * - Adds a fake temporary drag image to avoid browser defaults.\n * - Sets transfer data.\n * - Adds dragover listener.\n *\n * @param event The non-custom DragEvent.\n */\n function start(event) {\n const {\n ownerDocument\n } = event.target;\n event.dataTransfer.setData(transferDataType, JSON.stringify(transferData));\n const cloneWrapper = ownerDocument.createElement('div');\n // Reset position to 0,0. Natural stacking order will position this lower, even with a transform otherwise.\n cloneWrapper.style.top = '0';\n cloneWrapper.style.left = '0';\n const dragImage = ownerDocument.createElement('div');\n\n // Set a fake drag image to avoid browser defaults. Remove from DOM\n // right after. event.dataTransfer.setDragImage is not supported yet in\n // IE, we need to check for its existence first.\n if ('function' === typeof event.dataTransfer.setDragImage) {\n dragImage.classList.add(dragImageClass);\n ownerDocument.body.appendChild(dragImage);\n event.dataTransfer.setDragImage(dragImage, 0, 0);\n }\n cloneWrapper.classList.add(cloneWrapperClass);\n if (cloneClassname) {\n cloneWrapper.classList.add(cloneClassname);\n }\n let x = 0;\n let y = 0;\n // If a dragComponent is defined, the following logic will clone the\n // HTML node and inject it into the cloneWrapper.\n if (dragComponentRef.current) {\n // Position dragComponent at the same position as the cursor.\n x = event.clientX;\n y = event.clientY;\n cloneWrapper.style.transform = `translate( ${x}px, ${y}px )`;\n const clonedDragComponent = ownerDocument.createElement('div');\n clonedDragComponent.innerHTML = dragComponentRef.current.innerHTML;\n cloneWrapper.appendChild(clonedDragComponent);\n\n // Inject the cloneWrapper into the DOM.\n ownerDocument.body.appendChild(cloneWrapper);\n } else {\n const element = ownerDocument.getElementById(elementId);\n\n // Prepare element clone and append to element wrapper.\n const elementRect = element.getBoundingClientRect();\n const elementWrapper = element.parentNode;\n const elementTopOffset = elementRect.top;\n const elementLeftOffset = elementRect.left;\n cloneWrapper.style.width = `${elementRect.width + clonePadding * 2}px`;\n const clone = element.cloneNode(true);\n clone.id = `clone-${elementId}`;\n\n // Position clone right over the original element (20px padding).\n x = elementLeftOffset - clonePadding;\n y = elementTopOffset - clonePadding;\n cloneWrapper.style.transform = `translate( ${x}px, ${y}px )`;\n\n // Hack: Remove iFrames as it's causing the embeds drag clone to freeze.\n Array.from(clone.querySelectorAll('iframe')).forEach(child => child.parentNode?.removeChild(child));\n cloneWrapper.appendChild(clone);\n\n // Inject the cloneWrapper into the DOM.\n if (appendToOwnerDocument) {\n ownerDocument.body.appendChild(cloneWrapper);\n } else {\n elementWrapper?.appendChild(cloneWrapper);\n }\n }\n\n // Mark the current cursor coordinates.\n let cursorLeft = event.clientX;\n let cursorTop = event.clientY;\n function over(e) {\n // Skip doing any work if mouse has not moved.\n if (cursorLeft === e.clientX && cursorTop === e.clientY) {\n return;\n }\n const nextX = x + e.clientX - cursorLeft;\n const nextY = y + e.clientY - cursorTop;\n cloneWrapper.style.transform = `translate( ${nextX}px, ${nextY}px )`;\n cursorLeft = e.clientX;\n cursorTop = e.clientY;\n x = nextX;\n y = nextY;\n if (onDragOver) {\n onDragOver(e);\n }\n }\n\n // Aim for 60fps (16 ms per frame) for now. We can potentially use requestAnimationFrame (raf) instead,\n // note that browsers may throttle raf below 60fps in certain conditions.\n // @ts-ignore\n const throttledDragOver = throttle(over, 16);\n ownerDocument.addEventListener('dragover', throttledDragOver);\n\n // Update cursor to 'grabbing', document wide.\n ownerDocument.body.classList.add(bodyClass);\n if (onDragStart) {\n onDragStart(event);\n }\n cleanupRef.current = () => {\n // Remove drag clone.\n if (cloneWrapper && cloneWrapper.parentNode) {\n cloneWrapper.parentNode.removeChild(cloneWrapper);\n }\n if (dragImage && dragImage.parentNode) {\n dragImage.parentNode.removeChild(dragImage);\n }\n\n // Reset cursor.\n ownerDocument.body.classList.remove(bodyClass);\n ownerDocument.removeEventListener('dragover', throttledDragOver);\n };\n }\n useEffect(() => () => {\n cleanupRef.current();\n }, []);\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [children({\n onDraggableStart: start,\n onDraggableEnd: end\n }), dragComponent && /*#__PURE__*/_jsx(\"div\", {\n className: \"components-draggable-drag-component-root\",\n style: {\n display: 'none'\n },\n ref: dragComponentRef,\n children: dragComponent\n })]\n });\n}\nexport default Draggable;"],
5
- "mappings": ";AAOA,SAAS,gBAAgB;AACzB,SAAS,WAAW,cAAc;AAKlC,SAAS,OAAO,MAAM,YAAY,WAAW,QAAQ,aAAa;AAClE,IAAM,iBAAiB;AACvB,IAAM,oBAAoB;AAC1B,IAAM,eAAe;AACrB,IAAM,YAAY;AAyCX,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA,gCAAgC,mBAAmB;AAAA,EACnD,6BAA6B;AAC/B,GAAG;AACD,QAAM,mBAAmB,OAAO,IAAI;AACpC,QAAM,aAAa,OAAO,MAAM;AAAA,EAAC,CAAC;AAOlC,WAAS,IAAI,OAAO;AAClB,UAAM,eAAe;AACrB,eAAW,QAAQ;AACnB,QAAI,WAAW;AACb,gBAAU,KAAK;AAAA,IACjB;AAAA,EACF;AAYA,WAAS,MAAM,OAAO;AACpB,UAAM;AAAA,MACJ;AAAA,IACF,IAAI,MAAM;AACV,UA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ACL,UAAU;AAAA,IACZ,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACA,IAAO,oBAAQ;",
3
+ "sources": ["../../src/draggable/index.tsx", "../../../style-runtime/src/index.ts", "../../src/draggable/style.module.scss"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\nimport { throttle } from '@wordpress/compose';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { getWpCompatOverlaySlot } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\n\nimport styles from './style.module.scss';\n\n// Legacy class names preserved alongside the CSS-module hashed ones for\n// backwards compatibility. `filter(Boolean)` strips `undefined` from Jest's\n// CSS-module mock.\nimport { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst dragImageClasses = [styles['invisible-drag-image'], 'components-draggable__invisible-drag-image'].filter(Boolean);\nconst cloneWrapperClasses = [styles.clone, 'components-draggable__clone'].filter(Boolean);\n// Global class \u2014 shared with external code (e.g. block-editor keyboard drag).\nconst bodyClass = 'is-dragging-components-draggable';\nconst clonePadding = 0;\n\n/**\n * `Draggable` is a Component that provides a way to set up a cross-browser\n * (including IE) customizable drag image and the transfer data for the drag\n * event. It decouples the drag handle and the element to drag: use it by\n * wrapping the component that will become the drag handle and providing the DOM\n * ID of the element to drag.\n *\n * Note that the drag handle needs to declare the `draggable=\"true\"` property\n * and bind the `Draggable`s `onDraggableStart` and `onDraggableEnd` event\n * handlers to its own `onDragStart` and `onDragEnd` respectively. `Draggable`\n * takes care of the logic to setup the drag image and the transfer data, but is\n * not concerned with creating an actual DOM element that is draggable.\n *\n * ```jsx\n * import { Draggable, Panel, PanelBody } from '@wordpress/components';\n * import { Icon, more } from '@wordpress/icons';\n *\n * const MyDraggable = () => (\n * <div id=\"draggable-panel\">\n * <Panel header=\"Draggable panel\">\n * <PanelBody>\n * <Draggable elementId=\"draggable-panel\" transferData={ {} }>\n * { ( { onDraggableStart, onDraggableEnd } ) => (\n * <div\n * className=\"example-drag-handle\"\n * draggable\n * onDragStart={ onDraggableStart }\n * onDragEnd={ onDraggableEnd }\n * >\n * <Icon icon={ more } />\n * </div>\n * ) }\n * </Draggable>\n * </PanelBody>\n * </Panel>\n * </div>\n * );\n * ```\n */\nexport function Draggable({\n children,\n onDragStart,\n onDragOver,\n onDragEnd,\n appendToOwnerDocument = false,\n cloneClassname,\n elementId,\n transferData,\n __experimentalTransferDataType: transferDataType = 'text',\n __experimentalDragComponent: dragComponent\n}) {\n const dragComponentRef = useRef(null);\n const cleanupRef = useRef(() => {});\n\n /**\n * Removes the element clone, resets cursor, and removes drag listener.\n *\n * @param event The non-custom DragEvent.\n */\n function end(event) {\n event.preventDefault();\n cleanupRef.current();\n if (onDragEnd) {\n onDragEnd(event);\n }\n }\n\n /**\n * This method does a couple of things:\n *\n * - Clones the current element and spawns clone over original element.\n * - Adds a fake temporary drag image to avoid browser defaults.\n * - Sets transfer data.\n * - Adds dragover listener.\n *\n * @param event The non-custom DragEvent.\n */\n function start(event) {\n const {\n ownerDocument\n } = event.target;\n // Only use the slot when it lives in the same document as the\n // dragged element, so coordinate resolution stays in one space.\n const slot = getWpCompatOverlaySlot();\n const compatSlot = slot?.ownerDocument === ownerDocument ? slot : null;\n event.dataTransfer.setData(transferDataType, JSON.stringify(transferData));\n const cloneWrapper = ownerDocument.createElement('div');\n // Reset position to 0,0. Natural stacking order will position this lower, even with a transform otherwise.\n cloneWrapper.style.top = '0';\n cloneWrapper.style.left = '0';\n const dragImage = ownerDocument.createElement('div');\n\n // Set a fake drag image to avoid browser defaults. Remove from DOM\n // right after. event.dataTransfer.setDragImage is not supported yet in\n // IE, we need to check for its existence first.\n if ('function' === typeof event.dataTransfer.setDragImage) {\n dragImage.classList.add(...dragImageClasses);\n // Invisible \u2014 stays at the document body, no slot needed.\n ownerDocument.body.appendChild(dragImage);\n event.dataTransfer.setDragImage(dragImage, 0, 0);\n }\n cloneWrapper.classList.add(...cloneWrapperClasses);\n const inSlotClass = styles['is-in-compat-slot'];\n if (compatSlot && inSlotClass) {\n cloneWrapper.classList.add(inSlotClass);\n }\n if (cloneClassname) {\n cloneWrapper.classList.add(cloneClassname);\n }\n let x = 0;\n let y = 0;\n // If a dragComponent is defined, the following logic will clone the\n // HTML node and inject it into the cloneWrapper.\n if (dragComponentRef.current) {\n // Position dragComponent at the same position as the cursor.\n x = event.clientX;\n y = event.clientY;\n cloneWrapper.style.transform = `translate( ${x}px, ${y}px )`;\n const clonedDragComponent = ownerDocument.createElement('div');\n clonedDragComponent.innerHTML = dragComponentRef.current.innerHTML;\n cloneWrapper.appendChild(clonedDragComponent);\n (compatSlot ?? ownerDocument.body).appendChild(cloneWrapper);\n } else {\n const element = ownerDocument.getElementById(elementId);\n\n // Prepare element clone and append to element wrapper.\n const elementRect = element.getBoundingClientRect();\n const elementWrapper = element.parentNode;\n const elementTopOffset = elementRect.top;\n const elementLeftOffset = elementRect.left;\n cloneWrapper.style.width = `${elementRect.width + clonePadding * 2}px`;\n const clone = element.cloneNode(true);\n clone.id = `clone-${elementId}`;\n\n // Position clone right over the original element (20px padding).\n x = elementLeftOffset - clonePadding;\n y = elementTopOffset - clonePadding;\n cloneWrapper.style.transform = `translate( ${x}px, ${y}px )`;\n\n // Hack: Remove iFrames as it's causing the embeds drag clone to freeze.\n Array.from(clone.querySelectorAll('iframe')).forEach(child => child.parentNode?.removeChild(child));\n cloneWrapper.appendChild(clone);\n if (compatSlot) {\n compatSlot.appendChild(cloneWrapper);\n } else if (appendToOwnerDocument) {\n ownerDocument.body.appendChild(cloneWrapper);\n } else {\n elementWrapper?.appendChild(cloneWrapper);\n }\n }\n\n // Mark the current cursor coordinates.\n let cursorLeft = event.clientX;\n let cursorTop = event.clientY;\n function over(e) {\n // Skip doing any work if mouse has not moved.\n if (cursorLeft === e.clientX && cursorTop === e.clientY) {\n return;\n }\n const nextX = x + e.clientX - cursorLeft;\n const nextY = y + e.clientY - cursorTop;\n cloneWrapper.style.transform = `translate( ${nextX}px, ${nextY}px )`;\n cursorLeft = e.clientX;\n cursorTop = e.clientY;\n x = nextX;\n y = nextY;\n if (onDragOver) {\n onDragOver(e);\n }\n }\n\n // Aim for 60fps (16 ms per frame) for now. We can potentially use requestAnimationFrame (raf) instead,\n // note that browsers may throttle raf below 60fps in certain conditions.\n // @ts-ignore\n const throttledDragOver = throttle(over, 16);\n ownerDocument.addEventListener('dragover', throttledDragOver);\n\n // Update cursor to 'grabbing', document wide.\n ownerDocument.body.classList.add(bodyClass);\n if (onDragStart) {\n onDragStart(event);\n }\n cleanupRef.current = () => {\n // Remove drag clone.\n if (cloneWrapper && cloneWrapper.parentNode) {\n cloneWrapper.parentNode.removeChild(cloneWrapper);\n }\n if (dragImage && dragImage.parentNode) {\n dragImage.parentNode.removeChild(dragImage);\n }\n\n // Reset cursor.\n ownerDocument.body.classList.remove(bodyClass);\n ownerDocument.removeEventListener('dragover', throttledDragOver);\n };\n }\n useEffect(() => () => {\n cleanupRef.current();\n }, []);\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [children({\n onDraggableStart: start,\n onDraggableEnd: end\n }), dragComponent && /*#__PURE__*/_jsx(\"div\", {\n className: \"components-draggable-drag-component-root\",\n style: {\n display: 'none'\n },\n ref: dragComponentRef,\n children: dragComponent\n })]\n });\n}\nexport default Draggable;", "const STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n const globalScope = globalThis;\n if (globalScope.__wpStyleRuntime) {\n return globalScope.__wpStyleRuntime;\n }\n globalScope.__wpStyleRuntime = {\n documents: new Map(),\n styles: new Map(),\n injectedStyles: new WeakMap()\n };\n if (typeof document !== 'undefined') {\n registerDocument(document);\n }\n return globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(targetDocument, hash) {\n if (!targetDocument.head) {\n return false;\n }\n for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {\n if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle(targetDocument, hash, css) {\n if (!targetDocument.head) {\n return;\n }\n const runtime = getRuntime();\n let injectedStyles = runtime.injectedStyles.get(targetDocument);\n if (!injectedStyles) {\n injectedStyles = new Set();\n runtime.injectedStyles.set(targetDocument, injectedStyles);\n }\n if (injectedStyles.has(hash)) {\n return;\n }\n\n // Older generated CSS module output can still inject matching style tags\n // after this document's cache is created, so keep the DOM as the fallback\n // source of truth on cache misses.\n if (documentContainsStyleHash(targetDocument, hash)) {\n injectedStyles.add(hash);\n return;\n }\n const style = targetDocument.createElement('style');\n style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);\n style.appendChild(targetDocument.createTextNode(css));\n targetDocument.head.appendChild(style);\n injectedStyles.add(hash);\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument(targetDocument) {\n const runtime = getRuntime();\n runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);\n for (const [hash, css] of runtime.styles) {\n injectStyle(targetDocument, hash, css);\n }\n return () => {\n const count = runtime.documents.get(targetDocument);\n if (count === undefined) {\n return;\n }\n if (count <= 1) {\n runtime.documents.delete(targetDocument);\n return;\n }\n runtime.documents.set(targetDocument, count - 1);\n };\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle(hash, css) {\n const runtime = getRuntime();\n runtime.styles.set(hash, css);\n for (const targetDocument of runtime.documents.keys()) {\n injectStyle(targetDocument, hash, css);\n }\n}", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"f8d1257e92\", \"._3476c2e530687f96__invisible-drag-image{height:50px;left:-1000px;position:fixed;width:50px}._6f00e51ab7574306__clone{background:#0000;padding:0;pointer-events:none;position:fixed}._6f00e51ab7574306__clone:not(._664ecd37377558df__is-in-compat-slot){z-index:1000000000}body.is-dragging-components-draggable{cursor:move;cursor:grabbing!important}\");\n}\nexport default {\"invisible-drag-image\":\"_3476c2e530687f96__invisible-drag-image\",\"clone\":\"_6f00e51ab7574306__clone\",\"is-in-compat-slot\":\"_664ecd37377558df__is-in-compat-slot\"};\n"],
5
+ "mappings": ";AAOA,SAAS,gBAAgB;AACzB,SAAS,WAAW,cAAc;AAClC,SAAS,8BAA8B;;;ACTvC,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACpB,QAAM,cAAc;AACpB,MAAI,YAAY,kBAAkB;AAChC,WAAO,YAAY;AAAA,EACrB;AACA,cAAY,mBAAmB;AAAA,IAC7B,WAAW,oBAAI,IAAI;AAAA,IACnB,QAAQ,oBAAI,IAAI;AAAA,IAChB,gBAAgB,oBAAI,QAAQ;AAAA,EAC9B;AACA,MAAI,OAAO,aAAa,aAAa;AACnC,qBAAiB,QAAQ;AAAA,EAC3B;AACA,SAAO,YAAY;AACrB;AAUA,SAAS,0BAA0B,gBAAgB,MAAM;AACvD,MAAI,CAAC,eAAe,MAAM;AACxB,WAA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SAAS;AAAA,MACX;AAAA,MACA,KAAK;AAAA,MACL,UAAU;AAAA,IACZ,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACA,IAAO,oBAAQ;",
6
6
  "names": []
7
7
  }
@@ -169,7 +169,9 @@ function FormTokenField(props) {
169
169
  break;
170
170
  case "Space":
171
171
  if (tokenizeOnSpace) {
172
- preventDefault = addCurrentToken();
172
+ preventDefault = addCurrentToken({
173
+ preventDefaultOnFailedValidation: false
174
+ });
173
175
  }
174
176
  break;
175
177
  case "Escape":
@@ -223,7 +225,35 @@ function FormTokenField(props) {
223
225
  const items = text.split(separator);
224
226
  const tokenValue = items[items.length - 1] || "";
225
227
  if (items.length > 1) {
226
- addNewTokens(items.slice(0, -1));
228
+ const tokensToProcess = items.slice(0, -1);
229
+ const willFailValidation = (segment) => {
230
+ const transformed = saveTransform(segment);
231
+ return !!transformed && !valueContainsToken(transformed) && !__experimentalValidateInput(transformed);
232
+ };
233
+ const hasFailures = tokensToProcess.some(willFailValidation);
234
+ const addedTokens = addNewTokens(hasFailures ? items : tokensToProcess);
235
+ if (hasFailures) {
236
+ const rejected = items.filter((token) => {
237
+ const transformed = saveTransform(token);
238
+ if (!transformed) {
239
+ return false;
240
+ }
241
+ if (addedTokens.has(transformed)) {
242
+ return false;
243
+ }
244
+ if (valueContainsToken(transformed)) {
245
+ return false;
246
+ }
247
+ return !__experimentalValidateInput(transformed);
248
+ });
249
+ const usedSeparators = text.match(/[ ,\t]/g);
250
+ const separatorChar = usedSeparators?.[usedSeparators.length - 1] ?? (tokenizeOnSpace ? " " : ",");
251
+ const trailing = tokenValue === "" ? separatorChar : "";
252
+ const remaining = rejected.join(separatorChar) + trailing;
253
+ setIncompleteTokenValue(remaining);
254
+ onInputChange(remaining);
255
+ return;
256
+ }
227
257
  }
228
258
  setIncompleteTokenValue(tokenValue);
229
259
  onInputChange(tokenValue);
@@ -314,30 +344,33 @@ function FormTokenField(props) {
314
344
  moveInputToIndex(index);
315
345
  }
316
346
  }
317
- function addCurrentToken() {
347
+ function addCurrentToken({
348
+ preventDefaultOnFailedValidation = true
349
+ } = {}) {
318
350
  let preventDefault = false;
319
351
  const selectedSuggestion = getSelectedSuggestion();
320
352
  if (selectedSuggestion) {
321
353
  addNewToken(selectedSuggestion);
322
354
  preventDefault = true;
323
355
  } else if (inputHasValidValue()) {
324
- addNewToken(incompleteTokenValue);
325
- preventDefault = true;
356
+ const passedValidation = addNewToken(incompleteTokenValue);
357
+ preventDefault = passedValidation || preventDefaultOnFailedValidation;
326
358
  }
327
359
  return preventDefault;
328
360
  }
329
361
  function addNewTokens(tokens) {
330
- const tokensToAdd = [...new Set(tokens.map(saveTransform).filter(Boolean).filter((token) => !valueContainsToken(token)))];
362
+ const tokensToAdd = [...new Set(tokens.map(saveTransform).filter(Boolean).filter((token) => !valueContainsToken(token)).filter((token) => __experimentalValidateInput(token)))];
331
363
  if (tokensToAdd.length > 0) {
332
364
  const newValue = [...value];
333
365
  newValue.splice(getIndexOfInput(), 0, ...tokensToAdd);
334
366
  onChange(newValue);
335
367
  }
368
+ return new Set(tokensToAdd);
336
369
  }
337
370
  function addNewToken(token) {
338
371
  if (!__experimentalValidateInput(token)) {
339
372
  speak(messages.__experimentalInvalid, "assertive");
340
- return;
373
+ return false;
341
374
  }
342
375
  addNewTokens([token]);
343
376
  speak(messages.added, "assertive");
@@ -348,6 +381,7 @@ function FormTokenField(props) {
348
381
  if (isActive && !tokenizeOnBlur) {
349
382
  focus();
350
383
  }
384
+ return true;
351
385
  }
352
386
  function deleteToken(token) {
353
387
  const newTokens = value.filter((item) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/form-token-field/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce, useInstanceId, usePrevious } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport Token from './token';\nimport TokenInput from './token-input';\nimport { TokensAndInputWrapperFlex } from './styles';\nimport SuggestionsList from './suggestions-list';\nimport { FlexItem } from '../flex';\nimport { StyledHelp, StyledLabel } from '../base-control/styles/base-control-styles';\nimport { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';\nimport { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst identity = value => value;\n\n/**\n * A `FormTokenField` is a field similar to the tags and categories fields in the interim editor chrome,\n * or the \"to\" field in Mail on OS X. Tokens can be entered by typing them or selecting them from a list of suggested tokens.\n *\n * Up to one hundred suggestions that match what the user has typed so far will be shown from which the user can pick from (auto-complete).\n * Tokens are separated by the \",\" character. Suggestions can be selected with the up or down arrows and added with the tab or enter key.\n *\n * The `value` property is handled in a manner similar to controlled form components.\n * See [Forms](https://react.dev/reference/react-dom/components#form-components) in the React Documentation for more information.\n */\nexport function FormTokenField(props) {\n const {\n autoCapitalize,\n autoComplete,\n maxLength,\n placeholder,\n label = __('Add item'),\n className,\n suggestions = [],\n maxSuggestions = 100,\n value = [],\n displayTransform = identity,\n saveTransform = token => token.trim(),\n onChange = () => {},\n onInputChange = () => {},\n onFocus = undefined,\n isBorderless = false,\n disabled = false,\n tokenizeOnSpace = false,\n messages = {\n added: __('Item added.'),\n removed: __('Item removed.'),\n remove: __('Remove item'),\n __experimentalInvalid: __('Invalid item')\n },\n __experimentalRenderItem,\n __experimentalExpandOnFocus = false,\n __experimentalValidateInput = () => true,\n __experimentalShowHowTo,\n __next40pxDefaultSize = false,\n __experimentalAutoSelectFirstMatch = false,\n tokenizeOnBlur = false,\n help\n } = useDeprecated36pxDefaultSizeProp(props);\n maybeWarnDeprecated36pxSize({\n componentName: 'FormTokenField',\n size: undefined,\n __next40pxDefaultSize\n });\n const defaultHelp = tokenizeOnSpace ? __('Separate with commas, spaces, or the Enter key.') : __('Separate with commas or the Enter key.');\n let computedHelp = help !== undefined ? help : defaultHelp;\n if (typeof __experimentalShowHowTo === 'boolean') {\n deprecated('`__experimentalShowHowTo` prop in wp.components.FormTokenField', {\n since: '7.1',\n alternative: '`help` prop',\n hint: 'The `help` prop now defaults to the previous how-to text. Pass an empty string to hide it.'\n });\n if (__experimentalShowHowTo === false && help === undefined) {\n computedHelp = '';\n }\n }\n const instanceId = useInstanceId(FormTokenField);\n\n // We reset to these initial values again in the onBlur\n const [incompleteTokenValue, setIncompleteTokenValue] = useState('');\n const [inputOffsetFromEnd, setInputOffsetFromEnd] = useState(0);\n const [isActive, setIsActive] = useState(false);\n const [isExpanded, setIsExpanded] = useState(false);\n const [selectedSuggestionIndex, setSelectedSuggestionIndex] = useState(-1);\n const [selectedSuggestionScroll, setSelectedSuggestionScroll] = useState(false);\n const prevSuggestions = usePrevious(suggestions);\n const prevValue = usePrevious(value);\n const input = useRef(null);\n const tokensAndInput = useRef(null);\n const debouncedSpeak = useDebounce(speak, 500);\n useEffect(() => {\n // Make sure to focus the input when the isActive state is true.\n if (isActive && !hasFocus()) {\n focus();\n }\n }, [isActive]);\n useEffect(() => {\n const suggestionsDidUpdate = !isShallowEqual(suggestions, prevSuggestions || []);\n if (suggestionsDidUpdate || value !== prevValue) {\n updateSuggestions(suggestionsDidUpdate);\n }\n\n // TODO: updateSuggestions() should first be refactored so its actual deps are clearer.\n }, [suggestions, prevSuggestions, value, prevValue]);\n useEffect(() => {\n updateSuggestions();\n }, [incompleteTokenValue]);\n useEffect(() => {\n updateSuggestions();\n }, [__experimentalAutoSelectFirstMatch]);\n if (disabled && isActive) {\n setIsActive(false);\n setIncompleteTokenValue('');\n }\n function focus() {\n input.current?.focus();\n }\n function hasFocus() {\n return input.current === input.current?.ownerDocument.activeElement;\n }\n function onFocusHandler(event) {\n // If focus is on the input or on the container, set the isActive state to true.\n if (hasFocus() || event.target === tokensAndInput.current) {\n setIsActive(true);\n setIsExpanded(__experimentalExpandOnFocus || isExpanded);\n } else {\n /*\n * Otherwise, focus is on one of the token \"remove\" buttons and we\n * set the isActive state to false to prevent the input to be\n * re-focused, see componentDidUpdate().\n */\n setIsActive(false);\n }\n if ('function' === typeof onFocus) {\n onFocus(event);\n }\n }\n function onBlur(event) {\n if (inputHasValidValue() && __experimentalValidateInput(incompleteTokenValue)) {\n setIsActive(false);\n if (tokenizeOnBlur && inputHasValidValue()) {\n addNewToken(incompleteTokenValue);\n }\n } else {\n // Reset to initial state\n setIncompleteTokenValue('');\n setInputOffsetFromEnd(0);\n setIsActive(false);\n if (__experimentalExpandOnFocus) {\n // If `__experimentalExpandOnFocus` is true, don't close the suggestions list when\n // the user clicks on it (`tokensAndInput` will be the element that caused the blur).\n const hasFocusWithin = event.relatedTarget === tokensAndInput.current;\n setIsExpanded(hasFocusWithin);\n } else {\n // Else collapse the suggestion list. This will result in the suggestion list closing\n // after a suggestion has been submitted since that causes a blur.\n setIsExpanded(false);\n }\n setSelectedSuggestionIndex(-1);\n setSelectedSuggestionScroll(false);\n }\n }\n function onKeyDown(event) {\n let preventDefault = false;\n if (event.defaultPrevented) {\n return;\n }\n switch (event.key) {\n case 'Backspace':\n preventDefault = handleDeleteKey(deleteTokenBeforeInput);\n break;\n case 'Enter':\n preventDefault = addCurrentToken();\n break;\n case 'ArrowLeft':\n preventDefault = handleLeftArrowKey();\n break;\n case 'ArrowUp':\n preventDefault = handleUpArrowKey();\n break;\n case 'ArrowRight':\n preventDefault = handleRightArrowKey();\n break;\n case 'ArrowDown':\n preventDefault = handleDownArrowKey();\n break;\n case 'Delete':\n preventDefault = handleDeleteKey(deleteTokenAfterInput);\n break;\n case 'Space':\n if (tokenizeOnSpace) {\n preventDefault = addCurrentToken();\n }\n break;\n case 'Escape':\n preventDefault = handleEscapeKey(event);\n break;\n case 'Tab':\n preventDefault = handleTabKey(event);\n break;\n default:\n break;\n }\n if (preventDefault) {\n event.preventDefault();\n }\n }\n function onKeyPress(event) {\n let preventDefault = false;\n switch (event.key) {\n case ',':\n preventDefault = handleCommaKey();\n break;\n default:\n break;\n }\n if (preventDefault) {\n event.preventDefault();\n }\n }\n function onContainerTouched(event) {\n // Prevent clicking/touching the tokensAndInput container from blurring\n // the input and adding the current token.\n if (event.target === tokensAndInput.current && isActive) {\n event.preventDefault();\n }\n }\n function onTokenClickRemove(event) {\n deleteToken(event.value);\n focus();\n }\n function onSuggestionHovered(suggestion) {\n const index = getMatchingSuggestions().indexOf(suggestion);\n if (index >= 0) {\n setSelectedSuggestionIndex(index);\n setSelectedSuggestionScroll(false);\n }\n }\n function onSuggestionSelected(suggestion) {\n addNewToken(suggestion);\n }\n function onInputChangeHandler(event) {\n const text = event.value;\n const separator = tokenizeOnSpace ? /[ ,\\t]+/ : /[,\\t]+/;\n const items = text.split(separator);\n const tokenValue = items[items.length - 1] || '';\n if (items.length > 1) {\n addNewTokens(items.slice(0, -1));\n }\n setIncompleteTokenValue(tokenValue);\n onInputChange(tokenValue);\n }\n function handleDeleteKey(_deleteToken) {\n let preventDefault = false;\n if (hasFocus() && isInputEmpty()) {\n _deleteToken();\n preventDefault = true;\n }\n return preventDefault;\n }\n function handleLeftArrowKey() {\n let preventDefault = false;\n if (isInputEmpty()) {\n moveInputBeforePreviousToken();\n preventDefault = true;\n }\n return preventDefault;\n }\n function handleRightArrowKey() {\n let preventDefault = false;\n if (isInputEmpty()) {\n moveInputAfterNextToken();\n preventDefault = true;\n }\n return preventDefault;\n }\n function handleUpArrowKey() {\n setSelectedSuggestionIndex(index => {\n return (index === 0 ? getMatchingSuggestions(incompleteTokenValue, suggestions, value, maxSuggestions, saveTransform).length : index) - 1;\n });\n setSelectedSuggestionScroll(true);\n return true; // PreventDefault.\n }\n function handleDownArrowKey() {\n setSelectedSuggestionIndex(index => {\n return (index + 1) % getMatchingSuggestions(incompleteTokenValue, suggestions, value, maxSuggestions, saveTransform).length;\n });\n setSelectedSuggestionScroll(true);\n return true; // PreventDefault.\n }\n function collapseSuggestionsList(event) {\n if (event.target instanceof HTMLInputElement) {\n setIncompleteTokenValue(event.target.value);\n setIsExpanded(false);\n setSelectedSuggestionIndex(-1);\n setSelectedSuggestionScroll(false);\n }\n }\n function handleEscapeKey(event) {\n collapseSuggestionsList(event);\n return true; // PreventDefault.\n }\n function handleTabKey(event) {\n collapseSuggestionsList(event);\n return false; // Do not prevent the default behavior.\n }\n function handleCommaKey() {\n if (inputHasValidValue()) {\n addNewToken(incompleteTokenValue);\n }\n return true; // PreventDefault.\n }\n function moveInputToIndex(index) {\n setInputOffsetFromEnd(value.length - Math.max(index, -1) - 1);\n }\n function moveInputBeforePreviousToken() {\n setInputOffsetFromEnd(prevInputOffsetFromEnd => {\n return Math.min(prevInputOffsetFromEnd + 1, value.length);\n });\n }\n function moveInputAfterNextToken() {\n setInputOffsetFromEnd(prevInputOffsetFromEnd => {\n return Math.max(prevInputOffsetFromEnd - 1, 0);\n });\n }\n function deleteTokenBeforeInput() {\n const index = getIndexOfInput() - 1;\n if (index > -1) {\n deleteToken(value[index]);\n }\n }\n function deleteTokenAfterInput() {\n const index = getIndexOfInput();\n if (index < value.length) {\n deleteToken(value[index]);\n // Update input offset since it's the offset from the last token.\n moveInputToIndex(index);\n }\n }\n function addCurrentToken() {\n let preventDefault = false;\n const selectedSuggestion = getSelectedSuggestion();\n if (selectedSuggestion) {\n addNewToken(selectedSuggestion);\n preventDefault = true;\n } else if (inputHasValidValue()) {\n addNewToken(incompleteTokenValue);\n preventDefault = true;\n }\n return preventDefault;\n }\n function addNewTokens(tokens) {\n const tokensToAdd = [...new Set(tokens.map(saveTransform).filter(Boolean).filter(token => !valueContainsToken(token)))];\n if (tokensToAdd.length > 0) {\n const newValue = [...value];\n newValue.splice(getIndexOfInput(), 0, ...tokensToAdd);\n onChange(newValue);\n }\n }\n function addNewToken(token) {\n if (!__experimentalValidateInput(token)) {\n speak(messages.__experimentalInvalid, 'assertive');\n return;\n }\n addNewTokens([token]);\n speak(messages.added, 'assertive');\n setIncompleteTokenValue('');\n setSelectedSuggestionIndex(-1);\n setSelectedSuggestionScroll(false);\n setIsExpanded(!__experimentalExpandOnFocus);\n if (isActive && !tokenizeOnBlur) {\n focus();\n }\n }\n function deleteToken(token) {\n const newTokens = value.filter(item => {\n return getTokenValue(item) !== getTokenValue(token);\n });\n onChange(newTokens);\n speak(messages.removed, 'assertive');\n }\n function getTokenValue(token) {\n if ('object' === typeof token) {\n return token.value;\n }\n return token;\n }\n function getMatchingSuggestions(searchValue = incompleteTokenValue, _suggestions = suggestions, _value = value, _maxSuggestions = maxSuggestions, _saveTransform = saveTransform) {\n let match = _saveTransform(searchValue);\n const startsWithMatch = [];\n const containsMatch = [];\n const normalizedValue = _value.map(item => {\n if (typeof item === 'string') {\n return item;\n }\n return item.value;\n });\n if (match.length === 0) {\n _suggestions = _suggestions.filter(suggestion => !normalizedValue.includes(suggestion));\n } else {\n match = match.normalize('NFKC').toLocaleLowerCase();\n _suggestions.forEach(suggestion => {\n const index = suggestion.normalize('NFKC').toLocaleLowerCase().indexOf(match);\n if (normalizedValue.indexOf(suggestion) === -1) {\n if (index === 0) {\n startsWithMatch.push(suggestion);\n } else if (index > 0) {\n containsMatch.push(suggestion);\n }\n }\n });\n _suggestions = startsWithMatch.concat(containsMatch);\n }\n return _suggestions.slice(0, _maxSuggestions);\n }\n function getSelectedSuggestion() {\n if (selectedSuggestionIndex !== -1) {\n return getMatchingSuggestions()[selectedSuggestionIndex];\n }\n return undefined;\n }\n function valueContainsToken(token) {\n return value.some(item => {\n return getTokenValue(token) === getTokenValue(item);\n });\n }\n function getIndexOfInput() {\n return value.length - inputOffsetFromEnd;\n }\n function isInputEmpty() {\n return incompleteTokenValue.length === 0;\n }\n function inputHasValidValue() {\n return saveTransform(incompleteTokenValue).length > 0;\n }\n function updateSuggestions(resetSelectedSuggestion = true) {\n const inputHasMinimumChars = incompleteTokenValue.trim().length > 1;\n const matchingSuggestions = getMatchingSuggestions(incompleteTokenValue);\n const hasMatchingSuggestions = matchingSuggestions.length > 0;\n const shouldExpandIfFocuses = hasFocus() && __experimentalExpandOnFocus;\n setIsExpanded(shouldExpandIfFocuses || inputHasMinimumChars && hasMatchingSuggestions);\n if (resetSelectedSuggestion) {\n if (__experimentalAutoSelectFirstMatch && inputHasMinimumChars && hasMatchingSuggestions) {\n setSelectedSuggestionIndex(0);\n setSelectedSuggestionScroll(true);\n } else {\n setSelectedSuggestionIndex(-1);\n setSelectedSuggestionScroll(false);\n }\n }\n if (inputHasMinimumChars) {\n const message = hasMatchingSuggestions ? sprintf(/* translators: %d: number of results. */\n _n('%d result found, use up and down arrow keys to navigate.', '%d results found, use up and down arrow keys to navigate.', matchingSuggestions.length), matchingSuggestions.length) : __('No results.');\n debouncedSpeak(message, 'assertive');\n }\n }\n function renderTokensAndInput() {\n const components = value.map(renderToken);\n components.splice(getIndexOfInput(), 0, renderInput());\n return components;\n }\n function renderToken(token, index, tokens) {\n const _value = getTokenValue(token);\n const status = typeof token !== 'string' ? token.status : undefined;\n const termPosition = index + 1;\n const termsCount = tokens.length;\n return /*#__PURE__*/_jsx(FlexItem, {\n children: /*#__PURE__*/_jsx(Token, {\n value: _value,\n status: status,\n title: typeof token !== 'string' ? token.title : undefined,\n displayTransform: displayTransform,\n onClickRemove: onTokenClickRemove,\n isBorderless: typeof token !== 'string' && token.isBorderless || isBorderless,\n onMouseEnter: typeof token !== 'string' ? token.onMouseEnter : undefined,\n onMouseLeave: typeof token !== 'string' ? token.onMouseLeave : undefined,\n disabled: 'error' !== status && disabled,\n messages: messages,\n termsCount: termsCount,\n termPosition: termPosition\n })\n }, 'token-' + _value);\n }\n function renderInput() {\n const describedById = computedHelp ? `components-form-token-input-${instanceId}__help` : undefined;\n const inputProps = {\n instanceId,\n autoCapitalize,\n autoComplete,\n placeholder: value.length === 0 ? placeholder : '',\n disabled,\n value: incompleteTokenValue,\n onBlur,\n isExpanded,\n selectedSuggestionIndex,\n 'aria-describedby': describedById\n };\n return /*#__PURE__*/_jsx(TokenInput, {\n ...inputProps,\n onChange: !(maxLength && value.length >= maxLength) ? onInputChangeHandler : undefined,\n ref: input\n }, \"input\");\n }\n const classes = clsx(className, 'components-form-token-field__input-container', {\n 'is-active': isActive,\n 'is-disabled': disabled\n });\n let tokenFieldProps = {\n className: 'components-form-token-field',\n tabIndex: -1\n };\n const matchingSuggestions = getMatchingSuggestions();\n if (!disabled) {\n tokenFieldProps = Object.assign({}, tokenFieldProps, {\n onKeyDown: withIgnoreIMEEvents(onKeyDown),\n onKeyPress,\n onFocus: onFocusHandler\n });\n }\n\n // Disable reason: There is no appropriate role which describes the\n // input container intended accessible usability.\n // TODO: Refactor click detection to use blur to stop propagation.\n /* eslint-disable jsx-a11y/no-static-element-interactions */\n return /*#__PURE__*/_jsxs(\"div\", {\n ...tokenFieldProps,\n children: [label && /*#__PURE__*/_jsx(StyledLabel, {\n htmlFor: `components-form-token-input-${instanceId}`,\n className: \"components-form-token-field__label\",\n children: label\n }), /*#__PURE__*/_jsxs(\"div\", {\n ref: tokensAndInput,\n className: classes,\n tabIndex: -1,\n onMouseDown: onContainerTouched,\n onTouchStart: onContainerTouched,\n children: [/*#__PURE__*/_jsx(TokensAndInputWrapperFlex, {\n justify: \"flex-start\",\n align: \"center\",\n gap: 1,\n wrap: true,\n __next40pxDefaultSize: __next40pxDefaultSize,\n hasTokens: !!value.length,\n children: renderTokensAndInput()\n }), isExpanded && /*#__PURE__*/_jsx(SuggestionsList, {\n instanceId: instanceId,\n match: saveTransform(incompleteTokenValue),\n displayTransform: displayTransform,\n suggestions: matchingSuggestions,\n selectedIndex: selectedSuggestionIndex,\n scrollIntoView: selectedSuggestionScroll,\n onHover: onSuggestionHovered,\n onSelect: onSuggestionSelected,\n __experimentalRenderItem: __experimentalRenderItem\n })]\n }), computedHelp && /*#__PURE__*/_jsx(StyledHelp, {\n id: `components-form-token-input-${instanceId}__help`,\n className: \"components-form-token-field__help\",\n children: computedHelp\n })]\n });\n /* eslint-enable jsx-a11y/no-static-element-interactions */\n}\nexport default FormTokenField;"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,WAAW,QAAQ,gBAAgB;AAC5C,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,aAAa,eAAe,mBAAmB;AACxD,SAAS,aAAa;AACtB,SAAS,sBAAsB;AAC/B,OAAO,gBAAgB;AAKvB,OAAO,WAAW;AAClB,OAAO,gBAAgB;AACvB,SAAS,iCAAiC;AAC1C,OAAO,qBAAqB;AAC5B,SAAS,gBAAgB;AACzB,SAAS,YAAY,mBAAmB;AACxC,SAAS,wCAAwC;AACjD,SAAS,2BAA2B;AACpC,SAAS,mCAAmC;AAC5C,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,WAAW,WAAS;AAYnB,SAAS,eAAe,OAAO;AACpC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ,GAAG,UAAU;AAAA,IACrB;AAAA,IACA,cAAc,CAAC;AAAA,IACf,iBAAiB;AAAA,IACjB,QAAQ,CAAC;AAAA,IACT,mBAAmB;AAAA,IACnB,gBAAgB,WAAS,MAAM,KAAK;AAAA,IACpC,WAAW,MAAM;AAAA,IAAC;AAAA,IAClB,gBAAgB,MAAM;AAAA,IAAC;AAAA,IACvB,UAAU;AAAA,IACV,eAAe;AAAA,IACf,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB,WAAW;AAAA,MACT,OAAO,GAAG,aAAa;AAAA,MACvB,SAAS,GAAG,eAAe;AAAA,MAC3B,QAAQ,GAAG,aAAa;AAAA,MACxB,uBAAuB,GAAG,cAAc;AAAA,IAC1C;AAAA,IACA;AAAA,IACA,8BAA8B;AAAA,IAC9B,8BAA8B,MAAM;AAAA,IACpC;AAAA,IACA,wBAAwB;AAAA,IACxB,qCAAqC;AAAA,IAC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",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce, useInstanceId, usePrevious } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport Token from './token';\nimport TokenInput from './token-input';\nimport { TokensAndInputWrapperFlex } from './styles';\nimport SuggestionsList from './suggestions-list';\nimport { FlexItem } from '../flex';\nimport { StyledHelp, StyledLabel } from '../base-control/styles/base-control-styles';\nimport { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';\nimport { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst identity = value => value;\n\n/**\n * A `FormTokenField` is a field similar to the tags and categories fields in the interim editor chrome,\n * or the \"to\" field in Mail on OS X. Tokens can be entered by typing them or selecting them from a list of suggested tokens.\n *\n * Up to one hundred suggestions that match what the user has typed so far will be shown from which the user can pick from (auto-complete).\n * Tokens are separated by the \",\" character. Suggestions can be selected with the up or down arrows and added with the tab or enter key.\n *\n * The `value` property is handled in a manner similar to controlled form components.\n * See [Forms](https://react.dev/reference/react-dom/components#form-components) in the React Documentation for more information.\n */\nexport function FormTokenField(props) {\n const {\n autoCapitalize,\n autoComplete,\n maxLength,\n placeholder,\n label = __('Add item'),\n className,\n suggestions = [],\n maxSuggestions = 100,\n value = [],\n displayTransform = identity,\n saveTransform = token => token.trim(),\n onChange = () => {},\n onInputChange = () => {},\n onFocus = undefined,\n isBorderless = false,\n disabled = false,\n tokenizeOnSpace = false,\n messages = {\n added: __('Item added.'),\n removed: __('Item removed.'),\n remove: __('Remove item'),\n __experimentalInvalid: __('Invalid item')\n },\n __experimentalRenderItem,\n __experimentalExpandOnFocus = false,\n __experimentalValidateInput = () => true,\n __experimentalShowHowTo,\n __next40pxDefaultSize = false,\n __experimentalAutoSelectFirstMatch = false,\n tokenizeOnBlur = false,\n help\n } = useDeprecated36pxDefaultSizeProp(props);\n maybeWarnDeprecated36pxSize({\n componentName: 'FormTokenField',\n size: undefined,\n __next40pxDefaultSize\n });\n const defaultHelp = tokenizeOnSpace ? __('Separate with commas, spaces, or the Enter key.') : __('Separate with commas or the Enter key.');\n let computedHelp = help !== undefined ? help : defaultHelp;\n if (typeof __experimentalShowHowTo === 'boolean') {\n deprecated('`__experimentalShowHowTo` prop in wp.components.FormTokenField', {\n since: '7.1',\n alternative: '`help` prop',\n hint: 'The `help` prop now defaults to the previous how-to text. Pass an empty string to hide it.'\n });\n if (__experimentalShowHowTo === false && help === undefined) {\n computedHelp = '';\n }\n }\n const instanceId = useInstanceId(FormTokenField);\n\n // We reset to these initial values again in the onBlur\n const [incompleteTokenValue, setIncompleteTokenValue] = useState('');\n const [inputOffsetFromEnd, setInputOffsetFromEnd] = useState(0);\n const [isActive, setIsActive] = useState(false);\n const [isExpanded, setIsExpanded] = useState(false);\n const [selectedSuggestionIndex, setSelectedSuggestionIndex] = useState(-1);\n const [selectedSuggestionScroll, setSelectedSuggestionScroll] = useState(false);\n const prevSuggestions = usePrevious(suggestions);\n const prevValue = usePrevious(value);\n const input = useRef(null);\n const tokensAndInput = useRef(null);\n const debouncedSpeak = useDebounce(speak, 500);\n useEffect(() => {\n // Make sure to focus the input when the isActive state is true.\n if (isActive && !hasFocus()) {\n focus();\n }\n }, [isActive]);\n useEffect(() => {\n const suggestionsDidUpdate = !isShallowEqual(suggestions, prevSuggestions || []);\n if (suggestionsDidUpdate || value !== prevValue) {\n updateSuggestions(suggestionsDidUpdate);\n }\n\n // TODO: updateSuggestions() should first be refactored so its actual deps are clearer.\n }, [suggestions, prevSuggestions, value, prevValue]);\n useEffect(() => {\n updateSuggestions();\n }, [incompleteTokenValue]);\n useEffect(() => {\n updateSuggestions();\n }, [__experimentalAutoSelectFirstMatch]);\n if (disabled && isActive) {\n setIsActive(false);\n setIncompleteTokenValue('');\n }\n function focus() {\n input.current?.focus();\n }\n function hasFocus() {\n return input.current === input.current?.ownerDocument.activeElement;\n }\n function onFocusHandler(event) {\n // If focus is on the input or on the container, set the isActive state to true.\n if (hasFocus() || event.target === tokensAndInput.current) {\n setIsActive(true);\n setIsExpanded(__experimentalExpandOnFocus || isExpanded);\n } else {\n /*\n * Otherwise, focus is on one of the token \"remove\" buttons and we\n * set the isActive state to false to prevent the input to be\n * re-focused, see componentDidUpdate().\n */\n setIsActive(false);\n }\n if ('function' === typeof onFocus) {\n onFocus(event);\n }\n }\n function onBlur(event) {\n if (inputHasValidValue() && __experimentalValidateInput(incompleteTokenValue)) {\n setIsActive(false);\n if (tokenizeOnBlur && inputHasValidValue()) {\n addNewToken(incompleteTokenValue);\n }\n } else {\n // Reset to initial state\n setIncompleteTokenValue('');\n setInputOffsetFromEnd(0);\n setIsActive(false);\n if (__experimentalExpandOnFocus) {\n // If `__experimentalExpandOnFocus` is true, don't close the suggestions list when\n // the user clicks on it (`tokensAndInput` will be the element that caused the blur).\n const hasFocusWithin = event.relatedTarget === tokensAndInput.current;\n setIsExpanded(hasFocusWithin);\n } else {\n // Else collapse the suggestion list. This will result in the suggestion list closing\n // after a suggestion has been submitted since that causes a blur.\n setIsExpanded(false);\n }\n setSelectedSuggestionIndex(-1);\n setSelectedSuggestionScroll(false);\n }\n }\n function onKeyDown(event) {\n let preventDefault = false;\n if (event.defaultPrevented) {\n return;\n }\n switch (event.key) {\n case 'Backspace':\n preventDefault = handleDeleteKey(deleteTokenBeforeInput);\n break;\n case 'Enter':\n preventDefault = addCurrentToken();\n break;\n case 'ArrowLeft':\n preventDefault = handleLeftArrowKey();\n break;\n case 'ArrowUp':\n preventDefault = handleUpArrowKey();\n break;\n case 'ArrowRight':\n preventDefault = handleRightArrowKey();\n break;\n case 'ArrowDown':\n preventDefault = handleDownArrowKey();\n break;\n case 'Delete':\n preventDefault = handleDeleteKey(deleteTokenAfterInput);\n break;\n case 'Space':\n if (tokenizeOnSpace) {\n preventDefault = addCurrentToken({\n preventDefaultOnFailedValidation: false\n });\n }\n break;\n case 'Escape':\n preventDefault = handleEscapeKey(event);\n break;\n case 'Tab':\n preventDefault = handleTabKey(event);\n break;\n default:\n break;\n }\n if (preventDefault) {\n event.preventDefault();\n }\n }\n function onKeyPress(event) {\n let preventDefault = false;\n switch (event.key) {\n case ',':\n preventDefault = handleCommaKey();\n break;\n default:\n break;\n }\n if (preventDefault) {\n event.preventDefault();\n }\n }\n function onContainerTouched(event) {\n // Prevent clicking/touching the tokensAndInput container from blurring\n // the input and adding the current token.\n if (event.target === tokensAndInput.current && isActive) {\n event.preventDefault();\n }\n }\n function onTokenClickRemove(event) {\n deleteToken(event.value);\n focus();\n }\n function onSuggestionHovered(suggestion) {\n const index = getMatchingSuggestions().indexOf(suggestion);\n if (index >= 0) {\n setSelectedSuggestionIndex(index);\n setSelectedSuggestionScroll(false);\n }\n }\n function onSuggestionSelected(suggestion) {\n addNewToken(suggestion);\n }\n function onInputChangeHandler(event) {\n const text = event.value;\n const separator = tokenizeOnSpace ? /[ ,\\t]+/ : /[,\\t]+/;\n const items = text.split(separator);\n const tokenValue = items[items.length - 1] || '';\n if (items.length > 1) {\n const tokensToProcess = items.slice(0, -1);\n\n // Pre-check: would any segment be rejected by\n // `__experimentalValidateInput`? Empties and duplicates of the\n // current selection are intentional skips, not failures.\n const willFailValidation = segment => {\n const transformed = saveTransform(segment);\n return !!transformed && !valueContainsToken(transformed) && !__experimentalValidateInput(transformed);\n };\n const hasFailures = tokensToProcess.some(willFailValidation);\n\n // When there are failures, also commit the trailing in-progress\n // segment so the user is left with only the items that need\n // fixing, instead of mixing the trailing segment with the failed\n // ones (which would block tokenization on Enter or comma).\n const addedTokens = addNewTokens(hasFailures ? items : tokensToProcess);\n if (hasFailures) {\n // Derive rejected segments from `addedTokens` so this stays\n // in sync with `addNewTokens`'s filter chain.\n const rejected = items.filter(token => {\n const transformed = saveTransform(token);\n if (!transformed) {\n return false;\n }\n if (addedTokens.has(transformed)) {\n return false;\n }\n if (valueContainsToken(transformed)) {\n return false;\n }\n return !__experimentalValidateInput(transformed);\n });\n\n // Reuse the separator the user actually used (the last one\n // in `text`) so we don't rewrite their input: comma-separated\n // paste under `tokenizeOnSpace` stays comma-separated, and\n // typed space under `tokenizeOnSpace` stays a space. Falls\n // back to the mode-appropriate separator only when no\n // separator characters are present in `text`.\n const usedSeparators = text.match(/[ ,\\t]/g);\n const separatorChar = usedSeparators?.[usedSeparators.length - 1] ?? (tokenizeOnSpace ? ' ' : ',');\n // Preserve a trailing separator when the input ended with\n // one, so the user can keep typing past a failed-validation\n // space without their separator disappearing.\n const trailing = tokenValue === '' ? separatorChar : '';\n const remaining = rejected.join(separatorChar) + trailing;\n setIncompleteTokenValue(remaining);\n onInputChange(remaining);\n return;\n }\n }\n setIncompleteTokenValue(tokenValue);\n onInputChange(tokenValue);\n }\n function handleDeleteKey(_deleteToken) {\n let preventDefault = false;\n if (hasFocus() && isInputEmpty()) {\n _deleteToken();\n preventDefault = true;\n }\n return preventDefault;\n }\n function handleLeftArrowKey() {\n let preventDefault = false;\n if (isInputEmpty()) {\n moveInputBeforePreviousToken();\n preventDefault = true;\n }\n return preventDefault;\n }\n function handleRightArrowKey() {\n let preventDefault = false;\n if (isInputEmpty()) {\n moveInputAfterNextToken();\n preventDefault = true;\n }\n return preventDefault;\n }\n function handleUpArrowKey() {\n setSelectedSuggestionIndex(index => {\n return (index === 0 ? getMatchingSuggestions(incompleteTokenValue, suggestions, value, maxSuggestions, saveTransform).length : index) - 1;\n });\n setSelectedSuggestionScroll(true);\n return true; // PreventDefault.\n }\n function handleDownArrowKey() {\n setSelectedSuggestionIndex(index => {\n return (index + 1) % getMatchingSuggestions(incompleteTokenValue, suggestions, value, maxSuggestions, saveTransform).length;\n });\n setSelectedSuggestionScroll(true);\n return true; // PreventDefault.\n }\n function collapseSuggestionsList(event) {\n if (event.target instanceof HTMLInputElement) {\n setIncompleteTokenValue(event.target.value);\n setIsExpanded(false);\n setSelectedSuggestionIndex(-1);\n setSelectedSuggestionScroll(false);\n }\n }\n function handleEscapeKey(event) {\n collapseSuggestionsList(event);\n return true; // PreventDefault.\n }\n function handleTabKey(event) {\n collapseSuggestionsList(event);\n return false; // Do not prevent the default behavior.\n }\n function handleCommaKey() {\n if (inputHasValidValue()) {\n addNewToken(incompleteTokenValue);\n }\n\n // Comma is always a separator (typed in onKeyPress, never as input).\n // Pasted commas go through onInputChangeHandler, which validates.\n return true;\n }\n function moveInputToIndex(index) {\n setInputOffsetFromEnd(value.length - Math.max(index, -1) - 1);\n }\n function moveInputBeforePreviousToken() {\n setInputOffsetFromEnd(prevInputOffsetFromEnd => {\n return Math.min(prevInputOffsetFromEnd + 1, value.length);\n });\n }\n function moveInputAfterNextToken() {\n setInputOffsetFromEnd(prevInputOffsetFromEnd => {\n return Math.max(prevInputOffsetFromEnd - 1, 0);\n });\n }\n function deleteTokenBeforeInput() {\n const index = getIndexOfInput() - 1;\n if (index > -1) {\n deleteToken(value[index]);\n }\n }\n function deleteTokenAfterInput() {\n const index = getIndexOfInput();\n if (index < value.length) {\n deleteToken(value[index]);\n // Update input offset since it's the offset from the last token.\n moveInputToIndex(index);\n }\n }\n function addCurrentToken({\n preventDefaultOnFailedValidation = true\n } = {}) {\n let preventDefault = false;\n const selectedSuggestion = getSelectedSuggestion();\n if (selectedSuggestion) {\n addNewToken(selectedSuggestion);\n preventDefault = true;\n } else if (inputHasValidValue()) {\n const passedValidation = addNewToken(incompleteTokenValue);\n preventDefault = passedValidation || preventDefaultOnFailedValidation;\n }\n return preventDefault;\n }\n function addNewTokens(tokens) {\n const tokensToAdd = [...new Set(tokens.map(saveTransform).filter(Boolean).filter(token => !valueContainsToken(token)).filter(token => __experimentalValidateInput(token)))];\n if (tokensToAdd.length > 0) {\n const newValue = [...value];\n newValue.splice(getIndexOfInput(), 0, ...tokensToAdd);\n onChange(newValue);\n }\n return new Set(tokensToAdd);\n }\n\n /**\n * Validates and adds `token`. Returns `true` if validation passed,\n * `false` if it was rejected by `__experimentalValidateInput`. A `true`\n * return does not guarantee the token was added: `addNewTokens` may\n * still drop it as a duplicate or after `saveTransform` returns empty.\n */\n function addNewToken(token) {\n if (!__experimentalValidateInput(token)) {\n speak(messages.__experimentalInvalid, 'assertive');\n return false;\n }\n addNewTokens([token]);\n speak(messages.added, 'assertive');\n setIncompleteTokenValue('');\n setSelectedSuggestionIndex(-1);\n setSelectedSuggestionScroll(false);\n setIsExpanded(!__experimentalExpandOnFocus);\n if (isActive && !tokenizeOnBlur) {\n focus();\n }\n return true;\n }\n function deleteToken(token) {\n const newTokens = value.filter(item => {\n return getTokenValue(item) !== getTokenValue(token);\n });\n onChange(newTokens);\n speak(messages.removed, 'assertive');\n }\n function getTokenValue(token) {\n if ('object' === typeof token) {\n return token.value;\n }\n return token;\n }\n function getMatchingSuggestions(searchValue = incompleteTokenValue, _suggestions = suggestions, _value = value, _maxSuggestions = maxSuggestions, _saveTransform = saveTransform) {\n let match = _saveTransform(searchValue);\n const startsWithMatch = [];\n const containsMatch = [];\n const normalizedValue = _value.map(item => {\n if (typeof item === 'string') {\n return item;\n }\n return item.value;\n });\n if (match.length === 0) {\n _suggestions = _suggestions.filter(suggestion => !normalizedValue.includes(suggestion));\n } else {\n match = match.normalize('NFKC').toLocaleLowerCase();\n _suggestions.forEach(suggestion => {\n const index = suggestion.normalize('NFKC').toLocaleLowerCase().indexOf(match);\n if (normalizedValue.indexOf(suggestion) === -1) {\n if (index === 0) {\n startsWithMatch.push(suggestion);\n } else if (index > 0) {\n containsMatch.push(suggestion);\n }\n }\n });\n _suggestions = startsWithMatch.concat(containsMatch);\n }\n return _suggestions.slice(0, _maxSuggestions);\n }\n function getSelectedSuggestion() {\n if (selectedSuggestionIndex !== -1) {\n return getMatchingSuggestions()[selectedSuggestionIndex];\n }\n return undefined;\n }\n function valueContainsToken(token) {\n return value.some(item => {\n return getTokenValue(token) === getTokenValue(item);\n });\n }\n function getIndexOfInput() {\n return value.length - inputOffsetFromEnd;\n }\n function isInputEmpty() {\n return incompleteTokenValue.length === 0;\n }\n function inputHasValidValue() {\n return saveTransform(incompleteTokenValue).length > 0;\n }\n function updateSuggestions(resetSelectedSuggestion = true) {\n const inputHasMinimumChars = incompleteTokenValue.trim().length > 1;\n const matchingSuggestions = getMatchingSuggestions(incompleteTokenValue);\n const hasMatchingSuggestions = matchingSuggestions.length > 0;\n const shouldExpandIfFocuses = hasFocus() && __experimentalExpandOnFocus;\n setIsExpanded(shouldExpandIfFocuses || inputHasMinimumChars && hasMatchingSuggestions);\n if (resetSelectedSuggestion) {\n if (__experimentalAutoSelectFirstMatch && inputHasMinimumChars && hasMatchingSuggestions) {\n setSelectedSuggestionIndex(0);\n setSelectedSuggestionScroll(true);\n } else {\n setSelectedSuggestionIndex(-1);\n setSelectedSuggestionScroll(false);\n }\n }\n if (inputHasMinimumChars) {\n const message = hasMatchingSuggestions ? sprintf(/* translators: %d: number of results. */\n _n('%d result found, use up and down arrow keys to navigate.', '%d results found, use up and down arrow keys to navigate.', matchingSuggestions.length), matchingSuggestions.length) : __('No results.');\n debouncedSpeak(message, 'assertive');\n }\n }\n function renderTokensAndInput() {\n const components = value.map(renderToken);\n components.splice(getIndexOfInput(), 0, renderInput());\n return components;\n }\n function renderToken(token, index, tokens) {\n const _value = getTokenValue(token);\n const status = typeof token !== 'string' ? token.status : undefined;\n const termPosition = index + 1;\n const termsCount = tokens.length;\n return /*#__PURE__*/_jsx(FlexItem, {\n children: /*#__PURE__*/_jsx(Token, {\n value: _value,\n status: status,\n title: typeof token !== 'string' ? token.title : undefined,\n displayTransform: displayTransform,\n onClickRemove: onTokenClickRemove,\n isBorderless: typeof token !== 'string' && token.isBorderless || isBorderless,\n onMouseEnter: typeof token !== 'string' ? token.onMouseEnter : undefined,\n onMouseLeave: typeof token !== 'string' ? token.onMouseLeave : undefined,\n disabled: 'error' !== status && disabled,\n messages: messages,\n termsCount: termsCount,\n termPosition: termPosition\n })\n }, 'token-' + _value);\n }\n function renderInput() {\n const describedById = computedHelp ? `components-form-token-input-${instanceId}__help` : undefined;\n const inputProps = {\n instanceId,\n autoCapitalize,\n autoComplete,\n placeholder: value.length === 0 ? placeholder : '',\n disabled,\n value: incompleteTokenValue,\n onBlur,\n isExpanded,\n selectedSuggestionIndex,\n 'aria-describedby': describedById\n };\n return /*#__PURE__*/_jsx(TokenInput, {\n ...inputProps,\n onChange: !(maxLength && value.length >= maxLength) ? onInputChangeHandler : undefined,\n ref: input\n }, \"input\");\n }\n const classes = clsx(className, 'components-form-token-field__input-container', {\n 'is-active': isActive,\n 'is-disabled': disabled\n });\n let tokenFieldProps = {\n className: 'components-form-token-field',\n tabIndex: -1\n };\n const matchingSuggestions = getMatchingSuggestions();\n if (!disabled) {\n tokenFieldProps = Object.assign({}, tokenFieldProps, {\n onKeyDown: withIgnoreIMEEvents(onKeyDown),\n onKeyPress,\n onFocus: onFocusHandler\n });\n }\n\n // Disable reason: There is no appropriate role which describes the\n // input container intended accessible usability.\n // TODO: Refactor click detection to use blur to stop propagation.\n /* eslint-disable jsx-a11y/no-static-element-interactions */\n return /*#__PURE__*/_jsxs(\"div\", {\n ...tokenFieldProps,\n children: [label && /*#__PURE__*/_jsx(StyledLabel, {\n htmlFor: `components-form-token-input-${instanceId}`,\n className: \"components-form-token-field__label\",\n children: label\n }), /*#__PURE__*/_jsxs(\"div\", {\n ref: tokensAndInput,\n className: classes,\n tabIndex: -1,\n onMouseDown: onContainerTouched,\n onTouchStart: onContainerTouched,\n children: [/*#__PURE__*/_jsx(TokensAndInputWrapperFlex, {\n justify: \"flex-start\",\n align: \"center\",\n gap: 1,\n wrap: true,\n __next40pxDefaultSize: __next40pxDefaultSize,\n hasTokens: !!value.length,\n children: renderTokensAndInput()\n }), isExpanded && /*#__PURE__*/_jsx(SuggestionsList, {\n instanceId: instanceId,\n match: saveTransform(incompleteTokenValue),\n displayTransform: displayTransform,\n suggestions: matchingSuggestions,\n selectedIndex: selectedSuggestionIndex,\n scrollIntoView: selectedSuggestionScroll,\n onHover: onSuggestionHovered,\n onSelect: onSuggestionSelected,\n __experimentalRenderItem: __experimentalRenderItem\n })]\n }), computedHelp && /*#__PURE__*/_jsx(StyledHelp, {\n id: `components-form-token-input-${instanceId}__help`,\n className: \"components-form-token-field__help\",\n children: computedHelp\n })]\n });\n /* eslint-enable jsx-a11y/no-static-element-interactions */\n}\nexport default FormTokenField;"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,WAAW,QAAQ,gBAAgB;AAC5C,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,aAAa,eAAe,mBAAmB;AACxD,SAAS,aAAa;AACtB,SAAS,sBAAsB;AAC/B,OAAO,gBAAgB;AAKvB,OAAO,WAAW;AAClB,OAAO,gBAAgB;AACvB,SAAS,iCAAiC;AAC1C,OAAO,qBAAqB;AAC5B,SAAS,gBAAgB;AACzB,SAAS,YAAY,mBAAmB;AACxC,SAAS,wCAAwC;AACjD,SAAS,2BAA2B;AACpC,SAAS,mCAAmC;AAC5C,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,WAAW,WAAS;AAYnB,SAAS,eAAe,OAAO;AACpC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ,GAAG,UAAU;AAAA,IACrB;AAAA,IACA,cAAc,CAAC;AAAA,IACf,iBAAiB;AAAA,IACjB,QAAQ,CAAC;AAAA,IACT,mBAAmB;AAAA,IACnB,gBAAgB,WAAS,MAAM,KAAK;AAAA,IACpC,WAAW,MAAM;AAAA,IAAC;AAAA,IAClB,gBAAgB,MAAM;AAAA,IAAC;AAAA,IACvB,UAAU;AAAA,IACV,eAAe;AAAA,IACf,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB,WAAW;AAAA,MACT,OA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chingSuggestions"]
7
7
  }
@@ -1,11 +1,11 @@
1
1
  // packages/components/src/higher-order/with-notices/index.tsx
2
2
  import { v4 as uuid } from "uuid";
3
- import { forwardRef, useState, useMemo } from "@wordpress/element";
3
+ import { useState, useMemo } from "@wordpress/element";
4
4
  import { createHigherOrderComponent } from "@wordpress/compose";
5
5
  import NoticeList from "../../notice/list.mjs";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  var with_notices_default = createHigherOrderComponent((OriginalComponent) => {
8
- function Component(props, ref) {
8
+ return function Component(props) {
9
9
  const [noticeList, setNoticeList] = useState([]);
10
10
  const noticeOperations = useMemo(() => {
11
11
  const createNotice = (notice) => {
@@ -41,22 +41,10 @@ var with_notices_default = createHigherOrderComponent((OriginalComponent) => {
41
41
  onRemove: noticeOperations.removeNotice
42
42
  })
43
43
  };
44
- return isForwardRef ? /* @__PURE__ */ _jsx(OriginalComponent, {
45
- ...propsOut,
46
- ref
47
- }) : /* @__PURE__ */ _jsx(OriginalComponent, {
44
+ return /* @__PURE__ */ _jsx(OriginalComponent, {
48
45
  ...propsOut
49
46
  });
50
- }
51
- let isForwardRef;
52
- const {
53
- render
54
- } = OriginalComponent;
55
- if (typeof render === "function") {
56
- isForwardRef = true;
57
- return forwardRef(Component);
58
- }
59
- return Component;
47
+ };
60
48
  }, "withNotices");
61
49
  export {
62
50
  with_notices_default as default
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/higher-order/with-notices/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { v4 as uuid } from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useState, useMemo } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport NoticeList from '../../notice/list';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * Override the default edit UI to include notices if supported.\n *\n * Wrapping the original component with `withNotices` encapsulates the component\n * with the additional props `noticeOperations` and `noticeUI`.\n *\n * ```jsx\n * import { withNotices, Button } from '@wordpress/components';\n *\n * const MyComponentWithNotices = withNotices(\n * \t( { noticeOperations, noticeUI } ) => {\n * \t\tconst addError = () =>\n * \t\t\tnoticeOperations.createErrorNotice( 'Error message' );\n * \t\treturn (\n * \t\t\t<div>\n * \t\t\t\t{ noticeUI }\n * \t\t\t\t<Button variant=\"secondary\" onClick={ addError }>\n * \t\t\t\t\tAdd error\n * \t\t\t\t</Button>\n * \t\t\t</div>\n * \t\t);\n * \t}\n * );\n * ```\n *\n * @param OriginalComponent Original component.\n *\n * @return Wrapped component.\n */\nexport default createHigherOrderComponent(OriginalComponent => {\n function Component(props, ref) {\n const [noticeList, setNoticeList] = useState([]);\n const noticeOperations = useMemo(() => {\n const createNotice = notice => {\n const noticeToAdd = notice.id ? notice : {\n ...notice,\n id: uuid()\n };\n setNoticeList(current => [...current, noticeToAdd]);\n };\n return {\n createNotice,\n createErrorNotice: msg => {\n // @ts-expect-error TODO: Missing `id`, potentially a bug\n createNotice({\n status: 'error',\n content: msg\n });\n },\n removeNotice: id => {\n setNoticeList(current => current.filter(notice => notice.id !== id));\n },\n removeAllNotices: () => {\n setNoticeList([]);\n }\n };\n }, []);\n const propsOut = {\n ...props,\n noticeList,\n noticeOperations,\n noticeUI: noticeList.length > 0 && /*#__PURE__*/_jsx(NoticeList, {\n className: \"components-with-notices-ui\",\n notices: noticeList,\n onRemove: noticeOperations.removeNotice\n })\n };\n return isForwardRef ? /*#__PURE__*/_jsx(OriginalComponent, {\n ...propsOut,\n ref: ref\n }) : /*#__PURE__*/_jsx(OriginalComponent, {\n ...propsOut\n });\n }\n let isForwardRef;\n // @ts-expect-error - `render` will only be present when OriginalComponent was wrapped with forwardRef().\n const {\n render\n } = OriginalComponent;\n // Returns a forwardRef if OriginalComponent appears to be a forwardRef.\n if (typeof render === 'function') {\n isForwardRef = true;\n return forwardRef(Component);\n }\n return Component;\n}, 'withNotices');"],
5
- "mappings": ";A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AAW,SAAS;AAAA,EAC7B;AACA,SAAO;AACT,GAAG,aAAa;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { v4 as uuid } from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useMemo } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport NoticeList from '../../notice/list';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * Override the default edit UI to include notices if supported.\n *\n * Wrapping the original component with `withNotices` encapsulates the component\n * with the additional props `noticeOperations` and `noticeUI`.\n *\n * ```jsx\n * import { withNotices, Button } from '@wordpress/components';\n *\n * const MyComponentWithNotices = withNotices(\n * \t( { noticeOperations, noticeUI } ) => {\n * \t\tconst addError = () =>\n * \t\t\tnoticeOperations.createErrorNotice( 'Error message' );\n * \t\treturn (\n * \t\t\t<div>\n * \t\t\t\t{ noticeUI }\n * \t\t\t\t<Button variant=\"secondary\" onClick={ addError }>\n * \t\t\t\t\tAdd error\n * \t\t\t\t</Button>\n * \t\t\t</div>\n * \t\t);\n * \t}\n * );\n * ```\n *\n * @param OriginalComponent Original component.\n *\n * @return Wrapped component.\n */\nexport default createHigherOrderComponent(OriginalComponent => {\n return function Component(props) {\n const [noticeList, setNoticeList] = useState([]);\n const noticeOperations = useMemo(() => {\n const createNotice = notice => {\n const noticeToAdd = notice.id ? notice : {\n ...notice,\n id: uuid()\n };\n setNoticeList(current => [...current, noticeToAdd]);\n };\n return {\n createNotice,\n createErrorNotice: msg => {\n // @ts-expect-error TODO: Missing `id`, potentially a bug\n createNotice({\n status: 'error',\n content: msg\n });\n },\n removeNotice: id => {\n setNoticeList(current => current.filter(notice => notice.id !== id));\n },\n removeAllNotices: () => {\n setNoticeList([]);\n }\n };\n }, []);\n const propsOut = {\n ...props,\n noticeList,\n noticeOperations,\n noticeUI: noticeList.length > 0 && /*#__PURE__*/_jsx(NoticeList, {\n className: \"components-with-notices-ui\",\n notices: noticeList,\n onRemove: noticeOperations.removeNotice\n })\n };\n return /*#__PURE__*/_jsx(OriginalComponent, {\n ...propsOut\n });\n };\n}, 'withNotices');"],
5
+ "mappings": ";AAGA,SAAS,MAAM,YAAY;AAK3B,SAAS,UAAU,eAAe;AAClC,SAAS,kCAAkC;AAK3C,OAAO,gBAAgB;AACvB,SAAS,OAAO,YAAY;AA8B5B,IAAO,uBAAQ,2BAA2B,uBAAqB;AAC7D,SAAO,SAAS,UAAU,OAAO;AAC/B,UAAM,CAAC,YAAY,aAAa,IAAI,SAAS,CAAC,CAAC;AAC/C,UAAM,mBAAmB,QAAQ,MAAM;AACrC,YAAM,eAAe,YAAU;AAC7B,cAAM,cAAc,OAAO,KAAK,SAAS;AAAA,UACvC,GAAG;AAAA,UACH,IAAI,KAAK;AAAA,QACX;AACA,sBAAc,aAAW,CAAC,GAAG,SAAS,WAAW,CAAC;AAAA,MACpD;AACA,aAAO;AAAA,QACL;AAAA,QACA,mBAAmB,SAAO;AAExB,uBAAa;AAAA,YACX,QAAQ;AAAA,YACR,SAAS;AAAA,UACX,CAAC;AAAA,QACH;AAAA,QACA,cAAc,QAAM;AAClB,wBAAc,aAAW,QAAQ,OAAO,YAAU,OAAO,OAAO,EAAE,CAAC;AAAA,QACrE;AAAA,QACA,kBAAkB,MAAM;AACtB,wBAAc,CAAC,CAAC;AAAA,QAClB;AAAA,MACF;AAAA,IACF,GAAG,CAAC,CAAC;AACL,UAAM,WAAW;AAAA,MACf,GAAG;AAAA,MACH;AAAA,MACA;AAAA,MACA,UAAU,WAAW,SAAS,KAAkB,qBAAK,YAAY;AAAA,QAC/D,WAAW;AAAA,QACX,SAAS;AAAA,QACT,UAAU,iBAAiB;AAAA,MAC7B,CAAC;AAAA,IACH;AACA,WAAoB,qBAAK,mBAAmB;AAAA,MAC1C,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF,GAAG,aAAa;",
6
6
  "names": []
7
7
  }