@ryuzaki13/react-foundation-lib 2.6.0 → 2.7.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.
@@ -100,7 +100,7 @@ function p({ active: n, onDismiss: r, enabled: i = !0, documentTarget: a, contai
100
100
  }
101
101
  //#endregion
102
102
  //#region src/dom/useOverlayFocus.ts
103
- var m = "button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"]):not([disabled])";
103
+ var m = "button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [contenteditable=\"true\"]:not([tabindex=\"-1\"]), [contenteditable=\"\"]:not([tabindex=\"-1\"]), [tabindex]:not([tabindex=\"-1\"]):not([disabled])";
104
104
  function h({ active: n, trapFocus: i = !1, restoreFocus: a = !0, initialFocus: o = "auto", restoreFocusTarget: s, containerRef: c }) {
105
105
  let l = r(null), u = c ?? l, d = r(null), f = t((e) => Array.from(e.querySelectorAll(m)).filter((e) => !e.hasAttribute("aria-hidden"))), p = t((e) => {
106
106
  if (o === "container") return e;
@@ -180,8 +180,136 @@ var v = () => {
180
180
  window.removeEventListener("resize", e);
181
181
  };
182
182
  }, []), t;
183
- };
183
+ }, y = /* @__PURE__ */ new WeakMap();
184
+ function b(e, t) {
185
+ return t.map((t) => ({
186
+ name: t,
187
+ value: e.getPropertyValue(t),
188
+ priority: e.getPropertyPriority(t)
189
+ }));
190
+ }
191
+ function x(e, t) {
192
+ for (let { name: n } of t) e.removeProperty(n);
193
+ for (let { name: n, value: r, priority: i } of t) r && e.setProperty(n, r, i);
194
+ }
195
+ function S(e, t) {
196
+ let n = e.defaultView, r = e.body;
197
+ if (!n || !r) return () => void 0;
198
+ let i = y.get(e);
199
+ if (!i) {
200
+ let t = e.documentElement.style, a = r.style, o = b(t, [
201
+ "overflow",
202
+ "overflow-x",
203
+ "overflow-y"
204
+ ]), s = b(a, [
205
+ "position",
206
+ "top",
207
+ "left",
208
+ "width",
209
+ "overflow",
210
+ "overflow-x",
211
+ "overflow-y",
212
+ "box-sizing",
213
+ "padding-right"
214
+ ]), c = b(a, ["padding-right"]), l = n.scrollX, u = n.scrollY, d = Math.max(0, n.innerWidth - e.documentElement.clientWidth), f = Number.parseFloat(n.getComputedStyle(r).paddingRight) || 0, p = /* @__PURE__ */ new Map();
215
+ t.setProperty("overflow", "hidden"), a.setProperty("position", "fixed"), a.setProperty("top", `${-u}px`), a.setProperty("left", `${-l}px`), a.setProperty("width", "100%"), a.setProperty("overflow", "hidden"), a.setProperty("box-sizing", "border-box"), i = {
216
+ leases: p,
217
+ updateCompensation: () => {
218
+ d > 0 && [...p.values()].some(Boolean) ? a.setProperty("padding-right", `${f + d}px`) : x(a, c);
219
+ },
220
+ restore: () => {
221
+ x(t, o), x(a, s), n.scrollTo({
222
+ left: l,
223
+ top: u,
224
+ behavior: "instant"
225
+ });
226
+ }
227
+ }, y.set(e, i);
228
+ }
229
+ let a = Symbol();
230
+ return i.leases.set(a, t), i.updateCompensation(), () => {
231
+ i.leases.delete(a) && (i.leases.size > 0 ? i.updateCompensation() : (y.delete(e), i.restore()));
232
+ };
233
+ }
234
+ //#endregion
235
+ //#region src/dom/useDocumentScrollLock.ts
236
+ function C({ active: t, documentTarget: n, compensateScrollbar: r = !1 }) {
237
+ e(() => {
238
+ if (!t) return;
239
+ let e = n === void 0 ? typeof document > "u" ? null : document : n;
240
+ if (e) return S(e, r);
241
+ }, [
242
+ t,
243
+ n,
244
+ r
245
+ ]);
246
+ }
247
+ //#endregion
248
+ //#region src/dom/visual-viewport/attachVisualViewportFrame.ts
249
+ var w = [
250
+ "--visual-viewport-top",
251
+ "--visual-viewport-left",
252
+ "--visual-viewport-width",
253
+ "--visual-viewport-height"
254
+ ], T = /* @__PURE__ */ new WeakMap();
255
+ function E(e) {
256
+ let t = e.ownerDocument.defaultView;
257
+ if (!t) return () => void 0;
258
+ let n = t.visualViewport, r = e.style, i = w.map((e) => ({
259
+ name: e,
260
+ value: r.getPropertyValue(e),
261
+ priority: r.getPropertyPriority(e)
262
+ })), a = /* @__PURE__ */ new Map(), o = 0, s = () => {
263
+ o = 0;
264
+ let e = [
265
+ n?.offsetTop ?? 0,
266
+ n?.offsetLeft ?? 0,
267
+ n?.width ?? t.innerWidth,
268
+ n?.height ?? t.innerHeight
269
+ ], i = [
270
+ 0,
271
+ 0,
272
+ t.innerWidth,
273
+ t.innerHeight
274
+ ];
275
+ w.forEach((t, n) => {
276
+ let o = `${Number.isFinite(e[n]) ? e[n] : i[n]}px`;
277
+ a.get(t) !== o && (r.setProperty(t, o), a.set(t, o));
278
+ });
279
+ }, c = () => {
280
+ o ||= t.requestAnimationFrame(s);
281
+ };
282
+ return s(), n?.addEventListener("resize", c), n?.addEventListener("scroll", c), t.addEventListener("resize", c), () => {
283
+ t.cancelAnimationFrame(o), n?.removeEventListener("resize", c), n?.removeEventListener("scroll", c), t.removeEventListener("resize", c);
284
+ for (let { name: e, value: t, priority: n } of i) r.getPropertyValue(e) !== a.get(e) || r.getPropertyPriority(e) || (t ? r.setProperty(e, t, n) : r.removeProperty(e));
285
+ };
286
+ }
287
+ function D(e) {
288
+ let t = T.get(e);
289
+ t || (t = {
290
+ leases: /* @__PURE__ */ new Set(),
291
+ detach: E(e)
292
+ }, T.set(e, t));
293
+ let n = Symbol();
294
+ return t.leases.add(n), () => {
295
+ !t.leases.delete(n) || t.leases.size > 0 || (T.delete(e), t.detach());
296
+ };
297
+ }
298
+ //#endregion
299
+ //#region src/dom/useVisualViewportFrame.ts
300
+ function O({ active: t, containerRef: n }) {
301
+ e(() => {
302
+ if (!t || typeof window > "u") return;
303
+ let e = 0, r, i = () => {
304
+ let t = n.current;
305
+ t ? r = D(t) : e = window.requestAnimationFrame(i);
306
+ };
307
+ return i(), () => {
308
+ window.cancelAnimationFrame(e), r?.();
309
+ };
310
+ }, [t, n]);
311
+ }
184
312
  //#endregion
185
- export { p as a, u as c, s as d, a as f, h as i, c as l, _ as n, f as o, g as r, d as s, v as t, o as u };
313
+ export { g as a, f as c, c as d, o as f, _ as i, d as l, a as m, C as n, h as o, s as p, v as r, p as s, O as t, u };
186
314
 
