@blockle/blocks-react 3.0.1 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +138 -0
- package/dist/components/display/Tag/Tag.d.ts +28 -0
- package/dist/components/display/Tag/Tag.d.ts.map +1 -0
- package/dist/components/display/Tag/Tag.js +46 -0
- package/dist/components/feedback/Alert/Alert.d.ts +17 -2
- package/dist/components/feedback/Alert/Alert.d.ts.map +1 -1
- package/dist/components/feedback/Alert/Alert.js +8 -35
- package/dist/components/feedback/Toast/Toast.css.d.ts +10 -1
- package/dist/components/feedback/Toast/Toast.css.d.ts.map +1 -1
- package/dist/components/feedback/Toast/Toast.css.js +37 -10
- package/dist/components/feedback/Toast/ToastContext.d.ts +6 -0
- package/dist/components/feedback/Toast/ToastContext.d.ts.map +1 -1
- package/dist/components/feedback/Toast/ToastProvider.d.ts +15 -1
- package/dist/components/feedback/Toast/ToastProvider.d.ts.map +1 -1
- package/dist/components/feedback/Toast/ToastProvider.js +128 -44
- package/dist/components/feedback/Toast/useCountdowns.d.ts +14 -0
- package/dist/components/feedback/Toast/useCountdowns.d.ts.map +1 -0
- package/dist/components/feedback/Toast/useCountdowns.js +74 -0
- package/dist/components/form/Button/Button.d.ts +11 -3
- package/dist/components/form/Button/Button.d.ts.map +1 -1
- package/dist/components/form/Checkbox/Checkbox.d.ts +0 -1
- package/dist/components/form/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/form/Checkbox/Checkbox.js +7 -27
- package/dist/components/form/Checkbox/checkbox.css.d.ts.map +1 -1
- package/dist/components/form/Checkbox/checkbox.css.js +1 -0
- package/dist/components/form/IconButton/IconButton.d.ts +29 -0
- package/dist/components/form/IconButton/IconButton.d.ts.map +1 -0
- package/dist/components/form/IconButton/IconButton.js +61 -0
- package/dist/components/form/NumericInput/NumericInput.d.ts +11 -1
- package/dist/components/form/NumericInput/NumericInput.d.ts.map +1 -1
- package/dist/components/form/NumericInput/NumericInput.js +52 -24
- package/dist/components/form/Radio/Radio.d.ts +0 -1
- package/dist/components/form/Radio/Radio.d.ts.map +1 -1
- package/dist/components/form/Radio/Radio.js +1 -11
- package/dist/components/form/Radio/radio.css.d.ts.map +1 -1
- package/dist/components/form/Radio/radio.css.js +1 -0
- package/dist/components/form/Select/Select.d.ts +2 -1
- package/dist/components/form/Select/Select.d.ts.map +1 -1
- package/dist/components/form/Select/Select.js +4 -24
- package/dist/components/form/Switch/Switch.d.ts +5 -1
- package/dist/components/form/Switch/Switch.d.ts.map +1 -1
- package/dist/components/form/Switch/Switch.js +19 -29
- package/dist/components/form/Switch/switch.css.d.ts.map +1 -1
- package/dist/components/form/Switch/switch.css.js +1 -0
- package/dist/components/form/TextInput/TextInput.d.ts +0 -1
- package/dist/components/form/TextInput/TextInput.d.ts.map +1 -1
- package/dist/components/form/TextInput/TextInput.js +0 -2
- package/dist/components/form/Textarea/Textarea.css.d.ts +2 -0
- package/dist/components/form/Textarea/Textarea.css.d.ts.map +1 -1
- package/dist/components/form/Textarea/Textarea.css.js +17 -1
- package/dist/components/form/Textarea/Textarea.d.ts +11 -0
- package/dist/components/form/Textarea/Textarea.d.ts.map +1 -1
- package/dist/components/form/Textarea/Textarea.js +8 -2
- package/dist/components/layout/Inline/Inline.d.ts +11 -3
- package/dist/components/layout/Inline/Inline.d.ts.map +1 -1
- package/dist/components/layout/Inline/Inline.js +5 -3
- package/dist/components/layout/Stack/Stack.d.ts +12 -8
- package/dist/components/layout/Stack/Stack.d.ts.map +1 -1
- package/dist/components/layout/Stack/Stack.js +8 -4
- package/dist/components/navigation/Link/Link.d.ts +1 -1
- package/dist/components/navigation/Link/Link.d.ts.map +1 -1
- package/dist/components/navigation/Link/Link.js +2 -2
- package/dist/components/overlay/Dialog/Dialog.d.ts +4 -1
- package/dist/components/overlay/Dialog/Dialog.d.ts.map +1 -1
- package/dist/components/overlay/Dialog/Dialog.js +19 -46
- package/dist/components/overlay/Drawer/Drawer.d.ts +9 -2
- package/dist/components/overlay/Drawer/Drawer.d.ts.map +1 -1
- package/dist/components/overlay/Drawer/Drawer.js +25 -44
- package/dist/components/overlay/Drawer/drawer.css.d.ts.map +1 -1
- package/dist/components/overlay/Drawer/drawer.css.js +4 -8
- package/dist/components/overlay/Popover/Popover.d.ts +15 -3
- package/dist/components/overlay/Popover/Popover.d.ts.map +1 -1
- package/dist/components/overlay/Popover/Popover.js +35 -11
- package/dist/components/overlay/Popover/popover-utils.d.ts +38 -1
- package/dist/components/overlay/Popover/popover-utils.d.ts.map +1 -1
- package/dist/components/overlay/Popover/popover-utils.js +92 -41
- package/dist/components/overlay/Tooltip/Tooltip.d.ts +8 -0
- package/dist/components/overlay/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/overlay/Tooltip/Tooltip.js +3 -2
- package/dist/components/overlay/requestCloseReason.d.ts +6 -0
- package/dist/components/overlay/requestCloseReason.d.ts.map +1 -0
- package/dist/components/overlay/useModalOverlay.d.ts +35 -0
- package/dist/components/overlay/useModalOverlay.d.ts.map +1 -0
- package/dist/components/overlay/useModalOverlay.js +85 -0
- package/dist/components/typography/Heading/Heading.d.ts +2 -1
- package/dist/components/typography/Heading/Heading.d.ts.map +1 -1
- package/dist/components/typography/Heading/Heading.js +9 -1
- package/dist/components/typography/Text/Text.d.ts +3 -2
- package/dist/components/typography/Text/Text.d.ts.map +1 -1
- package/dist/components/typography/Text/Text.js +9 -1
- package/dist/components/typography/textOverflow.css.d.ts +3 -0
- package/dist/components/typography/textOverflow.css.d.ts.map +1 -0
- package/dist/components/typography/textOverflow.css.js +32 -0
- package/dist/components/typography/textOverflow.d.ts +9 -0
- package/dist/components/typography/textOverflow.d.ts.map +1 -0
- package/dist/components/typography/textOverflow.js +10 -0
- package/dist/hooks/useClickOutside/useClickOutside.d.ts.map +1 -1
- package/dist/hooks/useClickOutside/useClickOutside.js +27 -7
- package/dist/hooks/useModalDialog/useModalDialog.d.ts +13 -0
- package/dist/hooks/useModalDialog/useModalDialog.d.ts.map +1 -0
- package/dist/hooks/useModalDialog/useModalDialog.js +39 -0
- package/dist/icons/icons.d.ts +8 -0
- package/dist/icons/icons.d.ts.map +1 -0
- package/dist/icons/icons.js +39 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/testUtils/browser/consumerStyles.css.d.ts +2 -0
- package/dist/testUtils/browser/consumerStyles.css.d.ts.map +1 -0
- package/dist/testUtils/browser/pointer.d.ts +18 -0
- package/dist/testUtils/browser/pointer.d.ts.map +1 -0
- package/dist/testUtils/testTheme.css.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/components/feedback/Alert/Alert.css.d.ts +0 -2
- package/dist/components/feedback/Alert/Alert.css.d.ts.map +0 -1
- package/dist/components/feedback/Alert/Alert.css.js +0 -15
- package/dist/components/overlay/Dialog/dialogHelper.d.ts +0 -7
- package/dist/components/overlay/Dialog/dialogHelper.d.ts.map +0 -1
- package/dist/components/overlay/Dialog/dialogHelper.js +0 -22
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { classnames } from "@blockle/blocks-core";
|
|
4
|
-
import {
|
|
3
|
+
import { composeRefs, classnames } from "@blockle/blocks-core";
|
|
4
|
+
import { useRef, useState } from "react";
|
|
5
5
|
import { useComponentStyles } from "../../../hooks/useComponentStyles/useComponentStyles.js";
|
|
6
6
|
import { input, container } from "./switch.css.js";
|
|
7
7
|
const Switch = ({
|
|
@@ -9,55 +9,45 @@ const Switch = ({
|
|
|
9
9
|
className,
|
|
10
10
|
defaultChecked,
|
|
11
11
|
onChange,
|
|
12
|
+
ref,
|
|
12
13
|
...restProps
|
|
13
14
|
}) => {
|
|
14
|
-
const
|
|
15
|
-
|
|
15
|
+
const inputRef = useRef(null);
|
|
16
|
+
const [uncontrolledChecked, setUncontrolledChecked] = useState(
|
|
17
|
+
defaultChecked ?? false
|
|
16
18
|
);
|
|
19
|
+
const isControlled = checked !== void 0;
|
|
20
|
+
const isChecked = isControlled ? checked : uncontrolledChecked;
|
|
17
21
|
const baseClassName = useComponentStyles("switch", { root: true });
|
|
18
22
|
const thumbClassName = useComponentStyles("switch", { thumb: true }, false);
|
|
19
|
-
|
|
20
|
-
if (
|
|
21
|
-
|
|
23
|
+
const onChangeHandler = (event) => {
|
|
24
|
+
if (!isControlled) {
|
|
25
|
+
setUncontrolledChecked(event.target.checked);
|
|
22
26
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
setIsChecked((checked2) => {
|
|
26
|
-
const newValue = !checked2;
|
|
27
|
-
if (onChange) {
|
|
28
|
-
onChange(newValue);
|
|
29
|
-
}
|
|
30
|
-
return newValue;
|
|
31
|
-
});
|
|
32
|
-
}, [onChange]);
|
|
33
|
-
const onChangeHandler = useCallback(
|
|
34
|
-
(event) => {
|
|
35
|
-
setIsChecked(event.target.checked);
|
|
36
|
-
if (onChange) {
|
|
37
|
-
onChange(event.target.checked);
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
[onChange]
|
|
41
|
-
);
|
|
27
|
+
onChange?.(event);
|
|
28
|
+
};
|
|
42
29
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
43
30
|
"div",
|
|
44
31
|
{
|
|
45
32
|
className: classnames(className, container, baseClassName),
|
|
46
33
|
"data-checked": isChecked,
|
|
47
34
|
onClick: (event) => {
|
|
48
|
-
if (event.target
|
|
35
|
+
if (event.target === inputRef.current) {
|
|
49
36
|
return;
|
|
50
37
|
}
|
|
51
|
-
|
|
38
|
+
inputRef.current?.click();
|
|
52
39
|
},
|
|
53
40
|
children: [
|
|
54
41
|
/* @__PURE__ */ jsx(
|
|
55
42
|
"input",
|
|
56
43
|
{
|
|
57
44
|
type: "checkbox",
|
|
45
|
+
role: "switch",
|
|
58
46
|
className: input,
|
|
59
|
-
checked
|
|
47
|
+
checked,
|
|
48
|
+
defaultChecked,
|
|
60
49
|
onChange: onChangeHandler,
|
|
50
|
+
ref: composeRefs(ref, inputRef),
|
|
61
51
|
...restProps
|
|
62
52
|
}
|
|
63
53
|
),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.css.d.ts","sourceRoot":"","sources":["../../../../src/components/form/Switch/switch.css.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"switch.css.d.ts","sourceRoot":"","sources":["../../../../src/components/form/Switch/switch.css.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,QASpB,CAAC;AAEH,eAAO,MAAM,KAAK,QAQhB,CAAC"}
|
|
@@ -2,7 +2,6 @@ import { HTMLElementProps, OptionalLiteral } from '@blockle/blocks-core';
|
|
|
2
2
|
export type TextInputProps = {
|
|
3
3
|
inputClassName?: string;
|
|
4
4
|
endSlot?: React.ReactNode;
|
|
5
|
-
name: string;
|
|
6
5
|
startSlot?: React.ReactNode;
|
|
7
6
|
type?: OptionalLiteral<'email' | 'number' | 'password' | 'tel' | 'text' | 'url'>;
|
|
8
7
|
} & Omit<HTMLElementProps<HTMLInputElement>, 'type'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../../src/components/form/TextInput/TextInput.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAM9B,MAAM,MAAM,cAAc,GAAG;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,
|
|
1
|
+
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../../src/components/form/TextInput/TextInput.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAM9B,MAAM,MAAM,cAAc,GAAG;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,IAAI,CAAC,EAAE,eAAe,CACpB,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CACzD,CAAC;CAEH,GAAG,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,CAAC;AAErD,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAsC9C,CAAC"}
|
|
@@ -8,7 +8,6 @@ const TextInput = ({
|
|
|
8
8
|
className,
|
|
9
9
|
inputClassName,
|
|
10
10
|
endSlot,
|
|
11
|
-
name,
|
|
12
11
|
placeholder,
|
|
13
12
|
startSlot,
|
|
14
13
|
type = "text",
|
|
@@ -31,7 +30,6 @@ const TextInput = ({
|
|
|
31
30
|
/* @__PURE__ */ jsx(
|
|
32
31
|
"input",
|
|
33
32
|
{
|
|
34
|
-
name,
|
|
35
33
|
type,
|
|
36
34
|
placeholder,
|
|
37
35
|
className: classnames(input, inputStyles, inputClassName),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.css.d.ts","sourceRoot":"","sources":["../../../../src/components/form/Textarea/Textarea.css.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ,QASnB,CAAC;AAEH,eAAO,MAAM,kBAAkB,QAE7B,CAAC"}
|
|
1
|
+
{"version":3,"file":"Textarea.css.d.ts","sourceRoot":"","sources":["../../../../src/components/form/Textarea/Textarea.css.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ,QASnB,CAAC;AAEH,eAAO,MAAM,kBAAkB,QAE7B,CAAC;AAEH,eAAO,MAAM,aAAa,QAMxB,CAAC;AAEH,eAAO,MAAM,YAAY,QAMvB,CAAC"}
|
|
@@ -15,8 +15,24 @@ const textarea = style({
|
|
|
15
15
|
const fieldSizingEnabled = style({
|
|
16
16
|
fieldSizing: "content"
|
|
17
17
|
});
|
|
18
|
+
const containerFill = style({
|
|
19
|
+
"@layer": {
|
|
20
|
+
[layers.molecule]: {
|
|
21
|
+
blockSize: "100%"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const textareaFill = style({
|
|
26
|
+
"@layer": {
|
|
27
|
+
[layers.molecule]: {
|
|
28
|
+
minBlockSize: "100%"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
18
32
|
endFileScope();
|
|
19
33
|
export {
|
|
34
|
+
containerFill,
|
|
20
35
|
fieldSizingEnabled,
|
|
21
|
-
textarea
|
|
36
|
+
textarea,
|
|
37
|
+
textareaFill
|
|
22
38
|
};
|
|
@@ -11,6 +11,17 @@ export type TextareaProps = {
|
|
|
11
11
|
* itself keeps growing inside it.
|
|
12
12
|
*/
|
|
13
13
|
maxBlockSize?: string | number;
|
|
14
|
+
/**
|
|
15
|
+
* If true, the wrapper stretches to its parent's block size and the
|
|
16
|
+
* `<textarea>` is at least as tall as the wrapper. Combine with `grow` to
|
|
17
|
+
* give textareas side by side, such as in a `Grid`, equal heights.
|
|
18
|
+
*
|
|
19
|
+
* The heights match up to the container's maximum block size. Past it, the
|
|
20
|
+
* containers stay equal while the typed-in `<textarea>` scrolls inside its
|
|
21
|
+
* own; raise `maxBlockSize` to lift the limit. The parent needs a definite
|
|
22
|
+
* block size, such as a stretched grid cell.
|
|
23
|
+
*/
|
|
24
|
+
fill?: boolean;
|
|
14
25
|
/**
|
|
15
26
|
* Props for the wrapper element. Accepts the same atoms as `Box`.
|
|
16
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../../../src/components/form/Textarea/Textarea.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,KAAK,EAEV,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAM9B,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B;;OAEG;IACH,cAAc,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,KAAK,CAAC;CAE9E,GAAG,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;AAE1C,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../../../src/components/form/Textarea/Textarea.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,KAAK,EAEV,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAM9B,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B;;;;;;;;;OASG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,KAAK,CAAC;CAE9E,GAAG,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;AAE1C,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAiD5C,CAAC"}
|
|
@@ -3,12 +3,13 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { classnames } from "@blockle/blocks-core";
|
|
4
4
|
import { useComponentStyles } from "../../../hooks/useComponentStyles/useComponentStyles.js";
|
|
5
5
|
import { Box } from "../../layout/Box/Box.js";
|
|
6
|
-
import { textarea, fieldSizingEnabled } from "./Textarea.css.js";
|
|
6
|
+
import { textarea, fieldSizingEnabled, textareaFill, containerFill } from "./Textarea.css.js";
|
|
7
7
|
const Textarea = ({
|
|
8
8
|
ref,
|
|
9
9
|
value,
|
|
10
10
|
grow,
|
|
11
11
|
maxBlockSize,
|
|
12
|
+
fill,
|
|
12
13
|
containerProps,
|
|
13
14
|
...restProps
|
|
14
15
|
}) => {
|
|
@@ -27,7 +28,11 @@ const Textarea = ({
|
|
|
27
28
|
return /* @__PURE__ */ jsx(
|
|
28
29
|
Box,
|
|
29
30
|
{
|
|
30
|
-
className: classnames(
|
|
31
|
+
className: classnames(
|
|
32
|
+
containerClassName,
|
|
33
|
+
fill && containerFill,
|
|
34
|
+
containerClassNameFromProps
|
|
35
|
+
),
|
|
31
36
|
style: {
|
|
32
37
|
maxHeight: grow ? maxBlockSize : void 0,
|
|
33
38
|
...containerStyleFromProps
|
|
@@ -41,6 +46,7 @@ const Textarea = ({
|
|
|
41
46
|
className: classnames(
|
|
42
47
|
textarea,
|
|
43
48
|
grow && fieldSizingEnabled,
|
|
49
|
+
fill && textareaFill,
|
|
44
50
|
inputClassName,
|
|
45
51
|
className
|
|
46
52
|
),
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import { AlignItemsMap, Atoms, JustifyContentMap } from '@blockle/blocks-core';
|
|
1
|
+
import { AlignItemsMap, Atoms, HTMLElementProps, JustifyContentMap } from '@blockle/blocks-core';
|
|
2
2
|
export type InlineProps = {
|
|
3
3
|
alignX?: keyof JustifyContentMap;
|
|
4
4
|
alignY?: keyof AlignItemsMap;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Render the single child element instead of a `div`, with the layout
|
|
7
|
+
* classes and attributes merged onto it. A `ul` or `ol` child keeps its
|
|
8
|
+
* list markers unless `listStyle="none"` is passed. WebKit then no longer
|
|
9
|
+
* exposes the element as a list, so pass `role="list"` when list
|
|
10
|
+
* semantics matter.
|
|
11
|
+
*/
|
|
12
|
+
asChild?: boolean;
|
|
6
13
|
children: React.ReactNode;
|
|
7
14
|
className?: string;
|
|
15
|
+
ref?: React.Ref<HTMLElement>;
|
|
8
16
|
gap: Atoms['gap'];
|
|
9
17
|
style?: React.CSSProperties;
|
|
10
|
-
} & Omit<Atoms, 'flexDirection' | 'gap'>;
|
|
18
|
+
} & Omit<Atoms, 'flexDirection' | 'gap'> & Omit<HTMLElementProps<HTMLElement>, 'children' | 'ref'>;
|
|
11
19
|
export declare const Inline: React.FC<InlineProps>;
|
|
12
20
|
//# sourceMappingURL=Inline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Inline.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/Inline/Inline.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,KAAK,EAEV,KAAK,iBAAiB,EAEvB,MAAM,sBAAsB,CAAC;AAI9B,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,iBAAiB,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,aAAa,CAAC;IAC7B,
|
|
1
|
+
{"version":3,"file":"Inline.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/Inline/Inline.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,KAAK,EAEV,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEvB,MAAM,sBAAsB,CAAC;AAI9B,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,iBAAiB,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,aAAa,CAAC;IAC7B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC7B,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B,GAAG,IAAI,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK,CAAC,GACtC,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC,CAAC;AAE1D,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAyBxC,CAAC"}
|
|
@@ -4,24 +4,26 @@ import { Box } from "../Box/Box.js";
|
|
|
4
4
|
const Inline = ({
|
|
5
5
|
alignX,
|
|
6
6
|
alignY,
|
|
7
|
-
|
|
7
|
+
asChild,
|
|
8
8
|
children,
|
|
9
9
|
display = "flex",
|
|
10
10
|
gap,
|
|
11
|
+
ref,
|
|
11
12
|
...props
|
|
12
13
|
}) => {
|
|
13
14
|
return /* @__PURE__ */ jsx(
|
|
14
15
|
Box,
|
|
15
16
|
{
|
|
16
|
-
asChild
|
|
17
|
+
asChild,
|
|
17
18
|
display,
|
|
18
19
|
gap,
|
|
19
20
|
flexDirection: "row",
|
|
20
21
|
justifyContent: alignX ? justifyContentMap[alignX] : void 0,
|
|
21
22
|
alignItems: alignY ? alignItemsMap[alignY] : void 0,
|
|
22
23
|
flexWrap: "wrap",
|
|
24
|
+
ref,
|
|
23
25
|
...props,
|
|
24
|
-
children
|
|
26
|
+
children
|
|
25
27
|
}
|
|
26
28
|
);
|
|
27
29
|
};
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { AlignItemsMap, Atoms } from '@blockle/blocks-core';
|
|
1
|
+
import { AlignItemsMap, Atoms, HTMLElementProps, JustifyContentMap } from '@blockle/blocks-core';
|
|
2
2
|
export type StackProps = {
|
|
3
3
|
alignX?: keyof AlignItemsMap;
|
|
4
|
-
|
|
4
|
+
alignY?: keyof JustifyContentMap;
|
|
5
|
+
/**
|
|
6
|
+
* Render the single child element instead of a `div`, with the layout
|
|
7
|
+
* classes and attributes merged onto it. A `ul` or `ol` child keeps its
|
|
8
|
+
* list markers unless `listStyle="none"` is passed. WebKit then no longer
|
|
9
|
+
* exposes the element as a list, so pass `role="list"` when list
|
|
10
|
+
* semantics matter.
|
|
11
|
+
*/
|
|
12
|
+
asChild?: boolean;
|
|
5
13
|
children: React.ReactNode;
|
|
6
14
|
className?: string;
|
|
15
|
+
ref?: React.Ref<HTMLElement>;
|
|
7
16
|
gap: Atoms['gap'];
|
|
8
17
|
style?: React.CSSProperties;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Start prop is only valid when tag="ol"
|
|
12
|
-
*/
|
|
13
|
-
start?: number;
|
|
14
|
-
} & Omit<Atoms, 'flexDirection' | 'gap'>;
|
|
18
|
+
} & Omit<Atoms, 'flexDirection' | 'gap'> & Omit<HTMLElementProps<HTMLElement>, 'children' | 'ref'>;
|
|
15
19
|
export declare const Stack: React.FC<StackProps>;
|
|
16
20
|
//# sourceMappingURL=Stack.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stack.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/Stack/Stack.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"Stack.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/Stack/Stack.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,KAAK,EAEV,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEvB,MAAM,sBAAsB,CAAC;AAI9B,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,CAAC,EAAE,MAAM,aAAa,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,iBAAiB,CAAC;IACjC;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC7B,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B,GAAG,IAAI,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK,CAAC,GACtC,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC,CAAC;AAE1D,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAwBtC,CAAC"}
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { alignItemsMap } from "@blockle/blocks-core";
|
|
2
|
+
import { justifyContentMap, alignItemsMap } from "@blockle/blocks-core";
|
|
3
3
|
import { Box } from "../Box/Box.js";
|
|
4
4
|
const Stack = ({
|
|
5
|
-
|
|
5
|
+
asChild,
|
|
6
6
|
display = "flex",
|
|
7
7
|
children,
|
|
8
8
|
gap,
|
|
9
9
|
alignX,
|
|
10
|
+
alignY,
|
|
11
|
+
ref,
|
|
10
12
|
...restProps
|
|
11
13
|
}) => {
|
|
12
14
|
return /* @__PURE__ */ jsx(
|
|
13
15
|
Box,
|
|
14
16
|
{
|
|
15
|
-
asChild
|
|
17
|
+
asChild,
|
|
16
18
|
display,
|
|
17
19
|
gap,
|
|
18
20
|
flexDirection: "column",
|
|
19
21
|
alignItems: alignX ? alignItemsMap[alignX] : void 0,
|
|
22
|
+
justifyContent: alignY ? justifyContentMap[alignY] : void 0,
|
|
23
|
+
ref,
|
|
20
24
|
...restProps,
|
|
21
|
-
children
|
|
25
|
+
children
|
|
22
26
|
}
|
|
23
27
|
);
|
|
24
28
|
};
|
|
@@ -3,8 +3,8 @@ type LinkTheme = ComponentThemes['link'];
|
|
|
3
3
|
export type LinkProps = {
|
|
4
4
|
asChild?: boolean;
|
|
5
5
|
children?: React.ReactNode;
|
|
6
|
+
intent?: LinkTheme['variants']['intent'];
|
|
6
7
|
underline?: LinkTheme['variants']['underline'];
|
|
7
|
-
variant?: LinkTheme['variants']['variant'];
|
|
8
8
|
} & HTMLElementProps<HTMLAnchorElement> & MarginAtoms;
|
|
9
9
|
export declare const Link: React.FC<LinkProps>;
|
|
10
10
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/Link/Link.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAK9B,KAAK,SAAS,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,
|
|
1
|
+
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/Link/Link.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAK9B,KAAK,SAAS,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;CAChD,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,GACrC,WAAW,CAAC;AAId,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAsBpC,CAAC"}
|
|
@@ -8,13 +8,13 @@ const Link = ({
|
|
|
8
8
|
asChild,
|
|
9
9
|
children,
|
|
10
10
|
className,
|
|
11
|
+
intent,
|
|
11
12
|
underline,
|
|
12
|
-
variant,
|
|
13
13
|
...restProps
|
|
14
14
|
}) => {
|
|
15
15
|
const linkClassName = useComponentStyles("link", {
|
|
16
16
|
root: true,
|
|
17
|
-
variants: {
|
|
17
|
+
variants: { intent, underline }
|
|
18
18
|
});
|
|
19
19
|
return /* @__PURE__ */ jsx(
|
|
20
20
|
Template,
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ComponentThemes, HTMLElementProps } from '@blockle/blocks-core';
|
|
2
|
+
import { RequestCloseReason } from '../requestCloseReason.js';
|
|
2
3
|
type DialogTheme = ComponentThemes['dialog'];
|
|
3
4
|
export type DialogProps = {
|
|
4
5
|
open: boolean;
|
|
5
|
-
onRequestClose: () => void;
|
|
6
|
+
onRequestClose: (reason: RequestCloseReason) => void;
|
|
7
|
+
/** Runs on a close request, before the component prevents it and asks to close */
|
|
8
|
+
onCancel?: React.ReactEventHandler<HTMLDialogElement>;
|
|
6
9
|
className?: string;
|
|
7
10
|
size?: DialogTheme['variants']['size'];
|
|
8
11
|
'aria-label'?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../../src/components/overlay/Dialog/Dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../../src/components/overlay/Dialog/Dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,eAAe,EAGpB,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAInE,KAAK,WAAW,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;AAE7C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,cAAc,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACrD,kFAAkF;IAClF,QAAQ,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;AAExC,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAkDxC,CAAC"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import { useRef
|
|
5
|
-
import { useClickOutside } from "../../../hooks/useClickOutside/useClickOutside.js";
|
|
3
|
+
import { classnames, composeRefs } from "@blockle/blocks-core";
|
|
4
|
+
import { useRef } from "react";
|
|
6
5
|
import { useComponentStyles } from "../../../hooks/useComponentStyles/useComponentStyles.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { usePreventBodyScroll } from "../../../hooks/usePreventBodyScroll/usePreventBodyScroll.js";
|
|
10
|
-
import { useRestoreFocus } from "../../../hooks/useRestoreFocus/useRestoreFocus.js";
|
|
6
|
+
import { useModalDialog } from "../../../hooks/useModalDialog/useModalDialog.js";
|
|
7
|
+
import { useModalOverlay, DialogContext } from "../useModalOverlay.js";
|
|
11
8
|
import { dialog } from "./dialog.css.js";
|
|
12
|
-
import { useNestedDialog, DialogContext } from "./dialogHelper.js";
|
|
13
9
|
const Dialog = ({
|
|
14
10
|
children,
|
|
15
11
|
open,
|
|
16
12
|
className,
|
|
17
13
|
onRequestClose,
|
|
18
14
|
size,
|
|
15
|
+
ref,
|
|
16
|
+
onKeyDown,
|
|
17
|
+
onKeyDownCapture,
|
|
18
|
+
onCancel,
|
|
19
19
|
...restProps
|
|
20
20
|
}) => {
|
|
21
21
|
const dialogRef = useRef(null);
|
|
@@ -23,55 +23,28 @@ const Dialog = ({
|
|
|
23
23
|
dialog: true,
|
|
24
24
|
variants: { size }
|
|
25
25
|
});
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
onRequestClose();
|
|
35
|
-
},
|
|
36
|
-
[onRequestClose]
|
|
37
|
-
);
|
|
38
|
-
useKeyboard("Escape", onEscape, { enabled: open && enabled });
|
|
39
|
-
useClickOutside(dialogRef, onRequestClose, { enabled: open && enabled });
|
|
40
|
-
useIsomorphicLayoutEffect(() => {
|
|
41
|
-
if (open && visible) {
|
|
42
|
-
if (!dialogRef.current || !dialogRef.current.showModal) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
dialogRef.current.showModal();
|
|
46
|
-
} else if (open) {
|
|
47
|
-
setVisible(true);
|
|
48
|
-
} else {
|
|
49
|
-
if (!hasAnimationDuration(dialogRef.current)) {
|
|
50
|
-
setVisible(false);
|
|
51
|
-
}
|
|
52
|
-
if (dialogRef.current?.close) {
|
|
53
|
-
dialogRef.current.close();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}, [open, visible]);
|
|
57
|
-
const onAnimationEnd = useCallback(() => {
|
|
58
|
-
if (!open) {
|
|
59
|
-
setVisible(false);
|
|
60
|
-
}
|
|
61
|
-
}, [open]);
|
|
26
|
+
const { contextValue, closeRequestProps } = useModalOverlay(dialogRef, {
|
|
27
|
+
open,
|
|
28
|
+
onRequestClose,
|
|
29
|
+
onKeyDown,
|
|
30
|
+
onKeyDownCapture,
|
|
31
|
+
onCancel
|
|
32
|
+
});
|
|
33
|
+
const { visible, onAnimationEnd } = useModalDialog(dialogRef, open);
|
|
62
34
|
if (!visible) {
|
|
63
35
|
return null;
|
|
64
36
|
}
|
|
65
37
|
const dataOpen = typeof window === "undefined" && open ? true : void 0;
|
|
66
|
-
return /* @__PURE__ */ jsx(DialogContext.Provider, { value:
|
|
38
|
+
return /* @__PURE__ */ jsx(DialogContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
67
39
|
"dialog",
|
|
68
40
|
{
|
|
69
|
-
ref: dialogRef,
|
|
41
|
+
ref: composeRefs(ref, dialogRef),
|
|
70
42
|
open: dataOpen,
|
|
71
43
|
className: classnames(dialog, dialogClassName, className),
|
|
72
44
|
onAnimationEnd,
|
|
73
45
|
onTransitionEnd: onAnimationEnd,
|
|
74
46
|
...restProps,
|
|
47
|
+
...closeRequestProps,
|
|
75
48
|
children
|
|
76
49
|
}
|
|
77
50
|
) });
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { HTMLElementProps } from '@blockle/blocks-core';
|
|
1
|
+
import { ComponentThemes, HTMLElementProps } from '@blockle/blocks-core';
|
|
2
|
+
import { RequestCloseReason } from '../requestCloseReason.js';
|
|
2
3
|
import * as styles from './drawer.css.js';
|
|
4
|
+
type DrawerTheme = ComponentThemes['drawer'];
|
|
3
5
|
export type DrawerProps = {
|
|
4
6
|
open: boolean;
|
|
5
|
-
onRequestClose: () => void;
|
|
7
|
+
onRequestClose: (reason: RequestCloseReason) => void;
|
|
8
|
+
/** Runs on a close request, before the component prevents it and asks to close */
|
|
9
|
+
onCancel?: React.ReactEventHandler<HTMLDialogElement>;
|
|
10
|
+
className?: string;
|
|
6
11
|
placement?: keyof typeof styles.placement;
|
|
12
|
+
size?: DrawerTheme['variants']['size'];
|
|
7
13
|
} & HTMLElementProps<HTMLDialogElement>;
|
|
8
14
|
export declare const Drawer: React.FC<DrawerProps>;
|
|
15
|
+
export {};
|
|
9
16
|
//# sourceMappingURL=Drawer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../../src/components/overlay/Drawer/Drawer.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../../src/components/overlay/Drawer/Drawer.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,eAAe,EAGpB,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAE1C,KAAK,WAAW,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;AAE7C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,cAAc,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACrD,kFAAkF;IAClF,QAAQ,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,OAAO,MAAM,CAAC,SAAS,CAAC;IAC1C,IAAI,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;CACxC,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;AAExC,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAyDxC,CAAC"}
|
|
@@ -1,78 +1,59 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import { useRef
|
|
5
|
-
import { useClickOutside } from "../../../hooks/useClickOutside/useClickOutside.js";
|
|
3
|
+
import { classnames, composeRefs } from "@blockle/blocks-core";
|
|
4
|
+
import { useRef } from "react";
|
|
6
5
|
import { useComponentStyles } from "../../../hooks/useComponentStyles/useComponentStyles.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { usePreventBodyScroll } from "../../../hooks/usePreventBodyScroll/usePreventBodyScroll.js";
|
|
6
|
+
import { useModalDialog } from "../../../hooks/useModalDialog/useModalDialog.js";
|
|
7
|
+
import { useModalOverlay, DialogContext } from "../useModalOverlay.js";
|
|
10
8
|
import { drawer, placement } from "./drawer.css.js";
|
|
11
9
|
const Drawer = ({
|
|
12
10
|
open,
|
|
13
11
|
onRequestClose,
|
|
12
|
+
className,
|
|
14
13
|
placement: placement$1 = "left",
|
|
14
|
+
size,
|
|
15
15
|
children,
|
|
16
|
+
ref,
|
|
17
|
+
onKeyDown,
|
|
18
|
+
onKeyDownCapture,
|
|
19
|
+
onCancel,
|
|
16
20
|
...restProps
|
|
17
21
|
}) => {
|
|
18
22
|
const dialogRef = useRef(null);
|
|
19
|
-
const [visible, setVisible] = useState(open);
|
|
20
23
|
const rootClassName = useComponentStyles("drawer", {
|
|
21
24
|
root: true,
|
|
22
|
-
variants: { placement: placement$1 }
|
|
25
|
+
variants: { placement: placement$1, size }
|
|
23
26
|
});
|
|
24
27
|
const dataOpen = typeof window === "undefined" && open ? true : void 0;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
);
|
|
34
|
-
useKeyboard("Escape", onEscape, { enabled: open });
|
|
35
|
-
useIsomorphicLayoutEffect(() => {
|
|
36
|
-
if (open && visible) {
|
|
37
|
-
if (!dialogRef.current || !dialogRef.current.showModal) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
dialogRef.current.showModal();
|
|
41
|
-
} else if (open) {
|
|
42
|
-
setVisible(true);
|
|
43
|
-
} else {
|
|
44
|
-
if (!hasAnimationDuration(dialogRef.current)) {
|
|
45
|
-
setVisible(false);
|
|
46
|
-
}
|
|
47
|
-
if (dialogRef.current?.close) {
|
|
48
|
-
dialogRef.current.close();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}, [open, visible]);
|
|
52
|
-
const onAnimationEnd = useCallback(() => {
|
|
53
|
-
if (!open) {
|
|
54
|
-
setVisible(false);
|
|
55
|
-
}
|
|
56
|
-
}, [open]);
|
|
28
|
+
const { contextValue, closeRequestProps } = useModalOverlay(dialogRef, {
|
|
29
|
+
open,
|
|
30
|
+
onRequestClose,
|
|
31
|
+
onKeyDown,
|
|
32
|
+
onKeyDownCapture,
|
|
33
|
+
onCancel
|
|
34
|
+
});
|
|
35
|
+
const { visible, onAnimationEnd } = useModalDialog(dialogRef, open);
|
|
57
36
|
if (!visible) {
|
|
58
37
|
return null;
|
|
59
38
|
}
|
|
60
|
-
return /* @__PURE__ */ jsx(
|
|
39
|
+
return /* @__PURE__ */ jsx(DialogContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
61
40
|
"dialog",
|
|
62
41
|
{
|
|
63
|
-
ref: dialogRef,
|
|
42
|
+
ref: composeRefs(ref, dialogRef),
|
|
64
43
|
open: dataOpen,
|
|
65
44
|
className: classnames(
|
|
66
45
|
drawer,
|
|
67
46
|
placement[placement$1],
|
|
68
|
-
rootClassName
|
|
47
|
+
rootClassName,
|
|
48
|
+
className
|
|
69
49
|
),
|
|
70
50
|
onAnimationEnd,
|
|
71
51
|
onTransitionEnd: onAnimationEnd,
|
|
72
52
|
...restProps,
|
|
53
|
+
...closeRequestProps,
|
|
73
54
|
children
|
|
74
55
|
}
|
|
75
|
-
);
|
|
56
|
+
) });
|
|
76
57
|
};
|
|
77
58
|
export {
|
|
78
59
|
Drawer
|