reshaped 3.2.7 → 3.3.1

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 (154) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/bundle.css +1 -1
  3. package/dist/bundle.d.ts +2 -0
  4. package/dist/bundle.js +11 -11
  5. package/dist/cjs/themes/_generator/definitions/figma.js +1 -0
  6. package/dist/cjs/themes/_generator/definitions/reshaped.js +5 -4
  7. package/dist/cjs/themes/_generator/tokens/duration/duration.types.d.ts +1 -1
  8. package/dist/cjs/themes/_generator/transform.js +17 -7
  9. package/dist/cjs/themes/_generator/utilities/generateColors.js +6 -6
  10. package/dist/cjs/themes/_generator/utilities/resolveTokenReference.js +1 -1
  11. package/dist/cjs/themes/figma/theme.css +1 -1
  12. package/dist/cjs/themes/reshaped/theme.css +1 -1
  13. package/dist/cjs/themes/slate/theme.css +1 -1
  14. package/dist/components/Alert/tests/Alert.stories.d.ts +5 -4
  15. package/dist/components/Alert/tests/Alert.stories.js +3 -2
  16. package/dist/components/Autocomplete/Autocomplete.js +3 -3
  17. package/dist/components/Autocomplete/Autocomplete.types.d.ts +8 -9
  18. package/dist/components/Badge/Badge.module.css +1 -1
  19. package/dist/components/Button/Button.module.css +1 -1
  20. package/dist/components/Card/Card.js +1 -1
  21. package/dist/components/ContextMenu/ContextMenu.d.ts +10 -0
  22. package/dist/components/ContextMenu/ContextMenu.js +37 -0
  23. package/dist/components/ContextMenu/ContextMenu.module.css +1 -0
  24. package/dist/components/ContextMenu/ContextMenu.types.d.ts +2 -0
  25. package/dist/components/ContextMenu/ContextMenu.types.js +1 -0
  26. package/dist/components/ContextMenu/index.d.ts +2 -0
  27. package/dist/components/ContextMenu/index.js +1 -0
  28. package/dist/components/ContextMenu/tests/ContextMenu.stories.d.ts +18 -0
  29. package/dist/components/ContextMenu/tests/ContextMenu.stories.js +27 -0
  30. package/dist/components/DropdownMenu/DropdownMenu.d.ts +1 -2
  31. package/dist/components/DropdownMenu/DropdownMenu.js +2 -2
  32. package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +4 -4
  33. package/dist/components/DropdownMenu/tests/DropdownMenu.stories.d.ts +1 -1
  34. package/dist/components/DropdownMenu/tests/DropdownMenu.stories.js +8 -0
  35. package/dist/components/FormControl/FormControl.context.d.ts +86 -86
  36. package/dist/components/Grid/Grid.js +5 -1
  37. package/dist/components/Hotkey/Hotkey.module.css +1 -1
  38. package/dist/components/Modal/Modal.js +1 -1
  39. package/dist/components/Modal/Modal.module.css +1 -1
  40. package/dist/components/Popover/Popover.js +1 -1
  41. package/dist/components/Popover/Popover.types.d.ts +1 -1
  42. package/dist/components/Resizable/Resizable.js +2 -2
  43. package/dist/components/Resizable/Resizable.module.css +1 -1
  44. package/dist/components/Resizable/Resizable.types.d.ts +3 -1
  45. package/dist/components/Resizable/tests/Resizable.stories.js +34 -1
  46. package/dist/components/ScrollArea/ScrollArea.js +9 -9
  47. package/dist/components/ScrollArea/ScrollArea.module.css +1 -1
  48. package/dist/components/ScrollArea/ScrollArea.types.d.ts +1 -4
  49. package/dist/components/ScrollArea/tests/ScrollArea.stories.d.ts +6 -4
  50. package/dist/components/ScrollArea/tests/ScrollArea.stories.js +28 -2
  51. package/dist/components/Table/Table.module.css +1 -1
  52. package/dist/components/Tabs/Tabs.module.css +1 -1
  53. package/dist/components/Tabs/Tabs.types.d.ts +2 -0
  54. package/dist/components/Tabs/TabsContext.d.ts +2 -2
  55. package/dist/components/Tabs/TabsPanel.js +3 -3
  56. package/dist/components/Text/Text.js +2 -1
  57. package/dist/components/TextField/TextField.js +4 -4
  58. package/dist/components/TextField/TextField.module.css +1 -1
  59. package/dist/components/TextField/TextField.types.d.ts +1 -0
  60. package/dist/components/Toast/Toast.js +3 -2
  61. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  62. package/dist/components/Tooltip/Tooltip.js +4 -4
  63. package/dist/components/Tooltip/Tooltip.types.d.ts +1 -1
  64. package/dist/components/Tooltip/tests/Tooltip.stories.d.ts +1 -1
  65. package/dist/components/View/View.js +8 -3
  66. package/dist/components/View/View.module.css +1 -1
  67. package/dist/components/View/View.types.d.ts +5 -5
  68. package/dist/components/View/tests/View.stories.js +6 -0
  69. package/dist/components/_private/Flyout/Flyout.context.d.ts +4 -4
  70. package/dist/components/_private/Flyout/Flyout.context.js +2 -2
  71. package/dist/components/_private/Flyout/Flyout.module.css +1 -1
  72. package/dist/components/_private/Flyout/Flyout.types.d.ts +8 -2
  73. package/dist/components/_private/Flyout/FlyoutContent.js +7 -5
  74. package/dist/components/_private/Flyout/FlyoutControlled.js +20 -13
  75. package/dist/components/_private/Flyout/FlyoutTrigger.js +1 -1
  76. package/dist/components/_private/Flyout/tests/Flyout.stories.d.ts +1 -0
  77. package/dist/components/_private/Flyout/tests/Flyout.stories.js +16 -1
  78. package/dist/components/_private/Flyout/useFlyout.d.ts +6 -11
  79. package/dist/components/_private/Flyout/useFlyout.js +19 -30
  80. package/dist/components/_private/Flyout/utilities/isFullyVisible.d.ts +6 -0
  81. package/dist/components/_private/Flyout/utilities/isFullyVisible.js +16 -0
  82. package/dist/components/_private/Portal/Portal.js +5 -2
  83. package/dist/hooks/_private/useOnClickOutside.d.ts +1 -1
  84. package/dist/hooks/_private/useOnClickOutside.js +8 -5
  85. package/dist/hooks/_private/useSingletonKeyboardMode.js +4 -0
  86. package/dist/index.d.ts +2 -0
  87. package/dist/index.js +1 -0
  88. package/dist/styles/align/align.css +1 -0
  89. package/dist/styles/align/index.d.ts +2 -1
  90. package/dist/styles/align/index.js +3 -3
  91. package/dist/styles/aspectRatio/aspectRatio.css +1 -0
  92. package/dist/styles/aspectRatio/index.d.ts +2 -1
  93. package/dist/styles/aspectRatio/index.js +2 -2
  94. package/dist/styles/bleed/bleed.module.css +1 -1
  95. package/dist/styles/bleed/index.js +2 -5
  96. package/dist/styles/height/height.module.css +1 -1
  97. package/dist/styles/height/index.js +2 -2
  98. package/dist/styles/inset/index.d.ts +2 -1
  99. package/dist/styles/inset/index.js +4 -7
  100. package/dist/styles/inset/inset.css +1 -0
  101. package/dist/styles/justify/index.d.ts +2 -1
  102. package/dist/styles/justify/index.js +3 -3
  103. package/dist/styles/justify/justify.css +1 -0
  104. package/dist/styles/maxHeight/index.js +2 -2
  105. package/dist/styles/maxHeight/maxHeight.module.css +1 -1
  106. package/dist/styles/maxWidth/index.js +2 -2
  107. package/dist/styles/maxWidth/maxWidth.module.css +1 -1
  108. package/dist/styles/minHeight/index.js +2 -2
  109. package/dist/styles/minHeight/minHeight.module.css +1 -1
  110. package/dist/styles/minWidth/index.js +2 -2
  111. package/dist/styles/minWidth/minWidth.module.css +1 -1
  112. package/dist/styles/padding/index.d.ts +2 -1
  113. package/dist/styles/padding/index.js +2 -2
  114. package/dist/styles/padding/padding.css +1 -0
  115. package/dist/styles/position/index.d.ts +2 -1
  116. package/dist/styles/position/index.js +4 -4
  117. package/dist/styles/position/position.css +1 -0
  118. package/dist/styles/textAlign/index.d.ts +2 -1
  119. package/dist/styles/textAlign/index.js +3 -3
  120. package/dist/styles/textAlign/textAlign.css +1 -0
  121. package/dist/styles/types.d.ts +5 -0
  122. package/dist/styles/width/index.js +2 -2
  123. package/dist/styles/width/width.module.css +1 -1
  124. package/dist/themes/_generator/definitions/figma.js +1 -0
  125. package/dist/themes/_generator/definitions/reshaped.js +5 -4
  126. package/dist/themes/_generator/tests/themes.stories.d.ts +4 -3
  127. package/dist/themes/_generator/tests/themes.stories.js +3 -2
  128. package/dist/themes/_generator/tokens/duration/duration.types.d.ts +1 -1
  129. package/dist/themes/_generator/utilities/generateColors.js +6 -6
  130. package/dist/themes/_generator/utilities/resolveTokenReference.js +1 -1
  131. package/dist/themes/figma/theme.css +1 -1
  132. package/dist/themes/reshaped/theme.css +1 -1
  133. package/dist/themes/slate/theme.css +1 -1
  134. package/dist/types/global.d.ts +4 -0
  135. package/dist/utilities/a11y/TrapFocus.js +2 -0
  136. package/dist/utilities/a11y/focus.d.ts +1 -1
  137. package/dist/utilities/a11y/focus.js +4 -1
  138. package/dist/utilities/a11y/tests/TrapFocus.stories.d.ts +6 -0
  139. package/dist/utilities/a11y/tests/TrapFocus.stories.js +59 -0
  140. package/dist/utilities/dom/find.d.ts +9 -0
  141. package/dist/utilities/dom/find.js +26 -0
  142. package/dist/utilities/dom/flyout.d.ts +2 -1
  143. package/dist/utilities/dom/flyout.js +13 -18
  144. package/dist/utilities/dom/index.d.ts +2 -2
  145. package/dist/utilities/dom/index.js +2 -2
  146. package/dist/utilities/scroll/lock.js +6 -2
  147. package/package.json +32 -32
  148. package/dist/styles/align/align.module.css +0 -1
  149. package/dist/styles/aspectRatio/aspectRatio.module.css +0 -1
  150. package/dist/styles/inset/inset.module.css +0 -1
  151. package/dist/styles/justify/justify.module.css +0 -1
  152. package/dist/styles/padding/padding.module.css +0 -1
  153. package/dist/styles/position/position.module.css +0 -1
  154. package/dist/styles/textAlign/textAlign.module.css +0 -1
