@namroodinc/liquid-editorial 0.14.0 → 0.16.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 (271) hide show
  1. package/README.md +283 -12
  2. package/UPGRADING.md +106 -0
  3. package/dist/chunks/{Avatar-Dw7EWd_-.cjs → Avatar-BZGFSE6C.cjs} +2 -2
  4. package/dist/chunks/{Avatar-Dw7EWd_-.cjs.map → Avatar-BZGFSE6C.cjs.map} +1 -1
  5. package/dist/chunks/{Avatar-BToMaTdL.js → Avatar-C4W-g8nU.js} +2 -2
  6. package/dist/chunks/{Avatar-BToMaTdL.js.map → Avatar-C4W-g8nU.js.map} +1 -1
  7. package/dist/chunks/{Board-XeDG9nWP.js → Board-Cbi5FMW-.js} +2 -2
  8. package/dist/chunks/{Board-XeDG9nWP.js.map → Board-Cbi5FMW-.js.map} +1 -1
  9. package/dist/chunks/{Board-DeXtaWNO.cjs → Board-_agEjTy8.cjs} +2 -2
  10. package/dist/chunks/{Board-DeXtaWNO.cjs.map → Board-_agEjTy8.cjs.map} +1 -1
  11. package/dist/chunks/{CollectionView-Dbg4d_tA.cjs → CollectionView-BfX2Lxre.cjs} +2 -2
  12. package/dist/chunks/{CollectionView-Dbg4d_tA.cjs.map → CollectionView-BfX2Lxre.cjs.map} +1 -1
  13. package/dist/chunks/{CollectionView-C0_bTO2v.js → CollectionView-DPJGtSP5.js} +2 -2
  14. package/dist/chunks/{CollectionView-C0_bTO2v.js.map → CollectionView-DPJGtSP5.js.map} +1 -1
  15. package/dist/chunks/{ColourField-DAFzOIOq.cjs → ColourField-BVGnW8Wh.cjs} +2 -2
  16. package/dist/chunks/{ColourField-DAFzOIOq.cjs.map → ColourField-BVGnW8Wh.cjs.map} +1 -1
  17. package/dist/chunks/{ColourField-Bb8H87fg.js → ColourField-BcuARZY4.js} +6 -6
  18. package/dist/chunks/{ColourField-Bb8H87fg.js.map → ColourField-BcuARZY4.js.map} +1 -1
  19. package/dist/chunks/{DatePicker-COm1giw8.js → DatePicker-VQUsbYdo.js} +3 -3
  20. package/dist/chunks/{DatePicker-COm1giw8.js.map → DatePicker-VQUsbYdo.js.map} +1 -1
  21. package/dist/chunks/{DatePicker-DOg3iQYy.cjs → DatePicker-zA0bWVBp.cjs} +2 -2
  22. package/dist/chunks/{DatePicker-DOg3iQYy.cjs.map → DatePicker-zA0bWVBp.cjs.map} +1 -1
  23. package/dist/chunks/{Drawer-nUTJtwX_.js → Drawer-2cf0SaG4.js} +3 -3
  24. package/dist/chunks/{Drawer-nUTJtwX_.js.map → Drawer-2cf0SaG4.js.map} +1 -1
  25. package/dist/chunks/{Drawer-B2dcTh5l.cjs → Drawer-BzvSfkCL.cjs} +2 -2
  26. package/dist/chunks/{Drawer-B2dcTh5l.cjs.map → Drawer-BzvSfkCL.cjs.map} +1 -1
  27. package/dist/chunks/EntryPicker-C7EBfpaw.cjs +2 -0
  28. package/dist/chunks/EntryPicker-C7EBfpaw.cjs.map +1 -0
  29. package/dist/chunks/{EntryPicker-Ie9T47hA.js → EntryPicker-DBnDsgzi.js} +397 -397
  30. package/dist/chunks/EntryPicker-DBnDsgzi.js.map +1 -0
  31. package/dist/chunks/FormEditor-BG8bOXI8.js +35 -0
  32. package/dist/chunks/FormEditor-BG8bOXI8.js.map +1 -0
  33. package/dist/chunks/FormEditor-BJN0QuLI.cjs +2 -0
  34. package/dist/chunks/FormEditor-BJN0QuLI.cjs.map +1 -0
  35. package/dist/chunks/Icon-QLZH31JA.cjs +2 -0
  36. package/dist/chunks/Icon-QLZH31JA.cjs.map +1 -0
  37. package/dist/chunks/Icon-kLLQC54Z.js +107 -0
  38. package/dist/chunks/Icon-kLLQC54Z.js.map +1 -0
  39. package/dist/chunks/{Message-VJTPhId7.js → Message-DM6pTq7N.js} +2 -2
  40. package/dist/chunks/{Message-VJTPhId7.js.map → Message-DM6pTq7N.js.map} +1 -1
  41. package/dist/chunks/{Message-B0A5bz8V.cjs → Message-yZJDVzb8.cjs} +2 -2
  42. package/dist/chunks/{Message-B0A5bz8V.cjs.map → Message-yZJDVzb8.cjs.map} +1 -1
  43. package/dist/chunks/{NumberField-C90eJGny.js → NumberField-CVsK4l9P.js} +13 -13
  44. package/dist/chunks/{NumberField-C90eJGny.js.map → NumberField-CVsK4l9P.js.map} +1 -1
  45. package/dist/chunks/{NumberField-BrWFmPkW.cjs → NumberField-Ccjpa_1d.cjs} +2 -2
  46. package/dist/chunks/{NumberField-BrWFmPkW.cjs.map → NumberField-Ccjpa_1d.cjs.map} +1 -1
  47. package/dist/chunks/RichTextEditor-D4rNww9d.cjs +2 -0
  48. package/dist/chunks/RichTextEditor-D4rNww9d.cjs.map +1 -0
  49. package/dist/chunks/RichTextEditor-DSxiMLVd.js +2832 -0
  50. package/dist/chunks/RichTextEditor-DSxiMLVd.js.map +1 -0
  51. package/dist/chunks/dialogLabel-Dx-WEEzI.cjs +2 -0
  52. package/dist/chunks/dialogLabel-Dx-WEEzI.cjs.map +1 -0
  53. package/dist/chunks/dialogLabel-nB1gwKz0.js +157 -0
  54. package/dist/chunks/dialogLabel-nB1gwKz0.js.map +1 -0
  55. package/dist/chunks/overlayLayer-CPd3zj_u.cjs +2 -0
  56. package/dist/chunks/overlayLayer-CPd3zj_u.cjs.map +1 -0
  57. package/dist/chunks/overlayLayer-Dv1vmfaI.js +199 -0
  58. package/dist/chunks/overlayLayer-Dv1vmfaI.js.map +1 -0
  59. package/dist/chunks/{useTooltip-Du8PutGX.js → useTooltip-COyAcujL.js} +2 -2
  60. package/dist/chunks/{useTooltip-Du8PutGX.js.map → useTooltip-COyAcujL.js.map} +1 -1
  61. package/dist/chunks/{useTooltip-ekdwMJFz.cjs → useTooltip-nEDN0ObI.cjs} +2 -2
  62. package/dist/chunks/{useTooltip-ekdwMJFz.cjs.map → useTooltip-nEDN0ObI.cjs.map} +1 -1
  63. package/dist/components/AppShell/index.cjs +1 -1
  64. package/dist/components/AppShell/index.js +1 -1
  65. package/dist/components/AssetCard/index.cjs +1 -1
  66. package/dist/components/AssetCard/index.js +1 -1
  67. package/dist/components/AssetGrid/index.cjs +1 -1
  68. package/dist/components/AssetGrid/index.js +1 -1
  69. package/dist/components/Avatar/index.cjs +1 -1
  70. package/dist/components/Avatar/index.js +1 -1
  71. package/dist/components/Banner/index.cjs +1 -1
  72. package/dist/components/Banner/index.js +1 -1
  73. package/dist/components/Board/index.cjs +1 -1
  74. package/dist/components/Board/index.js +1 -1
  75. package/dist/components/Button/index.cjs +1 -1
  76. package/dist/components/Button/index.js +1 -1
  77. package/dist/components/Choice/index.cjs +1 -1
  78. package/dist/components/Choice/index.cjs.map +1 -1
  79. package/dist/components/Choice/index.js +5 -5
  80. package/dist/components/CollectionView/index.cjs +1 -1
  81. package/dist/components/CollectionView/index.js +1 -1
  82. package/dist/components/ColourField/index.cjs +1 -1
  83. package/dist/components/ColourField/index.js +1 -1
  84. package/dist/components/DatePicker/index.cjs +1 -1
  85. package/dist/components/DatePicker/index.js +1 -1
  86. package/dist/components/Drawer/index.cjs +1 -1
  87. package/dist/components/Drawer/index.js +1 -1
  88. package/dist/components/EditLayout/index.cjs +1 -1
  89. package/dist/components/EditLayout/index.cjs.map +1 -1
  90. package/dist/components/EditLayout/index.js +6 -7
  91. package/dist/components/EditLayout/index.js.map +1 -1
  92. package/dist/components/EntryPicker/index.cjs +1 -1
  93. package/dist/components/EntryPicker/index.js +1 -1
  94. package/dist/components/EntryPicker/style.css +1 -1
  95. package/dist/components/FormEditor/README.md +205 -178
  96. package/dist/components/FormEditor/control.d.cts +4 -4
  97. package/dist/components/FormEditor/control.d.cts.map +1 -1
  98. package/dist/components/FormEditor/control.d.ts +4 -4
  99. package/dist/components/FormEditor/control.d.ts.map +1 -1
  100. package/dist/components/FormEditor/form.d.cts +3 -3
  101. package/dist/components/FormEditor/form.d.cts.map +1 -1
  102. package/dist/components/FormEditor/form.d.ts +3 -3
  103. package/dist/components/FormEditor/form.d.ts.map +1 -1
  104. package/dist/components/FormEditor/index.cjs +1 -1
  105. package/dist/components/FormEditor/index.js +2 -2
  106. package/dist/components/FormEditor/model.d.cts +2 -0
  107. package/dist/components/FormEditor/model.d.cts.map +1 -1
  108. package/dist/components/FormEditor/model.d.ts +2 -0
  109. package/dist/components/FormEditor/model.d.ts.map +1 -1
  110. package/dist/components/FormEditor/rich-text-control.d.cts +1 -2
  111. package/dist/components/FormEditor/rich-text-control.d.cts.map +1 -1
  112. package/dist/components/FormEditor/rich-text-control.d.ts +1 -2
  113. package/dist/components/FormEditor/rich-text-control.d.ts.map +1 -1
  114. package/dist/components/Icon/icons.d.cts +5 -0
  115. package/dist/components/Icon/icons.d.cts.map +1 -1
  116. package/dist/components/Icon/icons.d.ts +5 -0
  117. package/dist/components/Icon/icons.d.ts.map +1 -1
  118. package/dist/components/Icon/index.cjs +1 -1
  119. package/dist/components/Icon/index.js +1 -1
  120. package/dist/components/ImageCropper/index.cjs +1 -1
  121. package/dist/components/ImageCropper/index.cjs.map +1 -1
  122. package/dist/components/ImageCropper/index.js +6 -6
  123. package/dist/components/Menu/index.cjs +1 -1
  124. package/dist/components/Menu/index.js +9 -9
  125. package/dist/components/Menu/index.js.map +1 -1
  126. package/dist/components/Modal/index.cjs +1 -1
  127. package/dist/components/Modal/index.js +2 -2
  128. package/dist/components/NumberField/index.cjs +1 -1
  129. package/dist/components/NumberField/index.js +1 -1
  130. package/dist/components/Popover/index.cjs +1 -1
  131. package/dist/components/Popover/index.cjs.map +1 -1
  132. package/dist/components/Popover/index.d.cts.map +1 -1
  133. package/dist/components/Popover/index.d.ts.map +1 -1
  134. package/dist/components/Popover/index.js +67 -64
  135. package/dist/components/Popover/index.js.map +1 -1
  136. package/dist/components/RichTextEditor/block-plugins.d.cts +62 -0
  137. package/dist/components/RichTextEditor/block-plugins.d.cts.map +1 -0
  138. package/dist/components/RichTextEditor/block-plugins.d.ts +62 -0
  139. package/dist/components/RichTextEditor/block-plugins.d.ts.map +1 -0
  140. package/dist/components/RichTextEditor/content-block-frame.d.cts +32 -0
  141. package/dist/components/RichTextEditor/content-block-frame.d.cts.map +1 -0
  142. package/dist/components/RichTextEditor/content-block-frame.d.ts +32 -0
  143. package/dist/components/RichTextEditor/content-block-frame.d.ts.map +1 -0
  144. package/dist/components/RichTextEditor/content-block-view.d.cts +3 -0
  145. package/dist/components/RichTextEditor/content-block-view.d.cts.map +1 -0
  146. package/dist/components/RichTextEditor/content-block-view.d.ts +3 -0
  147. package/dist/components/RichTextEditor/content-block-view.d.ts.map +1 -0
  148. package/dist/components/RichTextEditor/content-block.d.cts +10 -0
  149. package/dist/components/RichTextEditor/content-block.d.cts.map +1 -0
  150. package/dist/components/RichTextEditor/content-block.d.ts +10 -0
  151. package/dist/components/RichTextEditor/content-block.d.ts.map +1 -0
  152. package/dist/components/RichTextEditor/document.d.cts +24 -8
  153. package/dist/components/RichTextEditor/document.d.cts.map +1 -1
  154. package/dist/components/RichTextEditor/document.d.ts +24 -8
  155. package/dist/components/RichTextEditor/document.d.ts.map +1 -1
  156. package/dist/components/RichTextEditor/index.cjs +1 -1
  157. package/dist/components/RichTextEditor/index.d.cts +6 -4
  158. package/dist/components/RichTextEditor/index.d.cts.map +1 -1
  159. package/dist/components/RichTextEditor/index.d.ts +6 -4
  160. package/dist/components/RichTextEditor/index.d.ts.map +1 -1
  161. package/dist/components/RichTextEditor/index.js +1 -1
  162. package/dist/components/RichTextEditor/picker-block.d.cts +25 -0
  163. package/dist/components/RichTextEditor/picker-block.d.cts.map +1 -0
  164. package/dist/components/RichTextEditor/picker-block.d.ts +25 -0
  165. package/dist/components/RichTextEditor/picker-block.d.ts.map +1 -0
  166. package/dist/components/RichTextEditor/style.css +126 -49
  167. package/dist/components/RichTextEditor/table-actions.d.cts +11 -0
  168. package/dist/components/RichTextEditor/table-actions.d.cts.map +1 -0
  169. package/dist/components/RichTextEditor/table-actions.d.ts +11 -0
  170. package/dist/components/RichTextEditor/table-actions.d.ts.map +1 -0
  171. package/dist/components/RichTextEditor/table-bands.d.cts +19 -0
  172. package/dist/components/RichTextEditor/table-bands.d.cts.map +1 -0
  173. package/dist/components/RichTextEditor/table-bands.d.ts +19 -0
  174. package/dist/components/RichTextEditor/table-bands.d.ts.map +1 -0
  175. package/dist/components/RichTextEditor/table-view.d.cts +4 -0
  176. package/dist/components/RichTextEditor/table-view.d.cts.map +1 -0
  177. package/dist/components/RichTextEditor/table-view.d.ts +4 -0
  178. package/dist/components/RichTextEditor/table-view.d.ts.map +1 -0
  179. package/dist/components/RichTextEditor/tables.d.cts.map +1 -1
  180. package/dist/components/RichTextEditor/tables.d.ts.map +1 -1
  181. package/dist/components/RichTextEditor/use-blocks.d.cts +19 -0
  182. package/dist/components/RichTextEditor/use-blocks.d.cts.map +1 -0
  183. package/dist/components/RichTextEditor/use-blocks.d.ts +19 -0
  184. package/dist/components/RichTextEditor/use-blocks.d.ts.map +1 -0
  185. package/dist/components/SearchField/index.cjs +1 -1
  186. package/dist/components/SearchField/index.js +1 -1
  187. package/dist/components/Select/index.cjs +1 -1
  188. package/dist/components/Select/index.js +2 -2
  189. package/dist/components/SelectionCard/index.cjs +1 -1
  190. package/dist/components/SelectionCard/index.cjs.map +1 -1
  191. package/dist/components/SelectionCard/index.js +4 -4
  192. package/dist/components/SelectionCard/index.js.map +1 -1
  193. package/dist/components/SideNav/index.cjs +1 -1
  194. package/dist/components/SideNav/index.js +1 -1
  195. package/dist/components/SortableList/index.cjs +1 -1
  196. package/dist/components/SortableList/index.js +1 -1
  197. package/dist/components/Stepper/index.cjs +1 -1
  198. package/dist/components/Stepper/index.js +1 -1
  199. package/dist/components/SubNav/index.cjs +1 -1
  200. package/dist/components/SubNav/index.js +1 -1
  201. package/dist/components/Switch/style.css +2 -6
  202. package/dist/components/Table/index.cjs +1 -1
  203. package/dist/components/Table/index.js +1 -1
  204. package/dist/components/Time/index.cjs +1 -1
  205. package/dist/components/Time/index.js +1 -1
  206. package/dist/components/Toast/index.cjs +1 -1
  207. package/dist/components/Toast/index.js +1 -1
  208. package/dist/components/TopNav/index.cjs +1 -1
  209. package/dist/components/TopNav/index.js +1 -1
  210. package/dist/index.cjs +1 -1
  211. package/dist/index.d.cts +2 -2
  212. package/dist/index.d.cts.map +1 -1
  213. package/dist/index.d.ts +2 -2
  214. package/dist/index.d.ts.map +1 -1
  215. package/dist/index.js +49 -49
  216. package/dist/internal/useStableValue.d.cts +8 -0
  217. package/dist/internal/useStableValue.d.cts.map +1 -0
  218. package/dist/internal/useStableValue.d.ts +8 -0
  219. package/dist/internal/useStableValue.d.ts.map +1 -0
  220. package/dist/rich-text-blocks.cjs +2 -0
  221. package/dist/rich-text-blocks.cjs.map +1 -0
  222. package/dist/rich-text-blocks.d.cts +20 -0
  223. package/dist/rich-text-blocks.d.cts.map +1 -0
  224. package/dist/rich-text-blocks.d.ts +20 -0
  225. package/dist/rich-text-blocks.d.ts.map +1 -0
  226. package/dist/rich-text-blocks.js +36 -0
  227. package/dist/rich-text-blocks.js.map +1 -0
  228. package/package.json +14 -1
  229. package/dist/chunks/EntryPicker-BwEYRtQl.cjs +0 -2
  230. package/dist/chunks/EntryPicker-BwEYRtQl.cjs.map +0 -1
  231. package/dist/chunks/EntryPicker-Ie9T47hA.js.map +0 -1
  232. package/dist/chunks/FormEditor-D1HUnjMI.cjs +0 -2
  233. package/dist/chunks/FormEditor-D1HUnjMI.cjs.map +0 -1
  234. package/dist/chunks/FormEditor-DgDV5aeR.js +0 -30
  235. package/dist/chunks/FormEditor-DgDV5aeR.js.map +0 -1
  236. package/dist/chunks/Icon-Bxvp1-td.js +0 -102
  237. package/dist/chunks/Icon-Bxvp1-td.js.map +0 -1
  238. package/dist/chunks/Icon-CnnTrtNb.cjs +0 -2
  239. package/dist/chunks/Icon-CnnTrtNb.cjs.map +0 -1
  240. package/dist/chunks/RichTextEditor-DPhEkDxi.js +0 -2108
  241. package/dist/chunks/RichTextEditor-DPhEkDxi.js.map +0 -1
  242. package/dist/chunks/RichTextEditor-DV7NZp_k.cjs +0 -2
  243. package/dist/chunks/RichTextEditor-DV7NZp_k.cjs.map +0 -1
  244. package/dist/chunks/dialogLabel-C153NosD.js +0 -176
  245. package/dist/chunks/dialogLabel-C153NosD.js.map +0 -1
  246. package/dist/chunks/dialogLabel-CNNQbtob.cjs +0 -2
  247. package/dist/chunks/dialogLabel-CNNQbtob.cjs.map +0 -1
  248. package/dist/chunks/overlayLayer-CtOTt1xB.cjs +0 -2
  249. package/dist/chunks/overlayLayer-CtOTt1xB.cjs.map +0 -1
  250. package/dist/chunks/overlayLayer-Og07sIyl.js +0 -180
  251. package/dist/chunks/overlayLayer-Og07sIyl.js.map +0 -1
  252. package/dist/components/RichTextEditor/embed-context.d.cts +0 -41
  253. package/dist/components/RichTextEditor/embed-context.d.cts.map +0 -1
  254. package/dist/components/RichTextEditor/embed-context.d.ts +0 -41
  255. package/dist/components/RichTextEditor/embed-context.d.ts.map +0 -1
  256. package/dist/components/RichTextEditor/embed-types.d.cts +0 -29
  257. package/dist/components/RichTextEditor/embed-types.d.cts.map +0 -1
  258. package/dist/components/RichTextEditor/embed-types.d.ts +0 -29
  259. package/dist/components/RichTextEditor/embed-types.d.ts.map +0 -1
  260. package/dist/components/RichTextEditor/storyblock-view.d.cts +0 -3
  261. package/dist/components/RichTextEditor/storyblock-view.d.cts.map +0 -1
  262. package/dist/components/RichTextEditor/storyblock-view.d.ts +0 -3
  263. package/dist/components/RichTextEditor/storyblock-view.d.ts.map +0 -1
  264. package/dist/components/RichTextEditor/storyblock.d.cts +0 -19
  265. package/dist/components/RichTextEditor/storyblock.d.cts.map +0 -1
  266. package/dist/components/RichTextEditor/storyblock.d.ts +0 -19
  267. package/dist/components/RichTextEditor/storyblock.d.ts.map +0 -1
  268. package/dist/components/RichTextEditor/use-embeds.d.cts +0 -31
  269. package/dist/components/RichTextEditor/use-embeds.d.cts.map +0 -1
  270. package/dist/components/RichTextEditor/use-embeds.d.ts +0 -31
  271. package/dist/components/RichTextEditor/use-embeds.d.ts.map +0 -1
