reshaped 3.9.0-canary.1 → 3.9.0-canary.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +2 -31
- package/dist/cli/theming/index.js +4 -4
- package/dist/cli/theming/reshaped.config.js +1 -1
- package/dist/components/Accordion/Accordion.types.d.ts +1 -1
- package/dist/components/Accordion/AccordionControlled.js +2 -2
- package/dist/components/Accordion/AccordionTrigger.js +2 -2
- package/dist/components/Accordion/index.d.ts +1 -1
- package/dist/components/Accordion/index.js +1 -1
- package/dist/components/ActionBar/ActionBar.js +1 -1
- package/dist/components/ActionBar/ActionBar.types.d.ts +1 -1
- package/dist/components/Actionable/Actionable.js +1 -1
- package/dist/components/Alert/Alert.js +1 -1
- package/dist/components/Alert/Alert.types.d.ts +1 -1
- package/dist/components/Autocomplete/Autocomplete.js +6 -6
- package/dist/components/Autocomplete/Autocomplete.types.d.ts +3 -3
- package/dist/components/Avatar/Avatar.js +9 -26
- package/dist/components/Avatar/Avatar.module.css +1 -1
- package/dist/components/Badge/Badge.js +4 -4
- package/dist/components/Badge/Badge.module.css +1 -1
- package/dist/components/Badge/Badge.types.d.ts +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +3 -3
- package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +1 -1
- package/dist/components/Breadcrumbs/BreadcrumbsItem.js +1 -1
- package/dist/components/Button/Button.js +2 -2
- package/dist/components/Button/Button.types.d.ts +3 -3
- package/dist/components/Calendar/Calendar.types.d.ts +25 -6
- package/dist/components/Calendar/CalendarControlled.js +45 -10
- package/dist/components/Calendar/CalendarControls.js +11 -11
- package/dist/components/Calendar/CalendarDate.js +13 -11
- package/dist/components/Calendar/CalendarMonth.js +3 -3
- package/dist/components/Calendar/CalendarYear.js +1 -1
- package/dist/components/Calendar/useCalendarKeyboardNavigation.js +1 -1
- package/dist/components/Card/Card.js +2 -2
- package/dist/components/Card/Card.types.d.ts +1 -1
- package/dist/components/Carousel/Carousel.js +4 -4
- package/dist/components/Carousel/Carousel.types.d.ts +1 -1
- package/dist/components/Carousel/CarouselControl.d.ts +1 -1
- package/dist/components/Carousel/CarouselControl.js +3 -3
- package/dist/components/Checkbox/Checkbox.js +5 -15
- package/dist/components/CheckboxGroup/CheckboxGroup.types.d.ts +1 -1
- package/dist/components/Container/Container.js +1 -1
- package/dist/components/Container/Container.types.d.ts +1 -1
- package/dist/components/ContextMenu/ContextMenu.js +1 -1
- package/dist/components/Dismissible/Dismissible.js +1 -1
- package/dist/components/Divider/Divider.d.ts +1 -1
- package/dist/components/Divider/Divider.js +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +5 -5
- package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +4 -4
- package/dist/components/FileUpload/FileUpload.js +9 -7
- package/dist/components/FileUpload/FileUpload.module.css +1 -1
- package/dist/components/FileUpload/FileUpload.types.d.ts +3 -1
- package/dist/components/Flyout/Flyout.constants.d.ts +2 -3
- package/dist/components/Flyout/Flyout.js +1 -1
- package/dist/components/Flyout/Flyout.module.css +1 -1
- package/dist/components/Flyout/Flyout.types.d.ts +6 -7
- package/dist/components/Flyout/FlyoutContent.js +7 -7
- package/dist/components/Flyout/FlyoutControlled.js +14 -9
- package/dist/components/Flyout/index.d.ts +1 -1
- package/dist/components/Flyout/index.js +1 -1
- package/dist/components/Flyout/useFlyout.d.ts +2 -2
- package/dist/components/Flyout/useFlyout.js +5 -18
- package/dist/components/Flyout/utilities/calculatePosition.d.ts +6 -6
- package/dist/components/Flyout/utilities/calculatePosition.js +6 -6
- package/dist/components/Flyout/utilities/flyout.d.ts +1 -1
- package/dist/components/Flyout/utilities/flyout.js +5 -2
- package/dist/components/FormControl/FormControlCaption.js +1 -1
- package/dist/components/FormControl/FormControlLabel.js +1 -1
- package/dist/components/FormControl/index.d.ts +2 -2
- package/dist/components/FormControl/index.js +2 -2
- package/dist/components/Grid/Grid.js +1 -1
- package/dist/components/Grid/Grid.types.d.ts +2 -2
- package/dist/components/HiddenInput/HiddenInput.js +34 -0
- package/dist/components/HiddenInput/HiddenInput.types.d.ts +26 -0
- package/dist/components/Icon/Icon.js +1 -1
- package/dist/components/Image/Image.js +14 -9
- package/dist/components/Image/Image.module.css +1 -1
- package/dist/components/Image/Image.types.d.ts +4 -2
- package/dist/components/Link/Link.js +1 -1
- package/dist/components/MenuItem/MenuItem.js +1 -1
- package/dist/components/MenuItem/MenuItem.types.d.ts +2 -2
- package/dist/components/Modal/Modal.js +8 -8
- package/dist/components/Modal/Modal.module.css +1 -1
- package/dist/components/Modal/Modal.types.d.ts +1 -1
- package/dist/components/NumberField/NumberFieldControlled.js +7 -7
- package/dist/components/Overlay/Overlay.js +8 -8
- package/dist/components/PinField/PinFieldControlled.js +4 -4
- package/dist/components/Popover/Popover.js +3 -3
- package/dist/components/Popover/Popover.module.css +1 -1
- package/dist/components/Popover/Popover.types.d.ts +2 -2
- package/dist/components/Radio/Radio.js +5 -15
- package/dist/components/RadioGroup/RadioGroup.types.d.ts +1 -1
- package/dist/components/Reshaped/Reshaped.js +4 -4
- package/dist/components/Reshaped/Reshaped.types.d.ts +1 -1
- package/dist/components/Resizable/Resizable.js +2 -2
- package/dist/components/Resizable/Resizable.types.d.ts +1 -1
- package/dist/components/Resizable/ResizableHandle.js +1 -1
- package/dist/components/Scrim/Scrim.js +4 -3
- package/dist/components/Scrim/Scrim.module.css +1 -1
- package/dist/components/Scrim/Scrim.types.d.ts +2 -1
- package/dist/components/ScrollArea/ScrollArea.js +5 -5
- package/dist/components/Select/Select.types.d.ts +3 -3
- package/dist/components/Select/SelectCustomControlled.js +6 -3
- package/dist/components/Select/SelectEndContent.js +1 -1
- package/dist/components/Select/SelectGroup.js +1 -1
- package/dist/components/Select/SelectNative.js +2 -2
- package/dist/components/Select/SelectRoot.js +1 -1
- package/dist/components/Select/SelectTrigger.js +1 -1
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/Skeleton/Skeleton.js +1 -1
- package/dist/components/Slider/SliderControlled.js +7 -7
- package/dist/components/Slider/SliderThumb.js +3 -3
- package/dist/components/Stepper/Stepper.js +4 -4
- package/dist/components/Switch/Switch.js +1 -1
- package/dist/components/Table/Table.js +2 -2
- package/dist/components/Tabs/Tabs.module.css +1 -1
- package/dist/components/Tabs/Tabs.types.d.ts +4 -2
- package/dist/components/Tabs/TabsContext.d.ts +1 -0
- package/dist/components/Tabs/TabsControlled.js +2 -1
- package/dist/components/Tabs/TabsItem.js +4 -4
- package/dist/components/Tabs/TabsList.js +17 -13
- package/dist/components/Tabs/TabsPanel.js +3 -3
- package/dist/components/Text/Text.js +3 -3
- package/dist/components/Text/Text.module.css +1 -1
- package/dist/components/Text/Text.types.d.ts +2 -0
- package/dist/components/TextArea/TextArea.js +1 -1
- package/dist/components/TextArea/TextArea.types.d.ts +1 -1
- package/dist/components/TextField/TextField.js +2 -2
- package/dist/components/TextField/TextField.types.d.ts +2 -2
- package/dist/components/Theme/GlobalColorMode.js +1 -1
- package/dist/components/Theme/Theme.js +2 -2
- package/dist/components/Timeline/Timeline.js +1 -1
- package/dist/components/Toast/Toast.js +2 -2
- package/dist/components/Toast/Toast.types.d.ts +1 -1
- package/dist/components/Toast/ToastContainer.js +3 -3
- package/dist/components/Toast/ToastProvider.js +1 -1
- package/dist/components/Toast/ToastRegion.js +2 -2
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.types.d.ts +1 -1
- package/dist/components/ToggleButtonGroup/ToggleButtonGroupControlled.js +1 -1
- package/dist/components/Tooltip/Tooltip.js +5 -3
- package/dist/components/View/View.js +2 -2
- package/dist/components/View/View.types.d.ts +1 -1
- package/dist/components/_private/Expandable/Expandable.js +2 -2
- package/dist/components/_private/Portal/Portal.js +1 -1
- package/dist/config/tailwind.js +2 -2
- package/dist/hooks/_private/useDrag.js +4 -4
- package/dist/hooks/_private/useFadeSide.js +1 -1
- package/dist/hooks/useResponsiveClientValue.js +1 -1
- package/dist/styles/mixin.js +1 -1
- package/dist/tests/ThemesPlayground.js +16 -16
- package/dist/themes/_generator/definitions/slate.js +1 -1
- package/dist/themes/_generator/tokens/color/utilities/generateColors.d.ts +1 -1
- package/dist/themes/_generator/tokens/color/utilities/generateMetaColors.d.ts +1 -1
- package/dist/themes/_generator/tokens/color/utilities/generateMetaColors.js +1 -1
- package/dist/themes/_generator/tokens/font/font.types.d.ts +2 -2
- package/dist/themes/_generator/tokens/transforms.js +1 -1
- package/dist/themes/_generator/tokens/types.d.ts +3 -3
- package/dist/themes/_generator/transform.d.ts +1 -1
- package/dist/themes/_generator/transform.js +3 -3
- package/dist/themes/index.d.ts +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/utilities/a11y/TrapFocus.js +4 -4
- package/dist/utilities/scroll/lock.js +1 -1
- package/dist/utilities/scroll/lockStandard.js +1 -1
- package/dist/utilities/storybook/Example.js +1 -1
- package/package.json +4 -2
- package/dist/components/_private/HiddenInput/HiddenInput.js +0 -10
- package/dist/components/_private/HiddenInput/HiddenInput.types.d.ts +0 -15
- /package/dist/components/{_private/HiddenInput → HiddenInput}/HiddenInput.d.ts +0 -0
- /package/dist/components/{_private/HiddenInput → HiddenInput}/HiddenInput.module.css +0 -0
- /package/dist/components/{_private/HiddenInput → HiddenInput}/HiddenInput.types.js +0 -0
- /package/dist/components/{_private/HiddenInput → HiddenInput}/index.d.ts +0 -0
- /package/dist/components/{_private/HiddenInput → HiddenInput}/index.js +0 -0
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import Actionable from "../Actionable/index.js";
|
|
4
4
|
import { classNames } from "../../utilities/props.js";
|
|
5
|
-
import { getLocalISODate } from "./Calendar.utils.js";
|
|
6
5
|
import s from "./Calendar.module.css";
|
|
6
|
+
import { getLocalISODate } from "./Calendar.utils.js";
|
|
7
7
|
const CalendarDate = (props) => {
|
|
8
|
-
const { date, isoDate, startValue, endValue, disabled, focusable, onChange, range, hoveredDate, onDateHover, onDateHoverEnd, onDateFocus, renderAriaLabel,
|
|
8
|
+
const { date, isoDate, startValue, endValue, disabled: passedDisabled, focusable, onChange, range, hoveredDate, onDateHover, onDateHoverEnd, onDateFocus, selectedDates, disabledDates, renderAriaLabel, renderSlot, } = props;
|
|
9
9
|
if (!date)
|
|
10
10
|
return _jsx("td", { className: s.cell, "aria-hidden": "true" });
|
|
11
11
|
const isoStartValue = startValue && getLocalISODate({ date: startValue });
|
|
12
12
|
const isoEndValue = endValue && getLocalISODate({ date: endValue });
|
|
13
|
-
const isStartValue =
|
|
14
|
-
const isEndValue =
|
|
15
|
-
const isAfterStartValue =
|
|
16
|
-
const isBeforeEndValue =
|
|
17
|
-
const isInHoveredRange = hoveredDate && !endValue && hoveredDate > date;
|
|
18
|
-
const isInSelectedDates = !!selectedDates?.
|
|
13
|
+
const isStartValue = Boolean(isoDate && !!isoStartValue && isoDate === isoStartValue);
|
|
14
|
+
const isEndValue = Boolean(isoDate && !!isoEndValue && isoDate === isoEndValue);
|
|
15
|
+
const isAfterStartValue = Boolean(isoDate && isoStartValue && isoDate > isoStartValue);
|
|
16
|
+
const isBeforeEndValue = Boolean(isoDate && isoEndValue && isoDate < isoEndValue);
|
|
17
|
+
const isInHoveredRange = Boolean(hoveredDate && !endValue && hoveredDate > date);
|
|
18
|
+
const isInSelectedDates = !!selectedDates?.some((selectedDate) => getLocalISODate({ date: selectedDate }) === isoDate);
|
|
19
|
+
const disabled = passedDisabled ||
|
|
20
|
+
disabledDates?.some((disabledDate) => getLocalISODate({ date: disabledDate }) === isoDate);
|
|
19
21
|
let selection;
|
|
20
22
|
switch (true) {
|
|
21
23
|
case isAfterStartValue && isInHoveredRange:
|
|
@@ -61,7 +63,7 @@ const CalendarDate = (props) => {
|
|
|
61
63
|
handleMouseEnter();
|
|
62
64
|
onDateFocus(date);
|
|
63
65
|
};
|
|
64
|
-
return (_jsx("td", { className: dateClassNames, role: disabled ? "presentation" : "gridcell", children:
|
|
66
|
+
return (_jsx("td", { className: dateClassNames, role: disabled ? "presentation" : "gridcell", children: _jsxs(Actionable, { fullWidth: true, insetFocus: true, className: s["cell-button"], disabled: disabled, onClick: handleClick, attributes: {
|
|
65
67
|
role: "checkbox",
|
|
66
68
|
tabIndex: focusable ? 0 : -1,
|
|
67
69
|
"aria-hidden": disabled,
|
|
@@ -74,7 +76,7 @@ const CalendarDate = (props) => {
|
|
|
74
76
|
onMouseLeave: handleMouseLeave,
|
|
75
77
|
onFocus: handleFocus,
|
|
76
78
|
onBlur: handleMouseLeave,
|
|
77
|
-
}, children: date.getDate() }) }));
|
|
79
|
+
}, children: [date.getDate(), renderSlot?.({ date, selected: Boolean(selection && selection !== "range") })] }) }));
|
|
78
80
|
};
|
|
79
81
|
CalendarDate.displayName = "CalendarDate";
|
|
80
82
|
export default CalendarDate;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
+
import s from "./Calendar.module.css";
|
|
4
5
|
import { getMonthWeeks, getWeekdayNames, getLocalISODate, isDateFocusable } from "./Calendar.utils.js";
|
|
5
6
|
import CalendarDate from "./CalendarDate.js";
|
|
6
|
-
import s from "./Calendar.module.css";
|
|
7
7
|
const CalendarMonth = (props) => {
|
|
8
|
-
const { date, value, onChange, min, max, range, firstWeekDay, selectedDates, hoveredDate, onDateHover, onDateHoverEnd, renderWeekDay, renderDateAriaLabel, } = props;
|
|
8
|
+
const { date, value, onChange, min, max, range, firstWeekDay, selectedDates, disabledDates, hoveredDate, onDateHover, onDateHoverEnd, renderWeekDay, renderDateAriaLabel, renderDateSlot, } = props;
|
|
9
9
|
let foundFocusableDate = false;
|
|
10
10
|
const [lastFocusedDate, setLastFocusedDate] = useState();
|
|
11
11
|
const month = date.getMonth();
|
|
@@ -26,7 +26,7 @@ const CalendarMonth = (props) => {
|
|
|
26
26
|
// eslint-disable-next-line react-hooks/immutability
|
|
27
27
|
if (focusable)
|
|
28
28
|
foundFocusableDate = true;
|
|
29
|
-
return (_jsx(CalendarDate, { date: date, isoDate: isoDate, disabled: disabled, range: range, focusable: focusable, startValue: startValue, endValue: endValue, onChange: onChange, hoveredDate: hoveredDate, onDateHover: onDateHover, onDateHoverEnd: onDateHoverEnd, onDateFocus: setLastFocusedDate, renderAriaLabel: renderDateAriaLabel, selectedDates: selectedDates }, index));
|
|
29
|
+
return (_jsx(CalendarDate, { date: date, isoDate: isoDate, disabled: disabled, range: range, focusable: focusable, startValue: startValue, endValue: endValue, onChange: onChange, hoveredDate: hoveredDate, onDateHover: onDateHover, onDateHoverEnd: onDateHoverEnd, onDateFocus: setLastFocusedDate, renderAriaLabel: renderDateAriaLabel, selectedDates: selectedDates, disabledDates: disabledDates, renderSlot: renderDateSlot }, index));
|
|
30
30
|
}) }, key));
|
|
31
31
|
}) })] }));
|
|
32
32
|
};
|
|
@@ -2,8 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import Actionable from "../Actionable/index.js";
|
|
4
4
|
import { onNextFrame } from "../../utilities/animation.js";
|
|
5
|
-
import { getMonthNames } from "./Calendar.utils.js";
|
|
6
5
|
import s from "./Calendar.module.css";
|
|
6
|
+
import { getMonthNames } from "./Calendar.utils.js";
|
|
7
7
|
const MONTHS_PER_ROW = 3;
|
|
8
8
|
const CalendarYear = (props) => {
|
|
9
9
|
const { renderMonthLabel, renderMonthAriaLabel, monthDate, min, max, onMonthClick } = props;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import useHotkeys from "../../hooks/useHotkeys.js";
|
|
3
2
|
import * as keys from "../../constants/keys.js";
|
|
3
|
+
import useHotkeys from "../../hooks/useHotkeys.js";
|
|
4
4
|
import { getFocusableDates } from "./Calendar.utils.js";
|
|
5
5
|
const useCalendarKeyboardNavigation = (props) => {
|
|
6
6
|
const { rootRef, changeToNextMonth, changeToPreviousMonth, monthDate, verticalDelta, min, max } = props;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
-
import { classNames } from "../../utilities/props.js";
|
|
4
3
|
import Actionable from "../Actionable/index.js";
|
|
5
|
-
import s from "./Card.module.css";
|
|
6
4
|
import { resolveMixin } from "../../styles/mixin.js";
|
|
5
|
+
import { classNames } from "../../utilities/props.js";
|
|
6
|
+
import s from "./Card.module.css";
|
|
7
7
|
const Card = forwardRef((props, ref) => {
|
|
8
8
|
const { padding = 4 } = props;
|
|
9
9
|
const { selected, elevated, bleed, height, onClick, href, children, className, attributes,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type React from "react";
|
|
2
1
|
import type { ActionableProps } from "../Actionable";
|
|
3
2
|
import type { ViewProps } from "../View";
|
|
3
|
+
import type React from "react";
|
|
4
4
|
import type * as G from "../../types/global";
|
|
5
5
|
export type Props<TagName extends keyof React.JSX.IntrinsicElements = "div"> = {
|
|
6
6
|
/** Component padding, base unit multiplier */
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { classNames, responsiveVariables, responsiveClassNames } from "../../utilities/props.js";
|
|
5
|
-
import { rafThrottle } from "../../utilities/helpers.js";
|
|
6
4
|
import View from "../View/index.js";
|
|
7
|
-
import useRTL from "../../hooks/useRTL.js";
|
|
8
5
|
import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
|
|
9
|
-
import
|
|
6
|
+
import useRTL from "../../hooks/useRTL.js";
|
|
7
|
+
import { rafThrottle } from "../../utilities/helpers.js";
|
|
8
|
+
import { classNames, responsiveVariables, responsiveClassNames } from "../../utilities/props.js";
|
|
10
9
|
import s from "./Carousel.module.css";
|
|
10
|
+
import CarouselControl from "./CarouselControl.js";
|
|
11
11
|
const Carousel = (props) => {
|
|
12
12
|
const { children, gap = 3, visibleItems, bleed, navigationDisplay, onChange, onScroll, instanceRef, className, attributes, } = props;
|
|
13
13
|
const currentIndexRef = React.useRef(0);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { ActionableRef } from "../Actionable";
|
|
1
2
|
import type React from "react";
|
|
2
3
|
import type * as G from "../../types/global";
|
|
3
|
-
import type { ActionableRef } from "../Actionable";
|
|
4
4
|
export type Instance = {
|
|
5
5
|
/** Scroll to the previous item */
|
|
6
6
|
navigateBack: () => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActionableRef } from "../Actionable";
|
|
2
1
|
import * as T from "./Carousel.types";
|
|
2
|
+
import type { ActionableRef } from "../Actionable";
|
|
3
3
|
declare const CarouselControl: import("react").ForwardRefExoticComponent<T.ControlProps & import("react").RefAttributes<ActionableRef>>;
|
|
4
4
|
export default CarouselControl;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef, useState } from "react";
|
|
4
|
-
import { classNames } from "../../utilities/props.js";
|
|
5
4
|
import Button from "../Button/index.js";
|
|
6
|
-
import IconChevronRight from "../../icons/ChevronRight.js";
|
|
7
|
-
import IconChevronLeft from "../../icons/ChevronLeft.js";
|
|
8
5
|
import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
|
|
6
|
+
import IconChevronLeft from "../../icons/ChevronLeft.js";
|
|
7
|
+
import IconChevronRight from "../../icons/ChevronRight.js";
|
|
8
|
+
import { classNames } from "../../utilities/props.js";
|
|
9
9
|
import s from "./Carousel.module.css";
|
|
10
10
|
const CarouselControl = forwardRef((props, ref) => {
|
|
11
11
|
const { type, scrollElRef, oppositeControlElRef, scrollPosition, onClick, isRTL, mounted } = props;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { classNames, responsiveClassNames, responsivePropDependency } from "../../utilities/props.js";
|
|
5
|
-
import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
|
|
6
|
-
import HiddenInput from "../_private/HiddenInput/index.js";
|
|
7
|
-
import { useFormControl } from "../FormControl/index.js";
|
|
8
4
|
import { useCheckboxGroup } from "../CheckboxGroup/index.js";
|
|
5
|
+
import { useFormControl } from "../FormControl/index.js";
|
|
6
|
+
import HiddenInput from "../HiddenInput/index.js";
|
|
9
7
|
import Icon from "../Icon/index.js";
|
|
10
8
|
import Text from "../Text/index.js";
|
|
9
|
+
import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
|
|
11
10
|
import IconCheckmark from "../../icons/Checkmark.js";
|
|
11
|
+
import { classNames, responsiveClassNames, responsivePropDependency } from "../../utilities/props.js";
|
|
12
12
|
import s from "./Checkbox.module.css";
|
|
13
13
|
const Checkbox = (props) => {
|
|
14
14
|
const { children, value, onChange, onFocus, onBlur, indeterminate, size = "medium", className, attributes, inputAttributes, } = props;
|
|
@@ -21,20 +21,10 @@ const Checkbox = (props) => {
|
|
|
21
21
|
const name = checkboxGroup ? checkboxGroup.name : props.name;
|
|
22
22
|
const inputRef = React.useRef(null);
|
|
23
23
|
const rootClassName = classNames(s.root, className, size && hasError && s["--error"], disabled && s["--disabled"], size && responsiveClassNames(s, "--size", size));
|
|
24
|
-
const handleChange = (event) => {
|
|
25
|
-
if (!name)
|
|
26
|
-
return;
|
|
27
|
-
const { checked } = event.target;
|
|
28
|
-
const changeArgs = { name, value, checked, event };
|
|
29
|
-
if (onChange)
|
|
30
|
-
onChange(changeArgs);
|
|
31
|
-
if (checkboxGroup?.onChange)
|
|
32
|
-
checkboxGroup.onChange(changeArgs);
|
|
33
|
-
};
|
|
34
24
|
useIsomorphicLayoutEffect(() => {
|
|
35
25
|
inputRef.current.indeterminate = indeterminate || false;
|
|
36
26
|
}, [indeterminate, checked]);
|
|
37
|
-
return (_jsxs("label", { ...attributes, className: rootClassName, children: [_jsxs("span", { className: s.field, children: [_jsx(HiddenInput, { className: s.input, type: "checkbox", checked: checked, defaultChecked: defaultChecked, name: name, disabled: disabled, value: value, onChange:
|
|
27
|
+
return (_jsxs("label", { ...attributes, className: rootClassName, children: [_jsxs("span", { className: s.field, children: [_jsx(HiddenInput, { className: s.input, type: "checkbox", checked: checked, defaultChecked: defaultChecked, name: name, disabled: disabled, value: value, onChange: onChange, onFocus: onFocus, onBlur: onBlur, attributes: {
|
|
38
28
|
...inputAttributes,
|
|
39
29
|
ref: inputRef,
|
|
40
30
|
} }), _jsx("div", { className: s.decorator, children: _jsx(Icon, { svg: IconCheckmark, className: s.icon, size: responsivePropDependency(size, (size) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { classNames } from "../../utilities/props.js";
|
|
3
2
|
import View from "../View/index.js";
|
|
3
|
+
import { classNames } from "../../utilities/props.js";
|
|
4
4
|
import s from "./Container.module.css";
|
|
5
5
|
const Container = (props) => {
|
|
6
6
|
const { children, padding = 4, width, align, justify, height, maxHeight, className, attributes, } = props;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type React from "react";
|
|
2
1
|
import type { ViewProps } from "../View";
|
|
2
|
+
import type React from "react";
|
|
3
3
|
import type * as G from "../../types/global";
|
|
4
4
|
export type Props = Pick<ViewProps, "align" | "justify" | "height" | "maxHeight"> & {
|
|
5
5
|
/** Component inline padding */
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import DropdownMenu from "../DropdownMenu/index.js";
|
|
5
|
+
import useHandlerRef from "../../hooks/useHandlerRef.js";
|
|
5
6
|
import useScrollLock from "../../hooks/useScrollLock.js";
|
|
6
7
|
import s from "./ContextMenu.module.css";
|
|
7
|
-
import useHandlerRef from "../../hooks/useHandlerRef.js";
|
|
8
8
|
const ContextMenu = (props) => {
|
|
9
9
|
const { position = "end-top", onOpen, onClose, ...dropdownMenuProps } = props;
|
|
10
10
|
const [coordinates, setCoordinates] = React.useState();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { classNames } from "../../utilities/props.js";
|
|
4
3
|
import Button from "../Button/index.js";
|
|
5
4
|
import IconClose from "../../icons/Close.js";
|
|
5
|
+
import { classNames } from "../../utilities/props.js";
|
|
6
6
|
import s from "./Dismissible.module.css";
|
|
7
7
|
const Dismissible = (props) => {
|
|
8
8
|
const { children, align, onClose, hideCloseButton, variant, closeAriaLabel, className, attributes, } = props;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { classNames, responsiveClassNames } from "../../utilities/props.js";
|
|
3
2
|
import Text from "../Text/index.js";
|
|
3
|
+
import { classNames, responsiveClassNames } from "../../utilities/props.js";
|
|
4
4
|
import s from "./Divider.module.css";
|
|
5
5
|
const Divider = (props) => {
|
|
6
6
|
const { vertical, blank, children, contentPosition = "center", color, offset, className, attributes, } = props;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import Popover from "../Popover/index.js";
|
|
5
|
-
import MenuItem from "../MenuItem/index.js";
|
|
6
|
-
import Icon from "../Icon/index.js";
|
|
7
4
|
import { useFlyoutContext } from "../Flyout/index.js";
|
|
8
|
-
import
|
|
5
|
+
import Icon from "../Icon/index.js";
|
|
6
|
+
import MenuItem from "../MenuItem/index.js";
|
|
7
|
+
import Popover from "../Popover/index.js";
|
|
8
|
+
import * as keys from "../../constants/keys.js";
|
|
9
9
|
import useHotkeys from "../../hooks/useHotkeys.js";
|
|
10
10
|
import useRTL from "../../hooks/useRTL.js";
|
|
11
|
+
import IconChevronRight from "../../icons/ChevronRight.js";
|
|
11
12
|
import { classNames } from "../../utilities/props.js";
|
|
12
|
-
import * as keys from "../../constants/keys.js";
|
|
13
13
|
import s from "./DropdownMenu.module.css";
|
|
14
14
|
const DropdownMenuSubContext = React.createContext(null);
|
|
15
15
|
const DropdownMenuSubTriggerContext = React.createContext(false);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type React from "react";
|
|
2
|
-
import type { PopoverProps, PopoverInstance } from "../Popover";
|
|
3
|
-
import type { MenuItemProps } from "../MenuItem";
|
|
4
1
|
import type { FlyoutContentProps } from "../Flyout";
|
|
2
|
+
import type { MenuItemProps } from "../MenuItem";
|
|
3
|
+
import type { PopoverProps, PopoverInstance } from "../Popover";
|
|
4
|
+
import type React from "react";
|
|
5
5
|
export type Instance = PopoverInstance;
|
|
6
|
-
export type Props = Pick<PopoverProps, "children" | "position" | "forcePosition" | "fallbackPositions" | "fallbackAdjustLayout" | "fallbackMinWidth" | "fallbackMinHeight" | "triggerType" | "contentGap" | "contentShift" | "onOpen" | "onClose" | "active" | "defaultActive" | "width" | "disableHideAnimation" | "disableCloseOnOutsideClick" | "instanceRef" | "containerRef" | "positionRef" | "originCoordinates" | "borderRadius" | "elevation" | "initialFocusRef"> & {
|
|
6
|
+
export type Props = Pick<PopoverProps, "children" | "position" | "forcePosition" | "fallbackPositions" | "fallbackAdjustLayout" | "fallbackMinWidth" | "fallbackMinHeight" | "triggerType" | "contentGap" | "contentShift" | "contentMaxHeight" | "onOpen" | "onClose" | "active" | "defaultActive" | "width" | "disableHideAnimation" | "disableCloseOnOutsideClick" | "instanceRef" | "containerRef" | "positionRef" | "originCoordinates" | "borderRadius" | "elevation" | "initialFocusRef"> & {
|
|
7
7
|
/** Change component trap focus keyboard behavior and shortcuts */
|
|
8
8
|
trapFocusMode?: Extract<PopoverProps["trapFocusMode"], "action-menu" | "selection-menu"> | false;
|
|
9
9
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { classNames } from "../../utilities/props.js";
|
|
4
|
-
import View from "../View/index.js";
|
|
5
3
|
import HiddenVisually from "../HiddenVisually/index.js";
|
|
4
|
+
import View from "../View/index.js";
|
|
6
5
|
import useToggle from "../../hooks/useToggle.js";
|
|
6
|
+
import { classNames } from "../../utilities/props.js";
|
|
7
7
|
import s from "./FileUpload.module.css";
|
|
8
8
|
export const FileUploadTrigger = (props) => {
|
|
9
9
|
const { children } = props;
|
|
10
10
|
return _jsx("span", { className: s.trigger, children: children });
|
|
11
11
|
};
|
|
12
12
|
const FileUpload = (props) => {
|
|
13
|
-
const { name, children, height, variant = "outline", inline, className, attributes, inputAttributes, onChange, } = props;
|
|
13
|
+
const { name, children, height, variant = "outline", inline, className, disabled, attributes, inputAttributes, onChange, } = props;
|
|
14
14
|
const highlightToggle = useToggle();
|
|
15
|
-
const rootClassNames = classNames(s.root, variant && s[`--variant-${variant}`], inline && s[`--inline`], highlightToggle.active && s["--highlighted"], className);
|
|
15
|
+
const rootClassNames = classNames(s.root, variant && s[`--variant-${variant}`], inline && s[`--inline`], highlightToggle.active && s["--highlighted"], disabled && s["--disabled"], className);
|
|
16
16
|
const handleDragOver = (event) => {
|
|
17
17
|
event.preventDefault();
|
|
18
18
|
attributes?.onDragOver?.(event);
|
|
@@ -41,15 +41,17 @@ const FileUpload = (props) => {
|
|
|
41
41
|
onChange?.({ name, event, value: Array.from(nextValue) });
|
|
42
42
|
inputAttributes?.onChange?.(event);
|
|
43
43
|
};
|
|
44
|
-
const inputNode = (_jsx(HiddenVisually, { children: _jsx("input", { ...inputAttributes, type: "file", className: s.field, name: name, onChange: handleChange }) }));
|
|
44
|
+
const inputNode = (_jsx(HiddenVisually, { children: _jsx("input", { ...inputAttributes, type: "file", className: s.field, name: name, disabled: disabled, onChange: handleChange }) }));
|
|
45
45
|
const childrenNode = typeof children === "function" ? children({ highlighted: highlightToggle.active }) : children;
|
|
46
|
-
return (_jsx(View, { className: rootClassNames, height: height,
|
|
46
|
+
return (_jsx(View, { className: rootClassNames, height: height,
|
|
47
|
+
// For the focus ring radius
|
|
48
|
+
borderRadius: "medium", attributes: {
|
|
47
49
|
...attributes,
|
|
48
50
|
onDragOver: handleDragOver,
|
|
49
51
|
onDragEnter: handleDragEnter,
|
|
50
52
|
onDragLeave: handleDragLeave,
|
|
51
53
|
onDrop: handleDrop,
|
|
52
|
-
}, children: variant === "outline" && !inline ? (_jsxs(View, { as: "label", className: s.triggerLayer, padding: 6, borderRadius: "medium", gap: 2, align: "center", justify: "center", textAlign: "center",
|
|
54
|
+
}, children: variant === "outline" && !inline ? (_jsxs(View, { as: "label", className: s.triggerLayer, padding: 6, borderRadius: "medium", gap: 2, align: "center", justify: "center", textAlign: "center", height: "100%", children: [inputNode, _jsx(View.Item, { children: childrenNode })] })) : (_jsxs("label", { className: s.triggerLayer, children: [inputNode, childrenNode] })) }));
|
|
53
55
|
};
|
|
54
56
|
FileUpload.displayName = "FileUpload";
|
|
55
57
|
FileUploadTrigger.displayName = "FileUpload.Trigger";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.root{--rs-file-upload-radius:var(--rs-radius-medium);display:block}[data-rs-keyboard] .root:focus-within{box-shadow:var(--rs-shadow-focus)}.--inline{--rs-file-upload-radius:var(--rs-radius-small)}.--inline,.--inline .triggerLayer{display:inline-block;vertical-align:top}[data-rs-keyboard] .--inline:focus-within{box-shadow:none}[data-rs-keyboard] .--inline:focus-within .triggerLayer>*{box-shadow:var(--rs-shadow-focus)}.--variant-outline .triggerLayer{border:1px dashed var(--rs-
|
|
1
|
+
.root{--rs-file-upload-radius:var(--rs-radius-medium);--rs-file-upload-border-color:var(--rs-color-border-neutral);--rs-file-upload-hover-background-color:rgba(var(--rs-color-rgb-background-neutral),0.16);display:block}[data-rs-keyboard] .root:focus-within{box-shadow:var(--rs-shadow-focus)}.triggerLayer:has(.trigger){pointer-events:none}.triggerLayer:has(.trigger) .trigger,.triggerLayer:has(.trigger) a,.triggerLayer:has(.trigger) button{pointer-events:all}.trigger{display:contents}.--inline{--rs-file-upload-radius:var(--rs-radius-small)}.--inline,.--inline .triggerLayer{display:inline-block;vertical-align:top}[data-rs-keyboard] .--inline:focus-within{box-shadow:none}[data-rs-keyboard] .--inline:focus-within .triggerLayer>*{box-shadow:var(--rs-shadow-focus)}.--variant-outline .triggerLayer{border:1px dashed var(--rs-file-upload-border-color);border-radius:var(--rs-file-upload-radius);transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:background-color,border-color}.--highlighted.--variant-outline .triggerLayer{background:rgba(var(--rs-color-rgb-background-primary),.08);border-color:var(--rs-color-border-primary)}@media (hover:hover) and (pointer:fine){.--variant-outline .triggerLayer:hover:not(:has(.trigger)){background:var(--rs-file-upload-hover-background-color)}}.--disabled{--rs-file-upload-border-color:var(--rs-color-border-disabled);--rs-file-upload-hover-background-color:transparent}.--disabled .triggerLayer{cursor:not-allowed;opacity:.4}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type React from "react";
|
|
2
1
|
import type { ViewProps } from "../View";
|
|
2
|
+
import type React from "react";
|
|
3
3
|
import type * as G from "../../types/global";
|
|
4
4
|
export type Props = {
|
|
5
5
|
/** Name of the input element */
|
|
6
6
|
name: string;
|
|
7
|
+
/** Disable the file upload input */
|
|
8
|
+
disabled?: boolean;
|
|
7
9
|
/** Node for inserting children, can be a render function that receives component state */
|
|
8
10
|
children?: React.ReactNode | ((props: {
|
|
9
11
|
highlighted?: boolean;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type * as T from "./Flyout.types";
|
|
2
1
|
export declare const mouseEnter = 600;
|
|
3
|
-
export declare const defaultStyles:
|
|
4
|
-
export declare const resetStyles:
|
|
2
|
+
export declare const defaultStyles: React.CSSProperties;
|
|
3
|
+
export declare const resetStyles: React.CSSProperties;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import FlyoutUncontrolled from "./FlyoutUncontrolled.js";
|
|
3
2
|
import FlyoutControlled from "./FlyoutControlled.js";
|
|
3
|
+
import FlyoutUncontrolled from "./FlyoutUncontrolled.js";
|
|
4
4
|
const Flyout = (props) => {
|
|
5
5
|
const { active } = props;
|
|
6
6
|
if (typeof active === "boolean")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.content{--rs-flyout-gap:0;--rs-flyout-origin-x:50%;--rs-flyout-origin-y:50%;isolation:isolate;pointer-events:none;position:absolute}.content.--hover{pointer-events:all}.content.--hover-disabled,.content.--hover-disabled .inner{pointer-events:none}.inner{backface-visibility:hidden;height:100%;max-height:
|
|
1
|
+
.content{--rs-flyout-gap:0;--rs-flyout-max-h:100%;--rs-flyout-origin-x:50%;--rs-flyout-origin-y:50%;display:flex;flex-direction:column;isolation:isolate;pointer-events:none;position:absolute}.content.--hover{pointer-events:all}.content.--hover-disabled,.content.--hover-disabled .inner{pointer-events:none}.inner{backface-visibility:hidden;flex-grow:1;height:100%;max-height:var(--rs-flyout-max-h);max-width:100%;opacity:0;outline:none;overflow:auto;pointer-events:all;transform:scale(.92) translateY(0);transform-origin:var(--rs-flyout-origin-x) var(--rs-flyout-origin-y);transition:1ms var(--rs-easing-accelerate)}[data-rs-keyboard] .inner:focus{box-shadow:var(--rs-shadow-focus)}.content.--width-trigger .inner{transform:scale(1) translateY(var(--rs-unit-x2))}.content.--position-top,.content.--position-top-end,.content.--position-top-start{--rs-flyout-origin-y:100%;padding-bottom:calc(var(--rs-unit-x1) * var(--rs-flyout-gap))}.content.--position-bottom,.content.--position-bottom-end,.content.--position-bottom-start{--rs-flyout-origin-y:0%;padding-top:calc(var(--rs-unit-x1) * var(--rs-flyout-gap))}.content.--position-bottom-start,.content.--position-top-start{--rs-flyout-origin-x:0%}.content.--position-bottom-end,.content.--position-top-end{--rs-flyout-origin-x:100%}.content.--position-start,.content.--position-start-bottom,.content.--position-start-top{--rs-flyout-origin-x:100%;padding-right:calc(var(--rs-unit-x1) * var(--rs-flyout-gap))}.content.--position-end,.content.--position-end-bottom,.content.--position-end-top{--rs-flyout-origin-x:0%;padding-left:calc(var(--rs-unit-x1) * var(--rs-flyout-gap))}.content.--position-end-top,.content.--position-start-top{--rs-flyout-origin-y:0%}.content.--position-end-bottom,.content.--position-start-bottom{--rs-flyout-origin-y:100%}.content.--visible .inner{opacity:1;transform:scale(1) translateY(0)}.content.--animated .inner{transition-duration:var(--rs-duration-rapid);transition-property:opacity,transform}.content.--animated.--visible .inner{transition-duration:var(--rs-duration-fast);transition-timing-function:var(--rs-easing-decelerate)}
|
|
@@ -23,17 +23,14 @@ export type Options = Pick<BaseProps, "width" | "fallbackAdjustLayout" | "fallba
|
|
|
23
23
|
lastUsedPosition: Position;
|
|
24
24
|
onPositionChoose: (position: Position) => void;
|
|
25
25
|
};
|
|
26
|
-
export type Styles = React.CSSProperties;
|
|
27
26
|
export type State = {
|
|
28
|
-
styles: Styles;
|
|
29
27
|
position?: Position;
|
|
30
28
|
status: "idle" | "rendered" | "positioned" | "visible" | "hidden";
|
|
31
29
|
};
|
|
32
30
|
export type FlyoutData = {
|
|
33
|
-
styles: Styles;
|
|
34
31
|
position: Position;
|
|
35
32
|
};
|
|
36
|
-
export type UseFlyoutData = Pick<State, "
|
|
33
|
+
export type UseFlyoutData = Pick<State, "position" | "status"> & {
|
|
37
34
|
updatePosition: (args?: {
|
|
38
35
|
sync?: boolean;
|
|
39
36
|
fallback?: boolean;
|
|
@@ -72,7 +69,7 @@ export type TriggerAttributes = {
|
|
|
72
69
|
onFocus?: () => void;
|
|
73
70
|
onMouseDown?: () => void;
|
|
74
71
|
onMouseEnter?: () => void;
|
|
75
|
-
onMouseLeave?: () => void;
|
|
72
|
+
onMouseLeave?: (e: React.MouseEvent) => void;
|
|
76
73
|
onTouchStart?: () => void;
|
|
77
74
|
onClick?: () => void;
|
|
78
75
|
"aria-describedby"?: string;
|
|
@@ -132,6 +129,8 @@ type BaseProps = {
|
|
|
132
129
|
contentGap?: number;
|
|
133
130
|
/** Shift the content on the secondary axis, relative to its original position */
|
|
134
131
|
contentShift?: number;
|
|
132
|
+
/** Maximum height for the content */
|
|
133
|
+
contentMaxHeight?: string;
|
|
135
134
|
/** Additional classname for the content element */
|
|
136
135
|
contentClassName?: string;
|
|
137
136
|
/** Additional attributes for the content element */
|
|
@@ -178,7 +177,7 @@ export type ContextProps = {
|
|
|
178
177
|
}) => void;
|
|
179
178
|
handleOpen: () => void;
|
|
180
179
|
handleMouseEnter: () => void;
|
|
181
|
-
handleMouseLeave: () => void;
|
|
180
|
+
handleMouseLeave: (e: React.MouseEvent) => void;
|
|
182
181
|
handleMouseDown: () => void;
|
|
183
182
|
handleTransitionEnd: (e: React.TransitionEvent) => void;
|
|
184
183
|
handleTransitionStart: (e: TransitionEvent) => void;
|
|
@@ -189,7 +188,7 @@ export type ContextProps = {
|
|
|
189
188
|
handleContentMouseDown: () => void;
|
|
190
189
|
handleContentMouseUp: () => void;
|
|
191
190
|
isSubmenu: boolean;
|
|
192
|
-
} & Pick<Props, "triggerType" | "contentClassName" | "contentAttributes" | "contentGap" | "trapFocusMode" | "containerRef" | "disableContentHover" | "autoFocus">;
|
|
191
|
+
} & Pick<Props, "triggerType" | "contentClassName" | "contentAttributes" | "contentGap" | "contentMaxHeight" | "trapFocusMode" | "containerRef" | "disableContentHover" | "autoFocus">;
|
|
193
192
|
export type TriggerContextProps = {
|
|
194
193
|
elRef?: ContextProps["triggerElRef"];
|
|
195
194
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { classNames } from "../../utilities/props.js";
|
|
5
|
-
import { rafThrottle } from "../../utilities/helpers.js";
|
|
6
|
-
import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
|
|
7
4
|
import Portal from "../_private/Portal/index.js";
|
|
5
|
+
import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
|
|
8
6
|
import { findClosestPositionContainer, findClosestScrollableContainer } from "../../utilities/dom/index.js";
|
|
9
|
-
import
|
|
7
|
+
import { rafThrottle } from "../../utilities/helpers.js";
|
|
8
|
+
import { classNames } from "../../utilities/props.js";
|
|
10
9
|
import { useFlyoutContext, ContentProvider } from "./Flyout.context.js";
|
|
11
10
|
import s from "./Flyout.module.css";
|
|
11
|
+
import cooldown from "./utilities/cooldown.js";
|
|
12
12
|
const FlyoutContent = (props) => {
|
|
13
13
|
const { children, className, attributes } = props;
|
|
14
|
-
const { flyout, id, flyoutElRef, triggerElRef, handleClose, handleTransitionEnd, handleTransitionStart, triggerType, handleMouseEnter, handleMouseLeave, handleContentMouseDown, handleContentMouseUp, contentClassName, contentAttributes, contentGap, trapFocusMode, disableContentHover, autoFocus, width, containerRef: passedContainerRef, isSubmenu, } = useFlyoutContext();
|
|
15
|
-
const {
|
|
14
|
+
const { flyout, id, flyoutElRef, triggerElRef, handleClose, handleTransitionEnd, handleTransitionStart, triggerType, handleMouseEnter, handleMouseLeave, handleContentMouseDown, handleContentMouseUp, contentClassName, contentAttributes, contentGap, contentMaxHeight, trapFocusMode, disableContentHover, autoFocus, width, containerRef: passedContainerRef, isSubmenu, } = useFlyoutContext();
|
|
15
|
+
const { status, position } = flyout;
|
|
16
16
|
const [mounted, setMounted] = React.useState(false);
|
|
17
17
|
const closestFixedContainer = React.useMemo(() => {
|
|
18
18
|
if (!mounted)
|
|
@@ -95,8 +95,8 @@ const FlyoutContent = (props) => {
|
|
|
95
95
|
role = "menubar";
|
|
96
96
|
}
|
|
97
97
|
const content = (_jsx(ContentProvider, { value: { elRef: flyoutElRef }, children: _jsx("div", { className: rootClassNames, style: {
|
|
98
|
-
...styles,
|
|
99
98
|
"--rs-flyout-gap": contentGap,
|
|
99
|
+
"--rs-flyout-max-h": contentMaxHeight,
|
|
100
100
|
}, ref: flyoutElRef, onTransitionEnd: handleTransitionEnd, onMouseEnter: triggerType === "hover" ? handleMouseEnter : undefined, onMouseLeave: triggerType === "hover" ? handleMouseLeave : undefined, onMouseDown: handleContentMouseDown, onTouchStart: handleContentMouseDown, onMouseUp: handleContentMouseUp, onTouchEnd: handleContentMouseUp, children: _jsx("div", { role: role, ...attributes, id: id, tabIndex: !autoFocus ? -1 : undefined, "aria-modal": role === "dialog" ? true : undefined, style: { ...attributes?.style, ...contentAttributes?.style }, className: innerClassNames, children: children }) }) }));
|
|
101
101
|
return _jsx(Portal, { targetRef: containerRef, children: content });
|
|
102
102
|
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { TrapFocus, checkKeyboardMode } from "../../utilities/a11y/index.js";
|
|
5
4
|
import useIsDismissible from "../../hooks/_private/useIsDismissible.js";
|
|
6
5
|
import useElementId from "../../hooks/useElementId.js";
|
|
7
|
-
import
|
|
6
|
+
import useHandlerRef from "../../hooks/useHandlerRef.js";
|
|
8
7
|
import useHotkeys from "../../hooks/useHotkeys.js";
|
|
8
|
+
import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
|
|
9
9
|
import useOnClickOutside from "../../hooks/useOnClickOutside.js";
|
|
10
10
|
import useRTL from "../../hooks/useRTL.js";
|
|
11
|
+
import { TrapFocus, checkKeyboardMode } from "../../utilities/a11y/index.js";
|
|
11
12
|
import { checkTransitions, onNextFrame } from "../../utilities/animation.js";
|
|
12
|
-
import useFlyout from "./useFlyout.js";
|
|
13
13
|
import * as timeouts from "./Flyout.constants.js";
|
|
14
|
-
import cooldown from "./utilities/cooldown.js";
|
|
15
14
|
import { Provider, useFlyoutTriggerContext, useFlyoutContext, useFlyoutContentContext, } from "./Flyout.context.js";
|
|
16
|
-
import
|
|
15
|
+
import useFlyout from "./useFlyout.js";
|
|
16
|
+
import cooldown from "./utilities/cooldown.js";
|
|
17
17
|
const FlyoutControlled = (props) => {
|
|
18
|
-
const { triggerType = "click", groupTimeouts, onOpen, onClose, children, disabled, forcePosition, fallbackAdjustLayout, fallbackMinWidth, fallbackMinHeight, trapFocusMode = "dialog", width, disableHideAnimation, disableContentHover, disableCloseOnOutsideClick, autoFocus = true, originCoordinates, contentGap = 2, contentShift, contentClassName, contentAttributes, position: passedPosition, active: passedActive, id: passedId, instanceRef, containerRef, initialFocusRef, positionRef, } = props;
|
|
18
|
+
const { triggerType = "click", groupTimeouts, onOpen, onClose, children, disabled, forcePosition, fallbackAdjustLayout, fallbackMinWidth, fallbackMinHeight, trapFocusMode = "dialog", width, disableHideAnimation, disableContentHover, disableCloseOnOutsideClick, autoFocus = true, originCoordinates, contentGap = 2, contentShift, contentMaxHeight, contentClassName, contentAttributes, position: passedPosition, active: passedActive, id: passedId, instanceRef, containerRef, initialFocusRef, positionRef, } = props;
|
|
19
19
|
const fallbackPositions = props.fallbackPositions === false || forcePosition ? [] : props.fallbackPositions;
|
|
20
20
|
const onOpenRef = useHandlerRef(onOpen);
|
|
21
21
|
const onCloseRef = useHandlerRef(onClose);
|
|
@@ -146,11 +146,15 @@ const FlyoutControlled = (props) => {
|
|
|
146
146
|
}, groupTimeouts && cooldown.status === "warming" ? timeouts.mouseEnter : 0);
|
|
147
147
|
}
|
|
148
148
|
}, [clearTimer, handleOpen, groupTimeouts]);
|
|
149
|
-
const handleMouseLeave = React.useCallback(() => {
|
|
149
|
+
const handleMouseLeave = React.useCallback((e) => {
|
|
150
|
+
if (e.relatedTarget === flyoutElRef.current)
|
|
151
|
+
return;
|
|
152
|
+
if (e.relatedTarget === triggerElRef.current)
|
|
153
|
+
return;
|
|
150
154
|
cooldown.cool();
|
|
151
155
|
clearTimer();
|
|
152
156
|
handleClose({});
|
|
153
|
-
}, [clearTimer, handleClose]);
|
|
157
|
+
}, [clearTimer, handleClose, triggerElRef, flyoutElRef]);
|
|
154
158
|
const handleTriggerClick = React.useCallback(() => {
|
|
155
159
|
if (!isRendered) {
|
|
156
160
|
handleOpen();
|
|
@@ -305,7 +309,7 @@ const FlyoutControlled = (props) => {
|
|
|
305
309
|
shouldReturnFocusRef.current = false;
|
|
306
310
|
handleClose({ reason: "outside-click" });
|
|
307
311
|
}, {
|
|
308
|
-
disabled:
|
|
312
|
+
disabled: !isRendered || disableCloseOnOutsideClick,
|
|
309
313
|
});
|
|
310
314
|
return (_jsx(Provider, { value: {
|
|
311
315
|
id,
|
|
@@ -331,6 +335,7 @@ const FlyoutControlled = (props) => {
|
|
|
331
335
|
contentClassName,
|
|
332
336
|
contentAttributes,
|
|
333
337
|
contentGap,
|
|
338
|
+
contentMaxHeight,
|
|
334
339
|
containerRef,
|
|
335
340
|
disableContentHover,
|
|
336
341
|
autoFocus,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Flyout from "./Flyout";
|
|
2
|
-
import FlyoutTrigger from "./FlyoutTrigger";
|
|
3
2
|
import FlyoutContent from "./FlyoutContent";
|
|
3
|
+
import FlyoutTrigger from "./FlyoutTrigger";
|
|
4
4
|
declare const FlyoutRoot: typeof Flyout & {
|
|
5
5
|
Trigger: typeof FlyoutTrigger;
|
|
6
6
|
Content: typeof FlyoutContent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Flyout from "./Flyout.js";
|
|
2
|
-
import FlyoutTrigger from "./FlyoutTrigger.js";
|
|
3
2
|
import FlyoutContent from "./FlyoutContent.js";
|
|
3
|
+
import FlyoutTrigger from "./FlyoutTrigger.js";
|
|
4
4
|
const FlyoutRoot = Flyout;
|
|
5
5
|
FlyoutRoot.Trigger = FlyoutTrigger;
|
|
6
6
|
FlyoutRoot.Content = FlyoutContent;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type * as G from "../../types/global";
|
|
3
2
|
import type * as T from "./Flyout.types";
|
|
3
|
+
import type * as G from "../../types/global";
|
|
4
4
|
type UseFlyout = (args: Pick<T.Props, "width" | "position" | "defaultActive" | "fallbackAdjustLayout" | "fallbackMinWidth" | "fallbackMinHeight" | "contentGap" | "contentShift"> & {
|
|
5
5
|
fallbackPositions?: T.Position[];
|
|
6
6
|
container?: HTMLElement | null;
|
|
7
7
|
triggerElRef: React.RefObject<HTMLElement | null>;
|
|
8
8
|
flyoutElRef: React.RefObject<HTMLElement | null>;
|
|
9
9
|
triggerBounds?: DOMRect | G.Coordinates | null;
|
|
10
|
-
}) => Pick<T.State, "
|
|
10
|
+
}) => Pick<T.State, "position" | "status"> & {
|
|
11
11
|
updatePosition: (options?: {
|
|
12
12
|
sync?: boolean;
|
|
13
13
|
}) => void;
|