@pgcorp/ui-kit 0.14.0 → 0.15.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 (117) hide show
  1. package/README.md +330 -12
  2. package/dist/assets/src/components/layout/{SResizeHandle.vue_vue_type_style_index_0_scoped_13b9b27a_lang.css → SResizeHandle.vue_vue_type_style_index_0_scoped_dc65aba1_lang.css} +1 -1
  3. package/dist/assets/src/components/shared/_internal/SDialogSurface.css_vue_type_style_index_0_src_a108e8f1_scoped_a108e8f1_lang.css +2 -0
  4. package/dist/assets/src/components/shared/containers/{SCollapsiblePanel.css_vue_type_style_index_0_src_71824088_scoped_71824088_lang.css → SCollapsiblePanel.css_vue_type_style_index_0_src_db85261d_scoped_db85261d_lang.css} +1 -1
  5. package/dist/assets/src/components/shared/containers/{SOverlayHost.css_vue_type_style_index_0_src_8f9be94e_scoped_8f9be94e_lang.css → SOverlayHost.css_vue_type_style_index_0_src_09215628_scoped_09215628_lang.css} +1 -1
  6. package/dist/assets/src/components/shared/containers/{SPopover.css_vue_type_style_index_0_src_4091d007_scoped_4091d007_lang.css → SPopover.css_vue_type_style_index_0_src_a4f1f64a_scoped_a4f1f64a_lang.css} +1 -1
  7. package/dist/assets/src/components/shared/containers/SSidebarSection.css_vue_type_style_index_0_src_52396e42_scoped_52396e42_lang.css +2 -0
  8. package/dist/assets/src/components/shared/controls/SButton.css_vue_type_style_index_0_src_7a5acda9_scoped_7a5acda9_lang.css +1 -1
  9. package/dist/assets/src/components/shared/controls/SCheckbox.css_vue_type_style_index_0_src_2562f916_scoped_2562f916_lang.css +2 -0
  10. package/dist/assets/src/components/shared/controls/SCombobox.css_vue_type_style_index_0_src_d630c922_scoped_d630c922_lang.css +2 -0
  11. package/dist/assets/src/components/shared/controls/SContextMenu.css_vue_type_style_index_0_src_43b6e378_scoped_43b6e378_lang.css +1 -0
  12. package/dist/assets/src/components/shared/controls/{SDropdownMenu.css_vue_type_style_index_0_src_857e2649_scoped_857e2649_lang.css → SDropdownMenu.css_vue_type_style_index_0_src_40040ae5_scoped_40040ae5_lang.css} +1 -1
  13. package/dist/assets/src/components/shared/controls/{SMenuSurface.css_vue_type_style_index_0_src_84109ad9_scoped_84109ad9_lang.css → SMenuSurface.css_vue_type_style_index_0_src_d2b7d71b_scoped_d2b7d71b_lang.css} +1 -1
  14. package/dist/assets/src/components/shared/controls/SSelect.css_vue_type_style_index_0_src_d1ead6c0_scoped_d1ead6c0_lang.css +2 -0
  15. package/dist/assets/src/components/shared/data-display/SControlledToastViewport.css_vue_type_style_index_0_src_a69aa84b_scoped_a69aa84b_lang.css +2 -0
  16. package/dist/assets/src/components/shared/data-display/SScrollViewport.css_vue_type_style_index_0_src_d94fcf8c_scoped_d94fcf8c_lang.css +2 -0
  17. package/dist/assets/src/components/shared/data-display/STooltip.css_vue_type_style_index_0_src_true_lang.css +1 -1
  18. package/dist/assets/src/components/shared/data-display/_internal/STableFrame.css_vue_type_style_index_0_src_914bad28_scoped_914bad28_lang.css +2 -0
  19. package/dist/assets/src/components/shared/navigation/{SBottomNav.vue_vue_type_style_index_0_scoped_24be0f2b_lang.css → SBottomNav.vue_vue_type_style_index_0_scoped_68cf84b3_lang.css} +1 -1
  20. package/dist/src/components/layout/SResizeHandle.vue.js +2 -2
  21. package/dist/src/components/layout/SResizeHandle.vue_vue_type_script_setup_true_lang.js +4 -2
  22. package/dist/src/components/shared/_internal/SDialogSurface.vue.d.ts +9 -1
  23. package/dist/src/components/shared/_internal/SDialogSurface.vue.js +2 -2
  24. package/dist/src/components/shared/_internal/SDialogSurface.vue_vue_type_script_setup_true_lang.js +174 -82
  25. package/dist/src/components/shared/_internal/dialogSurface.d.ts +2 -0
  26. package/dist/src/components/shared/_internal/dialogSurface.js +30 -27
  27. package/dist/src/components/shared/_internal/dialogSurfaceMotion.d.ts +14 -0
  28. package/dist/src/components/shared/_internal/dialogSurfaceMotion.js +84 -0
  29. package/dist/src/components/shared/_internal/focusTrap.js +15 -13
  30. package/dist/src/components/shared/containers/SCollapsiblePanel.vue.d.ts +5 -0
  31. package/dist/src/components/shared/containers/SCollapsiblePanel.vue.js +2 -2
  32. package/dist/src/components/shared/containers/SCollapsiblePanel.vue_vue_type_script_setup_true_lang.js +123 -121
  33. package/dist/src/components/shared/containers/SDrawer.vue.d.ts +4 -4
  34. package/dist/src/components/shared/containers/SDrawer.vue.js +3 -6
  35. package/dist/src/components/shared/containers/SDrawer.vue_vue_type_script_setup_true_lang.js +104 -128
  36. package/dist/src/components/shared/containers/SModal.vue.d.ts +8 -8
  37. package/dist/src/components/shared/containers/SModal.vue.js +3 -6
  38. package/dist/src/components/shared/containers/SModal.vue_vue_type_script_setup_true_lang.js +87 -103
  39. package/dist/src/components/shared/containers/SOverlayHost.vue.js +2 -2
  40. package/dist/src/components/shared/containers/SOverlayHost.vue_vue_type_script_setup_true_lang.js +32 -31
  41. package/dist/src/components/shared/containers/SPanel.vue.d.ts +1 -1
  42. package/dist/src/components/shared/containers/SPopover.vue.js +2 -2
  43. package/dist/src/components/shared/containers/SPopover.vue_vue_type_script_setup_true_lang.js +225 -200
  44. package/dist/src/components/shared/containers/SSidebarSection.vue.js +2 -2
  45. package/dist/src/components/shared/containers/SSidebarSection.vue_vue_type_script_setup_true_lang.js +4 -3
  46. package/dist/src/components/shared/controls/SCheckbox.vue.js +2 -2
  47. package/dist/src/components/shared/controls/SCheckbox.vue_vue_type_script_setup_true_lang.js +13 -7
  48. package/dist/src/components/shared/controls/SCombobox.vue.js +2 -2
  49. package/dist/src/components/shared/controls/SCombobox.vue_vue_type_script_setup_true_lang.js +104 -94
  50. package/dist/src/components/shared/controls/SContextMenu.vue.js +2 -2
  51. package/dist/src/components/shared/controls/SContextMenu.vue_vue_type_script_setup_true_lang.js +86 -81
  52. package/dist/src/components/shared/controls/SDropdownMenu.vue.js +2 -2
  53. package/dist/src/components/shared/controls/SDropdownMenu.vue_vue_type_script_setup_true_lang.js +77 -72
  54. package/dist/src/components/shared/controls/SMenuSurface.vue.js +2 -2
  55. package/dist/src/components/shared/controls/SMenuSurface.vue_vue_type_script_setup_true_lang.js +81 -77
  56. package/dist/src/components/shared/controls/SSelect.vue.js +2 -2
  57. package/dist/src/components/shared/controls/SSelect.vue_vue_type_script_setup_true_lang.js +85 -77
  58. package/dist/src/components/shared/data-display/SControlledToastViewport.vue.js +2 -2
  59. package/dist/src/components/shared/data-display/SControlledToastViewport.vue_vue_type_script_setup_true_lang.js +58 -49
  60. package/dist/src/components/shared/data-display/SScrollViewport.vue.d.ts +10 -5
  61. package/dist/src/components/shared/data-display/SScrollViewport.vue.js +2 -2
  62. package/dist/src/components/shared/data-display/SScrollViewport.vue_vue_type_script_setup_true_lang.js +162 -111
  63. package/dist/src/components/shared/data-display/STooltip.vue_vue_type_script_setup_true_lang.js +276 -224
  64. package/dist/src/components/shared/data-display/_internal/STableFrame.vue.d.ts +3 -3
  65. package/dist/src/components/shared/data-display/_internal/STableFrame.vue.js +2 -2
  66. package/dist/src/components/shared/data-display/_internal/STableFrame.vue_vue_type_script_setup_true_lang.js +62 -46
  67. package/dist/src/components/shared/data-display/scrollViewport.d.ts +2 -0
  68. package/dist/src/components/shared/navigation/SBottomNav.vue.js +2 -2
  69. package/dist/src/components/shared/navigation/SBottomNav.vue_vue_type_script_setup_true_lang.js +3 -1
  70. package/dist/src/components/shared/navigation/STabList.vue.d.ts +1 -1
  71. package/dist/src/composables/useDialogOverlay.d.ts +12 -2
  72. package/dist/src/composables/useDialogOverlay.js +192 -119
  73. package/dist/src/internal/flatTree.d.ts +8 -0
  74. package/dist/src/internal/flatTree.js +23 -0
  75. package/dist/src/internal/focusNavigation.d.ts +3 -0
  76. package/dist/src/internal/focusNavigation.js +28 -15
  77. package/dist/src/internal/inertLease.d.ts +8 -0
  78. package/dist/src/internal/inertLease.js +33 -0
  79. package/dist/src/internal/layerStack.d.ts +40 -0
  80. package/dist/src/internal/layerStack.js +301 -94
  81. package/dist/src/internal/nativeFocus.d.ts +4 -0
  82. package/dist/src/internal/nativeFocus.js +12 -0
  83. package/dist/src/internal/overlayPortal.d.ts +17 -0
  84. package/dist/src/internal/overlayPortal.js +23 -0
  85. package/dist/src/internal/semanticSizing.d.ts +2 -2
  86. package/dist/src/internal/semanticSizing.js +2 -1
  87. package/dist/src/internal/useMenuLayer.d.ts +1 -0
  88. package/dist/src/internal/useMenuLayer.js +63 -57
  89. package/dist/src/internal/viewportModality.d.ts +27 -0
  90. package/dist/src/internal/viewportModality.js +132 -0
  91. package/dist/typography.js +17 -62
  92. package/docs/overlay-lifecycle.md +195 -0
  93. package/docs/public-api.md +141 -4
  94. package/docs/resize.md +34 -5
  95. package/docs/scroll-viewport.md +30 -10
  96. package/docs/theming.md +42 -8
  97. package/package.json +1 -1
  98. package/src/components/shared/_internal/SDialogSurface.css +185 -40
  99. package/src/components/shared/controls/SButton.css +0 -3
  100. package/src/components/shared/controls/SCheckbox.css +19 -7
  101. package/src/components/shared/data-display/SControlledToastViewport.css +2 -10
  102. package/src/components/shared/data-display/SScrollViewport.css +17 -1
  103. package/src/components/shared/data-display/STooltip.css +1 -1
  104. package/src/components/shared/data-display/_internal/STableFrame.css +1 -5
  105. package/dist/assets/src/components/shared/_internal/SDialogSurface.css_vue_type_style_index_0_src_0e58afdc_scoped_0e58afdc_lang.css +0 -2
  106. package/dist/assets/src/components/shared/containers/SDrawer.css_vue_type_style_index_0_src_61cf20dd_scoped_61cf20dd_lang.css +0 -2
  107. package/dist/assets/src/components/shared/containers/SModal.css_vue_type_style_index_0_src_42e1bd5f_scoped_42e1bd5f_lang.css +0 -2
  108. package/dist/assets/src/components/shared/containers/SSidebarSection.css_vue_type_style_index_0_src_21f71ae8_scoped_21f71ae8_lang.css +0 -2
  109. package/dist/assets/src/components/shared/controls/SCheckbox.css_vue_type_style_index_0_src_55d4826e_scoped_55d4826e_lang.css +0 -2
  110. package/dist/assets/src/components/shared/controls/SCombobox.css_vue_type_style_index_0_src_537f5744_scoped_537f5744_lang.css +0 -2
  111. package/dist/assets/src/components/shared/controls/SContextMenu.css_vue_type_style_index_0_src_03921269_scoped_03921269_lang.css +0 -1
  112. package/dist/assets/src/components/shared/controls/SSelect.css_vue_type_style_index_0_src_df3d6688_scoped_df3d6688_lang.css +0 -2
  113. package/dist/assets/src/components/shared/data-display/SControlledToastViewport.css_vue_type_style_index_0_src_5864b6c6_scoped_5864b6c6_lang.css +0 -2
  114. package/dist/assets/src/components/shared/data-display/SScrollViewport.css_vue_type_style_index_0_src_e5d11342_scoped_e5d11342_lang.css +0 -2
  115. package/dist/assets/src/components/shared/data-display/_internal/STableFrame.css_vue_type_style_index_0_src_52b5825e_scoped_52b5825e_lang.css +0 -2
  116. package/src/components/shared/containers/SDrawer.css +0 -87
  117. package/src/components/shared/containers/SModal.css +0 -27
