reshaped 3.0.2 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/bundle.css +1 -1
- package/dist/bundle.d.ts +3 -3
- package/dist/bundle.js +10 -10
- package/dist/components/Autocomplete/Autocomplete.js +2 -2
- package/dist/components/Autocomplete/Autocomplete.types.d.ts +2 -1
- package/dist/components/Carousel/Carousel.types.d.ts +2 -2
- package/dist/components/Carousel/index.d.ts +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +3 -2
- package/dist/components/DropdownMenu/index.d.ts +1 -1
- package/dist/components/Modal/Modal.js +9 -4
- package/dist/components/Popover/Popover.js +2 -2
- package/dist/components/Popover/Popover.types.d.ts +3 -2
- package/dist/components/Popover/index.d.ts +1 -1
- package/dist/components/Reshaped/Reshaped.css +1 -1
- package/dist/components/Slider/Slider.module.css +1 -1
- package/dist/components/Slider/Slider.types.d.ts +2 -0
- package/dist/components/Slider/Slider.utilities.d.ts +4 -0
- package/dist/components/Slider/Slider.utilities.js +10 -0
- package/dist/components/Slider/SliderControlled.js +31 -27
- package/dist/components/Slider/SliderThumb.js +2 -2
- package/dist/components/Slider/tests/Slider.stories.d.ts +1 -0
- package/dist/components/Slider/tests/Slider.stories.js +9 -0
- package/dist/components/Text/Text.js +1 -1
- package/dist/components/Text/Text.module.css +1 -1
- package/dist/components/Text/Text.types.d.ts +1 -1
- package/dist/components/Text/tests/Text.stories.js +3 -0
- package/dist/components/Tooltip/Tooltip.js +2 -2
- package/dist/components/Tooltip/Tooltip.types.d.ts +1 -1
- package/dist/components/Tooltip/tests/Tooltip.stories.js +25 -1
- package/dist/components/View/View.js +3 -1
- package/dist/components/View/View.module.css +1 -1
- package/dist/components/View/View.types.d.ts +1 -1
- package/dist/components/View/tests/View.stories.js +6 -0
- package/dist/components/_private/Flyout/Flyout.constants.d.ts +3 -0
- package/dist/components/_private/Flyout/Flyout.constants.js +3 -0
- package/dist/components/_private/Flyout/Flyout.module.css +1 -1
- package/dist/components/_private/Flyout/Flyout.types.d.ts +9 -3
- package/dist/components/_private/Flyout/FlyoutContent.js +7 -4
- package/dist/components/_private/Flyout/FlyoutControlled.js +33 -18
- package/dist/components/_private/Flyout/index.d.ts +1 -1
- package/dist/components/_private/Flyout/tests/Flyout.stories.d.ts +3 -0
- package/dist/components/_private/Flyout/tests/Flyout.stories.js +62 -0
- package/dist/components/_private/Flyout/useFlyout.d.ts +4 -1
- package/dist/components/_private/Flyout/useFlyout.js +21 -16
- package/dist/components/_private/Flyout/utilities/calculatePosition.d.ts +1 -0
- package/dist/components/_private/Flyout/utilities/calculatePosition.js +3 -3
- package/dist/components/_private/Flyout/utilities/cooldown.d.ts +8 -0
- package/dist/components/_private/Flyout/utilities/cooldown.js +18 -0
- package/dist/index.d.ts +3 -3
- package/dist/styles/border/border.module.css +1 -0
- package/dist/styles/border/index.d.ts +3 -0
- package/dist/styles/border/index.js +10 -0
- package/dist/styles/types.d.ts +1 -0
- package/dist/utilities/dom.d.ts +2 -0
- package/dist/utilities/dom.js +9 -0
- package/package.json +1 -1
- package/dist/constants/timeouts.d.ts +0 -2
- package/dist/constants/timeouts.js +0 -2
@@ -8,7 +8,7 @@ import { getActiveElement } from "../../utilities/a11y/focus.js";
|
|
8
8
|
import * as keys from "../../constants/keys.js";
|
9
9
|
const AutocompleteContext = React.createContext({});
|
10
10
|
const Autocomplete = (props) => {
|
11
|
-
const { children, onChange, onInput, onItemSelect, name, ...textFieldProps } = props;
|
11
|
+
const { children, onChange, onInput, onItemSelect, name, containerRef, ...textFieldProps } = props;
|
12
12
|
const inputRef = React.useRef(null);
|
13
13
|
const [active, setActive] = React.useState(false);
|
14
14
|
// Prevent dropdown from opening on selecting an item
|
@@ -46,7 +46,7 @@ const Autocomplete = (props) => {
|
|
46
46
|
onInput?.({ value: e.currentTarget.value, name, event: e });
|
47
47
|
textFieldProps.inputAttributes?.onInput?.(e);
|
48
48
|
};
|
49
|
-
return (_jsx(AutocompleteContext.Provider, { value: { onItemClick: handleItemClick }, children: _jsxs(DropdownMenu, { position: "bottom", width: "trigger", triggerType: "focus", trapFocusMode: "selection-menu", active: !locked && hasChildren && active, onClose: handleClose, onOpen: handleOpen, disableHideAnimation: true, children: [_jsx(DropdownMenu.Trigger, { children: ({ ref, ...attributes }) => (_jsx(TextField, { ...textFieldProps, name: name, onChange: handleChange,
|
49
|
+
return (_jsx(AutocompleteContext.Provider, { value: { onItemClick: handleItemClick }, children: _jsxs(DropdownMenu, { position: "bottom", width: "trigger", triggerType: "focus", trapFocusMode: "selection-menu", active: !locked && hasChildren && active, onClose: handleClose, onOpen: handleOpen, containerRef: containerRef, disableHideAnimation: true, children: [_jsx(DropdownMenu.Trigger, { children: ({ ref, ...attributes }) => (_jsx(TextField, { ...textFieldProps, name: name, onChange: handleChange,
|
50
50
|
// Ignoring the type check since TS can't infer the correct html element type
|
51
51
|
attributes: { ...textFieldProps.attributes, ref }, inputAttributes: {
|
52
52
|
...textFieldProps.inputAttributes,
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { TextFieldProps } from "../TextField";
|
2
2
|
import type { MenuItemProps } from "../MenuItem";
|
3
|
-
|
3
|
+
import type { DropdownMenuProps } from "../DropdownMenu";
|
4
|
+
export type Props = TextFieldProps & Pick<DropdownMenuProps, "containerRef"> & {
|
4
5
|
onInput?: TextFieldProps["onChange"];
|
5
6
|
onItemSelect?: (args: {
|
6
7
|
value: string;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type React from "react";
|
2
2
|
import type * as G from "../../types/global";
|
3
|
-
export type
|
3
|
+
export type Instance = {
|
4
4
|
navigateBack: () => void;
|
5
5
|
navigateForward: () => void;
|
6
6
|
} | undefined;
|
@@ -22,7 +22,7 @@ export type Props = {
|
|
22
22
|
gap?: G.Responsive<number>;
|
23
23
|
bleed?: G.Responsive<number>;
|
24
24
|
navigationDisplay?: "hidden";
|
25
|
-
instanceRef?: React.Ref<
|
25
|
+
instanceRef?: React.Ref<Instance>;
|
26
26
|
className?: G.ClassName;
|
27
27
|
attributes?: G.Attributes<"div">;
|
28
28
|
};
|
@@ -1,2 +1,2 @@
|
|
1
1
|
export { default } from "./Carousel";
|
2
|
-
export type { Props as CarouselProps,
|
2
|
+
export type { Props as CarouselProps, Instance as CarouselInstanceRef, Instance as CarouselInstance, } from "./Carousel.types";
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import type React from "react";
|
2
|
-
import type { PopoverProps } from "../Popover";
|
2
|
+
import type { PopoverProps, PopoverInstance } from "../Popover";
|
3
3
|
import type { FlyoutContentProps } from "../_private/Flyout";
|
4
|
-
export type
|
4
|
+
export type Instance = PopoverInstance;
|
5
|
+
export type Props = Pick<PopoverProps, "children" | "position" | "forcePosition" | "triggerType" | "contentGap" | "onOpen" | "onClose" | "active" | "defaultActive" | "width" | "disableHideAnimation" | "instanceRef" | "containerRef"> & {
|
5
6
|
trapFocusMode?: Extract<PopoverProps["trapFocusMode"], "action-menu" | "selection-menu">;
|
6
7
|
};
|
7
8
|
export type ContentProps = Pick<FlyoutContentProps, "attributes" | "children" | "className">;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
export { default } from "./DropdownMenu";
|
2
|
-
export type { Props as DropdownMenuProps } from "./DropdownMenu.types";
|
2
|
+
export type { Props as DropdownMenuProps, Instance as DropdownMenuInstance, } from "./DropdownMenu.types";
|
@@ -70,6 +70,9 @@ const Modal = (props) => {
|
|
70
70
|
const handleDragStart = (e) => {
|
71
71
|
if (disableSwipeGesture)
|
72
72
|
return;
|
73
|
+
// Prevent swipe to close from happening when user is working with text selection
|
74
|
+
if (window.getSelection()?.toString())
|
75
|
+
return;
|
73
76
|
let currentEl = e.target;
|
74
77
|
const rootEl = rootRef.current;
|
75
78
|
while (currentEl && (currentEl === rootEl || rootEl?.contains(currentEl))) {
|
@@ -116,6 +119,8 @@ const Modal = (props) => {
|
|
116
119
|
const handleDrag = (e) => {
|
117
120
|
if (!dragging || clientPosition === "center")
|
118
121
|
return;
|
122
|
+
if (rootRef.current?.scrollTop !== 0 || rootRef.current?.scrollLeft !== 0)
|
123
|
+
return;
|
119
124
|
const target = e.targetTouches[0];
|
120
125
|
const coordinate = { x: target.clientX, y: target.clientY };
|
121
126
|
const key = clientPosition === "bottom" ? "y" : "x";
|
@@ -126,11 +131,11 @@ const Modal = (props) => {
|
|
126
131
|
dragLastCoordinateRef.current = coordinate[key];
|
127
132
|
}
|
128
133
|
const next = Math.abs(coordinate[key] - dragStartCoordinatesRef.current[key]);
|
129
|
-
const
|
134
|
+
const nextPerpendicular = Math.abs(coordinate[oppositeKey] - dragStartCoordinatesRef.current[oppositeKey]);
|
130
135
|
// For start/end drawers - ignore the swiping
|
131
136
|
// If user is scrolling vertically more than swiping
|
132
137
|
if (position !== "bottom" &&
|
133
|
-
(next <
|
138
|
+
(next < nextPerpendicular || nextPerpendicular > DRAG_OPPOSITE_THRESHOLD)) {
|
134
139
|
dragLastCoordinateRef.current = coordinate[key];
|
135
140
|
return;
|
136
141
|
}
|
@@ -140,8 +145,8 @@ const Modal = (props) => {
|
|
140
145
|
? Math.min(0, prev + dragDirectionRef.current)
|
141
146
|
: Math.max(0, prev + dragDirectionRef.current));
|
142
147
|
};
|
143
|
-
document.addEventListener("touchmove", handleDrag);
|
144
|
-
document.addEventListener("touchend", handleDragEnd);
|
148
|
+
document.addEventListener("touchmove", handleDrag, { passive: true });
|
149
|
+
document.addEventListener("touchend", handleDragEnd, { passive: true });
|
145
150
|
return () => {
|
146
151
|
document.removeEventListener("touchmove", handleDrag);
|
147
152
|
document.removeEventListener("touchend", handleDragEnd);
|
@@ -4,14 +4,14 @@ import Flyout from "../_private/Flyout/index.js";
|
|
4
4
|
import s from "./Popover.module.css";
|
5
5
|
import getPaddingStyles from "../../styles/padding/index.js";
|
6
6
|
const Popover = (props) => {
|
7
|
-
const { id, forcePosition, onOpen, onClose, active, defaultActive, children, width, contentGap, variant = "elevated", triggerType = "click", position = "bottom", disableHideAnimation, instanceRef, } = props;
|
7
|
+
const { id, forcePosition, onOpen, onClose, active, defaultActive, children, width, contentGap, variant = "elevated", triggerType = "click", position = "bottom", disableHideAnimation, disableContentHover, instanceRef, containerRef, } = props;
|
8
8
|
const padding = props.padding ?? (variant === "headless" ? 0 : 4);
|
9
9
|
const trapFocusMode = props.trapFocusMode || (triggerType === "hover" ? "content-menu" : undefined);
|
10
10
|
const paddingStyles = getPaddingStyles(padding);
|
11
11
|
const contentClassName = classNames(s.content, !!width && s["content--has-width"], variant && s[`content--variant-${variant}`], paddingStyles?.classNames);
|
12
12
|
return (
|
13
13
|
// @ts-ignore
|
14
|
-
_jsx(Flyout, { id: id, instanceRef: instanceRef, position: position, forcePosition: forcePosition, onOpen: onOpen, onClose: onClose, trapFocusMode: trapFocusMode, triggerType: triggerType, active: active, defaultActive: defaultActive, width: width, disableHideAnimation: disableHideAnimation, contentGap: contentGap, contentClassName: contentClassName, contentAttributes: { style: { ...paddingStyles?.variables } }, children: children }));
|
14
|
+
_jsx(Flyout, { id: id, instanceRef: instanceRef, position: position, forcePosition: forcePosition, onOpen: onOpen, onClose: onClose, trapFocusMode: trapFocusMode, triggerType: triggerType, active: active, defaultActive: defaultActive, width: width, disableHideAnimation: disableHideAnimation, disableContentHover: disableContentHover, contentGap: contentGap, containerRef: containerRef, contentClassName: contentClassName, contentAttributes: { style: { ...paddingStyles?.variables } }, children: children }));
|
15
15
|
};
|
16
16
|
Popover.Trigger = Flyout.Trigger;
|
17
17
|
Popover.Content = Flyout.Content;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import type React from "react";
|
2
|
-
import type { FlyoutProps } from "../_private/Flyout";
|
3
|
-
export type
|
2
|
+
import type { FlyoutProps, FlyoutInstance } from "../_private/Flyout";
|
3
|
+
export type Instance = FlyoutInstance;
|
4
|
+
export type Props = Pick<FlyoutProps, "id" | "position" | "forcePosition" | "onOpen" | "onClose" | "width" | "trapFocusMode" | "active" | "defaultActive" | "contentGap" | "instanceRef" | "triggerType" | "disableHideAnimation" | "disableContentHover" | "containerRef"> & {
|
4
5
|
children?: React.ReactNode;
|
5
6
|
padding?: number;
|
6
7
|
variant?: "elevated" | "headless";
|
@@ -1,2 +1,2 @@
|
|
1
1
|
export { default } from "./Popover";
|
2
|
-
export type { Props as PopoverProps } from "./Popover.types";
|
2
|
+
export type { Props as PopoverProps, Instance as PopoverInstance } from "./Popover.types";
|
@@ -1 +1 @@
|
|
1
|
-
:root{--rs-z-index-raised:5;--rs-z-index-flyout:80;--rs-z-index-fixed:90;--rs-z-index-overlay:100;--rs-z-index-notification:110}blockquote,body,dd,dl,figcaption,figure,h1,h2,h3,h4,h5,h6,li,ol,p,ul{margin:0;padding:0}ol[class],ul[class]{list-style:none}textarea{resize:vertical}table{border-collapse:collapse;border-spacing:0}fieldset{border:0;margin:0;padding:0}img{display:block;max-width:100%}button,input,select,textarea{font:inherit}option{background:var(--rs-color-background-elevation-base)}label{cursor:pointer}input::placeholder,textarea::placeholder{color:var(--rs-color-foreground-neutral-faded);opacity:.5}html{-webkit-text-size-adjust:100%;-webkit-font-smoothing:antialiased;font-family:var(--rs-font-family-body);font-size:87.5%;font-weight:var(--rs-font-weight-regular);line-height:var(--rs-line-height-body-3);text-rendering:optimizelegibility;touch-action:manipulation}*{box-sizing:border-box}body,html{background:var(--rs-color-background-page);color:var(--rs-color-foreground-neutral);height:100%;scroll-behavior:smooth}[data-rs-theme]:not(html){font-family:var(--rs-font-family-body);font-size:var(--rs-font-size-body-3);font-weight:var(--rs-font-weight-regular);line-height:var(--rs-line-height-body-3)}[data-rs-color-mode=light]{color-scheme:light}[data-rs-color-mode=dark]{color-scheme:dark}@media (prefers-reduced-motion:reduce){*{animation-duration:.01ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important;transition-duration:.01ms!important}}[data-rs-no-transition] *,[data-rs-no-transition] :after,[data-rs-no-transition] :before{transition:none!important}
|
1
|
+
:root{--rs-z-index-raised:5;--rs-z-index-flyout:80;--rs-z-index-fixed:90;--rs-z-index-overlay:100;--rs-z-index-notification:110}@layer rs.reset{blockquote,body,dd,dl,figcaption,figure,h1,h2,h3,h4,h5,h6,li,ol,p,ul{margin:0;padding:0}ol[class],ul[class]{list-style:none}textarea{resize:vertical}table{border-collapse:collapse;border-spacing:0}fieldset{border:0;margin:0;padding:0}img{display:block;max-width:100%}button,input,select,textarea{font:inherit}option{background:var(--rs-color-background-elevation-base)}label{cursor:pointer}input::placeholder,textarea::placeholder{color:var(--rs-color-foreground-neutral-faded);opacity:.5}html{-webkit-text-size-adjust:100%;-webkit-font-smoothing:antialiased;font-family:var(--rs-font-family-body);font-size:87.5%;font-weight:var(--rs-font-weight-regular);line-height:var(--rs-line-height-body-3);text-rendering:optimizelegibility;touch-action:manipulation}*{box-sizing:border-box}body,html{background:var(--rs-color-background-page);color:var(--rs-color-foreground-neutral);height:100%;scroll-behavior:smooth}}[data-rs-theme]:not(html){font-family:var(--rs-font-family-body);font-size:var(--rs-font-size-body-3);font-weight:var(--rs-font-weight-regular);line-height:var(--rs-line-height-body-3)}[data-rs-color-mode=light]{color-scheme:light}[data-rs-color-mode=dark]{color-scheme:dark}@media (prefers-reduced-motion:reduce){*{animation-duration:.01ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important;transition-duration:.01ms!important}}[data-rs-no-transition] *,[data-rs-no-transition] :after,[data-rs-no-transition] :before{transition:none!important}
|
@@ -1 +1 @@
|
|
1
|
-
.root{--rs-slider-overflow-gap:var(--rs-unit-x1);--rs-slider-thumb-size:var(--rs-unit-x4);align-items:center;cursor:pointer;display:flex;
|
1
|
+
.root{--rs-slider-overflow-gap:var(--rs-unit-x1);--rs-slider-thumb-size:var(--rs-unit-x4);align-items:center;cursor:pointer;display:flex;position:relative;user-select:none;-webkit-tap-highlight-color:transparent}.root:has(.thumb:hover,.thumb--active,.input:focus){overflow:visible}.bar{background:var(--rs-color-background-neutral);border-radius:var(--rs-radius-small);position:relative}.bar,.input{overflow:hidden}.input{height:1px;opacity:0;pointer-events:none;position:absolute;width:1px}.selection{background:var(--rs-color-background-primary);position:absolute}.tooltip{--rs-slider-tooltip-translate:calc(-50% + var(--rs-slider-tooltip-offset, 0px));background:var(--rs-color-background-elevation-overlay);border-radius:var(--rs-radius-small);box-shadow:var(--rs-shadow-overlay);box-sizing:initial;color:var(--rs-color-foreground-neutral);font-variant-numeric:tabular-nums;min-width:var(--rs-line-height-caption-1);opacity:0;padding:calc(var(--rs-unit-x1) / 2) var(--rs-unit-x1);pointer-events:none;text-align:center;transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:opacity,transform;user-select:none;white-space:nowrap;will-change:transform}.thumb,.thumbs,.tooltip{position:absolute}.thumb:before{background:var(--rs-color-background-primary);border-radius:999px;box-shadow:0 0 0 2px var(--rs-color-background-elevation-base);box-sizing:border-box;height:var(--rs-slider-thumb-size);transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:box-shadow;width:var(--rs-slider-thumb-size)}.thumb:after,.thumb:before{content:"";position:absolute}.thumb:after{cursor:grab;height:var(--rs-unit-x7);width:var(--rs-unit-x7)}.thumb:hover .tooltip{opacity:1}.input:focus+.thumb:after,.thumb--active:after{cursor:grabbing}.input:focus+.thumb:before,.thumb--active:before{box-shadow:0 0 0 1px var(--rs-color-background-elevation-base)}.input:focus+.thumb .tooltip,.thumb--active .tooltip{opacity:1}.input:focus+.thumb:before{box-shadow:var(--rs-focus-shadow)}.--orientation-horizontal{height:var(--rs-slider-thumb-size);margin-inline:calc(var(--rs-slider-overflow-gap) * -1);overflow-x:clip;padding-inline:var(--rs-slider-overflow-gap)}.--orientation-horizontal .bar{height:var(--rs-unit-x1);width:100%}.--orientation-horizontal .selection{height:100%;inset-inline-start:var(--rs-slider-selection-start);width:var(--rs-slider-selection-size)}.--orientation-horizontal .tooltip{bottom:100%;left:50%;transform:translate(var(--rs-slider-tooltip-translate))}.--orientation-horizontal .thumbs{height:100%;inset-inline:calc(var(--rs-slider-thumb-size) / 2 + var(--rs-slider-overflow-gap))}.--orientation-horizontal .thumb{height:100%;inset-inline-start:var(--ts-slider-thumb-position);width:0}.--orientation-horizontal .thumb:after,.--orientation-horizontal .thumb:before{left:0;top:50%;transform:translate(-50%,-50%)}.--orientation-horizontal .input:focus+.thumb .tooltip,.--orientation-horizontal .thumb--active .tooltip,.--orientation-horizontal .thumb:hover .tooltip{transform:translate(var(--rs-slider-tooltip-translate),calc(var(--rs-unit-x1) * -1.5))}.--orientation-vertical{flex-direction:column;height:100%;margin-block:calc(var(--rs-slider-overflow-gap) * -1);overflow-y:clip;padding-block:var(--rs-slider-overflow-gap);width:var(--rs-slider-thumb-size)}.--orientation-vertical .bar{height:100%;width:var(--rs-unit-x1)}.--orientation-vertical .selection{height:var(--rs-slider-selection-size);inset-block-end:var(--rs-slider-selection-start);inset-inline-start:auto;width:100%}.--orientation-vertical .tooltip{inset-inline-start:100%;top:50%;transform:translateY(var(--rs-slider-tooltip-translate))}.--orientation-vertical .thumbs{inset-block:calc(var(--rs-slider-thumb-size) / 2 + var(--rs-slider-overflow-gap));width:100%}.--orientation-vertical .thumb{height:0;inset-block-end:var(--ts-slider-thumb-position);width:100%}.--orientation-vertical .thumb:after,.--orientation-vertical .thumb:before{left:50%;top:0;transform:translate(-50%,-50%)}.--orientation-vertical .input:focus+.thumb .tooltip,.--orientation-vertical .thumb--active .tooltip,.--orientation-vertical .thumb:hover .tooltip{transform:translate(calc(var(--rs-unit-x1) * 1.5),-50%)}.--disabled{cursor:not-allowed}.--disabled .bar{background-color:var(--rs-color-background-disabled)}.--disabled .selection,.--disabled .thumb:before{background-color:var(--rs-color-foreground-disabled)}.--disabled .thumb:after{cursor:not-allowed}.--disabled .thumb:hover .tooltip{opacity:0}
|
@@ -47,6 +47,7 @@ type BaseProps = {
|
|
47
47
|
disabled?: boolean;
|
48
48
|
min?: number;
|
49
49
|
max?: number;
|
50
|
+
orientation?: "vertical" | "horizontal";
|
50
51
|
renderValue?: (args: {
|
51
52
|
value: number;
|
52
53
|
}) => string;
|
@@ -74,6 +75,7 @@ export type ThumbProps = {
|
|
74
75
|
max: number;
|
75
76
|
min: number;
|
76
77
|
step: NonNullable<BaseProps["step"]>;
|
78
|
+
orientation: NonNullable<BaseProps["orientation"]>;
|
77
79
|
renderValue?: BaseProps["renderValue"];
|
78
80
|
tooltipRef: React.RefObject<HTMLDivElement>;
|
79
81
|
};
|
@@ -1,2 +1,6 @@
|
|
1
1
|
export declare const getPrecision: (value: number) => number;
|
2
2
|
export declare const applyStepToValue: (value: number, step: number) => number;
|
3
|
+
export declare const getDragCoord: ({ event, vertical, }: {
|
4
|
+
event: MouseEvent | TouchEvent;
|
5
|
+
vertical?: boolean;
|
6
|
+
}) => number;
|
@@ -12,3 +12,13 @@ export const applyStepToValue = (value, step) => {
|
|
12
12
|
}
|
13
13
|
return result;
|
14
14
|
};
|
15
|
+
export const getDragCoord = ({ event, vertical, }) => {
|
16
|
+
if (vertical) {
|
17
|
+
if (event instanceof MouseEvent)
|
18
|
+
return event.pageY || event.screenY;
|
19
|
+
return event.changedTouches[0].pageY;
|
20
|
+
}
|
21
|
+
if (event instanceof MouseEvent)
|
22
|
+
return event.pageX || event.screenX;
|
23
|
+
return event.changedTouches[0].pageX;
|
24
|
+
};
|
@@ -2,21 +2,17 @@
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
3
3
|
import React from "react";
|
4
4
|
import { classNames } from "../../utilities/helpers.js";
|
5
|
-
import { enableUserSelect, disableUserSelect } from "../../utilities/dom.js";
|
5
|
+
import { enableUserSelect, disableUserSelect, enableScroll, disableScroll } from "../../utilities/dom.js";
|
6
6
|
import useRTL from "../../hooks/useRTL.js";
|
7
7
|
import useElementId from "../../hooks/useElementId.js";
|
8
8
|
import { useFormControl } from "../FormControl/index.js";
|
9
9
|
import SliderThumb from "./SliderThumb.js";
|
10
|
-
import { applyStepToValue } from "./Slider.utilities.js";
|
10
|
+
import { applyStepToValue, getDragCoord } from "./Slider.utilities.js";
|
11
11
|
import s from "./Slider.module.css";
|
12
12
|
const THUMB_SIZE = 16;
|
13
|
-
const getDragX = (event) => {
|
14
|
-
if (event instanceof MouseEvent)
|
15
|
-
return event.pageX || event.screenX;
|
16
|
-
return event.changedTouches[0].pageX;
|
17
|
-
};
|
18
13
|
const SliderControlled = (props) => {
|
19
|
-
const { name, range, max, min, step = 1, onChange, onChangeCommit, renderValue, className, attributes, } = props;
|
14
|
+
const { name, range, max, min, step = 1, onChange, onChangeCommit, renderValue, className, attributes, orientation = "horizontal", } = props;
|
15
|
+
const vertical = orientation === "vertical";
|
20
16
|
const minValue = range && props.minValue !== undefined ? applyStepToValue(props.minValue, step) : undefined;
|
21
17
|
const maxValue = applyStepToValue(range ? props.maxValue : props.value, step);
|
22
18
|
const barRef = React.useRef(null);
|
@@ -32,27 +28,31 @@ const SliderControlled = (props) => {
|
|
32
28
|
const minId = `${inputId}-min`;
|
33
29
|
const maxId = `${inputId}-max`;
|
34
30
|
const disabled = formControl?.disabled || props.disabled;
|
35
|
-
const rootClassNames = classNames(s.root, disabled && s["--disabled"], className);
|
36
|
-
const getPositionValue = React.useCallback((
|
37
|
-
|
31
|
+
const rootClassNames = classNames(s.root, disabled && s["--disabled"], orientation && s[`--orientation-${orientation}`], className);
|
32
|
+
const getPositionValue = React.useCallback((dragCoord) => {
|
33
|
+
const barEl = barRef.current;
|
34
|
+
if (!barEl)
|
38
35
|
return;
|
39
|
-
const
|
36
|
+
const barSize = vertical ? barEl.clientHeight : barEl.clientWidth;
|
37
|
+
const barRect = barEl.getBoundingClientRect();
|
40
38
|
// Move by half thumb size since it's a reserved space
|
41
|
-
const
|
42
|
-
const
|
43
|
-
const thumbsAreaWidth =
|
44
|
-
let percentage =
|
45
|
-
if (rtl)
|
39
|
+
const barCoord = barRect[vertical ? "top" : "left"] + THUMB_SIZE / 2;
|
40
|
+
const position = dragCoord - barCoord;
|
41
|
+
const thumbsAreaWidth = barSize - THUMB_SIZE;
|
42
|
+
let percentage = position / thumbsAreaWidth;
|
43
|
+
if (rtl || vertical)
|
46
44
|
percentage = 1 - percentage;
|
47
45
|
let value = (max - min) * percentage + min;
|
48
46
|
value = Math.max(min, Math.min(max, value));
|
49
47
|
return applyStepToValue(value, step);
|
50
|
-
}, [max, min, rtl, step]);
|
48
|
+
}, [max, min, rtl, step, vertical]);
|
51
49
|
const getPercentPosition = (value) => {
|
52
50
|
const ratio = (value - min) / (max - min);
|
53
51
|
return ratio * 100;
|
54
52
|
};
|
55
53
|
const positionTooltip = React.useCallback((draggingId) => {
|
54
|
+
if (vertical)
|
55
|
+
return;
|
56
56
|
const draggingRef = draggingId === minId ? minTooltipRef : maxTooltipRef;
|
57
57
|
const thumbRef = draggingId === minId ? minRef : maxRef;
|
58
58
|
let nextTooltipOffset = 0;
|
@@ -75,7 +75,7 @@ const SliderControlled = (props) => {
|
|
75
75
|
if (tooltipEl) {
|
76
76
|
tooltipEl.style.setProperty("--rs-slider-tooltip-offset", `${nextTooltipOffset || 0}px`);
|
77
77
|
}
|
78
|
-
}, [minId]);
|
78
|
+
}, [minId, vertical]);
|
79
79
|
const handleMinChange = React.useCallback((value, options) => {
|
80
80
|
if (!range)
|
81
81
|
return;
|
@@ -100,8 +100,8 @@ const SliderControlled = (props) => {
|
|
100
100
|
return;
|
101
101
|
let minDistance;
|
102
102
|
let closestId;
|
103
|
-
const
|
104
|
-
const nextValue = getPositionValue(
|
103
|
+
const dragCoord = getDragCoord({ event: nativeEvent, vertical });
|
104
|
+
const nextValue = getPositionValue(dragCoord);
|
105
105
|
const thumbs = [
|
106
106
|
{ ref: minRef, id: minId },
|
107
107
|
{ ref: maxRef, id: maxId },
|
@@ -110,7 +110,8 @@ const SliderControlled = (props) => {
|
|
110
110
|
if (!item.ref.current)
|
111
111
|
return;
|
112
112
|
const el = item.ref.current;
|
113
|
-
const
|
113
|
+
const elRect = el.getBoundingClientRect();
|
114
|
+
const distance = Math.abs((vertical ? elRect.top : elRect.left) - dragCoord);
|
114
115
|
if (minDistance === undefined || distance <= minDistance) {
|
115
116
|
minDistance = distance;
|
116
117
|
closestId = item.id;
|
@@ -123,6 +124,7 @@ const SliderControlled = (props) => {
|
|
123
124
|
if (closestId === maxId)
|
124
125
|
handleMaxChange(nextValue);
|
125
126
|
disableUserSelect();
|
127
|
+
disableScroll();
|
126
128
|
setDraggingId(closestId);
|
127
129
|
};
|
128
130
|
const handleMinDragStart = () => {
|
@@ -143,13 +145,14 @@ const SliderControlled = (props) => {
|
|
143
145
|
handleMaxChange(maxValue, { commit: true });
|
144
146
|
}
|
145
147
|
enableUserSelect();
|
148
|
+
enableScroll();
|
146
149
|
setDraggingId(null);
|
147
150
|
}, [minValue, maxValue, handleMinChange, handleMaxChange, draggingId, minId, maxId]);
|
148
151
|
const handleDrag = React.useCallback((e) => {
|
149
152
|
if (!draggingId)
|
150
153
|
return;
|
151
|
-
const
|
152
|
-
const nextValue = getPositionValue(
|
154
|
+
const coord = getDragCoord({ event: e, vertical });
|
155
|
+
const nextValue = getPositionValue(coord);
|
153
156
|
if (nextValue === undefined)
|
154
157
|
return;
|
155
158
|
// Switch to another id if thumbs overlap
|
@@ -173,6 +176,7 @@ const SliderControlled = (props) => {
|
|
173
176
|
handleMinChange,
|
174
177
|
maxId,
|
175
178
|
minId,
|
179
|
+
vertical,
|
176
180
|
]);
|
177
181
|
React.useEffect(() => {
|
178
182
|
positionTooltip(minId);
|
@@ -196,8 +200,8 @@ const SliderControlled = (props) => {
|
|
196
200
|
// mouse/touch events only needed for non-keyboard use
|
197
201
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
198
202
|
_jsxs("div", { ...attributes, className: rootClassNames, onMouseDown: handleMouseDown, onTouchStart: handleMouseDown, children: [_jsx("div", { className: s.bar, ref: barRef, children: _jsx("div", { className: s.selection, style: {
|
199
|
-
|
200
|
-
|
201
|
-
} }) }), _jsxs("div", { className: s.thumbs, children: [minValue !== undefined && minPercentPosition !== undefined && (_jsx(SliderThumb, { id: minId, active: minId === draggingId, name: name, disabled: disabled, onChange: handleMinChange, value: minValue, onDragStart: handleMinDragStart, position: minPercentPosition, max: max, min: min, ref: minRef, tooltipRef: minTooltipRef, renderValue: renderValue, step: step })), _jsx(SliderThumb, { id: maxId, active: maxId === draggingId, name: name, disabled: disabled, onChange: handleMaxChange, value: maxValue, onDragStart: handleMaxDragStart, position: maxPercentPosition, max: max, min: min, ref: maxRef, tooltipRef: maxTooltipRef, renderValue: renderValue, step: step })] })] }));
|
203
|
+
"--rs-slider-selection-start": `${minPercentPosition || 0}%`,
|
204
|
+
"--rs-slider-selection-size": `${maxPercentPosition - (minPercentPosition || 0)}%`,
|
205
|
+
} }) }), _jsxs("div", { className: s.thumbs, children: [minValue !== undefined && minPercentPosition !== undefined && (_jsx(SliderThumb, { id: minId, active: minId === draggingId, name: name, disabled: disabled, onChange: handleMinChange, value: minValue, onDragStart: handleMinDragStart, position: minPercentPosition, max: max, min: min, ref: minRef, tooltipRef: minTooltipRef, renderValue: renderValue, step: step, orientation: orientation })), _jsx(SliderThumb, { id: maxId, active: maxId === draggingId, name: name, disabled: disabled, onChange: handleMaxChange, value: maxValue, onDragStart: handleMaxDragStart, position: maxPercentPosition, max: max, min: min, ref: maxRef, tooltipRef: maxTooltipRef, renderValue: renderValue, step: step, orientation: orientation })] })] }));
|
202
206
|
};
|
203
207
|
export default SliderControlled;
|
@@ -7,7 +7,7 @@ import Text from "../Text/index.js";
|
|
7
7
|
import { getPrecision } from "./Slider.utilities.js";
|
8
8
|
import s from "./Slider.module.css";
|
9
9
|
const SliderThumb = (props, ref) => {
|
10
|
-
const { name, value, disabled, active, position, max, min, step, onChange, onDragStart, renderValue, tooltipRef, } = props;
|
10
|
+
const { name, value, disabled, active, position, max, min, step, onChange, onDragStart, renderValue, tooltipRef, orientation, } = props;
|
11
11
|
const id = React.useId();
|
12
12
|
const thumbClassNames = classNames(s.thumb, active && s["thumb--active"]);
|
13
13
|
const precision = getPrecision(step);
|
@@ -15,6 +15,6 @@ const SliderThumb = (props, ref) => {
|
|
15
15
|
const handleChange = (e) => {
|
16
16
|
onChange(+e.target.value);
|
17
17
|
};
|
18
|
-
return (_jsxs(_Fragment, { children: [_jsx("input", { className: s.input, type: "range", name: name, value: value, onChange: handleChange, disabled: disabled, max: max, min: min, step: step, "aria-labelledby": id }), _jsx("div", { ref: ref, className: thumbClassNames, onMouseDown: onDragStart, onTouchStart: onDragStart, style: {
|
18
|
+
return (_jsxs(_Fragment, { children: [_jsx("input", { className: s.input, type: "range", name: name, value: value, onChange: handleChange, disabled: disabled, max: max, min: min, step: step, "aria-labelledby": id, "aria-orientation": orientation }), _jsx("div", { ref: ref, className: thumbClassNames, onMouseDown: onDragStart, onTouchStart: onDragStart, style: { "--ts-slider-thumb-position": `${position}%` }, id: id, "aria-hidden": "true", children: _jsx(Theme, { colorMode: "inverted", children: _jsx(Text, { variant: "caption-1", weight: "medium", className: s.tooltip, attributes: { ref: tooltipRef }, children: tooltipValue }) }) })] }));
|
19
19
|
};
|
20
20
|
export default React.forwardRef(SliderThumb);
|
@@ -9,6 +9,7 @@ declare const _default: {
|
|
9
9
|
};
|
10
10
|
export default _default;
|
11
11
|
export declare const base: () => import("react").JSX.Element;
|
12
|
+
export declare const direction: () => import("react").JSX.Element;
|
12
13
|
export declare const step: () => import("react").JSX.Element;
|
13
14
|
export declare const boundaries: () => import("react").JSX.Element;
|
14
15
|
export declare const status: () => import("react").JSX.Element;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Example } from "../../../utilities/storybook/index.js";
|
2
2
|
import Slider from "../index.js";
|
3
|
+
import View from "../../View/index.js";
|
3
4
|
import FormControl from "../../FormControl/index.js";
|
4
5
|
export default {
|
5
6
|
title: "Components/Slider",
|
@@ -14,6 +15,14 @@ export const base = () => (<Example>
|
|
14
15
|
<Example.Item title="range">
|
15
16
|
<Slider range name="slider" defaultMinValue={30} defaultMaxValue={100} renderValue={() => "Hundred more times"}/>
|
16
17
|
</Example.Item>
|
18
|
+
<div style={{ height: 2000 }}/>
|
19
|
+
</Example>);
|
20
|
+
export const direction = () => (<Example>
|
21
|
+
<Example.Item title="vertical">
|
22
|
+
<View height="200px">
|
23
|
+
<Slider range name="slider" defaultMinValue={30} defaultMaxValue={100} orientation="vertical"/>
|
24
|
+
</View>
|
25
|
+
</Example.Item>
|
17
26
|
</Example>);
|
18
27
|
export const step = () => (<Example>
|
19
28
|
<Example.Item title="float step">
|
@@ -17,7 +17,7 @@ const Text = (props) => {
|
|
17
17
|
* It still resolves the attributes correctly based on the tag
|
18
18
|
*/
|
19
19
|
const TagName = props.as || (largestVariant && tagMap[largestVariant]) || "div";
|
20
|
-
const rootClassName = classNames(s.root, color && s[`--color-${color}`], ...responsiveClassNames(s, "--variant", variant), ...responsiveClassNames(s, "--align", align), weight
|
20
|
+
const rootClassName = classNames(s.root, color && s[`--color-${color}`], ...responsiveClassNames(s, "--variant", variant), ...responsiveClassNames(s, "--align", align), ...responsiveClassNames(s, "--weight", weight), decoration && s[`--decoration-${decoration}`], maxLines !== undefined && s[`--clamp`], maxLines === 1 && s["--break-all"], wrap && s[`--wrap-${wrap}`], className);
|
21
21
|
const style = {
|
22
22
|
...attributes?.style,
|
23
23
|
"--rs-text-lines": maxLines,
|
@@ -1 +1 @@
|
|
1
|
-
.root{transition:color var(--rs-duration-fast) var(--rs-easing-standard)}.--clamp{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:var(--rs-text-lines);overflow:hidden}.--break-all{word-break:break-all}.--wrap-balance{text-wrap:balance}.--align-start{text-align:start}.--align-center{text-align:center}.--align-end{text-align:end}.--variant-title-1{font-family:var(--rs-font-family-title-1);font-size:var(--rs-font-size-title-1);font-weight:var(--rs-font-weight-title-1);line-height:var(--rs-line-height-title-1)}.--variant-title-2{font-family:var(--rs-font-family-title-2);font-size:var(--rs-font-size-title-2);font-weight:var(--rs-font-weight-title-2);line-height:var(--rs-line-height-title-2)}.--variant-title-3{font-family:var(--rs-font-family-title-3);font-size:var(--rs-font-size-title-3);font-weight:var(--rs-font-weight-title-3);line-height:var(--rs-line-height-title-3)}.--variant-title-4{font-family:var(--rs-font-family-title-4);font-size:var(--rs-font-size-title-4);font-weight:var(--rs-font-weight-title-4);line-height:var(--rs-line-height-title-4)}.--variant-title-5{font-family:var(--rs-font-family-title-5);font-size:var(--rs-font-size-title-5);font-weight:var(--rs-font-weight-title-5);line-height:var(--rs-line-height-title-5)}.--variant-title-6{font-family:var(--rs-font-family-title-6);font-size:var(--rs-font-size-title-6);font-weight:var(--rs-font-weight-title-6);line-height:var(--rs-line-height-title-6)}.--variant-featured-1{font-family:var(--rs-font-family-featured-1);font-size:var(--rs-font-size-featured-1);font-weight:var(--rs-font-weight-featured-1);line-height:var(--rs-line-height-featured-1)}.--variant-featured-2{font-family:var(--rs-font-family-featured-2);font-size:var(--rs-font-size-featured-2);font-weight:var(--rs-font-weight-featured-2);line-height:var(--rs-line-height-featured-2)}.--variant-featured-3{font-family:var(--rs-font-family-featured-3);font-size:var(--rs-font-size-featured-3);font-weight:var(--rs-font-weight-featured-3);line-height:var(--rs-line-height-featured-3)}.--variant-body-1{font-family:var(--rs-font-family-body-1);font-size:var(--rs-font-size-body-1);font-weight:var(--rs-font-weight-body-1);line-height:var(--rs-line-height-body-1)}.--variant-body-2{font-family:var(--rs-font-family-body-2);font-size:var(--rs-font-size-body-2);font-weight:var(--rs-font-weight-body-2);line-height:var(--rs-line-height-body-2)}.--variant-body-3{font-family:var(--rs-font-family-body-3);font-size:var(--rs-font-size-body-3);font-weight:var(--rs-font-weight-body-3);line-height:var(--rs-line-height-body-3)}.--variant-caption-1{font-family:var(--rs-font-family-caption-1);font-size:var(--rs-font-size-caption-1);font-weight:var(--rs-font-weight-caption-1);line-height:var(--rs-line-height-caption-1)}.--variant-caption-2{font-family:var(--rs-font-family-caption-2);font-size:var(--rs-font-size-caption-2);font-weight:var(--rs-font-weight-caption-2);line-height:var(--rs-line-height-caption-2)}.--weight-regular{font-weight:var(--rs-font-weight-regular)!important}.--weight-medium{font-weight:var(--rs-font-weight-medium)!important}.--weight-bold{font-weight:var(--rs-font-weight-bold)!important}.--color-neutral{color:var(--rs-color-foreground-neutral)}.--color-neutral-faded{color:var(--rs-color-foreground-neutral-faded)}.--color-primary{color:var(--rs-color-foreground-primary)}.--color-warning{color:var(--rs-color-foreground-warning)}.--color-positive{color:var(--rs-color-foreground-positive)}.--color-critical{color:var(--rs-color-foreground-critical)}.--color-disabled{color:var(--rs-color-foreground-disabled)}.--decoration-line-through{text-decoration:line-through}@media (--rs-viewport-m ){.--align-start--m{text-align:start}.--align-center--m{text-align:center}.--align-end--m{text-align:end}.--variant-title-1--m{font-family:var(--rs-font-family-title-1);font-size:var(--rs-font-size-title-1);font-weight:var(--rs-font-weight-title-1);line-height:var(--rs-line-height-title-1)}.--variant-title-2--m{font-family:var(--rs-font-family-title-2);font-size:var(--rs-font-size-title-2);font-weight:var(--rs-font-weight-title-2);line-height:var(--rs-line-height-title-2)}.--variant-title-3--m{font-family:var(--rs-font-family-title-3);font-size:var(--rs-font-size-title-3);font-weight:var(--rs-font-weight-title-3);line-height:var(--rs-line-height-title-3)}.--variant-title-4--m{font-family:var(--rs-font-family-title-4);font-size:var(--rs-font-size-title-4);font-weight:var(--rs-font-weight-title-4);line-height:var(--rs-line-height-title-4)}.--variant-title-5--m{font-family:var(--rs-font-family-title-5);font-size:var(--rs-font-size-title-5);font-weight:var(--rs-font-weight-title-5);line-height:var(--rs-line-height-title-5)}.--variant-title-6--m{font-family:var(--rs-font-family-title-6);font-size:var(--rs-font-size-title-6);font-weight:var(--rs-font-weight-title-6);line-height:var(--rs-line-height-title-6)}.--variant-featured-1--m{font-family:var(--rs-font-family-featured-1);font-size:var(--rs-font-size-featured-1);font-weight:var(--rs-font-weight-featured-1);line-height:var(--rs-line-height-featured-1)}.--variant-featured-2--m{font-family:var(--rs-font-family-featured-2);font-size:var(--rs-font-size-featured-2);font-weight:var(--rs-font-weight-featured-2);line-height:var(--rs-line-height-featured-2)}.--variant-featured-3--m{font-family:var(--rs-font-family-featured-3);font-size:var(--rs-font-size-featured-3);font-weight:var(--rs-font-weight-featured-3);line-height:var(--rs-line-height-featured-3)}.--variant-body-1--m{font-family:var(--rs-font-family-body-1);font-size:var(--rs-font-size-body-1);font-weight:var(--rs-font-weight-body-1);line-height:var(--rs-line-height-body-1)}.--variant-body-2--m{font-family:var(--rs-font-family-body-2);font-size:var(--rs-font-size-body-2);font-weight:var(--rs-font-weight-body-2);line-height:var(--rs-line-height-body-2)}.--variant-body-3--m{font-family:var(--rs-font-family-body-3);font-size:var(--rs-font-size-body-3);font-weight:var(--rs-font-weight-body-3);line-height:var(--rs-line-height-body-3)}.--variant-caption-1--m{font-family:var(--rs-font-family-caption-1);font-size:var(--rs-font-size-caption-1);font-weight:var(--rs-font-weight-caption-1);line-height:var(--rs-line-height-caption-1)}.--variant-caption-2--m{font-family:var(--rs-font-family-caption-2);font-size:var(--rs-font-size-caption-2);font-weight:var(--rs-font-weight-caption-2);line-height:var(--rs-line-height-caption-2)}}@media (--rs-viewport-l ){.--align-start--l{text-align:start}.--align-center--l{text-align:center}.--align-end--l{text-align:end}.--variant-title-1--l{font-family:var(--rs-font-family-title-1);font-size:var(--rs-font-size-title-1);font-weight:var(--rs-font-weight-title-1);line-height:var(--rs-line-height-title-1)}.--variant-title-2--l{font-family:var(--rs-font-family-title-2);font-size:var(--rs-font-size-title-2);font-weight:var(--rs-font-weight-title-2);line-height:var(--rs-line-height-title-2)}.--variant-title-3--l{font-family:var(--rs-font-family-title-3);font-size:var(--rs-font-size-title-3);font-weight:var(--rs-font-weight-title-3);line-height:var(--rs-line-height-title-3)}.--variant-title-4--l{font-family:var(--rs-font-family-title-4);font-size:var(--rs-font-size-title-4);font-weight:var(--rs-font-weight-title-4);line-height:var(--rs-line-height-title-4)}.--variant-title-5--l{font-family:var(--rs-font-family-title-5);font-size:var(--rs-font-size-title-5);font-weight:var(--rs-font-weight-title-5);line-height:var(--rs-line-height-title-5)}.--variant-title-6--l{font-family:var(--rs-font-family-title-6);font-size:var(--rs-font-size-title-6);font-weight:var(--rs-font-weight-title-6);line-height:var(--rs-line-height-title-6)}.--variant-featured-1--l{font-family:var(--rs-font-family-featured-1);font-size:var(--rs-font-size-featured-1);font-weight:var(--rs-font-weight-featured-1);line-height:var(--rs-line-height-featured-1)}.--variant-featured-2--l{font-family:var(--rs-font-family-featured-2);font-size:var(--rs-font-size-featured-2);font-weight:var(--rs-font-weight-featured-2);line-height:var(--rs-line-height-featured-2)}.--variant-featured-3--l{font-family:var(--rs-font-family-featured-3);font-size:var(--rs-font-size-featured-3);font-weight:var(--rs-font-weight-featured-3);line-height:var(--rs-line-height-featured-3)}.--variant-body-1--l{font-family:var(--rs-font-family-body-1);font-size:var(--rs-font-size-body-1);font-weight:var(--rs-font-weight-body-1);line-height:var(--rs-line-height-body-1)}.--variant-body-2--l{font-family:var(--rs-font-family-body-2);font-size:var(--rs-font-size-body-2);font-weight:var(--rs-font-weight-body-2);line-height:var(--rs-line-height-body-2)}.--variant-body-3--l{font-family:var(--rs-font-family-body-3);font-size:var(--rs-font-size-body-3);font-weight:var(--rs-font-weight-body-3);line-height:var(--rs-line-height-body-3)}.--variant-caption-1--l{font-family:var(--rs-font-family-caption-1);font-size:var(--rs-font-size-caption-1);font-weight:var(--rs-font-weight-caption-1);line-height:var(--rs-line-height-caption-1)}.--variant-caption-2--l{font-family:var(--rs-font-family-caption-2);font-size:var(--rs-font-size-caption-2);font-weight:var(--rs-font-weight-caption-2);line-height:var(--rs-line-height-caption-2)}}@media (--rs-viewport-xl ){.--align-start--xl{text-align:start}.--align-center--xl{text-align:center}.--align-end--xl{text-align:end}.--variant-title-1--xl{font-family:var(--rs-font-family-title-1);font-size:var(--rs-font-size-title-1);font-weight:var(--rs-font-weight-title-1);line-height:var(--rs-line-height-title-1)}.--variant-title-2--xl{font-family:var(--rs-font-family-title-2);font-size:var(--rs-font-size-title-2);font-weight:var(--rs-font-weight-title-2);line-height:var(--rs-line-height-title-2)}.--variant-title-3--xl{font-family:var(--rs-font-family-title-3);font-size:var(--rs-font-size-title-3);font-weight:var(--rs-font-weight-title-3);line-height:var(--rs-line-height-title-3)}.--variant-title-4--xl{font-family:var(--rs-font-family-title-4);font-size:var(--rs-font-size-title-4);font-weight:var(--rs-font-weight-title-4);line-height:var(--rs-line-height-title-4)}.--variant-title-5--xl{font-family:var(--rs-font-family-title-5);font-size:var(--rs-font-size-title-5);font-weight:var(--rs-font-weight-title-5);line-height:var(--rs-line-height-title-5)}.--variant-title-6--xl{font-family:var(--rs-font-family-title-6);font-size:var(--rs-font-size-title-6);font-weight:var(--rs-font-weight-title-6);line-height:var(--rs-line-height-title-6)}.--variant-featured-1--xl{font-family:var(--rs-font-family-featured-1);font-size:var(--rs-font-size-featured-1);font-weight:var(--rs-font-weight-featured-1);line-height:var(--rs-line-height-featured-1)}.--variant-featured-2--xl{font-family:var(--rs-font-family-featured-2);font-size:var(--rs-font-size-featured-2);font-weight:var(--rs-font-weight-featured-2);line-height:var(--rs-line-height-featured-2)}.--variant-featured-3--xl{font-family:var(--rs-font-family-featured-3);font-size:var(--rs-font-size-featured-3);font-weight:var(--rs-font-weight-featured-3);line-height:var(--rs-line-height-featured-3)}.--variant-body-1--xl{font-family:var(--rs-font-family-body-1);font-size:var(--rs-font-size-body-1);font-weight:var(--rs-font-weight-body-1);line-height:var(--rs-line-height-body-1)}.--variant-body-2--xl{font-family:var(--rs-font-family-body-2);font-size:var(--rs-font-size-body-2);font-weight:var(--rs-font-weight-body-2);line-height:var(--rs-line-height-body-2)}.--variant-body-3--xl{font-family:var(--rs-font-family-body-3);font-size:var(--rs-font-size-body-3);font-weight:var(--rs-font-weight-body-3);line-height:var(--rs-line-height-body-3)}.--variant-caption-1--xl{font-family:var(--rs-font-family-caption-1);font-size:var(--rs-font-size-caption-1);font-weight:var(--rs-font-weight-caption-1);line-height:var(--rs-line-height-caption-1)}.--variant-caption-2--xl{font-family:var(--rs-font-family-caption-2);font-size:var(--rs-font-size-caption-2);font-weight:var(--rs-font-weight-caption-2);line-height:var(--rs-line-height-caption-2)}}
|
1
|
+
.root{transition:color var(--rs-duration-fast) var(--rs-easing-standard)}.--clamp{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:var(--rs-text-lines);overflow:hidden}.--break-all{word-break:break-all}.--wrap-balance{text-wrap:balance}.--align-start{text-align:start}.--align-center{text-align:center}.--align-end{text-align:end}.--variant-title-1{font-family:var(--rs-font-family-title-1);font-size:var(--rs-font-size-title-1);font-weight:var(--rs-font-weight-title-1);line-height:var(--rs-line-height-title-1)}.--variant-title-2{font-family:var(--rs-font-family-title-2);font-size:var(--rs-font-size-title-2);font-weight:var(--rs-font-weight-title-2);line-height:var(--rs-line-height-title-2)}.--variant-title-3{font-family:var(--rs-font-family-title-3);font-size:var(--rs-font-size-title-3);font-weight:var(--rs-font-weight-title-3);line-height:var(--rs-line-height-title-3)}.--variant-title-4{font-family:var(--rs-font-family-title-4);font-size:var(--rs-font-size-title-4);font-weight:var(--rs-font-weight-title-4);line-height:var(--rs-line-height-title-4)}.--variant-title-5{font-family:var(--rs-font-family-title-5);font-size:var(--rs-font-size-title-5);font-weight:var(--rs-font-weight-title-5);line-height:var(--rs-line-height-title-5)}.--variant-title-6{font-family:var(--rs-font-family-title-6);font-size:var(--rs-font-size-title-6);font-weight:var(--rs-font-weight-title-6);line-height:var(--rs-line-height-title-6)}.--variant-featured-1{font-family:var(--rs-font-family-featured-1);font-size:var(--rs-font-size-featured-1);font-weight:var(--rs-font-weight-featured-1);line-height:var(--rs-line-height-featured-1)}.--variant-featured-2{font-family:var(--rs-font-family-featured-2);font-size:var(--rs-font-size-featured-2);font-weight:var(--rs-font-weight-featured-2);line-height:var(--rs-line-height-featured-2)}.--variant-featured-3{font-family:var(--rs-font-family-featured-3);font-size:var(--rs-font-size-featured-3);font-weight:var(--rs-font-weight-featured-3);line-height:var(--rs-line-height-featured-3)}.--variant-body-1{font-family:var(--rs-font-family-body-1);font-size:var(--rs-font-size-body-1);font-weight:var(--rs-font-weight-body-1);line-height:var(--rs-line-height-body-1)}.--variant-body-2{font-family:var(--rs-font-family-body-2);font-size:var(--rs-font-size-body-2);font-weight:var(--rs-font-weight-body-2);line-height:var(--rs-line-height-body-2)}.--variant-body-3{font-family:var(--rs-font-family-body-3);font-size:var(--rs-font-size-body-3);font-weight:var(--rs-font-weight-body-3);line-height:var(--rs-line-height-body-3)}.--variant-caption-1{font-family:var(--rs-font-family-caption-1);font-size:var(--rs-font-size-caption-1);font-weight:var(--rs-font-weight-caption-1);line-height:var(--rs-line-height-caption-1)}.--variant-caption-2{font-family:var(--rs-font-family-caption-2);font-size:var(--rs-font-size-caption-2);font-weight:var(--rs-font-weight-caption-2);line-height:var(--rs-line-height-caption-2)}.--weight-regular{font-weight:var(--rs-font-weight-regular)!important}.--weight-medium{font-weight:var(--rs-font-weight-medium)!important}.--weight-bold{font-weight:var(--rs-font-weight-bold)!important}.--color-neutral{color:var(--rs-color-foreground-neutral)}.--color-neutral-faded{color:var(--rs-color-foreground-neutral-faded)}.--color-primary{color:var(--rs-color-foreground-primary)}.--color-warning{color:var(--rs-color-foreground-warning)}.--color-positive{color:var(--rs-color-foreground-positive)}.--color-critical{color:var(--rs-color-foreground-critical)}.--color-disabled{color:var(--rs-color-foreground-disabled)}.--decoration-line-through{text-decoration:line-through}@media (--rs-viewport-m ){.--align-start--m{text-align:start}.--align-center--m{text-align:center}.--align-end--m{text-align:end}.--variant-title-1--m{font-family:var(--rs-font-family-title-1);font-size:var(--rs-font-size-title-1);font-weight:var(--rs-font-weight-title-1);line-height:var(--rs-line-height-title-1)}.--variant-title-2--m{font-family:var(--rs-font-family-title-2);font-size:var(--rs-font-size-title-2);font-weight:var(--rs-font-weight-title-2);line-height:var(--rs-line-height-title-2)}.--variant-title-3--m{font-family:var(--rs-font-family-title-3);font-size:var(--rs-font-size-title-3);font-weight:var(--rs-font-weight-title-3);line-height:var(--rs-line-height-title-3)}.--variant-title-4--m{font-family:var(--rs-font-family-title-4);font-size:var(--rs-font-size-title-4);font-weight:var(--rs-font-weight-title-4);line-height:var(--rs-line-height-title-4)}.--variant-title-5--m{font-family:var(--rs-font-family-title-5);font-size:var(--rs-font-size-title-5);font-weight:var(--rs-font-weight-title-5);line-height:var(--rs-line-height-title-5)}.--variant-title-6--m{font-family:var(--rs-font-family-title-6);font-size:var(--rs-font-size-title-6);font-weight:var(--rs-font-weight-title-6);line-height:var(--rs-line-height-title-6)}.--variant-featured-1--m{font-family:var(--rs-font-family-featured-1);font-size:var(--rs-font-size-featured-1);font-weight:var(--rs-font-weight-featured-1);line-height:var(--rs-line-height-featured-1)}.--variant-featured-2--m{font-family:var(--rs-font-family-featured-2);font-size:var(--rs-font-size-featured-2);font-weight:var(--rs-font-weight-featured-2);line-height:var(--rs-line-height-featured-2)}.--variant-featured-3--m{font-family:var(--rs-font-family-featured-3);font-size:var(--rs-font-size-featured-3);font-weight:var(--rs-font-weight-featured-3);line-height:var(--rs-line-height-featured-3)}.--variant-body-1--m{font-family:var(--rs-font-family-body-1);font-size:var(--rs-font-size-body-1);font-weight:var(--rs-font-weight-body-1);line-height:var(--rs-line-height-body-1)}.--variant-body-2--m{font-family:var(--rs-font-family-body-2);font-size:var(--rs-font-size-body-2);font-weight:var(--rs-font-weight-body-2);line-height:var(--rs-line-height-body-2)}.--variant-body-3--m{font-family:var(--rs-font-family-body-3);font-size:var(--rs-font-size-body-3);font-weight:var(--rs-font-weight-body-3);line-height:var(--rs-line-height-body-3)}.--variant-caption-1--m{font-family:var(--rs-font-family-caption-1);font-size:var(--rs-font-size-caption-1);font-weight:var(--rs-font-weight-caption-1);line-height:var(--rs-line-height-caption-1)}.--variant-caption-2--m{font-family:var(--rs-font-family-caption-2);font-size:var(--rs-font-size-caption-2);font-weight:var(--rs-font-weight-caption-2);line-height:var(--rs-line-height-caption-2)}.--weight-regular--m{font-weight:var(--rs-font-weight-regular)!important}.--weight-medium--m{font-weight:var(--rs-font-weight-medium)!important}.--weight-bold--m{font-weight:var(--rs-font-weight-bold)!important}}@media (--rs-viewport-l ){.--align-start--l{text-align:start}.--align-center--l{text-align:center}.--align-end--l{text-align:end}.--variant-title-1--l{font-family:var(--rs-font-family-title-1);font-size:var(--rs-font-size-title-1);font-weight:var(--rs-font-weight-title-1);line-height:var(--rs-line-height-title-1)}.--variant-title-2--l{font-family:var(--rs-font-family-title-2);font-size:var(--rs-font-size-title-2);font-weight:var(--rs-font-weight-title-2);line-height:var(--rs-line-height-title-2)}.--variant-title-3--l{font-family:var(--rs-font-family-title-3);font-size:var(--rs-font-size-title-3);font-weight:var(--rs-font-weight-title-3);line-height:var(--rs-line-height-title-3)}.--variant-title-4--l{font-family:var(--rs-font-family-title-4);font-size:var(--rs-font-size-title-4);font-weight:var(--rs-font-weight-title-4);line-height:var(--rs-line-height-title-4)}.--variant-title-5--l{font-family:var(--rs-font-family-title-5);font-size:var(--rs-font-size-title-5);font-weight:var(--rs-font-weight-title-5);line-height:var(--rs-line-height-title-5)}.--variant-title-6--l{font-family:var(--rs-font-family-title-6);font-size:var(--rs-font-size-title-6);font-weight:var(--rs-font-weight-title-6);line-height:var(--rs-line-height-title-6)}.--variant-featured-1--l{font-family:var(--rs-font-family-featured-1);font-size:var(--rs-font-size-featured-1);font-weight:var(--rs-font-weight-featured-1);line-height:var(--rs-line-height-featured-1)}.--variant-featured-2--l{font-family:var(--rs-font-family-featured-2);font-size:var(--rs-font-size-featured-2);font-weight:var(--rs-font-weight-featured-2);line-height:var(--rs-line-height-featured-2)}.--variant-featured-3--l{font-family:var(--rs-font-family-featured-3);font-size:var(--rs-font-size-featured-3);font-weight:var(--rs-font-weight-featured-3);line-height:var(--rs-line-height-featured-3)}.--variant-body-1--l{font-family:var(--rs-font-family-body-1);font-size:var(--rs-font-size-body-1);font-weight:var(--rs-font-weight-body-1);line-height:var(--rs-line-height-body-1)}.--variant-body-2--l{font-family:var(--rs-font-family-body-2);font-size:var(--rs-font-size-body-2);font-weight:var(--rs-font-weight-body-2);line-height:var(--rs-line-height-body-2)}.--variant-body-3--l{font-family:var(--rs-font-family-body-3);font-size:var(--rs-font-size-body-3);font-weight:var(--rs-font-weight-body-3);line-height:var(--rs-line-height-body-3)}.--variant-caption-1--l{font-family:var(--rs-font-family-caption-1);font-size:var(--rs-font-size-caption-1);font-weight:var(--rs-font-weight-caption-1);line-height:var(--rs-line-height-caption-1)}.--variant-caption-2--l{font-family:var(--rs-font-family-caption-2);font-size:var(--rs-font-size-caption-2);font-weight:var(--rs-font-weight-caption-2);line-height:var(--rs-line-height-caption-2)}.--weight-regular--l{font-weight:var(--rs-font-weight-regular)!important}.--weight-medium--l{font-weight:var(--rs-font-weight-medium)!important}.--weight-bold--l{font-weight:var(--rs-font-weight-bold)!important}}@media (--rs-viewport-xl ){.--align-start--xl{text-align:start}.--align-center--xl{text-align:center}.--align-end--xl{text-align:end}.--variant-title-1--xl{font-family:var(--rs-font-family-title-1);font-size:var(--rs-font-size-title-1);font-weight:var(--rs-font-weight-title-1);line-height:var(--rs-line-height-title-1)}.--variant-title-2--xl{font-family:var(--rs-font-family-title-2);font-size:var(--rs-font-size-title-2);font-weight:var(--rs-font-weight-title-2);line-height:var(--rs-line-height-title-2)}.--variant-title-3--xl{font-family:var(--rs-font-family-title-3);font-size:var(--rs-font-size-title-3);font-weight:var(--rs-font-weight-title-3);line-height:var(--rs-line-height-title-3)}.--variant-title-4--xl{font-family:var(--rs-font-family-title-4);font-size:var(--rs-font-size-title-4);font-weight:var(--rs-font-weight-title-4);line-height:var(--rs-line-height-title-4)}.--variant-title-5--xl{font-family:var(--rs-font-family-title-5);font-size:var(--rs-font-size-title-5);font-weight:var(--rs-font-weight-title-5);line-height:var(--rs-line-height-title-5)}.--variant-title-6--xl{font-family:var(--rs-font-family-title-6);font-size:var(--rs-font-size-title-6);font-weight:var(--rs-font-weight-title-6);line-height:var(--rs-line-height-title-6)}.--variant-featured-1--xl{font-family:var(--rs-font-family-featured-1);font-size:var(--rs-font-size-featured-1);font-weight:var(--rs-font-weight-featured-1);line-height:var(--rs-line-height-featured-1)}.--variant-featured-2--xl{font-family:var(--rs-font-family-featured-2);font-size:var(--rs-font-size-featured-2);font-weight:var(--rs-font-weight-featured-2);line-height:var(--rs-line-height-featured-2)}.--variant-featured-3--xl{font-family:var(--rs-font-family-featured-3);font-size:var(--rs-font-size-featured-3);font-weight:var(--rs-font-weight-featured-3);line-height:var(--rs-line-height-featured-3)}.--variant-body-1--xl{font-family:var(--rs-font-family-body-1);font-size:var(--rs-font-size-body-1);font-weight:var(--rs-font-weight-body-1);line-height:var(--rs-line-height-body-1)}.--variant-body-2--xl{font-family:var(--rs-font-family-body-2);font-size:var(--rs-font-size-body-2);font-weight:var(--rs-font-weight-body-2);line-height:var(--rs-line-height-body-2)}.--variant-body-3--xl{font-family:var(--rs-font-family-body-3);font-size:var(--rs-font-size-body-3);font-weight:var(--rs-font-weight-body-3);line-height:var(--rs-line-height-body-3)}.--variant-caption-1--xl{font-family:var(--rs-font-family-caption-1);font-size:var(--rs-font-size-caption-1);font-weight:var(--rs-font-weight-caption-1);line-height:var(--rs-line-height-caption-1)}.--variant-caption-2--xl{font-family:var(--rs-font-family-caption-2);font-size:var(--rs-font-size-caption-2);font-weight:var(--rs-font-weight-caption-2);line-height:var(--rs-line-height-caption-2)}.--weight-regular--xl{font-weight:var(--rs-font-weight-regular)!important}.--weight-medium--xl{font-weight:var(--rs-font-weight-medium)!important}.--weight-bold--xl{font-weight:var(--rs-font-weight-bold)!important}}
|
@@ -3,7 +3,7 @@ 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
4
|
export type Props<TagName extends keyof JSX.IntrinsicElements = "div"> = {
|
5
5
|
variant?: G.Responsive<Variant>;
|
6
|
-
weight?: "regular" | "medium" | "bold"
|
6
|
+
weight?: G.Responsive<"regular" | "medium" | "bold">;
|
7
7
|
color?: "neutral" | "neutral-faded" | "critical" | "warning" | "positive" | "primary" | "disabled";
|
8
8
|
align?: G.Responsive<"start" | "center" | "end">;
|
9
9
|
wrap?: "balance";
|
@@ -66,6 +66,9 @@ export const weight = () => (<Example>
|
|
66
66
|
<Example.Item title="weight: bold">
|
67
67
|
<Text weight="bold">Bold</Text>
|
68
68
|
</Example.Item>
|
69
|
+
<Example.Item title={["responsive", "[s] weight: regular", "[m+] bold"]}>
|
70
|
+
<Text weight={{ s: "regular", m: "bold" }}>Responsive</Text>
|
71
|
+
</Example.Item>
|
69
72
|
</Example>);
|
70
73
|
export const color = () => (<Example>
|
71
74
|
<Example.Item title="color: inherit">
|
@@ -5,9 +5,9 @@ import Text from "../Text/index.js";
|
|
5
5
|
import Flyout from "../_private/Flyout/index.js";
|
6
6
|
import s from "./Tooltip.module.css";
|
7
7
|
const Tooltip = (props) => {
|
8
|
-
const { id, text, children, onOpen, onClose, position = "bottom", active } = props;
|
8
|
+
const { id, text, children, onOpen, onClose, position = "bottom", active, disabled, disableContentHover, } = props;
|
9
9
|
if (!text)
|
10
10
|
return _jsx(_Fragment, { children: children({}) });
|
11
|
-
return (_jsxs(Flyout, { id: id, active: active, position: position, onOpen: onOpen, onClose: onClose, triggerType: "hover", children: [_jsx(Flyout.Trigger, { children: children }), _jsx(Flyout.Content, { children: _jsx(Theme, { colorMode: "inverted", children: _jsx(Text, { variant: "caption-1", className: s.root, children: text }) }) })] }));
|
11
|
+
return (_jsxs(Flyout, { id: id, active: active, position: position, disabled: disabled, onOpen: onOpen, onClose: onClose, disableContentHover: disableContentHover, triggerType: "hover", children: [_jsx(Flyout.Trigger, { children: children }), _jsx(Flyout.Content, { children: _jsx(Theme, { colorMode: "inverted", children: _jsx(Text, { variant: "caption-1", className: s.root, children: text }) }) })] }));
|
12
12
|
};
|
13
13
|
export default Tooltip;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import type { FlyoutProps, FlyoutTriggerProps } from "../_private/Flyout";
|
3
|
-
export type Props = Pick<FlyoutProps, "id" | "position" | "onOpen" | "onClose" | "active"> & {
|
3
|
+
export type Props = Pick<FlyoutProps, "id" | "position" | "onOpen" | "onClose" | "active" | "disabled" | "disableContentHover"> & {
|
4
4
|
children: (attributes: Parameters<FlyoutTriggerProps["children"]>[0] | {}) => React.ReactNode;
|
5
5
|
text?: React.ReactNode;
|
6
6
|
};
|
@@ -31,7 +31,11 @@ const DemoResponsive = (props) => {
|
|
31
31
|
};
|
32
32
|
export const position = () => (<Example>
|
33
33
|
<Example.Item title="position: bottom-start">
|
34
|
-
<
|
34
|
+
<View direction="row" gap={2}>
|
35
|
+
<Demo position="bottom-start" text="Tooltip 1"/>
|
36
|
+
<Demo position="bottom-start" text="Tooltip 2"/>
|
37
|
+
<Demo position="bottom-start" text="Tooltip 3"/>
|
38
|
+
</View>
|
35
39
|
</Example.Item>
|
36
40
|
<Example.Item title="position: bottom">
|
37
41
|
<Demo position="bottom"/>
|
@@ -55,9 +59,29 @@ export const position = () => (<Example>
|
|
55
59
|
</View>
|
56
60
|
</Example.Item>
|
57
61
|
|
62
|
+
<Example.Item title="position: start-top">
|
63
|
+
<View align="end">
|
64
|
+
<Demo position="start-top"/>
|
65
|
+
</View>
|
66
|
+
</Example.Item>
|
67
|
+
|
68
|
+
<Example.Item title="position: start-bottom">
|
69
|
+
<View align="end">
|
70
|
+
<Demo position="start-bottom"/>
|
71
|
+
</View>
|
72
|
+
</Example.Item>
|
73
|
+
|
58
74
|
<Example.Item title="position: end">
|
59
75
|
<Demo position="end"/>
|
60
76
|
</Example.Item>
|
77
|
+
|
78
|
+
<Example.Item title="position: end-top">
|
79
|
+
<Demo position="end-top"/>
|
80
|
+
</Example.Item>
|
81
|
+
|
82
|
+
<Example.Item title="position: end-bottom">
|
83
|
+
<Demo position="end-bottom"/>
|
84
|
+
</Example.Item>
|
61
85
|
</Example>);
|
62
86
|
export const controlled = () => (<Example>
|
63
87
|
<Example.Item title="active, controlled, position: bottom">
|
@@ -16,6 +16,7 @@ import getMinHeightStyles from "../../styles/minHeight/index.js";
|
|
16
16
|
import getPositionStyles from "../../styles/position/index.js";
|
17
17
|
import getInsetStyles from "../../styles/inset/index.js";
|
18
18
|
import getAspectRatioStyles from "../../styles/aspectRatio/index.js";
|
19
|
+
import getBorderStyles from "../../styles/border/index.js";
|
19
20
|
const ViewItem = (props) => {
|
20
21
|
const { columns, grow, gapBefore, as: TagName = "div", order, children, className, attributes, } = props;
|
21
22
|
const itemClassNames = classNames(s.item, className, gapBefore === "auto" && s["item--gap-auto"], gapBefore !== undefined && s["item--gap-before"], columns && s["item--columns"], ...responsiveClassNames(s, "item--grow", grow), ...responsiveClassNames(s, "item--columns", columns));
|
@@ -61,6 +62,7 @@ const View = (props) => {
|
|
61
62
|
const insetStartStyles = getInsetStyles(insetStart, "start");
|
62
63
|
const insetEndStyles = getInsetStyles(insetEnd, "end");
|
63
64
|
const aspectRatioStyles = getAspectRatioStyles(aspectRatio);
|
65
|
+
const borderStyles = getBorderStyles(borderColor);
|
64
66
|
let renderedItemIndex = 0;
|
65
67
|
// If wrap is not defined, it can be set based on item grow and split usage
|
66
68
|
let nowrap;
|
@@ -133,7 +135,7 @@ const View = (props) => {
|
|
133
135
|
return renderItem({ child, index: renderedIndex });
|
134
136
|
});
|
135
137
|
// Classnames and attributes are written here so we can assign nowrap to the root element based on the children
|
136
|
-
const rootClassNames = classNames(s.root, className, radiusStyles?.classNames, positionStyles?.classNames, bleedStyles?.classNames, widthStyles?.classNames, heightStyles?.classNames, aspectRatioStyles?.classNames, maxWidthStyles?.classNames, maxHeightStyles?.classNames, minWidthStyles?.classNames, minHeightStyles?.classNames, insetStyles?.classNames, insetTopStyles?.classNames, insetBottomStyles?.classNames, insetStartStyles?.classNames, insetEndStyles?.classNames, textAlign && s[`--align-text-${textAlign}`], backgroundColor && s[`--bg-${backgroundColor}`],
|
138
|
+
const rootClassNames = classNames(s.root, className, radiusStyles?.classNames, positionStyles?.classNames, bleedStyles?.classNames, widthStyles?.classNames, heightStyles?.classNames, aspectRatioStyles?.classNames, maxWidthStyles?.classNames, maxHeightStyles?.classNames, minWidthStyles?.classNames, minHeightStyles?.classNames, insetStyles?.classNames, insetTopStyles?.classNames, insetBottomStyles?.classNames, insetStartStyles?.classNames, insetEndStyles?.classNames, borderStyles?.classNames, textAlign && s[`--align-text-${textAlign}`], backgroundColor && s[`--bg-${backgroundColor}`], shadow && s[`--shadow-${shadow}`], overflow && s[`--overflow-${overflow}`], animated && s["--animated"], divided && s["--divided"], (padding !== undefined || paddingInline !== undefined || paddingBlock !== undefined) &&
|
137
139
|
s["--padding"], paddingBottom !== undefined && s["--padding-bottom"], paddingEnd !== undefined && s["--padding-end"], paddingStart !== undefined && s["--padding-start"], paddingTop !== undefined && s["--padding-top"], (isFlex || nowrap) && s["--flex"], ...responsiveClassNames(s, "--direction", direction), ...responsiveClassNames(s, "--align", align), ...responsiveClassNames(s, "--justify", justify),
|
138
140
|
// Wrap and nowrap are separate here because inverting any of them could result into a false value which will be ignored by classNames
|
139
141
|
...responsiveClassNames(s, "--nowrap", nowrap || wrap === false), ...responsiveClassNames(s, "--wrap", wrap),
|