@a-type/ui 6.1.18 → 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/drawer/Drawer.d.ts +2 -3
- package/dist/components/drawer/Drawer.js +4 -5
- package/dist/components/drawer/Drawer.js.map +1 -1
- package/dist/components/drawer/Drawer.module.css +81 -27
- package/dist/components/drawer/Drawer.stories.js +2 -1
- package/dist/components/drawer/Drawer.stories.js.map +1 -1
- 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/scrollArea/ScrollArea.module.css +1 -0
- package/package.json +2 -1
- package/src/components/drawer/Drawer.module.css +81 -27
- package/src/components/drawer/Drawer.stories.tsx +44 -3
- package/src/components/drawer/Drawer.tsx +17 -32
- package/src/components/globalErrorFallback/GlobalErrorFallback.tsx +2 -1
- package/src/components/scrollArea/ScrollArea.module.css +1 -0
|
@@ -5,13 +5,12 @@ export interface DrawerContentProps extends DrawerPopupProps {
|
|
|
5
5
|
ref?: Ref<HTMLDivElement>;
|
|
6
6
|
innerClassName?: string;
|
|
7
7
|
}
|
|
8
|
-
export interface DrawerProps extends Omit<DrawerRootProps, '
|
|
9
|
-
children: React.ReactNode;
|
|
8
|
+
export interface DrawerProps extends Omit<DrawerRootProps, 'swipeDirection'> {
|
|
10
9
|
}
|
|
11
10
|
declare function DrawerClose({ children, render, ...props }: DrawerCloseProps & {
|
|
12
11
|
ref?: React.Ref<HTMLButtonElement>;
|
|
13
12
|
}): import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
export declare const Drawer: (({ children,
|
|
13
|
+
export declare const Drawer: (({ children, snapPoints, ...props }: DrawerProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
15
14
|
Trigger: ({ render, ...props }: DrawerTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
15
|
Content: ({ ref, children, className, disableDefaultClose, innerClassName, ...props }: DrawerContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
16
|
Title: import("react").FunctionComponent<import("@base-ui/react/drawer").DrawerTitleProps>;
|
|
@@ -19,9 +19,8 @@ import { Box } from '../box/Box.js';
|
|
|
19
19
|
import { Button } from '../button/index.js';
|
|
20
20
|
import { Icon } from '../icon/Icon.js';
|
|
21
21
|
import { useParticles } from '../particles/ParticleContext.js';
|
|
22
|
-
import { ScrollArea } from '../scrollArea/ScrollArea.js';
|
|
23
22
|
import cls from './Drawer.module.css';
|
|
24
|
-
const
|
|
23
|
+
const DrawerBackdrop = withClassName(BaseDrawer.Backdrop, cls.overlay);
|
|
25
24
|
const StyledPopup = withClassName(BaseDrawer.Popup, cls.popup);
|
|
26
25
|
const DrawerContent = function DrawerContent(_a) {
|
|
27
26
|
var { ref, children, className, disableDefaultClose, innerClassName } = _a, props = __rest(_a, ["ref", "children", "className", "disableDefaultClose", "innerClassName"]);
|
|
@@ -63,7 +62,7 @@ const DrawerContent = function DrawerContent(_a) {
|
|
|
63
62
|
}
|
|
64
63
|
}, [particles]);
|
|
65
64
|
const finalRef = useMergedRef(ref, openRef);
|
|
66
|
-
return (_jsxs(BaseDrawer.Portal, { children: [_jsx(
|
|
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 })] })) })] }) }));
|
|
67
66
|
};
|
|
68
67
|
function DrawerSwipeHandle(_a) {
|
|
69
68
|
var { ref, className } = _a, props = __rest(_a, ["ref", "className"]);
|
|
@@ -77,8 +76,8 @@ const DrawerTitle = withClassName(BaseDrawer.Title, cls.title);
|
|
|
77
76
|
const DrawerDescription = withClassName(BaseDrawer.Description, cls.description);
|
|
78
77
|
const defaultSnapPoints = [0.75, 1];
|
|
79
78
|
const DrawerRoot = (_a) => {
|
|
80
|
-
var { children,
|
|
81
|
-
return (_jsx(BaseDrawer.Root, Object.assign({ swipeDirection: "down",
|
|
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 })));
|
|
82
81
|
};
|
|
83
82
|
const DrawerTrigger = (_a) => {
|
|
84
83
|
var { render } = _a, props = __rest(_a, ["render"]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../../../src/components/drawer/Drawer.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EACN,MAAM,IAAI,UAAU,GAKpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAiC,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,YAAY,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,
|
|
1
|
+
{"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../../../src/components/drawer/Drawer.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EACN,MAAM,IAAI,UAAU,GAKpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,IAAI,MA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
|
4
|
-
|
|
8
|
+
|
|
5
9
|
@apply --mx-bg(var(--m-gray-ink));
|
|
6
|
-
|
|
10
|
+
opacity: calc(
|
|
11
|
+
0.2 + var(--swipe-opacity) * (1 - var(--drawer-swipe-progress, 0))
|
|
12
|
+
);
|
|
13
|
+
|
|
7
14
|
border-top: var(--m-lw) solid var(--m-gray);
|
|
8
|
-
|
|
15
|
+
|
|
16
|
+
transition: all var(--m-dur-long) var(--m-ease);
|
|
17
|
+
|
|
9
18
|
backdrop-filter: blur(2px);
|
|
10
19
|
|
|
11
20
|
&[data-starting-style],
|
|
12
21
|
&[data-ending-style] {
|
|
13
22
|
opacity: 0;
|
|
14
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
|
+
}
|
|
15
32
|
}
|
|
16
33
|
|
|
17
34
|
.viewport {
|
|
18
|
-
--bleed:
|
|
35
|
+
--bleed: 3rem;
|
|
19
36
|
|
|
20
37
|
position: fixed;
|
|
21
38
|
inset: 0;
|
|
@@ -37,47 +54,60 @@
|
|
|
37
54
|
&[data-closed]::after {
|
|
38
55
|
opacity: 0;
|
|
39
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
|
+
}
|
|
40
64
|
}
|
|
41
65
|
|
|
42
66
|
.popup {
|
|
67
|
+
--bleed: 3rem;
|
|
68
|
+
--top-gap: 1rem;
|
|
69
|
+
|
|
43
70
|
box-sizing: border-box;
|
|
44
71
|
position: relative;
|
|
45
72
|
z-index: 1;
|
|
46
73
|
max-width: unset;
|
|
47
74
|
width: 100%;
|
|
48
|
-
max-height:
|
|
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
|
+
);
|
|
49
82
|
|
|
50
83
|
display: flex;
|
|
51
84
|
flex-direction: column;
|
|
52
85
|
align-items: stretch;
|
|
53
86
|
|
|
87
|
+
@apply --mx-bg(var(--m-surface-ambient-bg));
|
|
88
|
+
@apply --mx-borderColor(var(--m-gray-heavy));
|
|
89
|
+
|
|
54
90
|
touch-action: none;
|
|
55
91
|
|
|
56
92
|
overflow: visible;
|
|
57
93
|
|
|
58
94
|
transition:
|
|
59
|
-
transform var(--m-dur) var(--m-ease),
|
|
60
|
-
|
|
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);
|
|
61
98
|
|
|
62
99
|
--shadow-dir: -1;
|
|
63
100
|
@apply --mx-shadow;
|
|
64
101
|
--mx-shadow-value: 0 calc(var(--shadow-dir, 1) * var(--m-shadow-lg-y))
|
|
65
102
|
var(--m-shadow-lg-blur) var(--m-shadow-lg-spread) var(--m-shadow-lg-color);
|
|
66
103
|
|
|
67
|
-
@apply --mx-bg(var(--m-surface-ambient-bg));
|
|
68
|
-
@apply --mx-borderColor(var(--m-gray-heavy));
|
|
69
|
-
|
|
70
104
|
border-radius: var(--m-surface-rd) var(--m-surface-rd) 0 0;
|
|
71
105
|
border-bottom-width: 0;
|
|
72
|
-
padding-bottom: max(
|
|
73
|
-
0px,
|
|
74
|
-
calc(var(--drawer-snap-point-offset) + var(--drawer-swipe-movement-y))
|
|
75
|
-
);
|
|
76
106
|
|
|
77
|
-
/* Use drawer's built-in swipe movement for animation */
|
|
78
107
|
transform: translateY(
|
|
79
108
|
calc(
|
|
80
|
-
var(--drawer-swipe-movement-y
|
|
109
|
+
var(--drawer-swipe-movement-y) + var(--drawer-snap-point-offset) -
|
|
110
|
+
var(--bleed)
|
|
81
111
|
)
|
|
82
112
|
);
|
|
83
113
|
will-change: transform;
|
|
@@ -85,32 +115,41 @@
|
|
|
85
115
|
/* Disable transitions while swiping so movement is immediate */
|
|
86
116
|
&[data-swiping] {
|
|
87
117
|
transition: none;
|
|
118
|
+
user-select: none;
|
|
88
119
|
}
|
|
89
120
|
|
|
90
121
|
&[data-starting-style],
|
|
91
122
|
&[data-ending-style] {
|
|
92
|
-
transform: translateY(100%);
|
|
123
|
+
transform: translateY(calc(100% - var(--bleed)));
|
|
93
124
|
padding-bottom: 0;
|
|
125
|
+
box-shadow: 0 0 0 transparent;
|
|
94
126
|
}
|
|
127
|
+
|
|
95
128
|
&[data-ending-style] {
|
|
96
|
-
transition-duration: calc(var(--drawer-swipe-strength) *
|
|
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;
|
|
97
140
|
}
|
|
98
141
|
}
|
|
99
142
|
|
|
100
143
|
.contentScrollArea {
|
|
101
|
-
width: 100%;
|
|
102
|
-
height: 100%;
|
|
103
144
|
flex: 1 1 auto;
|
|
104
145
|
min-height: 0;
|
|
105
146
|
overscroll-behavior: contain;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
147
|
+
touch-action: auto;
|
|
148
|
+
overflow-y: auto;
|
|
149
|
+
padding: var(--m-surface-p);
|
|
109
150
|
display: flex;
|
|
110
151
|
flex-direction: column;
|
|
111
152
|
gap: var(--m-sp-md);
|
|
112
|
-
padding: var(--m-surface-p);
|
|
113
|
-
overscroll-behavior: contain;
|
|
114
153
|
}
|
|
115
154
|
|
|
116
155
|
.swipeHandle {
|
|
@@ -160,7 +199,7 @@
|
|
|
160
199
|
|
|
161
200
|
.actions {
|
|
162
201
|
position: sticky;
|
|
163
|
-
bottom:
|
|
202
|
+
bottom: 0;
|
|
164
203
|
z-index: 100;
|
|
165
204
|
display: flex;
|
|
166
205
|
flex-direction: row;
|
|
@@ -168,7 +207,6 @@
|
|
|
168
207
|
align-items: center;
|
|
169
208
|
justify-content: end;
|
|
170
209
|
align-self: end;
|
|
171
|
-
padding-bottom: --fn-literal(1px);
|
|
172
210
|
@apply --mx-shadow;
|
|
173
211
|
--mx-shadow-value: 0 calc(-1 * var(--m-shadow-md-y)) 16px
|
|
174
212
|
var(--m-shadow-md-spread) var(--m-gray-paper);
|
|
@@ -178,5 +216,21 @@
|
|
|
178
216
|
gap: var(--m-sp-sm);
|
|
179
217
|
border-radius: var(--m-surface-rd);
|
|
180
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
|
+
}
|
|
181
235
|
}
|
|
182
236
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Button } from '../button/index.js';
|
|
3
|
+
import { Input } from '../input/Input.js';
|
|
3
4
|
import { H1, P } from '../typography/index.js';
|
|
4
5
|
import { Drawer } from './Drawer.js';
|
|
5
6
|
const meta = {
|
|
@@ -12,7 +13,7 @@ const meta = {
|
|
|
12
13
|
};
|
|
13
14
|
export default meta;
|
|
14
15
|
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(
|
|
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..." })] }));
|
|
16
17
|
}
|
|
17
18
|
export const Default = {
|
|
18
19
|
args: {
|
|
@@ -1 +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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,KAAC,KAAK,IAAC,WAAW,EAAC,mBAAmB,GAAG,EACzC,KAAC,CAAC,0aAOE,EACJ,KAAC,KAAK,IAAC,WAAW,EAAC,mBAAmB,GAAG,IACpC,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"}
|
|
@@ -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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,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a-type/ui",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/a-type/ui"
|
|
@@ -94,6 +94,7 @@
|
|
|
94
94
|
"typescript": "^5.9.3",
|
|
95
95
|
"typescript-eslint": "^8.53.0",
|
|
96
96
|
"typescript-plugin-css-modules": "^5.2.0",
|
|
97
|
+
"vite": "^8.2.0",
|
|
97
98
|
"vitest": "^4.0.18",
|
|
98
99
|
"vitest-browser-react": "^2.0.4"
|
|
99
100
|
},
|
|
@@ -1,21 +1,38 @@
|
|
|
1
1
|
.overlay {
|
|
2
|
+
--bleed: 3rem;
|
|
3
|
+
--swipe-opacity: 0.2;
|
|
4
|
+
|
|
2
5
|
position: fixed;
|
|
6
|
+
min-height: 100dvh;
|
|
3
7
|
inset: 0;
|
|
4
|
-
|
|
8
|
+
|
|
5
9
|
@apply --mx-bg(var(--m-gray-ink));
|
|
6
|
-
|
|
10
|
+
opacity: calc(
|
|
11
|
+
0.2 + var(--swipe-opacity) * (1 - var(--drawer-swipe-progress, 0))
|
|
12
|
+
);
|
|
13
|
+
|
|
7
14
|
border-top: var(--m-lw) solid var(--m-gray);
|
|
8
|
-
|
|
15
|
+
|
|
16
|
+
transition: all var(--m-dur-long) var(--m-ease);
|
|
17
|
+
|
|
9
18
|
backdrop-filter: blur(2px);
|
|
10
19
|
|
|
11
20
|
&[data-starting-style],
|
|
12
21
|
&[data-ending-style] {
|
|
13
22
|
opacity: 0;
|
|
14
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
|
+
}
|
|
15
32
|
}
|
|
16
33
|
|
|
17
34
|
.viewport {
|
|
18
|
-
--bleed:
|
|
35
|
+
--bleed: 3rem;
|
|
19
36
|
|
|
20
37
|
position: fixed;
|
|
21
38
|
inset: 0;
|
|
@@ -37,47 +54,60 @@
|
|
|
37
54
|
&[data-closed]::after {
|
|
38
55
|
opacity: 0;
|
|
39
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
|
+
}
|
|
40
64
|
}
|
|
41
65
|
|
|
42
66
|
.popup {
|
|
67
|
+
--bleed: 3rem;
|
|
68
|
+
--top-gap: 1rem;
|
|
69
|
+
|
|
43
70
|
box-sizing: border-box;
|
|
44
71
|
position: relative;
|
|
45
72
|
z-index: 1;
|
|
46
73
|
max-width: unset;
|
|
47
74
|
width: 100%;
|
|
48
|
-
max-height:
|
|
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
|
+
);
|
|
49
82
|
|
|
50
83
|
display: flex;
|
|
51
84
|
flex-direction: column;
|
|
52
85
|
align-items: stretch;
|
|
53
86
|
|
|
87
|
+
@apply --mx-bg(var(--m-surface-ambient-bg));
|
|
88
|
+
@apply --mx-borderColor(var(--m-gray-heavy));
|
|
89
|
+
|
|
54
90
|
touch-action: none;
|
|
55
91
|
|
|
56
92
|
overflow: visible;
|
|
57
93
|
|
|
58
94
|
transition:
|
|
59
|
-
transform var(--m-dur) var(--m-ease),
|
|
60
|
-
|
|
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);
|
|
61
98
|
|
|
62
99
|
--shadow-dir: -1;
|
|
63
100
|
@apply --mx-shadow;
|
|
64
101
|
--mx-shadow-value: 0 calc(var(--shadow-dir, 1) * var(--m-shadow-lg-y))
|
|
65
102
|
var(--m-shadow-lg-blur) var(--m-shadow-lg-spread) var(--m-shadow-lg-color);
|
|
66
103
|
|
|
67
|
-
@apply --mx-bg(var(--m-surface-ambient-bg));
|
|
68
|
-
@apply --mx-borderColor(var(--m-gray-heavy));
|
|
69
|
-
|
|
70
104
|
border-radius: var(--m-surface-rd) var(--m-surface-rd) 0 0;
|
|
71
105
|
border-bottom-width: 0;
|
|
72
|
-
padding-bottom: max(
|
|
73
|
-
0px,
|
|
74
|
-
calc(var(--drawer-snap-point-offset) + var(--drawer-swipe-movement-y))
|
|
75
|
-
);
|
|
76
106
|
|
|
77
|
-
/* Use drawer's built-in swipe movement for animation */
|
|
78
107
|
transform: translateY(
|
|
79
108
|
calc(
|
|
80
|
-
var(--drawer-swipe-movement-y
|
|
109
|
+
var(--drawer-swipe-movement-y) + var(--drawer-snap-point-offset) -
|
|
110
|
+
var(--bleed)
|
|
81
111
|
)
|
|
82
112
|
);
|
|
83
113
|
will-change: transform;
|
|
@@ -85,32 +115,41 @@
|
|
|
85
115
|
/* Disable transitions while swiping so movement is immediate */
|
|
86
116
|
&[data-swiping] {
|
|
87
117
|
transition: none;
|
|
118
|
+
user-select: none;
|
|
88
119
|
}
|
|
89
120
|
|
|
90
121
|
&[data-starting-style],
|
|
91
122
|
&[data-ending-style] {
|
|
92
|
-
transform: translateY(100%);
|
|
123
|
+
transform: translateY(calc(100% - var(--bleed)));
|
|
93
124
|
padding-bottom: 0;
|
|
125
|
+
box-shadow: 0 0 0 transparent;
|
|
94
126
|
}
|
|
127
|
+
|
|
95
128
|
&[data-ending-style] {
|
|
96
|
-
transition-duration: calc(var(--drawer-swipe-strength) *
|
|
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;
|
|
97
140
|
}
|
|
98
141
|
}
|
|
99
142
|
|
|
100
143
|
.contentScrollArea {
|
|
101
|
-
width: 100%;
|
|
102
|
-
height: 100%;
|
|
103
144
|
flex: 1 1 auto;
|
|
104
145
|
min-height: 0;
|
|
105
146
|
overscroll-behavior: contain;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
147
|
+
touch-action: auto;
|
|
148
|
+
overflow-y: auto;
|
|
149
|
+
padding: var(--m-surface-p);
|
|
109
150
|
display: flex;
|
|
110
151
|
flex-direction: column;
|
|
111
152
|
gap: var(--m-sp-md);
|
|
112
|
-
padding: var(--m-surface-p);
|
|
113
|
-
overscroll-behavior: contain;
|
|
114
153
|
}
|
|
115
154
|
|
|
116
155
|
.swipeHandle {
|
|
@@ -160,7 +199,7 @@
|
|
|
160
199
|
|
|
161
200
|
.actions {
|
|
162
201
|
position: sticky;
|
|
163
|
-
bottom:
|
|
202
|
+
bottom: 0;
|
|
164
203
|
z-index: 100;
|
|
165
204
|
display: flex;
|
|
166
205
|
flex-direction: row;
|
|
@@ -168,7 +207,6 @@
|
|
|
168
207
|
align-items: center;
|
|
169
208
|
justify-content: end;
|
|
170
209
|
align-self: end;
|
|
171
|
-
padding-bottom: --fn-literal(1px);
|
|
172
210
|
@apply --mx-shadow;
|
|
173
211
|
--mx-shadow-value: 0 calc(-1 * var(--m-shadow-md-y)) 16px
|
|
174
212
|
var(--m-shadow-md-spread) var(--m-gray-paper);
|
|
@@ -178,4 +216,20 @@
|
|
|
178
216
|
gap: var(--m-sp-sm);
|
|
179
217
|
border-radius: var(--m-surface-rd);
|
|
180
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
|
+
}
|
|
181
235
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { Button } from '../button/index.js';
|
|
3
|
+
import { Input } from '../input/Input.js';
|
|
3
4
|
import { H1, P } from '../typography/index.js';
|
|
4
5
|
import { Drawer } from './Drawer.js';
|
|
5
6
|
|
|
@@ -25,9 +26,49 @@ function DummyContent() {
|
|
|
25
26
|
porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula
|
|
26
27
|
accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi.
|
|
27
28
|
</P>
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
<Input placeholder="Type something..." />
|
|
30
|
+
<P>
|
|
31
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at
|
|
32
|
+
porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula
|
|
33
|
+
accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi.
|
|
34
|
+
</P>
|
|
35
|
+
<Input placeholder="Type something..." />
|
|
36
|
+
<P>
|
|
37
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at
|
|
38
|
+
porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula
|
|
39
|
+
accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi. Lorem
|
|
40
|
+
ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at porttitor
|
|
41
|
+
sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula accumsan,
|
|
42
|
+
sit amet ullamcorper nunc ultricies. Nulla facilisi.
|
|
43
|
+
</P>
|
|
44
|
+
<Input placeholder="Type something..." />
|
|
45
|
+
<P>
|
|
46
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at
|
|
47
|
+
porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula
|
|
48
|
+
accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi. Lorem
|
|
49
|
+
ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at porttitor
|
|
50
|
+
sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula accumsan,
|
|
51
|
+
sit amet ullamcorper nunc ultricies. Nulla facilisi.
|
|
52
|
+
</P>
|
|
53
|
+
<Input placeholder="Type something..." />
|
|
54
|
+
<P>
|
|
55
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at
|
|
56
|
+
porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula
|
|
57
|
+
accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi. Lorem
|
|
58
|
+
ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at porttitor
|
|
59
|
+
sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula accumsan,
|
|
60
|
+
sit amet ullamcorper nunc ultricies. Nulla facilisi.
|
|
61
|
+
</P>
|
|
62
|
+
<Input placeholder="Type something..." />
|
|
63
|
+
<P>
|
|
64
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at
|
|
65
|
+
porttitor sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula
|
|
66
|
+
accumsan, sit amet ullamcorper nunc ultricies. Nulla facilisi. Lorem
|
|
67
|
+
ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at porttitor
|
|
68
|
+
sem. Aliquam erat volutpat. Donec fermentum tortor eget ligula accumsan,
|
|
69
|
+
sit amet ullamcorper nunc ultricies. Nulla facilisi.
|
|
70
|
+
</P>
|
|
71
|
+
<Input placeholder="Type something..." />
|
|
31
72
|
</div>
|
|
32
73
|
);
|
|
33
74
|
}
|
|
@@ -13,10 +13,9 @@ import { Box } from '../box/Box.js';
|
|
|
13
13
|
import { Button } from '../button/index.js';
|
|
14
14
|
import { Icon } from '../icon/Icon.js';
|
|
15
15
|
import { useParticles } from '../particles/ParticleContext.js';
|
|
16
|
-
import { ScrollArea } from '../scrollArea/ScrollArea.js';
|
|
17
16
|
import cls from './Drawer.module.css';
|
|
18
17
|
|
|
19
|
-
const
|
|
18
|
+
const DrawerBackdrop = withClassName(BaseDrawer.Backdrop, cls.overlay);
|
|
20
19
|
|
|
21
20
|
const StyledPopup = withClassName(BaseDrawer.Popup, cls.popup);
|
|
22
21
|
|
|
@@ -81,23 +80,20 @@ const DrawerContent = function DrawerContent({
|
|
|
81
80
|
const finalRef = useMergedRef(ref, openRef);
|
|
82
81
|
|
|
83
82
|
return (
|
|
84
|
-
<BaseDrawer.
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
<
|
|
88
|
-
{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
<
|
|
92
|
-
className={clsx(cls.contentScrollAreaContent, innerClassName)}
|
|
93
|
-
style={{ minWidth: undefined }}
|
|
94
|
-
>
|
|
83
|
+
<BaseDrawer.VirtualKeyboardProvider>
|
|
84
|
+
<BaseDrawer.Portal>
|
|
85
|
+
<DrawerBackdrop data-role="backdrop" />
|
|
86
|
+
<BaseDrawer.Viewport className={cls.viewport}>
|
|
87
|
+
<StyledPopup ref={finalRef} {...props} className={className}>
|
|
88
|
+
{!disableDefaultClose && <DrawerDefaultClose />}
|
|
89
|
+
<DrawerSwipeHandle />
|
|
90
|
+
<div className={clsx(cls.contentScrollArea, innerClassName)}>
|
|
95
91
|
{children}
|
|
96
|
-
</
|
|
97
|
-
</
|
|
98
|
-
</
|
|
99
|
-
</BaseDrawer.
|
|
100
|
-
</BaseDrawer.
|
|
92
|
+
</div>
|
|
93
|
+
</StyledPopup>
|
|
94
|
+
</BaseDrawer.Viewport>
|
|
95
|
+
</BaseDrawer.Portal>
|
|
96
|
+
</BaseDrawer.VirtualKeyboardProvider>
|
|
101
97
|
);
|
|
102
98
|
};
|
|
103
99
|
|
|
@@ -142,27 +138,16 @@ const DrawerDescription = withClassName(
|
|
|
142
138
|
);
|
|
143
139
|
|
|
144
140
|
// TODO: support swipeDirection
|
|
145
|
-
export interface DrawerProps
|
|
146
|
-
extends Omit<DrawerRootProps, 'children' | 'swipeDirection'> {
|
|
147
|
-
children: React.ReactNode;
|
|
148
|
-
}
|
|
141
|
+
export interface DrawerProps extends Omit<DrawerRootProps, 'swipeDirection'> {}
|
|
149
142
|
const defaultSnapPoints = [0.75, 1];
|
|
150
143
|
const DrawerRoot = ({
|
|
151
144
|
children,
|
|
152
|
-
defaultSnapPoint = 0.5,
|
|
153
145
|
snapPoints = defaultSnapPoints,
|
|
154
146
|
...props
|
|
155
147
|
}: DrawerProps) => {
|
|
156
148
|
return (
|
|
157
|
-
<BaseDrawer.Root
|
|
158
|
-
|
|
159
|
-
defaultSnapPoint={defaultSnapPoint}
|
|
160
|
-
snapPoints={snapPoints}
|
|
161
|
-
{...props}
|
|
162
|
-
>
|
|
163
|
-
<BaseDrawer.VirtualKeyboardProvider>
|
|
164
|
-
{children}
|
|
165
|
-
</BaseDrawer.VirtualKeyboardProvider>
|
|
149
|
+
<BaseDrawer.Root swipeDirection="down" snapPoints={snapPoints} {...props}>
|
|
150
|
+
{children}
|
|
166
151
|
</BaseDrawer.Root>
|
|
167
152
|
);
|
|
168
153
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Box, BoxProps, Heading, P } from '@a-type/ui';
|
|
2
1
|
import { useLocalStorage } from '../../hooks.js';
|
|
2
|
+
import { Box, type BoxProps } from '../box/Box.js';
|
|
3
|
+
import { Heading, P } from '../typography/typography.js';
|
|
3
4
|
|
|
4
5
|
export function GlobalErrorFallback({ children, ...rest }: BoxProps) {
|
|
5
6
|
const hadRecentError = useHadRecentError();
|