@@ -1,158 +1,365 @@
1
1
  import { createAggregateError as e } from "./es2020.js";
2
- import { isFocusableElement as t } from "./focusNavigation.js";
2
+ import { flatTreeContains as t } from "./flatTree.js";
3
+ import { nativeFocusedElement as n } from "./nativeFocus.js";
4
+ import { acquireNativeDialog as r } from "./viewportModality.js";
5
+ import { isFocusableElement as i, isProgrammaticallyFocusableElement as a } from "./focusNavigation.js";
3
6
  //#region src/internal/layerStack.ts
4
- var n = [], r = !1, i = 0, a = "", o = 0, s = (e, t) => e.root()?.contains(t) || e.anchor?.()?.contains(t) ? !0 : e.branches?.().some((e) => e.contains(t)) ?? !1, c = (e) => {
7
+ var o = [], s = !1, c = !1, l = 0, u = "", d = 0, f = null, p = null, m = 0, h = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new WeakMap(), _ = null, v = t, y = (e, t) => {
8
+ let n = e.root();
9
+ return n && v(n, t) ? !0 : e.branches?.().some((e) => v(e, t)) ?? !1;
10
+ }, b = (e, t) => {
11
+ let n = e.anchor?.();
12
+ return y(e, t) || !!(n && v(n, t));
13
+ }, x = (e, t) => {
14
+ let n = e.dismissalRoots?.();
15
+ if (!n) return b(e, t);
16
+ let r = e.anchor?.();
17
+ return n.some((e) => v(e, t)) || (e.branches?.().some((e) => v(e, t)) ?? !1) || !!(r && v(r, t));
18
+ }, S = (e) => e.lost || !e.target.isConnected || e.programmatic && e.target instanceof HTMLElement && !a(e.target), C = (e) => {
19
+ e.active = !1, h.delete(e), K();
20
+ }, w = (e) => e.target instanceof Element && (!e.target.isConnected || E(e.modalityLoss) || e.programmatic && e.target instanceof HTMLElement && !a(e.target)), T = (e) => (e.releasingHost || e.hostReleased) && e.programmatic && e.releaseBoundary?.isConnected === !0 && e.releaseBoundary.hasAttribute("inert") && w(e), E = (e) => e !== null && e.mutation.isCurrent() && e.target.isConnected && v(e.mutation.boundary, e.target), D = (e) => T(e) || E(e.modalityLoss), O = (e) => {
21
+ if (!e.active || !e.settling) return;
22
+ e.settling = !1;
23
+ let t = n();
24
+ t !== e.target && (t === document.body && D(e) || C(e));
25
+ }, k = (e) => {
26
+ if (!e.active || e.focusRevision !== m) return !1;
27
+ let t = n();
28
+ return t === e.target ? !0 : t !== document.body || !w(e) ? !1 : e.source ? !0 : D(e);
29
+ }, A = (e, t) => [...e.encounters].every((e) => e === t || e.registered && Q(t, e)), j = (e, t) => {
30
+ _ = {
31
+ request: e,
32
+ target: t
33
+ };
34
+ try {
35
+ t.focus({ preventScroll: !0 });
36
+ } finally {
37
+ _ = null;
38
+ }
39
+ };
40
+ function M(e = {}) {
41
+ if (typeof document > "u" || typeof window > "u") return null;
42
+ if (e.releaseBoundary !== void 0 && e.releaseBoundary !== null && (!(e.releaseBoundary instanceof HTMLElement) || !e.releaseBoundary.isConnected || e.releaseBoundary.ownerDocument !== document)) throw TypeError("layerStack: focus release boundary must be a connected same-document HTMLElement");
43
+ let t = n(), r = f, i = r !== null && r.revision === d && r.focusRevision === m && (t === r.activeAtClose || t === document.body && (r.activeAtClose instanceof HTMLElement && !r.activeAtClose.isConnected || E(r.retirementLoss))), s = (t && t !== document.body ? [...o].reverse().find((e) => y(e, t)) ?? null : null) ?? (i ? r.entry : null);
44
+ if (t === document.body && p && !s) return null;
45
+ let c = i ? r.activeAtClose : t, l = c instanceof HTMLElement ? c : null;
46
+ if (s?.kind === "menu") {
47
+ l = s.restoreTarget;
48
+ let e = s.parentId;
49
+ for (; l && e;) {
50
+ let t = o.find((t) => t.id === e);
51
+ if (!t || t.kind !== "menu" || !y(t, l)) break;
52
+ l = t.restoreTarget, e = t.parentId;
53
+ }
54
+ }
55
+ let u = Object.freeze({
56
+ restoreTarget: l,
57
+ acquireHost: (e) => {
58
+ _.active && !k(_) && C(_);
59
+ let t = _.releaseBoundary, r = _.active && _.target instanceof Node && n() === _.target && t?.isConnected === !0 && v(t, _.target);
60
+ _.releasingHost = r;
61
+ try {
62
+ let n = e();
63
+ return _.hostReleased = r && t?.hasAttribute("inert") === !0, n;
64
+ } finally {
65
+ _.releasingHost = !1;
66
+ }
67
+ },
68
+ cancel: () => C(_)
69
+ }), _ = {
70
+ token: u,
71
+ source: s,
72
+ target: c,
73
+ programmatic: c instanceof HTMLElement && a(c),
74
+ releaseBoundary: e.releaseBoundary ?? null,
75
+ encounters: /* @__PURE__ */ new Set(),
76
+ focusRevision: m,
77
+ pendingRestore: i ? r : null,
78
+ claimant: null,
79
+ active: !0,
80
+ settling: !1,
81
+ releasingHost: !1,
82
+ hostReleased: !1,
83
+ modalityLoss: null
84
+ };
85
+ return g.set(u, _), h.add(_), W(), u;
86
+ }
87
+ var N = (e) => {
88
+ let t = e && e !== document.body ? [...o].reverse().find((t) => y(t, e)) : void 0;
89
+ p = e && t ? {
90
+ target: e,
91
+ entry: t,
92
+ programmatic: e instanceof HTMLElement && a(e),
93
+ lost: !1,
94
+ settling: !1
95
+ } : null;
96
+ }, P = () => {
97
+ let e = n();
98
+ if (e === document.body) {
99
+ let e = p !== null && S(p), t = [...h].filter((t) => D(t) || e && t.source === p?.entry);
100
+ if (e || t.length > 0) {
101
+ e && p && (p.lost = !0);
102
+ for (let e of [...h]) t.includes(e) || C(e);
103
+ return;
104
+ }
105
+ }
106
+ m += 1;
107
+ for (let t of [...h]) {
108
+ let n = _;
109
+ n && t.pendingRestore === n.request && t.source === n.request.entry && e === n.target && e === t.token.restoreTarget ? (t.target = e, t.programmatic = e instanceof HTMLElement && a(e), t.focusRevision = m) : C(t);
110
+ }
111
+ N(e);
112
+ }, F = (e) => {
113
+ if (p !== e || !e.settling) return;
114
+ e.settling = !1;
115
+ let t = n();
116
+ if (t !== e.target) {
117
+ if (t === document.body && S(e)) {
118
+ e.lost = !0;
119
+ return;
120
+ }
121
+ p = null, m += 1;
122
+ for (let e of [...h]) C(e);
123
+ }
124
+ }, I = (e) => {
125
+ let t = e.composedPath().find((e) => e instanceof Element);
126
+ for (let e of h) e.source || e.target !== t || n() === e.target || D(e) || e.settling || (e.settling = !0, queueMicrotask(() => O(e)));
127
+ let r = p;
128
+ if (r && n() !== r.target && e.composedPath().find((e) => e instanceof Element) === r.target) {
129
+ if (S(r)) {
130
+ r.lost = !0;
131
+ return;
132
+ }
133
+ r.settling || (r.settling = !0, queueMicrotask(() => F(r)));
134
+ }
135
+ }, ee = (e) => {
5
136
  if (e.parent !== void 0) {
6
137
  if (e.parent === null) return null;
7
- let t = n.find((t) => t.id === e.parent?.id);
138
+ let t = o.find((t) => t.id === e.parent?.id);
8
139
  if (!t?.registered || !t.root()?.isConnected) throw TypeError("layerStack: explicit parent must be a live connected layer registration");
9
140
  return t.id;
10
141
  }
11
142
  let t = e.anchor?.() ?? e.restoreTarget ?? (typeof document < "u" && document.activeElement instanceof HTMLElement ? document.activeElement : null);
12
- return t ? [...n].reverse().find((e) => s(e, t))?.id ?? null : null;
13
- }, l = () => n[n.length - 1], u = (e, t) => {
143
+ return t ? [...o].reverse().find((e) => b(e, t))?.id ?? null : null;
144
+ }, L = () => o[o.length - 1], te = (e, t) => {
14
145
  if (!e.eventBoundary) return !0;
15
146
  let n = e.eventBoundary();
16
- return n?.isConnected ? t.composedPath().some((t) => t instanceof Node && (n.contains(t) || s(e, t))) : !1;
17
- }, d = (e) => {
18
- let t = [...n].reverse().find((e) => e.modal);
19
- return [...n].reverse().find((n) => (!t || n === t || T(n, t)) && u(n, e));
20
- }, f = (e) => {
147
+ return n?.isConnected ? t.composedPath().some((t) => t instanceof Node && (n.contains(t) || b(e, t))) : !1;
148
+ }, R = (e) => {
149
+ let t = [...o].reverse().find((e) => e.modal);
150
+ return [...o].reverse().find((n) => (!t || n === t || Q(n, t)) && te(n, e));
151
+ }, z = (e) => {
21
152
  let t = e.parentId;
22
153
  for (; t;) {
23
- let e = n.find((e) => e.id === t);
154
+ let e = o.find((e) => e.id === t);
24
155
  if (!e) break;
25
156
  if (e.modal || e.trapFocus) return e.root() ?? document;
26
157
  t = e.parentId;
27
158
  }
28
159
  return document;
29
- }, p = (e) => {
30
- if (!l()) return;
160
+ }, B = (e) => {
161
+ if (!L()) return;
31
162
  if (e.key === "Escape") {
32
- let t = d(e);
163
+ let t = R(e);
33
164
  if (!t) return;
34
165
  (t.dismissOnEscape?.() ?? !0) && (e.preventDefault(), e.stopPropagation(), t.requestDismiss("escape", e));
35
166
  return;
36
167
  }
37
168
  if (e.key !== "Tab") return;
38
169
  let t = -1;
39
- for (let e = n.length - 1; e >= 0; --e) if (n[e]?.trapFocus) {
170
+ for (let e = o.length - 1; e >= 0; --e) if (o[e]?.trapFocus) {
40
171
  t = e;
41
172
  break;
42
173
  }
43
174
  if (t < 0) return;
44
- let r = n[t];
45
- r && (n.slice(t + 1).some((e) => T(e, r) && (e.blocksParentFocusTrap ?? !0)) || r.trapFocus?.(e));
46
- }, m = (e, t) => {
47
- let r = d(e);
48
- if (!r) return;
49
- let i = e.target;
50
- if (i instanceof Node && s(r, i)) return;
51
- let a = x();
52
- t === "outside-pointer" && a && i instanceof Node && !s(a, i) && !n.some((e) => T(e, a) && s(e, i)) && e.preventDefault(), (r.dismissOnOutsidePointer?.() ?? !0) && r.requestDismiss(t, e);
53
- }, h = (e) => {
54
- m(e, "outside-pointer");
55
- }, g = (e) => {
56
- m(e, "outside-contextmenu");
57
- }, _ = () => {
58
- r || typeof window > "u" || typeof document > "u" || (r = !0, window.addEventListener("keydown", p, !0), document.addEventListener("pointerdown", h, !0), document.addEventListener("contextmenu", g, !0));
59
- }, v = () => {
60
- !r || n.length > 0 || typeof window > "u" || typeof document > "u" || (r = !1, window.removeEventListener("keydown", p, !0), document.removeEventListener("pointerdown", h, !0), document.removeEventListener("contextmenu", g, !0));
61
- }, y = () => {
62
- typeof document < "u" && (i === 0 && (a = document.body.style.overflow, document.body.style.overflow = "hidden"), i += 1);
63
- }, b = () => {
64
- typeof document < "u" && (i = Math.max(0, i - 1), i === 0 && (document.body.style.overflow = a));
65
- }, x = () => [...n].reverse().find((e) => e.modal), S = (e, t) => {
66
- let r = x();
67
- return r ? s(r, e) || n.some((t) => T(t, r) && s(t, e)) : t.contains(e);
68
- }, C = (e, n, r) => {
175
+ let n = o[t];
176
+ n && (o.slice(t + 1).some((e) => Q(e, n) && (e.blocksParentFocusTrap ?? !0)) || n.trapFocus?.(e));
177
+ }, V = (e, t) => {
178
+ let n = R(e);
179
+ if (!n) return;
180
+ let r = e.target;
181
+ if (r instanceof Node && x(n, r)) return;
182
+ let i = Y();
183
+ t === "outside-pointer" && i && r instanceof Node && !x(i, r) && !o.some((e) => Q(e, i) && x(e, r)) && e.preventDefault(), (n.dismissOnOutsidePointer?.() ?? !0) && n.requestDismiss(t, e);
184
+ }, H = (e) => {
185
+ V(e, "outside-pointer");
186
+ }, U = (e) => {
187
+ V(e, "outside-contextmenu");
188
+ }, W = () => {
189
+ typeof window > "u" || typeof document > "u" || c || (c = !0, document.addEventListener("focusin", P, !0), document.addEventListener("focusout", I, !0));
190
+ }, G = () => {
191
+ typeof window < "u" && typeof document < "u" && (s || (s = !0, window.addEventListener("keydown", B, !0), document.addEventListener("pointerdown", H, !0), document.addEventListener("contextmenu", U, !0)), W());
192
+ }, K = () => {
193
+ o.length > 0 || typeof window > "u" || typeof document > "u" || (s && (s = !1, window.removeEventListener("keydown", B, !0), document.removeEventListener("pointerdown", H, !0), document.removeEventListener("contextmenu", U, !0)), !(!c || f || h.size > 0) && (c = !1, document.removeEventListener("focusin", P, !0), document.removeEventListener("focusout", I, !0), p = null));
194
+ }, q = () => {
195
+ typeof document < "u" && (l === 0 && (u = document.body.style.overflow, document.body.style.overflow = "hidden"), l += 1);
196
+ }, J = () => {
197
+ typeof document < "u" && (l = Math.max(0, l - 1), l === 0 && (document.body.style.overflow = u));
198
+ }, Y = () => [...o].reverse().find((e) => e.modal), X = (e) => {
199
+ let t = e.nativeDialog;
200
+ if (!t) return;
201
+ let n = t.portal();
202
+ if (e.root() !== t.subject || !n?.isConnected || n.ownerDocument !== t.subject.ownerDocument || n.parentElement !== t.subject) throw TypeError("layerStack: viewport dialog requires its exact connected direct native portal");
203
+ e.nativeCycle?.refresh();
204
+ }, Z = (e, t) => {
205
+ let n = Y();
206
+ return n ? b(n, e) || o.some((t) => Q(t, n) && b(t, e)) : v(t, e);
207
+ }, ne = (e, t, r, i, o, s) => {
208
+ let c = {
209
+ entry: e,
210
+ activeAtClose: t,
211
+ revision: r,
212
+ focusRevision: i,
213
+ lostFocus: o,
214
+ retirementLoss: s
215
+ };
216
+ f = c;
217
+ for (let t of h) t.source === e && t.focusRevision === i && (t.pendingRestore = c);
69
218
  queueMicrotask(() => {
70
- if (o !== r) return;
71
- let i = document.activeElement, a = n instanceof HTMLElement && !n.isConnected && i === document.body;
72
- if (i !== n && !a) return;
73
- if (e.restoreTarget?.isConnected && t(e.restoreTarget)) {
74
- let t = f(e);
75
- if (S(e.restoreTarget, t)) {
76
- e.restoreTarget.focus({ preventScroll: !0 });
219
+ if (f === c) try {
220
+ if (f = null, d !== r || m !== i || o && !S(o)) return;
221
+ let l = n(), u = t instanceof HTMLElement && !t.isConnected && l === document.body, p = l === document.body && E(s);
222
+ if (l !== t && !u && !p) return;
223
+ if (e.restoreTarget?.isConnected && a(e.restoreTarget)) {
224
+ let t = z(e);
225
+ if (Z(e.restoreTarget, t)) {
226
+ j(c, e.restoreTarget);
227
+ return;
228
+ }
229
+ }
230
+ let h = z(e), g = [
231
+ Y()?.root(),
232
+ h,
233
+ L()?.root()
234
+ ];
235
+ for (let e of g) if (e instanceof HTMLElement && e.isConnected && a(e) && Z(e, h)) {
236
+ j(c, e);
77
237
  return;
78
238
  }
239
+ } finally {
240
+ K();
79
241
  }
80
- let s = f(e), c = x()?.root();
81
- c?.isConnected ? c.focus({ preventScroll: !0 }) : s instanceof HTMLElement && s.isConnected ? s.focus({ preventScroll: !0 }) : l()?.root()?.focus({ preventScroll: !0 });
82
242
  });
83
- }, w = (e, n) => {
84
- let r = document.activeElement, i = !1;
243
+ }, re = (e, t) => {
244
+ let n = document.activeElement, r = !1;
85
245
  return {
86
246
  cancel: () => {
87
- i = !0;
247
+ r = !0;
88
248
  },
89
249
  commit: (a) => {
90
250
  queueMicrotask(() => {
91
- if (i || o !== a || !e.isConnected || !t(e) || !(n instanceof Node) || !n.isConnected || !n.contains(e)) return;
92
- let s = document.activeElement, c = r instanceof HTMLElement && !r.isConnected && s === document.body;
93
- (s === r || c) && S(e, n) && e.focus({ preventScroll: !0 });
251
+ if (r || d !== a || !e.isConnected || !i(e) || !(t instanceof Node) || !t.isConnected || !t.contains(e)) return;
252
+ let o = document.activeElement, s = n instanceof HTMLElement && !n.isConnected && o === document.body;
253
+ (o === n || s) && Z(e, t) && e.focus({ preventScroll: !0 });
94
254
  });
95
255
  }
96
256
  };
97
- }, T = (e, t) => {
98
- let r = e.parentId;
99
- for (; r;) {
100
- if (r === t.id) return !0;
101
- r = n.find((e) => e.id === r)?.parentId ?? null;
257
+ }, Q = (e, t) => {
258
+ let n = e.parentId;
259
+ for (; n;) {
260
+ if (n === t.id) return !0;
261
+ n = o.find((e) => e.id === n)?.parentId ?? null;
102
262
  }
103
263
  return !1;
104
- }, E = (e) => {
264
+ }, $ = (e) => {
105
265
  if (!e.registered) return;
106
266
  e.focusHandoff?.cancel(), e.focusHandoff = null, e.registered = !1;
107
- let t = n.indexOf(e);
108
- t >= 0 && n.splice(t, 1), e.modal && b();
267
+ let t = o.indexOf(e);
268
+ t >= 0 && o.splice(t, 1), e.modal && J();
109
269
  };
110
- function D(t) {
111
- let r = l(), i = c(t), a = n.find((e) => e.id === i), u = t.kind === "dialog" || t.modal || r?.tier === "overlay" ? "overlay" : "floating", d = r && r.tier === u ? `calc(${r.zIndex} + var(--s-layer-overlay-step))` : u === "overlay" ? "var(--s-layer-root-overlay-backdrop)" : "var(--s-layer-root-floating)", p = {
270
+ function ie(t) {
271
+ let i = t.focusAdmission ? g.get(t.focusAdmission) : void 0;
272
+ if (t.focusAdmission && !i) throw TypeError("layerStack: focus admission must be captured by this owner");
273
+ if (i?.claimant) throw TypeError("layerStack: focus admission already belongs to another registration");
274
+ let s = L(), c = ee(t), l = o.find((e) => e.id === c), u = t.kind === "dialog" || t.modal || s?.tier === "overlay" ? "overlay" : "floating", _ = s && s.tier === u ? `calc(${s.zIndex} + var(--s-layer-overlay-step))` : u === "overlay" ? "var(--s-layer-root-overlay-backdrop)" : "var(--s-layer-root-floating)", x = {
112
275
  ...t,
113
276
  id: Symbol(t.kind),
114
- parentId: i,
115
- eventBoundary: t.eventBoundary ?? (t.modal ? void 0 : a?.eventBoundary),
277
+ parentId: c,
278
+ eventBoundary: t.eventBoundary ?? (t.modal ? void 0 : l?.eventBoundary),
116
279
  restoreTarget: t.restoreTarget ?? null,
117
280
  tier: u,
118
- zIndex: d,
281
+ zIndex: _,
119
282
  registered: !0,
120
- focusHandoff: null
283
+ focusHandoff: null,
284
+ nativeCycle: null
121
285
  };
122
- return n.push(p), o += 1, p.modal && y(), _(), {
123
- id: p.id,
124
- zIndex: p.zIndex,
125
- focusScope: () => f(p),
126
- isTopmost: () => p.registered && l() === p,
286
+ o.push(x), d += 1;
287
+ for (let e of h) e.encounters.add(x);
288
+ if (i && (i.claimant = x, A(i, x) || C(i)), f = null, x.modal && q(), G(), x.nativeDialog) try {
289
+ X(x), i?.active && !k(i) && C(i), x.nativeCycle = r(x.nativeDialog.subject, (e) => {
290
+ i?.active && i.target instanceof Element && n() === i.target && v(e.boundary, i.target) && (i.modalityLoss = {
291
+ target: i.target,
292
+ mutation: e
293
+ });
294
+ }, () => {
295
+ i && C(i);
296
+ });
297
+ } catch (e) {
298
+ throw $(x), i && C(i), K(), e;
299
+ }
300
+ let w = n();
301
+ return w && y(x, w) && N(w), {
302
+ id: x.id,
303
+ zIndex: x.zIndex,
304
+ focusScope: () => z(x),
305
+ isTopmost: () => x.registered && L() === x,
306
+ refreshModality: () => {
307
+ x.registered && X(x);
308
+ },
309
+ containsFocusTarget: (e) => x.registered && (b(x, e) || o.some((t) => t.registered && Q(t, x) && b(t, e))),
310
+ captureOwnedFocusLoss: (e) => {
311
+ let t = p;
312
+ if (!x.registered || !t || t.entry !== x || t.target !== e) return null;
313
+ let r = d, i = m;
314
+ return { isCurrentUnavailable: () => x.registered && d === r && m === i && p === t && n() === document.body && S(t) };
315
+ },
316
+ claimFocus: (e) => {
317
+ if (!i || !i.active) return !1;
318
+ if (i.claimant !== x) throw TypeError("layerStack: focus admission claimant does not match its registration");
319
+ return !x.registered || L() !== x || !A(i, x) || !e.isConnected || e.ownerDocument !== document || !y(x, e) || !Z(e, z(x)) || !a(e) || !k(i) ? (C(i), !1) : (C(i), e.focus({ preventScroll: !!x.eventBoundary }), n() === e);
320
+ },
127
321
  handoffFocus: (e) => {
128
- if (!p.registered) throw Error("layerStack: focus handoff requires a live registration");
129
- p.focusHandoff?.cancel();
130
- let t = w(e, f(p));
131
- return p.focusHandoff = t, t.cancel;
322
+ if (!x.registered) throw Error("layerStack: focus handoff requires a live registration");
323
+ x.focusHandoff?.cancel();
324
+ let t = re(e, z(x));
325
+ return x.focusHandoff = t, t.cancel;
132
326
  },
133
- unregister: ({ restoreFocus: t = !1, retireDescendants: r = !1, commitFocusHandoff: i = !1 } = {}) => {
134
- if (!p.registered) return;
135
- let a = i ? p.focusHandoff : null;
136
- a && (p.focusHandoff = null);
137
- let c = n.findIndex((e) => e.id === p.id), l = r ? n.filter((e) => T(e, p)) : [], u = typeof document < "u" ? document.activeElement : null, d = u instanceof Node && (s(p, u) || l.some((e) => s(e, u)));
327
+ unregister: ({ restoreFocus: t = !1, retireDescendants: r = !1, commitFocusHandoff: a = !1 } = {}) => {
328
+ if (!x.registered) return;
329
+ let s = a ? x.focusHandoff : null;
330
+ s && (x.focusHandoff = null);
331
+ let c = o.findIndex((e) => e.id === x.id), l = r ? o.filter((e) => Q(e, x)) : [], u = [x, ...l];
332
+ p?.settling && u.some((e) => e.nativeCycle !== null) && u.some((e) => e.id === p?.entry.id) && F(p);
333
+ let g = f, _ = g?.entry.restoreTarget, v = g?.revision === d && g.focusRevision === m && _ != null && [x, ...l].some((e) => y(e, _)) ? g : null;
334
+ f = null;
335
+ let w = n(), T = w instanceof Node && (b(x, w) || l.some((e) => b(e, w))), E = typeof document < "u" && w === document.body && p !== null && [x, ...l].some((e) => e.id === p?.entry.id) && (S(p) || p.settling) ? p : null, D = v?.focusRevision ?? m, O = i?.active === !0 && i.claimant === x && A(i, x) && k(i);
138
336
  if (c >= 0) {
139
- let e = p.root();
140
- for (let t of n.slice(c + 1)) t.parentId === p.id && (t.parentId = p.parentId), e?.contains(t.restoreTarget) && (t.restoreTarget = p.restoreTarget);
141
- for (let e of [...l].reverse()) E(e);
142
- E(p);
337
+ let e = x.root();
338
+ for (let t of o.slice(c + 1)) t.parentId === x.id && (t.parentId = x.parentId), e?.contains(t.restoreTarget) && (t.restoreTarget = x.restoreTarget);
339
+ for (let e of [...l].reverse()) $(e);
340
+ $(x);
341
+ }
342
+ d += 1;
343
+ let j = d, M = null, N = [];
344
+ for (let e of [...l].reverse().concat(x)) try {
345
+ e.nativeCycle?.close((t) => {
346
+ T && w instanceof Element && y(e, w) && (M = {
347
+ target: w,
348
+ mutation: t
349
+ });
350
+ });
351
+ } catch (e) {
352
+ N.push(e);
143
353
  }
144
- o += 1;
145
- let f = o;
146
- v();
147
- let m = [];
354
+ for (let e of [...h]) (e.claimant === x || e.source !== x || !t || l.length > 0) && C(e);
148
355
  for (let e of [...l].reverse()) try {
149
356
  e.onRetire?.();
150
357
  } catch (e) {
151
- m.push(e);
358
+ N.push(e);
152
359
  }
153
- if (a && m.length === 0 ? a.commit(f) : a?.cancel(), !a && t && d && C(p, u, f), m.length > 0) throw e(m, "layerStack: owner retirement failed");
360
+ if (s && N.length === 0 ? s.commit(j) : s?.cancel(), !s && t && N.length === 0 && d === j && (T || E || v || O) && ne(x, v ? v.activeAtClose : w, j, D, v?.lostFocus ?? E, v?.retirementLoss ?? M), K(), N.length > 0) throw e(N, "layerStack: owner retirement failed");
154
361
  }
155
362
  };
156
363
  }
157
364
  //#endregion
158
- export { D as registerLayer };
365
+ export { M as captureLayerFocusAdmission, ie as registerLayer };
@@ -0,0 +1,4 @@
1
+ /** Reads actual native focus owners through exposed shadow-root focus chains without eligibility or modality policy. */
2
+ export declare const nativeFocusChain: () => Element[];
3
+ /** Returns the exposed native leaf, retaining opaque shadow hosts as the actual observable boundary. */
4
+ export declare const nativeFocusedElement: () => Element | null;
@@ -0,0 +1,12 @@
1
+ //#region src/internal/nativeFocus.ts
2
+ var e = () => {
3
+ if (typeof document > "u") return [];
4
+ let e = [], t = document.activeElement;
5
+ for (; t;) e.push(t), t = t.shadowRoot?.activeElement ?? null;
6
+ return e;
7
+ }, t = () => {
8
+ let t = e();
9
+ return t[t.length - 1] ?? null;
10
+ };
11
+ //#endregion
12
+ export { e as nativeFocusChain, t as nativeFocusedElement };
@@ -0,0 +1,17 @@
1
+ import { ComputedRef, Ref } from 'vue';
2
+ /** Exact native dialog portal ownership; initial focus admission does not control this lifetime. */
3
+ export interface OverlayPortalContext {
4
+ readonly scope: Readonly<Ref<'document' | 'native'>>;
5
+ readonly subject: Readonly<Ref<HTMLDialogElement | null>>;
6
+ readonly target: Readonly<Ref<HTMLElement | null>>;
7
+ readonly admitted: Readonly<Ref<boolean>>;
8
+ }
9
+ /** Provides one viewport cycle; contained owners preserve the inherited viewport context. */
10
+ export declare function provideOverlayPortal(context: OverlayPortalContext): void;
11
+ /** Returns the logical native owner, or undefined for an unscoped document surface. */
12
+ export declare function useOverlayPortal(): OverlayPortalContext | undefined;
13
+ /**
14
+ * Unscoped layers use body. Scoped pending/retired layers have no target; a connected
15
+ * portal outside its exact same-document native subject is a contract error.
16
+ */
17
+ export declare function useOverlayPortalTarget(): ComputedRef<HTMLElement | 'body' | null>;
@@ -0,0 +1,23 @@
1
+ import { flatTreeContains as e } from "./flatTree.js";
2
+ import { computed as t, inject as n, provide as r } from "vue";
3
+ //#region src/internal/overlayPortal.ts
4
+ var i = Symbol("ui-kit-overlay-portal");
5
+ function a(e) {
6
+ r(i, e);
7
+ }
8
+ function o() {
9
+ return n(i, void 0);
10
+ }
11
+ function s() {
12
+ let n = o();
13
+ return t(() => {
14
+ if (!n || n.scope.value === "document") return "body";
15
+ if (!n.admitted.value) return null;
16
+ let t = n.subject.value, r = n.target.value;
17
+ if (!t || !r || !t.isConnected || !r.isConnected) return null;
18
+ if (t.ownerDocument !== r.ownerDocument || !e(t, r)) throw TypeError("ui-kit overlay portal: connected target must belong to its exact same-document native dialog");
19
+ return t.open ? r : null;
20
+ });
21
+ }
22
+ //#endregion
23
+ export { a as provideOverlayPortal, o as useOverlayPortal, s as useOverlayPortalTarget };
@@ -1,5 +1,5 @@
1
1
  declare const SCROLLABLE_VIEWPORT_MAX_BLOCK_SIZES: readonly ["none", "sm", "md", "lg"];
2
- declare const SCROLL_VIEWPORT_BLOCK_SIZES: readonly ["sm", "md", "lg", "fill"];
2
+ declare const SCROLL_VIEWPORT_BLOCK_SIZES: readonly ["sm", "md", "lg", "fill", "content"];
3
3
  declare const EXPANDED_CONTENT_MAX_BLOCK_SIZES: readonly ["sm", "md", "lg"];
4
4
  declare const TABLE_COLUMN_INLINE_SIZES: readonly ["auto", "content", "2xs", "xs", "sm", "md", "lg", "xl", "fill"];
5
5
  declare const TABLE_COLUMN_MIN_INLINE_SIZES: readonly ["2xs", "xs", "sm", "md", "lg", "xl"];
@@ -8,7 +8,7 @@ declare const TABLE_COLUMN_MIN_INLINE_SIZES: readonly ["2xs", "xs", "sm", "md",
8
8
  * Maximum block size for a scroll viewport; none preserves natural flow.
9
9
  */
10
10
  export type ScrollableViewportMaxBlockSize = typeof SCROLLABLE_VIEWPORT_MAX_BLOCK_SIZES[number];
11
- /** Фиксированная semantic block-size рабочей scroll-области. / Fixed semantic block size of a scroll workspace. */
11
+ /** Semantic block-size scroll-области; content сохраняет естественный flow. / Semantic scroll size; content preserves natural flow. */
12
12
  export type ScrollViewportBlockSize = typeof SCROLL_VIEWPORT_BLOCK_SIZES[number];
13
13
  /**
14
14
  * Максимальный block-size раскрытого текстового content region.
@@ -9,7 +9,8 @@ var t = [
9
9
  "sm",
10
10
  "md",
11
11
  "lg",
12
- "fill"
12
+ "fill",
13
+ "content"
13
14
  ], r = [
14
15
  "sm",
15
16
  "md",
@@ -18,6 +18,7 @@ export declare function useMenuLayer(layerApiRef: Ref<SMenuLayerApi | null>, opt
18
18
  onRetire?: () => void;
19
19
  }): {
20
20
  isOpen: Ref<boolean, boolean>;
21
+ portalTarget: import('vue').ComputedRef<HTMLElement | "body" | null>;
21
22
  position: Ref<import('../composables/useFloatingPosition').FloatingCoordinates, import('../composables/useFloatingPosition').FloatingCoordinates>;
22
23
  availableSize: Ref<import('../composables/useFloatingPosition').FloatingAvailableSize | null, import('../composables/useFloatingPosition').FloatingAvailableSize | null>;
23
24
  zIndex: Ref<string, string>;