reshaped 3.2.0-canary.2 → 3.2.0-canary.4
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/CHANGELOG.md +11 -0
- package/dist/bundle.css +1 -1
- package/dist/bundle.d.ts +1 -1
- package/dist/bundle.js +11 -11
- package/dist/components/Accordion/tests/Accordion.stories.js +33 -19
- package/dist/components/Autocomplete/Autocomplete.js +2 -2
- package/dist/components/Autocomplete/Autocomplete.types.d.ts +3 -2
- package/dist/components/Autocomplete/index.d.ts +1 -1
- package/dist/components/Badge/Badge.types.d.ts +1 -1
- package/dist/components/Image/Image.js +3 -1
- package/dist/components/Modal/Modal.js +3 -3
- package/dist/components/Modal/Modal.module.css +1 -1
- package/dist/components/Modal/Modal.types.d.ts +6 -2
- package/dist/components/Modal/tests/Modal.stories.d.ts +1 -0
- package/dist/components/Modal/tests/Modal.stories.js +27 -0
- package/dist/components/Overlay/Overlay.js +5 -5
- package/dist/components/Overlay/Overlay.module.css +1 -1
- package/dist/components/Overlay/Overlay.types.d.ts +4 -1
- package/dist/components/Overlay/index.d.ts +1 -1
- package/dist/components/Reshaped/Reshaped.css +1 -1
- package/dist/components/Reshaped/Reshaped.js +3 -3
- package/dist/components/Reshaped/Reshaped.module.css +1 -1
- package/dist/components/Reshaped/Reshaped.types.d.ts +4 -3
- package/dist/components/Switch/Switch.js +1 -1
- package/dist/components/Switch/tests/Switch.stories.js +5 -0
- package/dist/components/Theme/GlobalColorMode.js +3 -2
- package/dist/components/Theme/Theme.d.ts +1 -0
- package/dist/components/Theme/Theme.js +13 -12
- package/dist/components/Theme/Theme.types.d.ts +4 -0
- package/dist/components/Theme/Theme.utilities.d.ts +1 -0
- package/dist/components/Theme/Theme.utilities.js +1 -0
- package/dist/components/Theme/index.d.ts +1 -1
- package/dist/components/Theme/index.js +1 -1
- package/dist/components/Tooltip/Tooltip.js +2 -2
- package/dist/components/Tooltip/Tooltip.types.d.ts +1 -1
- package/dist/components/_private/Flyout/FlyoutControlled.js +1 -3
- package/dist/components/_private/Flyout/tests/Flyout.stories.js +6 -0
- package/dist/hooks/useResponsiveClientValue.js +3 -3
- package/dist/index.d.ts +1 -1
- package/package.json +2 -1
@@ -3,6 +3,7 @@ import { Example, Placeholder } from "../../../utilities/storybook/index.js";
|
|
3
3
|
import Accordion from "../index.js";
|
4
4
|
import Button from "../../Button/index.js";
|
5
5
|
import View from "../../View/index.js";
|
6
|
+
import useToggle from "../../../hooks/useToggle.js";
|
6
7
|
export default {
|
7
8
|
title: "Utilities/Accordion",
|
8
9
|
component: Accordion,
|
@@ -97,30 +98,43 @@ const DemoMultiple = () => {
|
|
97
98
|
</View>))}
|
98
99
|
</View>);
|
99
100
|
};
|
100
|
-
export const composition = () =>
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
<Accordion.Content>
|
105
|
-
<View paddingTop={2}>
|
106
|
-
<Placeholder h={200}/>
|
107
|
-
</View>
|
108
|
-
</Accordion.Content>
|
109
|
-
</Accordion>
|
110
|
-
</Example.Item>
|
111
|
-
<Example.Item title="inside View">
|
112
|
-
<View backgroundColor="neutral-faded" borderRadius="medium" padding={4}>
|
101
|
+
export const composition = () => {
|
102
|
+
const toggle = useToggle();
|
103
|
+
return (<Example>
|
104
|
+
<Example.Item title="custom content size">
|
113
105
|
<Accordion>
|
114
106
|
<Accordion.Trigger>Accordion trigger</Accordion.Trigger>
|
107
|
+
<Accordion.Content>
|
108
|
+
<View paddingTop={2}>
|
109
|
+
<Placeholder h={200}/>
|
110
|
+
</View>
|
111
|
+
</Accordion.Content>
|
112
|
+
</Accordion>
|
113
|
+
</Example.Item>
|
114
|
+
<Example.Item title="inside View">
|
115
|
+
<View backgroundColor="neutral-faded" borderRadius="medium" padding={4}>
|
116
|
+
<Accordion>
|
117
|
+
<Accordion.Trigger>Accordion trigger</Accordion.Trigger>
|
118
|
+
<Accordion.Content>
|
119
|
+
<View paddingTop={2}>
|
120
|
+
<Placeholder />
|
121
|
+
</View>
|
122
|
+
</Accordion.Content>
|
123
|
+
</Accordion>
|
124
|
+
</View>
|
125
|
+
</Example.Item>
|
126
|
+
<Example.Item title="multiple items, depending on state">
|
127
|
+
<DemoMultiple />
|
128
|
+
</Example.Item>
|
129
|
+
<Example.Item title="external trigger">
|
130
|
+
<Button onClick={toggle.toggle}>Toggle</Button>
|
131
|
+
<Accordion active={toggle.active}>
|
115
132
|
<Accordion.Content>
|
116
133
|
<View paddingTop={2}>
|
117
134
|
<Placeholder />
|
118
135
|
</View>
|
119
136
|
</Accordion.Content>
|
120
137
|
</Accordion>
|
121
|
-
</
|
122
|
-
</Example
|
123
|
-
|
124
|
-
<DemoMultiple />
|
125
|
-
</Example.Item>
|
126
|
-
</Example>);
|
138
|
+
</Example.Item>
|
139
|
+
</Example>);
|
140
|
+
};
|
@@ -9,7 +9,7 @@ import * as keys from "../../constants/keys.js";
|
|
9
9
|
import useHandlerRef from "../../hooks/useHandlerRef.js";
|
10
10
|
const AutocompleteContext = React.createContext({});
|
11
11
|
const Autocomplete = (props) => {
|
12
|
-
const { children, onChange, onInput, onItemSelect, name, containerRef, onBackspace, ...textFieldProps } = props;
|
12
|
+
const { children, onChange, onInput, onItemSelect, name, containerRef, instanceRef, onBackspace, ...textFieldProps } = props;
|
13
13
|
const onBackspaceRef = useHandlerRef(onBackspace);
|
14
14
|
const internalInputRef = React.useRef(null);
|
15
15
|
const inputAttributesRef = textFieldProps.inputAttributes?.ref;
|
@@ -50,7 +50,7 @@ const Autocomplete = (props) => {
|
|
50
50
|
onInput?.({ value: e.currentTarget.value, name, event: e });
|
51
51
|
textFieldProps.inputAttributes?.onInput?.(e);
|
52
52
|
};
|
53
|
-
return (_jsx(AutocompleteContext.Provider, { value: { onItemClick: handleItemClick }, children: _jsxs(DropdownMenu, { position: "bottom", width: "trigger", triggerType: "focus", trapFocusMode: "selection-menu", active: !lockedRef.current && hasChildren && active, onClose: handleClose, onOpen: handleOpen, containerRef: containerRef, disableHideAnimation: true, children: [_jsx(DropdownMenu.Trigger, { children: ({ ref, ...attributes }) => (_jsx(TextField, { ...textFieldProps, name: name, onChange: handleChange, focused: hasChildren && active,
|
53
|
+
return (_jsx(AutocompleteContext.Provider, { value: { onItemClick: handleItemClick }, children: _jsxs(DropdownMenu, { position: "bottom", width: "trigger", triggerType: "focus", trapFocusMode: "selection-menu", active: !lockedRef.current && hasChildren && active, onClose: handleClose, onOpen: handleOpen, containerRef: containerRef, disableHideAnimation: true, instanceRef: instanceRef, children: [_jsx(DropdownMenu.Trigger, { children: ({ ref, ...attributes }) => (_jsx(TextField, { ...textFieldProps, name: name, onChange: handleChange, focused: hasChildren && active,
|
54
54
|
// Ignoring the type check since TS can't infer the correct html element type
|
55
55
|
attributes: { ...textFieldProps.attributes, ref }, inputAttributes: {
|
56
56
|
...textFieldProps.inputAttributes,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { TextFieldProps } from "../TextField";
|
2
2
|
import type { MenuItemProps } from "../MenuItem";
|
3
|
-
import type { DropdownMenuProps } from "../DropdownMenu";
|
4
|
-
export type Props = TextFieldProps & Pick<DropdownMenuProps, "containerRef"> & {
|
3
|
+
import type { DropdownMenuProps, DropdownMenuInstance } from "../DropdownMenu";
|
4
|
+
export type Props = TextFieldProps & Pick<DropdownMenuProps, "containerRef" | "instanceRef"> & {
|
5
5
|
onInput?: TextFieldProps["onChange"];
|
6
6
|
onItemSelect?: (args: {
|
7
7
|
value: string;
|
@@ -17,3 +17,4 @@ export type Context = {
|
|
17
17
|
value: string;
|
18
18
|
}) => void;
|
19
19
|
};
|
20
|
+
export type Instance = DropdownMenuInstance;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
export { default } from "./Autocomplete";
|
2
|
-
export type { Props as AutocompleteProps } from "./Autocomplete.types";
|
2
|
+
export type { Props as AutocompleteProps, Instance as AutocompleteInstance, } from "./Autocomplete.types";
|
@@ -12,7 +12,7 @@ type BaseProps = {
|
|
12
12
|
} & Pick<ActionableProps, "href" | "onClick" | "attributes">;
|
13
13
|
type WithChildren = BaseProps & {
|
14
14
|
children: React.ReactNode;
|
15
|
-
color?: "critical" | "warning" | "positive" | "primary";
|
15
|
+
color?: "neutral" | "critical" | "warning" | "positive" | "primary";
|
16
16
|
variant?: "faded" | "outline";
|
17
17
|
};
|
18
18
|
type WithEmpty = BaseProps & {
|
@@ -15,7 +15,9 @@ const Image = (props) => {
|
|
15
15
|
const baseClassNames = classNames(s.root, radiusStyles?.classNames, widthStyles?.classNames, heightStyles?.classNames, displayMode && s[`--display-mode-${displayMode}`], className);
|
16
16
|
const imgClassNames = classNames(s.image, baseClassNames);
|
17
17
|
const fallbackClassNames = classNames(s.fallback, baseClassNames);
|
18
|
+
const isFallback = (status === "error" || !src) && !!fallback;
|
18
19
|
const style = {
|
20
|
+
...attributes?.style,
|
19
21
|
...widthStyles?.variables,
|
20
22
|
...heightStyles?.variables,
|
21
23
|
};
|
@@ -30,7 +32,7 @@ const Image = (props) => {
|
|
30
32
|
React.useEffect(() => {
|
31
33
|
setStatus("loading");
|
32
34
|
}, [src]);
|
33
|
-
if (
|
35
|
+
if (isFallback) {
|
34
36
|
if (typeof fallback === "string") {
|
35
37
|
return (_jsx("img", { ...attributes, src: fallback, alt: alt, role: alt ? undefined : "presentation", className: fallbackClassNames, style: style }));
|
36
38
|
}
|
@@ -40,7 +40,7 @@ const ModalSubtitle = (props) => {
|
|
40
40
|
return (_jsx(Text, { variant: "body-3", color: "neutral-faded", attributes: { id: `${id}-subtitle` }, children: children }));
|
41
41
|
};
|
42
42
|
const Modal = (props) => {
|
43
|
-
const { children, onClose, onOpen, active, size, padding = 4, position = "center", transparentOverlay, blurredOverlay, ariaLabel, autoFocus = true, disableSwipeGesture, disableCloseOnOutsideClick, overlayClassName, className, attributes, } = props;
|
43
|
+
const { children, onClose, onOpen, active, size, padding = 4, position = "center", overflow, transparentOverlay, blurredOverlay, ariaLabel, autoFocus = true, disableSwipeGesture, disableCloseOnOutsideClick, overlayClassName, className, attributes, } = props;
|
44
44
|
const onCloseRef = useHandlerRef(onClose);
|
45
45
|
const id = useElementId();
|
46
46
|
const clientPosition = useResponsiveClientValue(position);
|
@@ -112,7 +112,7 @@ const Modal = (props) => {
|
|
112
112
|
// Changing to a different direction will keep the modal opened
|
113
113
|
const shouldClose = clientPosition === "start" ? dragDirectionRef.current < 0 : dragDirectionRef.current > 0;
|
114
114
|
if (Math.abs(dragDistanceRef.current) > DRAG_THRESHOLD && shouldClose) {
|
115
|
-
onCloseRef.current?.();
|
115
|
+
onCloseRef.current?.({ reason: "drag" });
|
116
116
|
}
|
117
117
|
else {
|
118
118
|
resetDragData();
|
@@ -168,7 +168,7 @@ const Modal = (props) => {
|
|
168
168
|
return (_jsx(Overlay, { onClose: onClose, onOpen: onOpen, disableCloseOnClick: disableCloseOnOutsideClick, active: active, transparent: transparentOverlay || hideProgress, blurred: blurredOverlay, className: overlayClassName, attributes: {
|
169
169
|
onTouchStart: handleDragStart,
|
170
170
|
}, children: ({ active }) => {
|
171
|
-
const rootClassNames = classNames(s.root, className, paddingStyles?.classNames, active && s["--active"], dragging && s["--dragging"], responsiveClassNames(s, "--position", position));
|
171
|
+
const rootClassNames = classNames(s.root, className, paddingStyles?.classNames, active && s["--active"], dragging && s["--dragging"], overflow && s[`--overflow-${overflow}`], responsiveClassNames(s, "--position", position));
|
172
172
|
return (_jsx(Context.Provider, { value: value, children: _jsx("div", { ...attributes, style: {
|
173
173
|
...paddingStyles?.variables,
|
174
174
|
...responsiveVariables("--rs-modal-size", size),
|
@@ -1 +1 @@
|
|
1
|
-
.root{background:var(--rs-color-background-elevation-overlay);box-shadow:var(--rs-shadow-overlay);color:var(--rs-color-foreground-neutral);transition:var(--rs-easing-accelerate) var(--rs-duration-medium);transition-property:transform,opacity;will-change:transform}.root:focus-visible{box-shadow:var(--rs-focus-shadow);outline:none}.root{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);--rs-modal-size-m:var(--rs-modal-size-s);--rs-modal-size-l:var(--rs-modal-size-m);--rs-modal-size-xl:var(--rs-modal-size-l);--rs-modal-size:var(--rs-modal-size-s)}.--position-center{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:var(--rs-radius-large);height:auto;inset:0;margin:var(--rs-unit-x4);max-height:none;max-width:calc(100vw - var(--rs-unit-x8));opacity:0;overflow:hidden;position:relative;transform:scale(.96);width:var(--rs-modal-size)}.--position-center.--active,[dir=rtl] .--position-center.--active{opacity:1;transform:translate(0) scale(1)!important}.--position-bottom{--rs-modal-size-s:auto;border-radius:var(--rs-radius-large) var(--rs-radius-large) 0 0;height:var(--rs-modal-size);inset:0;inset-block-start:auto;margin:0;margin-top:var(--rs-unit-x4);max-height:calc(100vh - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translateY(100%);width:100%}.--position-bottom.--active,[dir=rtl] .--position-bottom.--active{transform:translateY(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-start{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-end:auto;margin:0;margin-inline-end:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(-100%);width:var(--rs-modal-size)}[dir=rtl] .--position-start{transform:translate(100%)}.--position-start.--active,[dir=rtl] .--position-start.--active{transform:translate(min(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-end{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-start:auto;margin:0;margin-inline-start:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(100%);width:var(--rs-modal-size)}[dir=rtl] .--position-end{transform:translate(-100%)}.--position-end.--active,[dir=rtl] .--position-end.--active{transform:translate(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-full-screen{--rs-modal-size-s:100%;border-radius:0;height:100%;inset:0;inset-block-start:auto;margin:0;max-height:100%;max-width:100%;opacity:0;overflow:auto;position:fixed;transform:translateY(var(--rs-unit-x4));width:100%}.--position-full-screen.--active,[dir=rtl] .--position-full-screen.--active{opacity:1;transform:translate(0)!important}.--active,[dir=rtl] .--active{transition-timing-function:var(--rs-easing-decelerate)}.--dragging{transition:none}@media (--rs-viewport-m ){.root{--rs-modal-size:var(--rs-modal-size-m)}.--position-center--m{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:var(--rs-radius-large);height:auto;inset:0;margin:var(--rs-unit-x4);max-height:none;max-width:calc(100vw - var(--rs-unit-x8));opacity:0;overflow:hidden;position:relative;transform:scale(.96);width:var(--rs-modal-size)}.--position-center--m.--active,[dir=rtl] .--position-center--m.--active{opacity:1;transform:translate(0) scale(1)!important}.--position-bottom--m{--rs-modal-size-s:auto;border-radius:var(--rs-radius-large) var(--rs-radius-large) 0 0;height:var(--rs-modal-size);inset:0;inset-block-start:auto;margin:0;margin-top:var(--rs-unit-x4);max-height:calc(100vh - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translateY(100%);width:100%}.--position-bottom--m.--active,[dir=rtl] .--position-bottom--m.--active{transform:translateY(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-start--m{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-end:auto;margin:0;margin-inline-end:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(-100%);width:var(--rs-modal-size)}[dir=rtl] .--position-start--m{transform:translate(100%)}.--position-start--m.--active,[dir=rtl] .--position-start--m.--active{transform:translate(min(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-end--m{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-start:auto;margin:0;margin-inline-start:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(100%);width:var(--rs-modal-size)}[dir=rtl] .--position-end--m{transform:translate(-100%)}.--position-end--m.--active,[dir=rtl] .--position-end--m.--active{transform:translate(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-full-screen--m{--rs-modal-size-s:100%;border-radius:0;height:100%;inset:0;inset-block-start:auto;margin:0;max-height:100%;max-width:100%;opacity:0;overflow:auto;position:fixed;transform:translateY(var(--rs-unit-x4));width:100%}.--position-full-screen--m.--active,[dir=rtl] .--position-full-screen--m.--active{opacity:1;transform:translate(0)!important}}@media (--rs-viewport-l ){.root{--rs-modal-size:var(--rs-modal-size-l)}.--position-center--l{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:var(--rs-radius-large);height:auto;inset:0;margin:var(--rs-unit-x4);max-height:none;max-width:calc(100vw - var(--rs-unit-x8));opacity:0;overflow:hidden;position:relative;transform:scale(.96);width:var(--rs-modal-size)}.--position-center--l.--active,[dir=rtl] .--position-center--l.--active{opacity:1;transform:translate(0) scale(1)!important}.--position-bottom--l{--rs-modal-size-s:auto;border-radius:var(--rs-radius-large) var(--rs-radius-large) 0 0;height:var(--rs-modal-size);inset:0;inset-block-start:auto;margin:0;margin-top:var(--rs-unit-x4);max-height:calc(100vh - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translateY(100%);width:100%}.--position-bottom--l.--active,[dir=rtl] .--position-bottom--l.--active{transform:translateY(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-start--l{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-end:auto;margin:0;margin-inline-end:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(-100%);width:var(--rs-modal-size)}[dir=rtl] .--position-start--l{transform:translate(100%)}.--position-start--l.--active,[dir=rtl] .--position-start--l.--active{transform:translate(min(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-end--l{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-start:auto;margin:0;margin-inline-start:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(100%);width:var(--rs-modal-size)}[dir=rtl] .--position-end--l{transform:translate(-100%)}.--position-end--l.--active,[dir=rtl] .--position-end--l.--active{transform:translate(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-full-screen--l{--rs-modal-size-s:100%;border-radius:0;height:100%;inset:0;inset-block-start:auto;margin:0;max-height:100%;max-width:100%;opacity:0;overflow:auto;position:fixed;transform:translateY(var(--rs-unit-x4));width:100%}.--position-full-screen--l.--active,[dir=rtl] .--position-full-screen--l.--active{opacity:1;transform:translate(0)!important}}@media (--rs-viewport-xl ){.root{--rs-modal-size:var(--rs-modal-size-xl)}.--position-center--xl{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:var(--rs-radius-large);height:auto;inset:0;margin:var(--rs-unit-x4);max-height:none;max-width:calc(100vw - var(--rs-unit-x8));opacity:0;overflow:hidden;position:relative;transform:scale(.96);width:var(--rs-modal-size)}.--position-center--xl.--active,[dir=rtl] .--position-center--xl.--active{opacity:1;transform:translate(0) scale(1)!important}.--position-bottom--xl{--rs-modal-size-s:auto;border-radius:var(--rs-radius-large) var(--rs-radius-large) 0 0;height:var(--rs-modal-size);inset:0;inset-block-start:auto;margin:0;margin-top:var(--rs-unit-x4);max-height:calc(100vh - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translateY(100%);width:100%}.--position-bottom--xl.--active,[dir=rtl] .--position-bottom--xl.--active{transform:translateY(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-start--xl{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-end:auto;margin:0;margin-inline-end:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(-100%);width:var(--rs-modal-size)}[dir=rtl] .--position-start--xl{transform:translate(100%)}.--position-start--xl.--active,[dir=rtl] .--position-start--xl.--active{transform:translate(min(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-end--xl{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-start:auto;margin:0;margin-inline-start:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(100%);width:var(--rs-modal-size)}[dir=rtl] .--position-end--xl{transform:translate(-100%)}.--position-end--xl.--active,[dir=rtl] .--position-end--xl.--active{transform:translate(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-full-screen--xl{--rs-modal-size-s:100%;border-radius:0;height:100%;inset:0;inset-block-start:auto;margin:0;max-height:100%;max-width:100%;opacity:0;overflow:auto;position:fixed;transform:translateY(var(--rs-unit-x4));width:100%}.--position-full-screen--xl.--active,[dir=rtl] .--position-full-screen--xl.--active{opacity:1;transform:translate(0)!important}}
|
1
|
+
.root{background:var(--rs-color-background-elevation-overlay);box-shadow:var(--rs-shadow-overlay);color:var(--rs-color-foreground-neutral);transition:var(--rs-easing-accelerate) var(--rs-duration-medium);transition-property:transform,opacity;will-change:transform}.root:focus-visible{box-shadow:var(--rs-focus-shadow);outline:none}.root{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);--rs-modal-size-m:var(--rs-modal-size-s);--rs-modal-size-l:var(--rs-modal-size-m);--rs-modal-size-xl:var(--rs-modal-size-l);--rs-modal-size:var(--rs-modal-size-s)}.--position-center{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:var(--rs-radius-large);height:auto;inset:0;margin:var(--rs-unit-x4);max-height:none;max-width:calc(100vw - var(--rs-unit-x8));opacity:0;overflow:hidden;position:relative;transform:scale(.96);width:var(--rs-modal-size)}.--position-center.--active,[dir=rtl] .--position-center.--active{opacity:1;transform:translate(0) scale(1)!important}.--position-bottom{--rs-modal-size-s:auto;border-radius:var(--rs-radius-large) var(--rs-radius-large) 0 0;height:var(--rs-modal-size);inset:0;inset-block-start:auto;margin:0;margin-top:var(--rs-unit-x4);max-height:calc(100vh - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translateY(100%);width:100%}.--position-bottom.--active,[dir=rtl] .--position-bottom.--active{transform:translateY(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-start{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-end:auto;margin:0;margin-inline-end:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(-100%);width:var(--rs-modal-size)}[dir=rtl] .--position-start{transform:translate(100%)}.--position-start.--active,[dir=rtl] .--position-start.--active{transform:translate(min(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-end{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-start:auto;margin:0;margin-inline-start:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(100%);width:var(--rs-modal-size)}[dir=rtl] .--position-end{transform:translate(-100%)}.--position-end.--active,[dir=rtl] .--position-end.--active{transform:translate(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-full-screen{--rs-modal-size-s:100%;border-radius:0;height:100%;inset:0;inset-block-start:auto;margin:0;max-height:100%;max-width:100%;opacity:0;overflow:auto;position:fixed;transform:translateY(var(--rs-unit-x4));width:100%}.--position-full-screen.--active,[dir=rtl] .--position-full-screen.--active{opacity:1;transform:translate(0)!important}.--active,[dir=rtl] .--active{transition-timing-function:var(--rs-easing-decelerate)}.--dragging{transition:none}.--overflow-visible{overflow:visible}@media (--rs-viewport-m ){.root{--rs-modal-size:var(--rs-modal-size-m)}.--position-center--m{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:var(--rs-radius-large);height:auto;inset:0;margin:var(--rs-unit-x4);max-height:none;max-width:calc(100vw - var(--rs-unit-x8));opacity:0;overflow:hidden;position:relative;transform:scale(.96);width:var(--rs-modal-size)}.--position-center--m.--active,[dir=rtl] .--position-center--m.--active{opacity:1;transform:translate(0) scale(1)!important}.--position-bottom--m{--rs-modal-size-s:auto;border-radius:var(--rs-radius-large) var(--rs-radius-large) 0 0;height:var(--rs-modal-size);inset:0;inset-block-start:auto;margin:0;margin-top:var(--rs-unit-x4);max-height:calc(100vh - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translateY(100%);width:100%}.--position-bottom--m.--active,[dir=rtl] .--position-bottom--m.--active{transform:translateY(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-start--m{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-end:auto;margin:0;margin-inline-end:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(-100%);width:var(--rs-modal-size)}[dir=rtl] .--position-start--m{transform:translate(100%)}.--position-start--m.--active,[dir=rtl] .--position-start--m.--active{transform:translate(min(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-end--m{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-start:auto;margin:0;margin-inline-start:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(100%);width:var(--rs-modal-size)}[dir=rtl] .--position-end--m{transform:translate(-100%)}.--position-end--m.--active,[dir=rtl] .--position-end--m.--active{transform:translate(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-full-screen--m{--rs-modal-size-s:100%;border-radius:0;height:100%;inset:0;inset-block-start:auto;margin:0;max-height:100%;max-width:100%;opacity:0;overflow:auto;position:fixed;transform:translateY(var(--rs-unit-x4));width:100%}.--position-full-screen--m.--active,[dir=rtl] .--position-full-screen--m.--active{opacity:1;transform:translate(0)!important}}@media (--rs-viewport-l ){.root{--rs-modal-size:var(--rs-modal-size-l)}.--position-center--l{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:var(--rs-radius-large);height:auto;inset:0;margin:var(--rs-unit-x4);max-height:none;max-width:calc(100vw - var(--rs-unit-x8));opacity:0;overflow:hidden;position:relative;transform:scale(.96);width:var(--rs-modal-size)}.--position-center--l.--active,[dir=rtl] .--position-center--l.--active{opacity:1;transform:translate(0) scale(1)!important}.--position-bottom--l{--rs-modal-size-s:auto;border-radius:var(--rs-radius-large) var(--rs-radius-large) 0 0;height:var(--rs-modal-size);inset:0;inset-block-start:auto;margin:0;margin-top:var(--rs-unit-x4);max-height:calc(100vh - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translateY(100%);width:100%}.--position-bottom--l.--active,[dir=rtl] .--position-bottom--l.--active{transform:translateY(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-start--l{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-end:auto;margin:0;margin-inline-end:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(-100%);width:var(--rs-modal-size)}[dir=rtl] .--position-start--l{transform:translate(100%)}.--position-start--l.--active,[dir=rtl] .--position-start--l.--active{transform:translate(min(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-end--l{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-start:auto;margin:0;margin-inline-start:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(100%);width:var(--rs-modal-size)}[dir=rtl] .--position-end--l{transform:translate(-100%)}.--position-end--l.--active,[dir=rtl] .--position-end--l.--active{transform:translate(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-full-screen--l{--rs-modal-size-s:100%;border-radius:0;height:100%;inset:0;inset-block-start:auto;margin:0;max-height:100%;max-width:100%;opacity:0;overflow:auto;position:fixed;transform:translateY(var(--rs-unit-x4));width:100%}.--position-full-screen--l.--active,[dir=rtl] .--position-full-screen--l.--active{opacity:1;transform:translate(0)!important}}@media (--rs-viewport-xl ){.root{--rs-modal-size:var(--rs-modal-size-xl)}.--position-center--xl{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:var(--rs-radius-large);height:auto;inset:0;margin:var(--rs-unit-x4);max-height:none;max-width:calc(100vw - var(--rs-unit-x8));opacity:0;overflow:hidden;position:relative;transform:scale(.96);width:var(--rs-modal-size)}.--position-center--xl.--active,[dir=rtl] .--position-center--xl.--active{opacity:1;transform:translate(0) scale(1)!important}.--position-bottom--xl{--rs-modal-size-s:auto;border-radius:var(--rs-radius-large) var(--rs-radius-large) 0 0;height:var(--rs-modal-size);inset:0;inset-block-start:auto;margin:0;margin-top:var(--rs-unit-x4);max-height:calc(100vh - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translateY(100%);width:100%}.--position-bottom--xl.--active,[dir=rtl] .--position-bottom--xl.--active{transform:translateY(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-start--xl{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-end:auto;margin:0;margin-inline-end:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(-100%);width:var(--rs-modal-size)}[dir=rtl] .--position-start--xl{transform:translate(100%)}.--position-start--xl.--active,[dir=rtl] .--position-start--xl.--active{transform:translate(min(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-end--xl{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-start:auto;margin:0;margin-inline-start:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(100%);width:var(--rs-modal-size)}[dir=rtl] .--position-end--xl{transform:translate(-100%)}.--position-end--xl.--active,[dir=rtl] .--position-end--xl.--active{transform:translate(max(var(--rs-modal-drag,0px),0px)) scale(1)!important}.--position-full-screen--xl{--rs-modal-size-s:100%;border-radius:0;height:100%;inset:0;inset-block-start:auto;margin:0;max-height:100%;max-width:100%;opacity:0;overflow:auto;position:fixed;transform:translateY(var(--rs-unit-x4));width:100%}.--position-full-screen--xl.--active,[dir=rtl] .--position-full-screen--xl.--active{opacity:1;transform:translate(0)!important}}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type React from "react";
|
2
2
|
import type * as G from "../../types/global";
|
3
|
-
import type { OverlayProps } from "../Overlay";
|
3
|
+
import type { OverlayProps, OverlayCloseReason } from "../Overlay";
|
4
4
|
export type Context = {
|
5
5
|
id: string;
|
6
6
|
titleMounted: boolean;
|
@@ -19,6 +19,10 @@ export type Props = {
|
|
19
19
|
position?: G.Responsive<"center" | "end" | "bottom" | "start" | "full-screen">;
|
20
20
|
size?: G.Responsive<string>;
|
21
21
|
padding?: G.Responsive<number>;
|
22
|
+
overflow?: "visible";
|
23
|
+
onClose?: (args: {
|
24
|
+
reason: OverlayCloseReason | "drag";
|
25
|
+
}) => void;
|
22
26
|
transparentOverlay?: boolean;
|
23
27
|
blurredOverlay?: boolean;
|
24
28
|
disableSwipeGesture?: boolean;
|
@@ -30,4 +34,4 @@ export type Props = {
|
|
30
34
|
attributes?: G.Attributes<"div"> & {
|
31
35
|
ref?: React.RefObject<HTMLDivElement>;
|
32
36
|
};
|
33
|
-
} & Pick<OverlayProps, "
|
37
|
+
} & Pick<OverlayProps, "onOpen" | "active">;
|
@@ -17,6 +17,7 @@ export default _default;
|
|
17
17
|
export declare const position: () => React.JSX.Element;
|
18
18
|
export declare const size: () => React.JSX.Element;
|
19
19
|
export declare const padding: () => React.JSX.Element;
|
20
|
+
export declare const overflow: () => React.JSX.Element;
|
20
21
|
export declare const composition: () => React.JSX.Element;
|
21
22
|
export declare const overlay: () => React.JSX.Element;
|
22
23
|
export declare const flags: () => React.JSX.Element;
|
@@ -89,6 +89,33 @@ export const padding = () => (<Example>
|
|
89
89
|
<Demo padding={{ s: 2, m: 6 }}/>
|
90
90
|
</Example.Item>
|
91
91
|
</Example>);
|
92
|
+
export const overflow = () => (<Example>
|
93
|
+
<Example.Item title="default overflow">
|
94
|
+
<Demo>
|
95
|
+
<div style={{
|
96
|
+
position: "absolute",
|
97
|
+
top: -32,
|
98
|
+
left: -32,
|
99
|
+
height: 100,
|
100
|
+
width: 100,
|
101
|
+
background: "tomato",
|
102
|
+
}}/>
|
103
|
+
</Demo>
|
104
|
+
</Example.Item>
|
105
|
+
|
106
|
+
<Example.Item title="overflow: visible">
|
107
|
+
<Demo overflow="visible">
|
108
|
+
<div style={{
|
109
|
+
position: "absolute",
|
110
|
+
top: -32,
|
111
|
+
left: -32,
|
112
|
+
height: 100,
|
113
|
+
width: 100,
|
114
|
+
background: "tomato",
|
115
|
+
}}/>
|
116
|
+
</Demo>
|
117
|
+
</Example.Item>
|
118
|
+
</Example>);
|
92
119
|
export const composition = () => (<Example>
|
93
120
|
<Example.Item title="title, subtitle, dismissible">
|
94
121
|
<Demo title="Modal title" subtitle="Modal subtitle"/>
|
@@ -35,10 +35,10 @@ const Overlay = (props) => {
|
|
35
35
|
return;
|
36
36
|
return firstChild.contains(el);
|
37
37
|
};
|
38
|
-
const close = React.useCallback(() => {
|
38
|
+
const close = React.useCallback((reason) => {
|
39
39
|
if (!visible || !isDismissible())
|
40
40
|
return;
|
41
|
-
onCloseRef.current?.();
|
41
|
+
onCloseRef.current?.({ reason });
|
42
42
|
}, [visible, isDismissible, onCloseRef]);
|
43
43
|
const handleMouseDown = (event) => {
|
44
44
|
isMouseDownValidRef.current = !isInsideChild(event.target);
|
@@ -48,10 +48,10 @@ const Overlay = (props) => {
|
|
48
48
|
const shouldClose = isMouseDownValidRef.current && isMouseUpValid && !clickThrough;
|
49
49
|
if (!shouldClose || disableCloseOnClick)
|
50
50
|
return;
|
51
|
-
close();
|
51
|
+
close("overlay-click");
|
52
52
|
};
|
53
53
|
const handleTransitionEnd = (e) => {
|
54
|
-
if (e.propertyName !== "
|
54
|
+
if (e.propertyName !== "opacity" || e.target !== e.currentTarget)
|
55
55
|
return;
|
56
56
|
setAnimated(false);
|
57
57
|
if (visible)
|
@@ -60,7 +60,7 @@ const Overlay = (props) => {
|
|
60
60
|
unlockScroll();
|
61
61
|
remove();
|
62
62
|
};
|
63
|
-
useHotkeys({ Escape: close }, [close]);
|
63
|
+
useHotkeys({ Escape: () => close("escape-key") }, [close]);
|
64
64
|
React.useEffect(() => {
|
65
65
|
setAnimated(true);
|
66
66
|
if (active && !rendered)
|
@@ -1 +1 @@
|
|
1
|
-
.root{overflow:auto;-webkit-overflow-scrolling:touch;background-color:rgba(var(--rs-color-rgb-black),0);color:var(--rs-color-white);cursor:default!important;inset:-1px;opacity:0;outline:none;position:fixed;z-index:var(--rs-z-index-overlay)}.wrapper{display:table;height:100%;width:100%}.inner{display:table-cell;text-align:center}.content,.inner{vertical-align:middle}.content{display:inline-block;text-align:initial}.root.--visible{background-color:rgba(var(--rs-color-rgb-black),var(--rs-overlay-opacity));opacity:1}.root.--click-through{color:inherit;pointer-events:none}.root.--blurred{backdrop-filter:blur(3px)}.root.--click-through .content,.root.--click-through>:not(.wrapper){pointer-events:all}.root.--animated{transition:var(--rs-duration-medium) var(--rs-easing-accelerate);transition-property:background-color,
|
1
|
+
.root{overflow:auto;-webkit-overflow-scrolling:touch;background-color:rgba(var(--rs-color-rgb-black),0);color:var(--rs-color-white);cursor:default!important;inset:-1px;opacity:0;outline:none;position:fixed;z-index:var(--rs-z-index-overlay)}.wrapper{display:table;height:100%;width:100%}.inner{display:table-cell;text-align:center}.content,.inner{vertical-align:middle}.content{display:inline-block;text-align:initial}.root.--visible{background-color:rgba(var(--rs-color-rgb-black),var(--rs-overlay-opacity));opacity:1}.root.--click-through{color:inherit;pointer-events:none}.root.--blurred{backdrop-filter:blur(3px)}.root.--click-through .content,.root.--click-through>:not(.wrapper){pointer-events:all}.root.--animated{transition:var(--rs-duration-medium) var(--rs-easing-accelerate);transition-property:background-color,opacity}.root.--animated.--visible{transition-timing-function:var(--rs-easing-decelerate)}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import type React from "react";
|
2
2
|
import type * as G from "../../types/global";
|
3
|
+
export type CloseReason = "overlay-click" | "escape-key";
|
3
4
|
export type Props = {
|
4
5
|
transparent?: boolean | number;
|
5
6
|
blurred?: boolean;
|
@@ -7,7 +8,9 @@ export type Props = {
|
|
7
8
|
active: boolean;
|
8
9
|
}) => React.ReactNode);
|
9
10
|
active?: boolean;
|
10
|
-
onClose?: (
|
11
|
+
onClose?: (args: {
|
12
|
+
reason: CloseReason;
|
13
|
+
}) => void;
|
11
14
|
onOpen?: () => void;
|
12
15
|
disableCloseOnClick?: boolean;
|
13
16
|
className?: G.ClassName;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
export { default } from "./Overlay";
|
2
|
-
export type { Props as OverlayProps } from "./Overlay.types";
|
2
|
+
export type { Props as OverlayProps, CloseReason as OverlayCloseReason } from "./Overlay.types";
|
@@ -1 +1 @@
|
|
1
|
-
:root{--rs-z-index-raised:5;--rs-z-index-flyout:80;--rs-z-index-fixed:90;--rs-z-index-overlay:100;--rs-z-index-notification:110}@layer rs.reset{blockquote,body,dd,dl,figcaption,figure,h1,h2,h3,h4,h5,h6,li,ol,p,ul{margin:0;padding:0}ol[class],ul[class]{list-style:none}textarea{resize:vertical}table{border-collapse:collapse;border-spacing:0}fieldset{border:0;margin:0;padding:0}img{display:block;max-width:100%}button,input,select,textarea{font:inherit}option{background:var(--rs-color-background-elevation-base)}label{cursor:pointer}input::placeholder,textarea::placeholder{color:var(--rs-color-foreground-neutral-faded);opacity:.5}html{-webkit-text-size-adjust:100%;-webkit-font-smoothing:antialiased;font-size:100%;text-rendering:optimizelegibility;touch-action:manipulation}*{box-sizing:border-box}body,html{background:var(--rs-color-background-page);color:var(--rs-color-foreground-neutral);height:100%;scroll-behavior:smooth}}[data-rs-theme]:not(html)
|
1
|
+
:root{--rs-z-index-raised:5;--rs-z-index-flyout:80;--rs-z-index-fixed:90;--rs-z-index-overlay:100;--rs-z-index-notification:110}@layer rs.reset{[data-rs-theme] blockquote,[data-rs-theme] body,[data-rs-theme] dd,[data-rs-theme] dl,[data-rs-theme] figcaption,[data-rs-theme] figure,[data-rs-theme] h1,[data-rs-theme] h2,[data-rs-theme] h3,[data-rs-theme] h4,[data-rs-theme] h5,[data-rs-theme] h6,[data-rs-theme] li,[data-rs-theme] ol,[data-rs-theme] p,[data-rs-theme] ul{margin:0;padding:0}[data-rs-theme] ol[class],[data-rs-theme] ul[class]{list-style:none}[data-rs-theme] textarea{resize:vertical}[data-rs-theme] table{border-collapse:collapse;border-spacing:0}[data-rs-theme] fieldset{border:0;margin:0;padding:0}[data-rs-theme] img{display:block;max-width:100%}[data-rs-theme] button,[data-rs-theme] input,[data-rs-theme] select,[data-rs-theme] textarea{font:inherit}[data-rs-theme] option{background:var(--rs-color-background-elevation-base)}[data-rs-theme] label{cursor:pointer}[data-rs-theme] input::placeholder,[data-rs-theme] textarea::placeholder{color:var(--rs-color-foreground-neutral-faded);opacity:.5}html[data-rs-theme]{-webkit-text-size-adjust:100%;-webkit-font-smoothing:antialiased;font-size:100%;text-rendering:optimizelegibility;touch-action:manipulation}[data-rs-theme] *{box-sizing:border-box}[data-rs-theme] body,html[data-rs-theme]{background:var(--rs-color-background-page);color:var(--rs-color-foreground-neutral);height:100%;scroll-behavior:smooth}}[data-rs-theme] body,[data-rs-theme]:not(html){font-family:var(--rs-font-family-body);font-size:var(--rs-font-size-body-3);font-weight:var(--rs-font-weight-regular);letter-spacing:var(--rs-letter-spacing-body-3);line-height:var(--rs-line-height-body-3)}[data-rs-color-mode=light]{color-scheme:light}[data-rs-color-mode=dark]{color-scheme:dark}@media (prefers-reduced-motion:reduce){*{animation-duration:.01ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important;transition-duration:.01ms!important}}[data-rs-no-transition] *,[data-rs-no-transition] :after,[data-rs-no-transition] :before{transition:none!important}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
3
3
|
import { classNames } from "../../utilities/helpers.js";
|
4
|
-
import
|
4
|
+
import { GlobalColorMode, PrivateTheme } from "../Theme/index.js";
|
5
5
|
import { ToastProvider } from "../Toast/index.js";
|
6
6
|
import useSingletonKeyboardMode from "../../hooks/_private/useSingletonKeyboardMode.js";
|
7
7
|
import { SingletonEnvironmentContext, useSingletonRTL, } from "../../hooks/_private/useSingletonEnvironment.js";
|
@@ -15,8 +15,8 @@ const ReshapedInner = (props) => {
|
|
15
15
|
return (_jsx(SingletonEnvironmentContext.Provider, { value: { rtl: rtlState, defaultViewport }, children: _jsx(SingletonHotkeysProvider, { children: _jsx(ToastProvider, { options: toastOptions, children: children }) }) }));
|
16
16
|
};
|
17
17
|
const Reshaped = (props) => {
|
18
|
-
const { theme, defaultTheme = "reshaped", defaultColorMode, className } = props;
|
18
|
+
const { theme, defaultTheme = "reshaped", defaultColorMode, scoped, className } = props;
|
19
19
|
const rootClassNames = classNames(s.root, className);
|
20
|
-
return (_jsx(GlobalColorMode, { defaultMode: defaultColorMode, children: _jsx(
|
20
|
+
return (_jsx(GlobalColorMode, { defaultMode: defaultColorMode, children: _jsx(PrivateTheme, { name: theme, defaultName: defaultTheme, className: rootClassNames, scoped: scoped, children: _jsx(ReshapedInner, { ...props, children: props.children }) }) }));
|
21
21
|
};
|
22
22
|
export default Reshaped;
|
@@ -1 +1 @@
|
|
1
|
-
.root{color:inherit;
|
1
|
+
.root{color:inherit;display:contents}
|
@@ -4,11 +4,12 @@ import type { ToastProviderProps } from "../Toast";
|
|
4
4
|
import type * as G from "../../types/global";
|
5
5
|
export type Props = {
|
6
6
|
children?: React.ReactNode;
|
7
|
+
theme?: NonNullable<ThemeProps["name"]>;
|
8
|
+
defaultTheme?: NonNullable<ThemeProps["defaultName"]>;
|
7
9
|
defaultRTL?: boolean;
|
8
10
|
defaultColorMode?: GlobalColorModeProps["defaultMode"];
|
9
11
|
defaultViewport?: G.Viewport;
|
10
|
-
className?: G.ClassName;
|
11
|
-
theme?: NonNullable<ThemeProps["name"]>;
|
12
|
-
defaultTheme?: NonNullable<ThemeProps["defaultName"]>;
|
13
12
|
toastOptions?: ToastProviderProps["options"];
|
13
|
+
scoped?: boolean;
|
14
|
+
className?: G.ClassName;
|
14
15
|
};
|
@@ -21,6 +21,6 @@ const Switch = (props) => {
|
|
21
21
|
checked: event.target.checked,
|
22
22
|
});
|
23
23
|
};
|
24
|
-
return (_jsxs("label", { ...attributes, className: rootClassNames, children: [_jsx("input", { type: "checkbox", ...inputAttributes, className: s.input, name: name, checked: checked, defaultChecked: defaultChecked, disabled: disabled, onChange: handleChange, onFocus: onFocus || inputAttributes?.onFocus, onBlur: onBlur || inputAttributes?.onBlur, id: id }), _jsx("span", { className: s.area, "aria-hidden": "true", children: _jsx("span", { className: s.thumb }) }), children && (_jsx(Text, { variant: size === "small" ? "caption-1" : "body-3", weight: "medium", children: children }))] }));
|
24
|
+
return (_jsxs("label", { ...attributes, className: rootClassNames, children: [_jsx("input", { type: "checkbox", ...inputAttributes, className: s.input, name: name, checked: checked, defaultChecked: defaultChecked, disabled: disabled, onChange: handleChange, onFocus: onFocus || inputAttributes?.onFocus, onBlur: onBlur || inputAttributes?.onBlur, id: id }), _jsx("span", { className: s.area, "aria-hidden": "true", children: _jsx("span", { className: s.thumb }) }), children && (_jsx(Text, { variant: size === "small" ? "caption-1" : "body-3", weight: "medium", color: disabled ? "disabled" : undefined, children: children }))] }));
|
25
25
|
};
|
26
26
|
export default Switch;
|
@@ -60,4 +60,9 @@ export const disabled = () => (<Example>
|
|
60
60
|
<Example.Item title="disabled, selected">
|
61
61
|
<Switch name="active" disabled defaultChecked inputAttributes={{ "aria-label": "test switch" }}/>
|
62
62
|
</Example.Item>
|
63
|
+
<Example.Item title="disabled, with label">
|
64
|
+
<Switch name="active" disabled>
|
65
|
+
Switch
|
66
|
+
</Switch>
|
67
|
+
</Example.Item>
|
63
68
|
</Example>);
|
@@ -4,11 +4,12 @@ import React from "react";
|
|
4
4
|
import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
|
5
5
|
import { enableTransitions, disableTransitions, onNextFrame } from "../../utilities/animation.js";
|
6
6
|
import { GlobalColorModeContext } from "./Theme.context.js";
|
7
|
+
import { getRootThemeEl } from "./Theme.utilities.js";
|
7
8
|
const GlobalColorMode = (props) => {
|
8
9
|
const { defaultMode, children } = props;
|
9
10
|
const [mode, setMode] = React.useState(defaultMode || "light");
|
10
11
|
const changeColorMode = React.useCallback((targetMode) => {
|
11
|
-
|
12
|
+
getRootThemeEl().setAttribute("data-rs-color-mode", targetMode);
|
12
13
|
setMode((prevMode) => {
|
13
14
|
if (prevMode !== targetMode) {
|
14
15
|
// Avoid components styles animating when switching to another color mode
|
@@ -27,7 +28,7 @@ const GlobalColorMode = (props) => {
|
|
27
28
|
* This could happen if we're receiving the mode on the client but before React hydration
|
28
29
|
*/
|
29
30
|
useIsomorphicLayoutEffect(() => {
|
30
|
-
const nextColorMode =
|
31
|
+
const nextColorMode = getRootThemeEl().getAttribute("data-rs-color-mode");
|
31
32
|
if (nextColorMode)
|
32
33
|
changeColorMode(nextColorMode);
|
33
34
|
}, []);
|
@@ -4,10 +4,12 @@ import React from "react";
|
|
4
4
|
import { classNames } from "../../utilities/helpers.js";
|
5
5
|
import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
|
6
6
|
import { ThemeContext } from "./Theme.context.js";
|
7
|
+
import { getRootThemeEl } from "./Theme.utilities.js";
|
7
8
|
import { useTheme, useGlobalColorMode } from "./useTheme.js";
|
8
9
|
import s from "./Theme.module.css";
|
9
|
-
const Theme = (props) => {
|
10
|
-
|
10
|
+
const Theme = (props) => _jsx(PrivateTheme, { ...props });
|
11
|
+
export const PrivateTheme = (props) => {
|
12
|
+
const { name, defaultName, colorMode, scoped, children, className } = props;
|
11
13
|
const [mounted, setMounted] = React.useState(false);
|
12
14
|
const [stateTheme, setStateTheme] = React.useState(defaultName);
|
13
15
|
const globalColorMode = useGlobalColorMode();
|
@@ -36,16 +38,15 @@ const Theme = (props) => {
|
|
36
38
|
useIsomorphicLayoutEffect(() => {
|
37
39
|
if (!document || !isRootProvider)
|
38
40
|
return;
|
39
|
-
const
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
const themeRootEl = getRootThemeEl();
|
42
|
+
const hasColorModeApplied = themeRootEl.getAttribute("data-rs-color-mode");
|
43
|
+
themeRootEl.setAttribute("data-rs-theme", usedTheme);
|
44
|
+
if (!hasColorModeApplied)
|
45
|
+
themeRootEl.setAttribute("data-rs-color-mode", usedColorMode);
|
44
46
|
return () => {
|
45
|
-
|
46
|
-
if (!hasColorModeApplied)
|
47
|
-
|
48
|
-
}
|
47
|
+
themeRootEl.removeAttribute("data-rs-theme");
|
48
|
+
if (!hasColorModeApplied)
|
49
|
+
themeRootEl.removeAttribute("data-rs-color-mode");
|
49
50
|
};
|
50
51
|
}, [usedTheme, usedColorMode, isRootProvider]);
|
51
52
|
const value = React.useMemo(() => ({
|
@@ -55,6 +56,6 @@ const Theme = (props) => {
|
|
55
56
|
setTheme,
|
56
57
|
setRootTheme,
|
57
58
|
}), [usedTheme, usedColorMode, setTheme, setRootTheme, rootTheme]);
|
58
|
-
return (_jsx(ThemeContext.Provider, { value: value, children: _jsx("div", { className: rootClassNames, "data-rs-theme": isRootProvider ? undefined : usedTheme, "data-rs-color-mode": isRootProvider || (!colorMode && !mounted) ? undefined : usedColorMode, children: children }) }));
|
59
|
+
return (_jsx(ThemeContext.Provider, { value: value, children: _jsx("div", { className: rootClassNames, "data-rs-root": scoped ? true : undefined, "data-rs-theme": isRootProvider ? undefined : usedTheme, "data-rs-color-mode": isRootProvider || (!colorMode && !mounted) ? undefined : usedColorMode, children: children }) }));
|
59
60
|
};
|
60
61
|
export default Theme;
|
@@ -20,7 +20,11 @@ export type Props = {
|
|
20
20
|
className?: G.ClassName;
|
21
21
|
children?: React.ReactNode;
|
22
22
|
};
|
23
|
+
export type PrivateProps = Props & {
|
24
|
+
scoped?: boolean;
|
25
|
+
};
|
23
26
|
export type GlobalColorModeProps = {
|
24
27
|
defaultMode?: ColorMode;
|
28
|
+
scoped?: boolean;
|
25
29
|
children?: React.ReactNode;
|
26
30
|
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getRootThemeEl: () => Element;
|
@@ -0,0 +1 @@
|
|
1
|
+
export const getRootThemeEl = () => document.querySelector("[data-rs-root]") || document.documentElement;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { default } from "./Theme";
|
1
|
+
export { default, PrivateTheme } from "./Theme";
|
2
2
|
export { default as GlobalColorMode } from "./GlobalColorMode";
|
3
3
|
export { useTheme } from "./useTheme";
|
4
4
|
export type { Props as ThemeProps, GlobalColorModeProps } from "./Theme.types";
|
@@ -5,9 +5,9 @@ import Text from "../Text/index.js";
|
|
5
5
|
import Flyout from "../_private/Flyout/index.js";
|
6
6
|
import s from "./Tooltip.module.css";
|
7
7
|
const Tooltip = (props) => {
|
8
|
-
const { id, text, children, onOpen, onClose, position = "bottom", active, disabled, disableContentHover, } = props;
|
8
|
+
const { id, text, children, onOpen, onClose, position = "bottom", containerRef, active, disabled, disableContentHover, } = props;
|
9
9
|
if (!text)
|
10
10
|
return _jsx(_Fragment, { children: children({}) });
|
11
|
-
return (_jsxs(Flyout, { id: id, active: active, position: position, disabled: disabled, onOpen: onOpen, onClose: onClose, disableContentHover: disableContentHover, triggerType: "hover", children: [_jsx(Flyout.Trigger, { children: children }), _jsx(Flyout.Content, { children: _jsx(Theme, { colorMode: "inverted", children: _jsx(Text, { variant: "caption-1", className: s.root, children: text }) }) })] }));
|
11
|
+
return (_jsxs(Flyout, { id: id, active: active, position: position, disabled: disabled, onOpen: onOpen, onClose: onClose, disableContentHover: disableContentHover, containerRef: containerRef, triggerType: "hover", children: [_jsx(Flyout.Trigger, { children: children }), _jsx(Flyout.Content, { children: _jsx(Theme, { colorMode: "inverted", children: _jsx(Text, { variant: "caption-1", className: s.root, children: text }) }) })] }));
|
12
12
|
};
|
13
13
|
export default Tooltip;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import type { FlyoutProps, FlyoutTriggerProps } from "../_private/Flyout";
|
3
|
-
export type Props = Pick<FlyoutProps, "id" | "position" | "onOpen" | "onClose" | "active" | "disabled" | "disableContentHover"> & {
|
3
|
+
export type Props = Pick<FlyoutProps, "id" | "position" | "onOpen" | "onClose" | "active" | "disabled" | "disableContentHover" | "containerRef"> & {
|
4
4
|
children: (attributes: Parameters<FlyoutTriggerProps["children"]>[0] | {}) => React.ReactNode;
|
5
5
|
text?: React.ReactNode;
|
6
6
|
};
|
@@ -95,14 +95,12 @@ const FlyoutRoot = (props) => {
|
|
95
95
|
if (
|
96
96
|
// Empty flyouts don't move the focus so they have to be closed on blur
|
97
97
|
focusedContent ||
|
98
|
-
// Content menu keeps the focus on the original trigger so moving the focus away from it shouldn't close it
|
99
|
-
(triggerType === "hover" && trapFocusMode === "content-menu") ||
|
100
98
|
// Prevent from closing in case user interacts with items inside content
|
101
99
|
lockedBlurEffects.current) {
|
102
100
|
return;
|
103
101
|
}
|
104
102
|
handleClose();
|
105
|
-
}, [handleClose
|
103
|
+
}, [handleClose]);
|
106
104
|
const handleFocus = React.useCallback(() => {
|
107
105
|
if (triggerType === "hover" && !checkKeyboardMode())
|
108
106
|
return;
|
@@ -91,6 +91,12 @@ export const modes = () => (<Example>
|
|
91
91
|
</Demo>
|
92
92
|
</Example.Item>
|
93
93
|
|
94
|
+
<Example.Item title="content-menu hover without buttons">
|
95
|
+
<Demo position="bottom-start" trapFocusMode="content-menu" triggerType="hover">
|
96
|
+
<div style={{ height: 50, width: 50, background: "tomato" }}/>
|
97
|
+
</Demo>
|
98
|
+
</Example.Item>
|
99
|
+
|
94
100
|
<Example.Item title="content-menu hover">
|
95
101
|
<Demo position="bottom-start" trapFocusMode="content-menu" triggerType="hover">
|
96
102
|
<button type="button">Item 1</button>
|
@@ -36,11 +36,11 @@ const useResponsiveClientValue = (value) => {
|
|
36
36
|
return value;
|
37
37
|
}
|
38
38
|
if (viewport === "xl")
|
39
|
-
return value.xl
|
39
|
+
return value.xl ?? value.l ?? value.m ?? value.s;
|
40
40
|
if (viewport === "l")
|
41
|
-
return value.l
|
41
|
+
return value.l ?? value.m ?? value.s;
|
42
42
|
if (viewport === "m")
|
43
|
-
return value.m
|
43
|
+
return value.m ?? value.s;
|
44
44
|
return value.s;
|
45
45
|
};
|
46
46
|
export default useResponsiveClientValue;
|