@@ -1,176 +0,0 @@
1
- import { _ as e, d as t, g as n, m as r, p as i, u as a } from "./overlayLayer-Og07sIyl.js";
2
- import { t as o } from "./isComposing-8bRWyiLF.js";
3
- import { useEffect as s, useInsertionEffect as c, useRef as l, useState as u, useSyncExternalStore as d } from "react";
4
- //#region src/internal/movableHost.ts
5
- function f(e, t = {}) {
6
- if (typeof document > "u") return null;
7
- let n = document.createElement("div");
8
- return n.className = e, Object.assign(n.style, t), n;
9
- }
10
- var p = () => () => {};
11
- function m(e, t) {
12
- let [n] = u(() => f(e, t)), r = d(p, () => !0, () => !1);
13
- return c(() => () => n?.remove(), [n]), r ? n : null;
14
- }
15
- function h(e, t, n = null) {
16
- return t ? e.parentNode !== t && (g(e, t, null, n), !0) : (e.remove(), !1);
17
- }
18
- function g(e, n, r, i = null) {
19
- let a = document.activeElement, o = a && e.contains(a) ? a : i, s = o instanceof HTMLElement && e.contains(o) && (o === a || t(a));
20
- n.insertBefore(e, r), s && o.focus({ preventScroll: !0 });
21
- }
22
- //#endregion
23
- //#region src/internal/useDialogPortal.ts
24
- var _ = /* @__PURE__ */ new WeakMap();
25
- function v(e, t, n) {
26
- let r = Array.from(t.children).filter((t) => t !== e && _.has(t)), i = (e) => (_.get(e) ?? 0) > n;
27
- return {
28
- inPlace: e.parentNode === t && r.every((t) => i(t) === !!(e.compareDocumentPosition(t) & Node.DOCUMENT_POSITION_FOLLOWING)),
29
- before: r.find(i) ?? null
30
- };
31
- }
32
- function y(e, t, n) {
33
- let [r, i] = u(e ?? 0);
34
- e !== void 0 && e !== r && i(e);
35
- let a = m("ds-dialog-host", { display: "contents" });
36
- return c(() => {
37
- if (!a) return;
38
- if (!t) {
39
- a.remove();
40
- return;
41
- }
42
- _.set(a, r);
43
- let e = n ?? document.body, { inPlace: i, before: o } = v(a, e, r);
44
- i || g(a, e, o);
45
- }, [
46
- a,
47
- r,
48
- t,
49
- n
50
- ]), a;
51
- }
52
- //#endregion
53
- //#region src/internal/dialogStack.ts
54
- var b = /* @__PURE__ */ new Set(), x = 0;
55
- function S() {
56
- return x += 1, x;
57
- }
58
- function C(e, t) {
59
- let n = {
60
- layer: e,
61
- order: t
62
- };
63
- return b.add(n), {
64
- isTopmost: () => {
65
- for (let n of b) if (n.layer > e || n.layer === e && n.order > t) return !1;
66
- return b.has(n);
67
- },
68
- close: () => {
69
- b.delete(n);
70
- }
71
- };
72
- }
73
- //#endregion
74
- //#region src/internal/lockBodyScroll.ts
75
- var w = 0, T = {
76
- overflow: "",
77
- paddingRight: ""
78
- };
79
- function E() {
80
- let { body: e, documentElement: t } = document;
81
- if (w === 0) {
82
- T = {
83
- overflow: e.style.overflow,
84
- paddingRight: e.style.paddingRight
85
- };
86
- let n = t.clientWidth;
87
- e.style.overflow = "hidden";
88
- let r = t.clientWidth - n;
89
- if (r > 0) {
90
- let t = parseFloat(getComputedStyle(e).paddingRight) || 0;
91
- e.style.paddingRight = `${t + r}px`;
92
- }
93
- }
94
- w += 1;
95
- let n = !1;
96
- return () => {
97
- n || (n = !0, --w, !(w > 0) && (e.style.overflow = T.overflow, e.style.paddingRight = T.paddingRight));
98
- };
99
- }
100
- //#endregion
101
- //#region src/internal/useModalDialog.ts
102
- function D(e, t) {
103
- for (let n = t.parentElement; n && e.contains(n); n = n.parentElement) if (n.scrollHeight > n.clientHeight) {
104
- let e = n.getBoundingClientRect(), r = t.getBoundingClientRect();
105
- r.top < e.top ? n.scrollTop -= e.top - r.top : r.bottom > e.bottom && (n.scrollTop += Math.min(r.bottom - e.bottom, r.top - e.top));
106
- }
107
- }
108
- function O(e, i, a, o) {
109
- i && e.contains(i) && !t(i) && i.focus({ preventScroll: !0 }), i && document.activeElement === i ? D(e, i) : r(e, document.activeElement) || (a?.() ?? n(e)[0] ?? e).focus(o);
110
- }
111
- function k({ isOpen: n, isActive: c = !0, layer: d = 60, panelRef: f, onClose: p, initialFocus: m, preventScroll: h = !1, container: g }) {
112
- let _ = a({
113
- onClose: p,
114
- initialFocus: m
115
- }), [v, y] = u(null), b = l(null);
116
- return v !== null !== n && y(n ? {
117
- opener: typeof document > "u" ? null : document.activeElement,
118
- order: S()
119
- } : null), s(() => {
120
- if (!n || !c || !v) return;
121
- let a = { preventScroll: h }, s = f.current, l = C(d, v.order), u = (e) => {
122
- e instanceof HTMLElement && (b.current = {
123
- order: v.order,
124
- element: e
125
- });
126
- }, p = ({ target: e }) => u(e);
127
- s?.addEventListener("focusin", p);
128
- let m = document.activeElement;
129
- if (l.isTopmost() && s && !r(s, m)) {
130
- let e = b.current;
131
- O(s, e?.order === v.order ? e.element : void 0, _.current.initialFocus, a);
132
- } else s?.contains(m) && u(m);
133
- let g = (t) => {
134
- if (l.isTopmost()) {
135
- if (t.key === "Escape") {
136
- if (t.defaultPrevented || o(t)) return;
137
- t.preventDefault(), _.current.onClose();
138
- } else e(t, f.current);
139
- }
140
- };
141
- window.addEventListener("keydown", g);
142
- let y = E();
143
- return () => {
144
- s?.removeEventListener("focusin", p), window.removeEventListener("keydown", g), l.close(), y(), t(document.activeElement) && i(v.opener, a);
145
- };
146
- }, [
147
- n,
148
- c,
149
- d,
150
- v,
151
- f,
152
- h,
153
- g,
154
- _
155
- ]), {
156
- onScrimMouseDown: (e) => {
157
- n && c && e.target === e.currentTarget && (e.preventDefault(), _.current.onClose());
158
- },
159
- order: v?.order
160
- };
161
- }
162
- //#endregion
163
- //#region src/internal/dialogLabel.ts
164
- function A(e, t, n, r, i) {
165
- return {
166
- role: "dialog",
167
- "aria-modal": i || void 0,
168
- "aria-hidden": !i || e["aria-hidden"],
169
- "aria-labelledby": e["aria-label"] ? void 0 : e["aria-labelledby"] ?? t,
170
- "aria-describedby": r ? n : e["aria-describedby"]
171
- };
172
- }
173
- //#endregion
174
- export { h as a, f as i, k as n, m as o, y as r, A as t };
175
-
176
- //# sourceMappingURL=dialogLabel-C153NosD.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dialogLabel-C153NosD.js","names":["trapTabFocus","cannotHoldFocus","tabbableControls","panelHoldsFocus","focusNearest","useLatest","isComposing","createMovableHost","host","className","style","subscribe","useMovableHost","useState","hydrated","useSyncExternalStore","useInsertionEffect","moveHost","slot","insertHost","lastFocused","active","focused","refocus","before","ranks","placement","others","parent","child","isLater","other","rank","useDialogPortal","setRank","order","isPresent","container","inPlace","stack","openings","nextDialogOrder","openDialog","entry","layer","locks","previous","lockBodyScroll","body","width","documentElement","scrollbar","padding","released","revealInPanel","area","control","panel","view","box","focusPanel","initialFocus","options","useModalDialog","latest","opening","setOpening","useRef","isOpen","useEffect","isActive","focusOptions","panelRef","dialog","remember","element","rememberFocus","target","onKeyDown","event","unlockScroll","preventScroll","dialogAttributes","props","titleId","hasDescription","descriptionId"],"sources":["../../src/internal/movableHost.ts","../../src/internal/useDialogPortal.ts","../../src/internal/dialogStack.ts","../../src/internal/lockBodyScroll.ts","../../src/internal/useModalDialog.ts","../../src/internal/dialogLabel.ts"],"sourcesContent":["import { useInsertionEffect, useState, useSyncExternalStore } from \"react\";\nimport { cannotHoldFocus } from \"./dialogFocus\";\n\n/**\n * A detached element for portal content that moves between slots, so the tree\n * rendered into it never remounts. Null on the server.\n */\nexport function createMovableHost(className: string, style: Partial<CSSStyleDeclaration> = {}) {\n if (typeof document === \"undefined\") {\n return null;\n }\n const host = document.createElement(\"div\");\n host.className = className;\n Object.assign(host.style, style);\n return host;\n}\n\nconst subscribe = () => () => {};\n\n/**\n * A movable host for content that is also server rendered. It is null on the\n * server and while hydrating, so the first client render can match inline\n * server markup; client-only renders get the host on their first render.\n */\nexport function useMovableHost(className: string, style?: Partial<CSSStyleDeclaration>) {\n const [host] = useState(() => createMovableHost(className, style));\n const hydrated = useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n // An insertion effect, which Strict Mode never replays: replaying a passive\n // cleanup would detach a host that an insertion effect placed.\n useInsertionEffect(() => () => host?.remove(), [host]);\n return hydrated ? host : null;\n}\n\n/**\n * Moves `host` into `slot`, or detaches it when there is no slot. A host already\n * in place is left alone: re-inserting it would reset scroll positions and drop\n * focus and the text selection. Returns whether the host moved.\n */\nexport function moveHost(\n host: HTMLElement,\n slot: Element | null,\n lastFocused: Element | null = null,\n) {\n if (!slot) {\n host.remove();\n return false;\n }\n if (host.parentNode === slot) {\n return false;\n }\n insertHost(host, slot, null, lastFocused);\n return true;\n}\n\n/**\n * Inserts `host` into `slot` before `before`, or at its end. Moving drops focus,\n * so the element inside the host that had it (or `lastFocused`, when an earlier\n * removal already dropped it) gets it back.\n */\nexport function insertHost(\n host: HTMLElement,\n slot: Element,\n before: Node | null,\n lastFocused: Element | null = null,\n) {\n const active = document.activeElement;\n const focused = active && host.contains(active) ? active : lastFocused;\n const refocus =\n focused instanceof HTMLElement &&\n host.contains(focused) &&\n (focused === active || cannotHoldFocus(active));\n slot.insertBefore(host, before);\n if (refocus) {\n focused.focus({ preventScroll: true });\n }\n}\n","import { useInsertionEffect, useState } from \"react\";\nimport { insertHost, useMovableHost } from \"./movableHost\";\n\n/** The opening order of each dialog's portal host. */\nconst ranks = new WeakMap<Element, number>();\n\n/**\n * Where `host` belongs among the other dialog hosts in `parent`: before the\n * first one opened later. It is in place when every host opened earlier comes\n * before it and every one opened later after it, whatever else lies between.\n */\nfunction placement(host: Element, parent: Element, rank: number) {\n const others = Array.from(parent.children).filter((child) => child !== host && ranks.has(child));\n const isLater = (other: Element) => (ranks.get(other) ?? 0) > rank;\n const inPlace =\n host.parentNode === parent &&\n others.every(\n (other) =>\n isLater(other) ===\n Boolean(host.compareDocumentPosition(other) & Node.DOCUMENT_POSITION_FOLLOWING),\n );\n return { inPlace, before: others.find(isLater) ?? null };\n}\n\n/**\n * A portal host that paints dialogs in opening order, as the dialog stack ranks\n * them, including a nested dialog that opens in the same commit as its parent\n * (React inserts that one's portal first). The host moves only when its order\n * is wrong, keeping focus, so a reopened dialog keeps its scroll and focus.\n * Null on the server and while hydrating.\n */\nexport function useDialogPortal(\n order: number | undefined,\n isPresent: boolean,\n container?: HTMLElement | null,\n) {\n // Kept through a closing transition, when the dialog no longer has an order.\n const [rank, setRank] = useState(order ?? 0);\n if (order !== undefined && order !== rank) {\n setRank(order);\n }\n // Contents only, so a contained drawer's container lays out the frame itself.\n const host = useMovableHost(\"ds-dialog-host\", { display: \"contents\" });\n // Before layout effects, so content measures and focuses inside the document.\n useInsertionEffect(() => {\n if (!host) {\n return;\n }\n if (!isPresent) {\n host.remove();\n return;\n }\n ranks.set(host, rank);\n const parent = container ?? document.body;\n const { inPlace, before } = placement(host, parent, rank);\n if (!inPlace) {\n insertHost(host, parent, before);\n }\n }, [host, rank, isPresent, container]);\n return host;\n}\n","interface Entry {\n layer: number;\n order: number;\n}\nconst stack = new Set<Entry>();\nlet openings = 0;\n\n/**\n * A dialog's place among those on its layer, taken as it opens and kept while\n * it is suspended. Taken during render, where a dialog renders before the ones\n * nested in it, so nested dialogs that open with it still come after it.\n */\nexport function nextDialogOrder() {\n openings += 1;\n return openings;\n}\n\n/**\n * Register an open modal dialog; only the topmost one handles keys. A higher\n * layer wins, then the later opening, matching paint order: portals append as\n * dialogs open. A dialog resuming from suspension keeps its opening order, so\n * it never jumps above dialogs opened while it was suspended.\n */\nexport function openDialog(layer: number, order: number) {\n const entry: Entry = { layer, order };\n stack.add(entry);\n return {\n isTopmost: () => {\n for (const other of stack) {\n if (other.layer > layer || (other.layer === layer && other.order > order)) {\n return false;\n }\n }\n return stack.has(entry);\n },\n close: () => {\n stack.delete(entry);\n },\n };\n}\n","let locks = 0;\nlet previous = { overflow: \"\", paddingRight: \"\" };\n\n/**\n * Nested dialogs may unmount in either order; restore scrolling after the last.\n * Hiding a classic scrollbar widens the page, so the body is padded by the\n * width it gave back and layouts that measure themselves keep their mode.\n */\nexport function lockBodyScroll() {\n const { body, documentElement } = document;\n if (locks === 0) {\n previous = { overflow: body.style.overflow, paddingRight: body.style.paddingRight };\n const width = documentElement.clientWidth;\n body.style.overflow = \"hidden\";\n const scrollbar = documentElement.clientWidth - width;\n if (scrollbar > 0) {\n const padding = parseFloat(getComputedStyle(body).paddingRight) || 0;\n body.style.paddingRight = `${padding + scrollbar}px`;\n }\n }\n locks += 1;\n let released = false;\n return () => {\n if (released) {\n return;\n }\n released = true;\n locks -= 1;\n if (locks > 0) {\n return;\n }\n body.style.overflow = previous.overflow;\n body.style.paddingRight = previous.paddingRight;\n };\n}\n","import { useEffect, useRef, useState, type MouseEvent, type RefObject } from \"react\";\nimport { nextDialogOrder, openDialog } from \"./dialogStack\";\nimport { lockBodyScroll } from \"./lockBodyScroll\";\nimport {\n cannotHoldFocus,\n focusNearest,\n panelHoldsFocus,\n tabbableControls,\n trapTabFocus,\n} from \"./dialogFocus\";\nimport { isComposing } from \"./isComposing\";\nimport { useLatest } from \"./useLatest\";\n\nexport interface ModalDialogOptions {\n isOpen: boolean;\n /** An inactive open dialog stays mounted but leaves keys, focus and scrim presses to others. */\n isActive?: boolean;\n layer?: number;\n panelRef: RefObject<HTMLElement | null>;\n /** Escape and a direct scrim press call this. Read when called, so it may change every render. */\n onClose: () => void;\n /** First focus when focus isn't already inside the panel. Defaults to the first tabbable control, then the panel. */\n initialFocus?: () => HTMLElement | null | undefined;\n /** Panels that slide in from off-screen must not scroll the page when focused. */\n preventScroll?: boolean;\n /** Registration restarts when this changes while open, such as a new portal container. */\n container?: unknown;\n}\n\ninterface Opening {\n opener: Element | null;\n order: number;\n}\n\n/** Scroll the panel's own scroll areas, never the page or the panel's host, until `control` shows. */\nfunction revealInPanel(panel: HTMLElement, control: HTMLElement) {\n for (let area = control.parentElement; area && panel.contains(area); area = area.parentElement) {\n if (area.scrollHeight > area.clientHeight) {\n const view = area.getBoundingClientRect();\n const box = control.getBoundingClientRect();\n if (box.top < view.top) {\n area.scrollTop -= view.top - box.top;\n } else if (box.bottom > view.bottom) {\n area.scrollTop += Math.min(box.bottom - view.bottom, box.top - view.top);\n }\n }\n }\n}\n\n/**\n * Return to the control focused last in this opening, else to the initial\n * focus. A suspended panel stays laid out, so its scroll areas keep their\n * positions; a restored control is still brought into view within the panel,\n * in case its content moved, leaving the page where it is.\n */\nfunction focusPanel(\n panel: HTMLElement,\n previous: HTMLElement | undefined,\n initialFocus: ModalDialogOptions[\"initialFocus\"],\n options: FocusOptions,\n) {\n if (previous && panel.contains(previous) && !cannotHoldFocus(previous)) {\n previous.focus({ preventScroll: true });\n }\n if (previous && document.activeElement === previous) {\n revealInPanel(panel, previous);\n } else if (!panelHoldsFocus(panel, document.activeElement)) {\n (initialFocus?.() ?? tabbableControls(panel)[0] ?? panel).focus(options);\n }\n}\n\n/**\n * Behaviour every modal overlay shares: one dialog-stack entry, a body scroll\n * lock, Escape and a Tab trap while topmost, initial focus, and focus returned\n * to the opener (or its nearest focusable container) when closing dropped it.\n */\nexport function useModalDialog({\n isOpen,\n isActive = true,\n layer = 60,\n panelRef,\n onClose,\n initialFocus,\n preventScroll = false,\n container,\n}: ModalDialogOptions) {\n const latest = useLatest({ onClose, initialFocus });\n // Captured as the dialog opens, before autoFocus or the caller moves focus\n // inside it, and before the dialogs nested in it render.\n const [opening, setOpening] = useState<Opening | null>(null);\n const lastFocused = useRef<{ order: number; element: HTMLElement } | null>(null);\n if ((opening !== null) !== isOpen) {\n setOpening(\n isOpen\n ? {\n opener: typeof document === \"undefined\" ? null : document.activeElement,\n order: nextDialogOrder(),\n }\n : null,\n );\n }\n\n useEffect(() => {\n if (!isOpen || !isActive || !opening) {\n return;\n }\n const focusOptions = { preventScroll };\n const panel = panelRef.current;\n const dialog = openDialog(layer, opening.order);\n // Remembered per opening, so a new opening starts from its initial focus.\n const remember = (element: EventTarget | null) => {\n if (element instanceof HTMLElement) {\n lastFocused.current = { order: opening.order, element };\n }\n };\n const rememberFocus = ({ target }: FocusEvent) => remember(target);\n panel?.addEventListener(\"focusin\", rememberFocus);\n const active = document.activeElement;\n // Leave focus that autoFocus, the caller, or a popup resuming inside the\n // panel (its effects run first) already placed there.\n if (dialog.isTopmost() && panel && !panelHoldsFocus(panel, active)) {\n const previous = lastFocused.current;\n focusPanel(\n panel,\n previous?.order === opening.order ? previous.element : undefined,\n latest.current.initialFocus,\n focusOptions,\n );\n } else if (panel?.contains(active)) {\n // Focus placed before the listener was attached.\n remember(active);\n }\n\n const onKeyDown = (event: KeyboardEvent) => {\n // A nested picker, drawer or modal handles keys until it closes.\n if (!dialog.isTopmost()) {\n return;\n }\n if (event.key === \"Escape\") {\n // A popup inside the panel (Menu, Select, DateField) claims its Escape first.\n if (event.defaultPrevented || isComposing(event)) {\n return;\n }\n event.preventDefault();\n latest.current.onClose();\n return;\n }\n trapTabFocus(event, panelRef.current);\n };\n // On window, so popup handlers on the document and inside the panel run first.\n window.addEventListener(\"keydown\", onKeyDown);\n const unlockScroll = lockBodyScroll();\n\n return () => {\n panel?.removeEventListener(\"focusin\", rememberFocus);\n window.removeEventListener(\"keydown\", onKeyDown);\n dialog.close();\n unlockScroll();\n // Restore focus only when closing dropped it; the caller may already have placed it.\n if (cannotHoldFocus(document.activeElement)) {\n focusNearest(opening.opener, focusOptions);\n }\n };\n }, [isOpen, isActive, layer, opening, panelRef, preventScroll, container, latest]);\n\n /** Presses on the scrim itself close the dialog without moving focus first. */\n const onScrimMouseDown = (event: MouseEvent) => {\n if (isOpen && isActive && event.target === event.currentTarget) {\n event.preventDefault();\n latest.current.onClose();\n }\n };\n return { onScrimMouseDown, order: opening?.order };\n}\n","import type { AriaAttributes } from \"react\";\n\n/** Keep naming and visibility consistent across dialog frames, including suspended panels. */\nexport function dialogAttributes(\n props: AriaAttributes,\n titleId: string,\n descriptionId: string,\n hasDescription: boolean,\n active: boolean,\n) {\n return {\n role: \"dialog\" as const,\n \"aria-modal\": active || undefined,\n \"aria-hidden\": active ? props[\"aria-hidden\"] : true,\n \"aria-labelledby\": props[\"aria-label\"] ? undefined : (props[\"aria-labelledby\"] ?? titleId),\n \"aria-describedby\": hasDescription ? descriptionId : props[\"aria-describedby\"],\n };\n}\n"],"mappings":";;;;AAOA,SAAgBO,EAAkB,GAAmB,IAAsC,CAAC,GAAG;CAC7F,IAAI,OAAO,WAAa,KACtB,OAAO;CAET,IAAMC,IAAO,SAAS,cAA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C/CL,EAAO,MAAM,GACbO,EAAa,GAET/E,EAAgB,SAAS,aAAa,KACxCG,EAAa6D,EAAQ,QAAQM,CAAY;EAE7C;CACF,GAAG;EAACH;EAAQE;EAAU1B;EAAOqB;EAASO;EAAUS;EAAe5C;EAAW2B;CAAM,CAAC,GAS1E;EAAE,mBANiB,MAAsB;GAC9C,AAAII,KAAUE,KAAYS,EAAM,WAAWA,EAAM,kBAC/CA,EAAM,eAAe,GACrBf,EAAO,QAAQ,QAAQ;EAE3B;EAC2B,OAAOC,GAAS;CAAM;AACnD;;;AC1KA,SAAgBiB,EACd,GACA,GACA,GACA,GACA,GACA;CACA,OAAO;EACL,MAAM;EACN,cAAc7D,KAAU,KAAA;EACxB,eAAe,MAAS8D,EAAM;EAC9B,mBAAmBA,EAAM,gBAAgB,KAAA,IAAaA,EAAM,sBAAsBC;EAClF,oBAAoBC,IAAiBC,IAAgBH,EAAM;CAC7D;AACF"}
@@ -1,2 +0,0 @@
1
- const e=require("./overlayLayer-CtOTt1xB.cjs"),t=require("./isComposing-BrBcAANm.cjs");let n=require("react");function r(e,t={}){if(typeof document>`u`)return null;let n=document.createElement(`div`);return n.className=e,Object.assign(n.style,t),n}var i=()=>()=>{};function a(e,t){let[a]=(0,n.useState)(()=>r(e,t)),o=(0,n.useSyncExternalStore)(i,()=>!0,()=>!1);return(0,n.useInsertionEffect)(()=>()=>a?.remove(),[a]),o?a:null}function o(e,t,n=null){return t?e.parentNode!==t&&(s(e,t,null,n),!0):(e.remove(),!1)}function s(t,n,r,i=null){let a=document.activeElement,o=a&&t.contains(a)?a:i,s=o instanceof HTMLElement&&t.contains(o)&&(o===a||e.d(a));n.insertBefore(t,r),s&&o.focus({preventScroll:!0})}var c=new WeakMap;function l(e,t,n){let r=Array.from(t.children).filter(t=>t!==e&&c.has(t)),i=e=>(c.get(e)??0)>n;return{inPlace:e.parentNode===t&&r.every(t=>i(t)===!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)),before:r.find(i)??null}}function u(e,t,r){let[i,o]=(0,n.useState)(e??0);e!==void 0&&e!==i&&o(e);let u=a(`ds-dialog-host`,{display:`contents`});return(0,n.useInsertionEffect)(()=>{if(!u)return;if(!t){u.remove();return}c.set(u,i);let e=r??document.body,{inPlace:n,before:a}=l(u,e,i);n||s(u,e,a)},[u,i,t,r]),u}var d=new Set,f=0;function p(){return f+=1,f}function m(e,t){let n={layer:e,order:t};return d.add(n),{isTopmost:()=>{for(let n of d)if(n.layer>e||n.layer===e&&n.order>t)return!1;return d.has(n)},close:()=>{d.delete(n)}}}var h=0,g={overflow:``,paddingRight:``};function _(){let{body:e,documentElement:t}=document;if(h===0){g={overflow:e.style.overflow,paddingRight:e.style.paddingRight};let n=t.clientWidth;e.style.overflow=`hidden`;let r=t.clientWidth-n;if(r>0){let t=parseFloat(getComputedStyle(e).paddingRight)||0;e.style.paddingRight=`${t+r}px`}}h+=1;let n=!1;return()=>{n||(n=!0,--h,!(h>0)&&(e.style.overflow=g.overflow,e.style.paddingRight=g.paddingRight))}}function v(e,t){for(let n=t.parentElement;n&&e.contains(n);n=n.parentElement)if(n.scrollHeight>n.clientHeight){let e=n.getBoundingClientRect(),r=t.getBoundingClientRect();r.top<e.top?n.scrollTop-=e.top-r.top:r.bottom>e.bottom&&(n.scrollTop+=Math.min(r.bottom-e.bottom,r.top-e.top))}}function y(t,n,r,i){n&&t.contains(n)&&!e.d(n)&&n.focus({preventScroll:!0}),n&&document.activeElement===n?v(t,n):e.m(t,document.activeElement)||(r?.()??e.g(t)[0]??t).focus(i)}function b({isOpen:r,isActive:i=!0,layer:a=60,panelRef:o,onClose:s,initialFocus:c,preventScroll:l=!1,container:u}){let d=e.u({onClose:s,initialFocus:c}),[f,h]=(0,n.useState)(null),g=(0,n.useRef)(null);return f!==null!==r&&h(r?{opener:typeof document>`u`?null:document.activeElement,order:p()}:null),(0,n.useEffect)(()=>{if(!r||!i||!f)return;let n={preventScroll:l},s=o.current,c=m(a,f.order),u=e=>{e instanceof HTMLElement&&(g.current={order:f.order,element:e})},p=({target:e})=>u(e);s?.addEventListener(`focusin`,p);let h=document.activeElement;if(c.isTopmost()&&s&&!e.m(s,h)){let e=g.current;y(s,e?.order===f.order?e.element:void 0,d.current.initialFocus,n)}else s?.contains(h)&&u(h);let v=n=>{if(c.isTopmost()){if(n.key===`Escape`){if(n.defaultPrevented||t.t(n))return;n.preventDefault(),d.current.onClose()}else e._(n,o.current)}};window.addEventListener(`keydown`,v);let b=_();return()=>{s?.removeEventListener(`focusin`,p),window.removeEventListener(`keydown`,v),c.close(),b(),e.d(document.activeElement)&&e.p(f.opener,n)}},[r,i,a,f,o,l,u,d]),{onScrimMouseDown:e=>{r&&i&&e.target===e.currentTarget&&(e.preventDefault(),d.current.onClose())},order:f?.order}}function x(e,t,n,r,i){return{role:`dialog`,"aria-modal":i||void 0,"aria-hidden":!i||e[`aria-hidden`],"aria-labelledby":e[`aria-label`]?void 0:e[`aria-labelledby`]??t,"aria-describedby":r?n:e[`aria-describedby`]}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return x}});
2
- //# sourceMappingURL=dialogLabel-CNNQbtob.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dialogLabel-CNNQbtob.cjs","names":["useState","useSyncExternalStore","cannotHoldFocus","useState","cannotHoldFocus","panelHoldsFocus","tabbableControls","useLatest","useState","useRef","isComposing","require_overlayLayer","require_isComposing","react","createMovableHost","host","className","style","subscribe","useMovableHost","hydrated","moveHost","slot","insertHost","lastFocused","active","focused","refocus","before","ranks","placement","others","parent","child","isLater","other","rank","useDialogPortal","setRank","order","isPresent","container","inPlace","stack","openings","nextDialogOrder","openDialog","entry","layer","locks","previous","lockBodyScroll","body","width","documentElement","scrollbar","padding","released","revealInPanel","area","control","panel","view","box","focusPanel","initialFocus","options","useModalDialog","latest","opening","setOpening","isOpen","isActive","focusOptions","panelRef","dialog","remember","element","rememberFocus","target","onKeyDown","event","unlockScroll","preventScroll","dialogAttributes","props","titleId","hasDescription","descriptionId"],"sources":["../../src/internal/movableHost.ts","../../src/internal/useDialogPortal.ts","../../src/internal/dialogStack.ts","../../src/internal/lockBodyScroll.ts","../../src/internal/useModalDialog.ts","../../src/internal/dialogLabel.ts"],"sourcesContent":["import { useInsertionEffect, useState, useSyncExternalStore } from \"react\";\nimport { cannotHoldFocus } from \"./dialogFocus\";\n\n/**\n * A detached element for portal content that moves between slots, so the tree\n * rendered into it never remounts. Null on the server.\n */\nexport function createMovableHost(className: string, style: Partial<CSSStyleDeclaration> = {}) {\n if (typeof document === \"undefined\") {\n return null;\n }\n const host = document.createElement(\"div\");\n host.className = className;\n Object.assign(host.style, style);\n return host;\n}\n\nconst subscribe = () => () => {};\n\n/**\n * A movable host for content that is also server rendered. It is null on the\n * server and while hydrating, so the first client render can match inline\n * server markup; client-only renders get the host on their first render.\n */\nexport function useMovableHost(className: string, style?: Partial<CSSStyleDeclaration>) {\n const [host] = useState(() => createMovableHost(className, style));\n const hydrated = useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n // An insertion effect, which Strict Mode never replays: replaying a passive\n // cleanup would detach a host that an insertion effect placed.\n useInsertionEffect(() => () => host?.remove(), [host]);\n return hydrated ? host : null;\n}\n\n/**\n * Moves `host` into `slot`, or detaches it when there is no slot. A host already\n * in place is left alone: re-inserting it would reset scroll positions and drop\n * focus and the text selection. Returns whether the host moved.\n */\nexport function moveHost(\n host: HTMLElement,\n slot: Element | null,\n lastFocused: Element | null = null,\n) {\n if (!slot) {\n host.remove();\n return false;\n }\n if (host.parentNode === slot) {\n return false;\n }\n insertHost(host, slot, null, lastFocused);\n return true;\n}\n\n/**\n * Inserts `host` into `slot` before `before`, or at its end. Moving drops focus,\n * so the element inside the host that had it (or `lastFocused`, when an earlier\n * removal already dropped it) gets it back.\n */\nexport function insertHost(\n host: HTMLElement,\n slot: Element,\n before: Node | null,\n lastFocused: Element | null = null,\n) {\n const active = document.activeElement;\n const focused = active && host.contains(active) ? active : lastFocused;\n const refocus =\n focused instanceof HTMLElement &&\n host.contains(focused) &&\n (focused === active || cannotHoldFocus(active));\n slot.insertBefore(host, before);\n if (refocus) {\n focused.focus({ preventScroll: true });\n }\n}\n","import { useInsertionEffect, useState } from \"react\";\nimport { insertHost, useMovableHost } from \"./movableHost\";\n\n/** The opening order of each dialog's portal host. */\nconst ranks = new WeakMap<Element, number>();\n\n/**\n * Where `host` belongs among the other dialog hosts in `parent`: before the\n * first one opened later. It is in place when every host opened earlier comes\n * before it and every one opened later after it, whatever else lies between.\n */\nfunction placement(host: Element, parent: Element, rank: number) {\n const others = Array.from(parent.children).filter((child) => child !== host && ranks.has(child));\n const isLater = (other: Element) => (ranks.get(other) ?? 0) > rank;\n const inPlace =\n host.parentNode === parent &&\n others.every(\n (other) =>\n isLater(other) ===\n Boolean(host.compareDocumentPosition(other) & Node.DOCUMENT_POSITION_FOLLOWING),\n );\n return { inPlace, before: others.find(isLater) ?? null };\n}\n\n/**\n * A portal host that paints dialogs in opening order, as the dialog stack ranks\n * them, including a nested dialog that opens in the same commit as its parent\n * (React inserts that one's portal first). The host moves only when its order\n * is wrong, keeping focus, so a reopened dialog keeps its scroll and focus.\n * Null on the server and while hydrating.\n */\nexport function useDialogPortal(\n order: number | undefined,\n isPresent: boolean,\n container?: HTMLElement | null,\n) {\n // Kept through a closing transition, when the dialog no longer has an order.\n const [rank, setRank] = useState(order ?? 0);\n if (order !== undefined && order !== rank) {\n setRank(order);\n }\n // Contents only, so a contained drawer's container lays out the frame itself.\n const host = useMovableHost(\"ds-dialog-host\", { display: \"contents\" });\n // Before layout effects, so content measures and focuses inside the document.\n useInsertionEffect(() => {\n if (!host) {\n return;\n }\n if (!isPresent) {\n host.remove();\n return;\n }\n ranks.set(host, rank);\n const parent = container ?? document.body;\n const { inPlace, before } = placement(host, parent, rank);\n if (!inPlace) {\n insertHost(host, parent, before);\n }\n }, [host, rank, isPresent, container]);\n return host;\n}\n","interface Entry {\n layer: number;\n order: number;\n}\nconst stack = new Set<Entry>();\nlet openings = 0;\n\n/**\n * A dialog's place among those on its layer, taken as it opens and kept while\n * it is suspended. Taken during render, where a dialog renders before the ones\n * nested in it, so nested dialogs that open with it still come after it.\n */\nexport function nextDialogOrder() {\n openings += 1;\n return openings;\n}\n\n/**\n * Register an open modal dialog; only the topmost one handles keys. A higher\n * layer wins, then the later opening, matching paint order: portals append as\n * dialogs open. A dialog resuming from suspension keeps its opening order, so\n * it never jumps above dialogs opened while it was suspended.\n */\nexport function openDialog(layer: number, order: number) {\n const entry: Entry = { layer, order };\n stack.add(entry);\n return {\n isTopmost: () => {\n for (const other of stack) {\n if (other.layer > layer || (other.layer === layer && other.order > order)) {\n return false;\n }\n }\n return stack.has(entry);\n },\n close: () => {\n stack.delete(entry);\n },\n };\n}\n","let locks = 0;\nlet previous = { overflow: \"\", paddingRight: \"\" };\n\n/**\n * Nested dialogs may unmount in either order; restore scrolling after the last.\n * Hiding a classic scrollbar widens the page, so the body is padded by the\n * width it gave back and layouts that measure themselves keep their mode.\n */\nexport function lockBodyScroll() {\n const { body, documentElement } = document;\n if (locks === 0) {\n previous = { overflow: body.style.overflow, paddingRight: body.style.paddingRight };\n const width = documentElement.clientWidth;\n body.style.overflow = \"hidden\";\n const scrollbar = documentElement.clientWidth - width;\n if (scrollbar > 0) {\n const padding = parseFloat(getComputedStyle(body).paddingRight) || 0;\n body.style.paddingRight = `${padding + scrollbar}px`;\n }\n }\n locks += 1;\n let released = false;\n return () => {\n if (released) {\n return;\n }\n released = true;\n locks -= 1;\n if (locks > 0) {\n return;\n }\n body.style.overflow = previous.overflow;\n body.style.paddingRight = previous.paddingRight;\n };\n}\n","import { useEffect, useRef, useState, type MouseEvent, type RefObject } from \"react\";\nimport { nextDialogOrder, openDialog } from \"./dialogStack\";\nimport { lockBodyScroll } from \"./lockBodyScroll\";\nimport {\n cannotHoldFocus,\n focusNearest,\n panelHoldsFocus,\n tabbableControls,\n trapTabFocus,\n} from \"./dialogFocus\";\nimport { isComposing } from \"./isComposing\";\nimport { useLatest } from \"./useLatest\";\n\nexport interface ModalDialogOptions {\n isOpen: boolean;\n /** An inactive open dialog stays mounted but leaves keys, focus and scrim presses to others. */\n isActive?: boolean;\n layer?: number;\n panelRef: RefObject<HTMLElement | null>;\n /** Escape and a direct scrim press call this. Read when called, so it may change every render. */\n onClose: () => void;\n /** First focus when focus isn't already inside the panel. Defaults to the first tabbable control, then the panel. */\n initialFocus?: () => HTMLElement | null | undefined;\n /** Panels that slide in from off-screen must not scroll the page when focused. */\n preventScroll?: boolean;\n /** Registration restarts when this changes while open, such as a new portal container. */\n container?: unknown;\n}\n\ninterface Opening {\n opener: Element | null;\n order: number;\n}\n\n/** Scroll the panel's own scroll areas, never the page or the panel's host, until `control` shows. */\nfunction revealInPanel(panel: HTMLElement, control: HTMLElement) {\n for (let area = control.parentElement; area && panel.contains(area); area = area.parentElement) {\n if (area.scrollHeight > area.clientHeight) {\n const view = area.getBoundingClientRect();\n const box = control.getBoundingClientRect();\n if (box.top < view.top) {\n area.scrollTop -= view.top - box.top;\n } else if (box.bottom > view.bottom) {\n area.scrollTop += Math.min(box.bottom - view.bottom, box.top - view.top);\n }\n }\n }\n}\n\n/**\n * Return to the control focused last in this opening, else to the initial\n * focus. A suspended panel stays laid out, so its scroll areas keep their\n * positions; a restored control is still brought into view within the panel,\n * in case its content moved, leaving the page where it is.\n */\nfunction focusPanel(\n panel: HTMLElement,\n previous: HTMLElement | undefined,\n initialFocus: ModalDialogOptions[\"initialFocus\"],\n options: FocusOptions,\n) {\n if (previous && panel.contains(previous) && !cannotHoldFocus(previous)) {\n previous.focus({ preventScroll: true });\n }\n if (previous && document.activeElement === previous) {\n revealInPanel(panel, previous);\n } else if (!panelHoldsFocus(panel, document.activeElement)) {\n (initialFocus?.() ?? tabbableControls(panel)[0] ?? panel).focus(options);\n }\n}\n\n/**\n * Behaviour every modal overlay shares: one dialog-stack entry, a body scroll\n * lock, Escape and a Tab trap while topmost, initial focus, and focus returned\n * to the opener (or its nearest focusable container) when closing dropped it.\n */\nexport function useModalDialog({\n isOpen,\n isActive = true,\n layer = 60,\n panelRef,\n onClose,\n initialFocus,\n preventScroll = false,\n container,\n}: ModalDialogOptions) {\n const latest = useLatest({ onClose, initialFocus });\n // Captured as the dialog opens, before autoFocus or the caller moves focus\n // inside it, and before the dialogs nested in it render.\n const [opening, setOpening] = useState<Opening | null>(null);\n const lastFocused = useRef<{ order: number; element: HTMLElement } | null>(null);\n if ((opening !== null) !== isOpen) {\n setOpening(\n isOpen\n ? {\n opener: typeof document === \"undefined\" ? null : document.activeElement,\n order: nextDialogOrder(),\n }\n : null,\n );\n }\n\n useEffect(() => {\n if (!isOpen || !isActive || !opening) {\n return;\n }\n const focusOptions = { preventScroll };\n const panel = panelRef.current;\n const dialog = openDialog(layer, opening.order);\n // Remembered per opening, so a new opening starts from its initial focus.\n const remember = (element: EventTarget | null) => {\n if (element instanceof HTMLElement) {\n lastFocused.current = { order: opening.order, element };\n }\n };\n const rememberFocus = ({ target }: FocusEvent) => remember(target);\n panel?.addEventListener(\"focusin\", rememberFocus);\n const active = document.activeElement;\n // Leave focus that autoFocus, the caller, or a popup resuming inside the\n // panel (its effects run first) already placed there.\n if (dialog.isTopmost() && panel && !panelHoldsFocus(panel, active)) {\n const previous = lastFocused.current;\n focusPanel(\n panel,\n previous?.order === opening.order ? previous.element : undefined,\n latest.current.initialFocus,\n focusOptions,\n );\n } else if (panel?.contains(active)) {\n // Focus placed before the listener was attached.\n remember(active);\n }\n\n const onKeyDown = (event: KeyboardEvent) => {\n // A nested picker, drawer or modal handles keys until it closes.\n if (!dialog.isTopmost()) {\n return;\n }\n if (event.key === \"Escape\") {\n // A popup inside the panel (Menu, Select, DateField) claims its Escape first.\n if (event.defaultPrevented || isComposing(event)) {\n return;\n }\n event.preventDefault();\n latest.current.onClose();\n return;\n }\n trapTabFocus(event, panelRef.current);\n };\n // On window, so popup handlers on the document and inside the panel run first.\n window.addEventListener(\"keydown\", onKeyDown);\n const unlockScroll = lockBodyScroll();\n\n return () => {\n panel?.removeEventListener(\"focusin\", rememberFocus);\n window.removeEventListener(\"keydown\", onKeyDown);\n dialog.close();\n unlockScroll();\n // Restore focus only when closing dropped it; the caller may already have placed it.\n if (cannotHoldFocus(document.activeElement)) {\n focusNearest(opening.opener, focusOptions);\n }\n };\n }, [isOpen, isActive, layer, opening, panelRef, preventScroll, container, latest]);\n\n /** Presses on the scrim itself close the dialog without moving focus first. */\n const onScrimMouseDown = (event: MouseEvent) => {\n if (isOpen && isActive && event.target === event.currentTarget) {\n event.preventDefault();\n latest.current.onClose();\n }\n };\n return { onScrimMouseDown, order: opening?.order };\n}\n","import type { AriaAttributes } from \"react\";\n\n/** Keep naming and visibility consistent across dialog frames, including suspended panels. */\nexport function dialogAttributes(\n props: AriaAttributes,\n titleId: string,\n descriptionId: string,\n hasDescription: boolean,\n active: boolean,\n) {\n return {\n role: \"dialog\" as const,\n \"aria-modal\": active || undefined,\n \"aria-hidden\": active ? props[\"aria-hidden\"] : true,\n \"aria-labelledby\": props[\"aria-label\"] ? undefined : (props[\"aria-labelledby\"] ?? titleId),\n \"aria-describedby\": hasDescription ? descriptionId : props[\"aria-describedby\"],\n };\n}\n"],"mappings":"A,8GAOA,SAAgBc,EAAkB,EAAmB,EAAsC,CAAC,EAAG,CAC7F,GAAI,OAAO,SAAa,IACtB,OAAO,KAET,IAAMC,EAAO,SAAS,cAAc,KAAK,EAGzC,MAFA,GAAK,UAAYC,EACjB,OAAO,OAAOD,EAAK,MAAOE,CAAK,EACxBF,CACT,CAEA,IAAMG,UAAwB,CAAC,EAO/B,SAAgBC,EAAe,EAAmB,EAAsC,CACtF,GAAM,CAACJ,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E,EAAAA,EAAgB,SAAS,aAAa,GACxCO,EAAA,EAAa0D,EAAQ,OAAQI,CAAY,CAE7C,CACF,EAAG,CAACF,EAAQC,EAAUxB,EAAOqB,EAASK,EAAUS,EAAe1C,EAAW2B,CAAM,CAAC,EAS1E,CAAE,iBANiB,GAAsB,CAC1CG,GAAUC,GAAYS,EAAM,SAAWA,EAAM,gBAC/CA,EAAM,eAAe,EACrBb,EAAO,QAAQ,QAAQ,EAE3B,EAC2B,MAAOC,GAAS,KAAM,CACnD,CC1KA,SAAgBe,EACd,EACA,EACA,EACA,EACA,EACA,CACA,MAAO,CACL,KAAM,SACN,aAAc3D,GAAU,IAAA,GACxB,cAAe,IAAS4D,EAAM,eAC9B,kBAAmBA,EAAM,cAAgB,IAAA,GAAaA,EAAM,oBAAsBC,EAClF,mBAAoBC,EAAiBC,EAAgBH,EAAM,mBAC7D,CACF,C"}
@@ -1,2 +0,0 @@
1
- const e=require("./useIsomorphicLayoutEffect-XM4Ot6x5.cjs");let t=require("react"),n=require("react/jsx-runtime");var r=`:is(button, [href], input:not([type='hidden']), select, textarea, [tabindex], [contenteditable]:not([contenteditable='false'])):not(:disabled):not([tabindex='-1']):not([aria-hidden='true'])`;function i(e){let t=e.closest(`[contenteditable]`);return!(e.matches(`a[href]`)&&t&&t!==e&&t.getAttribute(`contenteditable`)!==`false`&&!e.hasAttribute(`tabindex`))&&(e.checkVisibility?.()??!e.closest(`[hidden]`))&&!e.closest(`[inert]`)}function a(e){return!e||e===e.ownerDocument.body||!e.isConnected||e.closest(`[aria-hidden='true'], [inert]`)!==null}function o(e,t){let n=e;for(;n;){if(n instanceof HTMLElement&&!a(n)&&(n.focus(t),n.getRootNode().activeElement===n))return!0;n=n.parentElement?.closest(`[tabindex]`)??null}return!1}function s(e){return e instanceof HTMLInputElement&&e.type===`radio`}function c(e,t){return e===t||s(e)&&s(t)&&e.name!==``&&e.name===t.name&&e.form===t.form}function l(e){let t=Array.from(e.querySelectorAll(r)).filter(i);return t.filter(e=>!s(e)||e.checked||!t.some(t=>s(t)&&t.checked&&c(t,e)))}var u=new WeakMap;function d(e,t){return u.set(e,t),()=>{u.delete(e)}}function f(e){let t=e instanceof Element?e:e.parentElement;for(;t&&!u.has(t);)t=t.parentElement;return t}function p(e,t){let n=new Set,r=f(t);for(;r&&!n.has(r);){n.add(r);let t=u.get(r);if(e.contains(t))return!0;r=f(t)}return!1}function m(e,t){return t!==null&&(e.contains(t)||p(e,t))}function h(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function g(e,t){if(e.key!==`Tab`||e.defaultPrevented||!t)return;let n=l(t),r=n[0],i=n.at(-1);if(!r||!i)return;let a=t.getRootNode().activeElement??document.activeElement,o=a!==null&&t.contains(a);!o&&a&&p(t,a)||(!o||(e.shiftKey?c(a,r)||h(a,r):c(a,i)||h(i,a)))&&(e.preventDefault(),(e.shiftKey?i:r).focus())}function _(e){let t=new Set,n=e;for(;!t.has(n);){t.add(n);let r=n.closest(`[aria-modal='true']`),i=f(n),a=l(r??(i instanceof HTMLElement?i:e.ownerDocument.body)).filter(e=>f(e)===i),o=a.find(e=>h(n,e)&&!n.contains(e));if(o){o.focus({preventScroll:!0});return}let s=i&&u.get(i);if(r||!s){if(a[0]){a[0].focus({preventScroll:!0});return}break}if(!s.isConnected)break;n=s}l(e)[0]?.focus({preventScroll:!0})}function v(n){let r=(0,t.useRef)(n);return e.t(()=>{r.current=n}),r}var y=(0,t.createContext)(null),b=[`data-theme`,`lang`,`dir`];function x(e){let t=e.closest(`[dir]`)?getComputedStyle(e).direction||e.closest(`[dir]`).getAttribute(`dir`):null;return{"data-theme":e.closest(`[data-theme]`)?.getAttribute(`data-theme`)??null,lang:e.closest(`[lang]`)?.getAttribute(`lang`)??null,dir:t}}function S(t,n,r,{keepDir:i=!1}={}){let a=v(r);e.t(()=>{let e=t.current,r=a.current?.();if(!n||!e||!r)return;let o=()=>{for(let[t,n]of Object.entries(x(r)))t===`dir`&&i||(n===null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n))};o();let s=new MutationObserver(o);for(let e=r;e;e=e.parentElement)s.observe(e,{attributes:!0,attributeFilter:b});return()=>s.disconnect()},[t,n,i,a])}function C(e,n,r){let i=(0,t.useContext)(y);S(e,n,i&&(()=>i.current),r)}var w=(0,t.createContext)(void 0);function T({layer:e,children:t}){return(0,n.jsx)(w.Provider,{value:e,children:t})}function E(){return(0,t.useContext)(w)}var D=(0,t.createContext)(!1);function O(){return(0,t.useContext)(D)}function k(e){let t=O();return e&&!t}function A({layer:e,isSuspended:t,children:r}){return(0,n.jsx)(w.Provider,{value:e,children:(0,n.jsx)(D.Provider,{value:t,children:r})})}function j(e,n){let[r,i]=(0,t.useState)(`closed`),a=e?n?r===`closed`?`shown`:r:r===`closed`?`closed`:`suspended`:`closed`;return a!==r&&i(a),a===`suspended`}function M(e,t,n){let r=E(),i=k(!t),a=j(e,i);return{layer:n??r,isVisible:i,isResumed:a}}Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return v}});
2
- //# sourceMappingURL=overlayLayer-CtOTt1xB.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overlayLayer-CtOTt1xB.cjs","names":["useRef","createContext","useContext","createContext","useContext","useState","require_useIsomorphicLayoutEffect","react","react_jsx_runtime","focusableSelector","canTakeFocus","editingHost","element","cannotHoldFocus","focusNearest","candidate","options","isRadio","sameStop","a","b","tabbableControls","controls","container","control","other","popupAnchors","registerPopup","popup","anchor","popupAround","node","inOwnedPopup","visited","panel","panelHoldsFocus","active","precedes","trapTabFocus","event","first","last","inside","focusAfterField","origin","root","modal","next","useLatest","ref","value","PortalScopeContext","scopeAttributes","scopeOf","direction","usePortalScope","latest","getAnchor","rootRef","isOpen","sync","name","keepDir","observer","useInheritedPortalScope","LayerContext","OverlayLayer","layer","useOverlayLayer","OverlayHiddenContext","useOverlayHidden","useOverlayOpen","hidden","open","DialogContent","isSuspended","useResumed","phase","setPhase","isVisible","useDialogPresence","inheritedLayer","isHidden","isResumed","overlayLayer"],"sources":["../../src/internal/dialogFocus.ts","../../src/internal/useLatest.ts","../../src/internal/portalScope.ts","../../src/internal/overlayLayer.tsx"],"sourcesContent":["const focusableSelector =\n \":is(button, [href], input:not([type='hidden']), select, textarea, [tabindex], [contenteditable]:not([contenteditable='false'])):not(:disabled):not([tabindex='-1']):not([aria-hidden='true'])\";\n\n// Unrendered controls (display: none, [hidden], closed <details>) and inert\n// subtrees cannot take focus. Environments without checkVisibility fall back\n// to the hidden attribute.\nfunction canTakeFocus(element: HTMLElement) {\n const editingHost = element.closest(\"[contenteditable]\");\n // A link being edited is document content, not a native Tab stop. Explicit\n // tabindex and links inside noneditable widgets still participate normally.\n const writingLink =\n element.matches(\"a[href]\") &&\n editingHost &&\n editingHost !== element &&\n editingHost.getAttribute(\"contenteditable\") !== \"false\" &&\n !element.hasAttribute(\"tabindex\");\n return (\n !writingLink &&\n (element.checkVisibility?.() ?? !element.closest(\"[hidden]\")) &&\n !element.closest(\"[inert]\")\n );\n}\n\n/** Removed, hidden and inert elements can't keep focus, and neither can the page. */\nexport function cannotHoldFocus(element: Element | null) {\n return (\n !element ||\n element === element.ownerDocument.body ||\n !element.isConnected ||\n element.closest(\"[aria-hidden='true'], [inert]\") !== null\n );\n}\n\n/**\n * Focuses `element`, or, when it can no longer take focus (disabled, or no\n * longer editable), its nearest ancestor with a tabindex, such as an enclosing\n * dialog panel. Returns whether anything took focus.\n */\nexport function focusNearest(element: Element | null, options?: FocusOptions) {\n let candidate = element;\n while (candidate) {\n if (candidate instanceof HTMLElement && !cannotHoldFocus(candidate)) {\n candidate.focus(options);\n if ((candidate.getRootNode() as Document | ShadowRoot).activeElement === candidate) {\n return true;\n }\n }\n candidate = candidate.parentElement?.closest(\"[tabindex]\") ?? null;\n }\n return false;\n}\n\nfunction isRadio(element: Element | null): element is HTMLInputElement {\n return element instanceof HTMLInputElement && element.type === \"radio\";\n}\n\n/** Radios sharing a name and form are one Tab stop. */\nfunction sameStop(a: Element, b: Element) {\n return (\n a === b || (isRadio(a) && isRadio(b) && a.name !== \"\" && a.name === b.name && a.form === b.form)\n );\n}\n\n/**\n * The controls Tab visits inside `container`, in document order. A radio group\n * contributes only its checked radio, or every radio while none is checked.\n */\nexport function tabbableControls(container: HTMLElement) {\n const controls = Array.from(container.querySelectorAll<HTMLElement>(focusableSelector)).filter(\n canTakeFocus,\n );\n return controls.filter(\n (control) =>\n !isRadio(control) ||\n control.checked ||\n !controls.some((other) => isRadio(other) && other.checked && sameStop(other, control)),\n );\n}\n\nconst popupAnchors = new WeakMap<Element, Element>();\n\n/**\n * Popups portal outside the dialog that opened them. Registering one with its\n * anchor lets that dialog's Tab trap treat the popup as its own.\n */\nexport function registerPopup(popup: Element, anchor: Element) {\n popupAnchors.set(popup, anchor);\n return () => {\n popupAnchors.delete(popup);\n };\n}\n\nfunction popupAround(node: Node) {\n let element = node instanceof Element ? node : node.parentElement;\n while (element && !popupAnchors.has(element)) {\n element = element.parentElement;\n }\n return element;\n}\n\n/** Inside a popup anchored in the panel, directly or through other popups. */\nfunction inOwnedPopup(panel: HTMLElement, node: Node) {\n const visited = new Set<Element>();\n let popup = popupAround(node);\n while (popup && !visited.has(popup)) {\n visited.add(popup);\n const anchor = popupAnchors.get(popup)!;\n if (panel.contains(anchor)) {\n return true;\n }\n popup = popupAround(anchor);\n }\n return false;\n}\n\n/** Focus in the panel or in a popup it owns, such as a menu that resumed with it. */\nexport function panelHoldsFocus(panel: HTMLElement, active: Element | null) {\n return active !== null && (panel.contains(active) || inOwnedPopup(panel, active));\n}\n\n/** `a` comes before `b` in document order, including as its ancestor. */\nfunction precedes(a: Node, b: Node) {\n return Boolean(b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING);\n}\n\n/**\n * Keeps Tab inside an aria-modal panel. Call only for the topmost dialog.\n * Focus that left the panel returns to its first control (last with Shift);\n * Tab inside a popup the panel owns is left to the popup and the browser.\n */\nexport function trapTabFocus(event: KeyboardEvent, panel: HTMLElement | null) {\n if (event.key !== \"Tab\" || event.defaultPrevented || !panel) {\n return;\n }\n const controls = tabbableControls(panel);\n const first = controls[0];\n const last = controls.at(-1);\n if (!first || !last) {\n return;\n }\n // document.activeElement stops at the host of a shadow root holding the panel.\n const active =\n (panel.getRootNode() as Document | ShadowRoot).activeElement ?? document.activeElement;\n const inside = active !== null && panel.contains(active);\n if (!inside && active && inOwnedPopup(panel, active)) {\n return;\n }\n // Focus on the panel itself, or on another untabbable element beyond the\n // first or last control, would otherwise leave the panel.\n const wraps =\n !inside ||\n (event.shiftKey\n ? sameStop(active, first) || precedes(active, first)\n : sameStop(active, last) || precedes(last, active));\n if (wraps) {\n event.preventDefault();\n (event.shiftKey ? last : first).focus();\n }\n}\n\n/**\n * Continue after the field, following popup anchors back to an enclosing modal or\n * the page. An anchor no longer in the document has no place in the Tab order,\n * so when the walk reaches one, or finds nothing to focus, focus returns to the\n * field's own first control rather than to the page or a closing popup.\n */\nexport function focusAfterField(root: HTMLElement) {\n const visited = new Set<Element>();\n let origin: Element = root;\n while (!visited.has(origin)) {\n visited.add(origin);\n const modal = origin.closest<HTMLElement>(\"[aria-modal='true']\");\n const popup = popupAround(origin);\n const scope = modal ?? (popup instanceof HTMLElement ? popup : root.ownerDocument.body);\n const controls = tabbableControls(scope).filter((control) => popupAround(control) === popup);\n const next = controls.find((control) => precedes(origin, control) && !origin.contains(control));\n if (next) {\n next.focus({ preventScroll: true });\n return;\n }\n const anchor = popup && popupAnchors.get(popup);\n if (modal || !anchor) {\n if (controls[0]) {\n controls[0].focus({ preventScroll: true });\n return;\n }\n break;\n }\n if (!anchor.isConnected) {\n break;\n }\n origin = anchor;\n }\n tabbableControls(root)[0]?.focus({ preventScroll: true });\n}\n","import { useRef } from \"react\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\n/**\n * The latest value, read when a callback or effect runs, so inline callbacks\n * never restart effects. Updated before layout effects and passive effects that\n * are declared after it read it.\n */\nexport function useLatest<T>(value: T) {\n const ref = useRef(value);\n useIsomorphicLayoutEffect(() => {\n ref.current = value;\n });\n return ref;\n}\n","import { createContext, useContext, type RefObject } from \"react\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\nimport { useLatest } from \"./useLatest\";\n\n/**\n * The inline element whose theme, direction and language body-mounted overlays\n * opened from inside it carry: RichTextEditor's frame, or a Popover's anchor.\n * Nested overlays inherit the same inline anchor rather than their parent's\n * panel, so they never depend on the order in which overlays mount.\n */\nexport const PortalScopeContext = createContext<RefObject<Element | null> | null>(null);\n\nconst scopeAttributes = [\"data-theme\", \"lang\", \"dir\"];\n\nfunction scopeOf(anchor: Element) {\n const direction = anchor.closest(\"[dir]\")\n ? getComputedStyle(anchor).direction || anchor.closest(\"[dir]\")!.getAttribute(\"dir\")\n : null;\n return {\n \"data-theme\": anchor.closest(\"[data-theme]\")?.getAttribute(\"data-theme\") ?? null,\n lang: anchor.closest(\"[lang]\")?.getAttribute(\"lang\") ?? null,\n dir: direction,\n };\n}\n\n/**\n * Copies the anchor's `data-theme`, `lang` and `dir` onto an overlay root while\n * it is open, and follows later changes to those attributes on the anchor's\n * ancestors. Attributes rather than resolved values, so the theme's whole\n * stylesheet keeps applying, including `color-scheme` and media queries.\n * Without an anchor the overlay inherits from the document root, as before.\n */\nexport function usePortalScope(\n rootRef: RefObject<HTMLElement | null>,\n isOpen: boolean,\n getAnchor: (() => Element | null | undefined) | null,\n { keepDir = false }: { keepDir?: boolean } = {},\n) {\n const latest = useLatest(getAnchor);\n\n useIsomorphicLayoutEffect(() => {\n const root = rootRef.current;\n const anchor = latest.current?.();\n if (!isOpen || !root || !anchor) {\n return;\n }\n const sync = () => {\n for (const [name, value] of Object.entries(scopeOf(anchor))) {\n if (name === \"dir\" && keepDir) {\n continue;\n }\n if (value === null) {\n root.removeAttribute(name);\n } else if (root.getAttribute(name) !== value) {\n root.setAttribute(name, value);\n }\n }\n };\n sync();\n // Only scoping attributes: class and style churn on ancestors never re-applies.\n const observer = new MutationObserver(sync);\n for (let node: Element | null = anchor; node; node = node.parentElement) {\n observer.observe(node, { attributes: true, attributeFilter: scopeAttributes });\n }\n return () => observer.disconnect();\n }, [rootRef, isOpen, keepDir, latest]);\n}\n\n/** Applies the scope of the inline anchor an enclosing editor or popover provides, if any. */\nexport function useInheritedPortalScope(\n rootRef: RefObject<HTMLElement | null>,\n isOpen: boolean,\n options?: { keepDir?: boolean },\n) {\n const anchor = useContext(PortalScopeContext);\n usePortalScope(rootRef, isOpen, anchor && (() => anchor.current), options);\n}\n","import { createContext, useContext, useState, type ReactNode } from \"react\";\n\nconst LayerContext = createContext<number | undefined>(undefined);\n\n/**\n * Layer used by dialogs and popovers opened from this content, including\n * portaled editors. Keep it below the toast layer (80) so toasts stay visible.\n */\nexport function OverlayLayer({ layer, children }: { layer: number; children: ReactNode }) {\n return <LayerContext.Provider value={layer}>{children}</LayerContext.Provider>;\n}\nexport function useOverlayLayer() {\n return useContext(LayerContext);\n}\n\nconst OverlayHiddenContext = createContext(false);\nexport function useOverlayHidden() {\n return useContext(OverlayHiddenContext);\n}\n/** Suspend nested overlay controllers without changing their owner's open state. */\nexport function useOverlayOpen(open: boolean) {\n const hidden = useOverlayHidden();\n return open && !hidden;\n}\n\n/**\n * What a dialog hands its content: its layer, so nested dialogs and popovers\n * paint above it, and its suspension, so their controllers pause with it.\n */\nexport function DialogContent({\n layer,\n isSuspended,\n children,\n}: {\n layer: number | undefined;\n isSuspended: boolean;\n children: ReactNode;\n}) {\n return (\n <LayerContext.Provider value={layer}>\n <OverlayHiddenContext.Provider value={isSuspended}>{children}</OverlayHiddenContext.Provider>\n </LayerContext.Provider>\n );\n}\n\n/**\n * True once an open dialog has been suspended, so it resumes in place instead\n * of replaying its entry motion. Opening again starts over.\n */\nfunction useResumed(isOpen: boolean, isVisible: boolean) {\n const [phase, setPhase] = useState<\"closed\" | \"shown\" | \"suspended\">(\"closed\");\n const next = !isOpen\n ? \"closed\"\n : isVisible\n ? phase === \"closed\"\n ? \"shown\"\n : phase\n : phase === \"closed\"\n ? \"closed\"\n : \"suspended\";\n if (next !== phase) {\n setPhase(next);\n }\n return next === \"suspended\";\n}\n\n/**\n * Where an open dialog sits: its layer (its own, else its surroundings'),\n * whether a suspended ancestor or `isHidden` hides it, and whether it is\n * resuming from such a suspension.\n */\nexport function useDialogPresence(isOpen: boolean, isHidden: boolean, overlayLayer?: number) {\n const inheritedLayer = useOverlayLayer();\n const isVisible = useOverlayOpen(!isHidden);\n const isResumed = useResumed(isOpen, isVisible);\n return { layer: overlayLayer ?? inheritedLayer, isVisible, isResumed };\n}\n"],"mappings":"A,kHAAA,IAAMS,EACJ,gMAKF,SAASC,EAAa,EAAsB,CAC1C,IAAMC,EAAcC,EAAQ,QAAQ,mBAAmB,EASvD,MACE,EANAA,EAAQ,QAAQ,SAAS,GACzBD,GACAA,IAAgBC,GAChBD,EAAY,aAAa,iB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/E,CACA,SAAgBC,GAAkB,CAChC,OAAA,EAAOhE,EAAAA,WAAAA,CAAW6D,CAAY,CAChC,CAEA,IAAMI,GAAA,EAAuBlE,EAAAA,cAAAA,CAAc,EAAK,EAChD,SAAgBmE,GAAmB,CACjC,OAAA,EAAOlE,EAAAA,WAAAA,CAAWiE,CAAoB,CACxC,CAEA,SAAgBE,EAAe,EAAe,CAC5C,IAAMC,EAASF,EAAiB,EAChC,OAAOG,GAAQ,CAACD,CAClB,CAMA,SAAgBE,EAAc,CAC5B,QACA,cACA,YAKC,CACD,OACE,EAAAlE,EAAA,IAAA,CAACyD,EAAa,SAAd,CAAuB,MAAOE,EAC5B,UAAA,EAAA3D,EAAA,IAAA,CAAC6D,EAAqB,SAAtB,CAA+B,MAAOM,EAAc,UAAwC,CAAA,CACvE,CAAA,CAE3B,CAMA,SAASC,EAAW,EAAiB,EAAoB,CACvD,GAAM,CAACC,EAAOC,IAAA,EAAYzE,EAAAA,SAAAA,CAA2C,QAAQ,EACvE0C,EAAQY,EAEVoB,EACEF,IAAU,SACR,QACAA,EACFA,IAAU,SACR,SACA,YAPJ,SAWJ,OAHI9B,IAAS8B,GACXC,EAAS/B,CAAI,EAERA,IAAS,WAClB,CAOA,SAAgBiC,EAAkB,EAAiB,EAAmB,EAAuB,CAC3F,IAAMC,EAAiBb,EAAgB,EACjCW,EAAYR,EAAe,CAACW,CAAQ,EACpCC,EAAYP,EAAWjB,EAAQoB,CAAS,EAC9C,MAAO,CAAE,MAAOK,GAAgBH,EAAgB,YAAW,WAAU,CACvE,C"}
@@ -1,180 +0,0 @@
1
- import { t as e } from "./useIsomorphicLayoutEffect-Bc9hxFMc.js";
2
- import { createContext as t, useContext as n, useRef as r, useState as i } from "react";
3
- import { jsx as a } from "react/jsx-runtime";
4
- //#region src/internal/dialogFocus.ts
5
- var o = ":is(button, [href], input:not([type='hidden']), select, textarea, [tabindex], [contenteditable]:not([contenteditable='false'])):not(:disabled):not([tabindex='-1']):not([aria-hidden='true'])";
6
- function s(e) {
7
- let t = e.closest("[contenteditable]");
8
- return !(e.matches("a[href]") && t && t !== e && t.getAttribute("contenteditable") !== "false" && !e.hasAttribute("tabindex")) && (e.checkVisibility?.() ?? !e.closest("[hidden]")) && !e.closest("[inert]");
9
- }
10
- function c(e) {
11
- return !e || e === e.ownerDocument.body || !e.isConnected || e.closest("[aria-hidden='true'], [inert]") !== null;
12
- }
13
- function l(e, t) {
14
- let n = e;
15
- for (; n;) {
16
- if (n instanceof HTMLElement && !c(n) && (n.focus(t), n.getRootNode().activeElement === n)) return !0;
17
- n = n.parentElement?.closest("[tabindex]") ?? null;
18
- }
19
- return !1;
20
- }
21
- function u(e) {
22
- return e instanceof HTMLInputElement && e.type === "radio";
23
- }
24
- function d(e, t) {
25
- return e === t || u(e) && u(t) && e.name !== "" && e.name === t.name && e.form === t.form;
26
- }
27
- function f(e) {
28
- let t = Array.from(e.querySelectorAll(o)).filter(s);
29
- return t.filter((e) => !u(e) || e.checked || !t.some((t) => u(t) && t.checked && d(t, e)));
30
- }
31
- var p = /* @__PURE__ */ new WeakMap();
32
- function m(e, t) {
33
- return p.set(e, t), () => {
34
- p.delete(e);
35
- };
36
- }
37
- function h(e) {
38
- let t = e instanceof Element ? e : e.parentElement;
39
- for (; t && !p.has(t);) t = t.parentElement;
40
- return t;
41
- }
42
- function g(e, t) {
43
- let n = /* @__PURE__ */ new Set(), r = h(t);
44
- for (; r && !n.has(r);) {
45
- n.add(r);
46
- let t = p.get(r);
47
- if (e.contains(t)) return !0;
48
- r = h(t);
49
- }
50
- return !1;
51
- }
52
- function _(e, t) {
53
- return t !== null && (e.contains(t) || g(e, t));
54
- }
55
- function v(e, t) {
56
- return !!(t.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_PRECEDING);
57
- }
58
- function y(e, t) {
59
- if (e.key !== "Tab" || e.defaultPrevented || !t) return;
60
- let n = f(t), r = n[0], i = n.at(-1);
61
- if (!r || !i) return;
62
- let a = t.getRootNode().activeElement ?? document.activeElement, o = a !== null && t.contains(a);
63
- !o && a && g(t, a) || (!o || (e.shiftKey ? d(a, r) || v(a, r) : d(a, i) || v(i, a))) && (e.preventDefault(), (e.shiftKey ? i : r).focus());
64
- }
65
- function b(e) {
66
- let t = /* @__PURE__ */ new Set(), n = e;
67
- for (; !t.has(n);) {
68
- t.add(n);
69
- let r = n.closest("[aria-modal='true']"), i = h(n), a = f(r ?? (i instanceof HTMLElement ? i : e.ownerDocument.body)).filter((e) => h(e) === i), o = a.find((e) => v(n, e) && !n.contains(e));
70
- if (o) {
71
- o.focus({ preventScroll: !0 });
72
- return;
73
- }
74
- let s = i && p.get(i);
75
- if (r || !s) {
76
- if (a[0]) {
77
- a[0].focus({ preventScroll: !0 });
78
- return;
79
- }
80
- break;
81
- }
82
- if (!s.isConnected) break;
83
- n = s;
84
- }
85
- f(e)[0]?.focus({ preventScroll: !0 });
86
- }
87
- //#endregion
88
- //#region src/internal/useLatest.ts
89
- function x(t) {
90
- let n = r(t);
91
- return e(() => {
92
- n.current = t;
93
- }), n;
94
- }
95
- //#endregion
96
- //#region src/internal/portalScope.ts
97
- var S = t(null), C = [
98
- "data-theme",
99
- "lang",
100
- "dir"
101
- ];
102
- function w(e) {
103
- let t = e.closest("[dir]") ? getComputedStyle(e).direction || e.closest("[dir]").getAttribute("dir") : null;
104
- return {
105
- "data-theme": e.closest("[data-theme]")?.getAttribute("data-theme") ?? null,
106
- lang: e.closest("[lang]")?.getAttribute("lang") ?? null,
107
- dir: t
108
- };
109
- }
110
- function T(t, n, r, { keepDir: i = !1 } = {}) {
111
- let a = x(r);
112
- e(() => {
113
- let e = t.current, r = a.current?.();
114
- if (!n || !e || !r) return;
115
- let o = () => {
116
- for (let [t, n] of Object.entries(w(r))) t === "dir" && i || (n === null ? e.removeAttribute(t) : e.getAttribute(t) !== n && e.setAttribute(t, n));
117
- };
118
- o();
119
- let s = new MutationObserver(o);
120
- for (let e = r; e; e = e.parentElement) s.observe(e, {
121
- attributes: !0,
122
- attributeFilter: C
123
- });
124
- return () => s.disconnect();
125
- }, [
126
- t,
127
- n,
128
- i,
129
- a
130
- ]);
131
- }
132
- function E(e, t, r) {
133
- let i = n(S);
134
- T(e, t, i && (() => i.current), r);
135
- }
136
- //#endregion
137
- //#region src/internal/overlayLayer.tsx
138
- var D = t(void 0);
139
- function O({ layer: e, children: t }) {
140
- return /* @__PURE__ */ a(D.Provider, {
141
- value: e,
142
- children: t
143
- });
144
- }
145
- function k() {
146
- return n(D);
147
- }
148
- var A = t(!1);
149
- function j() {
150
- return n(A);
151
- }
152
- function M(e) {
153
- let t = j();
154
- return e && !t;
155
- }
156
- function N({ layer: e, isSuspended: t, children: n }) {
157
- return /* @__PURE__ */ a(D.Provider, {
158
- value: e,
159
- children: /* @__PURE__ */ a(A.Provider, {
160
- value: t,
161
- children: n
162
- })
163
- });
164
- }
165
- function P(e, t) {
166
- let [n, r] = i("closed"), a = e ? t ? n === "closed" ? "shown" : n : n === "closed" ? "closed" : "suspended" : "closed";
167
- return a !== n && r(a), a === "suspended";
168
- }
169
- function F(e, t, n) {
170
- let r = k(), i = M(!t), a = P(e, i);
171
- return {
172
- layer: n ?? r,
173
- isVisible: i,
174
- isResumed: a
175
- };
176
- }
177
- //#endregion
178
- export { y as _, k as a, E as c, c as d, b as f, f as g, m as h, j as i, T as l, _ as m, O as n, M as o, l as p, F as r, S as s, N as t, x as u };
179
-
180
- //# sourceMappingURL=overlayLayer-Og07sIyl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overlayLayer-Og07sIyl.js","names":["useIsomorphicLayoutEffect","focusableSelector","canTakeFocus","editingHost","element","cannotHoldFocus","focusNearest","candidate","options","isRadio","sameStop","a","b","tabbableControls","controls","container","control","other","popupAnchors","registerPopup","popup","anchor","popupAround","node","inOwnedPopup","visited","panel","panelHoldsFocus","active","precedes","trapTabFocus","event","first","last","inside","focusAfterField","origin","root","modal","next","useLatest","ref","useRef","value","PortalScopeContext","createContext","scopeAttributes","scopeOf","direction","usePortalScope","latest","getAnchor","rootRef","isOpen","sync","name","keepDir","observer","useInheritedPortalScope","useContext","LayerContext","OverlayLayer","layer","useOverlayLayer","OverlayHiddenContext","useOverlayHidden","useOverlayOpen","hidden","open","DialogContent","isSuspended","useResumed","phase","setPhase","useState","isVisible","useDialogPresence","inheritedLayer","isHidden","isResumed","overlayLayer"],"sources":["../../src/internal/dialogFocus.ts","../../src/internal/useLatest.ts","../../src/internal/portalScope.ts","../../src/internal/overlayLayer.tsx"],"sourcesContent":["const focusableSelector =\n \":is(button, [href], input:not([type='hidden']), select, textarea, [tabindex], [contenteditable]:not([contenteditable='false'])):not(:disabled):not([tabindex='-1']):not([aria-hidden='true'])\";\n\n// Unrendered controls (display: none, [hidden], closed <details>) and inert\n// subtrees cannot take focus. Environments without checkVisibility fall back\n// to the hidden attribute.\nfunction canTakeFocus(element: HTMLElement) {\n const editingHost = element.closest(\"[contenteditable]\");\n // A link being edited is document content, not a native Tab stop. Explicit\n // tabindex and links inside noneditable widgets still participate normally.\n const writingLink =\n element.matches(\"a[href]\") &&\n editingHost &&\n editingHost !== element &&\n editingHost.getAttribute(\"contenteditable\") !== \"false\" &&\n !element.hasAttribute(\"tabindex\");\n return (\n !writingLink &&\n (element.checkVisibility?.() ?? !element.closest(\"[hidden]\")) &&\n !element.closest(\"[inert]\")\n );\n}\n\n/** Removed, hidden and inert elements can't keep focus, and neither can the page. */\nexport function cannotHoldFocus(element: Element | null) {\n return (\n !element ||\n element === element.ownerDocument.body ||\n !element.isConnected ||\n element.closest(\"[aria-hidden='true'], [inert]\") !== null\n );\n}\n\n/**\n * Focuses `element`, or, when it can no longer take focus (disabled, or no\n * longer editable), its nearest ancestor with a tabindex, such as an enclosing\n * dialog panel. Returns whether anything took focus.\n */\nexport function focusNearest(element: Element | null, options?: FocusOptions) {\n let candidate = element;\n while (candidate) {\n if (candidate instanceof HTMLElement && !cannotHoldFocus(candidate)) {\n candidate.focus(options);\n if ((candidate.getRootNode() as Document | ShadowRoot).activeElement === candidate) {\n return true;\n }\n }\n candidate = candidate.parentElement?.closest(\"[tabindex]\") ?? null;\n }\n return false;\n}\n\nfunction isRadio(element: Element | null): element is HTMLInputElement {\n return element instanceof HTMLInputElement && element.type === \"radio\";\n}\n\n/** Radios sharing a name and form are one Tab stop. */\nfunction sameStop(a: Element, b: Element) {\n return (\n a === b || (isRadio(a) && isRadio(b) && a.name !== \"\" && a.name === b.name && a.form === b.form)\n );\n}\n\n/**\n * The controls Tab visits inside `container`, in document order. A radio group\n * contributes only its checked radio, or every radio while none is checked.\n */\nexport function tabbableControls(container: HTMLElement) {\n const controls = Array.from(container.querySelectorAll<HTMLElement>(focusableSelector)).filter(\n canTakeFocus,\n );\n return controls.filter(\n (control) =>\n !isRadio(control) ||\n control.checked ||\n !controls.some((other) => isRadio(other) && other.checked && sameStop(other, control)),\n );\n}\n\nconst popupAnchors = new WeakMap<Element, Element>();\n\n/**\n * Popups portal outside the dialog that opened them. Registering one with its\n * anchor lets that dialog's Tab trap treat the popup as its own.\n */\nexport function registerPopup(popup: Element, anchor: Element) {\n popupAnchors.set(popup, anchor);\n return () => {\n popupAnchors.delete(popup);\n };\n}\n\nfunction popupAround(node: Node) {\n let element = node instanceof Element ? node : node.parentElement;\n while (element && !popupAnchors.has(element)) {\n element = element.parentElement;\n }\n return element;\n}\n\n/** Inside a popup anchored in the panel, directly or through other popups. */\nfunction inOwnedPopup(panel: HTMLElement, node: Node) {\n const visited = new Set<Element>();\n let popup = popupAround(node);\n while (popup && !visited.has(popup)) {\n visited.add(popup);\n const anchor = popupAnchors.get(popup)!;\n if (panel.contains(anchor)) {\n return true;\n }\n popup = popupAround(anchor);\n }\n return false;\n}\n\n/** Focus in the panel or in a popup it owns, such as a menu that resumed with it. */\nexport function panelHoldsFocus(panel: HTMLElement, active: Element | null) {\n return active !== null && (panel.contains(active) || inOwnedPopup(panel, active));\n}\n\n/** `a` comes before `b` in document order, including as its ancestor. */\nfunction precedes(a: Node, b: Node) {\n return Boolean(b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING);\n}\n\n/**\n * Keeps Tab inside an aria-modal panel. Call only for the topmost dialog.\n * Focus that left the panel returns to its first control (last with Shift);\n * Tab inside a popup the panel owns is left to the popup and the browser.\n */\nexport function trapTabFocus(event: KeyboardEvent, panel: HTMLElement | null) {\n if (event.key !== \"Tab\" || event.defaultPrevented || !panel) {\n return;\n }\n const controls = tabbableControls(panel);\n const first = controls[0];\n const last = controls.at(-1);\n if (!first || !last) {\n return;\n }\n // document.activeElement stops at the host of a shadow root holding the panel.\n const active =\n (panel.getRootNode() as Document | ShadowRoot).activeElement ?? document.activeElement;\n const inside = active !== null && panel.contains(active);\n if (!inside && active && inOwnedPopup(panel, active)) {\n return;\n }\n // Focus on the panel itself, or on another untabbable element beyond the\n // first or last control, would otherwise leave the panel.\n const wraps =\n !inside ||\n (event.shiftKey\n ? sameStop(active, first) || precedes(active, first)\n : sameStop(active, last) || precedes(last, active));\n if (wraps) {\n event.preventDefault();\n (event.shiftKey ? last : first).focus();\n }\n}\n\n/**\n * Continue after the field, following popup anchors back to an enclosing modal or\n * the page. An anchor no longer in the document has no place in the Tab order,\n * so when the walk reaches one, or finds nothing to focus, focus returns to the\n * field's own first control rather than to the page or a closing popup.\n */\nexport function focusAfterField(root: HTMLElement) {\n const visited = new Set<Element>();\n let origin: Element = root;\n while (!visited.has(origin)) {\n visited.add(origin);\n const modal = origin.closest<HTMLElement>(\"[aria-modal='true']\");\n const popup = popupAround(origin);\n const scope = modal ?? (popup instanceof HTMLElement ? popup : root.ownerDocument.body);\n const controls = tabbableControls(scope).filter((control) => popupAround(control) === popup);\n const next = controls.find((control) => precedes(origin, control) && !origin.contains(control));\n if (next) {\n next.focus({ preventScroll: true });\n return;\n }\n const anchor = popup && popupAnchors.get(popup);\n if (modal || !anchor) {\n if (controls[0]) {\n controls[0].focus({ preventScroll: true });\n return;\n }\n break;\n }\n if (!anchor.isConnected) {\n break;\n }\n origin = anchor;\n }\n tabbableControls(root)[0]?.focus({ preventScroll: true });\n}\n","import { useRef } from \"react\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\n/**\n * The latest value, read when a callback or effect runs, so inline callbacks\n * never restart effects. Updated before layout effects and passive effects that\n * are declared after it read it.\n */\nexport function useLatest<T>(value: T) {\n const ref = useRef(value);\n useIsomorphicLayoutEffect(() => {\n ref.current = value;\n });\n return ref;\n}\n","import { createContext, useContext, type RefObject } from \"react\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\nimport { useLatest } from \"./useLatest\";\n\n/**\n * The inline element whose theme, direction and language body-mounted overlays\n * opened from inside it carry: RichTextEditor's frame, or a Popover's anchor.\n * Nested overlays inherit the same inline anchor rather than their parent's\n * panel, so they never depend on the order in which overlays mount.\n */\nexport const PortalScopeContext = createContext<RefObject<Element | null> | null>(null);\n\nconst scopeAttributes = [\"data-theme\", \"lang\", \"dir\"];\n\nfunction scopeOf(anchor: Element) {\n const direction = anchor.closest(\"[dir]\")\n ? getComputedStyle(anchor).direction || anchor.closest(\"[dir]\")!.getAttribute(\"dir\")\n : null;\n return {\n \"data-theme\": anchor.closest(\"[data-theme]\")?.getAttribute(\"data-theme\") ?? null,\n lang: anchor.closest(\"[lang]\")?.getAttribute(\"lang\") ?? null,\n dir: direction,\n };\n}\n\n/**\n * Copies the anchor's `data-theme`, `lang` and `dir` onto an overlay root while\n * it is open, and follows later changes to those attributes on the anchor's\n * ancestors. Attributes rather than resolved values, so the theme's whole\n * stylesheet keeps applying, including `color-scheme` and media queries.\n * Without an anchor the overlay inherits from the document root, as before.\n */\nexport function usePortalScope(\n rootRef: RefObject<HTMLElement | null>,\n isOpen: boolean,\n getAnchor: (() => Element | null | undefined) | null,\n { keepDir = false }: { keepDir?: boolean } = {},\n) {\n const latest = useLatest(getAnchor);\n\n useIsomorphicLayoutEffect(() => {\n const root = rootRef.current;\n const anchor = latest.current?.();\n if (!isOpen || !root || !anchor) {\n return;\n }\n const sync = () => {\n for (const [name, value] of Object.entries(scopeOf(anchor))) {\n if (name === \"dir\" && keepDir) {\n continue;\n }\n if (value === null) {\n root.removeAttribute(name);\n } else if (root.getAttribute(name) !== value) {\n root.setAttribute(name, value);\n }\n }\n };\n sync();\n // Only scoping attributes: class and style churn on ancestors never re-applies.\n const observer = new MutationObserver(sync);\n for (let node: Element | null = anchor; node; node = node.parentElement) {\n observer.observe(node, { attributes: true, attributeFilter: scopeAttributes });\n }\n return () => observer.disconnect();\n }, [rootRef, isOpen, keepDir, latest]);\n}\n\n/** Applies the scope of the inline anchor an enclosing editor or popover provides, if any. */\nexport function useInheritedPortalScope(\n rootRef: RefObject<HTMLElement | null>,\n isOpen: boolean,\n options?: { keepDir?: boolean },\n) {\n const anchor = useContext(PortalScopeContext);\n usePortalScope(rootRef, isOpen, anchor && (() => anchor.current), options);\n}\n","import { createContext, useContext, useState, type ReactNode } from \"react\";\n\nconst LayerContext = createContext<number | undefined>(undefined);\n\n/**\n * Layer used by dialogs and popovers opened from this content, including\n * portaled editors. Keep it below the toast layer (80) so toasts stay visible.\n */\nexport function OverlayLayer({ layer, children }: { layer: number; children: ReactNode }) {\n return <LayerContext.Provider value={layer}>{children}</LayerContext.Provider>;\n}\nexport function useOverlayLayer() {\n return useContext(LayerContext);\n}\n\nconst OverlayHiddenContext = createContext(false);\nexport function useOverlayHidden() {\n return useContext(OverlayHiddenContext);\n}\n/** Suspend nested overlay controllers without changing their owner's open state. */\nexport function useOverlayOpen(open: boolean) {\n const hidden = useOverlayHidden();\n return open && !hidden;\n}\n\n/**\n * What a dialog hands its content: its layer, so nested dialogs and popovers\n * paint above it, and its suspension, so their controllers pause with it.\n */\nexport function DialogContent({\n layer,\n isSuspended,\n children,\n}: {\n layer: number | undefined;\n isSuspended: boolean;\n children: ReactNode;\n}) {\n return (\n <LayerContext.Provider value={layer}>\n <OverlayHiddenContext.Provider value={isSuspended}>{children}</OverlayHiddenContext.Provider>\n </LayerContext.Provider>\n );\n}\n\n/**\n * True once an open dialog has been suspended, so it resumes in place instead\n * of replaying its entry motion. Opening again starts over.\n */\nfunction useResumed(isOpen: boolean, isVisible: boolean) {\n const [phase, setPhase] = useState<\"closed\" | \"shown\" | \"suspended\">(\"closed\");\n const next = !isOpen\n ? \"closed\"\n : isVisible\n ? phase === \"closed\"\n ? \"shown\"\n : phase\n : phase === \"closed\"\n ? \"closed\"\n : \"suspended\";\n if (next !== phase) {\n setPhase(next);\n }\n return next === \"suspended\";\n}\n\n/**\n * Where an open dialog sits: its layer (its own, else its surroundings'),\n * whether a suspended ancestor or `isHidden` hides it, and whether it is\n * resuming from such a suspension.\n */\nexport function useDialogPresence(isOpen: boolean, isHidden: boolean, overlayLayer?: number) {\n const inheritedLayer = useOverlayLayer();\n const isVisible = useOverlayOpen(!isHidden);\n const isResumed = useResumed(isOpen, isVisible);\n return { layer: overlayLayer ?? inheritedLayer, isVisible, isResumed };\n}\n"],"mappings":";;;;AAAA,IAAMC,IACJ;AAKF,SAASC,EAAa,GAAsB;CAC1C,IAAMC,IAAcC,EAAQ,QAAQ,mBAAmB;CASvD,OACE,EANAA,EAAQ,QAAQ,SAAS,KACzBD,KACAA,MAAgBC,KAChBD,EAAY,aAAa,iBAAiB,MAAM,WAChD,CAACC,EAAQ,aAAa,UAAU,OAG/BA,EAAQ,kBAAkB,KAAK,CAACA,EAAQ,QAAQ,UAAU,MAC3D,CAACA,EAAQ,QAAQ,SAAS;AAE9B;AAGA,SAAgBC,EAAgB,GAAyB;CACvD,OACE,CAACD,KACDA,MAAYA,EAAQ,cAAc,QAClC,CAACA,EAAQ,eACTA,EAAQ,QAAQ,+BAA+B,MAAM;AAEzD;AAOA,SAAgBE,EAAa,GAAyB,GAAwB;CAC5E,IAAIC,IAAYH;CAChB,OAAOG,IAAW;EAChB,IAAIA,aAAqB,eAAe,CAACF,EAAgBE,CAAS,MAChEA,EAAU,MAAMC,CAAO,GAClBD,EAAU,YAAY,CAAC,CAA2B,kBAAkBA,IACvE,OAAO;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J,OAHIjC,MAASiC,KACXC,EAASlC,CAAI,GAERA,MAAS;AAClB;AAOA,SAAgBqC,EAAkB,GAAiB,GAAmB,GAAuB;CAC3F,IAAMC,IAAiBd,EAAgB,GACjCY,IAAYT,EAAe,CAACY,CAAQ,GACpCC,IAAYR,EAAWlB,GAAQsB,CAAS;CAC9C,OAAO;EAAE,OAAOK,KAAgBH;EAAgB;EAAW;CAAU;AACvE"}
@@ -1,41 +0,0 @@
1
- import type { EntryItem } from "../EntryPicker/index.cjs";
2
- import type { SeedCopy } from "../EntryPicker/use-selected-items.cjs";
3
- import type { RichTextEmbedKind, RichTextEmbedSource } from "./embed-types.cjs";
4
- /** Whether a source can offer something to embed: choices to list, or one to create. */
5
- export declare function canEmbed(source: RichTextEmbedSource | undefined): boolean;
6
- /**
7
- * Whether a source's insertion stages a batch: always, when it has choices to
8
- * list. A source that can only create offers one item, so it stays single.
9
- */
10
- export declare function canBatch(source: RichTextEmbedSource | undefined): boolean;
11
- /**
12
- * What a block's node view reads from its source. Callbacks are stable wrappers
13
- * over the latest source and the rest are plain values, so an application that
14
- * builds new sources on every render doesn't re-render every block.
15
- */
16
- export interface EmbedSourceView {
17
- resolveItem?: (id: string) => EntryItem | null | Promise<EntryItem | null>;
18
- refreshKey?: string | number;
19
- items?: EntryItem[];
20
- isDialogHidden: boolean;
21
- /** The source can list or create a replacement. */
22
- canEmbed: boolean;
23
- onEditItem?: (item: EntryItem) => void;
24
- }
25
- export declare const EmbedContext: import("react").Context<{
26
- views: Partial<Record<RichTextEmbedKind, EmbedSourceView>>;
27
- disabled: boolean;
28
- /** A picker session is suspended or creating: starting another would orphan it. */
29
- busy: boolean;
30
- replace: (kind: RichTextEmbedKind, position: number) => void;
31
- /**
32
- * Changes with each pick. Picking a block's own item again leaves an equal node
33
- * that ProseMirror doesn't re-render, so blocks re-read `seed` when it changes.
34
- */
35
- pickCount: number;
36
- /** The row a writer just picked for this item, so its new block shows it at once. */
37
- seed: (kind: RichTextEmbedKind, id: string) => SeedCopy | undefined;
38
- /** The block has shown `copy`; later blocks for the item describe it afresh. */
39
- forgetSeed: (kind: RichTextEmbedKind, id: string, copy: SeedCopy) => void;
40
- }>;
41
- //# sourceMappingURL=embed-context.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"embed-context.d.cts","sourceRoot":"","sources":["../../../src/components/RichTextEditor/embed-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE5E,wFAAwF;AACxF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS,WAE/D;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS,WAE/D;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IAC3E,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;IACxB,mDAAmD;IACnD,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,YAAY;WAChB,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC;cAChD,OAAO;IACjB,mFAAmF;UAC7E,OAAO;aACJ,CAAC,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI;IAC5D;;;OAGG;eACQ,MAAM;IACjB,qFAAqF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