reshaped 3.3.2 → 3.3.3

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.
@@ -70,7 +70,7 @@ const ScrollArea = forwardRef((props, ref) => {
70
70
  const [scrollRatio, setScrollRatio] = React.useState({ x: 1, y: 1 });
71
71
  const [scrollPosition, setScrollPosition] = React.useState({ x: 0, y: 0 });
72
72
  const scrollableRef = React.useRef(null);
73
- const resizeObserverRef = React.useRef();
73
+ const contentRef = React.useRef(null);
74
74
  const heightStyles = getHeightStyles(height);
75
75
  const maxHeightStyles = getMaxHeightStyles(maxHeight);
76
76
  const rootClassNames = classNames(s.root, scrollbarDisplay && s[`--display-${scrollbarDisplay}`], heightStyles?.classNames, maxHeightStyles?.classNames, className);
@@ -127,15 +127,13 @@ const ScrollArea = forwardRef((props, ref) => {
127
127
  updateScroll();
128
128
  }, [updateScroll]);
129
129
  useIsomorphicLayoutEffect(() => {
130
- const scrollableEl = scrollableRef.current;
131
- if (!scrollableEl)
130
+ const contentEl = contentRef.current;
131
+ if (!contentEl)
132
132
  return;
133
- resizeObserverRef.current = new ResizeObserver(updateScroll);
134
- resizeObserverRef.current.observe(scrollableEl);
135
- return () => {
136
- resizeObserverRef.current?.disconnect();
137
- };
133
+ const observer = new ResizeObserver(updateScroll);
134
+ observer.observe(contentEl);
135
+ return () => observer.disconnect();
138
136
  }, [updateScroll]);
139
- return (_jsxs("div", { ...attributes, className: rootClassNames, style: rootVariables, children: [_jsx("div", { className: s.scrollable, ref: scrollableRef, onScroll: handleScroll, children: children }), scrollRatio.y < 1 && scrollbarDisplay !== "hidden" && (_jsx(ScrollAreaBar, { vertical: true, onThumbMove: handleThumbYMove, ratio: scrollRatio.y, position: scrollPosition.y })), scrollRatio.x < 1 && scrollbarDisplay !== "hidden" && (_jsx(ScrollAreaBar, { onThumbMove: handleThumbXMove, ratio: scrollRatio.x, position: scrollPosition.x }))] }));
137
+ return (_jsxs("div", { ...attributes, className: rootClassNames, style: rootVariables, children: [_jsx("div", { className: s.scrollable, ref: scrollableRef, onScroll: handleScroll, children: _jsx("div", { className: s.content, ref: contentRef, children: children }) }), scrollRatio.y < 1 && scrollbarDisplay !== "hidden" && (_jsx(ScrollAreaBar, { vertical: true, onThumbMove: handleThumbYMove, ratio: scrollRatio.y, position: scrollPosition.y })), scrollRatio.x < 1 && scrollbarDisplay !== "hidden" && (_jsx(ScrollAreaBar, { onThumbMove: handleThumbXMove, ratio: scrollRatio.x, position: scrollPosition.x }))] }));
140
138
  });
141
139
  export default ScrollArea;
