@octanejs/stick-to-bottom 0.0.16 → 0.0.18

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/stick-to-bottom",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "Octane binding for use-stick-to-bottom 1.1.6.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -40,11 +40,11 @@
40
40
  "./package.json": "./package.json"
41
41
  },
42
42
  "peerDependencies": {
43
- "octane": "^0.10.0"
43
+ "octane": "^0.11.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@octanejs/testing-library": "0.1.59",
47
- "octane": "0.10.0",
46
+ "@octanejs/testing-library": "0.1.61",
47
+ "octane": "0.11.0",
48
48
  "vitest": "^4.1.10"
49
49
  },
50
50
  "scripts": {
@@ -50,8 +50,7 @@ export interface StickToBottomProps extends Omit<DivProps, 'children'>, StickToB
50
50
  children: ((context: StickToBottomContext) => OctaneNode) | OctaneNode;
51
51
  }
52
52
 
53
- const useIsomorphicLayoutEffect =
54
- typeof window !== 'undefined' ? useLayoutEffect : useEffect;
53
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
55
54
 
56
55
  export function StickToBottom({
57
56
  instance,
@@ -87,35 +86,34 @@ export function StickToBottom({
87
86
  const { scrollRef, contentRef, scrollToBottom, stopScroll, isAtBottom, escapedFromLock, state } =
88
87
  instance ?? defaultInstance;
89
88
 
90
- const context = useMemo(function createContextValue(): StickToBottomContext {
91
- return {
92
- scrollToBottom,
93
- stopScroll,
94
- scrollRef,
95
- isAtBottom,
96
- escapedFromLock,
97
- contentRef,
98
- state,
99
- get targetScrollTop() {
100
- return customTargetScrollTop.current;
101
- },
102
- set targetScrollTop(next: GetTargetScrollTop | null) {
103
- customTargetScrollTop.current = next;
104
- },
105
- };
106
- }, [
107
- scrollToBottom,
108
- isAtBottom,
109
- contentRef,
110
- scrollRef,
111
- stopScroll,
112
- escapedFromLock,
113
- state,
114
- ]);
115
-
116
- useImperativeHandle(contextRef, function getContext() {
117
- return context;
118
- }, [context]);
89
+ const context = useMemo(
90
+ function createContextValue(): StickToBottomContext {
91
+ return {
92
+ scrollToBottom,
93
+ stopScroll,
94
+ scrollRef,
95
+ isAtBottom,
96
+ escapedFromLock,
97
+ contentRef,
98
+ state,
99
+ get targetScrollTop() {
100
+ return customTargetScrollTop.current;
101
+ },
102
+ set targetScrollTop(next: GetTargetScrollTop | null) {
103
+ customTargetScrollTop.current = next;
104
+ },
105
+ };
106
+ },
107
+ [scrollToBottom, isAtBottom, contentRef, scrollRef, stopScroll, escapedFromLock, state],
108
+ );
109
+
110
+ useImperativeHandle(
111
+ contextRef,
112
+ function getContext() {
113
+ return context;
114
+ },
115
+ [context],
116
+ );
119
117
 
120
118
  useIsomorphicLayoutEffect(function ensureOverflow() {
121
119
  if (!scrollRef.current) {
@@ -127,11 +125,15 @@ export function StickToBottom({
127
125
  }
128
126
  }, []);
129
127
 
130
- return <StickToBottomContext value={context}>
131
- <div {...props}>
132
- {typeof children === 'function' && !isChildrenBlock(children) ? children(context) : children}
133
- </div>
134
- </StickToBottomContext>;
128
+ return (
129
+ <StickToBottomContext value={context}>
130
+ <div {...props}>
131
+ {typeof children === 'function' && !isChildrenBlock(children)
132
+ ? children(context)
133
+ : children}
134
+ </div>
135
+ </StickToBottomContext>
136
+ );
135
137
  }
136
138
 
137
139
  export interface StickToBottomContentProps extends Omit<DivProps, 'children'> {
@@ -146,19 +148,23 @@ export function StickToBottomContent({
146
148
  }: StickToBottomContentProps) {
147
149
  const context = useStickToBottomContext();
148
150
 
149
- return <div
150
- ref={context.scrollRef}
151
- style={{
152
- height: '100%',
153
- width: '100%',
154
- scrollbarGutter: 'stable both-edges',
155
- }}
156
- className={scrollClassName}
157
- >
158
- <div {...props} ref={context.contentRef}>
159
- {typeof children === 'function' && !isChildrenBlock(children) ? children(context) : children}
151
+ return (
152
+ <div
153
+ ref={context.scrollRef}
154
+ style={{
155
+ height: '100%',
156
+ width: '100%',
157
+ scrollbarGutter: 'stable both-edges',
158
+ }}
159
+ className={scrollClassName}
160
+ >
161
+ <div {...props} ref={context.contentRef}>
162
+ {typeof children === 'function' && !isChildrenBlock(children)
163
+ ? children(context)
164
+ : children}
165
+ </div>
160
166
  </div>
161
- </div>;
167
+ );
162
168
  }
163
169
 
164
170
  StickToBottom.Content = StickToBottomContent;
@@ -166,7 +172,9 @@ StickToBottom.Content = StickToBottomContent;
166
172
  export function useStickToBottomContext(): StickToBottomContext {
167
173
  const context = useContext(StickToBottomContext);
168
174
  if (!context) {
169
- throw new Error('use-stick-to-bottom component context must be used within a StickToBottom component');
175
+ throw new Error(
176
+ 'use-stick-to-bottom component context must be used within a StickToBottom component',
177
+ );
170
178
  }
171
179
 
172
180
  return context;