@a-type/ui 6.1.16 → 6.1.18
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 +25 -0
- package/dist/components/drawer/Drawer.js +102 -0
- package/dist/components/drawer/Drawer.js.map +1 -0
- package/dist/components/drawer/Drawer.module.css +182 -0
- package/dist/components/drawer/Drawer.stories.d.ts +7 -0
- package/dist/components/drawer/Drawer.stories.js +27 -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/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- 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 +2 -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 +181 -0
- package/src/components/drawer/Drawer.stories.tsx +68 -0
- package/src/components/drawer/Drawer.tsx +204 -0
- package/src/components/drawer/index.ts +1 -0
- package/src/components/index.ts +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":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,E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AO,eACd,KAAC,MAAM,CAAC,IAAI,IAAC,KAAK,EAAE,IAAI,iCAAgC,EACxD,KAAC,MAAM,CAAC,IAAI,IAAC,KAAK,EAAC,SAAS,yBAAuB,EACnD,KAAC,MAAM,CAAC,IAAI,IAAC,KAAK,EAAC,SAAS,yBAAuB,EACnD,KAAC,MAAM,CAAC,IAAI,IAAC,KAAK,EAAC,SAAS,yBAAuB,IACnC,IACT,EACT,MAAC,MAAM,eACN,KAAC,MAAM,CAAC,OAAO,IAAC,MAAM,EAAE,KAAC,MAAM,KAAG,4BAA8B,EAChE,MAAC,MAAM,CAAC,OAAO,eACd,KAAC,MAAM,CAAC,KAAK,gCAA6B,EAC1C,KAAC,OAAO,IAAC,OAAO,EAAC,mBAAmB,YACnC,KAAC,MAAM,2BAAkB,GAChB,EACV,KAAC,YAAY,KAAG,EAChB,KAAC,YAAY,KAAG,IACA,IACT,IACO,IACT,CACT,CAAC;IACH,CAAC;CACD,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAU;IAChC,MAAM;QACL,OAAO,CACN,MAAC,MAAM,eACN,KAAC,MAAM,CAAC,aAAa,uBAA4B,EACjD,MAAC,MAAM,CAAC,OAAO,eACd,KAAC,MAAM,CAAC,KAAK,8BAA2B,EACxC,MAAC,MAAM,CAAC,UAAU,eACjB,KAAC,MAAM,CAAC,UAAU,IAAC,KAAK,EAAC,SAAS,yBAA6B,EAC/D,KAAC,MAAM,CAAC,UAAU,IAAC,KAAK,EAAC,SAAS,yBAA6B,EAC/D,KAAC,MAAM,CAAC,UAAU,IAAC,KAAK,EAAC,SAAS,yBAA6B,IAC5C,IACJ,IACT,CACT,CAAC;IACH,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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, 'children' | 'swipeDirection'> {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
declare function DrawerClose({ children, render, ...props }: DrawerCloseProps & {
|
|
12
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
13
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const Drawer: (({ children, defaultSnapPoint, snapPoints, ...props }: DrawerProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
15
|
+
Trigger: ({ render, ...props }: DrawerTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
Content: ({ ref, children, className, disableDefaultClose, innerClassName, ...props }: DrawerContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
Title: import("react").FunctionComponent<import("@base-ui/react/drawer").DrawerTitleProps>;
|
|
18
|
+
Description: import("react").FunctionComponent<import("@base-ui/react/drawer").DrawerDescriptionProps>;
|
|
19
|
+
Close: typeof DrawerClose;
|
|
20
|
+
Actions: import("react").FunctionComponent<import("../box/Box.js").BoxProps>;
|
|
21
|
+
Unstyled: DrawerParts;
|
|
22
|
+
createHandle: typeof BaseDrawer.createHandle;
|
|
23
|
+
};
|
|
24
|
+
export type DrawerParts = typeof BaseDrawer;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
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 { ScrollArea } from '../scrollArea/ScrollArea.js';
|
|
23
|
+
import cls from './Drawer.module.css';
|
|
24
|
+
const DrawerOverlay = withClassName(BaseDrawer.Backdrop, cls.overlay);
|
|
25
|
+
const StyledPopup = withClassName(BaseDrawer.Popup, cls.popup);
|
|
26
|
+
const DrawerContent = function DrawerContent(_a) {
|
|
27
|
+
var { ref, children, className, disableDefaultClose, innerClassName } = _a, props = __rest(_a, ["ref", "children", "className", "disableDefaultClose", "innerClassName"]);
|
|
28
|
+
const particles = useParticles();
|
|
29
|
+
const wasOpenRef = useRef(false);
|
|
30
|
+
const openRef = useCallback((element) => {
|
|
31
|
+
if (!wasOpenRef.current && (element === null || element === void 0 ? void 0 : element.hasAttribute('data-open'))) {
|
|
32
|
+
wasOpenRef.current = true;
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
particles === null || particles === void 0 ? void 0 : particles.addParticles(particles.elementExplosion({
|
|
35
|
+
count: 20,
|
|
36
|
+
margin: 40,
|
|
37
|
+
borders: ['top'],
|
|
38
|
+
color: [
|
|
39
|
+
{
|
|
40
|
+
space: 'rgb',
|
|
41
|
+
values: [0, 0, 0],
|
|
42
|
+
opacity: 0.02,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
space: 'rgb',
|
|
46
|
+
values: [0, 0, 0],
|
|
47
|
+
opacity: 0,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
element,
|
|
51
|
+
startRadius: 15,
|
|
52
|
+
endRadius: 0,
|
|
53
|
+
lifespan: 1000,
|
|
54
|
+
force: 0.5,
|
|
55
|
+
drag: 0.01,
|
|
56
|
+
forceFuzz: 0.5,
|
|
57
|
+
angleFuzz: 0.1,
|
|
58
|
+
}));
|
|
59
|
+
}, 180);
|
|
60
|
+
}
|
|
61
|
+
else if (!(element === null || element === void 0 ? void 0 : element.hasAttribute('data-open'))) {
|
|
62
|
+
wasOpenRef.current = false;
|
|
63
|
+
}
|
|
64
|
+
}, [particles]);
|
|
65
|
+
const finalRef = useMergedRef(ref, openRef);
|
|
66
|
+
return (_jsxs(BaseDrawer.Portal, { children: [_jsx(DrawerOverlay, {}), _jsx(BaseDrawer.Viewport, { className: cls.viewport, children: _jsxs(StyledPopup, Object.assign({ ref: finalRef }, props, { className: className, children: [!disableDefaultClose && _jsx(DrawerDefaultClose, {}), _jsx(DrawerSwipeHandle, {}), _jsx(ScrollArea, { direction: "vertical", className: cls.contentScrollArea, children: _jsx(ScrollArea.Content, { className: clsx(cls.contentScrollAreaContent, innerClassName), style: { minWidth: undefined }, children: children }) })] })) })] }));
|
|
67
|
+
};
|
|
68
|
+
function DrawerSwipeHandle(_a) {
|
|
69
|
+
var { ref, className } = _a, props = __rest(_a, ["ref", "className"]);
|
|
70
|
+
return (_jsx("div", Object.assign({ ref: ref }, props, { className: clsx(cls.swipeHandle, className), children: _jsx("div", { className: cls.swipeHandleBar }) })));
|
|
71
|
+
}
|
|
72
|
+
function DrawerDefaultClose(_a) {
|
|
73
|
+
var { ref, className } = _a, props = __rest(_a, ["ref", "className"]);
|
|
74
|
+
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" }) })));
|
|
75
|
+
}
|
|
76
|
+
const DrawerTitle = withClassName(BaseDrawer.Title, cls.title);
|
|
77
|
+
const DrawerDescription = withClassName(BaseDrawer.Description, cls.description);
|
|
78
|
+
const defaultSnapPoints = [0.75, 1];
|
|
79
|
+
const DrawerRoot = (_a) => {
|
|
80
|
+
var { children, defaultSnapPoint = 0.5, snapPoints = defaultSnapPoints } = _a, props = __rest(_a, ["children", "defaultSnapPoint", "snapPoints"]);
|
|
81
|
+
return (_jsx(BaseDrawer.Root, Object.assign({ swipeDirection: "down", defaultSnapPoint: defaultSnapPoint, snapPoints: snapPoints }, props, { children: _jsx(BaseDrawer.VirtualKeyboardProvider, { children: children }) })));
|
|
82
|
+
};
|
|
83
|
+
const DrawerTrigger = (_a) => {
|
|
84
|
+
var { render } = _a, props = __rest(_a, ["render"]);
|
|
85
|
+
return (_jsx(BaseDrawer.Trigger, Object.assign({ render: render || _jsx(Button, {}) }, props)));
|
|
86
|
+
};
|
|
87
|
+
function DrawerClose(_a) {
|
|
88
|
+
var { children, render } = _a, props = __rest(_a, ["children", "render"]);
|
|
89
|
+
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' })));
|
|
90
|
+
}
|
|
91
|
+
const DrawerActions = withClassName(Box, cls.actions);
|
|
92
|
+
export const Drawer = Object.assign(DrawerRoot, {
|
|
93
|
+
Trigger: DrawerTrigger,
|
|
94
|
+
Content: DrawerContent,
|
|
95
|
+
Title: DrawerTitle,
|
|
96
|
+
Description: DrawerDescription,
|
|
97
|
+
Close: DrawerClose,
|
|
98
|
+
Actions: DrawerActions,
|
|
99
|
+
Unstyled: BaseDrawer,
|
|
100
|
+
createHandle: BaseDrawer.createHandle,
|
|
101
|
+
});
|
|
102
|
+
//# sourceMappingURL=Drawer.js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M,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE;IAC/C,OAAO,EAAE,aAAa;IACtB,OAAO,EAAE,aAAa;IACtB,KAAK,EAAE,WAAW;IAClB,WAAW,EAAE,iBAAiB;IAC9B,KAAK,EAAE,WAAW;IAClB,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE,UAAyB;IACnC,YAAY,EAAE,UAAU,CAAC,YAAY;CACrC,CAAC,CAAC"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
@layer components {.overlay {
|
|
2
|
+
position: fixed;
|
|
3
|
+
inset: 0;
|
|
4
|
+
@apply --mx-shadow;
|
|
5
|
+
@apply --mx-bg(var(--m-gray-ink));
|
|
6
|
+
@apply --mx-bg-faded(5%);
|
|
7
|
+
border-top: var(--m-lw) solid var(--m-gray);
|
|
8
|
+
transition: all var(--m-dur) var(--m-ease);
|
|
9
|
+
backdrop-filter: blur(2px);
|
|
10
|
+
|
|
11
|
+
&[data-starting-style],
|
|
12
|
+
&[data-ending-style] {
|
|
13
|
+
opacity: 0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.viewport {
|
|
18
|
+
--bleed: 100px;
|
|
19
|
+
|
|
20
|
+
position: fixed;
|
|
21
|
+
inset: 0;
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: flex-end;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
touch-action: none;
|
|
26
|
+
|
|
27
|
+
&::after {
|
|
28
|
+
content: '';
|
|
29
|
+
position: fixed;
|
|
30
|
+
inset-inline: 0;
|
|
31
|
+
bottom: 0;
|
|
32
|
+
height: var(--bleed);
|
|
33
|
+
@apply --mx-bg(var(--m-surface-ambient-bg));
|
|
34
|
+
pointer-events: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&[data-closed]::after {
|
|
38
|
+
opacity: 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.popup {
|
|
43
|
+
box-sizing: border-box;
|
|
44
|
+
position: relative;
|
|
45
|
+
z-index: 1;
|
|
46
|
+
max-width: unset;
|
|
47
|
+
width: 100%;
|
|
48
|
+
max-height: 85svh;
|
|
49
|
+
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
align-items: stretch;
|
|
53
|
+
|
|
54
|
+
touch-action: none;
|
|
55
|
+
|
|
56
|
+
overflow: visible;
|
|
57
|
+
|
|
58
|
+
transition:
|
|
59
|
+
transform var(--m-dur) var(--m-ease),
|
|
60
|
+
opacity var(--m-dur) var(--m-ease);
|
|
61
|
+
|
|
62
|
+
--shadow-dir: -1;
|
|
63
|
+
@apply --mx-shadow;
|
|
64
|
+
--mx-shadow-value: 0 calc(var(--shadow-dir, 1) * var(--m-shadow-lg-y))
|
|
65
|
+
var(--m-shadow-lg-blur) var(--m-shadow-lg-spread) var(--m-shadow-lg-color);
|
|
66
|
+
|
|
67
|
+
@apply --mx-bg(var(--m-surface-ambient-bg));
|
|
68
|
+
@apply --mx-borderColor(var(--m-gray-heavy));
|
|
69
|
+
|
|
70
|
+
border-radius: var(--m-surface-rd) var(--m-surface-rd) 0 0;
|
|
71
|
+
border-bottom-width: 0;
|
|
72
|
+
padding-bottom: max(
|
|
73
|
+
0px,
|
|
74
|
+
calc(var(--drawer-snap-point-offset) + var(--drawer-swipe-movement-y))
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
/* Use drawer's built-in swipe movement for animation */
|
|
78
|
+
transform: translateY(
|
|
79
|
+
calc(
|
|
80
|
+
var(--drawer-swipe-movement-y, 0px) + var(--drawer-snap-point-offset, 0px)
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
will-change: transform;
|
|
84
|
+
|
|
85
|
+
/* Disable transitions while swiping so movement is immediate */
|
|
86
|
+
&[data-swiping] {
|
|
87
|
+
transition: none;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&[data-starting-style],
|
|
91
|
+
&[data-ending-style] {
|
|
92
|
+
transform: translateY(100%);
|
|
93
|
+
padding-bottom: 0;
|
|
94
|
+
}
|
|
95
|
+
&[data-ending-style] {
|
|
96
|
+
transition-duration: calc(var(--drawer-swipe-strength) * 400ms);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.contentScrollArea {
|
|
101
|
+
width: 100%;
|
|
102
|
+
height: 100%;
|
|
103
|
+
flex: 1 1 auto;
|
|
104
|
+
min-height: 0;
|
|
105
|
+
overscroll-behavior: contain;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.contentScrollAreaContent {
|
|
109
|
+
display: flex;
|
|
110
|
+
flex-direction: column;
|
|
111
|
+
gap: var(--m-sp-md);
|
|
112
|
+
padding: var(--m-surface-p);
|
|
113
|
+
overscroll-behavior: contain;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.swipeHandle {
|
|
117
|
+
position: relative;
|
|
118
|
+
display: flex;
|
|
119
|
+
align-items: center;
|
|
120
|
+
justify-content: center;
|
|
121
|
+
width: 100%;
|
|
122
|
+
cursor: grab;
|
|
123
|
+
touch-action: none;
|
|
124
|
+
padding-block: var(--m-sp-lg);
|
|
125
|
+
user-select: none;
|
|
126
|
+
flex-shrink: 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.swipeHandleBar {
|
|
130
|
+
height: --fn-literal(4px);
|
|
131
|
+
width: 20%;
|
|
132
|
+
@apply --mx-bg(var(--m-gray));
|
|
133
|
+
border-radius: var(--m-rd-lg);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.close {
|
|
137
|
+
position: absolute;
|
|
138
|
+
right: var(--m-sp-sm);
|
|
139
|
+
top: var(--m-sp-sm);
|
|
140
|
+
z-index: 101;
|
|
141
|
+
display: flex;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.title {
|
|
145
|
+
@apply --mx-fg(var(--m-gray-ink));
|
|
146
|
+
font-size: var(--m-prose-primary-size);
|
|
147
|
+
font-weight: var(--m-prose-primary-weight);
|
|
148
|
+
line-height: var(--m-prose-primary-lineHeight);
|
|
149
|
+
margin-block-end: var(--m-sp-xs);
|
|
150
|
+
margin-block-start: 0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.description {
|
|
154
|
+
@apply --mx-fg(var(--m-gray-heavy));
|
|
155
|
+
font-size: var(--m-prose-ambient-size);
|
|
156
|
+
line-height: var(--m-prose-ambient-lineHeight);
|
|
157
|
+
margin: 0;
|
|
158
|
+
margin-block-end: var(--m-sp-xs);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.actions {
|
|
162
|
+
position: sticky;
|
|
163
|
+
bottom: var(--m-sp-md);
|
|
164
|
+
z-index: 100;
|
|
165
|
+
display: flex;
|
|
166
|
+
flex-direction: row;
|
|
167
|
+
flex-wrap: wrap;
|
|
168
|
+
align-items: center;
|
|
169
|
+
justify-content: end;
|
|
170
|
+
align-self: end;
|
|
171
|
+
padding-bottom: --fn-literal(1px);
|
|
172
|
+
@apply --mx-shadow;
|
|
173
|
+
--mx-shadow-value: 0 calc(-1 * var(--m-shadow-md-y)) 16px
|
|
174
|
+
var(--m-shadow-md-spread) var(--m-gray-paper);
|
|
175
|
+
@apply --mx-bg(var(--m-surface-ambient-bg));
|
|
176
|
+
@apply --mx-bg-faded(50%);
|
|
177
|
+
margin-block-start: var(--m-sp-md);
|
|
178
|
+
gap: var(--m-sp-sm);
|
|
179
|
+
border-radius: var(--m-surface-rd);
|
|
180
|
+
transition: bottom var(--m-dur) var(--m-ease);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -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,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from '../button/index.js';
|
|
3
|
+
import { H1, P } from '../typography/index.js';
|
|
4
|
+
import { Drawer } from './Drawer.js';
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Components/Drawer',
|
|
7
|
+
component: Drawer,
|
|
8
|
+
argTypes: {},
|
|
9
|
+
parameters: {
|
|
10
|
+
controls: { expanded: true },
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
function DummyContent() {
|
|
15
|
+
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(Button, { disabled: true, color: "primary", children: "Click me" })] }));
|
|
16
|
+
}
|
|
17
|
+
export const Default = {
|
|
18
|
+
args: {
|
|
19
|
+
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" })] })] })] })),
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export const NoDefaultClose = {
|
|
23
|
+
args: {
|
|
24
|
+
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, {}) })] })] })),
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=Drawer.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.stories.js","sourceRoot":"","sources":["../../../src/components/drawer/Drawer.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,IAAI,GAAQ;IACjB,KAAK,EAAE,mBAAmB;IAC1B,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE;QACX,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC5B;CAC6B,CAAC;AAEhC,eAAe,IAAI,CAAC;AAIpB,SAAS,YAAY;IACpB,OAAO,CACN,eAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,aACvD,KAAC,EAAE,+BAAkB,EACrB,KAAC,CAAC,8NAIE,EACJ,KAAC,MAAM,IAAC,QAAQ,QAAC,KAAK,EAAC,SAAS,yBAEvB,IACJ,CACN,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAU;IAC7B,IAAI,EAAE;QACL,QAAQ,EAAE,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"}
|
|
@@ -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';
|
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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,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a-type/ui",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/a-type/ui"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@base-ui/react": "^1.6.0",
|
|
46
46
|
"@use-gesture/react": "^10.3.1",
|
|
47
47
|
"browser-image-resizer": "^2.4.1",
|
|
48
|
-
"calendar-blocks": "^0.
|
|
48
|
+
"calendar-blocks": "^0.5.3",
|
|
49
49
|
"clsx": "^2.1.1",
|
|
50
50
|
"date-fns": "^4.1.0",
|
|
51
51
|
"formik": "^2.4.6",
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { useCallback, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Dialog,
|
|
4
|
-
DialogActions,
|
|
5
|
-
DialogClose,
|
|
6
|
-
DialogContent,
|
|
7
|
-
DialogTitle,
|
|
8
|
-
DialogTrigger,
|
|
9
|
-
} from '../dialog/index.js';
|
|
2
|
+
import { Dialog } from '../dialog/index.js';
|
|
10
3
|
import { P } from '../typography/index.js';
|
|
11
4
|
import { Button, ButtonProps } from './Button.js';
|
|
12
5
|
|
|
@@ -55,14 +48,14 @@ export function ConfirmedButton({
|
|
|
55
48
|
|
|
56
49
|
return (
|
|
57
50
|
<Dialog open={open} onOpenChange={setOpen}>
|
|
58
|
-
<
|
|
59
|
-
<
|
|
60
|
-
<
|
|
51
|
+
<Dialog.Trigger render={<Button />} {...rest} />
|
|
52
|
+
<Dialog.Content>
|
|
53
|
+
<Dialog.Title>{confirmTitle}</Dialog.Title>
|
|
61
54
|
<P>{confirmText}</P>
|
|
62
|
-
<
|
|
63
|
-
<
|
|
55
|
+
<Dialog.Actions>
|
|
56
|
+
<Dialog.Close render={<Button emphasis="default" />}>
|
|
64
57
|
{cancelAction}
|
|
65
|
-
</
|
|
58
|
+
</Dialog.Close>
|
|
66
59
|
<Button
|
|
67
60
|
loading={loading}
|
|
68
61
|
onClick={confirm}
|
|
@@ -71,8 +64,8 @@ export function ConfirmedButton({
|
|
|
71
64
|
>
|
|
72
65
|
{confirmAction}
|
|
73
66
|
</Button>
|
|
74
|
-
</
|
|
75
|
-
</
|
|
67
|
+
</Dialog.Actions>
|
|
68
|
+
</Dialog.Content>
|
|
76
69
|
</Dialog>
|
|
77
70
|
);
|
|
78
71
|
}
|
|
@@ -71,7 +71,24 @@ function DateRangePickerRoot({
|
|
|
71
71
|
}));
|
|
72
72
|
|
|
73
73
|
const onDisplayChange = useCallback(
|
|
74
|
-
(
|
|
74
|
+
(
|
|
75
|
+
{ month: newMonth, year: newYear }: { month: number; year: number },
|
|
76
|
+
source: 'keyboard' | 'programmatic',
|
|
77
|
+
) => {
|
|
78
|
+
/**
|
|
79
|
+
* Important UX consideration:
|
|
80
|
+
*
|
|
81
|
+
* since we are displaying 2 months at once, we don't
|
|
82
|
+
* always want to change our view if the user's cursor
|
|
83
|
+
* date moves from one month to another. Specifically,
|
|
84
|
+
* if they move from the first visible month to the
|
|
85
|
+
* second visible month, we don't need to change the view,
|
|
86
|
+
* since they are still within the visible range.
|
|
87
|
+
* So, we write logic to ignore that case!
|
|
88
|
+
*/
|
|
89
|
+
if (source === 'keyboard' && newMonth === month + 1 && newYear === year) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
75
92
|
setDisplay({
|
|
76
93
|
month: newMonth,
|
|
77
94
|
year: newYear,
|