187
- //# sourceMappingURL=dom-RMvZy-Sx.js.map
315
+ //# sourceMappingURL=dom-Bin1L9-q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-Bin1L9-q.js","names":[],"sources":["../../src/dom/downloadFile.ts","../../src/dom/getOrCreatePortalRoot.ts","../../src/dom/scroll-anchor/captureScrollAnchor.ts","../../src/dom/useClickOutside.ts","../../src/dom/useElementHeightObserver.ts","../../src/dom/useEscapeDismiss.ts","../../src/dom/useOverlayFocus.ts","../../src/dom/useFocusTrap.ts","../../src/dom/useIntersectionObserver.ts","../../src/dom/useIsTouchDevice.ts","../../src/dom/document-scroll/acquireDocumentScrollLock.ts","../../src/dom/useDocumentScrollLock.ts","../../src/dom/visual-viewport/attachVisualViewportFrame.ts","../../src/dom/useVisualViewportFrame.ts"],"sourcesContent":["export function downloadFileFromObjectURL(filename: string, objectUrl: string) {\n\tconst link = document.createElement(\"a\");\n\n\tlink.href = objectUrl;\n\tlink.download = filename;\n\tlink.click();\n\n\twindow.setTimeout(() => {\n\t\twindow.URL.revokeObjectURL(objectUrl);\n\t}, 0);\n}\n\nexport function downloadFileFromBlob(filename: string, blob: Blob) {\n\tconst objectUrl = window.URL.createObjectURL(blob);\n\tdownloadFileFromObjectURL(filename, objectUrl);\n}\n\nexport function downloadFileFromJson(filename: string, payload: unknown) {\n\tconst blob = new Blob([JSON.stringify(payload, null, 2)], { type: \"application/json;charset=utf-8\" });\n\tdownloadFileFromBlob(filename, blob);\n}\n","export function getOrCreatePortalRoot(id: string): HTMLElement | null {\n\tif (typeof document === \"undefined\") {\n\t\treturn null;\n\t}\n\n\tconst existingElement = document.getElementById(id);\n\tif (existingElement instanceof HTMLElement) {\n\t\treturn existingElement;\n\t}\n\n\tconst portalRoot = document.createElement(\"div\");\n\tportalRoot.id = id;\n\tdocument.body.append(portalRoot);\n\n\treturn portalRoot;\n}\n","import { type CapturedScrollAnchor } from \"./scrollAnchorTypes\";\n\n// Один scroll host не может одновременно компенсировать один и тот же prepend дважды.\nconst activeAnchors = new WeakMap<HTMLElement, CapturedScrollAnchor>();\n\n/**\n * Захватывает позицию сохраняемого элемента перед изменением обычного вертикального списка.\n * Вызывать только на browser event/effect boundary; restore — после DOM commit, release — при отмене.\n * Новый захват того же viewport завершает предыдущий без прокрутки.\n */\nexport function captureScrollAnchor(viewport: HTMLElement | null, anchor: HTMLElement | null): CapturedScrollAnchor | null {\n\tif (!viewport?.isConnected || !anchor?.isConnected || viewport === anchor || !viewport.contains(anchor)) return null;\n\n\tactiveAnchors.get(viewport)?.release();\n\tconst initialOffset =\n\t\tanchor.getBoundingClientRect().top - viewport.getBoundingClientRect().top - viewport.clientTop + viewport.scrollTop;\n\tconst initialStyle = viewport.style.getPropertyValue(\"overflow-anchor\");\n\tconst initialPriority = viewport.style.getPropertyPriority(\"overflow-anchor\");\n\tlet active = true;\n\n\t// Native anchoring иначе успеет компенсировать prepend до restore и приведёт к двойному сдвигу.\n\tviewport.style.setProperty(\"overflow-anchor\", \"none\", \"important\");\n\t// В браузере без этого CSS-свойства native anchoring тоже отсутствует: сравниваем фактически принятый стиль.\n\tconst ownedStyle = viewport.style.getPropertyValue(\"overflow-anchor\");\n\tconst ownedPriority = viewport.style.getPropertyPriority(\"overflow-anchor\");\n\tconst ownsStyle = () =>\n\t\tviewport.style.getPropertyValue(\"overflow-anchor\") === ownedStyle &&\n\t\tviewport.style.getPropertyPriority(\"overflow-anchor\") === ownedPriority;\n\n\tconst operation: CapturedScrollAnchor = {\n\t\trelease() {\n\t\t\tif (!active) return;\n\t\t\tactive = false;\n\t\t\tactiveAnchors.delete(viewport);\n\t\t\t// Не затираем новое решение host, если он сам изменил свойство во время ожидания.\n\t\t\tif (!ownsStyle()) return;\n\t\t\tif (initialStyle) viewport.style.setProperty(\"overflow-anchor\", initialStyle, initialPriority);\n\t\t\telse viewport.style.removeProperty(\"overflow-anchor\");\n\t\t},\n\t\trestore() {\n\t\t\tif (!active) return false;\n\t\t\ttry {\n\t\t\t\tif (!viewport.isConnected || !anchor.isConnected || !viewport.contains(anchor) || !ownsStyle()) return false;\n\t\t\t\tconst currentOffset =\n\t\t\t\t\tanchor.getBoundingClientRect().top - viewport.getBoundingClientRect().top - viewport.clientTop + viewport.scrollTop;\n\t\t\t\tconst delta = currentOffset - initialOffset;\n\t\t\t\t// Content-space delta не отменяет ручную прокрутку между запросом и commit.\n\t\t\t\t// Instant не наследует CSS smooth; горизонтальная позиция остаётся неизменной.\n\t\t\t\tif (delta !== 0) viewport.scrollBy({ top: delta, behavior: \"instant\" });\n\t\t\t\treturn true;\n\t\t\t} finally {\n\t\t\t\toperation.release();\n\t\t\t}\n\t\t}\n\t};\n\tactiveAnchors.set(viewport, operation);\n\treturn operation;\n}\n","import { RefObject, useEffect } from \"react\";\n\nexport function useClickOutside(ref: RefObject<HTMLElement | null> | RefObject<HTMLElement | null>[], handler: () => void) {\n\tuseEffect(() => {\n\t\tconst handleClickOutside = (event: MouseEvent) => {\n\t\t\tif (Array.isArray(ref)) {\n\t\t\t\tlet isOutside = true;\n\t\t\t\tfor (const r of ref) {\n\t\t\t\t\tif (r.current && r.current.contains(event.target as Node)) {\n\t\t\t\t\t\tisOutside = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (isOutside) {\n\t\t\t\t\thandler();\n\t\t\t\t}\n\t\t\t} else if (ref.current && !ref.current.contains(event.target as Node)) {\n\t\t\t\thandler();\n\t\t\t}\n\t\t};\n\n\t\tdocument.addEventListener(\"mousedown\", handleClickOutside);\n\t\treturn () => document.removeEventListener(\"mousedown\", handleClickOutside);\n\t}, [ref, handler]);\n}\n","import { type RefObject, useLayoutEffect, useState } from \"react\";\n\nexport function useElementHeightObserver<TElement extends HTMLElement>(elementRef: RefObject<TElement | null>) {\n\tconst [height, setHeight] = useState(0);\n\n\tuseLayoutEffect(() => {\n\t\tconst element = elementRef.current;\n\t\tif (!element) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst observer = new ResizeObserver((entries) => {\n\t\t\tconst nextHeight = entries[0]?.contentRect.height ?? element.getBoundingClientRect().height;\n\t\t\tsetHeight(nextHeight);\n\t\t});\n\t\tobserver.observe(element);\n\n\t\treturn () => observer.disconnect();\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps, react-hooks/refs\n\t}, [elementRef.current]);\n\n\treturn height;\n}\n","import { RefObject, useEffect, useEffectEvent } from \"react\";\n\ninterface UseEscapeDismissOptions {\n\tactive: boolean;\n\tonDismiss: () => void;\n\tenabled?: boolean;\n\tdocumentTarget?: Document | null;\n\tcontainerRef?: RefObject<HTMLElement | null>;\n}\n\n/**\n * Подписывает overlay на закрытие по клавише Escape.\n */\nexport function useEscapeDismiss({ active, onDismiss, enabled = true, documentTarget, containerRef }: UseEscapeDismissOptions) {\n\tconst dismiss = useEffectEvent(() => onDismiss());\n\n\tuseEffect(() => {\n\t\tif (!active || !enabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst targetDocument = documentTarget ?? (typeof document === \"undefined\" ? null : document);\n\t\tif (!targetDocument) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst handleKeyDown = (event: KeyboardEvent) => {\n\t\t\tif (event.key !== \"Escape\" /*|| event.defaultPrevented*/) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst activeElement = targetDocument.activeElement;\n\t\t\tconst container = containerRef?.current;\n\t\t\tif (container && activeElement instanceof Node && activeElement !== container && !container.contains(activeElement)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t\tdismiss();\n\t\t};\n\n\t\ttargetDocument.addEventListener(\"keydown\", handleKeyDown, true);\n\t\treturn () => targetDocument.removeEventListener(\"keydown\", handleKeyDown, true);\n\t}, [active, enabled, documentTarget, containerRef]);\n}\n","import { RefObject, useEffect, useEffectEvent, useRef } from \"react\";\n\nconst focusableElementsSelector =\n\t'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [contenteditable=\"true\"]:not([tabindex=\"-1\"]), [contenteditable=\"\"]:not([tabindex=\"-1\"]), [tabindex]:not([tabindex=\"-1\"]):not([disabled])';\n\nexport interface UseOverlayFocusOptions<T extends HTMLElement> {\n\tactive: boolean;\n\ttrapFocus?: boolean;\n\trestoreFocus?: boolean;\n\tinitialFocus?: \"auto\" | \"container\" | ((container: T) => HTMLElement | null | undefined);\n\trestoreFocusTarget?: () => HTMLElement | null | undefined;\n\tcontainerRef?: RefObject<T | null>;\n}\n\n/**\n * Возвращает ref overlay-контейнера и управляет начальными/возвратными переходами фокуса.\n * Открытие и закрытие не прокручивают документ: портал может получить фокус\n * до завершения позиционирования. Пользовательский Tab по-прежнему раскрывает\n * выбранный элемент в прокручиваемом содержимом overlay.\n */\nexport function useOverlayFocus<T extends HTMLElement>({\n\tactive,\n\ttrapFocus = false,\n\trestoreFocus = true,\n\tinitialFocus = \"auto\",\n\trestoreFocusTarget,\n\tcontainerRef\n}: UseOverlayFocusOptions<T>) {\n\tconst internalOverlayRef = useRef<T | null>(null);\n\tconst overlayRef = containerRef ?? internalOverlayRef;\n\tconst previousActiveElementRef = useRef<HTMLElement | null>(null);\n\n\t/**\n\t * Собирает фокусируемые элементы overlay в актуальном DOM-порядке.\n\t */\n\tconst getFocusableElements = useEffectEvent((container: T) =>\n\t\tArray.from(container.querySelectorAll<HTMLElement>(focusableElementsSelector)).filter(\n\t\t\t(element) => !element.hasAttribute(\"aria-hidden\")\n\t\t)\n\t);\n\n\t/**\n\t * Вычисляет стартовый фокус при открытии overlay.\n\t */\n\tconst resolveInitialFocus = useEffectEvent((container: T) => {\n\t\tif (initialFocus === \"container\") {\n\t\t\treturn container;\n\t\t}\n\n\t\tif (typeof initialFocus === \"function\") {\n\t\t\treturn initialFocus(container) ?? container;\n\t\t}\n\n\t\tconst focusableElements = getFocusableElements(container);\n\t\treturn (\n\t\t\tfocusableElements.find((element) => element.hasAttribute(\"autofocus\") || element.hasAttribute(\"autoFocus\")) ??\n\t\t\tfocusableElements[0] ??\n\t\t\tcontainer\n\t\t);\n\t});\n\n\t/**\n\t * Вычисляет элемент, которому нужно вернуть фокус после закрытия overlay.\n\t */\n\tconst resolveRestoreFocusTarget = useEffectEvent(() => restoreFocusTarget?.() ?? previousActiveElementRef.current);\n\n\tuseEffect(() => {\n\t\tif (!active) {\n\t\t\treturn;\n\t\t}\n\n\t\tpreviousActiveElementRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n\t\tlet overlayElement: T | null = null;\n\t\tlet rafId = 0;\n\n\t\t/**\n\t\t * Цикл откладывает инициализацию, пока ref контейнера не будет привязан к DOM.\n\t\t */\n\t\tconst attachOverlay = () => {\n\t\t\toverlayElement = overlayRef.current;\n\t\t\tif (!overlayElement) {\n\t\t\t\trafId = window.requestAnimationFrame(attachOverlay);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst focusTarget = resolveInitialFocus(overlayElement);\n\t\t\tif (focusTarget instanceof HTMLElement && focusTarget.isConnected) {\n\t\t\t\tfocusTarget.focus({ preventScroll: true });\n\t\t\t}\n\n\t\t\tif (trapFocus) {\n\t\t\t\toverlayElement.addEventListener(\"keydown\", handleTabKey);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * Зацикливает Tab внутри overlay, пока он открыт как модальный слой.\n\t\t */\n\t\tconst handleTabKey = (event: KeyboardEvent) => {\n\t\t\tif (!trapFocus || event.key !== \"Tab\" || !overlayElement) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst focusableElements = getFocusableElements(overlayElement);\n\t\t\tif (focusableElements.length === 0) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\toverlayElement.focus();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst firstElement = focusableElements[0];\n\t\t\tconst lastElement = focusableElements[focusableElements.length - 1];\n\t\t\tconst activeElement = document.activeElement;\n\n\t\t\tif (event.shiftKey) {\n\t\t\t\tif (activeElement === firstElement || activeElement === overlayElement) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tlastElement.focus();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (activeElement === lastElement) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tfirstElement.focus();\n\t\t\t}\n\t\t};\n\n\t\tattachOverlay();\n\n\t\treturn () => {\n\t\t\twindow.cancelAnimationFrame(rafId);\n\t\t\tif (trapFocus && overlayElement) {\n\t\t\t\toverlayElement.removeEventListener(\"keydown\", handleTabKey);\n\t\t\t}\n\n\t\t\tif (!restoreFocus) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst restoreTarget = resolveRestoreFocusTarget();\n\t\t\tif (restoreTarget?.isConnected) {\n\t\t\t\trestoreTarget.focus({ preventScroll: true });\n\t\t\t}\n\t\t};\n\t}, [active, trapFocus, restoreFocus, overlayRef]);\n\n\treturn overlayRef;\n}\n","import { useOverlayFocus } from \"./useOverlayFocus\";\n\n/**\n * Совместимый wrapper для overlay с фокус-ловушкой.\n */\nexport const useFocusTrap = (isOpen: boolean) => {\n\treturn useOverlayFocus<HTMLDivElement>({ active: isOpen, trapFocus: true, restoreFocus: true, initialFocus: \"auto\" });\n};\n","import { useEffect, useState } from \"react\";\n\nexport function useIntersectionObserver(ref: React.RefObject<Element | null>, options?: IntersectionObserverInit) {\n\tconst [isIntersecting, setIsIntersecting] = useState(false);\n\n\tuseEffect(() => {\n\t\tconst el = ref.current;\n\t\tif (!el) return;\n\n\t\tconst observer = new IntersectionObserver(([entry]) => {\n\t\t\tsetIsIntersecting(entry.isIntersecting);\n\t\t}, options);\n\n\t\tobserver.observe(el);\n\n\t\treturn () => {\n\t\t\tif (el) {\n\t\t\t\tobserver.unobserve(el);\n\t\t\t}\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [options, ref]); // не забыть, что ref.current может меняться\n\n\treturn { isIntersecting };\n}\n","import { useEffect, useState } from \"react\";\n\nexport const useIsTouchDevice = () => {\n\tconst [isTouchDevice, setIsTouchDevice] = useState(false);\n\n\tuseEffect(() => {\n\t\tconst checkTouchDevice = () => {\n\t\t\tconst isTouch = window.matchMedia(\"(pointer: coarse)\").matches || \"ontouchstart\" in window || navigator.maxTouchPoints > 0;\n\t\t\tsetIsTouchDevice(isTouch);\n\t\t};\n\n\t\tcheckTouchDevice();\n\n\t\t// Обработчик для изменений в типе устройства\n\t\twindow.addEventListener(\"resize\", checkTouchDevice);\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"resize\", checkTouchDevice);\n\t\t};\n\t}, []);\n\n\treturn isTouchDevice;\n};\n","type InlineProperty = Readonly<{ name: string; value: string; priority: string }>;\n\ntype DocumentScrollLock = Readonly<{\n\tleases: Map<symbol, boolean>;\n\tupdateCompensation: () => void;\n\trestore: () => void;\n}>;\n\nconst locks = new WeakMap<Document, DocumentScrollLock>();\n\n/** Снимок ограничен принадлежащими lock свойствами, остальные inline-правки не затрагиваются. */\nfunction captureProperties(style: CSSStyleDeclaration, names: readonly string[]): readonly InlineProperty[] {\n\treturn names.map((name) => ({ name, value: style.getPropertyValue(name), priority: style.getPropertyPriority(name) }));\n}\n\nfunction restoreProperties(style: CSSStyleDeclaration, properties: readonly InlineProperty[]): void {\n\t// Сначала снимаем весь принадлежащий нам shorthand/longhand набор: иначе позднее\n\t// удаление пустого longhand может отменить только что восстановленный shorthand.\n\tfor (const { name } of properties) style.removeProperty(name);\n\tfor (const { name, value, priority } of properties) {\n\t\tif (value) style.setProperty(name, value, priority);\n\t}\n}\n\n/** Один владелец body/html на документ предотвращает преждевременный unlock вложенных overlays. */\nexport function acquireDocumentScrollLock(documentTarget: Document, compensateScrollbar: boolean): () => void {\n\tconst view = documentTarget.defaultView;\n\tconst body = documentTarget.body;\n\tif (!view || !body) return () => undefined;\n\n\tlet lock = locks.get(documentTarget);\n\tif (!lock) {\n\t\tconst rootStyle = documentTarget.documentElement.style;\n\t\tconst bodyStyle = body.style;\n\t\tconst rootProperties = captureProperties(rootStyle, [\"overflow\", \"overflow-x\", \"overflow-y\"]);\n\t\tconst bodyProperties = captureProperties(bodyStyle, [\n\t\t\t\"position\",\n\t\t\t\"top\",\n\t\t\t\"left\",\n\t\t\t\"width\",\n\t\t\t\"overflow\",\n\t\t\t\"overflow-x\",\n\t\t\t\"overflow-y\",\n\t\t\t\"box-sizing\",\n\t\t\t\"padding-right\"\n\t\t]);\n\t\tconst originalPadding = captureProperties(bodyStyle, [\"padding-right\"]);\n\t\tconst scrollX = view.scrollX;\n\t\tconst scrollY = view.scrollY;\n\t\tconst scrollbarWidth = Math.max(0, view.innerWidth - documentTarget.documentElement.clientWidth);\n\t\tconst computedPadding = Number.parseFloat(view.getComputedStyle(body).paddingRight) || 0;\n\t\tconst leases = new Map<symbol, boolean>();\n\n\t\t// Fixed body нужен и при iOS visual-viewport pan: одного overflow hidden недостаточно.\n\t\trootStyle.setProperty(\"overflow\", \"hidden\");\n\t\tbodyStyle.setProperty(\"position\", \"fixed\");\n\t\tbodyStyle.setProperty(\"top\", `${-scrollY}px`);\n\t\tbodyStyle.setProperty(\"left\", `${-scrollX}px`);\n\t\tbodyStyle.setProperty(\"width\", \"100%\");\n\t\tbodyStyle.setProperty(\"overflow\", \"hidden\");\n\t\tbodyStyle.setProperty(\"box-sizing\", \"border-box\");\n\n\t\tlock = {\n\t\t\tleases,\n\t\t\tupdateCompensation: () => {\n\t\t\t\tif (scrollbarWidth > 0 && [...leases.values()].some(Boolean)) {\n\t\t\t\t\tbodyStyle.setProperty(\"padding-right\", `${computedPadding + scrollbarWidth}px`);\n\t\t\t\t} else restoreProperties(bodyStyle, originalPadding);\n\t\t\t},\n\t\t\trestore: () => {\n\t\t\t\trestoreProperties(rootStyle, rootProperties);\n\t\t\t\trestoreProperties(bodyStyle, bodyProperties);\n\t\t\t\tview.scrollTo({ left: scrollX, top: scrollY, behavior: \"instant\" });\n\t\t\t}\n\t\t};\n\t\tlocks.set(documentTarget, lock);\n\t}\n\n\tconst lease = Symbol();\n\tlock.leases.set(lease, compensateScrollbar);\n\tlock.updateCompensation();\n\treturn () => {\n\t\tif (!lock.leases.delete(lease)) return;\n\t\tif (lock.leases.size > 0) lock.updateCompensation();\n\t\telse {\n\t\t\tlocks.delete(documentTarget);\n\t\t\tlock.restore();\n\t\t}\n\t};\n}\n","import { useEffect } from \"react\";\n\nimport { acquireDocumentScrollLock } from \"./document-scroll/acquireDocumentScrollLock\";\nimport { type UseDocumentScrollLockOptions } from \"./document-scroll/documentScrollLockTypes\";\n\n/** Блокирует фоновую прокрутку до освобождения последнего потребителя; не управляет focus/inert. */\nexport function useDocumentScrollLock({ active, documentTarget, compensateScrollbar = false }: UseDocumentScrollLockOptions): void {\n\tuseEffect(() => {\n\t\tif (!active) return;\n\t\tconst target = documentTarget === undefined ? (typeof document === \"undefined\" ? null : document) : documentTarget;\n\t\tif (!target) return;\n\t\treturn acquireDocumentScrollLock(target, compensateScrollbar);\n\t}, [active, documentTarget, compensateScrollbar]);\n}\n","const properties = [\"--visual-viewport-top\", \"--visual-viewport-left\", \"--visual-viewport-width\", \"--visual-viewport-height\"] as const;\n\nconst attachments = new WeakMap<HTMLElement, { leases: Set<symbol>; detach: () => void }>();\n\n/** Подписка меняет CSS-переменные конкретной поверхности, не вызывает React render на каждом pan. */\nfunction createVisualViewportFrame(container: HTMLElement): () => void {\n\tconst view = container.ownerDocument.defaultView;\n\tif (!view) return () => undefined;\n\tconst viewport = view.visualViewport;\n\tconst style = container.style;\n\tconst previous = properties.map((name) => ({ name, value: style.getPropertyValue(name), priority: style.getPropertyPriority(name) }));\n\tconst ownedValues = new Map<string, string>();\n\tlet frame = 0;\n\n\tconst update = (): void => {\n\t\tframe = 0;\n\t\tconst bounds = [\n\t\t\tviewport?.offsetTop ?? 0,\n\t\t\tviewport?.offsetLeft ?? 0,\n\t\t\tviewport?.width ?? view.innerWidth,\n\t\t\tviewport?.height ?? view.innerHeight\n\t\t];\n\t\tconst fallback = [0, 0, view.innerWidth, view.innerHeight];\n\t\tproperties.forEach((name, index) => {\n\t\t\tconst value = `${Number.isFinite(bounds[index]) ? bounds[index] : fallback[index]}px`;\n\t\t\tif (ownedValues.get(name) === value) return;\n\t\t\tstyle.setProperty(name, value);\n\t\t\townedValues.set(name, value);\n\t\t});\n\t};\n\n\tconst schedule = (): void => {\n\t\tif (!frame) frame = view.requestAnimationFrame(update);\n\t};\n\n\tupdate();\n\tviewport?.addEventListener(\"resize\", schedule);\n\tviewport?.addEventListener(\"scroll\", schedule);\n\tview.addEventListener(\"resize\", schedule);\n\treturn () => {\n\t\tview.cancelAnimationFrame(frame);\n\t\tviewport?.removeEventListener(\"resize\", schedule);\n\t\tviewport?.removeEventListener(\"scroll\", schedule);\n\t\tview.removeEventListener(\"resize\", schedule);\n\t\tfor (const { name, value, priority } of previous) {\n\t\t\t// Не затираем новое значение, если внешний owner уже забрал это CSS-свойство.\n\t\t\tif (style.getPropertyValue(name) !== ownedValues.get(name) || style.getPropertyPriority(name)) continue;\n\t\t\tif (value) style.setProperty(name, value, priority);\n\t\t\telse style.removeProperty(name);\n\t\t}\n\t};\n}\n\n/** Несколько модалок могут разделять portal-root; его frame снимается только последним owner. */\nexport function attachVisualViewportFrame(container: HTMLElement): () => void {\n\tlet attachment = attachments.get(container);\n\tif (!attachment) {\n\t\tattachment = { leases: new Set(), detach: createVisualViewportFrame(container) };\n\t\tattachments.set(container, attachment);\n\t}\n\tconst lease = Symbol();\n\tattachment.leases.add(lease);\n\treturn () => {\n\t\tif (!attachment.leases.delete(lease) || attachment.leases.size > 0) return;\n\t\tattachments.delete(container);\n\t\tattachment.detach();\n\t};\n}\n","import { useEffect } from \"react\";\n\nimport { attachVisualViewportFrame } from \"./visual-viewport/attachVisualViewportFrame\";\nimport { type UseVisualViewportFrameOptions } from \"./visual-viewport/visualViewportFrameTypes\";\n\n/** CSS frame использует реальные visualViewport размеры без отмены pinch zoom; SSR оставляет CSS fallback. */\nexport function useVisualViewportFrame({ active, containerRef }: UseVisualViewportFrameOptions): void {\n\tuseEffect(() => {\n\t\tif (!active || typeof window === \"undefined\") return;\n\t\tlet frame = 0;\n\t\tlet detach: (() => void) | undefined;\n\t\t// Portal может установить ref позже родительского effect; ожидание завершается при cleanup.\n\t\tconst attach = () => {\n\t\t\tconst container = containerRef.current;\n\t\t\tif (container) detach = attachVisualViewportFrame(container);\n\t\t\telse frame = window.requestAnimationFrame(attach);\n\t\t};\n\t\tattach();\n\t\treturn () => {\n\t\t\twindow.cancelAnimationFrame(frame);\n\t\t\tdetach?.();\n\t\t};\n\t}, [active, containerRef]);\n}\n"],"mappings":";;AAAA,SAAgB,EAA0B,GAAkB,GAAmB;CAC9E,IAAM,IAAO,SAAS,cAAc,GAAG;CAMvC,AAJA,EAAK,OAAO,GACZ,EAAK,WAAW,GAChB,EAAK,MAAM,GAEX,OAAO,iBAAiB;EACvB,OAAO,IAAI,gBAAgB,CAAS;CACrC,GAAG,CAAC;AACL;AAEA,SAAgB,EAAqB,GAAkB,GAAY;CAElE,EAA0B,GADR,OAAO,IAAI,gBAAgB,CACT,CAAS;AAC9C;AAEA,SAAgB,EAAqB,GAAkB,GAAkB;CAExE,EAAqB,GAAU,IADd,KAAK,CAAC,KAAK,UAAU,GAAS,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,iCAAiC,CACpE,CAAI;AACpC;;;ACpBA,SAAgB,EAAsB,GAAgC;CACrE,IAAI,OAAO,WAAa,KACvB,OAAO;CAGR,IAAM,IAAkB,SAAS,eAAe,CAAE;CAClD,IAAI,aAA2B,aAC9B,OAAO;CAGR,IAAM,IAAa,SAAS,cAAc,KAAK;CAI/C,OAHA,EAAW,KAAK,GAChB,SAAS,KAAK,OAAO,CAAU,GAExB;AACR;;;ACZA,IAAM,oBAAgB,IAAI,QAA2C;AAOrE,SAAgB,EAAoB,GAA8B,GAAyD;CAC1H,IAAI,CAAC,GAAU,eAAe,CAAC,GAAQ,eAAe,MAAa,KAAU,CA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Q,IAAI,IAAI;EAAG,QAAQ,EAA0B,CAAS;CAAE,GAC/E,EAAY,IAAI,GAAW,CAAU;CAEtC,IAAM,IAAQ,OAAO;CAErB,OADA,EAAW,OAAO,IAAI,CAAK,SACd;EACR,CAAC,EAAW,OAAO,OAAO,CAAK,KAAK,EAAW,OAAO,OAAO,MACjE,EAAY,OAAO,CAAS,GAC5B,EAAW,OAAO;CACnB;AACD;;;AC7DA,SAAgB,EAAuB,EAAE,WAAQ,mBAAqD;CACrG,QAAgB;EACf,IAAI,CAAC,KAAU,OAAO,SAAW,KAAa;EAC9C,IAAI,IAAQ,GACR,GAEE,UAAe;GACpB,IAAM,IAAY,EAAa;GAC/B,AAAI,IAAW,IAAS,EAA0B,CAAS,IACtD,IAAQ,OAAO,sBAAsB,CAAM;EACjD;EAEA,OADA,EAAO,SACM;GAEZ,AADA,OAAO,qBAAqB,CAAK,GACjC,IAAS;EACV;CACD,GAAG,CAAC,GAAQ,CAAY,CAAC;AAC1B"}
@@ -0,0 +1,3 @@
1
+ /** Один владелец body/html на документ предотвращает преждевременный unlock вложенных overlays. */
2
+ export declare function acquireDocumentScrollLock(documentTarget: Document, compensateScrollbar: boolean): () => void;
3
+ //# sourceMappingURL=acquireDocumentScrollLock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acquireDocumentScrollLock.d.ts","sourceRoot":"","sources":["../../../src/dom/document-scroll/acquireDocumentScrollLock.ts"],"names":[],"mappings":"AAwBA,mGAAmG;AACnG,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,QAAQ,EAAE,mBAAmB,EAAE,OAAO,GAAG,MAAM,IAAI,CAgE5G"}
@@ -0,0 +1,8 @@
1
+ /** Общая аренда блокировки документа; вложенные потребители освобождают только свою долю. */
2
+ export type UseDocumentScrollLockOptions = Readonly<{
3
+ active: boolean;
4
+ /** undefined выбирает глобальный document, null явно отключает DOM-операцию. */
5
+ documentTarget?: Document | null;
6
+ compensateScrollbar?: boolean;
7
+ }>;
8
+ //# sourceMappingURL=documentScrollLockTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentScrollLockTypes.d.ts","sourceRoot":"","sources":["../../../src/dom/document-scroll/documentScrollLockTypes.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CAAC;IACnD,MAAM,EAAE,OAAO,CAAC;IAChB,gFAAgF;IAChF,cAAc,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACjC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC,CAAC"}
@@ -9,4 +9,8 @@ export * from "./useFocusTrap";
9
9
  export * from "./useIntersectionObserver";