@@ -15,14 +15,14 @@ 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, contentShift, 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, originCoordinates, 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);
22
22
  const resolvedActive = disabled === true ? false : passedActive;
23
23
  const parentFlyoutContext = useFlyoutContext();
24
- const parentFlyoutTriggerContext = useFlyoutTriggerContext();
25
- const parentFlyoutContentContext = useFlyoutContentContext();
24
+ const { elRef: parentTriggerRef } = useFlyoutTriggerContext() || {};
25
+ const { elRef: parentContentRef } = useFlyoutContentContext() || {};
26
26
  const isSubmenu = parentFlyoutContext.trapFocusMode === "action-menu" ||
27
27
  parentFlyoutContext.trapFocusMode === "content-menu";
28
28
  const [isRTL] = useRTL();
@@ -30,10 +30,14 @@ const FlyoutRoot = (props) => {
30
30
  /**
31
31
  * Reuse the parent trigger ref in case we render nested triggers
32
32
  * For example, when we apply tooltip and popover to the same button
33
+ *
34
+ * Resolving the same inside another Flyout.Content should reset the inheritance
35
+ * For example, if you have a tooltip -> popover inside another popover.content, tooltip shouldn't use its parent context anymore
33
36
  */
34
- const triggerElRef = (!parentFlyoutContentContext && parentFlyoutTriggerContext?.triggerElRef) ||
35
- internalTriggerElRef;
36
- const triggerBoundsRef = React.useRef(null);
37
+ const isParentTriggerInsideFlyout = !!parentTriggerRef?.current && parentContentRef?.current?.contains(parentTriggerRef.current);
38
+ const tryParentTrigger = !parentContentRef || isParentTriggerInsideFlyout;
39
+ const triggerElRef = (tryParentTrigger && parentTriggerRef) || internalTriggerElRef;
40
+ const triggerBoundsRef = React.useRef();
37
41
  const flyoutElRef = React.useRef(null);
38
42
  const id = useElementId(passedId);
39
43
  const timerRef = React.useRef();
@@ -44,7 +48,7 @@ const FlyoutRoot = (props) => {
44
48
  const transitionStartedRef = React.useRef(false);
45
49
  // Lock blur event while pressing anywhere inside the flyout content
46
50
  const lockedBlurEffects = React.useRef(false);
47
- // Focus shouldn't retrun back to the trigger when user intentionally clicks outside the flyout
51
+ // Focus shouldn't return back to the trigger when user intentionally clicks outside the flyout
48
52
  const shouldReturnFocusRef = React.useRef(true);
49
53
  // Touch devices trigger onMouseEnter but we don't need to apply regular hover timeouts
50
54
  // So we're saving a flag on touch start and then change the mouse enter behavior
@@ -52,7 +56,7 @@ const FlyoutRoot = (props) => {
52
56
  const flyout = useFlyout({
53
57
  triggerElRef,
54
58
  flyoutElRef,
55
- triggerBoundsRef,
59
+ triggerBounds: originCoordinates ?? triggerBoundsRef.current,
56
60
  width,
57
61
  position: passedPosition,
58
62
  defaultActive: resolvedActive,
@@ -74,11 +78,12 @@ const FlyoutRoot = (props) => {
74
78
  * Called from the internal actions
75
79
  */
76
80
  const handleOpen = React.useCallback(() => {
77
- const canOpen = !lockedRef.current && !isRendered;
78
- if (!canOpen)
81
+ if (lockedRef.current)
82
+ return;
83
+ if (isRendered && triggerType !== "hover")
79
84
  return;
80
85
  onOpenRef.current?.();
81
- }, [isRendered, onOpenRef]);
86
+ }, [onOpenRef, isRendered, triggerType]);
82
87
  const handleClose = React.useCallback((options) => {
83
88
  const isLocked = triggerType === "click" && !isDismissible();
84
89
  const canClose = !isLocked && (isRendered || disabled);
@@ -164,7 +169,7 @@ const FlyoutRoot = (props) => {
164
169
  * After animation has started, we're sure about the correct bounds
165
170
  * so drop the cache to make flyout work when trigger moves around
166
171
  */
167
- triggerBoundsRef.current = null;
172
+ triggerBoundsRef.current = undefined;
168
173
  }, [resolvedActive]);
169
174
  const handleTransitionEnd = React.useCallback((e) => {
170
175
  if (flyoutElRef.current !== e.currentTarget || e.propertyName !== "transform")
@@ -277,12 +282,14 @@ const FlyoutRoot = (props) => {
277
282
  }), [handleOpen, handleClose, updatePosition]);
278
283
  useHotkeys({ Escape: () => handleClose() }, [handleClose]);
279
284
  useOnClickOutside([flyoutElRef, triggerElRef], () => {
285
+ if (!isRendered)
286
+ return;
280
287
  if (disableCloseOnOutsideClick)
281
288
  return;
282
289
  // Clicking outside changes focused element so we don't need to set it back ourselves
283
290
  shouldReturnFocusRef.current = false;
284
291
  handleClose();
285
- });
292
+ }, [isRendered]);
286
293
  return (_jsx(Provider, { value: {
287
294
  id,
288
295
  flyout,
@@ -36,6 +36,6 @@ const FlyoutTrigger = (props) => {
36
36
  childrenAttributes["aria-expanded"] = flyout.status !== "idle";
37
37
  childrenAttributes["aria-controls"] = flyout.status !== "idle" ? id : undefined;
38
38
  }
39
- return (_jsx(TriggerProvider, { value: { triggerElRef }, children: children(childrenAttributes) }));
39
+ return (_jsx(TriggerProvider, { value: { elRef: triggerElRef }, children: children(childrenAttributes) }));
40
40
  };
41
41
  export default FlyoutTrigger;
@@ -5,6 +5,7 @@ declare const _default: {
5
5
  export default _default;
6
6
  export declare const position: () => React.JSX.Element;
7
7
  export declare const dynamicPosition: () => React.JSX.Element;
8
+ export declare const originCoordinates: () => React.JSX.Element;
8
9
  export declare const modes: () => React.JSX.Element;
9
10
  export declare const width: () => React.JSX.Element;
10
11
  export declare const offset: () => React.JSX.Element;
@@ -51,6 +51,21 @@ export const position = () => (<div style={{ paddingTop: 200 }}>
51
51
  export const dynamicPosition = () => (<div style={{ position: "absolute", top: 0, left: "50%" }}>
52
52
  <Demo position="top"/>
53
53
  </div>);
54
+ export const originCoordinates = () => {
55
+ const [coordinates, setCoordinates] = React.useState(null);
56
+ return (<Example>
57
+ <Example.Item>
58
+ <View height={25} width={25} attributes={{
59
+ onContextMenu: (e) => {
60
+ e.preventDefault();
61
+ setCoordinates({ x: e.clientX, y: e.clientY });
62
+ },
63
+ }} backgroundColor="neutral-faded" borderRadius="medium"/>
64
+ <br /> <br />
65
+ <Demo position="top" originCoordinates={coordinates} active={!!coordinates} onClose={() => setCoordinates(null)}/>
66
+ </Example.Item>
67
+ </Example>);
68
+ };
54
69
  export const modes = () => (<Example>
55
70
  <Example.Item title="dialog click">
56
71
  <Demo position="bottom-start" trapFocusMode="dialog">
@@ -187,7 +202,7 @@ export const customPortalTarget = () => {
187
202
  return (<Example>
188
203
  <Example.Item title="Custom containerRef">
189
204
  <View padding={4} paddingInline={40} height={50} overflow="auto" backgroundColor="neutral-faded" borderRadius="small" attributes={{ ref: portalRef }}>
190
- <Flyout position="bottom-end" containerRef={portalRef} active>
205
+ <Flyout position="bottom-end" active>
191
206
  <Flyout.Trigger>{(attributes) => <button {...attributes}>Open</button>}</Flyout.Trigger>
192
207
  <Flyout.Content>
193
208
  <div style={{
@@ -1,22 +1,17 @@
1
1
  import React from "react";
2
+ import type * as G from "../../../types/global";
2
3
  import type * as T from "./Flyout.types";
3
- /**
4
- * Typings
5
- */
6
- type ElementRef = React.RefObject<HTMLElement>;
7
- type PassedFlyoutOptions = {
4
+ type UseFlyout = (args: {
8
5
  width?: T.Width;
9
6
  position?: T.Position;
10
7
  defaultActive?: boolean;
11
8
  fallbackPositions?: T.Position[];
12
- container?: HTMLElement | null;
13
- };
14
- type UseFlyout = (args: PassedFlyoutOptions & {
15
- triggerElRef: ElementRef;
16
- flyoutElRef: ElementRef;
17
- triggerBoundsRef: React.RefObject<DOMRect | undefined>;
18
9
  contentGap?: number;
19
10
  contentShift?: number;
11
+ container?: HTMLElement | null;
12
+ triggerElRef: React.RefObject<HTMLElement>;
13
+ flyoutElRef: React.RefObject<HTMLElement>;
14
+ triggerBounds?: DOMRect | G.Coordinates;
20
15
  }) => Pick<T.State, "styles" | "position" | "status"> & {
21
16
  updatePosition: (options?: {
22
17
  sync?: boolean;
@@ -1,23 +1,9 @@
1
1
  import React from "react";
2
2
  import useRTL from "../../../hooks/useRTL.js";
3
- import { getClosestFlyoutTarget, getShadowRoot } from "../../../utilities/dom/index.js";
3
+ import { findClosestRenderContainer, getShadowRoot, getRectFromCoordinates } from "../../../utilities/dom/index.js";
4
4
  import calculatePosition from "./utilities/calculatePosition.js";
5
5
  import getPositionFallbacks from "./utilities/getPositionFallbacks.js";
6
- /**
7
- * Check if element visually fits on the screen
8
- */
9
- const fullyVisible = (args) => {
10
- const { styles, scopeOffset } = args;
11
- const htmlEl = document.documentElement;
12
- const pageLeft = htmlEl.scrollLeft;
13
- const pageRight = pageLeft + htmlEl.clientWidth;
14
- const pageTop = htmlEl.scrollTop;
15
- const pageBottom = pageTop + htmlEl.clientHeight;
16
- return (styles.left + scopeOffset.left >= pageLeft &&
17
- styles.left + styles.width + scopeOffset.left <= pageRight &&
18
- styles.top + scopeOffset.top >= pageTop &&
19
- styles.top + styles.height + scopeOffset.top <= pageBottom);
20
- };
6
+ import isFullyVisible from "./utilities/isFullyVisible.js";
21
7
  /**
22
8
  * Order of keys here is responsible for the order of styles applied
23
9
  */
@@ -33,7 +19,6 @@ const resetStyles = {
33
19
  left: 0,
34
20
  top: 0,
35
21
  position: "fixed",
36
- // opacity: 0,
37
22
  visibility: "hidden",
38
23
  animation: "none",
39
24
  transition: "none",
@@ -46,9 +31,12 @@ const flyout = (args) => {
46
31
  const { triggerEl, flyoutEl, triggerBounds: passedTriggerBounds, contentShift = 0, contentGap = 0, ...options } = args;
47
32
  const { position, fallbackPositions, width, container, lastUsedFallback, onFallback } = options;
48
33
  const targetClone = flyoutEl.cloneNode(true);
49
- const triggerBounds = passedTriggerBounds || triggerEl.getBoundingClientRect();
50
34
  const baseUnit = getComputedStyle(flyoutEl).getPropertyValue("--rs-unit-x1");
51
35
  const unitModifier = baseUnit ? parseInt(baseUnit) : 0;
36
+ const triggerBounds = passedTriggerBounds || triggerEl?.getBoundingClientRect();
37
+ if (!triggerBounds)
38
+ return;
39
+ const resolvedTriggerBounds = getRectFromCoordinates(triggerBounds);
52
40
  // Reset all styles applied on the previous hook execution
53
41
  targetClone.style.cssText = "";
54
42
  Object.keys(resetStyles).forEach((key) => {
@@ -58,17 +46,17 @@ const flyout = (args) => {
58
46
  });
59
47
  if (width) {
60
48
  if (width === "trigger") {
61
- targetClone.style.width = `${triggerBounds.width}px`;
49
+ targetClone.style.width = `${resolvedTriggerBounds.width}px`;
62
50
  }
63
51
  else if (width !== "full") {
64
52
  targetClone.style.width = width;
65
53
  }
66
54
  }
67
- const shadowRoot = getShadowRoot(triggerEl);
55
+ const shadowRoot = triggerEl && getShadowRoot(triggerEl);
68
56
  // Insert inside shadow root if possible to make sure styles are applied correctly
69
57
  (shadowRoot || document.body).appendChild(targetClone);
70
58
  const flyoutBounds = targetClone.getBoundingClientRect();
71
- const containerParent = container || getClosestFlyoutTarget(triggerEl);
59
+ const containerParent = container || (triggerEl ? findClosestRenderContainer({ el: triggerEl }) : document.body);
72
60
  const containerBounds = containerParent.getBoundingClientRect();
73
61
  const scopeOffset = {
74
62
  top: containerBounds.top + document.documentElement.scrollTop - containerParent.scrollTop,
@@ -79,14 +67,14 @@ const flyout = (args) => {
79
67
  testOrder.some((currentPosition) => {
80
68
  const tested = calculatePosition({
81
69
  ...options,
82
- triggerBounds,
70
+ triggerBounds: resolvedTriggerBounds,
83
71
  flyoutBounds,
84
72
  scopeOffset,
85
73
  position: currentPosition,
86
74
  contentGap: contentGap * unitModifier,
87
75
  contentShift: contentShift * unitModifier,
88
76
  });
89
- const visible = fullyVisible(tested);
77
+ const visible = isFullyVisible(tested);
90
78
  const validPosition = visible || fallbackPositions?.length === 0;
91
79
  // Saving first try in case non of the options work
92
80
  if (validPosition || lastUsedFallback === currentPosition) {
@@ -96,7 +84,7 @@ const flyout = (args) => {
96
84
  return validPosition;
97
85
  });
98
86
  if (!calculated) {
99
- throw new Error(`Reshaped: Can't calculate styles for the ${position} position`);
87
+ throw new Error(`[Reshaped] Can't calculate styles for the ${position} position`);
100
88
  }
101
89
  targetClone.parentNode?.removeChild(targetClone);
102
90
  return calculated;
@@ -132,11 +120,11 @@ const flyoutReducer = (state, action) => {
132
120
  return state;
133
121
  return { ...state, status: "idle", styles: resetStyles };
134
122
  default:
135
- throw new Error("Invalid reducer type");
123
+ throw new Error("[Reshaped] Invalid flyout reducer type");
136
124
  }
137
125
  };
138
126
  const useFlyout = (args) => {
139
- const { triggerElRef, flyoutElRef, triggerBoundsRef, contentGap, contentShift, ...options } = args;
127
+ const { triggerElRef, flyoutElRef, triggerBounds, contentGap, contentShift, ...options } = args;
140
128
  const { position: defaultPosition = "bottom", fallbackPositions, width, container } = options;
141
129
  const lastUsedFallbackRef = React.useRef(defaultPosition);
142
130
  // Memo the array internally to avoid new arrays triggering useCallback
@@ -165,12 +153,12 @@ const useFlyout = (args) => {
165
153
  lastUsedFallbackRef.current = position;
166
154
  }, []);
167
155
  const updatePosition = React.useCallback((options) => {
168
- if (!triggerElRef.current || !flyoutElRef.current)
156
+ if (!flyoutElRef.current)
169
157
  return;
170
158
  const nextFlyoutData = flyout({
171
159
  triggerEl: triggerElRef.current,
172
160
  flyoutEl: flyoutElRef.current,
173
- triggerBounds: triggerBoundsRef.current,
161
+ triggerBounds,
174
162
  width,
175
163
  position: defaultPosition,
176
164
  fallbackPositions: cachedFallbackPositions,
@@ -181,8 +169,9 @@ const useFlyout = (args) => {
181
169
  contentGap,
182
170
  contentShift,
183
171
  });
184
- if (nextFlyoutData)
172
+ if (nextFlyoutData) {
185
173
  dispatch({ type: "position", payload: { ...nextFlyoutData, sync: options?.sync } });
174
+ }
186
175
  }, [
187
176
  container,
188
177
  defaultPosition,
@@ -190,7 +179,7 @@ const useFlyout = (args) => {
190
179
  isRTL,
191
180
  flyoutElRef,
192
181
  triggerElRef,
193
- triggerBoundsRef,
182
+ triggerBounds,
194
183
  width,
195
184
  contentGap,
196
185
  contentShift,
@@ -0,0 +1,6 @@
1
+ import calculatePosition from "./calculatePosition";
2
+ /**
3
+ * Check if element visually fits on the screen
4
+ */
5
+ declare const isFullyVisible: (args: ReturnType<typeof calculatePosition>) => boolean;
6
+ export default isFullyVisible;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Check if element visually fits on the screen
3
+ */
4
+ const isFullyVisible = (args) => {
5
+ const { styles, scopeOffset } = args;
6
+ const htmlEl = document.documentElement;
7
+ const pageLeft = htmlEl.scrollLeft;
8
+ const pageRight = pageLeft + htmlEl.clientWidth;
9
+ const pageTop = htmlEl.scrollTop;
10
+ const pageBottom = pageTop + htmlEl.clientHeight;
11
+ return (styles.left + scopeOffset.left >= pageLeft &&
12
+ styles.left + styles.width + scopeOffset.left <= pageRight &&
13
+ styles.top + scopeOffset.top >= pageTop &&
14
+ styles.top + styles.height + scopeOffset.top <= pageBottom);
15
+ };
16
+ export default isFullyVisible;
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import React from "react";
4
4
  import ReactDOM from "react-dom";
5
5
  import Theme from "../../Theme/index.js";
@@ -29,7 +29,10 @@ const Portal = (props) => {
29
29
  const nextScopeRef = targetRef || portal.scopeRef;
30
30
  const targetEl = nextScopeRef?.current || defaultTargetEl;
31
31
  /* Preserve the current theme when rendered in body */
32
- return (_jsxs(_Fragment, { children: [ReactDOM.createPortal(_jsx(Theme, { children: children }), targetEl), _jsx("div", { ref: rootRef, className: s.root })] }));
32
+ return [
33
+ ReactDOM.createPortal(_jsx(Theme, { children: children }), targetEl),
34
+ _jsx("div", { ref: rootRef, className: s.root }, "root"),
35
+ ];
33
36
  };
34
37
  function PortalScope(props) {
35
38
  const { children } = props;
@@ -1,3 +1,3 @@
1
1
  import React from "react";
2
- declare const useOnClickOutside: (refs: React.RefObject<HTMLElement>[], handler: (event: Event) => void) => void;
2
+ declare const useOnClickOutside: (refs: React.RefObject<HTMLElement>[], handler: (event: Event) => void, deps: any[]) => void;
3
3
  export default useOnClickOutside;
@@ -1,17 +1,20 @@
1
1
  import useHandlerRef from "../useHandlerRef.js";
2
2
  import React from "react";
3
- const useOnClickOutside = (refs, handler) => {
3
+ const useOnClickOutside = (refs, handler, deps) => {
4
4
  const handlerRef = useHandlerRef(handler);
5
5
  React.useEffect(() => {
6
6
  if (!handlerRef.current)
7
7
  return;
8
8
  const handleClick = (event) => {
9
+ if (event instanceof MouseEvent && event.button === 2) {
10
+ return;
11
+ }
9
12
  let isInside = false;
10
13
  const clickedEl = event.composedPath()[0];
11
14
  refs.forEach((elRef) => {
12
- if (!elRef.current ||
13
- elRef.current === clickedEl ||
14
- elRef.current.contains(clickedEl)) {
15
+ if (!elRef.current)
16
+ return;
17
+ if (elRef.current === clickedEl || elRef.current.contains(clickedEl)) {
15
18
  isInside = true;
16
19
  }
17
20
  });
@@ -27,6 +30,6 @@ const useOnClickOutside = (refs, handler) => {
27
30
  document.removeEventListener("touchstart", handleClick);
28
31
  };
29
32
  // eslint-disable-next-line react-hooks/exhaustive-deps
30
- }, [handlerRef, ...refs]);
33
+ }, [handlerRef, ...refs, ...deps]);
31
34
  };
32
35
  export default useOnClickOutside;
@@ -1,10 +1,14 @@
1
1
  import React from "react";
2
+ import * as keys from "../../constants/keys.js";
2
3
  import { enableKeyboardMode, disableKeyboardMode } from "../../utilities/a11y/index.js";
3
4
  const useSingletonKeyboardMode = () => {
4
5
  React.useEffect(() => {
5
6
  const handleKeyDown = (e) => {
6
7
  if (e.metaKey || e.altKey || e.ctrlKey)
7
8
  return;
9
+ // Prevent focus ring from appearing when using mouse but closing with esc
10
+ if (e.key === keys.ESC)
11
+ return;
8
12
  enableKeyboardMode();
9
13
  };
10
14
  const handleClick = () => {
package/dist/index.d.ts CHANGED
@@ -31,6 +31,8 @@ export { default as CheckboxGroup } from "./components/CheckboxGroup";
31
31
  export type { CheckboxGroupProps } from "./components/CheckboxGroup";
32
32
  export { default as Container } from "./components/Container";
33
33
  export type { ContainerProps } from "./components/Container";
34
+ export { default as ContextMenu } from "./components/ContextMenu";
35
+ export type { ContextMenuProps } from "./components/ContextMenu";
34
36
  export { default as Dismissible } from "./components/Dismissible";
35
37
  export type { DismissibleProps } from "./components/Dismissible";
36
38
  export { default as Divider } from "./components/Divider";
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ export { default as Carousel } from "./components/Carousel/index.js";
16
16
  export { default as Checkbox } from "./components/Checkbox/index.js";
17
17
  export { default as CheckboxGroup } from "./components/CheckboxGroup/index.js";
18
18
  export { default as Container } from "./components/Container/index.js";
19
+ export { default as ContextMenu } from "./components/ContextMenu/index.js";
19
20
  export { default as Dismissible } from "./components/Dismissible/index.js";
20
21
  export { default as Divider } from "./components/Divider/index.js";
21
22
  export { default as DropdownMenu } from "./components/DropdownMenu/index.js";
@@ -0,0 +1 @@
1
+ [style*="--rs-align-"]{align-items:var(--rs-align)!important;--rs-align-s: ;--rs-align-m:var(--rs-align-s);--rs-align-l:var(--rs-align-m);--rs-align-xl:var(--rs-align-l);--rs-align:var(--rs-align-s)}@media (--rs-viewport-m ){[style*="--rs-align-"]{--rs-align:var(--rs-align-m)}}@media (--rs-viewport-l ){[style*="--rs-align-"]{--rs-align:var(--rs-align-l)}}@media (--rs-viewport-xl ){[style*="--rs-align-"]{--rs-align:var(--rs-align-xl)}}
@@ -1,3 +1,4 @@
1
1
  import * as T from "../types";
2
- declare const getAlignStyles: T.StaticStyleUtility<T.Align>;
2
+ import "./align.css";
3
+ declare const getAlignStyles: T.VariableStyleUtility<T.Align>;
3
4
  export default getAlignStyles;
@@ -1,10 +1,10 @@
1
- import { responsiveClassNames } from "../../utilities/helpers.js";
2
- import s from "./align.module.css";
1
+ import { responsiveVariables } from "../../utilities/helpers.js";
2
+ import "./align.css";
3
3
  const getAlignStyles = (value) => {
4
4
  if (!value)
5
5
  return null;
6
6
  return {
7
- classNames: responsiveClassNames(s, "--align", value),
7
+ variables: responsiveVariables("--rs-align", value),
8
8
  };
9
9
  };
10
10
  export default getAlignStyles;
@@ -0,0 +1 @@
1
+ [style*="--rs-ratio-"]{--rs-ratio-s:0;--rs-ratio-m:var(--rs-ratio-s);--rs-ratio-l:var(--rs-ratio-m);--rs-ratio-xl:var(--rs-ratio-l);--rs-ratio:var(--rs-ratio-s)}[style*="--rs-ratio-"]:empty,[style*="--rs-ratio-"]:not(:empty)>*{aspect-ratio:var(--rs-ratio)}[style*="--rs-ratio-"]>img{object-fit:cover}@media (--rs-viewport-m ){[style*="--rs-ratio-"]{--rs-ratio:var(--rs-ratio-m)}}@media (--rs-viewport-l ){[style*="--rs-ratio-"]{--rs-ratio:var(--rs-ratio-l)}}@media (--rs-viewport-xl ){[style*="--rs-ratio-"]{--rs-ratio:var(--rs-ratio-xl)}}
@@ -1,3 +1,4 @@
1
1
  import * as T from "../types";
2
- declare const getAspectRatioStyles: T.DynamicStyleUtility<number>;
2
+ import "./aspectRatio.css";
3
+ declare const getAspectRatioStyles: T.VariableStyleUtility<number>;
3
4
  export default getAspectRatioStyles;
@@ -1,9 +1,9 @@
1
1
  import { responsiveVariables } from "../../utilities/helpers.js";
2
- import s from "./aspectRatio.module.css";
2
+ import "./aspectRatio.css";
3
3
  const getAspectRatioStyles = (value) => {
4
4
  if (!value)
5
5
  return null;
6
6
  const variables = responsiveVariables("--rs-ratio", value);
7
- return { classNames: s.root, variables };
7
+ return { variables };
8
8
  };
9
9
  export default getAspectRatioStyles;
@@ -1 +1 @@
1
- .root{margin-left:calc(var(--rs-unit-x1) * var(--rs-bleed) * -1);margin-right:calc(var(--rs-unit-x1) * var(--rs-bleed) * -1);--rs-bleed-s:0;--rs-bleed-m:var(--rs-bleed-s);--rs-bleed-l:var(--rs-bleed-m);--rs-bleed-xl:var(--rs-bleed-l);--rs-bleed:var(--rs-bleed-s)}.--bleed{border-left-style:none!important;border-radius:0;border-right-style:none!important}@media (--rs-viewport-m ){.root{--rs-bleed:var(--rs-bleed-m)}.--bleed-true--m{border-left-style:none!important;border-radius:0;border-right-style:none!important}.--bleed-false--m{border-left-style:solid!important;border-radius:var(--rs-radius);border-right-style:solid!important}}@media (--rs-viewport-l ){.root{--rs-bleed:var(--rs-bleed-l)}.--bleed-true--l{border-left-style:none!important;border-radius:0;border-right-style:none!important}.--bleed-false--l{border-left-style:solid!important;border-radius:var(--rs-radius);border-right-style:solid!important}}@media (--rs-viewport-xl ){.root{--rs-bleed:var(--rs-bleed-xl)}.--bleed-true--xl{border-left-style:none!important;border-radius:0;border-right-style:none!important}.--bleed-false--xl{border-left-style:solid!important;border-radius:var(--rs-radius);border-right-style:solid!important}}
1
+ .root[style*="--rs-bleed-"]{margin-left:calc(var(--rs-unit-x1) * var(--rs-bleed) * -1);margin-right:calc(var(--rs-unit-x1) * var(--rs-bleed) * -1);--rs-bleed-s:0;--rs-bleed-m:var(--rs-bleed-s);--rs-bleed-l:var(--rs-bleed-m);--rs-bleed-xl:var(--rs-bleed-l);--rs-bleed:var(--rs-bleed-s)}.--bleed{border-left-style:none!important;border-radius:0;border-right-style:none!important}@media (--rs-viewport-m ){.root[style*="--rs-bleed-"]{--rs-bleed:var(--rs-bleed-m)}.--bleed-true--m{border-left-style:none!important;border-radius:0;border-right-style:none!important}.--bleed-false--m{border-left-style:solid!important;border-radius:var(--rs-radius);border-right-style:solid!important}}@media (--rs-viewport-l ){.root[style*="--rs-bleed-"]{--rs-bleed:var(--rs-bleed-l)}.--bleed-true--l{border-left-style:none!important;border-radius:0;border-right-style:none!important}.--bleed-false--l{border-left-style:solid!important;border-radius:var(--rs-radius);border-right-style:solid!important}}@media (--rs-viewport-xl ){.root[style*="--rs-bleed-"]{--rs-bleed:var(--rs-bleed-xl)}.--bleed-true--xl{border-left-style:none!important;border-radius:0;border-right-style:none!important}.--bleed-false--xl{border-left-style:solid!important;border-radius:var(--rs-radius);border-right-style:solid!important}}
@@ -3,11 +3,8 @@ import s from "./bleed.module.css";
3
3
  const getBleedStyles = (value) => {
4
4
  if (value === undefined)
5
5
  return null;
6
- const classNames = [
7
- s.root,
8
- ...responsiveClassNames(s, "--bleed", responsivePropDependency(value, (value) => typeof value === "number" && value > 0)),
9
- ];
6
+ const classNames = responsiveClassNames(s, "--bleed", responsivePropDependency(value, (value) => typeof value === "number" && value > 0));
10
7
  const variables = responsiveVariables("--rs-bleed", value);
11
- return { classNames, variables };
8
+ return { classNames: [s.root, classNames], variables };
12
9
  };
13
10
  export default getBleedStyles;
@@ -1 +1 @@
1
- .literal,.unit{--rs-h-s:auto;--rs-h-m:var(--rs-h-s);--rs-h-l:var(--rs-h-m);--rs-h-xl:var(--rs-h-l);height:var(--rs-h)!important}.literal{--rs-h:var(--rs-h-s)}.unit{--rs-h:calc(var(--rs-h-s) * var(--rs-unit-x1))}@media (--rs-viewport-m ){.literal--m{--rs-h:var(--rs-h-m)}.unit--m{--rs-h:calc(var(--rs-h-m) * var(--rs-unit-x1))}}@media (--rs-viewport-l ){.literal--l{--rs-h:var(--rs-h-l)}.unit--l{--rs-h:calc(var(--rs-h-l) * var(--rs-unit-x1))}}@media (--rs-viewport-xl ){.literal--xl{--rs-h:var(--rs-h-xl)}.unit--xl{--rs-h:calc(var(--rs-h-xl) * var(--rs-unit-x1))}}
1
+ .root{--rs-h-s:auto;--rs-h-m:var(--rs-h-s);--rs-h-l:var(--rs-h-m);--rs-h-xl:var(--rs-h-l);height:var(--rs-h)!important}.--type-literal{--rs-h:var(--rs-h-s)}.--type-unit{--rs-h:calc(var(--rs-h-s) * var(--rs-unit-x1))}@media (--rs-viewport-m ){.--type-literal--m{--rs-h:var(--rs-h-m)}.--type-unit--m{--rs-h:calc(var(--rs-h-m) * var(--rs-unit-x1))}}@media (--rs-viewport-l ){.--type-literal--l{--rs-h:var(--rs-h-l)}.--type-unit--l{--rs-h:calc(var(--rs-h-l) * var(--rs-unit-x1))}}@media (--rs-viewport-xl ){.--type-literal--xl{--rs-h:var(--rs-h-xl)}.--type-unit--xl{--rs-h:calc(var(--rs-h-xl) * var(--rs-unit-x1))}}
@@ -4,7 +4,7 @@ const getHeightStyles = (value) => {
4
4
  if (!value)
5
5
  return null;
6
6
  const variables = responsiveVariables("--rs-h", value);
7
- const classNames = responsiveClassNames(s, (value) => (typeof value === "number" ? "unit" : "literal"), value, { excludeValueFromClassName: true });
8
- return { classNames, variables };
7
+ const classNames = responsiveClassNames(s, (value) => (typeof value === "number" ? "--type-unit" : "--type-literal"), value, { excludeValueFromClassName: true });
8
+ return { classNames: [s.root, classNames], variables };
9
9
  };
10
10
  export default getHeightStyles;
@@ -1,4 +1,5 @@
1
1
  import * as T from "../types";
2
2
  import * as G from "../../types/global";
3
- declare const getInsetStyles: (value?: G.Responsive<number>, side?: "top" | "bottom" | "start" | "end") => T.DynamicStyleUtilityResult;
3
+ import "./inset.css";
4
+ declare const getInsetStyles: (value?: G.Responsive<number | "auto">, side?: "top" | "bottom" | "start" | "end") => T.VariableStyleUtilityResult;
4
5
  export default getInsetStyles;
@@ -1,14 +1,11 @@
1
- import { responsiveVariables, responsiveClassNames } from "../../utilities/helpers.js";
2
- import s from "./inset.module.css";
1
+ import { responsiveVariables } from "../../utilities/helpers.js";
2
+ import "./inset.css";
3
3
  const getInsetStyles = (value, side) => {
4
4
  if (value === undefined)
5
5
  return null;
6
- const suffix = side ? `-${side}` : "";
6
+ const suffix = side ? `-${side}` : "-all";
7
7
  const variableName = `--rs-inset${suffix}`;
8
8
  const variables = responsiveVariables(variableName, value);
9
- const classNames = responsiveClassNames(s, `--inset${suffix}`, value, {
10
- excludeValueFromClassName: true,
11
- });
12
- return { classNames, variables };
9
+ return { variables };
13
10
  };
14
11
  export default getInsetStyles;
@@ -0,0 +1 @@
1
+ [style*="--rs-inset-all-"]{inset:calc(var(--rs-inset-all) * var(--rs-unit-x1));--rs-inset-all-s:0;--rs-inset-all-m:var(--rs-inset-all-s);--rs-inset-all-l:var(--rs-inset-all-m);--rs-inset-all-xl:var(--rs-inset-all-l);--rs-inset-all:var(--rs-inset-all-s)}[style*="--rs-inset-end-"]{inset-inline-end:calc(var(--rs-inset-end) * var(--rs-unit-x1));--rs-inset-end-s:0;--rs-inset-end-m:var(--rs-inset-end-s);--rs-inset-end-l:var(--rs-inset-end-m);--rs-inset-end-xl:var(--rs-inset-end-l);--rs-inset-end:var(--rs-inset-end-s)}[style*="--rs-inset-start-"]{inset-inline-start:calc(var(--rs-inset-start) * var(--rs-unit-x1));--rs-inset-start-s:0;--rs-inset-start-m:var(--rs-inset-start-s);--rs-inset-start-l:var(--rs-inset-start-m);--rs-inset-start-xl:var(--rs-inset-start-l);--rs-inset-start:var(--rs-inset-start-s)}[style*="--rs-inset-top-"]{inset-block-start:calc(var(--rs-inset-top) * var(--rs-unit-x1));--rs-inset-top-s:0;--rs-inset-top-m:var(--rs-inset-top-s);--rs-inset-top-l:var(--rs-inset-top-m);--rs-inset-top-xl:var(--rs-inset-top-l);--rs-inset-top:var(--rs-inset-top-s)}[style*="--rs-inset-bottom-"]{inset-block-end:calc(var(--rs-inset-bottom) * var(--rs-unit-x1));--rs-inset-bottom-s:0;--rs-inset-bottom-m:var(--rs-inset-bottom-s);--rs-inset-bottom-l:var(--rs-inset-bottom-m);--rs-inset-bottom-xl:var(--rs-inset-bottom-l);--rs-inset-bottom:var(--rs-inset-bottom-s)}@media (--rs-viewport-m ){[style*="--rs-inset-all-"]{--rs-inset-all:var(--rs-inset-all-m)}[style*="--rs-inset-end-"]{--rs-inset-end:var(--rs-inset-end-m)}[style*="--rs-inset-start-"]{--rs-inset-start:var(--rs-inset-start-m)}[style*="--rs-inset-top-"]{--rs-inset-top:var(--rs-inset-top-m)}[style*="--rs-inset-bottom-"]{--rs-inset-bottom:var(--rs-inset-bottom-m)}}@media (--rs-viewport-l ){[style*="--rs-inset-all-"]{--rs-inset-all:var(--rs-inset-all-l)}[style*="--rs-inset-end-"]{--rs-inset-end:var(--rs-inset-end-l)}[style*="--rs-inset-start-"]{--rs-inset-start:var(--rs-inset-start-l)}[style*="--rs-inset-top-"]{--rs-inset-top:var(--rs-inset-top-l)}[style*="--rs-inset-bottom-"]{--rs-inset-bottom:var(--rs-inset-bottom-l)}}@media (--rs-viewport-xl ){[style*="--rs-inset-all-"]{--rs-inset-all:var(--rs-inset-all-xl)}[style*="--rs-inset-end-"]{--rs-inset-end:var(--rs-inset-end-xl)}[style*="--rs-inset-start-"]{--rs-inset-start:var(--rs-inset-start-xl)}[style*="--rs-inset-top-"]{--rs-inset-top:var(--rs-inset-top-xl)}[style*="--rs-inset-bottom-"]{--rs-inset-bottom:var(--rs-inset-bottom-xl)}}
@@ -1,3 +1,4 @@
1
1
  import * as T from "../types";
2
- declare const getJustifyStyles: T.StaticStyleUtility<T.Justify>;
2
+ import "./justify.css";
3
+ declare const getJustifyStyles: T.VariableStyleUtility<T.Justify>;
3
4
  export default getJustifyStyles;
@@ -1,10 +1,10 @@
1
- import { responsiveClassNames } from "../../utilities/helpers.js";
2
- import s from "./justify.module.css";
1
+ import { responsiveVariables } from "../../utilities/helpers.js";
2
+ import "./justify.css";
3
3
  const getJustifyStyles = (value) => {
4
4
  if (!value)
5
5
  return null;
6
6
  return {
7
- classNames: responsiveClassNames(s, "--justify", value),
7
+ variables: responsiveVariables("--rs-justify", value),
8
8
  };
9
9
  };
10
10
  export default getJustifyStyles;
@@ -0,0 +1 @@
1
+ [style*="--rs-justify-"]{justify-content:var(--rs-justify)!important;--rs-justify-s: ;--rs-justify-m:var(--rs-justify-s);--rs-justify-l:var(--rs-justify-m);--rs-justify-xl:var(--rs-justify-l);--rs-justify:var(--rs-justify-s)}@media (--rs-viewport-m ){[style*="--rs-justify-"]{--rs-justify:var(--rs-justify-m)}}@media (--rs-viewport-l ){[style*="--rs-justify-"]{--rs-justify:var(--rs-justify-l)}}@media (--rs-viewport-xl ){[style*="--rs-justify-"]{--rs-justify:var(--rs-justify-xl)}}
@@ -4,7 +4,7 @@ const getMaxHeightStyles = (value) => {
4
4
  if (!value)
5
5
  return null;
6
6
  const variables = responsiveVariables("--rs-max-h", value);
7
- const classNames = responsiveClassNames(s, (value) => (typeof value === "number" ? "unit" : "literal"), value, { excludeValueFromClassName: true });
8
- return { classNames, variables };
7
+ const classNames = responsiveClassNames(s, (value) => (typeof value === "number" ? "--type-unit" : "--type-literal"), value, { excludeValueFromClassName: true });
8
+ return { classNames: [s.root, classNames], variables };
9
9
  };
10
10
  export default getMaxHeightStyles;
@@ -1 +1 @@
1
- .literal{max-height:var(--rs-max-h-s,auto)}.unit{max-height:calc(var(--rs-max-h-s) * var(--rs-unit-x1))}@media (--rs-viewport-m ){.literal--m{max-height:var(--rs-max-h-m)}.unit--m{max-height:calc(var(--rs-max-h-m) * var(--rs-unit-x1))}}@media (--rs-viewport-l ){.literal--l{max-height:var(--rs-max-h-l)}.unit--l{max-height:calc(var(--rs-max-h-l) * var(--rs-unit-x1))}}@media (--rs-viewport-xl ){.literal--xl{max-height:var(--rs-max-h-xl)}.unit--xl{max-height:calc(var(--rs-max-h-xl) * var(--rs-unit-x1))}}
1
+ .root[style*="--rs-max-h-"]{--rs-max-h-s:none;--rs-max-h-m:var(--rs-max-h-s);--rs-max-h-l:var(--rs-max-h-m);--rs-max-h-xl:var(--rs-max-h-l);--rs-max-h:var(--rs-max-h-s)}.--type-literal{max-height:var(--rs-max-h)!important}.--type-unit{max-height:calc(var(--rs-max-h) * var(--rs-unit-x1))!important}@media (--rs-viewport-m ){.root[style*="--rs-max-h-"]{--rs-max-h:var(--rs-max-h-m)}.--type-literal--m{max-height:var(--rs-max-h)!important}.--type-unit--m{max-height:calc(var(--rs-max-h) * var(--rs-unit-x1))!important}}@media (--rs-viewport-l ){.root[style*="--rs-max-h-"]{--rs-max-h:var(--rs-max-h-l)}.--type-literal--l{max-height:var(--rs-max-h)!important}.--type-unit--l{max-height:calc(var(--rs-max-h) * var(--rs-unit-x1))!important}}@media (--rs-viewport-xl ){.root[style*="--rs-max-h-"]{--rs-max-h:var(--rs-max-h-xl)}.--type-literal--xl{max-height:var(--rs-max-h)!important}.--type-unit--xl{max-height:calc(var(--rs-max-h) * var(--rs-unit-x1))!important}}
@@ -4,7 +4,7 @@ const getMaxWidthStyles = (value) => {
4
4
  if (!value)
5
5
  return null;
6
6
  const variables = responsiveVariables("--rs-max-w", value);
7
- const classNames = responsiveClassNames(s, (value) => (typeof value === "number" ? "unit" : "literal"), value, { excludeValueFromClassName: true });
8
- return { classNames, variables };
7
+ const classNames = responsiveClassNames(s, (value) => (typeof value === "number" ? "--type-unit" : "--type-literal"), value, { excludeValueFromClassName: true });
8
+ return { classNames: [s.root, classNames], variables };
9
9
  };
10
10
  export default getMaxWidthStyles;
@@ -1 +1 @@
1
- .literal{max-width:var(--rs-max-w-s,auto)}.unit{max-width:calc(var(--rs-max-w-s) * var(--rs-unit-x1))}@media (--rs-viewport-m ){.literal--m{max-width:var(--rs-max-w-m)}.unit--m{max-width:calc(var(--rs-max-w-m) * var(--rs-unit-x1))}}@media (--rs-viewport-l ){.literal--l{max-width:var(--rs-max-w-l)}.unit--l{max-width:calc(var(--rs-max-w-l) * var(--rs-unit-x1))}}@media (--rs-viewport-xl ){.literal--xl{max-width:var(--rs-max-w-xl)}.unit--xl{max-width:calc(var(--rs-max-w-xl) * var(--rs-unit-x1))}}
1
+ .root[style*="--rs-max-w-"]{--rs-max-w-s:none;--rs-max-w-m:var(--rs-max-w-s);--rs-max-w-l:var(--rs-max-w-m);--rs-max-w-xl:var(--rs-max-w-l);--rs-max-w:var(--rs-max-w-s)}.--type-literal{max-width:var(--rs-max-w)!important}.--type-unit{max-width:calc(var(--rs-max-w) * var(--rs-unit-x1))!important}@media (--rs-viewport-m ){.root[style*="--rs-max-w-"]{--rs-max-w:var(--rs-max-w-m)}.--type-literal--m{max-width:var(--rs-max-w)!important}.--type-unit--m{max-width:calc(var(--rs-max-w) * var(--rs-unit-x1))!important}}@media (--rs-viewport-l ){.root[style*="--rs-max-w-"]{--rs-max-w:var(--rs-max-w-l)}.--type-literal--l{max-width:var(--rs-max-w)!important}.--type-unit--l{max-width:calc(var(--rs-max-w) * var(--rs-unit-x1))!important}}@media (--rs-viewport-xl ){.root[style*="--rs-max-w-"]{--rs-max-w:var(--rs-max-w-xl)}.--type-literal--xl{max-width:var(--rs-max-w)!important}.--type-unit--xl{max-width:calc(var(--rs-max-w) * var(--rs-unit-x1))!important}}