reshaped 3.2.4 → 3.2.6-rc.0

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 (43) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/bundle.css +1 -1
  3. package/dist/bundle.js +11 -11
  4. package/dist/components/Actionable/Actionable.js +5 -1
  5. package/dist/components/Actionable/Actionable.types.d.ts +1 -0
  6. package/dist/components/Button/Button.js +2 -2
  7. package/dist/components/Button/Button.types.d.ts +1 -1
  8. package/dist/components/DropdownMenu/DropdownMenu.js +1 -0
  9. package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +1 -1
  10. package/dist/components/Link/Link.d.ts +1 -1
  11. package/dist/components/Link/Link.js +2 -2
  12. package/dist/components/Link/Link.types.d.ts +1 -1
  13. package/dist/components/Link/tests/Link.stories.d.ts +1 -1
  14. package/dist/components/MenuItem/MenuItem.js +2 -2
  15. package/dist/components/MenuItem/MenuItem.types.d.ts +1 -1
  16. package/dist/components/Modal/Modal.module.css +1 -1
  17. package/dist/components/Popover/Popover.types.d.ts +1 -1
  18. package/dist/components/Reshaped/Reshaped.js +5 -1
  19. package/dist/components/Tabs/TabsList.js +7 -16
  20. package/dist/components/Theme/GlobalColorMode.js +11 -6
  21. package/dist/components/Theme/Theme.context.js +2 -12
  22. package/dist/components/Theme/Theme.js +6 -6
  23. package/dist/components/Theme/Theme.types.d.ts +3 -2
  24. package/dist/components/Theme/Theme.utilities.d.ts +1 -1
  25. package/dist/components/Theme/Theme.utilities.js +10 -1
  26. package/dist/components/Theme/tests/Theme.stories.d.ts +1 -0
  27. package/dist/components/Theme/tests/Theme.stories.js +34 -1
  28. package/dist/components/Theme/useTheme.d.ts +1 -1
  29. package/dist/components/Theme/useTheme.js +1 -2
  30. package/dist/components/Tooltip/Tooltip.js +2 -2
  31. package/dist/components/Tooltip/Tooltip.types.d.ts +1 -1
  32. package/dist/components/_private/Flyout/Flyout.types.d.ts +3 -1
  33. package/dist/components/_private/Flyout/FlyoutControlled.js +2 -1
  34. package/dist/components/_private/Flyout/tests/Flyout.stories.d.ts +4 -4
  35. package/dist/components/_private/Flyout/tests/Flyout.stories.js +26 -19
  36. package/dist/components/_private/Flyout/useFlyout.d.ts +1 -0
  37. package/dist/components/_private/Flyout/useFlyout.js +7 -4
  38. package/dist/components/_private/Flyout/utilities/calculatePosition.js +7 -7
  39. package/dist/hooks/_private/useSingletonHotkeys.d.ts +3 -3
  40. package/dist/hooks/_private/useSingletonHotkeys.js +22 -16
  41. package/dist/hooks/tests/useHotkeys.stories.js +5 -2
  42. package/dist/hooks/useHotkeys.d.ts +2 -1
  43. package/package.json +1 -1
@@ -5,7 +5,7 @@ import { classNames } from "../../utilities/helpers.js";
5
5
  import * as keys from "../../constants/keys.js";
6
6
  import s from "./Actionable.module.css";
