@reforma/components 0.1.6 → 0.2.1

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 (129) hide show
  1. package/dist/Scrollable/Scrollable.d.ts +1 -2
  2. package/dist/Scrollable/Scrollable.d.ts.map +1 -1
  3. package/dist/Scrollable/Scrollable.js +45 -38
  4. package/dist/Scrollable/Scrollable.js.map +1 -1
  5. package/dist/Scrollable/useScrollChrome.d.ts +1 -2
  6. package/dist/Scrollable/useScrollChrome.d.ts.map +1 -1
  7. package/dist/Scrollable/useScrollChrome.js +125 -110
  8. package/dist/Scrollable/useScrollChrome.js.map +1 -1
  9. package/dist/chat/ComposerBanner/ComposerBanner.d.ts +2 -1
  10. package/dist/chat/ComposerBanner/ComposerBanner.d.ts.map +1 -1
  11. package/dist/chat/ComposerBanner/ComposerBanner.js +37 -29
  12. package/dist/chat/ComposerBanner/ComposerBanner.js.map +1 -1
  13. package/dist/chat/ComposerBanner/ComposerBanner.module.css +1 -1
  14. package/dist/chat/ComposerBanner/ComposerBanner.module.css.js +5 -3
  15. package/dist/chat/ComposerBanner/ComposerBanner.module.css.js.map +1 -1
  16. package/dist/chat/Tool/agent/AgentTool.d.ts.map +1 -1
  17. package/dist/chat/Tool/agent/AgentTool.js +89 -90
  18. package/dist/chat/Tool/agent/AgentTool.js.map +1 -1
  19. package/dist/chat/Tool/edit/EditTool.js +1 -1
  20. package/dist/chat/Tool/edit/EditTool.js.map +1 -1
  21. package/dist/node_modules/zod/v4/classic/errors.js +38 -0
  22. package/dist/node_modules/zod/v4/classic/errors.js.map +1 -0
  23. package/dist/node_modules/zod/v4/classic/parse.js +21 -0
  24. package/dist/node_modules/zod/v4/classic/parse.js.map +1 -0
  25. package/dist/node_modules/zod/v4/classic/schemas.js +822 -0
  26. package/dist/node_modules/zod/v4/classic/schemas.js.map +1 -0
  27. package/dist/node_modules/zod/v4/core/api.js +561 -0
  28. package/dist/node_modules/zod/v4/core/api.js.map +1 -0
  29. package/dist/node_modules/zod/v4/core/checks.js +262 -0
  30. package/dist/node_modules/zod/v4/core/checks.js.map +1 -0
  31. package/dist/node_modules/zod/v4/core/core.js +97 -0
  32. package/dist/node_modules/zod/v4/core/core.js.map +1 -0
  33. package/dist/node_modules/zod/v4/core/doc.js +35 -0
  34. package/dist/node_modules/zod/v4/core/doc.js.map +1 -0
  35. package/dist/node_modules/zod/v4/core/errors.js +79 -0
  36. package/dist/node_modules/zod/v4/core/errors.js.map +1 -0
  37. package/dist/node_modules/zod/v4/core/json-schema-processors.js +308 -0
  38. package/dist/node_modules/zod/v4/core/json-schema-processors.js.map +1 -0
  39. package/dist/node_modules/zod/v4/core/memoizer.js +203 -0
  40. package/dist/node_modules/zod/v4/core/memoizer.js.map +1 -0
  41. package/dist/node_modules/zod/v4/core/parse.js +113 -0
  42. package/dist/node_modules/zod/v4/core/parse.js.map +1 -0
  43. package/dist/node_modules/zod/v4/core/regexes.js +59 -0
  44. package/dist/node_modules/zod/v4/core/regexes.js.map +1 -0
  45. package/dist/node_modules/zod/v4/core/registries.js +41 -0
  46. package/dist/node_modules/zod/v4/core/registries.js.map +1 -0
  47. package/dist/node_modules/zod/v4/core/schemas.js +1104 -0
  48. package/dist/node_modules/zod/v4/core/schemas.js.map +1 -0
  49. package/dist/node_modules/zod/v4/core/to-json-schema.js +380 -0
  50. package/dist/node_modules/zod/v4/core/to-json-schema.js.map +1 -0
  51. package/dist/node_modules/zod/v4/core/util.js +465 -0
  52. package/dist/node_modules/zod/v4/core/util.js.map +1 -0
  53. package/dist/node_modules/zod/v4/core/versions.js +9 -0
  54. package/dist/node_modules/zod/v4/core/versions.js.map +1 -0
  55. package/dist/node_modules/zod/v4/locales/en.js +97 -0
  56. package/dist/node_modules/zod/v4/locales/en.js.map +1 -0
  57. package/dist/openui/actions.d.ts +16 -0
  58. package/dist/openui/actions.d.ts.map +1 -0
  59. package/dist/openui/actions.js +58 -0
  60. package/dist/openui/actions.js.map +1 -0
  61. package/dist/openui/components/controls.d.ts +34 -0
  62. package/dist/openui/components/controls.d.ts.map +1 -0
  63. package/dist/openui/components/controls.js +40 -0
  64. package/dist/openui/components/controls.js.map +1 -0
  65. package/dist/openui/components/layout.d.ts +74 -0
  66. package/dist/openui/components/layout.d.ts.map +1 -0
  67. package/dist/openui/components/layout.js +154 -0
  68. package/dist/openui/components/layout.js.map +1 -0
  69. package/dist/openui/components/list.d.ts +17 -0
  70. package/dist/openui/components/list.d.ts.map +1 -0
  71. package/dist/openui/components/list.js +96 -0
  72. package/dist/openui/components/list.js.map +1 -0
  73. package/dist/openui/components/svg.d.ts +100 -0
  74. package/dist/openui/components/svg.d.ts.map +1 -0
  75. package/dist/openui/components/svg.js +246 -0
  76. package/dist/openui/components/svg.js.map +1 -0
  77. package/dist/openui/components/table.d.ts +6 -0
  78. package/dist/openui/components/table.d.ts.map +1 -0
  79. package/dist/openui/components/table.js +54 -0
  80. package/dist/openui/components/table.js.map +1 -0
  81. package/dist/openui/components/text.d.ts +89 -0
  82. package/dist/openui/components/text.d.ts.map +1 -0
  83. package/dist/openui/components/text.js +181 -0
  84. package/dist/openui/components/text.js.map +1 -0
  85. package/dist/openui/functions/colors.d.ts +12 -0
  86. package/dist/openui/functions/colors.d.ts.map +1 -0
  87. package/dist/openui/functions/colors.js +32 -0
  88. package/dist/openui/functions/colors.js.map +1 -0
  89. package/dist/openui/functions/data.d.ts +170 -0
  90. package/dist/openui/functions/data.d.ts.map +1 -0
  91. package/dist/openui/functions/data.js +308 -0
  92. package/dist/openui/functions/data.js.map +1 -0
  93. package/dist/openui/functions/dates.d.ts +57 -0
  94. package/dist/openui/functions/dates.d.ts.map +1 -0
  95. package/dist/openui/functions/dates.js +184 -0
  96. package/dist/openui/functions/dates.js.map +1 -0
  97. package/dist/openui/functions/index.d.ts +136 -0
  98. package/dist/openui/functions/index.d.ts.map +1 -0
  99. package/dist/openui/functions/index.js +11 -0
  100. package/dist/openui/functions/index.js.map +1 -0
  101. package/dist/openui/functions/lists.d.ts +102 -0
  102. package/dist/openui/functions/lists.d.ts.map +1 -0
  103. package/dist/openui/functions/lists.js +305 -0
  104. package/dist/openui/functions/lists.js.map +1 -0
  105. package/dist/openui/functions/numbers.d.ts +72 -0
  106. package/dist/openui/functions/numbers.d.ts.map +1 -0
  107. package/dist/openui/functions/numbers.js +201 -0
  108. package/dist/openui/functions/numbers.js.map +1 -0
  109. package/dist/openui/functions/shared.d.ts +28 -0
  110. package/dist/openui/functions/shared.d.ts.map +1 -0
  111. package/dist/openui/functions/shared.js +69 -0
  112. package/dist/openui/functions/shared.js.map +1 -0
  113. package/dist/openui/functions/text.d.ts +97 -0
  114. package/dist/openui/functions/text.d.ts.map +1 -0
  115. package/dist/openui/functions/text.js +223 -0
  116. package/dist/openui/functions/text.js.map +1 -0
  117. package/dist/openui/index.d.ts +5 -0
  118. package/dist/openui/index.d.ts.map +1 -0
  119. package/dist/openui/index.js +14 -0
  120. package/dist/openui/index.js.map +1 -0
  121. package/dist/openui/library.d.ts +8 -0
  122. package/dist/openui/library.d.ts.map +1 -0
  123. package/dist/openui/library.js +37 -0
  124. package/dist/openui/library.js.map +1 -0
  125. package/dist/openui/schema.d.ts +36 -0
  126. package/dist/openui/schema.d.ts.map +1 -0
  127. package/dist/openui/schema.js +24 -0
  128. package/dist/openui/schema.js.map +1 -0
  129. package/package.json +4 -2