10
10
  export * from "./useIsTouchDevice";
11
11
  export * from "./useOverlayFocus";
12
+ export { useDocumentScrollLock } from "./useDocumentScrollLock";
13
+ export { type UseDocumentScrollLockOptions } from "./document-scroll/documentScrollLockTypes";
14
+ export { useVisualViewportFrame } from "./useVisualViewportFrame";
15
+ export { type UseVisualViewportFrameOptions } from "./visual-viewport/visualViewportFrameTypes";
12
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dom/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dom/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AAC9F,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,4CAA4C,CAAC"}
package/dist/dom/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "../chunks/dom-RMvZy-Sx.js";
2
- export { t as captureScrollAnchor, d as downloadFileFromBlob, n as downloadFileFromJson, r as downloadFileFromObjectURL, a as getOrCreatePortalRoot, l as useClickOutside, s as useElementHeightObserver, e as useEscapeDismiss, c as useFocusTrap, o as useIntersectionObserver, u as useIsTouchDevice, i as useOverlayFocus };
1
+ import { a as e, c as t, d as n, f as r, i, l as a, m as o, n as s, o as c, p as l, r as u, s as d, t as f, u as p } from "../chunks/dom-Bin1L9-q.js";
2
+ export { p as captureScrollAnchor, r as downloadFileFromBlob, l as downloadFileFromJson, o as downloadFileFromObjectURL, n as getOrCreatePortalRoot, a as useClickOutside, s as useDocumentScrollLock, t as useElementHeightObserver, d as useEscapeDismiss, e as useFocusTrap, i as useIntersectionObserver, u as useIsTouchDevice, c as useOverlayFocus, f as useVisualViewportFrame };
@@ -0,0 +1,4 @@
1
+ import { type UseDocumentScrollLockOptions } from "./document-scroll/documentScrollLockTypes";
2
+ /** Блокирует фоновую прокрутку до освобождения последнего потребителя; не управляет focus/inert. */
3
+ export declare function useDocumentScrollLock({ active, documentTarget, compensateScrollbar }: UseDocumentScrollLockOptions): void;
4
+ //# sourceMappingURL=useDocumentScrollLock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDocumentScrollLock.d.ts","sourceRoot":"","sources":["../../src/dom/useDocumentScrollLock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AAE9F,oGAAoG;AACpG,wBAAgB,qBAAqB,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,mBAA2B,EAAE,EAAE,4BAA4B,GAAG,IAAI,CAOjI"}
@@ -0,0 +1,4 @@
1
+ import { type UseVisualViewportFrameOptions } from "./visual-viewport/visualViewportFrameTypes";
2
+ /** CSS frame использует реальные visualViewport размеры без отмены pinch zoom; SSR оставляет CSS fallback. */
3
+ export declare function useVisualViewportFrame({ active, containerRef }: UseVisualViewportFrameOptions): void;
4
+ //# sourceMappingURL=useVisualViewportFrame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVisualViewportFrame.d.ts","sourceRoot":"","sources":["../../src/dom/useVisualViewportFrame.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAEhG,8GAA8G;AAC9G,wBAAgB,sBAAsB,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,6BAA6B,GAAG,IAAI,CAiBpG"}
@@ -0,0 +1,3 @@
1
+ /** Несколько модалок могут разделять portal-root; его frame снимается только последним owner. */
2
+ export declare function attachVisualViewportFrame(container: HTMLElement): () => void;
3
+ //# sourceMappingURL=attachVisualViewportFrame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachVisualViewportFrame.d.ts","sourceRoot":"","sources":["../../../src/dom/visual-viewport/attachVisualViewportFrame.ts"],"names":[],"mappings":"AAqDA,iGAAiG;AACjG,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,WAAW,GAAG,MAAM,IAAI,CAa5E"}
@@ -0,0 +1,7 @@
1
+ import { type RefObject } from "react";
2
+ /** Визуальная область браузера для CSS fixed-поверхности, включая экранную клавиатуру. */
3
+ export type UseVisualViewportFrameOptions = Readonly<{
4
+ active: boolean;
5
+ containerRef: RefObject<HTMLElement | null>;
6
+ }>;
7
+ //# sourceMappingURL=visualViewportFrameTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visualViewportFrameTypes.d.ts","sourceRoot":"","sources":["../../../src/dom/visual-viewport/visualViewportFrameTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,0FAA0F;AAC1F,MAAM,MAAM,6BAA6B,GAAG,QAAQ,CAAC;IACpD,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;CAC5C,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { u as e } from "../chunks/dom-RMvZy-Sx.js";
1
+ import { f as e } from "../chunks/dom-Bin1L9-q.js";
2
2
  import { Sn as t, c as n, l as r, pn as i, s as a, u as o, xn as s } from "../chunks/odata-service-CWkHASdw.js";