7
7
  const Actionable = forwardRef((props, ref) => {
8
- const { children, href, onClick, type, disabled, insetFocus, disableFocusRing, borderRadius, as, fullWidth, className, attributes, } = props;
8
+ const { children, href, onClick, type, disabled, insetFocus, disableFocusRing, borderRadius, as, stopPropagation, fullWidth, className, attributes, } = props;
9
9
  const rootClassNames = classNames(s.root, className, disabled && s["--disabled"], borderRadius && s[`--radius-${borderRadius}`], insetFocus && s["--inset"], disableFocusRing && s["--disabled-focus-ring"], fullWidth && s["--full-width"]);
10
10
  const rootAttributes = { ...attributes };
11
11
  const hasClickHandler = onClick || attributes?.onClick;
@@ -38,6 +38,8 @@ const Actionable = forwardRef((props, ref) => {
38
38
  const handlePress = (event) => {
39
39
  if (disabled)
40
40
  return;
41
+ if (stopPropagation)
42
+ event.stopPropagation();
41
43
  onClick?.(event);
42
44
  attributes?.onClick?.(event);
43
45
  };
@@ -48,6 +50,8 @@ const Actionable = forwardRef((props, ref) => {
48
50
  return;
49
51
  if (rootAttributes.role !== "button")
50
52
  return;
53
+ if (stopPropagation)
54
+ event.stopPropagation();
51
55
  event.preventDefault();
52
56
  handlePress(event);
53
57
  };
@@ -10,6 +10,7 @@ export type Props = {
10
10
  insetFocus?: boolean;
11
11
  disableFocusRing?: boolean;
12
12
  borderRadius?: "inherit";
13
+ stopPropagation?: boolean;
13
14
  as?: keyof JSX.IntrinsicElements;
14
15
  className?: G.ClassName;
15
16
  attributes?: G.Attributes<"button"> & Omit<JSX.IntrinsicElements["a"], keyof G.Attributes<"button">> & {
@@ -8,7 +8,7 @@ import ButtonGroup from "./ButtonGroup.js";
8
8
  import ButtonAligner from "./ButtonAligner.js";
9
9
  import s from "./Button.module.css";
10
10
  const Button = forwardRef((props, ref) => {
11
- const { variant = "solid", color = "neutral", elevated, highlighted, fullWidth, loading, disabled, type, href, size = "medium", children, rounded, onClick, icon, endIcon, as, className, attributes, } = props;
11
+ const { variant = "solid", color = "neutral", elevated, highlighted, fullWidth, loading, disabled, type, href, size = "medium", children, rounded, onClick, icon, endIcon, stopPropagation, as, className, attributes, } = props;
12
12
  const iconOnly = (icon || endIcon) && !children;
13
13
  const rootClassName = classNames(s.root, className, color && s[`--color-${color}`], variant && s[`--variant-${variant}`], responsiveClassNames(s, "--size", size), responsiveClassNames(s, "--full-width", fullWidth), elevated && variant !== "ghost" && s["--elevated"], rounded && s["--rounded"], disabled && s["--disabled"], loading && s["--loading"], highlighted && s["--highlighted"], iconOnly && s["--icon-only"]);
14
14
  const renderIcon = (position) => {
@@ -27,7 +27,7 @@ const Button = forwardRef((props, ref) => {
27
27
  });
28
28
  return (_jsx(Icon, { className: iconClassName, svg: (position === "start" ? icon : endIcon), size: iconSize, autoWidth: true }));
29
29
  };
30
- return (_jsxs(Actionable, { disabled: disabled || loading, className: rootClassName, attributes: { ...attributes, "data-rs-aligner-target": true }, type: type, onClick: onClick, href: href, ref: ref, as: as, children: [loading && (_jsx("div", { className: s.loader, children: _jsx(Loader, { color: "inherit" }) })), renderIcon("start"), children && _jsx("span", { className: s.text, children: children }), renderIcon("end")] }));
30
+ return (_jsxs(Actionable, { disabled: disabled || loading, className: rootClassName, attributes: { ...attributes, "data-rs-aligner-target": true }, type: type, onClick: onClick, href: href, ref: ref, as: as, stopPropagation: stopPropagation, children: [loading && (_jsx("div", { className: s.loader, children: _jsx(Loader, { color: "inherit" }) })), renderIcon("start"), children && _jsx("span", { className: s.text, children: children }), renderIcon("end")] }));
31
31
  });
32
32
  Button.Group = ButtonGroup;
33
33
  Button.Aligner = ButtonAligner;
@@ -4,7 +4,7 @@ import type { ActionableProps } from "../Actionable";
4
4
  import type { AlignerProps as BaseAlignerProps } from "../_private/Aligner";
5
5
  import type * as G from "../../types/global";
6
6
  export type Size = "xlarge" | "large" | "medium" | "small";
7
- export type Props = Pick<ActionableProps, "attributes" | "className" | "disabled" | "children" | "href" | "onClick" | "type" | "as"> & {
7
+ export type Props = Pick<ActionableProps, "attributes" | "className" | "disabled" | "children" | "href" | "onClick" | "type" | "as" | "stopPropagation"> & {
8
8
  color?: "primary" | "critical" | "positive" | "neutral" | "media" | "inherit";
9
9
  variant?: "solid" | "outline" | "ghost" | "faded";
10
10
  icon?: IconProps["svg"];
@@ -27,6 +27,7 @@ const DropdownMenuContent = (props) => {
27
27
  },
28
28
  }, [subMenuInstance?.current], {
29
29
  disabled: flyout.status === "idle",
30
+ ref: attributes?.ref,
30
31
  });
31
32
  const contentClassName = classNames(s.menu, className);
32
33
  return (_jsx(Popover.Content, { className: contentClassName, attributes: { ...attributes, ref }, children: children }));
@@ -2,7 +2,7 @@ import type React from "react";
2
2
  import type { PopoverProps, PopoverInstance } from "../Popover";
3
3
  import type { FlyoutContentProps } from "../_private/Flyout";
4
4
  export type Instance = PopoverInstance;
5
- export type Props = Pick<PopoverProps, "children" | "position" | "forcePosition" | "fallbackPositions" | "triggerType" | "contentGap" | "onOpen" | "onClose" | "active" | "defaultActive" | "width" | "disableHideAnimation" | "disableCloseOnOutsideClick" | "instanceRef" | "containerRef"> & {
5
+ export type Props = Pick<PopoverProps, "children" | "position" | "forcePosition" | "fallbackPositions" | "triggerType" | "contentGap" | "contentShift" | "onOpen" | "onClose" | "active" | "defaultActive" | "width" | "disableHideAnimation" | "disableCloseOnOutsideClick" | "instanceRef" | "containerRef"> & {
6
6
  trapFocusMode?: Extract<PopoverProps["trapFocusMode"], "action-menu" | "selection-menu">;
7
7
  };
8
8
  export type ContentProps = Pick<FlyoutContentProps, "attributes" | "children" | "className">;
@@ -1,4 +1,4 @@
1
- declare const Link: import("react").ForwardRefExoticComponent<Pick<import("../Actionable").ActionableProps, "disabled" | "className" | "attributes" | "children" | "type" | "onClick" | "href"> & {
1
+ declare const Link: import("react").ForwardRefExoticComponent<Pick<import("../Actionable").ActionableProps, "disabled" | "className" | "attributes" | "children" | "type" | "onClick" | "href" | "stopPropagation"> & {
2
2
  icon?: import("../Icon").IconProps["svg"];
3
3
  color?: "inherit" | "critical" | "primary" | "positive" | "warning";
4
4
  variant?: "plain" | "underline";
@@ -5,8 +5,8 @@ import Actionable from "../Actionable/index.js";
5
5
  import Icon from "../Icon/index.js";
6
6
  import s from "./Link.module.css";
7
7
  const Link = forwardRef((props, ref) => {
8
- const { icon, disabled, href, color = "primary", variant = "underline", className, children, attributes, type, onClick, } = props;
8
+ const { icon, disabled, href, color = "primary", variant = "underline", className, children, attributes, type, onClick, stopPropagation, } = props;
9
9
  const rootClassNames = classNames(s.root, className, disabled && s["--disabled"], variant && s[`--variant-${variant}`], color && s[`--color-${color}`], icon && s["--with-icon"]);
10
- return (_jsxs(Actionable, { href: href, disabled: disabled, className: rootClassNames, attributes: attributes, type: type, onClick: onClick, ref: ref, children: [icon && _jsx(Icon, { svg: icon }), children] }));
10
+ return (_jsxs(Actionable, { href: href, disabled: disabled, className: rootClassNames, attributes: attributes, type: type, onClick: onClick, ref: ref, stopPropagation: stopPropagation, children: [icon && _jsx(Icon, { svg: icon }), children] }));
11
11
  });
12
12
  export default Link;
@@ -1,6 +1,6 @@
1
1
  import type { ActionableProps } from "../Actionable";
2
2
  import type { IconProps } from "../Icon";
3
- export type Props = Pick<ActionableProps, "attributes" | "className" | "disabled" | "children" | "href" | "onClick" | "type"> & {
3
+ export type Props = Pick<ActionableProps, "attributes" | "className" | "disabled" | "children" | "href" | "onClick" | "type" | "stopPropagation"> & {
4
4
  icon?: IconProps["svg"];
5
5
  color?: "inherit" | "critical" | "primary" | "positive" | "warning";
6
6
  variant?: "plain" | "underline";
@@ -1,6 +1,6 @@
1
1
  declare const _default: {
2
2
  title: string;
3
- component: import("react").ForwardRefExoticComponent<Pick<import("../../Actionable").ActionableProps, "children" | "disabled" | "className" | "attributes" | "type" | "onClick" | "href"> & {
3
+ component: import("react").ForwardRefExoticComponent<Pick<import("../../Actionable").ActionableProps, "children" | "disabled" | "className" | "attributes" | "type" | "onClick" | "href" | "stopPropagation"> & {
4
4
  icon?: import("../../Icon").IconProps["svg"];
5
5
  color?: "inherit" | "critical" | "primary" | "positive" | "warning";
6
6
  variant?: "plain" | "underline";
@@ -7,11 +7,11 @@ import View from "../View/index.js";
7
7
  import MenuItemAligner from "./MenuItemAligner.js";
8
8
  import s from "./MenuItem.module.css";
9
9
  const MenuItem = forwardRef((props, ref) => {
10
- const { icon, startSlot, endSlot, children, color = "primary", selected, disabled, onClick, href, size = "medium", roundedCorners, as, className, attributes, } = props;
10
+ const { icon, startSlot, endSlot, children, color = "primary", selected, disabled, onClick, href, size = "medium", roundedCorners, stopPropagation, as, className, attributes, } = props;
11
11
  const rootClassNames = classNames(s.root, className, responsiveClassNames(s, "--size", size), responsiveClassNames(s, "--rounded-corners", roundedCorners), color && s[`--color-${color}`], selected && s["--selected"], disabled && s["--disabled"]);
12
12
  const gapSize = responsivePropDependency(size, (size) => (size === "large" ? 3 : 2));
13
13
  const iconSize = responsivePropDependency(size, (size) => (size === "large" ? 5 : 4));
14
- return (_jsx(Actionable, { disabled: disabled, className: rootClassNames, attributes: { ...attributes, "data-rs-aligner-target": true }, onClick: onClick, href: href, ref: ref, as: as, children: _jsxs(View, { direction: "row", gap: gapSize, align: "center", children: [icon && _jsx(Icon, { svg: icon, className: s.icon, size: iconSize }), !icon && startSlot, children && (_jsx(View.Item, { grow: true, className: s.content, children: children })), endSlot] }) }));
14
+ return (_jsx(Actionable, { disabled: disabled, className: rootClassNames, attributes: { ...attributes, "data-rs-aligner-target": true }, onClick: onClick, href: href, ref: ref, as: as, stopPropagation: stopPropagation, children: _jsxs(View, { direction: "row", gap: gapSize, align: "center", children: [icon && _jsx(Icon, { svg: icon, className: s.icon, size: iconSize }), !icon && startSlot, children && (_jsx(View.Item, { grow: true, className: s.content, children: children })), endSlot] }) }));
15
15
  });
16
16
  MenuItem.Aligner = MenuItemAligner;
17
17
  export default MenuItem;
@@ -3,7 +3,7 @@ import type { IconProps } from "../Icon";
3
3
  import type { ActionableProps } from "../Actionable";
4
4
  import type * as G from "../../types/global";
5
5
  export type Size = "small" | "medium" | "large";
6
- export type Props = Pick<ActionableProps, "attributes" | "className" | "disabled" | "children" | "href" | "onClick" | "as"> & {
6
+ export type Props = Pick<ActionableProps, "attributes" | "className" | "disabled" | "children" | "href" | "onClick" | "as" | "stopPropagation"> & {
7
7
  color?: "neutral" | "critical" | "primary";
8
8
  icon?: IconProps["svg"];
9
9
  startSlot?: React.ReactNode;
@@ -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}[data-rs-keyboard] .root:focus{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(100% - 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(100% - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translateY(100%);width:100%}.--position-bottom.--contained{position:absolute}.--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(100% - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(-100%);width:var(--rs-modal-size)}.--position-start.--contained{position:absolute}[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(100% - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(100%);width:var(--rs-modal-size)}.--position-end.--contained{position:absolute}[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.--contained{position:absolute}.--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(100% - 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(100% - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translateY(100%);width:100%}.--position-bottom--m.--contained{position:absolute}.--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(100% - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(-100%);width:var(--rs-modal-size)}.--position-start--m.--contained{position:absolute}[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(100% - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(100%);width:var(--rs-modal-size)}.--position-end--m.--contained{position:absolute}[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.--contained{position:absolute}.--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(100% - 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(100% - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translateY(100%);width:100%}.--position-bottom--l.--contained{position:absolute}.--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(100% - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(-100%);width:var(--rs-modal-size)}.--position-start--l.--contained{position:absolute}[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(100% - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(100%);width:var(--rs-modal-size)}.--position-end--l.--contained{position:absolute}[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.--contained{position:absolute}.--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(100% - 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(100% - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translateY(100%);width:100%}.--position-bottom--xl.--contained{position:absolute}.--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(100% - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(-100%);width:var(--rs-modal-size)}.--position-start--xl.--contained{position:absolute}[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(100% - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate(100%);width:var(--rs-modal-size)}.--position-end--xl.--contained{position:absolute}[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.--contained{position:absolute}.--position-full-screen--xl.--active,[dir=rtl] .--position-full-screen--xl.--active{opacity:1;transform:translate(0)!important}}
1
+ .root{--rs-modal-container-width:100vw;--rs-modal-position:fixed;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}[data-rs-keyboard] .root:focus{box-shadow:var(--rs-focus-shadow);outline:none}.root.--contained{--rs-modal-position:absolute;--rs-modal-container-width:100%}.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(var(--rs-modal-container-width) - 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(var(--rs-modal-container-width) - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:var(--rs-modal-position);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(var(--rs-modal-container-width) - var(--rs-unit-x4));opacity:1;overflow:auto;position:var(--rs-modal-position);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(var(--rs-modal-container-width) - var(--rs-unit-x4));opacity:1;overflow:auto;position:var(--rs-modal-position);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:var(--rs-modal-container-width);opacity:0;overflow:auto;position:var(--rs-modal-position);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(var(--rs-modal-container-width) - 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(var(--rs-modal-container-width) - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:var(--rs-modal-position);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(var(--rs-modal-container-width) - var(--rs-unit-x4));opacity:1;overflow:auto;position:var(--rs-modal-position);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(var(--rs-modal-container-width) - var(--rs-unit-x4));opacity:1;overflow:auto;position:var(--rs-modal-position);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:var(--rs-modal-container-width);opacity:0;overflow:auto;position:var(--rs-modal-position);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(var(--rs-modal-container-width) - 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(var(--rs-modal-container-width) - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:var(--rs-modal-position);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(var(--rs-modal-container-width) - var(--rs-unit-x4));opacity:1;overflow:auto;position:var(--rs-modal-position);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(var(--rs-modal-container-width) - var(--rs-unit-x4));opacity:1;overflow:auto;position:var(--rs-modal-position);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:var(--rs-modal-container-width);opacity:0;overflow:auto;position:var(--rs-modal-position);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(var(--rs-modal-container-width) - 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(var(--rs-modal-container-width) - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:var(--rs-modal-position);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(var(--rs-modal-container-width) - var(--rs-unit-x4));opacity:1;overflow:auto;position:var(--rs-modal-position);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(var(--rs-modal-container-width) - var(--rs-unit-x4));opacity:1;overflow:auto;position:var(--rs-modal-position);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:var(--rs-modal-container-width);opacity:0;overflow:auto;position:var(--rs-modal-position);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,7 +1,7 @@
1
1
  import type React from "react";
2
2
  import type { FlyoutProps, FlyoutInstance } from "../_private/Flyout";
3
3
  export type Instance = FlyoutInstance;
4
- export type Props = Pick<FlyoutProps, "id" | "position" | "forcePosition" | "fallbackPositions" | "onOpen" | "onClose" | "width" | "trapFocusMode" | "active" | "defaultActive" | "contentGap" | "instanceRef" | "triggerType" | "disableHideAnimation" | "disableContentHover" | "disableCloseOnOutsideClick" | "containerRef" | "initialFocusRef"> & {
4
+ export type Props = Pick<FlyoutProps, "id" | "position" | "forcePosition" | "fallbackPositions" | "onOpen" | "onClose" | "width" | "trapFocusMode" | "active" | "defaultActive" | "contentGap" | "contentShift" | "instanceRef" | "triggerType" | "disableHideAnimation" | "disableContentHover" | "disableCloseOnOutsideClick" | "containerRef" | "initialFocusRef"> & {
5
5
  children?: React.ReactNode;
6
6
  padding?: number;
7
7
  variant?: "elevated" | "headless";
@@ -1,8 +1,10 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
+ import React from "react";
3
4
  import { classNames } from "../../utilities/helpers.js";
4
5
  import { GlobalColorMode, PrivateTheme } from "../Theme/index.js";
5
6
  import { ToastProvider } from "../Toast/index.js";
7
+ import { useGlobalColorMode } from "../Theme/useTheme.js";
6
8
  import useSingletonKeyboardMode from "../../hooks/_private/useSingletonKeyboardMode.js";
7
9
  import { SingletonEnvironmentContext, useSingletonRTL, } from "../../hooks/_private/useSingletonEnvironment.js";
8
10
  import { SingletonHotkeysProvider } from "../../hooks/_private/useSingletonHotkeys.js";
@@ -17,6 +19,8 @@ const ReshapedInner = (props) => {
17
19
  const Reshaped = (props) => {
18
20
  const { theme, defaultTheme = "reshaped", defaultColorMode, scoped, className } = props;
19
21
  const rootClassNames = classNames(s.root, className);
20
- return (_jsx(GlobalColorMode, { defaultMode: defaultColorMode, children: _jsx(PrivateTheme, { name: theme, defaultName: defaultTheme, className: rootClassNames, scoped: scoped, children: _jsx(ReshapedInner, { ...props, children: props.children }) }) }));
22
+ const scopeRef = React.useRef(null);
23
+ const parentGlobalColorMode = useGlobalColorMode();
24
+ return (_jsx(GlobalColorMode, { defaultMode: defaultColorMode || parentGlobalColorMode.mode || "light", scopeRef: !!parentGlobalColorMode && scoped ? scopeRef : undefined, children: _jsx(PrivateTheme, { name: theme, defaultName: defaultTheme, className: rootClassNames, scoped: scoped, scopeRef: !!parentGlobalColorMode && scoped ? scopeRef : undefined, children: _jsx(ReshapedInner, { ...props, children: props.children }) }) }));
21
25
  };
22
26
  export default Reshaped;
@@ -60,30 +60,21 @@ const TabsList = (props) => {
60
60
  };
61
61
  }, [elScrollableRef]);
62
62
  const { ref: hotkeysRef } = useHotkeys({
63
- "ArrowLeft, ArrowUp": (e) => {
64
- if (name)
65
- return;
66
- e.preventDefault();
63
+ "ArrowLeft, ArrowUp": () => {
67
64
  focusPreviousElement(elScrollableRef.current);
68
65
  },
69
- "ArrowRight, ArrowDown": (e) => {
70
- if (name)
71
- return;
72
- e.preventDefault();
66
+ "ArrowRight, ArrowDown": () => {
73
67
  focusNextElement(elScrollableRef.current);
74
68
  },
75
- Home: (e) => {
76
- if (name)
77
- return;
78
- e.preventDefault();
69
+ Home: () => {
79
70
  focusFirstElement(elScrollableRef.current);
80
71
  },
81
- End: (e) => {
82
- if (name)
83
- return;
84
- e.preventDefault();
72
+ End: () => {
85
73
  focusLastElement(elScrollableRef.current);
86
74
  },
75
+ }, [], {
76
+ preventDefault: true,
77
+ disabled: !!name,
87
78
  });
88
79
  useIsomorphicLayoutEffect(() => {
89
80
  if (value)
@@ -3,13 +3,18 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import React from "react";
4
4
  import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
5
5
  import { enableTransitions, disableTransitions, onNextFrame } from "../../utilities/animation.js";
6
+ import { useGlobalColorMode } from "./useTheme.js";
6
7
  import { GlobalColorModeContext } from "./Theme.context.js";
7
8
  import { getRootThemeEl } from "./Theme.utilities.js";
8
9
  const GlobalColorMode = (props) => {
9
- const { defaultMode, children } = props;
10
- const [mode, setMode] = React.useState(defaultMode || "light");
10
+ const { defaultMode, scopeRef, children } = props;
11
+ const [mode, setMode] = React.useState(defaultMode);
12
+ const parentGlobalColorMode = useGlobalColorMode();
11
13
  const changeColorMode = React.useCallback((targetMode) => {
12
- getRootThemeEl().setAttribute("data-rs-color-mode", targetMode);
14
+ getRootThemeEl(scopeRef?.current).setAttribute("data-rs-color-mode", targetMode);
15
+ if (parentGlobalColorMode.mode && !scopeRef) {
16
+ parentGlobalColorMode.setMode(targetMode);
17
+ }
13
18
  setMode((prevMode) => {
14
19
  if (prevMode !== targetMode) {
15
20
  // Avoid components styles animating when switching to another color mode
@@ -17,7 +22,7 @@ const GlobalColorMode = (props) => {
17
22
  }
18
23
  return targetMode;
19
24
  });
20
- }, []);
25
+ }, [scopeRef, parentGlobalColorMode]);
21
26
  useIsomorphicLayoutEffect(() => {
22
27
  onNextFrame(() => {
23
28
  enableTransitions();
@@ -28,10 +33,10 @@ const GlobalColorMode = (props) => {
28
33
  * This could happen if we're receiving the mode on the client but before React hydration
29
34
  */
30
35
  useIsomorphicLayoutEffect(() => {
31
- const nextColorMode = getRootThemeEl().getAttribute("data-rs-color-mode");
36
+ const nextColorMode = getRootThemeEl(scopeRef?.current).getAttribute("data-rs-color-mode");
32
37
  if (nextColorMode)
33
38
  changeColorMode(nextColorMode);
34
- }, []);
39
+ }, [changeColorMode, scopeRef]);
35
40
  const value = React.useMemo(() => ({
36
41
  mode,
37
42
  setMode: changeColorMode,
@@ -1,16 +1,6 @@
1
1
  "use client";
2
2
  import React from "react";
3
3
  /* Context used to store data responsible for switching between modes of a theme */
4
- export const ThemeContext = React.createContext({
5
- theme: "",
6
- rootTheme: "",
7
- colorMode: "light",
8
- setTheme: () => { },
9
- setRootTheme: () => { },
10
- });
4
+ export const ThemeContext = React.createContext({});
11
5
  /* Context used to globally define mode, used only within the library */
12
- export const GlobalColorModeContext = React.createContext({
13
- mode: "light",
14
- setMode: () => { },
15
- invertMode: () => { },
16
- });
6
+ export const GlobalColorModeContext = React.createContext({});
@@ -9,15 +9,15 @@ import { useTheme, useGlobalColorMode } from "./useTheme.js";
9
9
  import s from "./Theme.module.css";
10
10
  const Theme = (props) => _jsx(PrivateTheme, { ...props });
11
11
  export const PrivateTheme = (props) => {
12
- const { name, defaultName, colorMode, scoped, children, className } = props;
12
+ const { name, defaultName, colorMode, scoped, scopeRef, children, className } = props;
13
13
  const [mounted, setMounted] = React.useState(false);
14
14
  const [stateTheme, setStateTheme] = React.useState(defaultName);
15
15
  const globalColorMode = useGlobalColorMode();
16
16
  const parentTheme = useTheme();
17
17
  const isRootProvider = !parentTheme.theme;
18
18
  const usedTheme = name || stateTheme || parentTheme.theme;
19
- const rootTheme = isRootProvider ? usedTheme : parentTheme.rootTheme;
20
- const parentColorMode = isRootProvider ? globalColorMode : parentTheme.colorMode;
19
+ const rootTheme = isRootProvider || scoped ? usedTheme : parentTheme.rootTheme;
20
+ const parentColorMode = isRootProvider || scoped ? globalColorMode.mode : parentTheme.colorMode;
21
21
  const invertedColorMode = parentColorMode === "light" ? "dark" : "light";
22
22
  const usedColorMode = colorMode === "inverted" ? invertedColorMode : colorMode || parentColorMode;
23
23
  const rootClassNames = classNames(s.root, className);
@@ -38,7 +38,7 @@ export const PrivateTheme = (props) => {
38
38
  useIsomorphicLayoutEffect(() => {
39
39
  if (!document || !isRootProvider)
40
40
  return;
41
- const themeRootEl = getRootThemeEl();
41
+ const themeRootEl = getRootThemeEl(scopeRef?.current);
42
42
  const hasColorModeApplied = themeRootEl.getAttribute("data-rs-color-mode");
43
43
  themeRootEl.setAttribute("data-rs-theme", usedTheme);
44
44
  if (!hasColorModeApplied)
@@ -48,7 +48,7 @@ export const PrivateTheme = (props) => {
48
48
  if (!hasColorModeApplied)
49
49
  themeRootEl.removeAttribute("data-rs-color-mode");
50
50
  };
51
- }, [usedTheme, usedColorMode, isRootProvider]);
51
+ }, [usedTheme, usedColorMode, isRootProvider, scopeRef]);
52
52
  const value = React.useMemo(() => ({
53
53
  theme: usedTheme,
54
54
  rootTheme,
@@ -56,6 +56,6 @@ export const PrivateTheme = (props) => {
56
56
  setTheme,
57
57
  setRootTheme,
58
58
  }), [usedTheme, usedColorMode, setTheme, setRootTheme, rootTheme]);
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
+ return (_jsx(ThemeContext.Provider, { value: value, children: _jsx("div", { className: rootClassNames, ref: scopeRef, "data-rs-root": scoped ? true : undefined, "data-rs-theme": isRootProvider ? undefined : usedTheme, "data-rs-color-mode": isRootProvider || (!colorMode && !mounted) ? undefined : usedColorMode, children: children }) }));
60
60
  };
61
61
  export default Theme;
@@ -22,9 +22,10 @@ export type Props = {
22
22
  };
23
23
  export type PrivateProps = Props & {
24
24
  scoped?: boolean;
25
+ scopeRef?: React.RefObject<HTMLDivElement>;
25
26
  };
26
27
  export type GlobalColorModeProps = {
27
- defaultMode?: ColorMode;
28
- scoped?: boolean;
28
+ defaultMode: ColorMode;
29
+ scopeRef?: React.RefObject<HTMLDivElement>;
29
30
  children?: React.ReactNode;
30
31
  };
@@ -1 +1 @@
1
- export declare const getRootThemeEl: () => Element;
1
+ export declare const getRootThemeEl: (scopeEl?: HTMLElement | null) => HTMLElement;
@@ -1 +1,10 @@
1
- export const getRootThemeEl = () => document.querySelector("[data-rs-root]") || document.documentElement;
1
+ export const getRootThemeEl = (scopeEl) => {
2
+ if (!scopeEl)
3
+ return document.documentElement;
4
+ if (scopeEl.hasAttribute("data-rs-root") ||
5
+ scopeEl === document.documentElement ||
6
+ !scopeEl.parentElement) {
7
+ return scopeEl;
8
+ }
9
+ return getRootThemeEl(scopeEl.parentElement);
10
+ };
@@ -9,4 +9,5 @@ declare const _default: {
9
9
  };
10
10
  export default _default;
11
11
  export declare const uncontrolled: () => import("react").JSX.Element;
12
+ export declare const nestedReshaped: () => import("react").JSX.Element;
12
13
  export declare const edgeCases: () => import("react").JSX.Element;
@@ -4,6 +4,7 @@ import View from "../../View/index.js";
4
4
  import MenuItem from "../../MenuItem/index.js";
5
5
  import Theme, { useTheme } from "../index.js";
6
6
  import { Example } from "../../../utilities/storybook/index.js";
7
+ import Reshaped from "../../Reshaped/index.js";
7
8
  export default {
8
9
  title: "Utilities/Theme",
9
10
  component: Theme,
@@ -15,7 +16,7 @@ export default {
15
16
  };
16
17
  const UncontrolledDemo = () => {
17
18
  const { setTheme, theme } = useTheme();
18
- return (<Button color="primary" onClick={() => setTheme(theme === "reshaped" ? "fake" : "reshaped")}>
19
+ return (<Button color="primary" onClick={() => setTheme(theme === "reshaped" ? "slate" : "reshaped")}>
19
20
  Toggle theme
20
21
  </Button>);
21
22
  };
@@ -26,6 +27,38 @@ export const uncontrolled = () => {
26
27
  </Example.Item>
27
28
  </Example>);
28
29
  };
30
+ const Nested = () => {
31
+ const { invertColorMode, colorMode } = useTheme();
32
+ return (<Button color="primary" variant="faded" onClick={invertColorMode}>
33
+ Slate: {colorMode}
34
+ </Button>);
35
+ };
36
+ export const nestedReshaped = () => {
37
+ const { invertColorMode, colorMode } = useTheme();
38
+ return (<Example>
39
+ <Example.Item title="reshaped + scoped slate">
40
+ <View gap={2} direction="row">
41
+ <Button color="primary" variant="faded" onClick={invertColorMode}>
42
+ Reshaped: {colorMode}
43
+ </Button>
44
+ <Reshaped theme="slate" scoped>
45
+ <Nested />
46
+ </Reshaped>
47
+ </View>
48
+ </Example.Item>
49
+
50
+ <Example.Item title="reshaped + not scoped slate">
51
+ <View gap={2} direction="row">
52
+ <Button color="primary" variant="faded" onClick={invertColorMode}>
53
+ Reshaped: {colorMode}
54
+ </Button>
55
+ <Reshaped theme="slate">
56
+ <Nested />
57
+ </Reshaped>
58
+ </View>
59
+ </Example.Item>
60
+ </Example>);
61
+ };
29
62
  const Demo = () => {
30
63
  const { invertColorMode } = useTheme();
31
64
  return (<View gap={3}>
@@ -1,4 +1,4 @@
1
- export declare const useGlobalColorMode: () => import("./Theme.types").ColorMode;
1
+ export declare const useGlobalColorMode: () => import("./Theme.types").GlobalColorModeContextData;
2
2
  export declare const useTheme: () => {
3
3
  theme: string;
4
4
  setTheme: (theme: string) => void;
@@ -2,8 +2,7 @@
2
2
  import React from "react";
3
3
  import { ThemeContext, GlobalColorModeContext } from "./Theme.context.js";
4
4
  export const useGlobalColorMode = () => {
5
- const { mode } = React.useContext(GlobalColorModeContext);
6
- return mode;
5
+ return React.useContext(GlobalColorModeContext);
7
6
  };
8
7
  export const useTheme = () => {
9
8
  const { colorMode, theme, setTheme, rootTheme, setRootTheme } = React.useContext(ThemeContext);
@@ -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", containerRef, active, disabled, disableContentHover, } = props;
8
+ const { id, text, children, onOpen, onClose, position = "bottom", containerRef, contentGap, contentShift, 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, containerRef: containerRef, triggerType: "hover", groupTimeouts: true, 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, contentGap: contentGap, contentShift: contentShift, onOpen: onOpen, onClose: onClose, disableContentHover: disableContentHover, containerRef: containerRef, triggerType: "hover", groupTimeouts: true, 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" | "containerRef"> & {
3
+ export type Props = Pick<FlyoutProps, "id" | "position" | "onOpen" | "onClose" | "active" | "disabled" | "disableContentHover" | "containerRef" | "contentGap" | "contentShift"> & {
4
4
  children: (attributes: Parameters<FlyoutTriggerProps["children"]>[0] | {}) => React.ReactNode;
5
5
  text?: React.ReactNode;
6
6
  };
@@ -18,6 +18,7 @@ export type Options = {
18
18
  lastUsedFallback: Position;
19
19
  onFallback: (position: Position) => void;
20
20
  contentGap?: number;
21
+ contentShift?: number;
21
22
  };
22
23
  export type Styles = React.CSSProperties;
23
24
  export type State = {
@@ -87,6 +88,7 @@ type BaseProps = {
87
88
  onClose?: () => void;
88
89
  width?: Width;
89
90
  contentGap?: number;
91
+ contentShift?: number;
90
92
  contentClassName?: string;
91
93
  contentAttributes?: G.Attributes<"div">;
92
94
  instanceRef?: React.Ref<Instance>;
@@ -130,6 +132,6 @@ export type ContextProps = {
130
132
  handleContentMouseDown: () => void;
131
133
  handleContentMouseUp: () => void;
132
134
  isSubmenu: boolean;
133
- } & Pick<Props, "triggerType" | "contentClassName" | "contentAttributes" | "trapFocusMode" | "contentGap" | "containerRef" | "disableContentHover">;
135
+ } & Pick<Props, "triggerType" | "contentClassName" | "contentAttributes" | "trapFocusMode" | "contentGap" | "contentShift" | "containerRef" | "disableContentHover">;
134
136
  export type TriggerContextProps = Pick<ContextProps, "triggerElRef">;
135
137
  export {};
@@ -15,7 +15,7 @@ import cooldown from "./utilities/cooldown.js";
15
15
  import { Provider, useFlyoutTriggerContext, useFlyoutContext, useFlyoutContentContext, } from "./Flyout.context.js";
16
16
  import useHandlerRef from "../../../hooks/useHandlerRef.js";
17
17
  const FlyoutRoot = (props) => {
18
- const { triggerType = "click", groupTimeouts, onOpen, onClose, children, disabled, forcePosition, trapFocusMode, width, disableHideAnimation, disableContentHover, disableCloseOnOutsideClick, contentGap = 2, contentClassName, contentAttributes, position: passedPosition, active: passedActive, id: passedId, instanceRef, containerRef, initialFocusRef, } = props;
18
+ const { triggerType = "click", groupTimeouts, onOpen, onClose, children, disabled, forcePosition, trapFocusMode, width, disableHideAnimation, disableContentHover, disableCloseOnOutsideClick, contentGap = 2, contentShift, contentClassName, contentAttributes, position: passedPosition, active: passedActive, id: passedId, instanceRef, containerRef, initialFocusRef, } = props;
19
19
  const fallbackPositions = props.fallbackPositions === false || forcePosition ? [] : props.fallbackPositions;
20
20
  const onOpenRef = useHandlerRef(onOpen);
21
21
  const onCloseRef = useHandlerRef(onClose);
@@ -59,6 +59,7 @@ const FlyoutRoot = (props) => {
59
59
  container: containerRef?.current,
60
60
  fallbackPositions,
61
61
  contentGap,
62
+ contentShift,
62
63
  });
63
64
  const { status, updatePosition, render, hide, remove, show } = flyout;
64
65
  const isRendered = status !== "idle";
@@ -3,15 +3,15 @@ declare const _default: {
3
3
  title: string;
4
4
  };
5
5
  export default _default;
6
- export declare const positions: () => React.JSX.Element;
6
+ export declare const position: () => React.JSX.Element;
7
7
  export declare const dynamicPosition: () => React.JSX.Element;
8
8
  export declare const modes: () => React.JSX.Element;
9
- export declare const widthTrigger: () => React.JSX.Element;
9
+ export declare const width: () => React.JSX.Element;
10
+ export declare const offset: () => React.JSX.Element;
10
11
  export declare const disableFlags: () => React.JSX.Element;
11
12
  export declare const initialFocus: () => React.JSX.Element;
12
13
  export declare const customPortalTarget: () => React.JSX.Element;
13
- export declare const testWidthOverflowOnMobile: () => React.JSX.Element;
14
14
  export declare const testInsideFixed: () => React.JSX.Element;
15
15
  export declare const testDynamicBounds: () => React.JSX.Element;
16
16
  export declare const testDisableOutsideClick: () => React.JSX.Element;
17
- export declare const scopedTheming: () => React.JSX.Element;
17
+ export declare const testScopedTheming: () => React.JSX.Element;