reshaped 4.0.1 → 4.0.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.
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +1 -1
- package/dist/components/Flyout/FlyoutContent.js +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +2 -2
- package/dist/components/ScrollArea/ScrollArea.module.css +1 -1
- package/dist/components/ScrollArea/ScrollArea.types.d.ts +2 -0
- package/dist/components/ScrollArea/tests/ScrollArea.stories.d.ts +4 -0
- package/dist/components/ScrollArea/tests/ScrollArea.stories.js +29 -1
- package/dist/components/Select/SelectCustomControlled.js +11 -1
- package/package.json +3 -3
|
@@ -48,7 +48,7 @@ const FlyoutContent = (props) => {
|
|
|
48
48
|
"--rs-flyout-max-h": contentMaxHeight,
|
|
49
49
|
"--rs-flyout-max-w": contentMaxWidth,
|
|
50
50
|
"--rs-flyout-z-index": contentZIndex,
|
|
51
|
-
}, ref: flyoutElRef, onTransitionEnd: handleTransitionEnd, onMouseEnter: triggerType === "hover" ? handleContentMouseEnter : undefined, onMouseLeave: triggerType === "hover" ? handleMouseLeave : undefined, onMouseDown: handleContentMouseDown, onTouchStart: handleContentMouseDown, onMouseUp: handleContentMouseUp, onTouchEnd: handleContentMouseUp, children: _jsx("div", { role: role, ...contentAttributes, ...attributes, id: id, tabIndex: !autoFocus ? -1 : undefined, "aria-modal": role === "dialog" ? true : undefined, style: { ...contentAttributes?.style, ...attributes?.style }, className: contentClassNames, children: _jsx(ScrollArea, { scrollableAttributes: scrollableAttributes, scrollableClassName: scrollableClassName, children: children }) }) }) }));
|
|
51
|
+
}, ref: flyoutElRef, onTransitionEnd: handleTransitionEnd, onMouseEnter: triggerType === "hover" ? handleContentMouseEnter : undefined, onMouseLeave: triggerType === "hover" ? handleMouseLeave : undefined, onMouseDown: handleContentMouseDown, onTouchStart: handleContentMouseDown, onMouseUp: handleContentMouseUp, onTouchEnd: handleContentMouseUp, children: _jsx("div", { role: role, ...contentAttributes, ...attributes, id: id, tabIndex: !autoFocus ? -1 : undefined, "aria-modal": role === "dialog" ? true : undefined, style: { ...contentAttributes?.style, ...attributes?.style }, className: contentClassNames, children: _jsx(ScrollArea, { overscrollBehavior: "contain", scrollableAttributes: scrollableAttributes, scrollableClassName: scrollableClassName, children: children }) }) }) }));
|
|
52
52
|
return (_jsx(Portal, { targetRef: shadowRootRef.current ? shadowRootRef : undefined, colorMode: colorMode, children: content }));
|
|
53
53
|
};
|
|
54
54
|
FlyoutContent.displayName = "Flyout.Content";
|
|
@@ -65,7 +65,7 @@ const ScrollAreaBar = (props) => {
|
|
|
65
65
|
}, ref: barRef, onClick: handleClick, onMouseDown: handleDragStart, "aria-hidden": "true", children: _jsx("div", { className: s.thumb }) }));
|
|
66
66
|
};
|
|
67
67
|
const ScrollArea = forwardRef((props, ref) => {
|
|
68
|
-
const { children, height, maxHeight, scrollbarDisplay = "hover", onScroll, className, attributes, scrollableAttributes, scrollableClassName, } = props;
|
|
68
|
+
const { children, height, maxHeight, scrollbarDisplay = "hover", overscrollBehavior = "auto", onScroll, className, attributes, scrollableAttributes, scrollableClassName, } = props;
|
|
69
69
|
const [scrollRatio, setScrollRatio] = React.useState({ x: 1, y: 1 });
|
|
70
70
|
const [scrollPosition, setScrollPosition] = React.useState({ x: 0, y: 0 });
|
|
71
71
|
const scrollableRef = React.useRef(null);
|
|
@@ -73,7 +73,7 @@ const ScrollArea = forwardRef((props, ref) => {
|
|
|
73
73
|
const rootRef = React.useRef(null);
|
|
74
74
|
const mixinStyles = resolveMixin({ height, maxHeight });
|
|
75
75
|
const rootClassNames = classNames(s.root, scrollbarDisplay && s[`--display-${scrollbarDisplay}`], className);
|
|
76
|
-
const scrollableClassNames = classNames(s.scrollable, mixinStyles.classNames);
|
|
76
|
+
const scrollableClassNames = classNames(s.scrollable, overscrollBehavior && s[`--overscroll-${overscrollBehavior}`], mixinStyles.classNames);
|
|
77
77
|
const updateScroll = React.useCallback(() => {
|
|
78
78
|
const scrollableEl = scrollableRef.current;
|
|
79
79
|
if (!scrollableEl)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.root{--rs-scroll-area-thumb-size:var(--rs-unit-x1);--rs-scroll-area-thumb-offset:var(--rs-unit-x1);height:100%;overflow:hidden;position:relative}[data-rs-keyboard] .root:has(.scrollable:focus){outline:var(--rs-outline)}.scrollable{height:100%;outline:none;overflow:auto;position:relative;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{background-color:var(--rs-color-background-neutral-faded);height:100%;opacity:0;position:relative;width:100%}.thumb,.thumb:before{border-radius:var(--rs-radius-circular);transition:opacity var(--rs-duration-fast) var(--rs-easing-standard)}.thumb:before{background:var(--rs-color-foreground-neutral);content:"";display:block;opacity:.2;position:absolute}.--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,.--display-visible>.scrollbar .thumb{opacity:1}.--display-hover:hover .--scrollbar-dragging .thumb:before,.--scrollbar-dragging .thumb:before,.scrollbar:hover .thumb:before{opacity:.32}
|
|
1
|
+
.root{--rs-scroll-area-thumb-size:var(--rs-unit-x1);--rs-scroll-area-thumb-offset:var(--rs-unit-x1);height:100%;overflow:hidden;position:relative}[data-rs-keyboard] .root:has(.scrollable:focus){outline:var(--rs-outline)}.scrollable{height:100%;outline:none;overflow:auto;position:relative;scrollbar-width:none;-webkit-overflow-scrolling:touch}.scrollable::-webkit-scrollbar{display:none;height:0;width:0}.--overscroll-auto{overscroll-behavior:auto}.--overscroll-contain{overscroll-behavior:contain}.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{background-color:var(--rs-color-background-neutral-faded);height:100%;opacity:0;position:relative;width:100%}.thumb,.thumb:before{border-radius:var(--rs-radius-circular);transition:opacity var(--rs-duration-fast) var(--rs-easing-standard)}.thumb:before{background:var(--rs-color-foreground-neutral);content:"";display:block;opacity:.2;position:absolute}.--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,.--display-visible>.scrollbar .thumb{opacity:1}.--display-hover:hover .--scrollbar-dragging .thumb:before,.--scrollbar-dragging .thumb:before,.scrollbar:hover .thumb:before{opacity:.32}
|
|
@@ -8,6 +8,8 @@ export type Props = {
|
|
|
8
8
|
children: React.ReactNode;
|
|
9
9
|
/** Scrollbar visibility behavior based on the user interaction */
|
|
10
10
|
scrollbarDisplay?: "visible" | "hover" | "hidden";
|
|
11
|
+
/** Control whether scroll can chain to parent scrollable containers */
|
|
12
|
+
overscrollBehavior?: "auto" | "contain";
|
|
11
13
|
/** Callback when the scroll area is scrolled */
|
|
12
14
|
onScroll?: (args: Coordinates) => void;
|
|
13
15
|
/** Height of the scroll area, literal css value or unit token multiplier */
|
|
@@ -22,6 +22,10 @@ export declare const scrollbarDisplay: {
|
|
|
22
22
|
name: string;
|
|
23
23
|
render: () => React.JSX.Element;
|
|
24
24
|
};
|
|
25
|
+
export declare const overscrollBehavior: {
|
|
26
|
+
name: string;
|
|
27
|
+
render: () => React.JSX.Element;
|
|
28
|
+
};
|
|
25
29
|
export declare const height: {
|
|
26
30
|
name: string;
|
|
27
31
|
render: () => React.JSX.Element;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.testDynamicHeight = exports.testNested = exports.className = exports.onScroll = exports.height = exports.scrollbarDisplay = exports.base = void 0;
|
|
6
|
+
exports.testDynamicHeight = exports.testNested = exports.className = exports.onScroll = exports.height = exports.overscrollBehavior = exports.scrollbarDisplay = exports.base = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const test_1 = require("storybook/test");
|
|
9
9
|
const Button_1 = __importDefault(require("../../Button"));
|
|
@@ -110,6 +110,34 @@ exports.scrollbarDisplay = {
|
|
|
110
110
|
</storybook_1.Example.Item>
|
|
111
111
|
</storybook_1.Example>),
|
|
112
112
|
};
|
|
113
|
+
exports.overscrollBehavior = {
|
|
114
|
+
name: "overscrollBehavior",
|
|
115
|
+
render: () => (<storybook_1.Example>
|
|
116
|
+
<storybook_1.Example.Item title="overscrollBehavior: auto">
|
|
117
|
+
<View_1.default height="200px" overflow="auto" backgroundColor="neutral-faded" padding={4}>
|
|
118
|
+
<View_1.default height="100px">Parent scroll area content before ScrollArea</View_1.default>
|
|
119
|
+
<ScrollArea_1.default height="100px" scrollbarDisplay="visible" overscrollBehavior="auto">
|
|
120
|
+
<View_1.default backgroundColor="neutral-faded" padding={4}>
|
|
121
|
+
{Array.from({ length: 10 }).map((_, index) => (<div key={index}>Item {index + 1}</div>))}
|
|
122
|
+
</View_1.default>
|
|
123
|
+
</ScrollArea_1.default>
|
|
124
|
+
<View_1.default height="300px">Parent scroll area content after ScrollArea</View_1.default>
|
|
125
|
+
</View_1.default>
|
|
126
|
+
</storybook_1.Example.Item>
|
|
127
|
+
|
|
128
|
+
<storybook_1.Example.Item title="overscrollBehavior: contain">
|
|
129
|
+
<View_1.default height="200px" overflow="auto" backgroundColor="neutral-faded" padding={4}>
|
|
130
|
+
<View_1.default height="100px">Parent scroll area content before ScrollArea</View_1.default>
|
|
131
|
+
<ScrollArea_1.default height="100px" scrollbarDisplay="visible" overscrollBehavior="contain">
|
|
132
|
+
<View_1.default backgroundColor="neutral-faded" padding={4}>
|
|
133
|
+
{Array.from({ length: 10 }).map((_, index) => (<div key={index}>Item {index + 1}</div>))}
|
|
134
|
+
</View_1.default>
|
|
135
|
+
</ScrollArea_1.default>
|
|
136
|
+
<View_1.default height="300px">Parent scroll area content after ScrollArea</View_1.default>
|
|
137
|
+
</View_1.default>
|
|
138
|
+
</storybook_1.Example.Item>
|
|
139
|
+
</storybook_1.Example>),
|
|
140
|
+
};
|
|
113
141
|
exports.height = {
|
|
114
142
|
name: "height, maxHeight",
|
|
115
143
|
render: () => (<storybook_1.Example>
|
|
@@ -15,6 +15,7 @@ const SelectCustomControlled = (props) => {
|
|
|
15
15
|
const searchStringRef = React.useRef("");
|
|
16
16
|
const searchTimeoutRef = React.useRef(null);
|
|
17
17
|
const dropdownRef = React.useRef(null);
|
|
18
|
+
const [openedWithTouch, setOpenedWithTouch] = React.useState(false);
|
|
18
19
|
const indexedOptions = [];
|
|
19
20
|
const selectedOptions = [];
|
|
20
21
|
const hasValue = multiple ? value.length > 0 : value;
|
|
@@ -108,7 +109,16 @@ const SelectCustomControlled = (props) => {
|
|
|
108
109
|
}
|
|
109
110
|
return null;
|
|
110
111
|
};
|
|
111
|
-
return (_jsxs(DropdownMenu, { width: width, disableHideAnimation: true, position: position ?? "bottom", fallbackPositions: fallbackPositions ?? (position ? undefined : ["bottom", "top"]), fallbackAdjustLayout:
|
|
112
|
+
return (_jsxs(DropdownMenu, { width: width, disableHideAnimation: true, position: position ?? "bottom", fallbackPositions: fallbackPositions ?? (position ? undefined : ["bottom", "top"]), fallbackAdjustLayout: !openedWithTouch, fallbackMinHeight: "220px", initialFocusRef: initialFocusRef, positionRef: positionRef, onClose: () => setOpenedWithTouch(false), children: [_jsx(DropdownMenu.Trigger, { children: (attributes) => {
|
|
113
|
+
const triggerAttributes = {
|
|
114
|
+
...attributes,
|
|
115
|
+
onTouchStart: () => {
|
|
116
|
+
setOpenedWithTouch(true);
|
|
117
|
+
attributes.onTouchStart?.();
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
return (_jsx(SelectTrigger, { ...props, triggerAttributes: triggerAttributes, value: value, children: renderValue() }));
|
|
121
|
+
} }), _jsx(DropdownMenu.Content, { attributes: {
|
|
112
122
|
ref: dropdownRef,
|
|
113
123
|
onKeyDown: handleKeyDown,
|
|
114
124
|
// Ignore the default menu role since we're using options
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reshaped",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "Professionally crafted design system in React and Figma for building products of any scale and complexity",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"cssnano": "7.1.4",
|
|
72
72
|
"csstype": "3.2.3",
|
|
73
73
|
"postcss-custom-media": "12.0.1",
|
|
74
|
-
"@reshaped/theming": "4.0.
|
|
75
|
-
"@reshaped/utilities": "4.0.
|
|
74
|
+
"@reshaped/theming": "4.0.3",
|
|
75
|
+
"@reshaped/utilities": "4.0.3"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"postcss": "^8",
|