@@ -1 +1 @@
1
- .root{--rs-scroll-area-thumb-size:calc(var(--rs-unit-x1) * 1.5);--rs-scroll-area-thumb-offset:calc(var(--rs-unit-x1) / 2);height:100%}.root,.scrollable{overflow:auto;position:relative}.scrollable{display:inline-block;max-height:100%;scrollbar-width:none;vertical-align:top;width:100%;-webkit-overflow-scrolling:touch}.scrollable::-webkit-scrollbar{display:none;height:0;width:0}.scrollbar{box-sizing:initial;padding:var(--rs-scroll-area-thumb-offset);position:absolute}.thumb{height:100%;position:relative;width:100%}.thumb:before{background:var(--rs-color-foreground-neutral);border-radius:999px;content:"";display:block;opacity:0;position:absolute;transition:opacity var(--rs-duration-fast) var(--rs-easing-standard)}.--scrollbar-y{inset-block:0;inset-inline-end:0;width:var(--rs-scroll-area-thumb-size)}.--scrollbar-y .thumb:before{height:calc(var(--rs-scroll-area-ratio) * 100%);inset-block-start:calc(var(--rs-scroll-area-position) * 100%);width:100%}.--scrollbar-x{height:var(--rs-scroll-area-thumb-size);inset-block-end:0;inset-inline:0}.--scrollbar-x .thumb:before{height:100%;inset-inline-start:calc(var(--rs-scroll-area-position) * 100%);width:calc(var(--rs-scroll-area-ratio) * 100%)}.--scrollbar-y:not(:last-child){inset-block-end:calc(var(--rs-scroll-area-thumb-size) + var(--rs-scroll-area-thumb-offset) * 2)}.--scrollbar-y~.--scrollbar-x{inset-inline-end:calc(var(--rs-scroll-area-thumb-size) + var(--rs-scroll-area-thumb-offset) * 2)}.--display-hover:hover .thumb:before,.--display-visible .thumb:before{opacity:.2}.--display-hover:hover .--scrollbar-dragging .thumb:before,.--scrollbar-dragging .thumb:before,.scrollbar:hover .thumb:before{opacity:.32}
1
+ .root{--rs-scroll-area-thumb-size:calc(var(--rs-unit-x1) * 1.5);--rs-scroll-area-thumb-offset:calc(var(--rs-unit-x1) / 2);overflow:hidden}.root,.scrollable{height:100%;position:relative}.scrollable{overflow:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch}.scrollable::-webkit-scrollbar{display:none;height:0;width:0}.content{display:inline-block;min-height:100%;min-width:100%;vertical-align:top}.scrollbar{box-sizing:initial;padding:var(--rs-scroll-area-thumb-offset);position:absolute}.thumb{height:100%;position:relative;width:100%}.thumb:before{background:var(--rs-color-foreground-neutral);border-radius:999px;content:"";display:block;opacity:0;position:absolute;transition:opacity var(--rs-duration-fast) var(--rs-easing-standard)}.--scrollbar-y{inset-block:0;inset-inline-end:0;width:var(--rs-scroll-area-thumb-size)}.--scrollbar-y .thumb:before{height:calc(var(--rs-scroll-area-ratio) * 100%);inset-block-start:calc(var(--rs-scroll-area-position) * 100%);width:100%}.--scrollbar-x{height:var(--rs-scroll-area-thumb-size);inset-block-end:0;inset-inline:0}.--scrollbar-x .thumb:before{height:100%;inset-inline-start:calc(var(--rs-scroll-area-position) * 100%);width:calc(var(--rs-scroll-area-ratio) * 100%)}.--scrollbar-y:not(:last-child){inset-block-end:calc(var(--rs-scroll-area-thumb-size) + var(--rs-scroll-area-thumb-offset) * 2)}.--scrollbar-y~.--scrollbar-x{inset-inline-end:calc(var(--rs-scroll-area-thumb-size) + var(--rs-scroll-area-thumb-offset) * 2)}.--display-hover:hover>.scrollbar .thumb:before,.--display-visible .thumb:before{opacity:.2}.--display-hover:hover .--scrollbar-dragging .thumb:before,.--scrollbar-dragging .thumb:before,.scrollbar:hover .thumb:before{opacity:.32}
@@ -117,6 +117,7 @@ export const ref = () => (<Example>
117
117
  </Example>);
118
118
  export const edgeCases = () => {
119
119
  const toggle = useToggle(true);
120
+ const [count, setCount] = React.useState(20);
120
121
  return (<Example>
121
122
  <Example.Item title="dynamic content update">
122
123
  <View gap={4}>
@@ -137,5 +138,33 @@ export const edgeCases = () => {
137
138
  </ScrollArea>
138
139
  </View>
139
140
  </Example.Item>
141
+
142
+ <Example.Item title="add items">
143
+ <View gap={4}>
144
+ <Button onClick={() => setCount((prev) => prev + 10)}>Add</Button>
145
+
146
+ <ScrollArea height="200px" scrollbarDisplay="visible">
147
+ {Array(count)
148
+ .fill("")
149
+ .map((_, index) => {
150
+ return <div key={index}>Item {index + 1}</div>;
151
+ })}
152
+ </ScrollArea>
153
+ </View>
154
+ </Example.Item>
155
+
156
+ <Example.Item title="nested, hover only for the current area">
157
+ <ScrollArea height="100px">
158
+ <View padding={8}>
159
+ <ScrollArea height="200px">
160
+ {Array(20)
161
+ .fill("")
162
+ .map((_, index) => {
163
+ return <div key={index}>Item {index + 1}</div>;
164
+ })}
165
+ </ScrollArea>
166
+ </View>
167
+ </ScrollArea>
168
+ </Example.Item>
140
169
  </Example>);
141
170
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reshaped",
3
3
  "description": "Professionally crafted design system in React & Figma for building products of any scale and complexity",
4
- "version": "3.3.2",
4
+ "version": "3.3.3",
5
5
  "license": "MIT",
6
6
  "email": "hello@reshaped.so",
7
7
  "homepage": "https://reshaped.so",