reshaped 3.9.0-canary.9 → 3.9.1-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.css +1 -1
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.js +2 -2
- package/dist/components/Accordion/AccordionControlled.js +0 -1
- package/dist/components/Actionable/Actionable.d.ts +8 -3
- package/dist/components/Actionable/Actionable.js +17 -70
- package/dist/components/Actionable/Actionable.module.css +1 -1
- package/dist/components/Actionable/Actionable.types.d.ts +2 -36
- package/dist/components/Actionable/index.d.ts +2 -1
- package/dist/components/Badge/Badge.js +2 -2
- package/dist/components/Badge/Badge.module.css +1 -1
- package/dist/components/Badge/Badge.types.d.ts +1 -1
- package/dist/components/Button/Button.module.css +1 -1
- package/dist/components/Calendar/Calendar.module.css +1 -1
- package/dist/components/Calendar/Calendar.utils.js +6 -7
- package/dist/components/Card/Card.d.ts +2 -2
- package/dist/components/Card/Card.types.d.ts +5 -5
- package/dist/components/Carousel/Carousel.js +0 -1
- package/dist/components/Flyout/Flyout.constants.d.ts +1 -0
- package/dist/components/Flyout/Flyout.constants.js +1 -0
- package/dist/components/Flyout/Flyout.module.css +1 -1
- package/dist/components/Flyout/Flyout.types.d.ts +10 -8
- package/dist/components/Flyout/FlyoutContent.js +4 -49
- package/dist/components/Flyout/FlyoutControlled.js +94 -76
- package/dist/components/Flyout/FlyoutTrigger.js +3 -3
- package/dist/components/Flyout/useFlyout.d.ts +3 -4
- package/dist/components/Flyout/useFlyout.js +70 -88
- package/dist/components/Flyout/utilities/safeArea.d.ts +10 -0
- package/dist/components/Flyout/utilities/safeArea.js +100 -0
- package/dist/components/Grid/Grid.types.d.ts +4 -4
- package/dist/components/HiddenInput/HiddenInput.js +2 -3
- package/dist/components/Image/Image.js +1 -1
- package/dist/components/Modal/Modal.js +0 -3
- package/dist/components/Popover/Popover.module.css +1 -1
- package/dist/components/Reshaped/Reshaped.css +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +6 -6
- package/dist/components/Select/Select.js +1 -1
- package/dist/components/Select/SelectCustomControlled.js +0 -1
- package/dist/components/Slider/SliderControlled.js +5 -4
- package/dist/components/Tabs/Tabs.module.css +1 -1
- package/dist/components/Tabs/Tabs.types.d.ts +3 -1
- package/dist/components/Tabs/TabsContext.d.ts +1 -0
- package/dist/components/Tabs/TabsControlled.js +2 -2
- package/dist/components/Tabs/TabsItem.js +2 -2
- package/dist/components/Tabs/TabsList.js +9 -5
- package/dist/components/Tabs/TabsPanel.js +1 -1
- package/dist/components/Text/Text.d.ts +1 -1
- package/dist/components/Text/Text.types.d.ts +3 -3
- package/dist/components/Toast/ToastContainer.js +0 -1
- package/dist/components/Tooltip/Tooltip.js +2 -2
- package/dist/components/Tooltip/Tooltip.module.css +1 -1
- package/dist/components/Tooltip/Tooltip.types.d.ts +1 -1
- package/dist/components/View/View.types.d.ts +4 -4
- package/dist/components/_private/Expandable/Expandable.js +1 -3
- package/dist/components/_private/Portal/Portal.js +0 -3
- package/dist/core/Actionable/Actionable.d.ts +4 -0
- package/dist/core/Actionable/Actionable.js +73 -0
- package/dist/core/Actionable/Actionable.types.d.ts +34 -0
- package/dist/core/Actionable/Actionable.types.js +1 -0
- package/dist/core/Actionable/index.d.ts +2 -0
- package/dist/core/Actionable/index.js +1 -0
- package/dist/hooks/_private/useDrag.js +0 -3
- package/dist/hooks/_private/usePrevious.js +0 -1
- package/dist/hooks/useOnClickOutside.js +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/types/global.d.ts +1 -1
- package/dist/utilities/a11y/TrapFocus.js +9 -3
- package/dist/utilities/dom/index.d.ts +0 -2
- package/dist/utilities/dom/index.js +0 -2
- package/dist/utilities/scroll/disable.js +4 -2
- package/package.json +7 -99
- package/README.md +0 -24
- package/dist/components/Flyout/utilities/calculatePosition.d.ts +0 -31
- package/dist/components/Flyout/utilities/calculatePosition.js +0 -178
- package/dist/components/Flyout/utilities/flyout.d.ts +0 -11
- package/dist/components/Flyout/utilities/flyout.js +0 -87
- package/dist/components/Flyout/utilities/getPositionFallbacks.d.ts +0 -3
- package/dist/components/Flyout/utilities/getPositionFallbacks.js +0 -39
- package/dist/components/Flyout/utilities/helpers.d.ts +0 -7
- package/dist/components/Flyout/utilities/helpers.js +0 -14
- package/dist/components/Flyout/utilities/isFullyVisible.d.ts +0 -12
- package/dist/components/Flyout/utilities/isFullyVisible.js +0 -22
- package/dist/utilities/dom/flyout.d.ts +0 -2
- package/dist/utilities/dom/flyout.js +0 -14
- package/dist/utilities/dom/userSelect.d.ts +0 -2
- package/dist/utilities/dom/userSelect.js +0 -6
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as G from "../../../types/global";
|
|
2
|
+
type SafePolygonOptions = {
|
|
3
|
+
contentRef: React.RefObject<HTMLElement | null>;
|
|
4
|
+
triggerRef: React.RefObject<HTMLElement | null>;
|
|
5
|
+
position: string | null | undefined;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
origin: G.Coordinates;
|
|
8
|
+
};
|
|
9
|
+
export declare function createSafeArea(options: SafePolygonOptions): () => void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a point is inside a triangle using barycentric coordinates
|
|
3
|
+
*/
|
|
4
|
+
function isPointInTriangle(point, triangle) {
|
|
5
|
+
const [p1, p2, p3] = triangle;
|
|
6
|
+
const denominator = (p2.y - p3.y) * (p1.x - p3.x) + (p3.x - p2.x) * (p1.y - p3.y);
|
|
7
|
+
const a = ((p2.y - p3.y) * (point.x - p3.x) + (p3.x - p2.x) * (point.y - p3.y)) / denominator;
|
|
8
|
+
const b = ((p3.y - p1.y) * (point.x - p3.x) + (p1.x - p3.x) * (point.y - p3.y)) / denominator;
|
|
9
|
+
const c = 1 - a - b;
|
|
10
|
+
return a >= 0 && a <= 1 && b >= 0 && b <= 1 && c >= 0 && c <= 1;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Gets the two closest corners of the content element based on the flyout position
|
|
14
|
+
*/
|
|
15
|
+
function getContentCorners(contentRect, position) {
|
|
16
|
+
const corners = {
|
|
17
|
+
topLeft: { x: contentRect.left, y: contentRect.top },
|
|
18
|
+
topRight: { x: contentRect.right, y: contentRect.top },
|
|
19
|
+
bottomLeft: { x: contentRect.left, y: contentRect.bottom },
|
|
20
|
+
bottomRight: { x: contentRect.right, y: contentRect.bottom },
|
|
21
|
+
};
|
|
22
|
+
if (position?.startsWith("bottom")) {
|
|
23
|
+
return [corners.topLeft, corners.topRight];
|
|
24
|
+
}
|
|
25
|
+
else if (position?.startsWith("top")) {
|
|
26
|
+
return [corners.bottomLeft, corners.bottomRight];
|
|
27
|
+
}
|
|
28
|
+
else if (position?.startsWith("start")) {
|
|
29
|
+
return [corners.topRight, corners.bottomRight];
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return [corners.topLeft, corners.bottomLeft];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Checks if the mouse is over the trigger or content elements
|
|
37
|
+
*/
|
|
38
|
+
function isMouseOverElement(point, contentRef, triggerRef) {
|
|
39
|
+
const elements = document.elementsFromPoint(point.x, point.y);
|
|
40
|
+
return elements.some((el) => (contentRef.current && contentRef.current.contains(el)) ||
|
|
41
|
+
(triggerRef.current && triggerRef.current.contains(el)));
|
|
42
|
+
}
|
|
43
|
+
export function createSafeArea(options) {
|
|
44
|
+
const { contentRef, triggerRef, position, onClose, origin: passedOrigin } = options;
|
|
45
|
+
if (!contentRef.current) {
|
|
46
|
+
// If content doesn't exist, just close immediately
|
|
47
|
+
onClose();
|
|
48
|
+
return () => { };
|
|
49
|
+
}
|
|
50
|
+
const contentRect = contentRef.current.getBoundingClientRect();
|
|
51
|
+
const [corner1, corner2] = getContentCorners(contentRect, position);
|
|
52
|
+
// Add buffer to origin based on position to extend safe area
|
|
53
|
+
const buffer = 10;
|
|
54
|
+
const origin = { x: passedOrigin.x, y: passedOrigin.y };
|
|
55
|
+
if (position?.startsWith("bottom")) {
|
|
56
|
+
origin.y -= buffer;
|
|
57
|
+
}
|
|
58
|
+
else if (position?.startsWith("top")) {
|
|
59
|
+
origin.y += buffer;
|
|
60
|
+
}
|
|
61
|
+
else if (position?.startsWith("start")) {
|
|
62
|
+
origin.x += buffer;
|
|
63
|
+
}
|
|
64
|
+
else if (position?.startsWith("end")) {
|
|
65
|
+
origin.x -= buffer;
|
|
66
|
+
}
|
|
67
|
+
const triangle = [origin, corner1, corner2];
|
|
68
|
+
let timeoutId = null;
|
|
69
|
+
const cleanup = () => {
|
|
70
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
71
|
+
if (timeoutId)
|
|
72
|
+
clearTimeout(timeoutId);
|
|
73
|
+
};
|
|
74
|
+
// Start timeout for 1 second
|
|
75
|
+
const startTimeout = () => {
|
|
76
|
+
if (timeoutId)
|
|
77
|
+
clearTimeout(timeoutId);
|
|
78
|
+
timeoutId = setTimeout(() => {
|
|
79
|
+
onClose();
|
|
80
|
+
cleanup();
|
|
81
|
+
}, 1000);
|
|
82
|
+
};
|
|
83
|
+
const handleMouseMove = (e) => {
|
|
84
|
+
const currentPoint = { x: e.clientX, y: e.clientY };
|
|
85
|
+
if (isMouseOverElement(currentPoint, contentRef, triggerRef)) {
|
|
86
|
+
cleanup();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (isPointInTriangle(currentPoint, triangle)) {
|
|
90
|
+
startTimeout();
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
onClose();
|
|
94
|
+
cleanup();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
startTimeout();
|
|
98
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
99
|
+
return cleanup;
|
|
100
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { Property } from "csstype";
|
|
|
2
2
|
import type React from "react";
|
|
3
3
|
import type * as TStyles from "../../styles/types";
|
|
4
4
|
import type * as G from "../../types/global";
|
|
5
|
-
export type Props<TagName extends keyof React.JSX.IntrinsicElements =
|
|
5
|
+
export type Props<TagName extends keyof React.JSX.IntrinsicElements | void = void> = {
|
|
6
6
|
/** Gap between grid items */
|
|
7
7
|
gap?: G.Responsive<number>;
|
|
8
8
|
/** Horizontal gap between grid items */
|
|
@@ -34,13 +34,13 @@ export type Props<TagName extends keyof React.JSX.IntrinsicElements = "div"> = {
|
|
|
34
34
|
/** Node for inserting children */
|
|
35
35
|
children?: React.ReactNode;
|
|
36
36
|
/** Custom root element html tag */
|
|
37
|
-
as?: TagName;
|
|
37
|
+
as?: TagName extends keyof React.JSX.IntrinsicElements ? TagName : keyof React.JSX.IntrinsicElements;
|
|
38
38
|
/** Additional classname for the root element */
|
|
39
39
|
className?: G.ClassName;
|
|
40
40
|
/** Additional attributes for the root element */
|
|
41
41
|
attributes?: G.Attributes<TagName>;
|
|
42
42
|
};
|
|
43
|
-
export type ItemProps<TagName extends keyof React.JSX.IntrinsicElements =
|
|
43
|
+
export type ItemProps<TagName extends keyof React.JSX.IntrinsicElements | void = void> = {
|
|
44
44
|
/** Grid area for template syntax */
|
|
45
45
|
area?: string;
|
|
46
46
|
/** Starting column position */
|
|
@@ -58,7 +58,7 @@ export type ItemProps<TagName extends keyof React.JSX.IntrinsicElements = "div">
|
|
|
58
58
|
/** Node for inserting children */
|
|
59
59
|
children?: React.ReactNode;
|
|
60
60
|
/** Custom item element html tag */
|
|
61
|
-
as?: TagName;
|
|
61
|
+
as?: TagName extends keyof React.JSX.IntrinsicElements ? TagName : keyof React.JSX.IntrinsicElements;
|
|
62
62
|
/** Additional classname for the item element */
|
|
63
63
|
className?: G.ClassName;
|
|
64
64
|
/** Additional attributes for the item element */
|
|
@@ -12,8 +12,7 @@ const HiddenInput = (props) => {
|
|
|
12
12
|
const formControl = useFormControl();
|
|
13
13
|
const name = checkboxGroup?.name ?? radioGroup?.name ?? props.name;
|
|
14
14
|
const disabled = formControl?.disabled ?? props.disabled ?? checkboxGroup?.disabled ?? radioGroup?.disabled;
|
|
15
|
-
const checked = (value && checkboxGroup?.value?.includes(value)) ||
|
|
16
|
-
radioGroup?.value === value ||
|
|
15
|
+
const checked = (value && (checkboxGroup?.value?.includes(value) ?? radioGroup?.value === value)) ||
|
|
17
16
|
props.checked;
|
|
18
17
|
const defaultChecked = checkboxGroup ? undefined : props.defaultChecked;
|
|
19
18
|
const handleChange = (event) => {
|
|
@@ -28,7 +27,7 @@ const HiddenInput = (props) => {
|
|
|
28
27
|
if (radioGroup?.onChange)
|
|
29
28
|
radioGroup.onChange(changeArgs);
|
|
30
29
|
};
|
|
31
|
-
return (_jsx("input", { ...attributes, className: rootClassNames, type: type, name: name, value: value, checked: checked, defaultChecked: defaultChecked, disabled: disabled, onChange: handleChange, onFocus: onFocus || attributes?.onFocus, onBlur: onBlur || attributes?.onBlur }));
|
|
30
|
+
return (_jsx("input", { ...attributes, className: rootClassNames, type: type, name: name, value: value, checked: checked, defaultChecked: defaultChecked, disabled: disabled, onChange: handleChange, onFocus: onFocus || attributes?.onFocus, onBlur: onBlur || attributes?.onBlur, "data-rs-hidden-input": true }));
|
|
32
31
|
};
|
|
33
32
|
HiddenInput.displayName = "HiddenInput";
|
|
34
33
|
export default HiddenInput;
|
|
@@ -7,7 +7,6 @@ import useElementId from "../../hooks/useElementId.js";
|
|
|
7
7
|
import useHandlerRef from "../../hooks/useHandlerRef.js";
|
|
8
8
|
import useResponsiveClientValue from "../../hooks/useResponsiveClientValue.js";
|
|
9
9
|
import { resolveMixin } from "../../styles/mixin.js";
|
|
10
|
-
import { enableUserSelect, disableUserSelect } from "../../utilities/dom/index.js";
|
|
11
10
|
import { classNames, responsiveVariables, responsiveClassNames } from "../../utilities/props.js";
|
|
12
11
|
import { enableScroll, disableScroll } from "../../utilities/scroll/index.js";
|
|
13
12
|
import s from "./Modal.module.css";
|
|
@@ -90,7 +89,6 @@ const Modal = (props) => {
|
|
|
90
89
|
// Prevent the drag handling when browser is trying to navigate to a previous page
|
|
91
90
|
if (clientPosition === "start" && e.targetTouches[0].clientX < DRAG_EDGE_BOUNDARY)
|
|
92
91
|
return;
|
|
93
|
-
disableUserSelect();
|
|
94
92
|
disableScroll();
|
|
95
93
|
setDragging(true);
|
|
96
94
|
};
|
|
@@ -108,7 +106,6 @@ const Modal = (props) => {
|
|
|
108
106
|
if (!dragging)
|
|
109
107
|
return;
|
|
110
108
|
const handleDragEnd = () => {
|
|
111
|
-
enableUserSelect();
|
|
112
109
|
enableScroll();
|
|
113
110
|
setDragging(false);
|
|
114
111
|
// Close only when dragging in the closing direction
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.content{--rs-border-w:1px;border:var(--rs-border-w) solid var(--rs-color-border-neutral-faded);max-width:360px}.content--variant-elevated{background:var(--rs-color-background-elevation-overlay);
|
|
1
|
+
.content{--rs-border-w:1px;border:var(--rs-border-w) solid var(--rs-color-border-neutral-faded);border-radius:var(--rs-radius-medium);max-width:360px}.content--variant-elevated{background:var(--rs-color-background-elevation-overlay);box-shadow:var(--rs-shadow-overlay);color:var(--rs-color-foreground-neutral);min-width:220px}.content--variant-elevated.content--elevation-raised{box-shadow:var(--rs-shadow-raised)}.content--variant-headless{border:none}.content--radius-small{border-radius:var(--rs-radius-small)}.content.content--has-width{max-width:none;min-width:0}@media (--rs-viewport-s ){.content{max-width:none}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer rs.reset{[data-rs-theme]{--rs-radius-circular:9999px;--rs-shadow-focus:0 0 0 2px var(--rs-color-background-elevation-base),0 0 0 4px var(--rs-color-border-primary);--rs-shadow-focus-inset:inset 0 0 0 2px var(--rs-color-border-primary),inset 0 0 0 4px var(--rs-color-background-elevation-base)}[data-rs-theme] blockquote,[data-rs-theme] body,[data-rs-theme] dd,[data-rs-theme] dl,[data-rs-theme] figcaption,[data-rs-theme] figure,[data-rs-theme] h1,[data-rs-theme] h2,[data-rs-theme] h3,[data-rs-theme] h4,[data-rs-theme] h5,[data-rs-theme] h6,[data-rs-theme] li,[data-rs-theme] ol,[data-rs-theme] p,[data-rs-theme] ul{margin:0;padding:0}[data-rs-theme] ol[class],[data-rs-theme] ul[class]{list-style:none}[data-rs-theme] textarea{resize:vertical}[data-rs-theme] table{border-collapse:collapse;border-spacing:0}[data-rs-theme] fieldset{border:0;margin:0;padding:0}[data-rs-theme] img{display:block;max-width:100%}[data-rs-theme] button,[data-rs-theme] input,[data-rs-theme] select,[data-rs-theme] textarea{font:inherit}[data-rs-theme] option{background:var(--rs-color-background-elevation-base)}[data-rs-theme] label{cursor:pointer}[data-rs-theme] input::placeholder,[data-rs-theme] textarea::placeholder{color:var(--rs-color-foreground-disabled)}html[data-rs-theme]{-webkit-text-size-adjust:100%;-webkit-font-smoothing:antialiased;font-size:100%;text-rendering:optimizelegibility;touch-action:manipulation}[data-rs-theme] *{box-sizing:border-box}[data-rs-theme] body,html[data-rs-theme]{background:var(--rs-color-background-page);color:var(--rs-color-foreground-neutral);min-height:
|
|
1
|
+
@layer rs.reset{[data-rs-theme]{--rs-radius-circular:9999px;--rs-shadow-focus:0 0 0 2px var(--rs-color-background-elevation-base),0 0 0 4px var(--rs-color-border-primary);--rs-shadow-focus-inset:inset 0 0 0 2px var(--rs-color-border-primary),inset 0 0 0 4px var(--rs-color-background-elevation-base)}[data-rs-theme] blockquote,[data-rs-theme] body,[data-rs-theme] dd,[data-rs-theme] dl,[data-rs-theme] figcaption,[data-rs-theme] figure,[data-rs-theme] h1,[data-rs-theme] h2,[data-rs-theme] h3,[data-rs-theme] h4,[data-rs-theme] h5,[data-rs-theme] h6,[data-rs-theme] li,[data-rs-theme] ol,[data-rs-theme] p,[data-rs-theme] ul{margin:0;padding:0}[data-rs-theme] ol[class],[data-rs-theme] ul[class]{list-style:none}[data-rs-theme] textarea{resize:vertical}[data-rs-theme] table{border-collapse:collapse;border-spacing:0}[data-rs-theme] fieldset{border:0;margin:0;padding:0}[data-rs-theme] img{display:block;max-width:100%}[data-rs-theme] button,[data-rs-theme] input,[data-rs-theme] select,[data-rs-theme] textarea{font:inherit}[data-rs-theme] option{background:var(--rs-color-background-elevation-base)}[data-rs-theme] label{cursor:pointer}[data-rs-theme] input::placeholder,[data-rs-theme] textarea::placeholder{color:var(--rs-color-foreground-disabled)}html[data-rs-theme]{-webkit-text-size-adjust:100%;-webkit-font-smoothing:antialiased;font-size:100%;text-rendering:optimizelegibility;touch-action:manipulation}[data-rs-theme] *{box-sizing:border-box}[data-rs-theme] body,html[data-rs-theme]{background:var(--rs-color-background-page);color:var(--rs-color-foreground-neutral);min-height:100dvh;scroll-behavior:smooth}[data-rs-theme] body,[data-rs-theme]:not(html){font-family:var(--rs-font-family-body);font-size:var(--rs-font-size-body-3);font-weight:var(--rs-font-weight-regular);letter-spacing:var(--rs-letter-spacing-body-3);line-height:var(--rs-line-height-body-3)}}[data-rs-color-mode=light]{color-scheme:light}[data-rs-color-mode=dark]{color-scheme:dark}@media (prefers-reduced-motion:reduce){*{animation-duration:0s!important;animation-iteration-count:1!important;scroll-behavior:auto!important;transition-duration:0s!important}}[data-rs-no-transition] *,[data-rs-no-transition] :after,[data-rs-no-transition] :before{transition:none!important}
|
|
@@ -4,8 +4,8 @@ import React, { forwardRef } from "react";
|
|
|
4
4
|
import useHandlerRef from "../../hooks/useHandlerRef.js";
|
|
5
5
|
import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
|
|
6
6
|
import { resolveMixin } from "../../styles/mixin.js";
|
|
7
|
-
import { disableUserSelect, enableUserSelect } from "../../utilities/dom/index.js";
|
|
8
7
|
import { classNames } from "../../utilities/props.js";
|
|
8
|
+
import { disableScroll, enableScroll } from "../../utilities/scroll/index.js";
|
|
9
9
|
import s from "./ScrollArea.module.css";
|
|
10
10
|
const ScrollAreaBar = (props) => {
|
|
11
11
|
const { ratio, position, vertical, onThumbMove } = props;
|
|
@@ -41,14 +41,14 @@ const ScrollAreaBar = (props) => {
|
|
|
41
41
|
const total = vertical ? elBar.scrollHeight : elBar.scrollWidth;
|
|
42
42
|
onThumbMoveRef.current?.({ value: diff / total, type: "relative" });
|
|
43
43
|
}, [vertical, dragging, onThumbMoveRef]);
|
|
44
|
-
const handleDragEnd = React.useCallback(() => {
|
|
45
|
-
setDragging(false);
|
|
46
|
-
enableUserSelect();
|
|
47
|
-
}, []);
|
|
48
44
|
const handleDragStart = () => {
|
|
49
45
|
setDragging(true);
|
|
50
|
-
|
|
46
|
+
disableScroll();
|
|
51
47
|
};
|
|
48
|
+
const handleDragEnd = React.useCallback(() => {
|
|
49
|
+
setDragging(false);
|
|
50
|
+
enableScroll();
|
|
51
|
+
}, []);
|
|
52
52
|
React.useEffect(() => {
|
|
53
53
|
if (!dragging)
|
|
54
54
|
return;
|
|
@@ -9,7 +9,7 @@ const Select = (props) => {
|
|
|
9
9
|
return (_jsx(SelectRoot, { ...props, children: (props) => {
|
|
10
10
|
const { options } = props;
|
|
11
11
|
const hasOptionChildren = React.Children.toArray(children).some((child) => {
|
|
12
|
-
return React.isValidElement(child) && child.type === "option";
|
|
12
|
+
return (React.isValidElement(child) && (child.type === "option" || child.type === "optgroup"));
|
|
13
13
|
});
|
|
14
14
|
const hasOptions = Boolean(options || hasOptionChildren);
|
|
15
15
|
if (!hasOptions) {
|
|
@@ -5,7 +5,7 @@ import { useFormControl } from "../FormControl/index.js";
|
|
|
5
5
|
import useElementId from "../../hooks/useElementId.js";
|
|
6
6
|
import useHandlerRef from "../../hooks/useHandlerRef.js";
|
|
7
7
|
import useRTL from "../../hooks/useRTL.js";
|
|
8
|
-
import {
|
|
8
|
+
import { triggerChangeEvent } from "../../utilities/dom/index.js";
|
|
9
9
|
import { classNames } from "../../utilities/props.js";
|
|
10
10
|
import { disableScroll, enableScroll } from "../../utilities/scroll/index.js";
|
|
11
11
|
import s from "./Slider.module.css";
|
|
@@ -144,30 +144,31 @@ const SliderControlled = (props) => {
|
|
|
144
144
|
handleMinChange(nextValue);
|
|
145
145
|
if (closestId === maxId)
|
|
146
146
|
handleMaxChange(nextValue);
|
|
147
|
-
disableUserSelect();
|
|
148
|
-
disableScroll();
|
|
149
147
|
setDraggingId(closestId);
|
|
150
148
|
};
|
|
151
149
|
const handleMinDragStart = (e) => {
|
|
152
150
|
if (disabled)
|
|
153
151
|
return;
|
|
154
152
|
e.stopPropagation();
|
|
153
|
+
disableScroll();
|
|
155
154
|
setDraggingId(minId);
|
|
156
155
|
};
|
|
157
156
|
const handleMaxDragStart = (e) => {
|
|
158
157
|
if (disabled)
|
|
159
158
|
return;
|
|
160
159
|
e.stopPropagation();
|
|
160
|
+
disableScroll();
|
|
161
161
|
setDraggingId(maxId);
|
|
162
162
|
};
|
|
163
163
|
const handleDragStop = React.useCallback(() => {
|
|
164
164
|
if (draggingId === minId && minValue !== undefined) {
|
|
165
165
|
handleMinChange(minValue, { commit: true });
|
|
166
|
+
minInputRef.current?.focus();
|
|
166
167
|
}
|
|
167
168
|
if (draggingId === maxId) {
|
|
168
169
|
handleMaxChange(maxValue, { commit: true });
|
|
170
|
+
maxInputRef.current?.focus();
|
|
169
171
|
}
|
|
170
|
-
enableUserSelect();
|
|
171
172
|
enableScroll();
|
|
172
173
|
setDraggingId(null);
|
|
173
174
|
}, [minValue, maxValue, handleMinChange, handleMaxChange, draggingId, minId, maxId]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@property --rs-tabs-mid-l{syntax:"<length>";initial-value:-24px;inherits:false}@property --rs-tabs-stop-l{syntax:"<length>";initial-value:0;inherits:false}@property --rs-tabs-stop-r{syntax:"<length-percentage>";initial-value:100%;inherits:false}@property --rs-tabs-mid-r{syntax:"<length-percentage>";initial-value:calc(100% + 24px);inherits:false}.root{
|
|
1
|
+
@property --rs-tabs-mid-l{syntax:"<length>";initial-value:-24px;inherits:false}@property --rs-tabs-stop-l{syntax:"<length>";initial-value:0;inherits:false}@property --rs-tabs-stop-r{syntax:"<length-percentage>";initial-value:100%;inherits:false}@property --rs-tabs-mid-r{syntax:"<length-percentage>";initial-value:calc(100% + 24px);inherits:false}.root{--rs-tabs-gap:var(--rs-unit-x6);box-sizing:initial;isolation:isolate;max-width:100%;position:relative}.inner:after{background-color:var(--rs-color-border-neutral-faded);content:"";position:absolute;z-index:2}.list{gap:var(--rs-tabs-gap)}.list,.listItem{position:relative}.listItem{flex-shrink:0}.button{--rs-tabs-focus-ring-inset:calc(var(--rs-unit-x2) * -1);position:relative;width:100%;z-index:1;-webkit-tap-highlight-color:transparent;border-radius:var(--rs-radius-medium)}[data-rs-keyboard] .button:focus:after{border-radius:var(--rs-radius-medium);box-shadow:var(--rs-shadow-focus-inset);content:"";inset:0;inset-inline:var(--rs-tabs-focus-ring-inset);pointer-events:none;position:absolute}.buttonContent{align-items:center;border-radius:var(--rs-radius-medium);box-sizing:border-box;display:flex;width:100%}.icon{color:inherit;transition:color var(--rs-duration-fast) var(--rs-easing-standard)}.icon:not(:last-child){margin-inline-end:var(--rs-unit-x2)}[data-rs-keyboard] .radio:focus+.buttonContent{box-shadow:var(--rs-shadow-focus-inset)}.item{color:var(--rs-color-foreground-neutral)}.item:after{content:"";opacity:0;pointer-events:none}.item--active.item:after{opacity:1}.item.item--disabled{color:var(--rs-color-foreground-disabled)}.root:not(:has(.selector)) .item:after{transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:opacity}.item:after,.selector{background:var(--rs-color-border-primary);border-radius:var(--rs-radius-medium);position:absolute;z-index:var(--rs-z-index-relative)}.selector{--rs-tab-selection-x:0;--rs-tab-selection-y:0;--rs-tab-selection-scale-x:0;--rs-tab-selection-scale-y:0;transform:translate(calc(var(--rs-tab-selection-x) * 1px),calc(var(--rs-tab-selection-y) * 1px)) translateZ(0);transform-origin:0 0}.selector.selector--hidden{visibility:hidden}.selector.selector--animated{transition:var(--rs-duration-medium) var(--rs-easing-decelerate);transition-property:transform,height,width;will-change:transform,height,width}.control{align-items:center;display:none;inset-block:0;opacity:0;pointer-events:none;position:absolute;transition:var(--rs-duration-medium) var(--rs-easing-decelerate);transition-property:opacity,transform;z-index:var(--rs-z-index-relative)}.control.control--active{opacity:1;pointer-events:all}[dir=rtl] .control{transform:scaleX(-1)}.control.control--next{inset-inline-end:0}.control.control--prev{inset-inline-start:0}.panel{outline:none}[data-rs-keyboard] .panel:focus{box-shadow:var(--rs-shadow-focus)}.panel.panel--hidden{display:none}.--scrollable .inner{overflow:auto;overflow:-moz-scrollbars-none;scrollbar-width:none;-ms-overflow-style:none;mask-image:linear-gradient(to right,transparent 0,transparent var(--rs-tabs-mid-l),#000 var(--rs-tabs-stop-l),#000 var(--rs-tabs-stop-r),transparent var(--rs-tabs-mid-r),transparent 100%);transition:var(--rs-duration-medium) var(--rs-easing-decelerate);transition-property:--rs-tabs-stop-l,--rs-tabs-stop-r,--rs-tabs-mid-l,--rs-tabs-mid-r}.--scrollable .inner::-webkit-scrollbar{display:none}.--direction-row .inner{white-space:nowrap}.--direction-row .inner:after{bottom:0;height:1px;inset-inline:0}.--direction-row .list{align-items:center;display:inline-flex;flex-wrap:nowrap;vertical-align:top}.--direction-row .item:after{inset-inline:0;bottom:0;height:2px}.--direction-row .selector{bottom:0;height:2px;left:0;width:calc(var(--rs-tab-selection-scale-x) * 1px)}.--direction-row .button{box-sizing:initial;margin-block:var(--rs-unit-x1)}.--direction-row .buttonContent{justify-content:center;padding:var(--rs-tabs-item-p-v) 0}.--direction-column{--rs-tabs-gap:var(--rs-unit-x1)}.--direction-column .inner:after{height:100%;inset-block:0;inset-inline-end:0;width:1px}.--direction-column .list{display:flex;flex-direction:column}.--direction-column .item{padding-inline-end:var(--rs-unit-x1)}.--direction-column .item:after{inset-block:0;inset-inline-end:0;width:2px}.--direction-column .selector{height:calc(var(--rs-tab-selection-scale-y) * 1px);inset-inline-end:0;top:0;width:2px}.--direction-column .button{--rs-tabs-focus-ring-inset:0;margin-inline-start:calc(var(--rs-unit-x2) * -1);padding:var(--rs-unit-x2);width:calc(100% + var(--rs-unit-x1))}.--direction-column .buttonContent{justify-content:flex-start}.--variant-borderless .inner:after,.--variant-pills .inner:after,.--variant-pills-elevated .inner:after{content:none}.--variant-pills,.--variant-pills-elevated{--rs-tabs-gap:var(--rs-unit-x1)}.--variant-pills .button,.--variant-pills-elevated .button{--rs-tabs-focus-ring-inset:0;margin:0;padding:0}.--variant-pills .buttonContent,.--variant-pills-elevated .buttonContent{margin:0;padding:var(--rs-tabs-item-p-v) var(--rs-tabs-item-p-h)}.--variant-pills .selector,.--variant-pills-elevated .selector{background-color:var(--rs-color-background-neutral);height:calc(var(--rs-tab-selection-scale-y) * 1px);width:calc(var(--rs-tab-selection-scale-x) * 1px);z-index:0}.--variant-pills .item:after,.--variant-pills-elevated .item:after{background-color:var(--rs-color-background-neutral);z-index:0}.--variant-pills-elevated.--direction-column .item:after,.--variant-pills.--direction-column .item:after{width:100%}.--variant-pills-elevated.--direction-column .selector,.--variant-pills.--direction-column .selector{left:0}.--variant-pills-elevated.--direction-row .item:after,.--variant-pills.--direction-row .item:after{height:100%}.--variant-pills-elevated.--direction-row .selector,.--variant-pills.--direction-row .selector{top:0}.--variant-pills .item--active:after,.--variant-pills .selector{opacity:.6}.--variant-pills-elevated .list{background:var(--rs-color-background-neutral-faded);border:2px solid transparent;border-radius:var(--rs-radius-medium)}.--variant-pills-elevated .buttonContent{padding:calc(var(--rs-tabs-item-p-v) - var(--rs-unit-x1) / 2) var(--rs-tabs-item-p-h)}.--variant-pills-elevated .item:after,.--variant-pills-elevated .selector{background:var(--rs-color-background-elevation-raised);border-radius:calc(var(--rs-radius-medium) - 1px);box-shadow:var(--rs-shadow-raised);box-sizing:border-box}.--size-medium{--rs-tabs-item-p-v:var(--rs-unit-x2);--rs-tabs-item-p-h:var(--rs-unit-x3)}.--size-large{--rs-tabs-item-p-v:var(--rs-unit-x3);--rs-tabs-item-p-h:var(--rs-unit-x4)}.--item-width-equal{max-width:none}.--item-width-equal .inner{flex-wrap:wrap}.--item-width-equal .list{display:flex}.--item-width-equal .listItem{flex-basis:0;flex-grow:1;margin:0;min-width:0}.--item-width-equal .buttonText{overflow:hidden;text-overflow:ellipsis}.--item-width-equal .button{--rs-tabs-focus-ring-inset:0}.--fade-end .inner,[dir=rtl] .--fade-start .inner{--rs-tabs-mid-r:100%;--rs-tabs-stop-r:calc(100% - var(--rs-unit-x1) * 10)}.--fade-start .inner,[dir=rtl] .--fade-end .inner{--rs-tabs-mid-l:0px;--rs-tabs-stop-l:calc(var(--rs-unit-x1) * 10)}@media (pointer:fine){.control{display:flex}.--fade-end .inner,[dir=rtl] .--fade-start .inner{--rs-tabs-mid-r:calc(100% - var(--rs-unit-x1) * 4);--rs-tabs-stop-r:calc(100% - var(--rs-unit-x1) * 10)}.--fade-start .inner,[dir=rtl] .--fade-end .inner{--rs-tabs-mid-l:calc(var(--rs-unit-x1) * 4);--rs-tabs-stop-l:calc(var(--rs-unit-x1) * 10)}}
|
|
@@ -53,6 +53,8 @@ export type BaseProps = {
|
|
|
53
53
|
size?: "medium" | "large";
|
|
54
54
|
/** Name of the tab buttons group when used as a form control */
|
|
55
55
|
name?: string;
|
|
56
|
+
/** Disable the animation of the tab button selection */
|
|
57
|
+
disableSelectionAnimation?: boolean;
|
|
56
58
|
/** Callback when the active tab value changes */
|
|
57
59
|
onChange?: (args: {
|
|
58
60
|
value: string;
|
|
@@ -75,7 +77,7 @@ export type UncontrolledProps = BaseProps & {
|
|
|
75
77
|
defaultValue?: string;
|
|
76
78
|
};
|
|
77
79
|
export type Props = ControlledProps | UncontrolledProps;
|
|
78
|
-
export type Context = Pick<BaseProps, "itemWidth" | "onChange" | "variant" | "name" | "direction"> & {
|
|
80
|
+
export type Context = Pick<BaseProps, "itemWidth" | "onChange" | "variant" | "name" | "direction" | "disableSelectionAnimation"> & {
|
|
79
81
|
size: NonNullable<BaseProps["size"]>;
|
|
80
82
|
value?: string;
|
|
81
83
|
setDefaultValue: (value: string) => void;
|
|
@@ -12,6 +12,7 @@ export declare const useTabs: (value?: string) => {
|
|
|
12
12
|
name?: string;
|
|
13
13
|
}) => void) | undefined;
|
|
14
14
|
itemWidth?: "equal" | undefined;
|
|
15
|
+
disableSelectionAnimation?: boolean | undefined;
|
|
15
16
|
size: NonNullable<T.BaseProps["size"]>;
|
|
16
17
|
value?: string;
|
|
17
18
|
setDefaultValue: (value: string) => void;
|
|
@@ -4,10 +4,9 @@ import React from "react";
|
|
|
4
4
|
import useElementId from "../../hooks/useElementId.js";
|
|
5
5
|
import { TabsProvider } from "./TabsContext.js";
|
|
6
6
|
const TabsControlled = (props) => {
|
|
7
|
-
const { children, value, onChange, onSilentChange, itemWidth, variant, name, direction = "row", size = "medium", } = props;
|
|
7
|
+
const { children, value, onChange, onSilentChange, itemWidth, variant, name, disableSelectionAnimation, direction = "row", size = "medium", } = props;
|
|
8
8
|
const id = useElementId();
|
|
9
9
|
const elActiveRef = React.useRef(null);
|
|
10
|
-
// eslint-disable-next-line react-hooks/refs
|
|
11
10
|
const elPrevActiveRef = React.useRef(elActiveRef.current);
|
|
12
11
|
const elScrollableRef = React.useRef(null);
|
|
13
12
|
const [selection, setSelection] = React.useState({
|
|
@@ -38,6 +37,7 @@ const TabsControlled = (props) => {
|
|
|
38
37
|
elScrollableRef,
|
|
39
38
|
selection,
|
|
40
39
|
setSelection,
|
|
40
|
+
disableSelectionAnimation,
|
|
41
41
|
}, children: children }));
|
|
42
42
|
};
|
|
43
43
|
TabsControlled.displayName = "TabsControlled";
|
|
@@ -16,7 +16,7 @@ const TabsItem = React.forwardRef((props, ref) => {
|
|
|
16
16
|
const itemRef = React.useRef(null);
|
|
17
17
|
const active = tabsValue === value;
|
|
18
18
|
const visuallySelected = active && selection.status === "idle";
|
|
19
|
-
const itemClassNames = classNames(s.item, visuallySelected && s["--
|
|
19
|
+
const itemClassNames = classNames(s.item, visuallySelected && s["item--active"], disabled && s["item--disabled"]);
|
|
20
20
|
const isFormControl = !!name;
|
|
21
21
|
const tabAttributes = {
|
|
22
22
|
role: "tab",
|
|
@@ -60,7 +60,7 @@ const TabsItem = React.forwardRef((props, ref) => {
|
|
|
60
60
|
return;
|
|
61
61
|
updateRefs();
|
|
62
62
|
}, [active, updateRefs]);
|
|
63
|
-
return (_jsx("div", { ...attributes, className: itemClassNames, ref: itemRef, role: "presentation", children: _jsxs(Actionable, { ref: ref, href: href,
|
|
63
|
+
return (_jsx("div", { ...attributes, className: itemClassNames, ref: itemRef, role: "presentation", children: _jsxs(Actionable, { ref: ref, href: href, disableFocusRing: true, disabled: disabled, onClick: !name ? handleChange : undefined, className: s.button, as: name ? "label" : undefined, attributes: {
|
|
64
64
|
...(!isFormControl && tabAttributes),
|
|
65
65
|
"aria-controls": panelId,
|
|
66
66
|
id: buttonId,
|
|
@@ -22,11 +22,11 @@ const findParentItem = (el, rootEl) => {
|
|
|
22
22
|
};
|
|
23
23
|
const TabsList = (props) => {
|
|
24
24
|
const { children, className, attributes } = props;
|
|
25
|
-
const { value, setDefaultValue, itemWidth, variant, name, direction, size, selection, setSelection, elActiveRef, elPrevActiveRef, elScrollableRef, } = useTabs();
|
|
25
|
+
const { value, setDefaultValue, itemWidth, variant, name, direction, size, selection, setSelection, elActiveRef, elPrevActiveRef, elScrollableRef, disableSelectionAnimation, } = useTabs();
|
|
26
26
|
const [rtl] = useRTL();
|
|
27
27
|
const fadeSide = useFadeSide(elScrollableRef, { disabled: itemWidth === "equal" });
|
|
28
28
|
const rootClassNames = classNames(s.root, size && s[`--size-${size}`], direction && s[`--direction-${direction}`], itemWidth && s[`--item-width-${itemWidth}`], variant && s[`--variant-${variant}`], fadeSide && s["--scrollable"], (fadeSide === "start" || fadeSide === "both") && s["--fade-start"], (fadeSide === "end" || fadeSide === "both") && s["--fade-end"], className);
|
|
29
|
-
const selectorClassNames = classNames(s.selector, selection.status === "idle" && s["--
|
|
29
|
+
const selectorClassNames = classNames(s.selector, selection.status === "idle" && s["selector--hidden"], selection.status === "animated" && s["selector--animated"]);
|
|
30
30
|
const handleNextClick = () => {
|
|
31
31
|
elScrollableRef.current.scrollBy({
|
|
32
32
|
// Using ceil here since during the second navigation half of the value may be
|
|
@@ -79,8 +79,12 @@ const TabsList = (props) => {
|
|
|
79
79
|
const selectionStyle = getElementSelectionStyle(elPrevActiveRef.current);
|
|
80
80
|
if (!selectionStyle)
|
|
81
81
|
return;
|
|
82
|
+
if (disableSelectionAnimation) {
|
|
83
|
+
setSelection({ ...selectionStyle, status: "idle" });
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
82
86
|
setSelection({ ...selectionStyle, status: "prepared" });
|
|
83
|
-
}, [value, getElementSelectionStyle]);
|
|
87
|
+
}, [value, getElementSelectionStyle, disableSelectionAnimation]);
|
|
84
88
|
useIsomorphicLayoutEffect(() => {
|
|
85
89
|
if (selection.status !== "prepared" || !elActiveRef.current)
|
|
86
90
|
return;
|
|
@@ -94,12 +98,12 @@ const TabsList = (props) => {
|
|
|
94
98
|
return null;
|
|
95
99
|
const props = child.props;
|
|
96
100
|
return (_jsx("div", { className: s.listItem, "data-rs-tabs-item": true, children: child }, props.value || child.key || index));
|
|
97
|
-
}), _jsx("div", { onTransitionEnd: handleTransitionEnd, className: selectorClassNames, style: {
|
|
101
|
+
}), !disableSelectionAnimation && (_jsx("div", { onTransitionEnd: handleTransitionEnd, className: selectorClassNames, style: {
|
|
98
102
|
"--rs-tab-selection-x": selection.left,
|
|
99
103
|
"--rs-tab-selection-y": selection.top,
|
|
100
104
|
"--rs-tab-selection-scale-x": selection.scaleX,
|
|
101
105
|
"--rs-tab-selection-scale-y": selection.scaleY,
|
|
102
|
-
} })] }) }), _jsx(Actionable, { onClick: handlePrevClick, touchHitbox: true, attributes: { "aria-hidden": true, tabIndex: -1 }, className: [
|
|
106
|
+
} }))] }) }), _jsx(Actionable, { onClick: handlePrevClick, touchHitbox: true, attributes: { "aria-hidden": true, tabIndex: -1 }, className: [
|
|
103
107
|
s.control,
|
|
104
108
|
s["control--prev"],
|
|
105
109
|
(fadeSide === "start" || fadeSide === "both") && s["control--active"],
|
|
@@ -11,7 +11,7 @@ const TabsPanel = (props) => {
|
|
|
11
11
|
const [needsTabIndex, setNeedsTabIndex] = React.useState(true);
|
|
12
12
|
const rootRef = React.useRef(null);
|
|
13
13
|
const active = panelValue === value;
|
|
14
|
-
const panelClassNames = classNames(s.panel, !active && s["--
|
|
14
|
+
const panelClassNames = classNames(s.panel, !active && s["panel--hidden"], className);
|
|
15
15
|
React.useEffect(() => {
|
|
16
16
|
const el = rootRef.current;
|
|
17
17
|
if (!el)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as T from "./Text.types";
|
|
2
2
|
declare const Text: {
|
|
3
|
-
<As extends keyof React.JSX.IntrinsicElements>(props: T.Props<As>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
<As extends keyof React.JSX.IntrinsicElements = "div">(props: T.Props<As>): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
displayName: string;
|
|
5
5
|
};
|
|
6
6
|
export default Text;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
2
|
import type * as G from "../../types/global";
|
|
3
3
|
export type Variant = "title-1" | "title-2" | "title-3" | "title-4" | "title-5" | "title-6" | "featured-1" | "featured-2" | "featured-3" | "body-1" | "body-2" | "body-3" | "caption-1" | "caption-2";
|
|
4
|
-
export type Props<TagName extends keyof React.JSX.IntrinsicElements =
|
|
4
|
+
export type Props<TagName extends keyof React.JSX.IntrinsicElements | void = void> = {
|
|
5
5
|
/** Text render variant */
|
|
6
6
|
variant?: G.Responsive<Variant>;
|
|
7
7
|
/** Text font weight */
|
|
@@ -20,12 +20,12 @@ export type Props<TagName extends keyof React.JSX.IntrinsicElements = "div"> = {
|
|
|
20
20
|
maxLines?: number;
|
|
21
21
|
/** Render as a numeric value to preserve the width of each character */
|
|
22
22
|
numeric?: true;
|
|
23
|
-
/** Render as a different html tag */
|
|
24
|
-
as?: TagName;
|
|
25
23
|
/** Node for inserting children */
|
|
26
24
|
children?: React.ReactNode;
|
|
27
25
|
/** Additional classname for the root element */
|
|
28
26
|
className?: G.ClassName;
|
|
29
27
|
/** Additional attributes for the root element */
|
|
30
28
|
attributes?: G.Attributes<TagName>;
|
|
29
|
+
/** Render as a different html tag */
|
|
30
|
+
as?: TagName extends keyof React.JSX.IntrinsicElements ? TagName : keyof React.JSX.IntrinsicElements;
|
|
31
31
|
};
|
|
@@ -89,7 +89,6 @@ const ToastContainer = (props) => {
|
|
|
89
89
|
// Height + padding + borders
|
|
90
90
|
height: status === "entered" ? `calc(${toastHeight}px + var(--rs-unit-x2) + 2px)` : 0,
|
|
91
91
|
// Disable transition when height of the toast can change
|
|
92
|
-
// eslint-disable-next-line react-hooks/refs
|
|
93
92
|
transitionDuration: resizingRef.current ? "0s" : undefined,
|
|
94
93
|
}, onTransitionEnd: handleTransitionEnd, onFocus: stopTimer, onBlur: startTimer, children: _jsx("span", { className: s.wrapper, children: _jsx(Toast, { ...toastProps, collapsed: index > 0 && !inspected, attributes: { ...toastProps.attributes, ref: wrapperRef } }) }) }));
|
|
95
94
|
};
|
|
@@ -5,12 +5,12 @@ import Text from "../Text/index.js";
|
|
|
5
5
|
import Theme from "../Theme/index.js";
|
|
6
6
|
import s from "./Tooltip.module.css";
|
|
7
7
|
const Tooltip = (props) => {
|
|
8
|
-
const { text, children, position = "bottom", color = "inverted", ...flyoutProps } = props;
|
|
8
|
+
const { text, children, position = "bottom", color = "inverted", contentMaxWidth = "360px", ...flyoutProps } = props;
|
|
9
9
|
if (!text)
|
|
10
10
|
return children({ ref: null });
|
|
11
11
|
return (_jsxs(Flyout, { ...flyoutProps, position: position, triggerType: "hover",
|
|
12
12
|
// Disable group timeouts by default since it's not controlled by the default user events
|
|
13
|
-
groupTimeouts: flyoutProps.active === undefined ? true : false, children: [_jsx(Flyout.Trigger, { children: children }), _jsx(Flyout.Content, { children: _jsx(Theme, { colorMode: color, children: _jsx(Text, { variant: "caption-1", className: s.root, children: text }) }) })] }));
|
|
13
|
+
groupTimeouts: flyoutProps.active === undefined ? true : false, contentMaxWidth: contentMaxWidth, children: [_jsx(Flyout.Trigger, { children: children }), _jsx(Flyout.Content, { children: _jsx(Theme, { colorMode: color, children: _jsx(Text, { variant: "caption-1", className: s.root, children: text }) }) })] }));
|
|
14
14
|
};
|
|
15
15
|
Tooltip.displayName = "Tooltip";
|
|
16
16
|
export default Tooltip;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.root{background:var(--rs-color-background-elevation-overlay);border-radius:var(--rs-radius-small);box-shadow:var(--rs-shadow-overlay);color:var(--rs-color-foreground-neutral);
|
|
1
|
+
.root{background:var(--rs-color-background-elevation-overlay);border-radius:var(--rs-radius-small);box-shadow:var(--rs-shadow-overlay);color:var(--rs-color-foreground-neutral);padding:var(--rs-unit-x1) var(--rs-unit-x2)}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { FlyoutProps, FlyoutTriggerAttributes } from "../Flyout";
|
|
3
|
-
export type Props = Pick<FlyoutProps, "id" | "position" | "onOpen" | "onClose" | "active" | "disabled" | "disableContentHover" | "containerRef" | "positionRef" | "contentGap" | "contentShift" | "originCoordinates" | "contentAttributes" | "contentClassName"> & {
|
|
3
|
+
export type Props = Pick<FlyoutProps, "id" | "position" | "onOpen" | "onClose" | "active" | "disabled" | "disableContentHover" | "containerRef" | "positionRef" | "contentGap" | "contentShift" | "contentMaxWidth" | "originCoordinates" | "contentAttributes" | "contentClassName" | "instanceRef"> & {
|
|
4
4
|
/** Node for inserting children */
|
|
5
5
|
children: (attributes: FlyoutTriggerAttributes) => React.ReactNode;
|
|
6
6
|
/** Text content for the tooltip */
|
|
@@ -3,11 +3,11 @@ import type * as TStyles from "../../styles/types";
|
|
|
3
3
|
import type * as G from "../../types/global";
|
|
4
4
|
type Columns = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | "auto";
|
|
5
5
|
export type Direction = "row" | "column" | "row-reverse" | "column-reverse";
|
|
6
|
-
export type Props<TagName extends keyof React.JSX.IntrinsicElements =
|
|
6
|
+
export type Props<TagName extends keyof React.JSX.IntrinsicElements | void = void> = {
|
|
7
7
|
/** Node for inserting the content */
|
|
8
8
|
children?: React.ReactNode;
|
|
9
9
|
/** Render as a different element */
|
|
10
|
-
as?: TagName;
|
|
10
|
+
as?: TagName extends keyof React.JSX.IntrinsicElements ? TagName : keyof React.JSX.IntrinsicElements;
|
|
11
11
|
/** Render a divider between each child */
|
|
12
12
|
divided?: boolean;
|
|
13
13
|
/** Flex direction for the content */
|
|
@@ -97,7 +97,7 @@ export type Props<TagName extends keyof React.JSX.IntrinsicElements = "div"> = {
|
|
|
97
97
|
/** Additional attributes for the root element */
|
|
98
98
|
attributes?: G.Attributes<TagName>;
|
|
99
99
|
} & Pick<ItemProps, "grow" | "shrink">;
|
|
100
|
-
export type ItemProps<TagName extends keyof React.JSX.IntrinsicElements =
|
|
100
|
+
export type ItemProps<TagName extends keyof React.JSX.IntrinsicElements | void = void> = {
|
|
101
101
|
/** Flex order of the item inside the parent */
|
|
102
102
|
order?: G.Responsive<number>;
|
|
103
103
|
/** Number of columns the item should span in the parent, View uses 12 columns */
|
|
@@ -109,7 +109,7 @@ export type ItemProps<TagName extends keyof React.JSX.IntrinsicElements = "div">
|
|
|
109
109
|
/** Individual gap before the item, overrides the parent View gap */
|
|
110
110
|
gapBefore?: G.Responsive<number> | "auto";
|
|
111
111
|
/** Render as a different element */
|
|
112
|
-
as?: TagName;
|
|
112
|
+
as?: TagName extends keyof React.JSX.IntrinsicElements ? TagName : keyof React.JSX.IntrinsicElements;
|
|
113
113
|
/** Additional attributes for the root element */
|
|
114
114
|
attributes?: G.Attributes<TagName>;
|
|
115
115
|
/** Additional classname for the root element */
|
|
@@ -10,9 +10,7 @@ const Expandable = (props) => {
|
|
|
10
10
|
const rootRef = React.useRef(null);
|
|
11
11
|
const mountedRef = React.useRef(false);
|
|
12
12
|
const [animatedHeight, setAnimatedHeight] = React.useState(active ? "auto" : null);
|
|
13
|
-
const contentClassNames = classNames(s.root,
|
|
14
|
-
// eslint-disable-next-line react-hooks/refs
|
|
15
|
-
mountedRef.current && animatedHeight !== "auto" && s["--animated"]);
|
|
13
|
+
const contentClassNames = classNames(s.root, mountedRef.current && animatedHeight !== "auto" && s["--animated"]);
|
|
16
14
|
const handleTransitionEnd = (e) => {
|
|
17
15
|
if (e.propertyName !== "height")
|
|
18
16
|
return;
|
|
@@ -18,7 +18,6 @@ const Portal = (props) => {
|
|
|
18
18
|
const { children, targetRef } = props;
|
|
19
19
|
const mountedToggle = useToggle();
|
|
20
20
|
const rootRef = React.useRef(null);
|
|
21
|
-
// eslint-disable-next-line react-hooks/refs
|
|
22
21
|
const rootNode = rootRef.current?.getRootNode();
|
|
23
22
|
const isShadowDom = rootNode instanceof ShadowRoot;
|
|
24
23
|
const defaultTargetEl = isShadowDom ? rootNode : document.body;
|
|
@@ -31,7 +30,6 @@ const Portal = (props) => {
|
|
|
31
30
|
*/
|
|
32
31
|
const portal = usePortalScope();
|
|
33
32
|
const nextScopeRef = targetRef || portal.scopeRef;
|
|
34
|
-
// eslint-disable-next-line react-hooks/refs
|
|
35
33
|
const targetEl = nextScopeRef?.current || defaultTargetEl;
|
|
36
34
|
useIsomorphicLayoutEffect(() => {
|
|
37
35
|
mountedToggle.activate();
|
|
@@ -39,7 +37,6 @@ const Portal = (props) => {
|
|
|
39
37
|
}, []);
|
|
40
38
|
/* Preserve the current theme when rendered in body */
|
|
41
39
|
return [
|
|
42
|
-
// eslint-disable-next-line react-hooks/refs
|
|
43
40
|
ReactDOM.createPortal(_jsx(Theme, { children: children }), targetEl),
|
|
44
41
|
// Make sure this element doesn't affect components using :last-child when their children use portals
|
|
45
42
|
!mountedToggle.active && _jsx("div", { ref: rootRef, className: s.root }, "root"),
|