@a-type/ui 6.1.16 → 6.1.19
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/components/button/ConfirmedButton.js +2 -2
- package/dist/components/button/ConfirmedButton.js.map +1 -1
- package/dist/components/datePicker/DatePicker.d.ts +1 -1
- package/dist/components/datePicker/DatePicker.stories.d.ts +1 -1
- package/dist/components/datePicker/DateRangePicker.d.ts +1 -1
- package/dist/components/datePicker/DateRangePicker.js +15 -1
- package/dist/components/datePicker/DateRangePicker.js.map +1 -1
- package/dist/components/dialog/Dialog.d.ts +20 -34
- package/dist/components/dialog/Dialog.js +47 -208
- package/dist/components/dialog/Dialog.js.map +1 -1
- package/dist/components/dialog/Dialog.module.css +10 -82
- package/dist/components/dialog/Dialog.stories.js +8 -7
- package/dist/components/dialog/Dialog.stories.js.map +1 -1
- package/dist/components/drawer/Drawer.d.ts +24 -0
- package/dist/components/drawer/Drawer.js +101 -0
- package/dist/components/drawer/Drawer.js.map +1 -0
- package/dist/components/drawer/Drawer.module.css +236 -0
- package/dist/components/drawer/Drawer.stories.d.ts +7 -0
- package/dist/components/drawer/Drawer.stories.js +28 -0
- package/dist/components/drawer/Drawer.stories.js.map +1 -0
- package/dist/components/drawer/index.d.ts +1 -0
- package/dist/components/drawer/index.js +2 -0
- package/dist/components/drawer/index.js.map +1 -0
- package/dist/components/globalErrorFallback/GlobalErrorFallback.d.ts +1 -1
- package/dist/components/globalErrorFallback/GlobalErrorFallback.js +2 -1
- package/dist/components/globalErrorFallback/GlobalErrorFallback.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/scrollArea/ScrollArea.module.css +1 -0
- package/dist/hooks/withContextVariant.d.ts +8 -0
- package/dist/hooks/withContextVariant.js +21 -0
- package/dist/hooks/withContextVariant.js.map +1 -0
- package/package.json +3 -2
- package/src/components/button/ConfirmedButton.tsx +9 -16
- package/src/components/datePicker/DateRangePicker.tsx +18 -1
- package/src/components/dialog/Dialog.module.css +10 -82
- package/src/components/dialog/Dialog.stories.tsx +45 -51
- package/src/components/dialog/Dialog.tsx +98 -332
- package/src/components/drawer/Drawer.module.css +235 -0
- package/src/components/drawer/Drawer.stories.tsx +109 -0
- package/src/components/drawer/Drawer.tsx +189 -0
- package/src/components/drawer/index.ts +1 -0
- package/src/components/globalErrorFallback/GlobalErrorFallback.tsx +2 -1
- package/src/components/index.ts +1 -0
- package/src/components/scrollArea/ScrollArea.module.css +1 -0
- package/src/hooks/withContextVariant.tsx +24 -0
|
@@ -8,7 +8,7 @@ import { Provider } from '../provider/Provider.js';
|
|
|
8
8
|
import { Select } from '../select/index.js';
|
|
9
9
|
import { Tooltip } from '../tooltip/Tooltip.js';
|
|
10
10
|
import { H1, P } from '../typography/index.js';
|
|
11
|
-
import { Dialog
|
|
11
|
+
import { Dialog } from './Dialog.js';
|
|
12
12
|
const meta = {
|
|
13
13
|
title: 'Components/Dialog',
|
|
14
14
|
component: Dialog,
|
|
@@ -23,22 +23,23 @@ function DummyContent() {
|
|
|
23
23
|
}
|
|
24
24
|
export const Default = {
|
|
25
25
|
args: {
|
|
26
|
-
children: (_jsxs(ParticleLayer, { noPortal: true, children: [_jsx(
|
|
26
|
+
children: (_jsxs(ParticleLayer, { noPortal: true, children: [_jsx(Dialog.Trigger, { render: _jsx(Button, {}), children: "Open" }), _jsx(DummyContent, {}), _jsxs(Dialog.Content, { children: [_jsx(Dialog.Title, { children: "Hello world" }), _jsx(DummyContent, {}), _jsx(DummyContent, {}), _jsx(DummyContent, {}), _jsxs(Box, { gap: true, children: [_jsx(Input, { placeholder: "Type something..." }), _jsx(Button, { emphasis: "primary", children: "Submit" })] }), _jsxs(Dialog.Actions, { children: [_jsx(Dialog.Close, {}), _jsx(Button, { emphasis: "primary", children: "Accept" })] })] })] })),
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
29
|
export const Small = {
|
|
30
30
|
args: {
|
|
31
|
-
children: (_jsxs(ParticleLayer, { noPortal: true, children: [_jsx(
|
|
31
|
+
children: (_jsxs(ParticleLayer, { noPortal: true, children: [_jsx(Dialog.Trigger, { render: _jsx(Button, {}), children: "Open" }), _jsx(DummyContent, {}), _jsxs(Dialog.Content, { children: [_jsx(Dialog.Title, { children: "Hello world" }), _jsx(DummyContent, {}), _jsx(Dialog.Actions, { children: _jsx(Dialog.Close, {}) })] })] })),
|
|
32
32
|
},
|
|
33
33
|
};
|
|
34
34
|
export const NoSheet = {
|
|
35
35
|
args: {
|
|
36
|
-
|
|
36
|
+
disableSheet: true,
|
|
37
|
+
children: (_jsxs(ParticleLayer, { noPortal: true, children: [_jsx(Dialog.Trigger, { render: _jsx(Button, {}), children: "Open" }), _jsx(DummyContent, {}), _jsxs(Dialog.Content, { children: [_jsx(Dialog.Title, { children: "Hello world" }), _jsx(Dialog.Actions, { children: _jsx(Dialog.Close, {}) })] })] })),
|
|
37
38
|
},
|
|
38
39
|
};
|
|
39
40
|
export const Positioned = {
|
|
40
41
|
args: {
|
|
41
|
-
children: (_jsxs(ParticleLayer, { noPortal: true, children: [_jsx(
|
|
42
|
+
children: (_jsxs(ParticleLayer, { noPortal: true, children: [_jsx(Dialog.Trigger, { render: _jsx(Button, {}), children: "Open" }), _jsx(DummyContent, {}), _jsxs(Dialog.Content, { style: { bottom: 0, top: 'auto' }, children: [_jsx(Dialog.Title, { children: "Hello world" }), _jsx(Dialog.Actions, { children: _jsx(Dialog.Close, {}) })] })] })),
|
|
42
43
|
},
|
|
43
44
|
};
|
|
44
45
|
export const VirtualKeyboard = {
|
|
@@ -52,7 +53,7 @@ export const VirtualKeyboard = {
|
|
|
52
53
|
document.body.style.removeProperty('--mock-virtual-keyboard-height');
|
|
53
54
|
}
|
|
54
55
|
}, [keyboard]);
|
|
55
|
-
return (_jsxs(Provider, { virtualKeyboardBehavior: "overlay", children: [_jsxs(Dialog, { children: [_jsx(
|
|
56
|
+
return (_jsxs(Provider, { virtualKeyboardBehavior: "overlay", children: [_jsxs(Dialog, { children: [_jsx(Dialog.Trigger, { render: _jsx(Button, {}), children: "Open" }), _jsx(DummyContent, {}), _jsxs(Dialog.Content, { children: [_jsx(Dialog.Title, { children: "Hello world" }), _jsx(Input, {}), _jsxs(Dialog.Actions, { children: [_jsx(Dialog.Close, {}), _jsx(Button, { onClick: () => setKeyboard((v) => !v), children: "Toggle fake kb" })] })] })] }), _jsx("div", { className: "bg-neutral-ink", style: {
|
|
56
57
|
position: 'fixed',
|
|
57
58
|
bottom: 0,
|
|
58
59
|
left: 0,
|
|
@@ -65,7 +66,7 @@ export const VirtualKeyboard = {
|
|
|
65
66
|
};
|
|
66
67
|
export const MultiNested = {
|
|
67
68
|
render() {
|
|
68
|
-
return (_jsxs(Dialog, { children: [_jsx(
|
|
69
|
+
return (_jsxs(Dialog, { children: [_jsx(Dialog.Trigger, { render: _jsx(Button, {}), children: "Open" }), _jsxs(Dialog.Content, { children: [_jsx(Dialog.Title, { children: "Hello world" }), _jsx(DummyContent, {}), _jsxs(Select, { value: "", children: [_jsx(Select.Trigger, { children: _jsx(Select.Value, {}) }), _jsxs(Select.Content, { children: [_jsx(Select.Item, { value: null, children: "Select an option" }), _jsx(Select.Item, { value: "option1", children: "Option 1" }), _jsx(Select.Item, { value: "option2", children: "Option 2" }), _jsx(Select.Item, { value: "option3", children: "Option 3" })] })] }), _jsxs(Dialog, { children: [_jsx(Dialog.Trigger, { render: _jsx(Button, {}), children: "Open nested" }), _jsxs(Dialog.Content, { children: [_jsx(Dialog.Title, { children: "Nested dialog" }), _jsx(Tooltip, { content: "This is a tooltip", children: _jsx(Button, { children: "Hover me" }) }), _jsx(DummyContent, {}), _jsx(DummyContent, {})] })] })] })] }));
|
|
69
70
|
},
|
|
70
71
|
};
|
|
71
72
|
export const Selectable = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.stories.js","sourceRoot":"","sources":["../../../src/components/dialog/Dialog.stories.tsx"],"names":[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AAS,yBAA6B,IAC5C,IACJ,IACT,CACT,CAAC;IACH,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Drawer as BaseDrawer, DrawerCloseProps, DrawerPopupProps, DrawerRootProps, DrawerTriggerProps } from '@base-ui/react/drawer';
|
|
2
|
+
import { Ref } from 'react';
|
|
3
|
+
export interface DrawerContentProps extends DrawerPopupProps {
|
|
4
|
+
disableDefaultClose?: boolean;
|
|
5
|
+
ref?: Ref<HTMLDivElement>;
|
|
6
|
+
innerClassName?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface DrawerProps extends Omit<DrawerRootProps, 'swipeDirection'> {
|
|
9
|
+
}
|
|
10
|
+
declare function DrawerClose({ children, render, ...props }: DrawerCloseProps & {
|
|
11
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const Drawer: (({ children, snapPoints, ...props }: DrawerProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
14
|
+
Trigger: ({ render, ...props }: DrawerTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
Content: ({ ref, children, className, disableDefaultClose, innerClassName, ...props }: DrawerContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
Title: import("react").FunctionComponent<import("@base-ui/react/drawer").DrawerTitleProps>;
|
|
17
|
+
Description: import("react").FunctionComponent<import("@base-ui/react/drawer").DrawerDescriptionProps>;
|
|
18
|
+
Close: typeof DrawerClose;
|
|
19
|
+
Actions: import("react").FunctionComponent<import("../box/Box.js").BoxProps>;
|
|
20
|
+
Unstyled: DrawerParts;
|
|
21
|
+
createHandle: typeof BaseDrawer.createHandle;
|
|
22
|
+
};
|
|
23
|
+
export type DrawerParts = typeof BaseDrawer;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Drawer as BaseDrawer, } from '@base-ui/react/drawer';
|
|
14
|
+
import clsx from 'clsx';
|
|
15
|
+
import { useCallback, useRef } from 'react';
|
|
16
|
+
import useMergedRef from '../../hooks/useMergedRef.js';
|
|
17
|
+
import { withClassName } from '../../hooks/withClassName.js';
|
|
18
|
+
import { Box } from '../box/Box.js';
|
|
19
|
+
import { Button } from '../button/index.js';
|
|
20
|
+
import { Icon } from '../icon/Icon.js';
|
|
21
|
+
import { useParticles } from '../particles/ParticleContext.js';
|
|
22
|
+
import cls from './Drawer.module.css';
|
|
23
|
+
const DrawerBackdrop = withClassName(BaseDrawer.Backdrop, cls.overlay);
|
|
24
|
+
const StyledPopup = withClassName(BaseDrawer.Popup, cls.popup);
|
|
25
|
+
const DrawerContent = function DrawerContent(_a) {
|
|
26
|
+
var { ref, children, className, disableDefaultClose, innerClassName } = _a, props = __rest(_a, ["ref", "children", "className", "disableDefaultClose", "innerClassName"]);
|
|
27
|
+
const particles = useParticles();
|
|
28
|
+
const wasOpenRef = useRef(false);
|
|
29
|
+
const openRef = useCallback((element) => {
|
|
30
|
+
if (!wasOpenRef.current && (element === null || element === void 0 ? void 0 : element.hasAttribute('data-open'))) {
|
|
31
|
+
wasOpenRef.current = true;
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
particles === null || particles === void 0 ? void 0 : particles.addParticles(particles.elementExplosion({
|
|
34
|
+
count: 20,
|
|
35
|
+
margin: 40,
|
|
36
|
+
borders: ['top'],
|
|
37
|
+
color: [
|
|
38
|
+
{
|
|
39
|
+
space: 'rgb',
|
|
40
|
+
values: [0, 0, 0],
|
|
41
|
+
opacity: 0.02,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
space: 'rgb',
|
|
45
|
+
values: [0, 0, 0],
|
|
46
|
+
opacity: 0,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
element,
|
|
50
|
+
startRadius: 15,
|
|
51
|
+
endRadius: 0,
|
|
52
|
+
lifespan: 1000,
|
|
53
|
+
force: 0.5,
|
|
54
|
+
drag: 0.01,
|
|
55
|
+
forceFuzz: 0.5,
|
|
56
|
+
angleFuzz: 0.1,
|
|
57
|
+
}));
|
|
58
|
+
}, 180);
|
|
59
|
+
}
|
|
60
|
+
else if (!(element === null || element === void 0 ? void 0 : element.hasAttribute('data-open'))) {
|
|
61
|
+
wasOpenRef.current = false;
|
|
62
|
+
}
|
|
63
|
+
}, [particles]);
|
|
64
|
+
const finalRef = useMergedRef(ref, openRef);
|
|
65
|
+
return (_jsx(BaseDrawer.VirtualKeyboardProvider, { children: _jsxs(BaseDrawer.Portal, { children: [_jsx(DrawerBackdrop, { "data-role": "backdrop" }), _jsx(BaseDrawer.Viewport, { className: cls.viewport, children: _jsxs(StyledPopup, Object.assign({ ref: finalRef }, props, { className: className, children: [!disableDefaultClose && _jsx(DrawerDefaultClose, {}), _jsx(DrawerSwipeHandle, {}), _jsx("div", { className: clsx(cls.contentScrollArea, innerClassName), children: children })] })) })] }) }));
|
|
66
|
+
};
|
|
67
|
+
function DrawerSwipeHandle(_a) {
|
|
68
|
+
var { ref, className } = _a, props = __rest(_a, ["ref", "className"]);
|
|
69
|
+
return (_jsx("div", Object.assign({ ref: ref }, props, { className: clsx(cls.swipeHandle, className), children: _jsx("div", { className: cls.swipeHandleBar }) })));
|
|
70
|
+
}
|
|
71
|
+
function DrawerDefaultClose(_a) {
|
|
72
|
+
var { ref, className } = _a, props = __rest(_a, ["ref", "className"]);
|
|
73
|
+
return (_jsx(DrawerClose, Object.assign({ className: clsx(cls.close, className), "aria-label": "Close drawer", ref: ref }, props, { render: _jsx(Button, { emphasis: "ghost", size: "small" }), children: _jsx(Icon, { name: "x" }) })));
|
|
74
|
+
}
|
|
75
|
+
const DrawerTitle = withClassName(BaseDrawer.Title, cls.title);
|
|
76
|
+
const DrawerDescription = withClassName(BaseDrawer.Description, cls.description);
|
|
77
|
+
const defaultSnapPoints = [0.75, 1];
|
|
78
|
+
const DrawerRoot = (_a) => {
|
|
79
|
+
var { children, snapPoints = defaultSnapPoints } = _a, props = __rest(_a, ["children", "snapPoints"]);
|
|
80
|
+
return (_jsx(BaseDrawer.Root, Object.assign({ swipeDirection: "down", snapPoints: snapPoints }, props, { children: children })));
|
|
81
|
+
};
|
|
82
|
+
const DrawerTrigger = (_a) => {
|
|
83
|
+
var { render } = _a, props = __rest(_a, ["render"]);
|
|
84
|
+
return (_jsx(BaseDrawer.Trigger, Object.assign({ render: render || _jsx(Button, {}) }, props)));
|
|
85
|
+
};
|
|
86
|
+
function DrawerClose(_a) {
|
|
87
|
+
var { children, render } = _a, props = __rest(_a, ["children", "render"]);
|
|
88
|
+
return (_jsx(BaseDrawer.Close, Object.assign({ render: render !== null && render !== void 0 ? render : _jsx(Button, { emphasis: "default" }) }, props, { children: children !== null && children !== void 0 ? children : 'Close' })));
|
|
89
|
+
}
|
|
90
|
+
const DrawerActions = withClassName(Box, cls.actions);
|
|
91
|
+
export const Drawer = Object.assign(DrawerRoot, {
|
|
92
|
+
Trigger: DrawerTrigger,
|
|
93
|
+
Content: DrawerContent,
|
|
94
|
+
Title: DrawerTitle,
|
|
95
|
+
Description: DrawerDescription,
|
|
96
|
+
Close: DrawerClose,
|
|
97
|
+
Actions: DrawerActions,
|
|
98
|
+
Unstyled: BaseDrawer,
|
|
99
|
+
createHandle: BaseDrawer.createHandle,
|
|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AAE,UAAyB;IACnC,YAAY,EAAE,UAAU,CAAC,YAAY;CACrC,CAAC,CAAC"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
@layer components {.overlay {
|
|
2
|
+
--bleed: 3rem;
|
|
3
|
+
--swipe-opacity: 0.2;
|
|
4
|
+
|
|
5
|
+
position: fixed;
|
|
6
|
+
min-height: 100dvh;
|
|
7
|
+
inset: 0;
|
|
8
|
+
|
|
9
|
+
@apply --mx-bg(var(--m-gray-ink));
|
|
10
|
+
opacity: calc(
|
|
11
|
+
0.2 + var(--swipe-opacity) * (1 - var(--drawer-swipe-progress, 0))
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
border-top: var(--m-lw) solid var(--m-gray);
|
|
15
|
+
|
|
16
|
+
transition: all var(--m-dur-long) var(--m-ease);
|
|
17
|
+
|
|
18
|
+
backdrop-filter: blur(2px);
|
|
19
|
+
|
|
20
|
+
&[data-starting-style],
|
|
21
|
+
&[data-ending-style] {
|
|
22
|
+
opacity: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&[data-swiping] {
|
|
26
|
+
transition-duration: 0ms;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&[data-ending-style] {
|
|
30
|
+
transition-duration: calc(var(--drawer-swipe-strength) * var(--m-dur-long));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.viewport {
|
|
35
|
+
--bleed: 3rem;
|
|
36
|
+
|
|
37
|
+
position: fixed;
|
|
38
|
+
inset: 0;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: flex-end;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
touch-action: none;
|
|
43
|
+
|
|
44
|
+
&::after {
|
|
45
|
+
content: '';
|
|
46
|
+
position: fixed;
|
|
47
|
+
inset-inline: 0;
|
|
48
|
+
bottom: 0;
|
|
49
|
+
height: var(--bleed);
|
|
50
|
+
@apply --mx-bg(var(--m-surface-ambient-bg));
|
|
51
|
+
pointer-events: none;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&[data-closed]::after {
|
|
55
|
+
opacity: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* While swiping, the popup's own bleed covers the bottom edge, so hide the
|
|
59
|
+
fixed fill — otherwise it paints white over the backdrop once the popup is
|
|
60
|
+
dragged far enough down. */
|
|
61
|
+
&:has([data-swiping])::after {
|
|
62
|
+
opacity: 0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.popup {
|
|
67
|
+
--bleed: 3rem;
|
|
68
|
+
--top-gap: 1rem;
|
|
69
|
+
|
|
70
|
+
box-sizing: border-box;
|
|
71
|
+
position: relative;
|
|
72
|
+
z-index: 1;
|
|
73
|
+
max-width: unset;
|
|
74
|
+
width: 100%;
|
|
75
|
+
max-height: calc(100% - var(--top-gap) + var(--bleed));
|
|
76
|
+
height: calc(100% - var(--top-gap) + var(--bleed));
|
|
77
|
+
margin-bottom: calc(-1 * var(--bleed));
|
|
78
|
+
padding-bottom: max(
|
|
79
|
+
0px,
|
|
80
|
+
calc(var(--drawer-snap-point-offset) + var(--drawer-swipe-movement-y))
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
display: flex;
|
|
84
|
+
flex-direction: column;
|
|
85
|
+
align-items: stretch;
|
|
86
|
+
|
|
87
|
+
@apply --mx-bg(var(--m-surface-ambient-bg));
|
|
88
|
+
@apply --mx-borderColor(var(--m-gray-heavy));
|
|
89
|
+
|
|
90
|
+
touch-action: none;
|
|
91
|
+
|
|
92
|
+
overflow: visible;
|
|
93
|
+
|
|
94
|
+
transition:
|
|
95
|
+
transform var(--m-dur-long) var(--m-ease),
|
|
96
|
+
box-shadow var(--m-dur-long) var(--m-ease),
|
|
97
|
+
padding-bottom var(--m-dur-long) var(--m-ease);
|
|
98
|
+
|
|
99
|
+
--shadow-dir: -1;
|
|
100
|
+
@apply --mx-shadow;
|
|
101
|
+
--mx-shadow-value: 0 calc(var(--shadow-dir, 1) * var(--m-shadow-lg-y))
|
|
102
|
+
var(--m-shadow-lg-blur) var(--m-shadow-lg-spread) var(--m-shadow-lg-color);
|
|
103
|
+
|
|
104
|
+
border-radius: var(--m-surface-rd) var(--m-surface-rd) 0 0;
|
|
105
|
+
border-bottom-width: 0;
|
|
106
|
+
|
|
107
|
+
transform: translateY(
|
|
108
|
+
calc(
|
|
109
|
+
var(--drawer-swipe-movement-y) + var(--drawer-snap-point-offset) -
|
|
110
|
+
var(--bleed)
|
|
111
|
+
)
|
|
112
|
+
);
|
|
113
|
+
will-change: transform;
|
|
114
|
+
|
|
115
|
+
/* Disable transitions while swiping so movement is immediate */
|
|
116
|
+
&[data-swiping] {
|
|
117
|
+
transition: none;
|
|
118
|
+
user-select: none;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
&[data-starting-style],
|
|
122
|
+
&[data-ending-style] {
|
|
123
|
+
transform: translateY(calc(100% - var(--bleed)));
|
|
124
|
+
padding-bottom: 0;
|
|
125
|
+
box-shadow: 0 0 0 transparent;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&[data-ending-style] {
|
|
129
|
+
transition-duration: calc(var(--drawer-swipe-strength) * var(--m-dur-long));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&::after {
|
|
133
|
+
content: '';
|
|
134
|
+
position: absolute;
|
|
135
|
+
inset-inline: 0;
|
|
136
|
+
top: 100%;
|
|
137
|
+
height: var(--bleed);
|
|
138
|
+
background-color: inherit;
|
|
139
|
+
pointer-events: none;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.contentScrollArea {
|
|
144
|
+
flex: 1 1 auto;
|
|
145
|
+
min-height: 0;
|
|
146
|
+
overscroll-behavior: contain;
|
|
147
|
+
touch-action: auto;
|
|
148
|
+
overflow-y: auto;
|
|
149
|
+
padding: var(--m-surface-p);
|
|
150
|
+
display: flex;
|
|
151
|
+
flex-direction: column;
|
|
152
|
+
gap: var(--m-sp-md);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.swipeHandle {
|
|
156
|
+
position: relative;
|
|
157
|
+
display: flex;
|
|
158
|
+
align-items: center;
|
|
159
|
+
justify-content: center;
|
|
160
|
+
width: 100%;
|
|
161
|
+
cursor: grab;
|
|
162
|
+
touch-action: none;
|
|
163
|
+
padding-block: var(--m-sp-lg);
|
|
164
|
+
user-select: none;
|
|
165
|
+
flex-shrink: 0;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.swipeHandleBar {
|
|
169
|
+
height: --fn-literal(4px);
|
|
170
|
+
width: 20%;
|
|
171
|
+
@apply --mx-bg(var(--m-gray));
|
|
172
|
+
border-radius: var(--m-rd-lg);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.close {
|
|
176
|
+
position: absolute;
|
|
177
|
+
right: var(--m-sp-sm);
|
|
178
|
+
top: var(--m-sp-sm);
|
|
179
|
+
z-index: 101;
|
|
180
|
+
display: flex;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.title {
|
|
184
|
+
@apply --mx-fg(var(--m-gray-ink));
|
|
185
|
+
font-size: var(--m-prose-primary-size);
|
|
186
|
+
font-weight: var(--m-prose-primary-weight);
|
|
187
|
+
line-height: var(--m-prose-primary-lineHeight);
|
|
188
|
+
margin-block-end: var(--m-sp-xs);
|
|
189
|
+
margin-block-start: 0;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.description {
|
|
193
|
+
@apply --mx-fg(var(--m-gray-heavy));
|
|
194
|
+
font-size: var(--m-prose-ambient-size);
|
|
195
|
+
line-height: var(--m-prose-ambient-lineHeight);
|
|
196
|
+
margin: 0;
|
|
197
|
+
margin-block-end: var(--m-sp-xs);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.actions {
|
|
201
|
+
position: sticky;
|
|
202
|
+
bottom: 0;
|
|
203
|
+
z-index: 100;
|
|
204
|
+
display: flex;
|
|
205
|
+
flex-direction: row;
|
|
206
|
+
flex-wrap: wrap;
|
|
207
|
+
align-items: center;
|
|
208
|
+
justify-content: end;
|
|
209
|
+
align-self: end;
|
|
210
|
+
@apply --mx-shadow;
|
|
211
|
+
--mx-shadow-value: 0 calc(-1 * var(--m-shadow-md-y)) 16px
|
|
212
|
+
var(--m-shadow-md-spread) var(--m-gray-paper);
|
|
213
|
+
@apply --mx-bg(var(--m-surface-ambient-bg));
|
|
214
|
+
@apply --mx-bg-faded(50%);
|
|
215
|
+
margin-block-start: var(--m-sp-md);
|
|
216
|
+
gap: var(--m-sp-sm);
|
|
217
|
+
border-radius: var(--m-surface-rd);
|
|
218
|
+
transition: bottom var(--m-dur) var(--m-ease);
|
|
219
|
+
|
|
220
|
+
/*
|
|
221
|
+
Hide the actions when the keyboard is open.
|
|
222
|
+
Done by moving them downward behind it.
|
|
223
|
+
This both fixes a bug with the positioning, and
|
|
224
|
+
gives the user more room to see.
|
|
225
|
+
*/
|
|
226
|
+
transform: translateY(calc(2 * var(--drawer-keyboard-inset, 0px)));
|
|
227
|
+
/*
|
|
228
|
+
Same but with modern CSS if()
|
|
229
|
+
*/
|
|
230
|
+
@supports (
|
|
231
|
+
display: if(style(--drawer-keyboard-inset > 0px): none; else: flex;)
|
|
232
|
+
) {
|
|
233
|
+
display: if(style(--drawer-keyboard-inset > 0px): none; else: flex;);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { Drawer } from './Drawer.js';
|
|
3
|
+
declare const meta: any;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Drawer>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const NoDefaultClose: Story;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from '../button/index.js';
|
|
3
|
+
import { Input } from '../input/Input.js';
|
|
4
|
+
import { H1, P } from '../typography/index.js';
|
|
5
|
+
import { Drawer } from './Drawer.js';
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Components/Drawer',
|
|
8
|
+
component: Drawer,
|
|
9
|
+
argTypes: {},
|
|
10
|
+
parameters: {
|
|
11
|
+
controls: { expanded: true },
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default meta;
|
|
15
|
+
function DummyContent() {
|
|
16
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx(H1, { children: "Some content" }), _jsx(P, { children: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi." }), _jsx(Input, { placeholder: "Type something..." }), _jsx(P, { children: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi." }), _jsx(Input, { placeholder: "Type something..." }), _jsx(P, { children: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi." }), _jsx(Input, { placeholder: "Type something..." }), _jsx(P, { children: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi." }), _jsx(Input, { placeholder: "Type something..." }), _jsx(P, { children: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi." }), _jsx(Input, { placeholder: "Type something..." }), _jsx(P, { children: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi." }), _jsx(Input, { placeholder: "Type something..." })] }));
|
|
17
|
+
}
|
|
18
|
+
export const Default = {
|
|
19
|
+
args: {
|
|
20
|
+
children: (_jsxs(_Fragment, { children: [_jsx(Drawer.Trigger, { render: _jsx(Button, {}), children: "Open" }), _jsxs(Drawer.Content, { children: [_jsx(Drawer.Title, { children: "Hello world" }), _jsx(DummyContent, {}), _jsxs(Drawer.Actions, { children: [_jsx(Drawer.Close, {}), _jsx(Button, { emphasis: "primary", children: "Accept" })] })] })] })),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
export const NoDefaultClose = {
|
|
24
|
+
args: {
|
|
25
|
+
children: (_jsxs(_Fragment, { children: [_jsx(Drawer.Trigger, { render: _jsx(Button, {}), children: "Open" }), _jsxs(Drawer.Content, { disableDefaultClose: true, children: [_jsx(Drawer.Title, { children: "No default close" }), _jsx(DummyContent, {}), _jsx(Drawer.Actions, { children: _jsx(Drawer.Close, {}) })] })] })),
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=Drawer.stories.js.map
|
|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E,CACT,8BACC,KAAC,MAAM,CAAC,OAAO,IAAC,MAAM,EAAE,KAAC,MAAM,KAAG,qBAAuB,EACzD,MAAC,MAAM,CAAC,OAAO,eACd,KAAC,MAAM,CAAC,KAAK,8BAA2B,EACxC,KAAC,YAAY,KAAG,EAChB,MAAC,MAAM,CAAC,OAAO,eACd,KAAC,MAAM,CAAC,KAAK,KAAG,EAChB,KAAC,MAAM,IAAC,QAAQ,EAAC,SAAS,uBAAgB,IAC1B,IACD,IACf,CACH;KACD;CACD,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAU;IACpC,IAAI,EAAE;QACL,QAAQ,EAAE,CACT,8BACC,KAAC,MAAM,CAAC,OAAO,IAAC,MAAM,EAAE,KAAC,MAAM,KAAG,qBAAuB,EACzD,MAAC,MAAM,CAAC,OAAO,IAAC,mBAAmB,mBAClC,KAAC,MAAM,CAAC,KAAK,mCAAgC,EAC7C,KAAC,YAAY,KAAG,EAChB,KAAC,MAAM,CAAC,OAAO,cACd,KAAC,MAAM,CAAC,KAAK,KAAG,GACA,IACD,IACf,CACH;KACD;CACD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Drawer.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/drawer/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BoxProps } from '
|
|
1
|
+
import { type BoxProps } from '../box/Box.js';
|
|
2
2
|
export declare function GlobalErrorFallback({ children, ...rest }: BoxProps): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
import { ButtonProps } from '@a-type/ui';
|
|
4
4
|
export interface ReloadButtonProps extends ButtonProps {
|
|
@@ -10,8 +10,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { Box, Heading, P } from '@a-type/ui';
|
|
14
13
|
import { useLocalStorage } from '../../hooks.js';
|
|
14
|
+
import { Box } from '../box/Box.js';
|
|
15
|
+
import { Heading, P } from '../typography/typography.js';
|
|
15
16
|
export function GlobalErrorFallback(_a) {
|
|
16
17
|
var { children } = _a, rest = __rest(_a, ["children"]);
|
|
17
18
|
const hadRecentError = useHadRecentError();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalErrorFallback.js","sourceRoot":"","sources":["../../../src/components/globalErrorFallback/GlobalErrorFallback.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"GlobalErrorFallback.js","sourceRoot":"","sources":["../../../src/components/globalErrorFallback/GlobalErrorFallback.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAiB,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,6BAA6B,CAAC;AAEzD,MAAM,UAAU,mBAAmB,CAAC,EAA+B;QAA/B,EAAE,QAAQ,OAAqB,EAAhB,IAAI,cAAnB,YAAqB,CAAF;IACtD,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;IAE3C,OAAO,CACN,KAAC,GAAG,kBAAC,GAAG,QAAC,MAAM,EAAC,eAAe,EAAC,CAAC,UAAK,IAAI,cACzC,MAAC,GAAG,IACH,GAAG,QACH,KAAK,EAAC,OAAO,EACb,OAAO,EAAC,QAAQ,EAChB,GAAG,QACH,KAAK,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE,aAElC,KAAC,OAAO,IAAC,QAAQ,EAAC,SAAS,EAAC,MAAM,EAAE,cAAM,qCAEhC,EACV,MAAC,CAAC,yDACsC,GAAG,EACzC,cAAc;4BACd,CAAC,CAAC,iGAAiG;4BACnG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extMenu.js';
|
|
15
15
|
export * from './datePicker/index.js';
|
|
16
16
|
export * from './dialog/index.js';
|
|
17
|
+
export * from './drawer/index.js';
|
|
17
18
|
export * from './divider/index.js';
|
|
18
19
|
export * from './dropdownMenu/index.js';
|
|
19
20
|
export * from './editableText/EditableText.js';
|
package/dist/components/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export * from './combobox/Combobox.js';
|
|
|
14
14
|
export * from './contextMenu/contextMenu.js';
|
|
15
15
|
export * from './datePicker/index.js';
|
|
16
16
|
export * from './dialog/index.js';
|
|
17
|
+
export * from './drawer/index.js';
|
|
17
18
|
export * from './divider/index.js';
|
|
18
19
|
export * from './dropdownMenu/index.js';
|
|
19
20
|
export * from './editableText/EditableText.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,oCAAoC,CAAC;AACnD,cAAc,iBAAiB,CAAC;AAChC,cAA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AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oCAAoC,CAAC;AACnD,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a context and HOC which swaps between two components
|
|
3
|
+
* based on a contextual value
|
|
4
|
+
*/
|
|
5
|
+
export declare function createWithContextVariant(): {
|
|
6
|
+
Context: import("react").Context<boolean>;
|
|
7
|
+
withContextVariant: <P extends object>(TrueComponent: React.ComponentType<P>, FalseComponent: React.ComponentType<P>) => (props: P) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a context and HOC which swaps between two components
|
|
5
|
+
* based on a contextual value
|
|
6
|
+
*/
|
|
7
|
+
export function createWithContextVariant() {
|
|
8
|
+
const Context = createContext(false);
|
|
9
|
+
function withContextVariant(TrueComponent, FalseComponent) {
|
|
10
|
+
return function WithContextVariant(props) {
|
|
11
|
+
const contextValue = useContext(Context);
|
|
12
|
+
const Component = contextValue ? TrueComponent : FalseComponent;
|
|
13
|
+
return _jsx(Component, Object.assign({}, props));
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
Context,
|
|
18
|
+
withContextVariant,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=withContextVariant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withContextVariant.js","sourceRoot":"","sources":["../../src/hooks/withContextVariant.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElD;;;GAGG;AACH,MAAM,UAAU,wBAAwB;IACvC,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACrC,SAAS,kBAAkB,CAC1B,aAAqC,EACrC,cAAsC;QAEtC,OAAO,SAAS,kBAAkB,CAAC,KAAQ;YAC1C,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;YACzC,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,CAAC;YAChE,OAAO,KAAC,SAAS,oBAAK,KAAK,EAAI,CAAC;QACjC,CAAC,CAAC;IACH,CAAC;IAED,OAAO;QACN,OAAO;QACP,kBAAkB;KAClB,CAAC;AACH,CAAC"}
|