reshaped 2.6.4 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/bundle.css +1 -1
- package/bundle.d.ts +2 -0
- package/bundle.js +10 -10
- package/components/Calendar/Calendar.d.ts +4 -0
- package/components/Calendar/Calendar.js +9 -0
- package/components/Calendar/Calendar.module.css +1 -0
- package/components/Calendar/Calendar.types.d.ts +102 -0
- package/components/Calendar/Calendar.types.js +1 -0
- package/components/Calendar/Calendar.utils.d.ts +43 -0
- package/components/Calendar/Calendar.utils.js +110 -0
- package/components/Calendar/CalendarControlled.d.ts +4 -0
- package/components/Calendar/CalendarControlled.js +72 -0
- package/components/Calendar/CalendarControls.d.ts +4 -0
- package/components/Calendar/CalendarControls.js +56 -0
- package/components/Calendar/CalendarDate.d.ts +4 -0
- package/components/Calendar/CalendarDate.js +58 -0
- package/components/Calendar/CalendarMonth.d.ts +4 -0
- package/components/Calendar/CalendarMonth.js +54 -0
- package/components/Calendar/CalendarUncontrolled.d.ts +4 -0
- package/components/Calendar/CalendarUncontrolled.js +29 -0
- package/components/Calendar/CalendarYear.d.ts +4 -0
- package/components/Calendar/CalendarYear.js +45 -0
- package/components/Calendar/index.d.ts +2 -0
- package/components/Calendar/index.js +1 -0
- package/components/Calendar/tests/Calendar.stories.d.ts +9 -0
- package/components/Calendar/tests/Calendar.stories.js +30 -0
- package/components/Calendar/useCalendarKeyboardNavigation.d.ts +11 -0
- package/components/Calendar/useCalendarKeyboardNavigation.js +67 -0
- package/components/Modal/Modal.js +97 -3
- package/components/Modal/Modal.module.css +1 -1
- package/components/Modal/tests/Modal.stories.js +3 -0
- package/components/Overlay/Overlay.js +14 -10
- package/components/Overlay/Overlay.module.css +1 -1
- package/components/Overlay/Overlay.types.d.ts +1 -1
- package/components/Slider/Slider.module.css +1 -1
- package/components/Text/Text.js +1 -1
- package/components/Text/Text.module.css +1 -1
- package/components/Text/tests/Text.stories.js +1 -1
- package/hooks/useResponsiveClientValue.d.ts +1 -1
- package/hooks/useResponsiveClientValue.js +3 -0
- package/index.d.ts +2 -0
- package/index.js +1 -0
- package/package.json +6 -6
@@ -0,0 +1,30 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Example } from "../../../utilities/storybook/index.js";
|
3
|
+
import Calendar from "../index.js";
|
4
|
+
export default { title: "Components/Calendar" };
|
5
|
+
export const base = () => (<Example>
|
6
|
+
<Example.Item title="base month">
|
7
|
+
<Calendar defaultMonth={new Date(2023, 11)} onChange={console.log}/>
|
8
|
+
</Example.Item>
|
9
|
+
</Example>);
|
10
|
+
export const selection = () => (<Example>
|
11
|
+
<Example.Item title="single">
|
12
|
+
<Calendar defaultMonth={new Date(2023, 11)} defaultValue={new Date(2023, 11, 15)}/>
|
13
|
+
</Example.Item>
|
14
|
+
<Example.Item title="range">
|
15
|
+
<Calendar range defaultMonth={new Date(2023, 11)} defaultValue={{ start: new Date(2023, 11, 15), end: new Date(2023, 11, 18) }}/>
|
16
|
+
</Example.Item>
|
17
|
+
</Example>);
|
18
|
+
export const boundaries = () => (<Example>
|
19
|
+
<Example.Item title="min">
|
20
|
+
<Calendar defaultMonth={new Date(2023, 11)} min={new Date(2023, 11, 4)}/>
|
21
|
+
</Example.Item>
|
22
|
+
<Example.Item title="max">
|
23
|
+
<Calendar defaultMonth={new Date(2023, 11)} max={new Date(2023, 11, 20)}/>
|
24
|
+
</Example.Item>
|
25
|
+
</Example>);
|
26
|
+
export const translation = () => (<Example>
|
27
|
+
<Example.Item title="NL">
|
28
|
+
<Calendar defaultMonth={new Date(2023, 11)} renderMonthLabel={({ date }) => date.toLocaleDateString("nl", { month: "short" })} renderSelectedMonthLabel={({ date }) => date.toLocaleDateString("nl", { month: "long", year: "numeric" })} renderWeekDay={({ date }) => date.toLocaleDateString("nl", { weekday: "short" })}/>
|
29
|
+
</Example.Item>
|
30
|
+
</Example>);
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from "react";
|
2
|
+
declare const useCalendarKeyboardNavigation: (props: {
|
3
|
+
monthDate: Date;
|
4
|
+
rootRef: React.MutableRefObject<HTMLDivElement | null>;
|
5
|
+
changeToNextMonth: () => void;
|
6
|
+
changeToPreviousMonth: () => void;
|
7
|
+
verticalDelta: number;
|
8
|
+
min?: Date;
|
9
|
+
max?: Date;
|
10
|
+
}) => void;
|
11
|
+
export default useCalendarKeyboardNavigation;
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import useHotkeys from "../../hooks/useHotkeys.js";
|
3
|
+
import * as keys from "../../constants/keys.js";
|
4
|
+
import { getFocusableDates } from "./Calendar.utils.js";
|
5
|
+
const useCalendarKeyboardNavigation = (props) => {
|
6
|
+
const { rootRef, changeToNextMonth, changeToPreviousMonth, monthDate, verticalDelta, min, max } = props;
|
7
|
+
const overflowCountRef = React.useRef(0);
|
8
|
+
const focusDate = React.useCallback((args) => {
|
9
|
+
const { delta, onMonthChange } = args;
|
10
|
+
const focusedEl = document.activeElement;
|
11
|
+
if (!focusedEl)
|
12
|
+
return;
|
13
|
+
const focusable = getFocusableDates(rootRef.current);
|
14
|
+
const focusableArr = Array.from(focusable);
|
15
|
+
const currentIndex = focusableArr.findIndex((el) => el === focusedEl);
|
16
|
+
const nextIndex = currentIndex + delta;
|
17
|
+
const nextEl = focusableArr[nextIndex];
|
18
|
+
const currentDateString = focusedEl.getAttribute("data-rs-date");
|
19
|
+
if (!currentDateString)
|
20
|
+
return;
|
21
|
+
const [year, month, date] = currentDateString === null || currentDateString === void 0 ? void 0 : currentDateString.split("-").map(Number);
|
22
|
+
let nextDate;
|
23
|
+
if (date) {
|
24
|
+
nextDate = new Date(year, month - 1, date + delta);
|
25
|
+
}
|
26
|
+
else if (delta > 0) {
|
27
|
+
nextDate = new Date(year, month - 1 + delta, 1);
|
28
|
+
}
|
29
|
+
else {
|
30
|
+
// If moving back in month navigation - check if the last date of that month is enabled
|
31
|
+
// We increase the delta, but set date to 0 which is the last date of the previous month
|
32
|
+
nextDate = new Date(year, month - 1 + delta + 1, 0);
|
33
|
+
}
|
34
|
+
const disabled = (min && nextDate < min) || (max && nextDate > max);
|
35
|
+
console.log({ nextDate, disabled });
|
36
|
+
if (disabled)
|
37
|
+
return;
|
38
|
+
if (nextEl) {
|
39
|
+
// If element is found but disabled - we do nothing and still keep the current month
|
40
|
+
nextEl.focus();
|
41
|
+
return;
|
42
|
+
}
|
43
|
+
overflowCountRef.current = nextIndex < 0 ? nextIndex : nextIndex - (focusableArr.length - 1);
|
44
|
+
onMonthChange();
|
45
|
+
}, [rootRef, min, max]);
|
46
|
+
/**
|
47
|
+
* Apply focus after switching the month based on the overflow value
|
48
|
+
*/
|
49
|
+
React.useEffect(() => {
|
50
|
+
const count = overflowCountRef.current;
|
51
|
+
if (count === 0)
|
52
|
+
return;
|
53
|
+
const els = getFocusableDates(rootRef.current);
|
54
|
+
const targetIndex = count < 0 ? els.length + count : count - 1;
|
55
|
+
const targetEl = els[targetIndex];
|
56
|
+
if (targetEl)
|
57
|
+
targetEl.focus();
|
58
|
+
overflowCountRef.current = 0;
|
59
|
+
}, [monthDate, rootRef]);
|
60
|
+
useHotkeys({
|
61
|
+
[keys.LEFT]: () => focusDate({ delta: -1, onMonthChange: changeToPreviousMonth }),
|
62
|
+
[keys.RIGHT]: () => focusDate({ delta: 1, onMonthChange: changeToNextMonth }),
|
63
|
+
[keys.UP]: () => focusDate({ delta: -verticalDelta, onMonthChange: changeToPreviousMonth }),
|
64
|
+
[keys.DOWN]: () => focusDate({ delta: verticalDelta, onMonthChange: changeToNextMonth }),
|
65
|
+
}, [changeToNextMonth, changeToPreviousMonth, focusDate, verticalDelta], { ref: rootRef });
|
66
|
+
};
|
67
|
+
export default useCalendarKeyboardNavigation;
|
@@ -1,11 +1,14 @@
|
|
1
1
|
"use client";
|
2
2
|
import React from "react";
|
3
3
|
import { classNames, responsiveVariables, responsiveClassNames } from "../../utilities/helpers.js";
|
4
|
+
import useResponsiveClientValue from "../../hooks/useResponsiveClientValue.js";
|
4
5
|
import Text from "../Text/index.js";
|
5
6
|
import Overlay from "../Overlay/index.js";
|
6
7
|
import useElementId from "../../hooks/useElementId.js";
|
7
8
|
import s from "./Modal.module.css";
|
8
9
|
import getPaddingStyles from "../../styles/padding/index.js";
|
10
|
+
const DRAG_THRESHOLD = 16;
|
11
|
+
const DRAG_EDGE_BOUNDARY = 32;
|
9
12
|
const Context = React.createContext({
|
10
13
|
id: "",
|
11
14
|
titleMounted: false,
|
@@ -35,8 +38,16 @@ const ModalSubtitle = (props) => {
|
|
35
38
|
const Modal = (props) => {
|
36
39
|
const { children, onClose, active, size, padding = 4, position = "center", transparentOverlay, className, attributes, } = props;
|
37
40
|
const id = useElementId();
|
41
|
+
const clientPosition = useResponsiveClientValue(position);
|
38
42
|
const [titleMounted, setTitleMounted] = React.useState(false);
|
39
43
|
const [subtitleMounted, setSubtitleMounted] = React.useState(false);
|
44
|
+
const [dragging, setDragging] = React.useState(false);
|
45
|
+
const rootRef = React.useRef(null);
|
46
|
+
const dragClientCoordinatesRef = React.useRef(0);
|
47
|
+
const dragDistanceRef = React.useRef(0);
|
48
|
+
const dragDirectionRef = React.useRef(0);
|
49
|
+
const [dragDistance, setDragDistance] = React.useState(0);
|
50
|
+
const [hideProgress, setHideProgress] = React.useState(0);
|
40
51
|
const paddingStyles = getPaddingStyles(padding);
|
41
52
|
const value = React.useMemo(() => ({
|
42
53
|
titleMounted,
|
@@ -45,10 +56,93 @@ const Modal = (props) => {
|
|
45
56
|
setSubtitleMounted,
|
46
57
|
id,
|
47
58
|
}), [id, subtitleMounted, titleMounted]);
|
48
|
-
|
49
|
-
|
59
|
+
const resetDragData = () => {
|
60
|
+
dragDirectionRef.current = 0;
|
61
|
+
dragClientCoordinatesRef.current = 0;
|
62
|
+
setDragDistance(0);
|
63
|
+
setHideProgress(0);
|
64
|
+
};
|
65
|
+
const handleDragStart = (e) => {
|
66
|
+
const el = e.target;
|
67
|
+
// Prioritize scrolling over modal swiping
|
68
|
+
if (el.scrollTop !== 0 || el.scrollLeft !== 0)
|
69
|
+
return;
|
70
|
+
// Start dragging only when starting on static elements
|
71
|
+
if (el.matches("input,textarea"))
|
72
|
+
return;
|
73
|
+
// Prevent the drag handling when browser tab swiping is triggering
|
74
|
+
if (clientPosition === "start" && e.targetTouches[0].clientX < DRAG_EDGE_BOUNDARY)
|
75
|
+
return;
|
76
|
+
setDragging(true);
|
77
|
+
};
|
78
|
+
// Once modal is closed - reset its drag data
|
79
|
+
const handleTransitionEnd = (e) => {
|
80
|
+
if (active)
|
81
|
+
return;
|
82
|
+
if (e.propertyName !== "transform")
|
83
|
+
return;
|
84
|
+
if (e.currentTarget !== e.target)
|
85
|
+
return;
|
86
|
+
resetDragData();
|
87
|
+
};
|
88
|
+
React.useEffect(() => {
|
89
|
+
if (!dragging)
|
90
|
+
return;
|
91
|
+
const handleDragEnd = () => {
|
92
|
+
setDragging(false);
|
93
|
+
// Close only when dragging in the closing direction
|
94
|
+
// Changing to a different direction will keep the modal opened
|
95
|
+
const shouldClose = clientPosition && ["bottom", "end"].includes(clientPosition)
|
96
|
+
? dragDirectionRef.current > 0
|
97
|
+
: dragDirectionRef.current < 0;
|
98
|
+
if (Math.abs(dragDistanceRef.current) > DRAG_THRESHOLD && shouldClose) {
|
99
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
100
|
+
}
|
101
|
+
else {
|
102
|
+
resetDragData();
|
103
|
+
}
|
104
|
+
};
|
105
|
+
const handleDrag = (e) => {
|
106
|
+
if (!dragging || clientPosition === "center")
|
107
|
+
return;
|
108
|
+
const prev = dragClientCoordinatesRef.current;
|
109
|
+
const target = e.targetTouches[0];
|
110
|
+
dragClientCoordinatesRef.current =
|
111
|
+
clientPosition === "bottom" ? target.clientY : target.clientX;
|
112
|
+
if (!prev)
|
113
|
+
return;
|
114
|
+
const delta = dragClientCoordinatesRef.current - prev;
|
115
|
+
dragDirectionRef.current = delta < 0 ? -1 : 1;
|
116
|
+
setDragDistance((prev) => {
|
117
|
+
const next = prev + delta;
|
118
|
+
return clientPosition === "start" ? Math.min(0, next) : Math.max(0, next);
|
119
|
+
});
|
120
|
+
};
|
121
|
+
document.addEventListener("touchmove", handleDrag);
|
122
|
+
document.addEventListener("touchend", handleDragEnd);
|
123
|
+
return () => {
|
124
|
+
document.removeEventListener("touchmove", handleDrag);
|
125
|
+
document.removeEventListener("touchend", handleDragEnd);
|
126
|
+
};
|
127
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
128
|
+
}, [dragging, clientPosition]);
|
129
|
+
// Syncing distance to the ref to avoid having a dependency on dragDistance in handleDragEnd
|
130
|
+
React.useEffect(() => {
|
131
|
+
const rootEl = rootRef.current;
|
132
|
+
if (!rootEl || !clientPosition)
|
133
|
+
return;
|
134
|
+
const isInline = ["start", "end"].includes(clientPosition);
|
135
|
+
const size = isInline ? rootEl.clientWidth : rootEl.clientHeight;
|
136
|
+
const progress = Math.abs(dragDistance) / size;
|
137
|
+
dragDistanceRef.current = dragDistance;
|
138
|
+
setHideProgress(progress / 2);
|
139
|
+
}, [dragDistance, clientPosition]);
|
140
|
+
return (React.createElement(Overlay, { onClose: onClose, active: active, transparent: transparentOverlay || hideProgress }, ({ active }) => {
|
141
|
+
const rootClassNames = classNames(s.root, className, paddingStyles === null || paddingStyles === void 0 ? void 0 : paddingStyles.classNames, active && s["--active"], dragging && s["--dragging"], responsiveClassNames(s, "--position", position));
|
50
142
|
return (React.createElement(Context.Provider, { value: value },
|
51
|
-
React.createElement("div", Object.assign({}, attributes, { style: Object.assign(Object.assign({}, paddingStyles === null || paddingStyles === void 0 ? void 0 : paddingStyles.variables), responsiveVariables("--rs-modal-size", size)),
|
143
|
+
React.createElement("div", Object.assign({}, attributes, { style: Object.assign(Object.assign(Object.assign({}, paddingStyles === null || paddingStyles === void 0 ? void 0 : paddingStyles.variables), responsiveVariables("--rs-modal-size", size)), { "--rs-modal-drag": Math.abs(dragDistance) < DRAG_THRESHOLD
|
144
|
+
? "0px"
|
145
|
+
: `${dragDistance + DRAG_THRESHOLD * (clientPosition === "start" ? 1 : -1)}px` }), "aria-labelledby": titleMounted ? `${id}-title` : undefined, "aria-describedby": subtitleMounted ? `${id}-subtitle` : undefined, className: rootClassNames, "aria-modal": "true", role: "dialog", onTouchStart: handleDragStart, onTransitionEnd: handleTransitionEnd, ref: rootRef }), children)));
|
52
146
|
}));
|
53
147
|
};
|
54
148
|
Modal.Title = ModalTitle;
|
@@ -1 +1 @@
|
|
1
|
-
.root{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);--rs-modal-size-m:var(--rs-modal-size-s);--rs-modal-size-l:var(--rs-modal-size-m);--rs-modal-size-xl:var(--rs-modal-size-l);--rs-modal-size:var(--rs-modal-size-s)
|
1
|
+
.root{background:var(--rs-color-background-elevation-overlay);box-shadow:var(--rs-shadow-overlay);color:var(--rs-color-foreground-neutral);transition:var(--rs-easing-accelerate) var(--rs-duration-medium);transition-property:transform,opacity}.--dragging{transition:none}.root{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);--rs-modal-size-m:var(--rs-modal-size-s);--rs-modal-size-l:var(--rs-modal-size-m);--rs-modal-size-xl:var(--rs-modal-size-l);--rs-modal-size:var(--rs-modal-size-s)}.--position-center{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:var(--rs-unit-radius-large);height:auto;inset:0;margin:var(--rs-unit-x4);max-height:none;max-width:calc(100vw - var(--rs-unit-x8));opacity:0;overflow:hidden;position:relative;transform:scale(.96);width:var(--rs-modal-size)}.--position-center.--active,[dir=rtl] .--position-center.--active{opacity:1;transform:translateZ(0) scale(1)!important}.--position-bottom{--rs-modal-size-s:auto;border-radius:var(--rs-unit-radius-large) var(--rs-unit-radius-large) 0 0;height:var(--rs-modal-size);inset:0;inset-block-start:auto;margin:0;margin-top:var(--rs-unit-x4);max-height:calc(100vh - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translate3d(0,100%,0);width:100%}.--position-bottom.--active,[dir=rtl] .--position-bottom.--active{transform:translate3d(0,max(var(--rs-modal-drag,0px),0px),0) scale(1)!important}.--position-start{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-end:auto;margin:0;margin-inline-end:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate3d(-100%,0,0);width:var(--rs-modal-size)}[dir=rtl] .--position-start{transform:translate3d(100%,0,0)}.--position-start.--active,[dir=rtl] .--position-start.--active{transform:translate3d(min(var(--rs-modal-drag,0px),0px),0,0) scale(1)!important}.--position-end{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-start:auto;margin:0;margin-inline-start:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate3d(100%,0,0);width:var(--rs-modal-size)}[dir=rtl] .--position-end{transform:translate3d(-100%,0,0)}.--position-end.--active,[dir=rtl] .--position-end.--active{transform:translate3d(max(var(--rs-modal-drag,0px),0px),0,0) scale(1)!important}.--active,[dir=rtl] .--active{transition-timing-function:var(--rs-easing-decelerate)}@media (min-width:660px){.root{--rs-modal-size:var(--rs-modal-size-m)}.--position-center--m{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:var(--rs-unit-radius-large);height:auto;inset:0;margin:var(--rs-unit-x4);max-height:none;max-width:calc(100vw - var(--rs-unit-x8));opacity:0;overflow:hidden;position:relative;transform:scale(.96);width:var(--rs-modal-size)}.--position-center--m.--active,[dir=rtl] .--position-center--m.--active{opacity:1;transform:translateZ(0) scale(1)!important}.--position-bottom--m{--rs-modal-size-s:auto;border-radius:var(--rs-unit-radius-large) var(--rs-unit-radius-large) 0 0;height:var(--rs-modal-size);inset:0;inset-block-start:auto;margin:0;margin-top:var(--rs-unit-x4);max-height:calc(100vh - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translate3d(0,100%,0);width:100%}.--position-bottom--m.--active,[dir=rtl] .--position-bottom--m.--active{transform:translate3d(0,max(var(--rs-modal-drag,0px),0px),0) scale(1)!important}.--position-start--m{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-end:auto;margin:0;margin-inline-end:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate3d(-100%,0,0);width:var(--rs-modal-size)}[dir=rtl] .--position-start--m{transform:translate3d(100%,0,0)}.--position-start--m.--active,[dir=rtl] .--position-start--m.--active{transform:translate3d(min(var(--rs-modal-drag,0px),0px),0,0) scale(1)!important}.--position-end--m{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-start:auto;margin:0;margin-inline-start:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate3d(100%,0,0);width:var(--rs-modal-size)}[dir=rtl] .--position-end--m{transform:translate3d(-100%,0,0)}.--position-end--m.--active,[dir=rtl] .--position-end--m.--active{transform:translate3d(max(var(--rs-modal-drag,0px),0px),0,0) scale(1)!important}}@media (min-width:900px){.root{--rs-modal-size:var(--rs-modal-size-l)}.--position-center--l{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:var(--rs-unit-radius-large);height:auto;inset:0;margin:var(--rs-unit-x4);max-height:none;max-width:calc(100vw - var(--rs-unit-x8));opacity:0;overflow:hidden;position:relative;transform:scale(.96);width:var(--rs-modal-size)}.--position-center--l.--active,[dir=rtl] .--position-center--l.--active{opacity:1;transform:translateZ(0) scale(1)!important}.--position-bottom--l{--rs-modal-size-s:auto;border-radius:var(--rs-unit-radius-large) var(--rs-unit-radius-large) 0 0;height:var(--rs-modal-size);inset:0;inset-block-start:auto;margin:0;margin-top:var(--rs-unit-x4);max-height:calc(100vh - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translate3d(0,100%,0);width:100%}.--position-bottom--l.--active,[dir=rtl] .--position-bottom--l.--active{transform:translate3d(0,max(var(--rs-modal-drag,0px),0px),0) scale(1)!important}.--position-start--l{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-end:auto;margin:0;margin-inline-end:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate3d(-100%,0,0);width:var(--rs-modal-size)}[dir=rtl] .--position-start--l{transform:translate3d(100%,0,0)}.--position-start--l.--active,[dir=rtl] .--position-start--l.--active{transform:translate3d(min(var(--rs-modal-drag,0px),0px),0,0) scale(1)!important}.--position-end--l{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-start:auto;margin:0;margin-inline-start:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate3d(100%,0,0);width:var(--rs-modal-size)}[dir=rtl] .--position-end--l{transform:translate3d(-100%,0,0)}.--position-end--l.--active,[dir=rtl] .--position-end--l.--active{transform:translate3d(max(var(--rs-modal-drag,0px),0px),0,0) scale(1)!important}}@media (min-width:1280px){.root{--rs-modal-size:var(--rs-modal-size-xl)}.--position-center--xl{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:var(--rs-unit-radius-large);height:auto;inset:0;margin:var(--rs-unit-x4);max-height:none;max-width:calc(100vw - var(--rs-unit-x8));opacity:0;overflow:hidden;position:relative;transform:scale(.96);width:var(--rs-modal-size)}.--position-center--xl.--active,[dir=rtl] .--position-center--xl.--active{opacity:1;transform:translateZ(0) scale(1)!important}.--position-bottom--xl{--rs-modal-size-s:auto;border-radius:var(--rs-unit-radius-large) var(--rs-unit-radius-large) 0 0;height:var(--rs-modal-size);inset:0;inset-block-start:auto;margin:0;margin-top:var(--rs-unit-x4);max-height:calc(100vh - var(--rs-unit-x4));max-width:100%;opacity:1;overflow:auto;position:fixed;transform:translate3d(0,100%,0);width:100%}.--position-bottom--xl.--active,[dir=rtl] .--position-bottom--xl.--active{transform:translate3d(0,max(var(--rs-modal-drag,0px),0px),0) scale(1)!important}.--position-start--xl{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-end:auto;margin:0;margin-inline-end:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate3d(-100%,0,0);width:var(--rs-modal-size)}[dir=rtl] .--position-start--xl{transform:translate3d(100%,0,0)}.--position-start--xl.--active,[dir=rtl] .--position-start--xl.--active{transform:translate3d(min(var(--rs-modal-drag,0px),0px),0,0) scale(1)!important}.--position-end--xl{--rs-modal-size-s:calc(var(--rs-unit-x1) * 100);border-radius:0;height:100%;inset:0;inset-inline-start:auto;margin:0;margin-inline-start:var(--rs-unit-x4);max-height:100%;max-width:calc(100vw - var(--rs-unit-x4));opacity:1;overflow:auto;position:fixed;transform:translate3d(100%,0,0);width:var(--rs-modal-size)}[dir=rtl] .--position-end--xl{transform:translate3d(-100%,0,0)}.--position-end--xl.--active,[dir=rtl] .--position-end--xl.--active{transform:translate3d(max(var(--rs-modal-drag,0px),0px),0,0) scale(1)!important}}
|
@@ -17,6 +17,7 @@ import Button from "../../Button/index.js";
|
|
17
17
|
import Dismissible from "../../Dismissible/index.js";
|
18
18
|
import DropdownMenu from "../../DropdownMenu/index.js";
|
19
19
|
import Switch from "../../Switch/index.js";
|
20
|
+
import TextField from "../../TextField/index.js";
|
20
21
|
import useToggle from "../../../hooks/useToggle.js";
|
21
22
|
export default { title: "Components/Modal" };
|
22
23
|
const Demo = (props) => {
|
@@ -32,6 +33,8 @@ const Demo = (props) => {
|
|
32
33
|
</Dismissible>)}
|
33
34
|
{children ||
|
34
35
|
"Lorem ipsum is placeholder text commonly used in the graphic, print, and publishing industries for previewing layouts and visual mockups."}
|
36
|
+
<Button onClick={() => { }}>Hey</Button>
|
37
|
+
<TextField name="hey"/>
|
35
38
|
</View>
|
36
39
|
</Modal>
|
37
40
|
</>);
|
@@ -12,7 +12,10 @@ import Portal from "../_private/Portal/index.js";
|
|
12
12
|
import s from "./Overlay.module.css";
|
13
13
|
const Overlay = (props) => {
|
14
14
|
const { active, children, transparent, onClose, className, attributes } = props;
|
15
|
+
const clickThrough = transparent === true;
|
16
|
+
const opacity = clickThrough ? 0 : (1 - (transparent || 0)) * 0.7;
|
15
17
|
const [mounted, setMounted] = React.useState(false);
|
18
|
+
const [animated, setAnimated] = React.useState(false);
|
16
19
|
const contentRef = React.useRef(null);
|
17
20
|
const isMouseDownValidRef = React.useRef(false);
|
18
21
|
const releaseFocusRef = React.useRef(null);
|
@@ -20,7 +23,7 @@ const Overlay = (props) => {
|
|
20
23
|
const { active: rendered, activate: render, deactivate: remove } = useToggle(active || false);
|
21
24
|
const { active: visible, activate: show, deactivate: hide } = useToggle(active || false);
|
22
25
|
const isDismissible = useIsDismissible(active, contentRef);
|
23
|
-
const rootClassNames = classNames(s.root, visible && s["--visible"],
|
26
|
+
const rootClassNames = classNames(s.root, visible && s["--visible"], clickThrough && s["--click-through"], animated && s["--animated"], className);
|
24
27
|
const isInsideChild = (el) => {
|
25
28
|
if (!contentRef.current)
|
26
29
|
return;
|
@@ -52,22 +55,24 @@ const Overlay = (props) => {
|
|
52
55
|
};
|
53
56
|
const handleMouseUp = (event) => {
|
54
57
|
const isMouseUpValid = !isInsideChild(event.target);
|
55
|
-
const shouldClose = isMouseDownValidRef.current && isMouseUpValid && !
|
58
|
+
const shouldClose = isMouseDownValidRef.current && isMouseUpValid && !clickThrough;
|
56
59
|
if (!shouldClose)
|
57
60
|
return;
|
58
61
|
close();
|
59
62
|
};
|
60
63
|
const handleTransitionEnd = (e) => {
|
61
|
-
if (e.propertyName !== "opacity" || e.
|
64
|
+
if (e.propertyName !== "opacity" || !e.pseudoElement)
|
62
65
|
return;
|
66
|
+
setAnimated(false);
|
63
67
|
if (visible)
|
64
68
|
return;
|
65
|
-
if (!
|
69
|
+
if (!clickThrough)
|
66
70
|
unlockScroll();
|
67
71
|
remove();
|
68
72
|
};
|
69
73
|
useHotkeys({ Escape: close }, [close]);
|
70
74
|
React.useEffect(() => {
|
75
|
+
setAnimated(true);
|
71
76
|
if (active && !rendered)
|
72
77
|
render();
|
73
78
|
if (!active && rendered)
|
@@ -77,11 +82,10 @@ const Overlay = (props) => {
|
|
77
82
|
React.useEffect(() => {
|
78
83
|
if (!rendered)
|
79
84
|
return;
|
80
|
-
if (!
|
85
|
+
if (!clickThrough)
|
81
86
|
lockScroll();
|
82
87
|
onNextFrame(() => show());
|
83
|
-
|
84
|
-
}, [rendered, show, lockScroll, transparent]);
|
88
|
+
}, [rendered, show, lockScroll, clickThrough]);
|
85
89
|
React.useEffect(() => {
|
86
90
|
if (!rendered)
|
87
91
|
return;
|
@@ -91,17 +95,17 @@ const Overlay = (props) => {
|
|
91
95
|
// Unlock scroll on unmount
|
92
96
|
React.useEffect(() => {
|
93
97
|
return () => {
|
94
|
-
if (!
|
98
|
+
if (!clickThrough)
|
95
99
|
unlockScroll();
|
96
100
|
};
|
97
|
-
}, [unlockScroll,
|
101
|
+
}, [unlockScroll, clickThrough]);
|
98
102
|
useIsomorphicLayoutEffect(() => {
|
99
103
|
setMounted(true);
|
100
104
|
}, []);
|
101
105
|
if (!rendered || !mounted)
|
102
106
|
return null;
|
103
107
|
return (React.createElement(Portal, null,
|
104
|
-
React.createElement(Portal.Scope, null, (ref) => (React.createElement("div", Object.assign({}, attributes, { ref: ref, role: "button", tabIndex: -1, className: rootClassNames, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onTransitionEnd: handleTransitionEnd }),
|
108
|
+
React.createElement(Portal.Scope, null, (ref) => (React.createElement("div", Object.assign({}, attributes, { ref: ref, style: { "--rs-overlay-opacity": opacity }, role: "button", tabIndex: -1, className: rootClassNames, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onTransitionEnd: handleTransitionEnd }),
|
105
109
|
React.createElement("div", { className: s.wrapper },
|
106
110
|
React.createElement("div", { className: s.inner },
|
107
111
|
React.createElement("div", { className: s.content, ref: contentRef }, typeof children === "function" ? children({ active: visible }) : children))))))));
|
@@ -1 +1 @@
|
|
1
|
-
.root{-webkit-overflow-scrolling:touch;color:var(--rs-color-white);
|
1
|
+
.root{-webkit-overflow-scrolling:touch;color:var(--rs-color-white);overflow:auto;z-index:var(--rs-z-index-overlay)}.root,.root:after{inset:0;position:fixed}.root:after{background:var(--rs-color-black);content:"";opacity:0}.wrapper{display:table;height:100%;width:100%}.inner{display:table-cell;text-align:center}.content,.inner{vertical-align:middle}.content{display:inline-block;position:relative;text-align:initial;z-index:var(--rs-z-index-raised)}.root.--visible:after{opacity:var(--rs-overlay-opacity)}.root.--click-through{color:inherit;pointer-events:none}.root.--click-through .content,.root.--click-through>:not(.wrapper){pointer-events:all}.root.--animated:after{transition:opacity var(--rs-duration-medium) var(--rs-easing-standard)}
|
@@ -1 +1 @@
|
|
1
|
-
.root{align-items:center;cursor:pointer;display:flex;height:var(--rs-unit-x4);-webkit-user-select:none;-moz-user-select:none;user-select:none}.bar,.root{position:relative}.bar{background:var(--rs-color-background-neutral);border-radius:var(--rs-unit-radius-small);height:var(--rs-unit-x1);width:100%}.bar,.input{overflow:hidden}.input{height:1px;opacity:0;pointer-events:none;position:absolute;width:1px}.selection{background:var(--rs-color-background-primary);height:100%;position:absolute}.tooltip{background:var(--rs-color-background-elevation-overlay);border-radius:var(--rs-unit-radius-small);bottom:100%;box-shadow:var(--rs-shadow-overlay);color:var(--rs-color-foreground-neutral);left:50%;opacity:0;padding:calc(var(--rs-unit-x1) / 2) var(--rs-unit-x1);transform:translate(-50%);transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:opacity,transform;-webkit-user-select:none;-moz-user-select:none;user-select:none}.thumb,.tooltip{position:absolute}.thumb{height:100%;width:0}.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-unit-x4);transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:box-shadow;width:var(--rs-unit-x4)}.thumb:after,.thumb:before{content:"";left:0;position:absolute;top:50%;transform:translate(-50%,-50%)}.thumb:after{cursor:grab;height:var(--rs-unit-x9);width:var(--rs-unit-x9)}.thumb:hover .tooltip{opacity:1;transform:translate(-50%,calc(var(--rs-unit-x1) * -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;transform:translate(-50%,calc(var(--rs-unit-x1) * -1)) scale(1.1)!important}.--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}
|
1
|
+
.root{-webkit-tap-highlight-color:transparent;align-items:center;cursor:pointer;display:flex;height:var(--rs-unit-x4);-webkit-user-select:none;-moz-user-select:none;user-select:none}.bar,.root{position:relative}.bar{background:var(--rs-color-background-neutral);border-radius:var(--rs-unit-radius-small);height:var(--rs-unit-x1);width:100%}.bar,.input{overflow:hidden}.input{height:1px;opacity:0;pointer-events:none;position:absolute;width:1px}.selection{background:var(--rs-color-background-primary);height:100%;position:absolute}.tooltip{background:var(--rs-color-background-elevation-overlay);border-radius:var(--rs-unit-radius-small);bottom:100%;box-shadow:var(--rs-shadow-overlay);color:var(--rs-color-foreground-neutral);left:50%;opacity:0;padding:calc(var(--rs-unit-x1) / 2) var(--rs-unit-x1);transform:translate(-50%);transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:opacity,transform;-webkit-user-select:none;-moz-user-select:none;user-select:none}.thumb,.tooltip{position:absolute}.thumb{height:100%;width:0}.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-unit-x4);transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:box-shadow;width:var(--rs-unit-x4)}.thumb:after,.thumb:before{content:"";left:0;position:absolute;top:50%;transform:translate(-50%,-50%)}.thumb:after{cursor:grab;height:var(--rs-unit-x9);width:var(--rs-unit-x9)}.thumb:hover .tooltip{opacity:1;transform:translate(-50%,calc(var(--rs-unit-x1) * -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;transform:translate(-50%,calc(var(--rs-unit-x1) * -1)) scale(1.1)!important}.--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}
|
package/components/Text/Text.js
CHANGED
@@ -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 && s[`--weight-${weight}`], decoration && s[`--decoration-${decoration}`], maxLines !== undefined && s[`--clamp`], className);
|
20
|
+
const rootClassName = classNames(s.root, color && s[`--color-${color}`], ...responsiveClassNames(s, "--variant", variant), ...responsiveClassNames(s, "--align", align), weight && s[`--weight-${weight}`], decoration && s[`--decoration-${decoration}`], maxLines !== undefined && s[`--clamp`], maxLines === 1 && s["--break-all"], className);
|
21
21
|
const style = Object.assign(Object.assign({}, attributes === null || attributes === void 0 ? void 0 : attributes.style), { "--rs-text-lines": maxLines });
|
22
22
|
return (React.createElement(TagName, Object.assign({}, attributes, { className: rootClassName, style: style }), children));
|
23
23
|
};
|
@@ -1 +1 @@
|
|
1
|
-
.root{transition:color var(--rs-duration-fast) var(--rs-easing-standard)}.--clamp{-webkit-box-orient:vertical;-webkit-line-clamp:var(--rs-text-lines);display:-webkit-box;overflow:hidden}.--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-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 (min-width:660px){.--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 (min-width:900px){.--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 (min-width:1280px){.--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{-webkit-box-orient:vertical;-webkit-line-clamp:var(--rs-text-lines);display:-webkit-box;overflow:hidden}.--break-all{word-break:break-all}.--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-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 (min-width:660px){.--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 (min-width:900px){.--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 (min-width:1280px){.--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)}}
|
@@ -87,7 +87,7 @@ export const decoration = () => (<Example>
|
|
87
87
|
</Example>);
|
88
88
|
export const maxLines = () => (<Example>
|
89
89
|
<Example.Item title="maxLines: 2">
|
90
|
-
<Text maxLines={
|
90
|
+
<Text maxLines={1}>
|
91
91
|
There are many variations of passages of Lorem Ipsum available, but the majority have
|
92
92
|
suffered alteration in some form, by injected humour, or randomised words which don't look
|
93
93
|
even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import type * as G from "../types/global";
|
2
|
-
declare const useResponsiveClientValue: <T extends unknown>(value: G.
|
2
|
+
declare const useResponsiveClientValue: <T extends unknown>(value: G.Responsive<T>) => T | undefined;
|
3
3
|
export default useResponsiveClientValue;
|
@@ -32,6 +32,9 @@ const useResponsiveClientValue = (value) => {
|
|
32
32
|
});
|
33
33
|
};
|
34
34
|
}, []);
|
35
|
+
if (typeof value !== "object" || value === null || !("s" in value)) {
|
36
|
+
return value;
|
37
|
+
}
|
35
38
|
if (viewport === "xl")
|
36
39
|
return value.xl || value.l || value.m || value.s;
|
37
40
|
if (viewport === "l")
|
package/index.d.ts
CHANGED
@@ -19,6 +19,8 @@ export { default as Button } from "./components/Button";
|
|
19
19
|
export type { ButtonProps, ButtonAlignerProps } from "./components/Button";
|
20
20
|
export { default as Breadcrumbs } from "./components/Breadcrumbs";
|
21
21
|
export type { BreadcrumbsProps } from "./components/Breadcrumbs";
|
22
|
+
export { default as Calendar } from "./components/Calendar";
|
23
|
+
export type { CalendarProps } from "./components/Calendar";
|
22
24
|
export { default as Card } from "./components/Card";
|
23
25
|
export type { CardProps } from "./components/Card";
|
24
26
|
export { default as Carousel } from "./components/Carousel";
|
package/index.js
CHANGED
@@ -10,6 +10,7 @@ export { default as Avatar } from "./components/Avatar/index.js";
|
|
10
10
|
export { default as Badge } from "./components/Badge/index.js";
|
11
11
|
export { default as Button } from "./components/Button/index.js";
|
12
12
|
export { default as Breadcrumbs } from "./components/Breadcrumbs/index.js";
|
13
|
+
export { default as Calendar } from "./components/Calendar/index.js";
|
13
14
|
export { default as Card } from "./components/Card/index.js";
|
14
15
|
export { default as Carousel } from "./components/Carousel/index.js";
|
15
16
|
export { default as Checkbox } from "./components/Checkbox/index.js";
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "reshaped",
|
3
3
|
"description": "Professionally crafted design system in React & Figma for building products of any scale and complexity",
|
4
|
-
"version": "2.
|
4
|
+
"version": "2.7.0",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
6
6
|
"email": "hello@reshaped.so",
|
7
7
|
"homepage": "https://reshaped.so",
|
@@ -86,9 +86,9 @@
|
|
86
86
|
"@semantic-release/changelog": "6.0.3",
|
87
87
|
"@semantic-release/git": "10.0.1",
|
88
88
|
"@size-limit/preset-big-lib": "9.0.0",
|
89
|
-
"@storybook/addon-a11y": "7.
|
90
|
-
"@storybook/react": "7.
|
91
|
-
"@storybook/react-vite": "7.
|
89
|
+
"@storybook/addon-a11y": "7.6.3",
|
90
|
+
"@storybook/react": "7.6.3",
|
91
|
+
"@storybook/react-vite": "7.6.3",
|
92
92
|
"@testing-library/jest-dom": "6.1.4",
|
93
93
|
"@testing-library/react": "14.1.2",
|
94
94
|
"@testing-library/user-event": "14.5.1",
|
@@ -126,13 +126,13 @@
|
|
126
126
|
"resolve-tspaths": "0.8.17",
|
127
127
|
"semantic-release": "22.0.8",
|
128
128
|
"size-limit": "9.0.0",
|
129
|
-
"storybook": "7.
|
129
|
+
"storybook": "7.6.3",
|
130
130
|
"stylelint": "15.11.0",
|
131
131
|
"stylelint-config-prettier": "9.0.5",
|
132
132
|
"stylelint-config-standard": "34.0.0",
|
133
133
|
"ts-jest": "29.1.1",
|
134
134
|
"typescript": "5.2.2",
|
135
|
-
"vite": "
|
135
|
+
"vite": "4",
|
136
136
|
"vite-tsconfig-paths": "4.2.1"
|
137
137
|
},
|
138
138
|
"peerDependencies": {
|