@@ -15,7 +15,6 @@ export type ScrollableProps = {
15
15
  * Prefer a child with `slot={SCROLLABLE_OVERLAY_SLOT}` (see {@link filterSlots}); this prop overrides that slot when set.
16
16
  */
17
17
  overlay?: React.ReactNode;
18
- poolingInterval?: number;
19
18
  onScroll?: (e: Event) => void;
20
19
  alwaysShowScrollbar?: boolean;
21
20
  vertical?: boolean;
@@ -40,5 +39,5 @@ export type ScrollableProps = {
40
39
  * The same flags are available from {@link useScrollable}.
41
40
  * Overlay UI: pass a child with `slot={SCROLLABLE_OVERLAY_SLOT}`, or use the `overlay` prop.
42
41
  */
43
- export declare function Scrollable({ ref: userRef, children, className, containerClass, contentClass, containerRef, contentRef, overlay, onScroll, alwaysShowScrollbar, vertical, horizontal, poolingInterval, gap, stickToBottom, edgeFade, ...attrs }: ScrollableProps): import("react").JSX.Element;
42
+ export declare function Scrollable({ ref: userRef, children, className, containerClass, contentClass, containerRef, contentRef, overlay, onScroll, alwaysShowScrollbar, vertical, horizontal, gap, stickToBottom, edgeFade, ...attrs }: ScrollableProps): import("react").JSX.Element;
44
43
  //# sourceMappingURL=Scrollable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Scrollable.d.ts","sourceRoot":"","sources":["../../src/Scrollable/Scrollable.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAA6B,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGtE,iIAAiI;AACjI,eAAO,MAAM,uBAAuB,YAAY,CAAC;AAEjD,MAAM,MAAM,eAAe,GAAG;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACjC,YAAY,CAAC,EAAE,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAExC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE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,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,oBAAoB,CAAC;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,CAAC;AAE3D;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,EACvB,GAAG,EAAE,OAAO,EACZ,QAAQ,EACR,SAAS,EACT,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,OAAO,EACP,QAAQ,EACR,mBAAmB,EACnB,QAAQ,EACR,UAAU,EACV,GAAO,EACP,aAAqB,EACrB,QAAgB,EAChB,GAAG,KAAK,EACX,EAAE,eAAe,+BAyJjB"}
@@ -1,17 +1,17 @@
1
- import { mergeRefs as v, cn as J } from "@reforma/lib";
2
- import { useMemo as t, useRef as K, useCallback as z } from "react";
3
- import { useStickToBottom as N } from "../hooks/useStickToBottom.js";
1
+ import { mergeRefs as v, cn as G } from "@reforma/lib";
2
+ import { useMemo as t, useRef as J, useCallback as z } from "react";
3
+ import { useStickToBottom as K } from "../hooks/useStickToBottom.js";
4
4
  import { filterSlots as g } from "../Slot/Slot.js";
5
- import { ScrollableContext as Q } from "./scrollable-context.js";
6
- import U from "./Scrollable.module.css.js";
5
+ import { ScrollableContext as N } from "./scrollable-context.js";
6
+ import Q from "./Scrollable.module.css.js";
7
7
  import { elementScrollAxisSource as h } from "./scrollAxisSource.js";
8
- import { ScrollChromeBars as W } from "./ScrollChromeBars.js";
9
- import { ScrollChromeRoot as X } from "./ScrollChromeRoot.js";
10
- import { ScrollContainer as Z } from "./ScrollContainer.js";
11
- import { useScrollChrome as $ } from "./useScrollChrome.js";
12
- import { jsx as m, jsxs as tt } from "react/jsx-runtime";
8
+ import { ScrollChromeBars as U } from "./ScrollChromeBars.js";
9
+ import { ScrollChromeRoot as W } from "./ScrollChromeRoot.js";
10
+ import { ScrollContainer as X } from "./ScrollContainer.js";
11
+ import { useScrollChrome as Z } from "./useScrollChrome.js";
12
+ import { jsx as m, jsxs as $ } from "react/jsx-runtime";
13
13
  const E = "overlay";
14
- function St({
14
+ function mt({
15
15
  ref: H,
16
16
  children: a,
17
17
  className: V,
@@ -24,19 +24,26 @@ function St({
24
24
  alwaysShowScrollbar: L,
25
25
  vertical: O,
26
26
  horizontal: P,
27
- poolingInterval: T,
28
- gap: j = 0,
27
+ gap: T = 0,
29
28
  stickToBottom: r = !1,
30
- edgeFade: A = !1,
31
- ...M
29
+ edgeFade: j = !1,
30
+ ...A
32
31
  }) {
33
- const w = t(() => g(a, E), [a]), B = t(() => g(a, (e) => e !== E, null), [a]), D = y ?? w, f = K(null), c = z(() => f.current, []), s = O ?? !0, i = P ?? !1, _ = t(() => s ? h(c, "vertical") : null, [c, s]), F = t(() => i ? h(c, "horizontal") : null, [c, i]), o = $({
34
- verticalSource: _,
35
- horizontalSource: F,
36
- gap: j,
37
- alwaysShowScrollbar: L,
38
- poolingInterval: T
39
- }), l = r !== !1, I = t(() => l ? typeof r == "object" && r !== null ? {
32
+ const M = t(() => g(a, E), [a]), w = t(() => g(a, (e) => e !== E, null), [a]), B = y ?? M, f = J(null), c = z(() => f.current, []), s = O ?? !0, i = P ?? !1, D = t(
33
+ // The getter is stored and called from effects, not during render.
34
+ // eslint-disable-next-line react-hooks/refs -- elementScrollAxisSource does not read `.current` now
35
+ () => s ? h(c, "vertical") : null,
36
+ [c, s]
37
+ ), _ = t(
38
+ // eslint-disable-next-line react-hooks/refs -- elementScrollAxisSource does not read `.current` now
39
+ () => i ? h(c, "horizontal") : null,
40
+ [c, i]
41
+ ), o = Z({
42
+ verticalSource: D,
43
+ horizontalSource: _,
44
+ gap: T,
45
+ alwaysShowScrollbar: L
46
+ }), l = r !== !1, F = t(() => l ? typeof r == "object" && r !== null ? {
40
47
  resize: "instant",
41
48
  ...r,
42
49
  enabled: r.enabled !== !1
@@ -47,7 +54,7 @@ function St({
47
54
  } : {
48
55
  enabled: !1,
49
56
  initial: !1
50
- }, [l, r]), u = N(I), {
57
+ }, [l, r]), u = K(F), {
51
58
  scrollRef: b,
52
59
  contentRef: R
53
60
  } = u, {
@@ -55,7 +62,7 @@ function St({
55
62
  } = o, C = z(() => {
56
63
  const e = f.current;
57
64
  e && (e.scrollTop = 0);
58
- }, []), Y = t(() => ({
65
+ }, []), I = t(() => ({
59
66
  stickToBottom: l ? u : null,
60
67
  scrollToTop: C,
61
68
  get atVerticalStart() {
@@ -70,39 +77,39 @@ function St({
70
77
  get atHorizontalEnd() {
71
78
  return n.current.atHorizontalEnd;
72
79
  }
73
- }), [n, C, l, u]), q = t(() => v(f, S, b), [S, b]), G = t(() => v(d, R), [d, R]);
74
- return /* @__PURE__ */ m(Q, {
75
- value: Y,
76
- children: /* @__PURE__ */ tt(X, {
77
- ...M,
80
+ }), [n, C, l, u]), Y = t(() => v(f, S, b), [S, b]), q = t(() => v(d, R), [d, R]);
81
+ return /* @__PURE__ */ m(N, {
82
+ value: I,
83
+ children: /* @__PURE__ */ $(W, {
84
+ ...A,
78
85
  ref: H,
79
86
  rootRef: o.rootRef,
80
87
  className: V,
81
88
  vertical: s,
82
89
  horizontal: i,
83
- edgeFade: A,
90
+ edgeFade: j,
84
91
  rootPointerHandlers: o.rootPointerHandlers,
85
- children: [/* @__PURE__ */ m(Z, {
86
- ref: q,
87
- contentRef: G,
88
- containerClass: J(l && U.containerStickToBottom, x),
92
+ children: [/* @__PURE__ */ m(X, {
93
+ ref: Y,
94
+ contentRef: q,
95
+ containerClass: G(l && Q.containerStickToBottom, x),
89
96
  contentClass: k,
90
97
  onScroll: p ? (e) => {
91
98
  p(e.nativeEvent);
92
99
  } : void 0,
93
- children: B
94
- }), /* @__PURE__ */ m(W, {
100
+ children: w
101
+ }), /* @__PURE__ */ m(U, {
95
102
  vertical: s,
96
103
  horizontal: i,
97
104
  setScrollbarV: o.setScrollbarV,
98
105
  setScrollbarH: o.setScrollbarH,
99
106
  onPointerDown: o.handlePointerDown
100
- }), D]
107
+ }), B]
101
108
  })
102
109
  });
103
110
  }
104
111
  export {
105
112
  E as SCROLLABLE_OVERLAY_SLOT,
106
- St as Scrollable
113
+ mt as Scrollable
107
114
  };
108
115
  //# sourceMappingURL=Scrollable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Scrollable.js","sources":["../../src/Scrollable/Scrollable.tsx"],"sourcesContent":["import { cn, mergeRefs } from '@reforma/lib';\nimport { useCallback, useMemo, useRef } from 'react';\n\nimport { useStickToBottom } from '../hooks/useStickToBottom';\nimport { filterSlots } from '../Slot';\nimport { ScrollableContext } from './scrollable-context';\nimport styles from './Scrollable.module.css';\nimport { elementScrollAxisSource } from './scrollAxisSource';\nimport { ScrollChromeBars } from './ScrollChromeBars';\nimport { ScrollChromeRoot } from './ScrollChromeRoot';\nimport { ScrollContainer } from './ScrollContainer';\nimport { useScrollChrome } from './useScrollChrome';\n\nimport type { HTMLAttributes, ReactNode, Ref } from 'react';\nimport type { StickToBottomOptions } from '../hooks/useStickToBottom';\nimport type { ScrollableContextValue } from './scrollable-context';\n\n/** `slot` value for children rendered in the overlay layer (with {@link useScrollable}), same pattern as {@link filterSlots}. */\nexport const SCROLLABLE_OVERLAY_SLOT = 'overlay';\n\nexport type ScrollableProps = {\n children?: React.ReactNode;\n\n ref?: Ref<HTMLDivElement | null>;\n containerRef?: Ref<HTMLDivElement | null>;\n contentRef?: Ref<HTMLDivElement | null>;\n\n className?: string;\n containerClass?: string;\n contentClass?: string;\n\n /**\n * Optional overlay region after the scroll container, inside `useScrollable` context.\n * Prefer a child with `slot={SCROLLABLE_OVERLAY_SLOT}` (see {@link filterSlots}); this prop overrides that slot when set.\n */\n overlay?: React.ReactNode;\n poolingInterval?: number;\n onScroll?: (e: Event) => void;\n alwaysShowScrollbar?: boolean;\n vertical?: boolean;\n horizontal?: boolean;\n gap?: number;\n /**\n * Stick-to-bottom for the scrollport.\n * The hook always mounts; refs are always attached. Activity is controlled by `enabled`:\n * - `false` — inert (`enabled: false`), `useScrollable().stickToBottom` is `null`\n * - `true` / options — active; pause with `enabled: false` or `setEnabled(false)` without tearing down refs\n */\n stickToBottom?: boolean | StickToBottomOptions;\n edgeFade?: boolean;\n} & Omit<React.HTMLAttributes<HTMLDivElement>, 'onScroll'>;\n\n/**\n * Custom scroll container with optional stick-to-bottom.\n *\n * The **root** element exposes scroll-edge hints when the corresponding axis is enabled:\n * - Vertical: `data-scroll-v-start`, `data-scroll-v-end` (near top / bottom).\n * - Horizontal: `data-scroll-h-start`, `data-scroll-h-end` (near left / right).\n * Values are booleans in React; in the DOM they appear as `\"true\"` / `\"false\"`.\n * The same flags are available from {@link useScrollable}.\n * Overlay UI: pass a child with `slot={SCROLLABLE_OVERLAY_SLOT}`, or use the `overlay` prop.\n */\nexport function Scrollable({\n ref: userRef,\n children,\n className,\n containerClass,\n contentClass,\n containerRef,\n contentRef,\n overlay,\n onScroll,\n alwaysShowScrollbar,\n vertical,\n horizontal,\n poolingInterval,\n gap = 0,\n stickToBottom = false,\n edgeFade = false,\n ...attrs\n}: ScrollableProps) {\n const overlayFromSlot = useMemo(\n (): ReactNode => filterSlots(children, SCROLLABLE_OVERLAY_SLOT),\n [children]\n );\n\n const scrollChildren = useMemo(\n (): ReactNode => filterSlots(\n children,\n slot => slot !== SCROLLABLE_OVERLAY_SLOT,\n null\n ),\n [children]\n );\n\n const overlayResolved = overlay ?? overlayFromSlot;\n\n const scrollContainerRef = useRef<HTMLDivElement>(null);\n\n const getScrollElement = useCallback(\n () => scrollContainerRef.current,\n []\n );\n\n const isVerticalEnabled = vertical ?? true;\n const isHorizontalEnabled = horizontal ?? false;\n\n const verticalSource = useMemo(\n () => (isVerticalEnabled ? elementScrollAxisSource(getScrollElement, 'vertical') : null),\n [getScrollElement, isVerticalEnabled]\n );\n\n const horizontalSource = useMemo(\n () => (isHorizontalEnabled ? elementScrollAxisSource(getScrollElement, 'horizontal') : null),\n [getScrollElement, isHorizontalEnabled]\n );\n\n const chrome = useScrollChrome({\n verticalSource,\n horizontalSource,\n gap,\n alwaysShowScrollbar,\n poolingInterval,\n });\n\n // Hook always runs (Rules of Hooks). Behavior is gated by `enabled`, not by omitting refs:\n // - `false` → enabled: false (inert listeners, no pin, context null)\n // - `true` / options → active (options.enabled can still pause at runtime)\n const stickConfigured = stickToBottom !== false;\n const stickToBottomHookOptions = useMemo((): StickToBottomOptions => {\n if (!stickConfigured) {\n return { enabled: false, initial: false };\n }\n\n if (typeof stickToBottom === 'object' && stickToBottom !== null) {\n return {\n resize: 'instant',\n ...stickToBottom,\n enabled: stickToBottom.enabled !== false,\n };\n }\n\n return { enabled: true, initial: 'instant', resize: 'instant' };\n }, [stickConfigured, stickToBottom]);\n\n const stickToBottomInstance = useStickToBottom(stickToBottomHookOptions);\n const { scrollRef: stickScrollRef, contentRef: stickContentRef } = stickToBottomInstance;\n\n const { edgesRef } = chrome;\n\n const scrollToTop = useCallback(() => {\n const el = scrollContainerRef.current;\n\n if (el) {\n el.scrollTop = 0;\n }\n }, []);\n\n const scrollableContextValue = useMemo<ScrollableContextValue>(\n () => ({\n stickToBottom: stickConfigured ? stickToBottomInstance : null,\n scrollToTop,\n get atVerticalStart() {\n return edgesRef.current.atVerticalStart;\n },\n get atVerticalEnd() {\n return edgesRef.current.atVerticalEnd;\n },\n get atHorizontalStart() {\n return edgesRef.current.atHorizontalStart;\n },\n get atHorizontalEnd() {\n return edgesRef.current.atHorizontalEnd;\n },\n }),\n [edgesRef, scrollToTop, stickConfigured, stickToBottomInstance]\n );\n\n // mergeRefs() returns a new callback every call — memoize so React does not\n // detach/reattach stick listeners on every parent render (e.g. isAtBottom flips).\n const containerMergedRef = useMemo(\n () => mergeRefs<HTMLDivElement>(scrollContainerRef, containerRef, stickScrollRef),\n [containerRef, stickScrollRef]\n );\n\n const contentMergedRef = useMemo(\n () => mergeRefs<HTMLDivElement>(contentRef, stickContentRef),\n [contentRef, stickContentRef]\n );\n\n return (\n <ScrollableContext value={ scrollableContextValue }>\n <ScrollChromeRoot\n { ...attrs as HTMLAttributes<HTMLDivElement> }\n ref={ userRef }\n rootRef={ chrome.rootRef }\n className={ className }\n vertical={ isVerticalEnabled }\n horizontal={ isHorizontalEnabled }\n edgeFade={ edgeFade }\n rootPointerHandlers={ chrome.rootPointerHandlers }\n >\n <ScrollContainer\n ref={ containerMergedRef }\n contentRef={ contentMergedRef }\n containerClass={ cn(\n stickConfigured && styles.containerStickToBottom,\n containerClass\n ) }\n contentClass={ contentClass }\n onScroll={ onScroll\n ? (e) => {\n onScroll(e.nativeEvent);\n }\n : undefined }\n >\n { scrollChildren }\n </ScrollContainer>\n\n <ScrollChromeBars\n vertical={ isVerticalEnabled }\n horizontal={ isHorizontalEnabled }\n setScrollbarV={ chrome.setScrollbarV }\n setScrollbarH={ chrome.setScrollbarH }\n onPointerDown={ chrome.handlePointerDown }\n />\n\n { overlayResolved }\n </ScrollChromeRoot>\n </ScrollableContext>\n );\n}\n"],"names":["SCROLLABLE_OVERLAY_SLOT","Scrollable","userRef","children","className","containerClass","contentClass","containerRef","contentRef","overlay","onScroll","alwaysShowScrollbar","vertical","horizontal","poolingInterval","gap","stickToBottom","edgeFade","attrs","overlayFromSlot","useMemo","filterSlots","scrollChildren","slot","overlayResolved","scrollContainerRef","useRef","getScrollElement","useCallback","isVerticalEnabled","isHorizontalEnabled","verticalSource","elementScrollAxisSource","horizontalSource","chrome","useScrollChrome","stickConfigured","stickToBottomHookOptions","stickToBottomInstance","useStickToBottom","stickScrollRef","stickContentRef","edgesRef","scrollToTop","el","scrollableContextValue","containerMergedRef","mergeRefs","contentMergedRef","ScrollableContext","ScrollChromeRoot","_jsx","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AA,MACA,UAAUyB;AAAA,MACV,YAAYC;AAAA,MACZ,UAAAb;AAAA,MACA,qBAAqBiB,EAAO;AAAA,MAC5B,UAAU,CAAciB,gBAAAA,EAAKC,GAAiB;AAAA,QAC5C,KAAKN;AAAA,QACL,YAAYE;AAAA,QACZ,gBAAgBK,EAAGjB,KAAmBkB,EAAO,wBAAwBjD,CAAc;AAAA,QACnF,cAAAC;AAAA,QACA,UAAUI,IAAW,CAAA,MAAK;AACxB,UAAAA,EAAS,EAAE,WAAW;AAAA,QACxB,IAAI;AAAA,QACJ,UAAUY;AAAA,MAAA,CACX,GAAgB6B,gBAAAA,EAAKI,GAAkB;AAAA,QACtC,UAAU1B;AAAA,QACV,YAAYC;AAAA,QACZ,eAAeI,EAAO;AAAA,QACtB,eAAeA,EAAO;AAAA,QACtB,eAAeA,EAAO;AAAA,MAAA,CACvB,GAAGV,CAAe;AAAA,IAAA,CACpB;AAAA,EAAA,CACF;AACH;"}
1
+ {"version":3,"file":"Scrollable.js","sources":["../../src/Scrollable/Scrollable.tsx"],"sourcesContent":["import { cn, mergeRefs } from '@reforma/lib';\nimport { useCallback, useMemo, useRef } from 'react';\n\nimport { useStickToBottom } from '../hooks/useStickToBottom';\nimport { filterSlots } from '../Slot';\nimport { ScrollableContext } from './scrollable-context';\nimport styles from './Scrollable.module.css';\nimport { elementScrollAxisSource } from './scrollAxisSource';\nimport { ScrollChromeBars } from './ScrollChromeBars';\nimport { ScrollChromeRoot } from './ScrollChromeRoot';\nimport { ScrollContainer } from './ScrollContainer';\nimport { useScrollChrome } from './useScrollChrome';\n\nimport type { HTMLAttributes, ReactNode, Ref } from 'react';\nimport type { StickToBottomOptions } from '../hooks/useStickToBottom';\nimport type { ScrollableContextValue } from './scrollable-context';\n\n/** `slot` value for children rendered in the overlay layer (with {@link useScrollable}), same pattern as {@link filterSlots}. */\nexport const SCROLLABLE_OVERLAY_SLOT = 'overlay';\n\nexport type ScrollableProps = {\n children?: React.ReactNode;\n\n ref?: Ref<HTMLDivElement | null>;\n containerRef?: Ref<HTMLDivElement | null>;\n contentRef?: Ref<HTMLDivElement | null>;\n\n className?: string;\n containerClass?: string;\n contentClass?: string;\n\n /**\n * Optional overlay region after the scroll container, inside `useScrollable` context.\n * Prefer a child with `slot={SCROLLABLE_OVERLAY_SLOT}` (see {@link filterSlots}); this prop overrides that slot when set.\n */\n overlay?: React.ReactNode;\n onScroll?: (e: Event) => void;\n alwaysShowScrollbar?: boolean;\n vertical?: boolean;\n horizontal?: boolean;\n gap?: number;\n /**\n * Stick-to-bottom for the scrollport.\n * The hook always mounts; refs are always attached. Activity is controlled by `enabled`:\n * - `false` — inert (`enabled: false`), `useScrollable().stickToBottom` is `null`\n * - `true` / options — active; pause with `enabled: false` or `setEnabled(false)` without tearing down refs\n */\n stickToBottom?: boolean | StickToBottomOptions;\n edgeFade?: boolean;\n} & Omit<React.HTMLAttributes<HTMLDivElement>, 'onScroll'>;\n\n/**\n * Custom scroll container with optional stick-to-bottom.\n *\n * The **root** element exposes scroll-edge hints when the corresponding axis is enabled:\n * - Vertical: `data-scroll-v-start`, `data-scroll-v-end` (near top / bottom).\n * - Horizontal: `data-scroll-h-start`, `data-scroll-h-end` (near left / right).\n * Values are booleans in React; in the DOM they appear as `\"true\"` / `\"false\"`.\n * The same flags are available from {@link useScrollable}.\n * Overlay UI: pass a child with `slot={SCROLLABLE_OVERLAY_SLOT}`, or use the `overlay` prop.\n */\nexport function Scrollable({\n ref: userRef,\n children,\n className,\n containerClass,\n contentClass,\n containerRef,\n contentRef,\n overlay,\n onScroll,\n alwaysShowScrollbar,\n vertical,\n horizontal,\n gap = 0,\n stickToBottom = false,\n edgeFade = false,\n ...attrs\n}: ScrollableProps) {\n const overlayFromSlot = useMemo(\n (): ReactNode => filterSlots(children, SCROLLABLE_OVERLAY_SLOT),\n [children]\n );\n\n const scrollChildren = useMemo(\n (): ReactNode => filterSlots(\n children,\n slot => slot !== SCROLLABLE_OVERLAY_SLOT,\n null\n ),\n [children]\n );\n\n const overlayResolved = overlay ?? overlayFromSlot;\n\n const scrollContainerRef = useRef<HTMLDivElement>(null);\n\n const getScrollElement = useCallback(\n () => scrollContainerRef.current,\n []\n );\n\n const isVerticalEnabled = vertical ?? true;\n const isHorizontalEnabled = horizontal ?? false;\n\n const verticalSource = useMemo(\n // The getter is stored and called from effects, not during render.\n // eslint-disable-next-line react-hooks/refs -- elementScrollAxisSource does not read `.current` now\n () => (isVerticalEnabled ? elementScrollAxisSource(getScrollElement, 'vertical') : null),\n [getScrollElement, isVerticalEnabled]\n );\n\n const horizontalSource = useMemo(\n // eslint-disable-next-line react-hooks/refs -- elementScrollAxisSource does not read `.current` now\n () => (isHorizontalEnabled ? elementScrollAxisSource(getScrollElement, 'horizontal') : null),\n [getScrollElement, isHorizontalEnabled]\n );\n\n const chrome = useScrollChrome({\n verticalSource,\n horizontalSource,\n gap,\n alwaysShowScrollbar,\n });\n\n // Hook always runs (Rules of Hooks). Behavior is gated by `enabled`, not by omitting refs:\n // - `false` → enabled: false (inert listeners, no pin, context null)\n // - `true` / options → active (options.enabled can still pause at runtime)\n const stickConfigured = stickToBottom !== false;\n const stickToBottomHookOptions = useMemo((): StickToBottomOptions => {\n if (!stickConfigured) {\n return { enabled: false, initial: false };\n }\n\n if (typeof stickToBottom === 'object' && stickToBottom !== null) {\n return {\n resize: 'instant',\n ...stickToBottom,\n enabled: stickToBottom.enabled !== false,\n };\n }\n\n return { enabled: true, initial: 'instant', resize: 'instant' };\n }, [stickConfigured, stickToBottom]);\n\n const stickToBottomInstance = useStickToBottom(stickToBottomHookOptions);\n const { scrollRef: stickScrollRef, contentRef: stickContentRef } = stickToBottomInstance;\n\n const { edgesRef } = chrome;\n\n const scrollToTop = useCallback(() => {\n const el = scrollContainerRef.current;\n\n if (el) {\n el.scrollTop = 0;\n }\n }, []);\n\n const scrollableContextValue = useMemo<ScrollableContextValue>(\n () => ({\n stickToBottom: stickConfigured ? stickToBottomInstance : null,\n scrollToTop,\n get atVerticalStart() {\n return edgesRef.current.atVerticalStart;\n },\n get atVerticalEnd() {\n return edgesRef.current.atVerticalEnd;\n },\n get atHorizontalStart() {\n return edgesRef.current.atHorizontalStart;\n },\n get atHorizontalEnd() {\n return edgesRef.current.atHorizontalEnd;\n },\n }),\n [edgesRef, scrollToTop, stickConfigured, stickToBottomInstance]\n );\n\n // mergeRefs() returns a new callback every call — memoize so React does not\n // detach/reattach stick listeners on every parent render (e.g. isAtBottom flips).\n const containerMergedRef = useMemo(\n () => mergeRefs<HTMLDivElement>(scrollContainerRef, containerRef, stickScrollRef),\n [containerRef, stickScrollRef]\n );\n\n const contentMergedRef = useMemo(\n () => mergeRefs<HTMLDivElement>(contentRef, stickContentRef),\n [contentRef, stickContentRef]\n );\n\n return (\n <ScrollableContext value={ scrollableContextValue }>\n <ScrollChromeRoot\n { ...attrs as HTMLAttributes<HTMLDivElement> }\n ref={ userRef }\n rootRef={ chrome.rootRef }\n className={ className }\n vertical={ isVerticalEnabled }\n horizontal={ isHorizontalEnabled }\n edgeFade={ edgeFade }\n rootPointerHandlers={ chrome.rootPointerHandlers }\n >\n <ScrollContainer\n ref={ containerMergedRef }\n contentRef={ contentMergedRef }\n containerClass={ cn(\n stickConfigured && styles.containerStickToBottom,\n containerClass\n ) }\n contentClass={ contentClass }\n onScroll={ onScroll\n ? (e) => {\n onScroll(e.nativeEvent);\n }\n : undefined }\n >\n { scrollChildren }\n </ScrollContainer>\n\n <ScrollChromeBars\n vertical={ isVerticalEnabled }\n horizontal={ isHorizontalEnabled }\n setScrollbarV={ chrome.setScrollbarV }\n setScrollbarH={ chrome.setScrollbarH }\n onPointerDown={ chrome.handlePointerDown }\n />\n\n { overlayResolved }\n </ScrollChromeRoot>\n </ScrollableContext>\n );\n}\n"],"names":["SCROLLABLE_OVERLAY_SLOT","Scrollable","userRef","children","className","containerClass","contentClass","containerRef","contentRef","overlay","onScroll","alwaysShowScrollbar","vertical","horizontal","gap","stickToBottom","edgeFade","attrs","overlayFromSlot","useMemo","filterSlots","scrollChildren","slot","overlayResolved","scrollContainerRef","useRef","getScrollElement","useCallback","isVerticalEnabled","isHorizontalEnabled","verticalSource","elementScrollAxisSource","horizontalSource","chrome","useScrollChrome","stickConfigured","stickToBottomHookOptions","stickToBottomInstance","useStickToBottom","stickScrollRef","stickContentRef","edgesRef","scrollToTop","el","scrollableContextValue","containerMergedRef","mergeRefs","contentMergedRef","ScrollableContext","ScrollChromeRoot","_jsx","ScrollContainer","cn","styles","ScrollChromeBars"],"mappings":";;;;;;;;;;;;AAaO,MAAMA,IAA0B;AAWhC,SAASC,GAAW;AAAA,EACzB,KAAKC;AAAA,EACL,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC;AAAA,EACA,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,KAAAC,IAAM;AAAA,EACN,eAAAC,IAAgB;AAAA,EAChB,UAAAC,IAAW;AAAA,EACX,GAAGC;AACL,GAAG;AACD,QAAMC,IAAkBC,EAAQ,MAAMC,EAAYjB,GAAUH,CAAuB,GAAG,CAACG,CAAQ,CAAC,GAC1FkB,IAAiBF,EAAQ,MAAMC,EAAYjB,GAAU,CAAAmB,MAAQA,MAAStB,GAAyB,IAAI,GAAG,CAACG,CAAQ,CAAC,GAChHoB,IAAkBd,KAAWS,GAC7BM,IAAqBC,EAAO,IAAI,GAChCC,IAAmBC,EAAY,MAAMH,EAAmB,SAAS,CAAA,CAAE,GACnEI,IAAoBhB,KAAY,IAChCiB,IAAsBhB,KAAc,IACpCiB,IAAiBX;AAAA;AAAA;AAAA,IAGvB,MAAMS,IAAoBG,EAAwBL,GAAkB,UAAU,IAAI;AAAA,IAAM,CAACA,GAAkBE,CAAiB;AAAA,EAAA,GACtHI,IAAmBb;AAAA;AAAA,IAEzB,MAAMU,IAAsBE,EAAwBL,GAAkB,YA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Ac,GAAG,CAAChC,GAAcgC,CAAc,CAAC,GAC9HQ,IAAmB5B,EAAQ,MAAM2B,EAAUtC,GAAYgC,CAAe,GAAG,CAAChC,GAAYgC,CAAe,CAAC;AAC5G,2BAAyBQ,GAAmB;AAAA,IAC1C,OAAOJ;AAAA,IACP,4BAA6BK,GAAkB;AAAA,MAC7C,GAAGhC;AAAA,MACH,KAAKf;AAAA,MACL,SAAS+B,EAAO;AAAA,MAChB,WAAA7B;AAAA,MACA,UAAUwB;AAAA,MACV,YAAYC;AAAA,MACZ,UAAAb;AAAA,MACA,qBAAqBiB,EAAO;AAAA,MAC5B,UAAU,CAAciB,gBAAAA,EAAKC,GAAiB;AAAA,QAC5C,KAAKN;AAAA,QACL,YAAYE;AAAA,QACZ,gBAAgBK,EAAGjB,KAAmBkB,EAAO,wBAAwBhD,CAAc;AAAA,QACnF,cAAAC;AAAA,QACA,UAAUI,IAAW,CAAA,MAAK;AACxB,UAAAA,EAAS,EAAE,WAAW;AAAA,QACxB,IAAI;AAAA,QACJ,UAAUW;AAAA,MAAA,CACX,GAAgB6B,gBAAAA,EAAKI,GAAkB;AAAA,QACtC,UAAU1B;AAAA,QACV,YAAYC;AAAA,QACZ,eAAeI,EAAO;AAAA,QACtB,eAAeA,EAAO;AAAA,QACtB,eAAeA,EAAO;AAAA,MAAA,CACvB,GAAGV,CAAe;AAAA,IAAA,CACpB;AAAA,EAAA,CACF;AACH;"}
@@ -15,7 +15,6 @@ export type UseScrollChromeOptions = {
15
15
  sourceKey?: unknown;
16
16
  gap?: number;
17
17
  alwaysShowScrollbar?: boolean;
18
- poolingInterval?: number;
19
18
  };
20
19
  export type UseScrollChromeResult = {
21
20
  rootRef: React.RefObject<HTMLDivElement | null>;
@@ -34,5 +33,5 @@ export type UseScrollChromeResult = {
34
33
  * Custom scrollbar chrome driven by direct DOM updates — no React state on scroll.
35
34
  * Shared by {@link Scrollable} and app-local scroll chrome (e.g. layers tree, frame page).
36
35
  */
37
- export declare function useScrollChrome({ verticalSource, horizontalSource, sourceKey, gap, alwaysShowScrollbar, poolingInterval, }: UseScrollChromeOptions): UseScrollChromeResult;
36
+ export declare function useScrollChrome({ verticalSource, horizontalSource, sourceKey, gap, alwaysShowScrollbar, }: UseScrollChromeOptions): UseScrollChromeResult;
38
37
  //# sourceMappingURL=useScrollChrome.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useScrollChrome.d.ts","sourceRoot":"","sources":["../../src/Scrollable/useScrollChrome.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,MAAM,iBAAiB,GAAG;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACjC,cAAc,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACzC,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC3C;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAChC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAChD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAC7C,aAAa,EAAE,CAAC,EAAE,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,CAAC;IACnD,aAAa,EAAE,CAAC,EAAE,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,CAAC;IACnD,6EAA6E;IAC7E,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,iBAA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AK,IAAI,CAAC;IACnD,6EAA6E;IAC7E,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,iBAAiB,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,YAAY,KAAK,IAAI,CAAC;IACnD,mBAAmB,EAAE;QACjB,cAAc,EAAE,MAAM,IAAI,CAAC;QAC3B,cAAc,EAAE,MAAM,IAAI,CAAC;KAC9B,CAAC;CACL,CAAC;AAuFF;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC5B,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,GAAO,EACP,mBAAmB,GACtB,EAAE,sBAAsB,GAAG,qBAAqB,CA0ShD"}
@@ -1,177 +1,192 @@
1
- import { useRef as a, useCallback as g, useMemo as q, useLayoutEffect as L, useEffect as C } from "react";
1
+ import { useRef as p, useCallback as h, useMemo as X, useLayoutEffect as C, useEffect as Y } from "react";
2
2
  import H from "./Scrollable.module.css.js";
3
- const N = {
3
+ const _ = {
4
4
  start: "atVerticalStart",
5
5
  end: "atVerticalEnd",
6
6
  startAttr: "data-scroll-v-start",
7
7
  endAttr: "data-scroll-v-end",
8
8
  showAttr: "data-scroll-show-v"
9
- }, Z = {
9
+ }, $ = {
10
10
  start: "atHorizontalStart",
11
11
  end: "atHorizontalEnd",
12
12
  startAttr: "data-scroll-h-start",
13
13
  endAttr: "data-scroll-h-end",
14
14
  showAttr: "data-scroll-show-h"
15
15
  };
16
- function I(n, o, c) {
17
- o[c.start] = !1, o[c.end] = !1, n && (n.removeAttribute(c.startAttr), n.removeAttribute(c.endAttr), n.removeAttribute(c.showAttr));
16
+ function x(r, c, i) {
17
+ c[i.start] = !1, c[i.end] = !1, r && (r.removeAttribute(i.startAttr), r.removeAttribute(i.endAttr), r.removeAttribute(i.showAttr));
18
18
  }
19
- function x(n, o, c, m, b, l, z) {
20
- if (!o) {
21
- I(n, b, l);
19
+ function I(r, c, i, d, m, S) {
20
+ if (!c) {
21
+ x(r, d, m);
22
22
  return;
23
23
  }
24
- const p = o.getMetrics();
25
- if (!p || p.clientSize <= 0 || p.scrollSize <= 0) {
26
- I(n, b, l);
24
+ const A = c.getMetrics();
25
+ if (!A || A.clientSize <= 0 || A.scrollSize <= 0) {
26
+ x(r, d, m);
27
27
  return;
28
28
  }
29
29
  const {
30
- offset: S,
31
- scrollSize: h,
32
- clientSize: A
33
- } = p, R = 1, f = z / A * 100, w = A / h * 100 - f * 2, O = S / h * 100 + f, i = w < 100 - f * 2, v = i ? S <= R : !0, E = i ? S + A >= h - R : !0;
34
- m.current = h, c && (c.style.setProperty("--ms-thumb-length", `${w}%`), c.style.setProperty("--ms-thumb-offset", `${O}%`)), b[l.start] = v, b[l.end] = E, n && (n.setAttribute(l.startAttr, String(v)), n.setAttribute(l.endAttr, String(E)), n.setAttribute(l.showAttr, i ? "true" : "false"));
30
+ offset: E,
31
+ scrollSize: O,
32
+ clientSize: g
33
+ } = A, b = 1, v = S / g * 100, w = g / O * 100 - v * 2, R = E / O * 100 + v, D = w < 100 - v * 2, f = D ? E <= b : !0, l = D ? E + g >= O - b : !0;
34
+ i && (i.style.setProperty("--ms-thumb-length", `${w}%`), i.style.setProperty("--ms-thumb-offset", `${R}%`)), d[m.start] = f, d[m.end] = l, r && (r.setAttribute(m.startAttr, String(f)), r.setAttribute(m.endAttr, String(l)), r.setAttribute(m.showAttr, D ? "true" : "false"));
35
35
  }
36
- function Q({
37
- verticalSource: n,
38
- horizontalSource: o,
39
- sourceKey: c,
40
- gap: m = 0,
41
- alwaysShowScrollbar: b,
42
- poolingInterval: l
36
+ function Z({
37
+ verticalSource: r,
38
+ horizontalSource: c,
39
+ sourceKey: i,
40
+ gap: d = 0,
41
+ alwaysShowScrollbar: m
43
42
  }) {
44
- const z = a(null), p = a(null), S = a(null), h = a({
43
+ const S = p(null), A = p(null), E = p(null), O = p({
45
44
  atVerticalStart: !0,
46
45
  atVerticalEnd: !0,
47
46
  atHorizontalStart: !0,
48
47
  atHorizontalEnd: !0
49
- }), A = a(null), R = a(!1), f = a(null), w = a(0), O = a(0), i = a({
48
+ }), g = p(null), b = p({
50
49
  hovered: !1,
51
50
  dragging: !1
52
- }), v = a(n), E = a(o);
53
- v.current = n, E.current = o;
54
- const F = g((t) => {
55
- p.current = t;
56
- }, []), G = g((t) => {
57
- S.current = t;
58
- }, []), d = g(() => {
59
- const t = z.current;
51
+ }), v = p(r), w = p(c);
52
+ v.current = r, w.current = c;
53
+ const R = h((t) => {
54
+ A.current = t;
55
+ }, []), D = h((t) => {
56
+ E.current = t;
57
+ }, []), f = h(() => {
58
+ const t = S.current;
60
59
  if (!t)
61
60
  return;
62
61
  const {
63
62
  hovered: e,
64
- dragging: s
65
- } = i.current;
66
- t.classList.toggle(H.hover, b || e), t.classList.toggle(H.inDrag, s);
67
- }, [b]), u = g(() => {
68
- R.current = !1;
69
- const t = z.current, e = h.current;
70
- x(t, v.current, p.current, w, e, N, m), x(t, E.current, S.current, O, e, Z, m);
71
- }, [m]), M = g((t, e) => {
72
- const s = e ? v.current : E.current, r = s?.getMetrics();
73
- !s || !r || r.clientSize <= 0 || (t.preventDefault(), t.stopPropagation(), f.current = {
74
- source: s,
63
+ dragging: n
64
+ } = b.current;
65
+ t.classList.toggle(H.hover, m || e), t.classList.toggle(H.inDrag, n);
66
+ }, [m]), l = h(() => {
67
+ const t = S.current, e = O.current;
68
+ I(t, v.current, A.current, e, _, d), I(t, w.current, E.current, e, $, d);
69
+ }, [d]), V = h((t, e) => {
70
+ const n = e ? v.current : w.current, s = n?.getMetrics();
71
+ !n || !s || s.clientSize <= 0 || (t.preventDefault(), t.stopPropagation(), g.current = {
72
+ source: n,
75
73
  isVertical: e,
76
- fromScrollOffset: r.offset,
77
- fromScrollSize: r.scrollSize,
74
+ fromScrollOffset: s.offset,
75
+ fromScrollSize: s.scrollSize,
78
76
  fromOffset: e ? t.screenY : t.screenX,
79
- totalDistance: r.clientSize - m * 2
77
+ totalDistance: s.clientSize - d * 2
80
78
  });
81
- }, [m]), P = g((t) => {
82
- const e = f.current;
79
+ }, [d]), L = h((t) => {
80
+ const e = g.current;
83
81
  if (!e || e.totalDistance === 0)
84
82
  return;
85
83
  t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation();
86
84
  const {
87
- source: s,
88
- isVertical: r,
89
- fromOffset: D,
90
- fromScrollOffset: X,
91
- fromScrollSize: Y,
92
- totalDistance: _
93
- } = e, $ = ((r ? t.screenY : t.screenX) - D) / _;
94
- s.setOffset(X + Y * $);
95
- }, []), V = g((t) => {
96
- t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation(), f.current = null;
97
- }, []), T = g((t) => {
85
+ source: n,
86
+ isVertical: s,
87
+ fromOffset: u,
88
+ fromScrollOffset: a,
89
+ fromScrollSize: o,
90
+ totalDistance: P
91
+ } = e, T = ((s ? t.screenY : t.screenX) - u) / P;
92
+ n.setOffset(a + o * T);
93
+ }, []), M = h((t) => {
94
+ t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation(), g.current = null;
95
+ }, []), F = h((t) => {
98
96
  const e = t.target.classList.contains(H.scrollbarV);
99
- M(t, e), i.current.dragging = !0, d();
100
- const s = new AbortController();
101
- document.addEventListener("pointermove", (r) => {
102
- P(r);
97
+ V(t, e), b.current.dragging = !0, f();
98
+ const n = new AbortController();
99
+ document.addEventListener("pointermove", (s) => {
100
+ L(s);
103
101
  }, {
104
- signal: s.signal,
102
+ signal: n.signal,
105
103
  capture: !0
106
- }), document.addEventListener("pointerup", (r) => {
107
- s.abort(), P(r), V(r), i.current.dragging = !1, d();
104
+ }), document.addEventListener("pointerup", (s) => {
105
+ n.abort(), L(s), M(s), b.current.dragging = !1, f();
108
106
  }, {
109
- signal: s.signal,
107
+ signal: n.signal,
110
108
  capture: !0
111
109
  });
112
- }, [M, P, V, d]), U = q(() => ({
110
+ }, [V, L, M, f]), G = X(() => ({
113
111
  onPointerEnter: () => {
114
- i.current.hovered = !0, d();
112
+ b.current.hovered = !0, f();
115
113
  },
116
114
  onPointerLeave: () => {
117
- i.current.hovered = !1, d();
115
+ b.current.hovered = !1, f();
118
116
  }
119
- }), [d]);
120
- return L(() => {
121
- d();
122
- }, [d]), L(() => {
123
- u();
124
- }, [u, c, n, o]), L(() => {
117
+ }), [f]);
118
+ return C(() => {
119
+ f();
120
+ }, [f]), C(() => {
121
+ l();
122
+ }, [l, i, r, c]), C(() => {
125
123
  if (typeof ResizeObserver > "u")
126
124
  return;
127
- const t = /* @__PURE__ */ new Set(), e = new ResizeObserver(() => u());
128
- for (const s of [n, o]) {
129
- const r = s?.getObserveElement?.();
130
- r && !t.has(r) && (t.add(r), e.observe(r));
125
+ const t = /* @__PURE__ */ new Set(), e = new ResizeObserver(() => l()), n = [], s = () => {
126
+ const a = /* @__PURE__ */ new Set();
127
+ for (const o of [r, c]) {
128
+ const P = o?.getObserveElement?.();
129
+ if (!P)
130
+ continue;
131
+ a.add(P);
132
+ const z = P.firstElementChild;
133
+ z && a.add(z);
134
+ }
135
+ for (const o of t)
136
+ a.has(o) || (e.unobserve(o), t.delete(o));
137
+ for (const o of a)
138
+ t.has(o) || (t.add(o), e.observe(o));
139
+ };
140
+ s();
141
+ for (const a of [r, c]) {
142
+ const o = a?.getObserveElement?.();
143
+ o && !n.includes(o) && n.push(o);
131
144
  }
145
+ const u = typeof MutationObserver > "u" ? null : new MutationObserver(() => {
146
+ s(), l();
147
+ });
148
+ for (const a of n)
149
+ u?.observe(a, {
150
+ childList: !0
151
+ });
132
152
  if (t.size === 0) {
133
- e.disconnect();
153
+ e.disconnect(), u?.disconnect();
134
154
  return;
135
155
  }
136
156
  return () => {
137
- e.disconnect();
157
+ e.disconnect(), u?.disconnect();
138
158
  };
139
- }, [u, c, n, o]), C(() => {
140
- const t = [], e = /* @__PURE__ */ new Set(), s = () => {
141
- u(), requestAnimationFrame(() => {
142
- R.current = !0;
143
- });
159
+ }, [l, i, r, c]), Y(() => {
160
+ const t = [], e = /* @__PURE__ */ new Set();
161
+ let n = 0;
162
+ const s = () => {
163
+ l(), cancelAnimationFrame(n), n = requestAnimationFrame(() => l());
144
164
  };
145
- for (const r of [n, o]) {
146
- if (!r?.subscribe)
165
+ for (const u of [r, c]) {
166
+ if (!u?.subscribe)
147
167
  continue;
148
- const D = r.getObserveElement?.();
149
- if (D) {
150
- if (e.has(D))
168
+ const a = u.getObserveElement?.();
169
+ if (a) {
170
+ if (e.has(a))
151
171
  continue;
152
- e.add(D);
172
+ e.add(a);
153
173
  }
154
- t.push(r.subscribe(s));
174
+ t.push(u.subscribe(s));
155
175
  }
156
176
  return () => {
157
- t.forEach((r) => r());
177
+ cancelAnimationFrame(n), t.forEach((u) => u()), g.current = null;
158
178
  };
159
- }, [u, c, n, o]), C(() => (A.current = setInterval(() => {
160
- const t = v.current?.getMetrics(), e = E.current?.getMetrics();
161
- (R.current || t != null && t.scrollSize !== w.current || e != null && e.scrollSize !== O.current) && u();
162
- }, l ?? 100), () => {
163
- A.current && clearInterval(A.current), f.current = null;
164
- }), [u, l]), {
165
- rootRef: z,
166
- edgesRef: h,
167
- setScrollbarV: F,
168
- setScrollbarH: G,
169
- redraw: u,
170
- handlePointerDown: T,
171
- rootPointerHandlers: U
179
+ }, [l, i, r, c]), {
180
+ rootRef: S,
181
+ edgesRef: O,
182
+ setScrollbarV: R,
183
+ setScrollbarH: D,
184
+ redraw: l,
185
+ handlePointerDown: F,
186
+ rootPointerHandlers: G
172
187
  };
173
188
  }
174
189
  export {
175
- Q as useScrollChrome
190
+ Z as useScrollChrome
176
191
  };
177
192
  //# sourceMappingURL=useScrollChrome.js.map