@salt-ds/lab 1.0.0-alpha.33 → 1.0.0-alpha.34
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/css/salt-lab.css +106 -223
- package/dist-cjs/calendar/Calendar.css.js +1 -1
- package/dist-cjs/calendar/internal/CalendarCarousel.css.js +1 -1
- package/dist-cjs/calendar/internal/CalendarCarousel.js +5 -29
- package/dist-cjs/calendar/internal/CalendarCarousel.js.map +1 -1
- package/dist-cjs/calendar/internal/CalendarContext.js.map +1 -1
- package/dist-cjs/calendar/internal/CalendarDay.css.js +1 -1
- package/dist-cjs/calendar/internal/CalendarDay.js +18 -19
- package/dist-cjs/calendar/internal/CalendarDay.js.map +1 -1
- package/dist-cjs/calendar/internal/CalendarMonth.css.js +1 -1
- package/dist-cjs/calendar/internal/CalendarMonth.js +0 -2
- package/dist-cjs/calendar/internal/CalendarMonth.js.map +1 -1
- package/dist-cjs/calendar/internal/CalendarNavigation.css.js +1 -1
- package/dist-cjs/calendar/internal/CalendarNavigation.js +74 -81
- package/dist-cjs/calendar/internal/CalendarNavigation.js.map +1 -1
- package/dist-cjs/calendar/internal/CalendarWeekHeader.css.js +1 -1
- package/dist-cjs/calendar/useCalendar.js +14 -8
- package/dist-cjs/calendar/useCalendar.js.map +1 -1
- package/dist-cjs/calendar/useCalendarDay.js +15 -5
- package/dist-cjs/calendar/useCalendarDay.js.map +1 -1
- package/dist-cjs/calendar/useSelection.js.map +1 -1
- package/dist-cjs/combo-box-next/ComboBoxNext.js +36 -13
- package/dist-cjs/combo-box-next/ComboBoxNext.js.map +1 -1
- package/dist-cjs/combo-box-next/useComboBoxNext.js +16 -15
- package/dist-cjs/combo-box-next/useComboBoxNext.js.map +1 -1
- package/dist-cjs/dialog/Dialog.css.js +1 -1
- package/dist-cjs/dialog/DialogHeader.css.js +6 -0
- package/dist-cjs/dialog/DialogHeader.css.js.map +1 -0
- package/dist-cjs/dialog/{DialogTitle.js → DialogHeader.js} +16 -16
- package/dist-cjs/dialog/DialogHeader.js.map +1 -0
- package/dist-cjs/dropdown-next/DropdownNext.js +7 -8
- package/dist-cjs/dropdown-next/DropdownNext.js.map +1 -1
- package/dist-cjs/index.js +2 -6
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/list-control/ListControlContext.js +3 -1
- package/dist-cjs/list-control/ListControlContext.js.map +1 -1
- package/dist-cjs/list-control/ListControlState.js +16 -18
- package/dist-cjs/list-control/ListControlState.js.map +1 -1
- package/dist-cjs/option/Option.css.js +1 -1
- package/dist-cjs/option/Option.js +10 -20
- package/dist-cjs/option/Option.js.map +1 -1
- package/dist-cjs/overlay/Overlay.css.js +1 -1
- package/dist-es/calendar/Calendar.css.js +1 -1
- package/dist-es/calendar/internal/CalendarCarousel.css.js +1 -1
- package/dist-es/calendar/internal/CalendarCarousel.js +5 -29
- package/dist-es/calendar/internal/CalendarCarousel.js.map +1 -1
- package/dist-es/calendar/internal/CalendarContext.js.map +1 -1
- package/dist-es/calendar/internal/CalendarDay.css.js +1 -1
- package/dist-es/calendar/internal/CalendarDay.js +20 -21
- package/dist-es/calendar/internal/CalendarDay.js.map +1 -1
- package/dist-es/calendar/internal/CalendarMonth.css.js +1 -1
- package/dist-es/calendar/internal/CalendarMonth.js +0 -2
- package/dist-es/calendar/internal/CalendarMonth.js.map +1 -1
- package/dist-es/calendar/internal/CalendarNavigation.css.js +1 -1
- package/dist-es/calendar/internal/CalendarNavigation.js +75 -82
- package/dist-es/calendar/internal/CalendarNavigation.js.map +1 -1
- package/dist-es/calendar/internal/CalendarWeekHeader.css.js +1 -1
- package/dist-es/calendar/useCalendar.js +14 -8
- package/dist-es/calendar/useCalendar.js.map +1 -1
- package/dist-es/calendar/useCalendarDay.js +15 -5
- package/dist-es/calendar/useCalendarDay.js.map +1 -1
- package/dist-es/calendar/useSelection.js.map +1 -1
- package/dist-es/combo-box-next/ComboBoxNext.js +36 -13
- package/dist-es/combo-box-next/ComboBoxNext.js.map +1 -1
- package/dist-es/combo-box-next/useComboBoxNext.js +16 -15
- package/dist-es/combo-box-next/useComboBoxNext.js.map +1 -1
- package/dist-es/dialog/Dialog.css.js +1 -1
- package/dist-es/dialog/DialogHeader.css.js +4 -0
- package/dist-es/dialog/DialogHeader.css.js.map +1 -0
- package/dist-es/dialog/{DialogTitle.js → DialogHeader.js} +16 -16
- package/dist-es/dialog/DialogHeader.js.map +1 -0
- package/dist-es/dropdown-next/DropdownNext.js +8 -9
- package/dist-es/dropdown-next/DropdownNext.js.map +1 -1
- package/dist-es/index.js +1 -3
- package/dist-es/index.js.map +1 -1
- package/dist-es/list-control/ListControlContext.js +3 -1
- package/dist-es/list-control/ListControlContext.js.map +1 -1
- package/dist-es/list-control/ListControlState.js +16 -19
- package/dist-es/list-control/ListControlState.js.map +1 -1
- package/dist-es/option/Option.css.js +1 -1
- package/dist-es/option/Option.js +11 -21
- package/dist-es/option/Option.js.map +1 -1
- package/dist-es/overlay/Overlay.css.js +1 -1
- package/dist-types/calendar/internal/CalendarContext.d.ts +2 -2
- package/dist-types/calendar/internal/CalendarNavigation.d.ts +3 -7
- package/dist-types/calendar/useCalendarDay.d.ts +7 -4
- package/dist-types/calendar/useSelection.d.ts +4 -4
- package/dist-types/combo-box-next/ComboBoxNext.d.ts +7 -10
- package/dist-types/combo-box-next/useComboBoxNext.d.ts +6 -4
- package/dist-types/dialog/DialogHeader.d.ts +22 -0
- package/dist-types/dialog/index.d.ts +1 -1
- package/dist-types/dropdown-next/DropdownNext.d.ts +49 -7
- package/dist-types/index.d.ts +0 -1
- package/dist-types/list-control/ListControlContext.d.ts +1 -1
- package/dist-types/list-control/ListControlState.d.ts +14 -12
- package/dist-types/option/Option.d.ts +0 -4
- package/package.json +2 -2
- package/dist-cjs/dialog/DialogTitle.css.js +0 -6
- package/dist-cjs/dialog/DialogTitle.css.js.map +0 -1
- package/dist-cjs/dialog/DialogTitle.js.map +0 -1
- package/dist-cjs/drawer/Drawer.css.js +0 -6
- package/dist-cjs/drawer/Drawer.css.js.map +0 -1
- package/dist-cjs/drawer/Drawer.js +0 -104
- package/dist-cjs/drawer/Drawer.js.map +0 -1
- package/dist-cjs/drawer/DrawerCloseButton.css.js +0 -6
- package/dist-cjs/drawer/DrawerCloseButton.css.js.map +0 -1
- package/dist-cjs/drawer/DrawerCloseButton.js +0 -44
- package/dist-cjs/drawer/DrawerCloseButton.js.map +0 -1
- package/dist-es/dialog/DialogTitle.css.js +0 -4
- package/dist-es/dialog/DialogTitle.css.js.map +0 -1
- package/dist-es/dialog/DialogTitle.js.map +0 -1
- package/dist-es/drawer/Drawer.css.js +0 -4
- package/dist-es/drawer/Drawer.css.js.map +0 -1
- package/dist-es/drawer/Drawer.js +0 -100
- package/dist-es/drawer/Drawer.js.map +0 -1
- package/dist-es/drawer/DrawerCloseButton.css.js +0 -4
- package/dist-es/drawer/DrawerCloseButton.css.js.map +0 -1
- package/dist-es/drawer/DrawerCloseButton.js +0 -36
- package/dist-es/drawer/DrawerCloseButton.js.map +0 -1
- package/dist-types/calendar/useCalendar.d.ts +0 -60
- package/dist-types/dialog/DialogTitle.d.ts +0 -22
- package/dist-types/drawer/Drawer.d.ts +0 -28
- package/dist-types/drawer/DrawerCloseButton.d.ts +0 -2
- package/dist-types/drawer/index.d.ts +0 -2
package/dist-es/option/Option.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef, useRef, useMemo, useEffect
|
|
2
|
+
import { forwardRef, useRef, useMemo, useEffect } from 'react';
|
|
3
3
|
import { makePrefixer, useId, useForkRef, Checkbox } from '@salt-ds/core';
|
|
4
4
|
import { clsx } from 'clsx';
|
|
5
5
|
import { useListControlContext } from '../list-control/ListControlContext.js';
|
|
@@ -8,18 +8,6 @@ import { useComponentCssInjection } from '@salt-ds/styles';
|
|
|
8
8
|
import css_248z from './Option.css.js';
|
|
9
9
|
|
|
10
10
|
const withBaseName = makePrefixer("saltOption");
|
|
11
|
-
function getOptionText(textValue, children) {
|
|
12
|
-
if (textValue) {
|
|
13
|
-
return textValue;
|
|
14
|
-
}
|
|
15
|
-
let textString = "";
|
|
16
|
-
Children.forEach(children, (child) => {
|
|
17
|
-
if (typeof child === "string") {
|
|
18
|
-
textString += child;
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
return textString;
|
|
22
|
-
}
|
|
23
11
|
const Option = forwardRef(function Option2(props, ref) {
|
|
24
12
|
const {
|
|
25
13
|
className,
|
|
@@ -28,7 +16,6 @@ const Option = forwardRef(function Option2(props, ref) {
|
|
|
28
16
|
onClick,
|
|
29
17
|
id: idProp,
|
|
30
18
|
value,
|
|
31
|
-
textValue,
|
|
32
19
|
...rest
|
|
33
20
|
} = props;
|
|
34
21
|
const targetWindow = useWindow();
|
|
@@ -39,7 +26,6 @@ const Option = forwardRef(function Option2(props, ref) {
|
|
|
39
26
|
});
|
|
40
27
|
const optionRef = useRef(null);
|
|
41
28
|
const id = useId(idProp);
|
|
42
|
-
const optionText = getOptionText(textValue, children);
|
|
43
29
|
const {
|
|
44
30
|
setActive,
|
|
45
31
|
activeState,
|
|
@@ -47,7 +33,8 @@ const Option = forwardRef(function Option2(props, ref) {
|
|
|
47
33
|
select,
|
|
48
34
|
register,
|
|
49
35
|
selectedState,
|
|
50
|
-
focusVisibleState
|
|
36
|
+
focusVisibleState,
|
|
37
|
+
valueToString
|
|
51
38
|
} = useListControlContext();
|
|
52
39
|
const selected = selectedState.includes(value);
|
|
53
40
|
const active = (activeState == null ? void 0 : activeState.id) === id;
|
|
@@ -55,10 +42,9 @@ const Option = forwardRef(function Option2(props, ref) {
|
|
|
55
42
|
() => ({
|
|
56
43
|
id: String(id),
|
|
57
44
|
disabled: Boolean(disabled),
|
|
58
|
-
value
|
|
59
|
-
text: optionText
|
|
45
|
+
value
|
|
60
46
|
}),
|
|
61
|
-
[id, disabled, value
|
|
47
|
+
[id, disabled, value]
|
|
62
48
|
);
|
|
63
49
|
const handleClick = (event) => {
|
|
64
50
|
if (disabled || id == void 0) {
|
|
@@ -68,6 +54,9 @@ const Option = forwardRef(function Option2(props, ref) {
|
|
|
68
54
|
select(event, optionValue);
|
|
69
55
|
onClick == null ? void 0 : onClick(event);
|
|
70
56
|
};
|
|
57
|
+
const handleMouseOver = () => {
|
|
58
|
+
setActive(optionValue);
|
|
59
|
+
};
|
|
71
60
|
useEffect(() => {
|
|
72
61
|
if (id && optionRef.current) {
|
|
73
62
|
return register(optionValue, optionRef.current);
|
|
@@ -89,14 +78,15 @@ const Option = forwardRef(function Option2(props, ref) {
|
|
|
89
78
|
role: "option",
|
|
90
79
|
id,
|
|
91
80
|
onClick: handleClick,
|
|
81
|
+
onMouseOver: handleMouseOver,
|
|
92
82
|
...rest,
|
|
93
83
|
children: [
|
|
94
84
|
multiselect && /* @__PURE__ */ jsx(Checkbox, {
|
|
95
85
|
checked: selected,
|
|
96
86
|
"aria-hidden": "true",
|
|
97
|
-
tabIndex: -1
|
|
87
|
+
inputProps: { tabIndex: -1 }
|
|
98
88
|
}),
|
|
99
|
-
children
|
|
89
|
+
children != null ? children : valueToString(value)
|
|
100
90
|
]
|
|
101
91
|
});
|
|
102
92
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Option.js","sources":["../src/option/Option.tsx"],"sourcesContent":["import {\n ComponentPropsWithoutRef,\n forwardRef,\n
|
|
1
|
+
{"version":3,"file":"Option.js","sources":["../src/option/Option.tsx"],"sourcesContent":["import {\n ComponentPropsWithoutRef,\n forwardRef,\n MouseEvent,\n ReactNode,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { Checkbox, makePrefixer, useForkRef, useId } from \"@salt-ds/core\";\nimport { clsx } from \"clsx\";\nimport {\n OptionValue,\n useListControlContext,\n} from \"../list-control/ListControlContext\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport optionCss from \"./Option.css\";\n\nexport interface OptionProps extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * If `true`, the option will be disabled.\n */\n disabled?: boolean;\n /**\n * The value of the option.\n */\n value: unknown;\n /**\n * The content of the option.\n */\n children?: ReactNode;\n}\n\nconst withBaseName = makePrefixer(\"saltOption\");\n\nexport const Option = forwardRef<HTMLDivElement, OptionProps>(function Option(\n props,\n ref\n) {\n const {\n className,\n children,\n disabled,\n onClick,\n id: idProp,\n value,\n ...rest\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-option\",\n css: optionCss,\n window: targetWindow,\n });\n\n const optionRef = useRef(null);\n const id = useId(idProp);\n\n const {\n setActive,\n activeState,\n multiselect,\n select,\n register,\n selectedState,\n focusVisibleState,\n valueToString,\n } = useListControlContext();\n\n const selected = selectedState.includes(value);\n const active = activeState?.id === id;\n\n const optionValue: OptionValue<unknown> = useMemo(\n () => ({\n id: String(id),\n disabled: Boolean(disabled),\n value,\n }),\n [id, disabled, value]\n );\n\n const handleClick = (event: MouseEvent<HTMLDivElement>) => {\n if (disabled || id == undefined) {\n return;\n }\n\n // set active descendent\n setActive(optionValue);\n\n // handle selection\n select(event, optionValue);\n\n onClick?.(event);\n };\n\n const handleMouseOver = () => {\n setActive(optionValue);\n };\n\n useEffect(() => {\n if (id && optionRef.current) {\n return register(optionValue, optionRef.current);\n }\n }, [optionValue, id, register]);\n\n const handleRef = useForkRef(optionRef, ref);\n\n return (\n <div\n aria-disabled={disabled ? \"true\" : undefined}\n aria-selected={selected}\n className={clsx(\n withBaseName(),\n {\n [withBaseName(\"active\")]: active,\n [withBaseName(\"focusVisible\")]: focusVisibleState && active,\n },\n className\n )}\n ref={handleRef}\n role=\"option\"\n id={id}\n onClick={handleClick}\n onMouseOver={handleMouseOver}\n {...rest}\n >\n {multiselect && (\n <Checkbox\n checked={selected}\n aria-hidden=\"true\"\n inputProps={{ tabIndex: -1 }}\n />\n )}\n {children ?? valueToString(value)}\n </div>\n );\n});\n"],"names":["Option","optionCss"],"mappings":";;;;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,oBACE,GAAA,CAAA,QAAA,EAAA;AAAA,QACC,OAAS,EAAA,QAAA;AAAA,QACT,aAAY,EAAA,MAAA;AAAA,QACZ,UAAA,EAAY,EAAE,QAAA,EAAU,CAAG,CAAA,EAAA;AAAA,OAC7B,CAAA;AAAA,MAED,QAAA,IAAA,IAAA,GAAA,QAAA,GAAY,cAAc,KAAK,CAAA;AAAA,KAAA;AAAA,GAClC,CAAA,CAAA;AAEJ,CAAC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var css_248z = ".saltOverlayPanel {\n --overlay-borderColor: var(--saltOverlay-borderColor, var(--salt-container-primary-borderColor));\n --overlay-background: var(--saltOverlay-background, var(--salt-container-primary-background));\n}\n\n.saltOverlayPanel {\n font-family: var(--salt-text-fontFamily);\n font-size: var(--saltOverlay-fontSize, var(--salt-text-fontSize));\n font-weight: var(--saltOverlay-fontWeight, var(--salt-text-fontWeight));\n line-height: var(--saltOverlay-lineHeight, var(--salt-text-lineHeight));\n\n border-color: var(--overlay-borderColor);\n border-style: var(--saltOverlay-borderStyle, var(--salt-container-borderStyle));\n border-width: var(--saltOverlay-borderWidth, var(--salt-size-border));\n\n background: var(--overlay-background);\n box-shadow: var(--saltOverlay-boxShadow, var(--salt-overlayable-shadow-popout));\n\n color: var(--saltOverlay-text-color, var(--salt-text-primary-foreground));\n z-index: var(--saltOverlay-zIndex, var(--salt-zIndex-flyover));\n width: max-content;\n}\n\n.saltOverlayPanelBase-container {\n animation: fade-in var(--salt-duration-perceptible) ease-in-out;\n position: relative;\n}\n\n@keyframes fade-in {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n.saltOverlayPanelBase-content {\n overflow: auto;\n padding: var(--saltOverlay-content-padding, var(--salt-spacing-100) 0 var(--salt-spacing-100) var(--salt-spacing-100));\n}\n\n.saltButton-secondary.saltOverlayPanelBase-closeButton {\n position: sticky;\n top: 0;\n float: right;\n}\n";
|
|
1
|
+
var css_248z = ".saltOverlayPanel {\n --overlay-borderColor: var(--saltOverlay-borderColor, var(--salt-container-primary-borderColor));\n --overlay-background: var(--saltOverlay-background, var(--salt-container-primary-background));\n}\n\n.saltOverlayPanel {\n font-family: var(--salt-text-fontFamily);\n font-size: var(--saltOverlay-fontSize, var(--salt-text-fontSize));\n font-weight: var(--saltOverlay-fontWeight, var(--salt-text-fontWeight));\n line-height: var(--saltOverlay-lineHeight, var(--salt-text-lineHeight));\n\n border-color: var(--overlay-borderColor);\n border-style: var(--saltOverlay-borderStyle, var(--salt-container-borderStyle));\n border-width: var(--saltOverlay-borderWidth, var(--salt-size-border));\n border-radius: var(--saltOverlay-borderRadius, var(--salt-palette-corner, 0));\n\n background: var(--overlay-background);\n box-shadow: var(--saltOverlay-boxShadow, var(--salt-overlayable-shadow-popout));\n\n color: var(--saltOverlay-text-color, var(--salt-text-primary-foreground));\n z-index: var(--saltOverlay-zIndex, var(--salt-zIndex-flyover));\n width: max-content;\n}\n\n.saltOverlayPanelBase-container {\n animation: fade-in var(--salt-duration-perceptible) ease-in-out;\n position: relative;\n}\n\n@keyframes fade-in {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n.saltOverlayPanelBase-content {\n overflow: auto;\n padding: var(--saltOverlay-content-padding, var(--salt-spacing-100) 0 var(--salt-spacing-100) var(--salt-spacing-100));\n}\n\n.saltButton-secondary.saltOverlayPanelBase-closeButton {\n position: sticky;\n top: 0;\n float: right;\n}\n";
|
|
2
2
|
|
|
3
3
|
export { css_248z as default };
|
|
4
4
|
//# sourceMappingURL=Overlay.css.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useCalendar } from "../useCalendar";
|
|
2
|
-
|
|
2
|
+
interface CalendarState {
|
|
3
3
|
state: ReturnType<typeof useCalendar>["state"];
|
|
4
4
|
helpers: ReturnType<typeof useCalendar>["helpers"];
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
6
|
declare const CalendarContext: import("react").Context<CalendarState | null>;
|
|
7
7
|
declare function useCalendarContext(): CalendarState;
|
|
8
8
|
export { CalendarContext, useCalendarContext };
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { ButtonProps } from "@salt-ds/core";
|
|
2
1
|
import { ComponentPropsWithRef } from "react";
|
|
3
|
-
import {
|
|
2
|
+
import { ButtonProps } from "@salt-ds/core";
|
|
3
|
+
import { DropdownNextProps } from "../../dropdown-next";
|
|
4
4
|
import { DateValue } from "@internationalized/date";
|
|
5
|
-
declare type
|
|
6
|
-
value: DateValue;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
};
|
|
9
|
-
declare type dateDropdownProps = DropdownProps<DropdownItem>;
|
|
5
|
+
declare type dateDropdownProps = DropdownNextProps<DateValue>;
|
|
10
6
|
export interface CalendarNavigationProps extends ComponentPropsWithRef<"div"> {
|
|
11
7
|
MonthDropdownProps?: dateDropdownProps;
|
|
12
8
|
YearDropdownProps?: dateDropdownProps;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { DateValue } from "@internationalized/date";
|
|
2
2
|
import { RefObject } from "react";
|
|
3
|
-
export
|
|
3
|
+
export interface DayStatus {
|
|
4
4
|
outOfRange?: boolean;
|
|
5
5
|
selected?: boolean;
|
|
6
6
|
today?: boolean;
|
|
7
|
-
unselectable?:
|
|
7
|
+
unselectable?: string | false;
|
|
8
|
+
highlighted?: string | false;
|
|
8
9
|
focused?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
9
11
|
hidden?: boolean;
|
|
10
|
-
}
|
|
12
|
+
}
|
|
11
13
|
export interface useCalendarDayProps {
|
|
12
14
|
date: DateValue;
|
|
13
15
|
month: DateValue;
|
|
@@ -15,5 +17,6 @@ export interface useCalendarDayProps {
|
|
|
15
17
|
export declare function useCalendarDay({ date, month }: useCalendarDayProps, ref: RefObject<HTMLElement>): {
|
|
16
18
|
status: DayStatus;
|
|
17
19
|
dayProps: Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">;
|
|
18
|
-
unselectableReason: string |
|
|
20
|
+
unselectableReason: string | false | void;
|
|
21
|
+
highlightedReason: string | false | void;
|
|
19
22
|
};
|
|
@@ -10,14 +10,14 @@ interface BaseUseSelectionCalendarProps<SelectionVariantType> {
|
|
|
10
10
|
}
|
|
11
11
|
declare type SingleSelectionValueType = DateValue;
|
|
12
12
|
declare type MultiSelectionValueType = DateValue[];
|
|
13
|
-
|
|
13
|
+
interface RangeSelectionValueType {
|
|
14
14
|
startDate?: DateValue;
|
|
15
15
|
endDate?: DateValue;
|
|
16
|
-
}
|
|
17
|
-
|
|
16
|
+
}
|
|
17
|
+
interface OffsetSelectionValueType {
|
|
18
18
|
startDate?: DateValue;
|
|
19
19
|
endDate?: DateValue;
|
|
20
|
-
}
|
|
20
|
+
}
|
|
21
21
|
export interface UseOffsetSelectionCalendarProps extends Omit<BaseUseSelectionCalendarProps<OffsetSelectionValueType>, "startDateOffset" | "endDateOffset"> {
|
|
22
22
|
selectionVariant: "offset";
|
|
23
23
|
startDateOffset?: (date: DateValue) => DateValue;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { ReactNode, Ref } from "react";
|
|
2
2
|
import { InputProps } from "@salt-ds/core";
|
|
3
|
-
import {
|
|
4
|
-
export
|
|
3
|
+
import { UseComboBoxNextProps } from "./useComboBoxNext";
|
|
4
|
+
export declare type ComboBoxNextProps<Item = string> = {
|
|
5
5
|
/**
|
|
6
6
|
* The options to display in the combo box.
|
|
7
7
|
*/
|
|
8
8
|
children?: ReactNode;
|
|
9
|
+
} & UseComboBoxNextProps<Item> & InputProps;
|
|
10
|
+
export declare const ComboBoxNext: <Item = string>(props: {
|
|
9
11
|
/**
|
|
10
|
-
* The
|
|
11
|
-
*/
|
|
12
|
-
defaultValue?: string | readonly string[] | number | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* The value of the input. The component will be controlled if this prop is provided.
|
|
12
|
+
* The options to display in the combo box.
|
|
15
13
|
*/
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
export declare const ComboBoxNext: <Item = string>(props: ComboBoxNextProps<Item> & {
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
} & import("../list-control/ListControlState").ListControlProps<Item> & Pick<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "defaultValue" | "value"> & InputProps & {
|
|
19
16
|
ref?: Ref<HTMLDivElement> | undefined;
|
|
20
17
|
}) => JSX.Element;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ListControlProps } from "../list-control/ListControlState";
|
|
2
|
-
import { SyntheticEvent } from "react";
|
|
2
|
+
import { ComponentPropsWithoutRef, SyntheticEvent } from "react";
|
|
3
3
|
import { OptionValue } from "../list-control/ListControlContext";
|
|
4
|
-
export declare
|
|
4
|
+
export declare type UseComboBoxNextProps<Item> = ListControlProps<Item> & Pick<ComponentPropsWithoutRef<"input">, "value" | "defaultValue">;
|
|
5
|
+
export declare function useComboBoxNext<Item>(props: UseComboBoxNextProps<Item>): {
|
|
5
6
|
select: (event: SyntheticEvent, option: OptionValue<Item>) => void;
|
|
7
|
+
valueState: string | number | readonly string[] | undefined;
|
|
8
|
+
setValueState: import("react").Dispatch<import("react").SetStateAction<string | number | readonly string[] | undefined>>;
|
|
6
9
|
multiselect: boolean;
|
|
7
10
|
openState: boolean;
|
|
8
11
|
setOpen: (newOpen: boolean, reason?: import("../list-control/ListControlState").OpenChangeReason | undefined, key?: string | undefined) => void;
|
|
@@ -12,8 +15,6 @@ export declare function useComboBoxNext<Item>(props: ListControlProps<Item>): {
|
|
|
12
15
|
selectedState: Item[];
|
|
13
16
|
setSelectedState: import("react").Dispatch<import("react").SetStateAction<Item[]>>;
|
|
14
17
|
clear: (event: SyntheticEvent<Element, Event>) => void;
|
|
15
|
-
valueState: string | number | readonly string[] | undefined;
|
|
16
|
-
setValueState: import("react").Dispatch<import("react").SetStateAction<string | number | readonly string[] | undefined>>;
|
|
17
18
|
focusVisibleState: boolean;
|
|
18
19
|
setFocusVisibleState: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
19
20
|
focusedState: boolean;
|
|
@@ -25,4 +26,5 @@ export declare function useComboBoxNext<Item>(props: ListControlProps<Item>): {
|
|
|
25
26
|
getIndexOfOption: (option: OptionValue<Item>) => number;
|
|
26
27
|
getOptionsMatching: (predicate: (option: OptionValue<Item>) => boolean) => OptionValue<Item>[];
|
|
27
28
|
getOptionFromSearch: (search: string, startFrom?: OptionValue<Item> | undefined) => OptionValue<Item> | undefined;
|
|
29
|
+
valueToString: (item: Item) => string;
|
|
28
30
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactNode, ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import { ValidationStatus } from "@salt-ds/core";
|
|
3
|
+
interface DialogTitleProps extends ComponentPropsWithoutRef<"div"> {
|
|
4
|
+
/**
|
|
5
|
+
* The status of the Dialog
|
|
6
|
+
*/
|
|
7
|
+
status?: ValidationStatus | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Displays the accent bar in the Dialog Title */
|
|
10
|
+
disableAccent?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Displays the header at the top of the Dialog
|
|
13
|
+
*/
|
|
14
|
+
header: ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Displays the preheader just above the header
|
|
17
|
+
**/
|
|
18
|
+
preheader?: ReactNode;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const DialogHeader: ({ className, header, preheader, disableAccent, status: statusProp, ...rest }: DialogTitleProps) => JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef, ReactNode, Ref } from "react";
|
|
2
2
|
import { ListControlProps } from "../list-control/ListControlState";
|
|
3
3
|
import { ValidationStatus } from "@salt-ds/core";
|
|
4
|
-
export
|
|
4
|
+
export declare type DropdownNextProps<Item = string> = {
|
|
5
5
|
/**
|
|
6
6
|
* If `true`, the dropdown will be disabled.
|
|
7
7
|
*/
|
|
@@ -40,18 +40,60 @@ export interface DropdownNextProps<Item = string> extends Omit<ComponentPropsWit
|
|
|
40
40
|
*/
|
|
41
41
|
variant?: "primary" | "secondary";
|
|
42
42
|
/**
|
|
43
|
-
* The
|
|
43
|
+
* The content of the dropdown shown in the button. The component will be controlled if this prop is provided.
|
|
44
|
+
*/
|
|
45
|
+
value?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Validation status, one of "error" | "warning" | "success".
|
|
48
|
+
*/
|
|
49
|
+
validationStatus?: Exclude<ValidationStatus, "info">;
|
|
50
|
+
} & Omit<ComponentPropsWithoutRef<"button">, "value" | "defaultValue"> & ListControlProps<Item>;
|
|
51
|
+
export declare const DropdownNext: <Item = string>(props: {
|
|
52
|
+
/**
|
|
53
|
+
* If `true`, the dropdown will be disabled.
|
|
54
|
+
*/
|
|
55
|
+
disabled?: boolean | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* If `true`, the dropdown will be read-only.
|
|
58
|
+
*/
|
|
59
|
+
readOnly?: boolean | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* The options to display in the dropdown.
|
|
62
|
+
*/
|
|
63
|
+
children?: ReactNode;
|
|
64
|
+
/**
|
|
65
|
+
* The marker to use in an empty read only dropdown.
|
|
66
|
+
* Use `''` to disable this feature. Defaults to '—'.
|
|
67
|
+
*/
|
|
68
|
+
emptyReadOnlyMarker?: string | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* If `true`, the dropdown will be multiselect.
|
|
71
|
+
*/
|
|
72
|
+
multiselect?: boolean | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* The text shown when the dropdown has no value.
|
|
75
|
+
*/
|
|
76
|
+
placeholder?: string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* If `true`, the dropdown will be required.
|
|
44
79
|
*/
|
|
45
|
-
|
|
80
|
+
required?: boolean | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Start adornment component
|
|
83
|
+
*/
|
|
84
|
+
startAdornment?: ReactNode;
|
|
85
|
+
/**
|
|
86
|
+
* Styling variant. Defaults to "primary".
|
|
87
|
+
*/
|
|
88
|
+
variant?: "primary" | "secondary" | undefined;
|
|
46
89
|
/**
|
|
47
90
|
* The content of the dropdown shown in the button. The component will be controlled if this prop is provided.
|
|
48
91
|
*/
|
|
49
|
-
value?: string |
|
|
92
|
+
value?: string | undefined;
|
|
50
93
|
/**
|
|
51
94
|
* Validation status, one of "error" | "warning" | "success".
|
|
52
95
|
*/
|
|
53
|
-
validationStatus?:
|
|
54
|
-
}
|
|
55
|
-
export declare const DropdownNext: <Item = string>(props: DropdownNextProps<Item> & {
|
|
96
|
+
validationStatus?: "error" | "warning" | "success" | undefined;
|
|
97
|
+
} & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "defaultValue" | "value"> & ListControlProps<Item> & {
|
|
56
98
|
ref?: Ref<HTMLButtonElement> | undefined;
|
|
57
99
|
}) => JSX.Element;
|
package/dist-types/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export interface OptionValue<Item> {
|
|
|
3
3
|
id: string;
|
|
4
4
|
disabled: boolean;
|
|
5
5
|
value: Item;
|
|
6
|
-
text: string;
|
|
7
6
|
}
|
|
8
7
|
export declare type OpenChangeReason = "input" | "manual";
|
|
9
8
|
export interface ListControlContextValue<Item> {
|
|
@@ -16,6 +15,7 @@ export interface ListControlContextValue<Item> {
|
|
|
16
15
|
setActive: (option: OptionValue<Item>) => void;
|
|
17
16
|
multiselect: boolean;
|
|
18
17
|
focusVisibleState: boolean;
|
|
18
|
+
valueToString: (item: Item) => string;
|
|
19
19
|
}
|
|
20
20
|
export declare const ListControlContext: import("react").Context<ListControlContextValue<any>>;
|
|
21
21
|
export declare function useListControlContext<Item>(): ListControlContextValue<Item>;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { SyntheticEvent } from "react";
|
|
2
2
|
import { OptionValue } from "./ListControlContext";
|
|
3
3
|
export declare type OpenChangeReason = "input" | "manual";
|
|
4
|
-
export
|
|
4
|
+
export declare type ListControlProps<Item> = {
|
|
5
|
+
/**
|
|
6
|
+
* If true, the control will be disabled.
|
|
7
|
+
*/
|
|
5
8
|
disabled?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* If true, the control will be read-only.
|
|
11
|
+
*/
|
|
6
12
|
readOnly?: boolean;
|
|
7
13
|
/**
|
|
8
14
|
* If true, the list will be open by default.
|
|
@@ -28,19 +34,16 @@ export interface ListControlProps<Item> {
|
|
|
28
34
|
* Callback fired when the selected options change.
|
|
29
35
|
*/
|
|
30
36
|
onSelectionChange?: (event: SyntheticEvent, newSelected: Item[]) => void;
|
|
31
|
-
/**
|
|
32
|
-
* The default value.
|
|
33
|
-
*/
|
|
34
|
-
defaultValue?: string | readonly string[] | number | undefined;
|
|
35
|
-
/**
|
|
36
|
-
* The value. The component will be controlled if this prop is provided.
|
|
37
|
-
*/
|
|
38
|
-
value?: string | readonly string[] | number | undefined;
|
|
39
37
|
/**
|
|
40
38
|
* If true, multiple options can be selected.
|
|
41
39
|
*/
|
|
42
40
|
multiselect?: boolean;
|
|
43
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Callback used to convert an option's `value` to a string. This is needed when the value is different to the display value or the value is not a string.
|
|
43
|
+
*/
|
|
44
|
+
valueToString?: (item: Item) => string;
|
|
45
|
+
};
|
|
46
|
+
export declare function defaultValueToString<Item>(item: Item): string;
|
|
44
47
|
export declare function useListControl<Item>(props: ListControlProps<Item>): {
|
|
45
48
|
multiselect: boolean;
|
|
46
49
|
openState: boolean;
|
|
@@ -52,8 +55,6 @@ export declare function useListControl<Item>(props: ListControlProps<Item>): {
|
|
|
52
55
|
setSelectedState: import("react").Dispatch<import("react").SetStateAction<Item[]>>;
|
|
53
56
|
select: (event: SyntheticEvent, option: OptionValue<Item>) => void;
|
|
54
57
|
clear: (event: SyntheticEvent) => void;
|
|
55
|
-
valueState: string | number | readonly string[] | undefined;
|
|
56
|
-
setValueState: import("react").Dispatch<import("react").SetStateAction<string | number | readonly string[] | undefined>>;
|
|
57
58
|
focusVisibleState: boolean;
|
|
58
59
|
setFocusVisibleState: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
59
60
|
focusedState: boolean;
|
|
@@ -65,4 +66,5 @@ export declare function useListControl<Item>(props: ListControlProps<Item>): {
|
|
|
65
66
|
getIndexOfOption: (option: OptionValue<Item>) => number;
|
|
66
67
|
getOptionsMatching: (predicate: (option: OptionValue<Item>) => boolean) => OptionValue<Item>[];
|
|
67
68
|
getOptionFromSearch: (search: string, startFrom?: OptionValue<Item> | undefined) => OptionValue<Item> | undefined;
|
|
69
|
+
valueToString: (item: Item) => string;
|
|
68
70
|
};
|
|
@@ -8,10 +8,6 @@ export interface OptionProps extends ComponentPropsWithoutRef<"div"> {
|
|
|
8
8
|
* The value of the option.
|
|
9
9
|
*/
|
|
10
10
|
value: unknown;
|
|
11
|
-
/**
|
|
12
|
-
* The text value of the option. If not provided, the text value will be inferred from the children.
|
|
13
|
-
*/
|
|
14
|
-
textValue?: string;
|
|
15
11
|
/**
|
|
16
12
|
* The content of the option.
|
|
17
13
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salt-ds/lab",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.34",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react-window": "^1.8.6",
|
|
27
27
|
"rifm": "^0.12.0",
|
|
28
28
|
"tinycolor2": "^1.4.2",
|
|
29
|
-
"@salt-ds/core": "^1.
|
|
29
|
+
"@salt-ds/core": "^1.19.0",
|
|
30
30
|
"@salt-ds/window": "^0.1.1",
|
|
31
31
|
"@salt-ds/styles": "^0.2.1",
|
|
32
32
|
"@salt-ds/icons": "^1.9.1"
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var css_248z = "/* Styles applied to the root element */\n.saltDialogTitle {\n padding-bottom: var(--salt-spacing-100);\n padding-left: var(--salt-spacing-300);\n padding-right: var(--salt-spacing-300);\n align-items: center;\n display: flex;\n flex-direction: row;\n gap: var(--salt-spacing-100);\n box-sizing: border-box;\n}\n\n.saltDialogTitle-title {\n margin: 0;\n}\n\n/* Styles applied to the status indicator icon overriding its default size */\n.saltDialogTitle .saltStatusIndicator.saltIcon {\n --icon-size: var(--salt-text-h2-lineHeight);\n}\n\n/* Styles applied to DialogTitle when accent={true} */\n.saltDialogTitle-withAccent {\n position: relative;\n}\n\n.saltDialogTitle-withAccent::before {\n content: \"\";\n position: absolute;\n top: 0;\n left: 0;\n bottom: var(--salt-spacing-100);\n width: var(--salt-size-accent);\n background: var(--salt-accent-background);\n}\n\n.saltDialogTitle-error::before {\n background: var(--salt-status-error-borderColor);\n}\n\n.saltDialogTitle-info::before {\n background: var(--salt-status-info-borderColor);\n}\n\n.saltDialogTitle-success::before {\n background: var(--salt-status-success-borderColor);\n}\n\n.saltDialogTitle-warning::before {\n background: var(--salt-status-warning-borderColor);\n}\n";
|
|
4
|
-
|
|
5
|
-
module.exports = css_248z;
|
|
6
|
-
//# sourceMappingURL=DialogTitle.css.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DialogTitle.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DialogTitle.js","sources":["../src/dialog/DialogTitle.tsx"],"sourcesContent":["import { ReactNode, ComponentPropsWithoutRef } from \"react\";\nimport clsx from \"clsx\";\nimport {\n H2,\n StatusIndicator,\n ValidationStatus,\n makePrefixer,\n Text,\n} from \"@salt-ds/core\";\nimport { useDialogContext } from \"./DialogContext\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport dialogTitleCss from \"./DialogTitle.css\";\n\nconst withBaseName = makePrefixer(\"saltDialogTitle\");\n\ninterface DialogTitleProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"title\"> {\n /**\n * The status of the Dialog\n */\n status?: ValidationStatus | undefined;\n /**\n * Displays the accent bar in the Dialog Title */\n disableAccent?: boolean;\n /**\n * Displays the Dialog Title in a H2 component\n */\n title: ReactNode;\n /**\n * Displays the Dialog Subtitle in a Label component\n **/\n subtitle?: ReactNode;\n\n className?: string;\n}\n\nexport const DialogTitle = ({\n className,\n title,\n subtitle,\n disableAccent,\n status: statusProp,\n ...rest\n}: DialogTitleProps) => {\n const { status: statusContext, id } = useDialogContext();\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-dialog-title\",\n css: dialogTitleCss,\n window: targetWindow,\n });\n\n const status = statusProp ?? (statusContext as ValidationStatus);\n\n return (\n <div\n id={id as string}\n className={clsx(\n withBaseName(),\n {\n [withBaseName(\"withAccent\")]: !disableAccent && !status,\n [withBaseName(status)]: !!status,\n },\n className\n )}\n {...rest}\n >\n {status && <StatusIndicator status={status} />}\n <div>\n {subtitle && (\n <Text as={\"label\"} variant=\"secondary\">\n {subtitle}\n </Text>\n )}\n <H2 className={clsx(withBaseName(\"title\"))}>{title}</H2>\n </div>\n </div>\n );\n};\n"],"names":["makePrefixer","useDialogContext","useWindow","useComponentCssInjection","dialogTitleCss","jsxs","clsx","jsx","StatusIndicator","Text","H2"],"mappings":";;;;;;;;;;;;;;;;AAcA,MAAM,YAAA,GAAeA,kBAAa,iBAAiB,CAAA,CAAA;AAuB5C,MAAM,cAAc,CAAC;AAAA,EAC1B,SAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,aAAA;AAAA,EACA,MAAQ,EAAA,UAAA;AAAA,EACL,GAAA,IAAA;AACL,CAA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AA,CAAA;AAEJ;;;;"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var css_248z = "/* Styles applied to Drawer component */\n.saltDrawer {\n background: var(--drawer-background);\n display: flex;\n flex-direction: column;\n max-height: 100%;\n max-width: 100%;\n overflow: auto;\n padding: var(--salt-spacing-300);\n box-shadow: var(--salt-overlayable-shadow-modal);\n z-index: var(--salt-zIndex-drawer);\n position: fixed;\n top: 0;\n box-sizing: border-box;\n}\n\n/* Styles applied when variant = \"primary\" */\n.saltDrawer-primary {\n --drawer-background: var(--salt-container-primary-background);\n}\n\n/* Styles applied when variant = \"secondary\" */\n.saltDrawer-secondary {\n --drawer-background: var(--salt-container-secondary-background);\n}\n\n/* Styles applied when position = \"top\" */\n.saltDrawer-top {\n left: 0;\n right: 0;\n bottom: auto;\n}\n\n/* Styles applied when position = \"top\" and the component mounts */\n.saltDrawer-top.saltDrawer-enterAnimation {\n animation: var(--salt-animation-slide-in-bottom);\n}\n\n/* Styles applied when position = \"top\" and the component unmounts */\n.saltDrawer-top.saltDrawer-exitAnimation {\n animation: var(--salt-animation-slide-out-bottom);\n}\n\n/* Styles applied when position = \"right\" */\n.saltDrawer-right {\n left: auto;\n right: 0;\n height: 100%;\n}\n\n/* Styles applied when position = \"right\" and the component mounts */\n.saltDrawer-right.saltDrawer-enterAnimation {\n animation: var(--salt-animation-slide-in-right);\n}\n\n/* Styles applied when position = \"right\" and the component unmounts */\n.saltDrawer-right.saltDrawer-exitAnimation {\n animation: var(--salt-animation-slide-out-right);\n}\n\n/* Styles applied when position = \"left\" */\n.saltDrawer-left {\n left: 0;\n right: auto;\n height: 100%;\n}\n\n/* Styles applied when position = \"left\" and the component mounts */\n.saltDrawer-left.saltDrawer-enterAnimation {\n animation: var(--salt-animation-slide-in-left);\n}\n\n/* Styles applied when position = \"left\" and the component unmounts */\n.saltDrawer-left.saltDrawer-exitAnimation {\n animation: var(--salt-animation-slide-out-left);\n}\n\n/* Styles applied when position = \"bottom\" */\n.saltDrawer-bottom {\n left: 0;\n right: 0;\n bottom: 0;\n top: auto;\n}\n\n/* Styles applied when position = \"bottom\" and the component mounts */\n.saltDrawer-bottom.saltDrawer-enterAnimation {\n animation: var(--salt-animation-slide-in-top);\n}\n\n/* Styles applied when position = \"bottom\" and the component unmounts */\n.saltDrawer-bottom.saltDrawer-exitAnimation {\n animation: var(--salt-animation-slide-out-top);\n}\n";
|
|
4
|
-
|
|
5
|
-
module.exports = css_248z;
|
|
6
|
-
//# sourceMappingURL=Drawer.css.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var clsx = require('clsx');
|
|
8
|
-
var react = require('@floating-ui/react');
|
|
9
|
-
var core = require('@salt-ds/core');
|
|
10
|
-
var window = require('@salt-ds/window');
|
|
11
|
-
var styles = require('@salt-ds/styles');
|
|
12
|
-
var Drawer$1 = require('./Drawer.css.js');
|
|
13
|
-
|
|
14
|
-
const ConditionalScrimWrapper = ({
|
|
15
|
-
condition,
|
|
16
|
-
children
|
|
17
|
-
}) => {
|
|
18
|
-
return condition ? /* @__PURE__ */ jsxRuntime.jsxs(core.Scrim, {
|
|
19
|
-
fixed: true,
|
|
20
|
-
children: [
|
|
21
|
-
" ",
|
|
22
|
-
children,
|
|
23
|
-
" "
|
|
24
|
-
]
|
|
25
|
-
}) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
26
|
-
children: [
|
|
27
|
-
children,
|
|
28
|
-
" "
|
|
29
|
-
]
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
const withBaseName = core.makePrefixer("saltDrawer");
|
|
33
|
-
const Drawer = React.forwardRef(function Drawer2(props, ref) {
|
|
34
|
-
var _a, _b;
|
|
35
|
-
const {
|
|
36
|
-
children,
|
|
37
|
-
className,
|
|
38
|
-
position = "left",
|
|
39
|
-
open = false,
|
|
40
|
-
onOpenChange,
|
|
41
|
-
variant = "primary",
|
|
42
|
-
disableDismiss,
|
|
43
|
-
disableScrim,
|
|
44
|
-
...rest
|
|
45
|
-
} = props;
|
|
46
|
-
const targetWindow = window.useWindow();
|
|
47
|
-
styles.useComponentCssInjection({
|
|
48
|
-
testId: "salt-drawer",
|
|
49
|
-
css: Drawer$1,
|
|
50
|
-
window: targetWindow
|
|
51
|
-
});
|
|
52
|
-
const [showComponent, setShowComponent] = React.useState(false);
|
|
53
|
-
const { Component: FloatingComponent } = core.useFloatingComponent();
|
|
54
|
-
const { context, floating, elements } = core.useFloatingUI({
|
|
55
|
-
open,
|
|
56
|
-
onOpenChange
|
|
57
|
-
});
|
|
58
|
-
const { getFloatingProps } = react.useInteractions([
|
|
59
|
-
react.useClick(context),
|
|
60
|
-
react.useDismiss(context, { enabled: !disableDismiss })
|
|
61
|
-
]);
|
|
62
|
-
const handleRef = core.useForkRef(floating, ref);
|
|
63
|
-
React.useEffect(() => {
|
|
64
|
-
if (open && !showComponent) {
|
|
65
|
-
setShowComponent(true);
|
|
66
|
-
}
|
|
67
|
-
if (!open && showComponent) {
|
|
68
|
-
const animate = setTimeout(() => {
|
|
69
|
-
setShowComponent(false);
|
|
70
|
-
}, 300);
|
|
71
|
-
return () => clearTimeout(animate);
|
|
72
|
-
}
|
|
73
|
-
}, [open, showComponent, setShowComponent]);
|
|
74
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ConditionalScrimWrapper, {
|
|
75
|
-
condition: open && !disableScrim,
|
|
76
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(FloatingComponent, {
|
|
77
|
-
open: showComponent,
|
|
78
|
-
ref: handleRef,
|
|
79
|
-
role: "dialog",
|
|
80
|
-
width: (_a = elements.floating) == null ? void 0 : _a.offsetWidth,
|
|
81
|
-
height: (_b = elements.floating) == null ? void 0 : _b.offsetHeight,
|
|
82
|
-
"aria-modal": "true",
|
|
83
|
-
focusManagerProps: {
|
|
84
|
-
context
|
|
85
|
-
},
|
|
86
|
-
className: clsx.clsx(
|
|
87
|
-
withBaseName(),
|
|
88
|
-
withBaseName(position),
|
|
89
|
-
{
|
|
90
|
-
[withBaseName("enterAnimation")]: open,
|
|
91
|
-
[withBaseName("exitAnimation")]: !open,
|
|
92
|
-
[withBaseName(variant)]: variant
|
|
93
|
-
},
|
|
94
|
-
className
|
|
95
|
-
),
|
|
96
|
-
...getFloatingProps(),
|
|
97
|
-
...rest,
|
|
98
|
-
children
|
|
99
|
-
})
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
exports.Drawer = Drawer;
|
|
104
|
-
//# sourceMappingURL=Drawer.js.map
|