3
3
  import { d as c, t as l } from "../chunks/validate-DyzojM0w.js";
4
4
  import { escapeXmlValue as u } from "../xml/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryuzaki13/react-foundation-lib",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "Reusable React and TypeScript foundation utilities, hooks, and primitives.",
5
5
  "license": "MIT",
6
6
  "author": "Ryuzaki13",
@@ -201,7 +201,7 @@
201
201
  },
202
202
  "scripts": {
203
203
  "build": "vite build && tsc -p tsconfig.build.json --emitDeclarationOnly",
204
- "typecheck": "tsc -p tsconfig.build.json --noEmit",
204
+ "typecheck": "tsc -p tsconfig.build.json --noEmit && tsc -p tsconfig.type-tests.json --noEmit",
205
205
  "test": "vitest run",
206
206
  "lint": "eslint .",
207
207
  "lint:fix": "eslint . --fix",
@@ -14,6 +14,8 @@ import { Meta } from "@storybook/addon-docs/blocks";
14
14
  - узнать высоту элемента через `ResizeObserver`;
15
15
  - узнать, пересекается ли элемент с viewport или другим root;
16
16
  - сохранить позицию чтения при вставке элементов выше текущего;
17
+ - согласованно блокировать прокрутку документа для вложенных overlays;
18
+ - привязать fixed-поверхность к visual viewport при экранной клавиатуре;
17
19
  - определить наличие touch/coarse-pointer возможностей.
18
20
 
19
21
  Модуль является низкоуровневым browser foundation-слоем. Он не создаёт готовые кнопки, dialog, modal, popover, tooltip или download UI. Визуальный компонент по-прежнему отвечает за семантический HTML, ARIA, стили, анимацию, стек overlay, сообщения об ошибках и пользовательский сценарий.
@@ -29,6 +31,7 @@ import { Meta } from "@storybook/addon-docs/blocks";
29
31
  - [Скачивание файлов](#скачивание-файлов)
30
32
  - [`getOrCreatePortalRoot`](#getorcreateportalroot)
31
33
  - [`captureScrollAnchor`](#capturescrollanchor)
34
+ - [Блокировка документа и visual viewport](#блокировка-документа-и-visual-viewport)
32
35
  - [`useClickOutside`](#useclickoutside)
33
36
  - [`useEscapeDismiss`](#useescapedismiss)
34
37
  - [`useElementHeightObserver`](#useelementheightobserver)
@@ -69,7 +72,7 @@ import { Meta } from "@storybook/addon-docs/blocks";
69
72
  - не удаляет portal root после использования;
70
73
  - не реализует полноценный dialog/modal/popover;
71
74
  - не назначает `role`, `aria-modal`, `aria-labelledby` или `aria-describedby`;
72
- - не блокирует прокрутку страницы;
75
+ - не выбирает автоматически, какие поверхности должны блокировать прокрутку страницы;
73
76
  - не делает фон `inert`;
74
77
  - не управляет стеком вложенных overlay;
75
78
  - не блокирует программный уход фокуса;
@@ -2128,6 +2131,64 @@ Touch-capable laptop не обязательно mobile. Не связывайт
2128
2131
 
2129
2132
  ## Краткий справочник API
2130
2133
 
2134
+ ### Блокировка документа и visual viewport
2135
+
2136
+ ```tsx
2137
+ import { useRef } from "react";
2138
+ import { useDocumentScrollLock, useVisualViewportFrame } from "@ryuzaki13/react-foundation-lib/dom";
2139
+
2140
+ function Surface({ open }: { open: boolean }) {
2141
+ const containerRef = useRef<HTMLDivElement>(null);
2142
+ useDocumentScrollLock({ active: open });
2143
+ useVisualViewportFrame({ active: open, containerRef });
2144
+ return open ? <div ref={containerRef} className="viewportSurface" /> : null;
2145
+ }
2146
+ ```
2147
+
2148
+ ```css
2149
+ .viewportSurface {
2150
+ position: fixed;
2151
+ top: var(--visual-viewport-top, 0px);
2152
+ left: var(--visual-viewport-left, 0px);
2153
+ width: var(--visual-viewport-width, 100%);
2154
+ height: var(--visual-viewport-height, 100dvh);
2155
+ overflow: hidden;
2156
+ }
2157
+ ```
2158
+
2159
+ `UseDocumentScrollLockOptions` содержит `active`, необязательные `documentTarget`
2160
+ и `compensateScrollbar` (по умолчанию `false`). `undefined` выбирает глобальный
2161
+ document, `null` явно отключает операцию. Потребители одного документа разделяют
2162
+ аренды: закрытие вложенного dialog не разблокирует открытый fullscreen. После
2163
+ последнего cleanup восстанавливаются исходные inline properties с priority и
2164
+ scroll X/Y; посторонние CSS-свойства не затрагиваются. Пока lock активен, другой
2165
+ код не должен параллельно изменять принадлежащие ему position/top/left/width,
2166
+ overflow, box-sizing и padding-right body или overflow html.
2167
+
2168
+ `UseVisualViewportFrameOptions` содержит `active` и `containerRef`. Hook пишет
2169
+ четыре показанные CSS-переменные только на переданный контейнер; готовый layout,
2170
+ scroll host, safe-area padding и z-index задаёт UI-владелец. `resize` и `scroll`
2171
+ visual viewport объединяются одним animation frame. Несколько потребителей
2172
+ одного portal root разделяют подписку. Отложенное появление portal ref
2173
+ поддерживается; после установки DOM-узел должен оставаться тем же до деактивации.
2174
+ При замене узла деактивируйте прежний lifecycle либо перемонтируйте его owner.
2175
+
2176
+ При отсутствии VisualViewport используются innerWidth/innerHeight окна и его
2177
+ resize. Нулевая размерность сохраняется как действительное состояние, NaN
2178
+ заменяется fallback. Pinch zoom не отключается: hook использует CSS-pixel bounds
2179
+ браузера и не добавляет обратный scale. Эти hooks не определяют «телефон» по UA,
2180
+ не перехватывают touchmove и не заставляют окно постоянно возвращаться в (0, 0).
2181
+
2182
+ Оба hook SSR-safe: browser работа начинается только после commit, первый HTML
2183
+ использует CSS fallback. Они не предоставляют focus trap, inert, Escape или
2184
+ порядок overlays — используйте UI primitive и `useOverlayFocus` по назначению.
2185
+ Прежние независимые body locks нужно заменить во всех совместно открываемых
2186
+ потребителях: общий ref-count не может координировать чужую реализацию.
2187
+
2188
+ JSDOM покрывает leases, lifecycle и события, но не поведение виртуальной
2189
+ клавиатуры. Мобильные fixed-поверхности дополнительно проверяйте на физическом
2190
+ устройстве: keyboard open/close, pan, orientation, pinch zoom и вложенный overlay.
2191
+
2131
2192
  | API | Вход | Результат | Default/событие | Главное ограничение |
2132
2193
  | --------------------------- | ----------------------------- | ----------------------------------- | ------------------------------------- | -------------------------------------------------------- |
2133
2194
  | `downloadFileFromObjectURL` | filename, object URL | `void` | revoke через `setTimeout(0)` | Принимает ownership URL; нет подтверждения download. |
@@ -1 +0,0 @@
1
- {"version":3,"file":"dom-RMvZy-Sx.js","names":[],"sources":["../../src/dom/downloadFile.ts","../../src/dom/getOrCreatePortalRoot.ts","../../src/dom/scroll-anchor/captureScrollAnchor.ts","../../src/dom/useClickOutside.ts","../../src/dom/useElementHeightObserver.ts","../../src/dom/useEscapeDismiss.ts","../../src/dom/useOverlayFocus.ts","../../src/dom/useFocusTrap.ts","../../src/dom/useIntersectionObserver.ts","../../src/dom/useIsTouchDevice.ts"],"sourcesContent":["export function downloadFileFromObjectURL(filename: string, objectUrl: string) {\n\tconst link = document.createElement(\"a\");\n\n\tlink.href = objectUrl;\n\tlink.download = filename;\n\tlink.click();\n\n\twindow.setTimeout(() => {\n\t\twindow.URL.revokeObjectURL(objectUrl);\n\t}, 0);\n}\n\nexport function downloadFileFromBlob(filename: string, blob: Blob) {\n\tconst objectUrl = window.URL.createObjectURL(blob);\n\tdownloadFileFromObjectURL(filename, objectUrl);\n}\n\nexport function downloadFileFromJson(filename: string, payload: unknown) {\n\tconst blob = new Blob([JSON.stringify(payload, null, 2)], { type: \"application/json;charset=utf-8\" });\n\tdownloadFileFromBlob(filename, blob);\n}\n","export function getOrCreatePortalRoot(id: string): HTMLElement | null {\n\tif (typeof document === \"undefined\") {\n\t\treturn null;\n\t}\n\n\tconst existingElement = document.getElementById(id);\n\tif (existingElement instanceof HTMLElement) {\n\t\treturn existingElement;\n\t}\n\n\tconst portalRoot = document.createElement(\"div\");\n\tportalRoot.id = id;\n\tdocument.body.append(portalRoot);\n\n\treturn portalRoot;\n}\n","import { type CapturedScrollAnchor } from \"./scrollAnchorTypes\";\n\n// Один scroll host не может одновременно компенсировать один и тот же prepend дважды.\nconst activeAnchors = new WeakMap<HTMLElement, CapturedScrollAnchor>();\n\n/**\n * Захватывает позицию сохраняемого элемента перед изменением обычного вертикального списка.\n * Вызывать только на browser event/effect boundary; restore — после DOM commit, release — при отмене.\n * Новый захват того же viewport завершает предыдущий без прокрутки.\n */\nexport function captureScrollAnchor(viewport: HTMLElement | null, anchor: HTMLElement | null): CapturedScrollAnchor | null {\n\tif (!viewport?.isConnected || !anchor?.isConnected || viewport === anchor || !viewport.contains(anchor)) return null;\n\n\tactiveAnchors.get(viewport)?.release();\n\tconst initialOffset =\n\t\tanchor.getBoundingClientRect().top - viewport.getBoundingClientRect().top - viewport.clientTop + viewport.scrollTop;\n\tconst initialStyle = viewport.style.getPropertyValue(\"overflow-anchor\");\n\tconst initialPriority = viewport.style.getPropertyPriority(\"overflow-anchor\");\n\tlet active = true;\n\n\t// Native anchoring иначе успеет компенсировать prepend до restore и приведёт к двойному сдвигу.\n\tviewport.style.setProperty(\"overflow-anchor\", \"none\", \"important\");\n\t// В браузере без этого CSS-свойства native anchoring тоже отсутствует: сравниваем фактически принятый стиль.\n\tconst ownedStyle = viewport.style.getPropertyValue(\"overflow-anchor\");\n\tconst ownedPriority = viewport.style.getPropertyPriority(\"overflow-anchor\");\n\tconst ownsStyle = () =>\n\t\tviewport.style.getPropertyValue(\"overflow-anchor\") === ownedStyle &&\n\t\tviewport.style.getPropertyPriority(\"overflow-anchor\") === ownedPriority;\n\n\tconst operation: CapturedScrollAnchor = {\n\t\trelease() {\n\t\t\tif (!active) return;\n\t\t\tactive = false;\n\t\t\tactiveAnchors.delete(viewport);\n\t\t\t// Не затираем новое решение host, если он сам изменил свойство во время ожидания.\n\t\t\tif (!ownsStyle()) return;\n\t\t\tif (initialStyle) viewport.style.setProperty(\"overflow-anchor\", initialStyle, initialPriority);\n\t\t\telse viewport.style.removeProperty(\"overflow-anchor\");\n\t\t},\n\t\trestore() {\n\t\t\tif (!active) return false;\n\t\t\ttry {\n\t\t\t\tif (!viewport.isConnected || !anchor.isConnected || !viewport.contains(anchor) || !ownsStyle()) return false;\n\t\t\t\tconst currentOffset =\n\t\t\t\t\tanchor.getBoundingClientRect().top - viewport.getBoundingClientRect().top - viewport.clientTop + viewport.scrollTop;\n\t\t\t\tconst delta = currentOffset - initialOffset;\n\t\t\t\t// Content-space delta не отменяет ручную прокрутку между запросом и commit.\n\t\t\t\t// Instant не наследует CSS smooth; горизонтальная позиция остаётся неизменной.\n\t\t\t\tif (delta !== 0) viewport.scrollBy({ top: delta, behavior: \"instant\" });\n\t\t\t\treturn true;\n\t\t\t} finally {\n\t\t\t\toperation.release();\n\t\t\t}\n\t\t}\n\t};\n\tactiveAnchors.set(viewport, operation);\n\treturn operation;\n}\n","import { RefObject, useEffect } from \"react\";\n\nexport function useClickOutside(ref: RefObject<HTMLElement | null> | RefObject<HTMLElement | null>[], handler: () => void) {\n\tuseEffect(() => {\n\t\tconst handleClickOutside = (event: MouseEvent) => {\n\t\t\tif (Array.isArray(ref)) {\n\t\t\t\tlet isOutside = true;\n\t\t\t\tfor (const r of ref) {\n\t\t\t\t\tif (r.current && r.current.contains(event.target as Node)) {\n\t\t\t\t\t\tisOutside = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (isOutside) {\n\t\t\t\t\thandler();\n\t\t\t\t}\n\t\t\t} else if (ref.current && !ref.current.contains(event.target as Node)) {\n\t\t\t\thandler();\n\t\t\t}\n\t\t};\n\n\t\tdocument.addEventListener(\"mousedown\", handleClickOutside);\n\t\treturn () => document.removeEventListener(\"mousedown\", handleClickOutside);\n\t}, [ref, handler]);\n}\n","import { type RefObject, useLayoutEffect, useState } from \"react\";\n\nexport function useElementHeightObserver<TElement extends HTMLElement>(elementRef: RefObject<TElement | null>) {\n\tconst [height, setHeight] = useState(0);\n\n\tuseLayoutEffect(() => {\n\t\tconst element = elementRef.current;\n\t\tif (!element) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst observer = new ResizeObserver((entries) => {\n\t\t\tconst nextHeight = entries[0]?.contentRect.height ?? element.getBoundingClientRect().height;\n\t\t\tsetHeight(nextHeight);\n\t\t});\n\t\tobserver.observe(element);\n\n\t\treturn () => observer.disconnect();\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps, react-hooks/refs\n\t}, [elementRef.current]);\n\n\treturn height;\n}\n","import { RefObject, useEffect, useEffectEvent } from \"react\";\n\ninterface UseEscapeDismissOptions {\n\tactive: boolean;\n\tonDismiss: () => void;\n\tenabled?: boolean;\n\tdocumentTarget?: Document | null;\n\tcontainerRef?: RefObject<HTMLElement | null>;\n}\n\n/**\n * Подписывает overlay на закрытие по клавише Escape.\n */\nexport function useEscapeDismiss({ active, onDismiss, enabled = true, documentTarget, containerRef }: UseEscapeDismissOptions) {\n\tconst dismiss = useEffectEvent(() => onDismiss());\n\n\tuseEffect(() => {\n\t\tif (!active || !enabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst targetDocument = documentTarget ?? (typeof document === \"undefined\" ? null : document);\n\t\tif (!targetDocument) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst handleKeyDown = (event: KeyboardEvent) => {\n\t\t\tif (event.key !== \"Escape\" /*|| event.defaultPrevented*/) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst activeElement = targetDocument.activeElement;\n\t\t\tconst container = containerRef?.current;\n\t\t\tif (container && activeElement instanceof Node && activeElement !== container && !container.contains(activeElement)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t\tdismiss();\n\t\t};\n\n\t\ttargetDocument.addEventListener(\"keydown\", handleKeyDown, true);\n\t\treturn () => targetDocument.removeEventListener(\"keydown\", handleKeyDown, true);\n\t}, [active, enabled, documentTarget, containerRef]);\n}\n","import { RefObject, useEffect, useEffectEvent, useRef } from \"react\";\n\nconst focusableElementsSelector =\n\t'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"]):not([disabled])';\n\nexport interface UseOverlayFocusOptions<T extends HTMLElement> {\n\tactive: boolean;\n\ttrapFocus?: boolean;\n\trestoreFocus?: boolean;\n\tinitialFocus?: \"auto\" | \"container\" | ((container: T) => HTMLElement | null | undefined);\n\trestoreFocusTarget?: () => HTMLElement | null | undefined;\n\tcontainerRef?: RefObject<T | null>;\n}\n\n/**\n * Возвращает ref overlay-контейнера и управляет начальными/возвратными переходами фокуса.\n * Открытие и закрытие не прокручивают документ: портал может получить фокус\n * до завершения позиционирования. Пользовательский Tab по-прежнему раскрывает\n * выбранный элемент в прокручиваемом содержимом overlay.\n */\nexport function useOverlayFocus<T extends HTMLElement>({\n\tactive,\n\ttrapFocus = false,\n\trestoreFocus = true,\n\tinitialFocus = \"auto\",\n\trestoreFocusTarget,\n\tcontainerRef\n}: UseOverlayFocusOptions<T>) {\n\tconst internalOverlayRef = useRef<T | null>(null);\n\tconst overlayRef = containerRef ?? internalOverlayRef;\n\tconst previousActiveElementRef = useRef<HTMLElement | null>(null);\n\n\t/**\n\t * Собирает фокусируемые элементы overlay в актуальном DOM-порядке.\n\t */\n\tconst getFocusableElements = useEffectEvent((container: T) =>\n\t\tArray.from(container.querySelectorAll<HTMLElement>(focusableElementsSelector)).filter(\n\t\t\t(element) => !element.hasAttribute(\"aria-hidden\")\n\t\t)\n\t);\n\n\t/**\n\t * Вычисляет стартовый фокус при открытии overlay.\n\t */\n\tconst resolveInitialFocus = useEffectEvent((container: T) => {\n\t\tif (initialFocus === \"container\") {\n\t\t\treturn container;\n\t\t}\n\n\t\tif (typeof initialFocus === \"function\") {\n\t\t\treturn initialFocus(container) ?? container;\n\t\t}\n\n\t\tconst focusableElements = getFocusableElements(container);\n\t\treturn (\n\t\t\tfocusableElements.find((element) => element.hasAttribute(\"autofocus\") || element.hasAttribute(\"autoFocus\")) ??\n\t\t\tfocusableElements[0] ??\n\t\t\tcontainer\n\t\t);\n\t});\n\n\t/**\n\t * Вычисляет элемент, которому нужно вернуть фокус после закрытия overlay.\n\t */\n\tconst resolveRestoreFocusTarget = useEffectEvent(() => restoreFocusTarget?.() ?? previousActiveElementRef.current);\n\n\tuseEffect(() => {\n\t\tif (!active) {\n\t\t\treturn;\n\t\t}\n\n\t\tpreviousActiveElementRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n\t\tlet overlayElement: T | null = null;\n\t\tlet rafId = 0;\n\n\t\t/**\n\t\t * Цикл откладывает инициализацию, пока ref контейнера не будет привязан к DOM.\n\t\t */\n\t\tconst attachOverlay = () => {\n\t\t\toverlayElement = overlayRef.current;\n\t\t\tif (!overlayElement) {\n\t\t\t\trafId = window.requestAnimationFrame(attachOverlay);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst focusTarget = resolveInitialFocus(overlayElement);\n\t\t\tif (focusTarget instanceof HTMLElement && focusTarget.isConnected) {\n\t\t\t\tfocusTarget.focus({ preventScroll: true });\n\t\t\t}\n\n\t\t\tif (trapFocus) {\n\t\t\t\toverlayElement.addEventListener(\"keydown\", handleTabKey);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * Зацикливает Tab внутри overlay, пока он открыт как модальный слой.\n\t\t */\n\t\tconst handleTabKey = (event: KeyboardEvent) => {\n\t\t\tif (!trapFocus || event.key !== \"Tab\" || !overlayElement) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst focusableElements = getFocusableElements(overlayElement);\n\t\t\tif (focusableElements.length === 0) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\toverlayElement.focus();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst firstElement = focusableElements[0];\n\t\t\tconst lastElement = focusableElements[focusableElements.length - 1];\n\t\t\tconst activeElement = document.activeElement;\n\n\t\t\tif (event.shiftKey) {\n\t\t\t\tif (activeElement === firstElement || activeElement === overlayElement) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tlastElement.focus();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (activeElement === lastElement) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tfirstElement.focus();\n\t\t\t}\n\t\t};\n\n\t\tattachOverlay();\n\n\t\treturn () => {\n\t\t\twindow.cancelAnimationFrame(rafId);\n\t\t\tif (trapFocus && overlayElement) {\n\t\t\t\toverlayElement.removeEventListener(\"keydown\", handleTabKey);\n\t\t\t}\n\n\t\t\tif (!restoreFocus) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst restoreTarget = resolveRestoreFocusTarget();\n\t\t\tif (restoreTarget?.isConnected) {\n\t\t\t\trestoreTarget.focus({ preventScroll: true });\n\t\t\t}\n\t\t};\n\t}, [active, trapFocus, restoreFocus, overlayRef]);\n\n\treturn overlayRef;\n}\n","import { useOverlayFocus } from \"./useOverlayFocus\";\n\n/**\n * Совместимый wrapper для overlay с фокус-ловушкой.\n */\nexport const useFocusTrap = (isOpen: boolean) => {\n\treturn useOverlayFocus<HTMLDivElement>({ active: isOpen, trapFocus: true, restoreFocus: true, initialFocus: \"auto\" });\n};\n","import { useEffect, useState } from \"react\";\n\nexport function useIntersectionObserver(ref: React.RefObject<Element | null>, options?: IntersectionObserverInit) {\n\tconst [isIntersecting, setIsIntersecting] = useState(false);\n\n\tuseEffect(() => {\n\t\tconst el = ref.current;\n\t\tif (!el) return;\n\n\t\tconst observer = new IntersectionObserver(([entry]) => {\n\t\t\tsetIsIntersecting(entry.isIntersecting);\n\t\t}, options);\n\n\t\tobserver.observe(el);\n\n\t\treturn () => {\n\t\t\tif (el) {\n\t\t\t\tobserver.unobserve(el);\n\t\t\t}\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [options, ref]); // не забыть, что ref.current может меняться\n\n\treturn { isIntersecting };\n}\n","import { useEffect, useState } from \"react\";\n\nexport const useIsTouchDevice = () => {\n\tconst [isTouchDevice, setIsTouchDevice] = useState(false);\n\n\tuseEffect(() => {\n\t\tconst checkTouchDevice = () => {\n\t\t\tconst isTouch = window.matchMedia(\"(pointer: coarse)\").matches || \"ontouchstart\" in window || navigator.maxTouchPoints > 0;\n\t\t\tsetIsTouchDevice(isTouch);\n\t\t};\n\n\t\tcheckTouchDevice();\n\n\t\t// Обработчик для изменений в типе устройства\n\t\twindow.addEventListener(\"resize\", checkTouchDevice);\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"resize\", checkTouchDevice);\n\t\t};\n\t}, []);\n\n\treturn isTouchDevice;\n};\n"],"mappings":";;AAAA,SAAgB,EAA0B,GAAkB,GAAmB;CAC9E,IAAM,IAAO,SAAS,cAAc,GAAG;CAMvC,AAJA,EAAK,OAAO,GACZ,EAAK,WAAW,GAChB,EAAK,MAAM,GAEX,OAAO,iBAAiB;EACvB,OAAO,IAAI,gBAAgB,CAAS;CACrC,GAAG,CAAC;AACL;AAEA,SAAgB,EAAqB,GAAkB,GAAY;CAElE,EAA0B,GADR,OAAO,IAAI,gBAAgB,CACT,CAAS;AAC9C;AAEA,SAAgB,EAAqB,GAAkB,GAAkB;CAExE,EAAqB,GAAU,IADd,KAAK,CAAC,KAAK,UAAU,GAAS,MAAM,CAAC,CAAC,GAAG,EAAE,MAA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