@zazz-ui/core 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -0
- package/README.md +5 -9
- package/dist/sri.json +34 -30
- package/dist/zazz.css +1 -1
- package/dist/zazz.js +1 -1
- package/editor/zazz.css-data.json +173 -3
- package/editor/zazz.html-data.json +138 -0
- package/editor/zazz.language-data.json +313 -125
- package/editor/zazz.lint-data.json +1501 -1383
- package/package.json +1 -5
- package/src/base/_defaults.css +1 -1
- package/src/base/_reset.css +16 -2
- package/src/base/_variables.css +43 -31
- package/src/base/carousel-scroll.d.ts +161 -0
- package/src/base/carousel-scroll.d.ts.map +1 -0
- package/src/base/carousel-scroll.js +1035 -0
- package/src/base/carousel-scroll.ts +1227 -0
- package/src/base/carousel.d.ts +34 -0
- package/src/base/carousel.d.ts.map +1 -0
- package/src/base/carousel.js +279 -0
- package/src/base/carousel.ts +292 -0
- package/src/base/dialog-lifecycle.js +1 -1
- package/src/base/dialog-lifecycle.ts +1 -1
- package/src/base/gesture.d.ts +201 -0
- package/src/base/gesture.d.ts.map +1 -0
- package/src/base/gesture.js +317 -0
- package/src/base/gesture.ts +494 -0
- package/src/base/kit-styling.d.ts.map +1 -1
- package/src/base/kit-styling.js +182 -162
- package/src/base/kit-styling.ts +182 -162
- package/src/base/utils.d.ts +1 -1
- package/src/base/utils.js +2 -2
- package/src/base/utils.ts +2 -2
- package/src/globals.d.ts +7 -30
- package/src/head.d.ts.map +1 -1
- package/src/head.js +1 -25
- package/src/head.ts +1 -25
- package/src/index.css +1 -0
- package/src/index.d.ts +6 -5
- package/src/index.d.ts.map +1 -1
- package/src/index.js +6 -5
- package/src/index.ts +6 -5
- package/src/manifest.d.ts +1 -1
- package/src/manifest.d.ts.map +1 -1
- package/src/manifest.js +25 -13
- package/src/manifest.ts +26 -14
- package/src/primitives/button/button.css +1 -1
- package/src/primitives/carousel/carousel.css +103 -20
- package/src/primitives/carousel/carousel.d.ts +4 -32
- package/src/primitives/carousel/carousel.d.ts.map +1 -1
- package/src/primitives/carousel/carousel.js +39 -14
- package/src/primitives/carousel/carousel.ts +21 -25
- package/src/primitives/dialog/dialog.css +14 -8
- package/src/primitives/drawer/drawer-indent.html +27 -0
- package/src/primitives/drawer/drawer-nested.html +72 -0
- package/src/primitives/drawer/drawer-responsive-dialog.html +44 -0
- package/src/primitives/drawer/drawer-snap.html +26 -0
- package/src/primitives/drawer/drawer.css +528 -0
- package/src/primitives/drawer/drawer.d.ts +24 -0
- package/src/primitives/drawer/drawer.d.ts.map +1 -0
- package/src/primitives/drawer/drawer.html +42 -0
- package/src/primitives/drawer/drawer.js +765 -0
- package/src/primitives/drawer/drawer.ts +823 -0
- package/src/primitives/fields/fields.css +4 -2
- package/src/primitives/input/input.css +4 -3
- package/src/primitives/input-group/input-group.css +5 -5
- package/src/primitives/lightbox/lightbox.css +2 -2
- package/src/primitives/lightbox/lightbox.d.ts.map +1 -1
- package/src/primitives/lightbox/lightbox.js +9 -8
- package/src/primitives/lightbox/lightbox.ts +9 -8
- package/src/primitives/password-group/password-group.css +5 -5
- package/src/primitives/radio/radio.css +15 -10
- package/src/primitives/slider/slider.css +2 -2
- package/src/primitives/switch/switch.css +6 -6
- package/src/primitives/tabs/tabs.css +10 -10
- package/src/primitives/toaster/toaster.css +29 -1
- package/src/primitives/toaster/toaster.d.ts.map +1 -1
- package/src/primitives/toaster/toaster.js +117 -9
- package/src/primitives/toaster/toaster.ts +136 -9
- package/src/primitives/tooltip/tooltip.css +93 -10
- package/src/base/embla.d.ts +0 -90
- package/src/base/embla.d.ts.map +0 -1
- package/src/base/embla.js +0 -878
- package/src/base/embla.ts +0 -1066
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* drawer.css: Drawer ([data-ui~="drawer"] on native <dialog>; slots
|
|
3
|
+
* data-drawer-slot="handle | content | header | body | footer | close";
|
|
4
|
+
* <ui-drawer-indent> / [data-ui~="drawer-indent"], the page wrapper that
|
|
5
|
+
* scales back behind an open drawer)
|
|
6
|
+
*
|
|
7
|
+
* A bottom sheet: a modal dialog that rises from the bottom edge and is dragged
|
|
8
|
+
* back down to dismiss. Alone (`data-ui="drawer"`) it is a drawer everywhere;
|
|
9
|
+
* on a dialog (`data-ui="dialog drawer"`) it is a drawer below the sm band on a
|
|
10
|
+
* touch screen and the plain dialog otherwise. `data-drawer-snap` gives it
|
|
11
|
+
* resting heights; a drawer opened over another pushes that one back.
|
|
12
|
+
*
|
|
13
|
+
* @layer variables, components
|
|
14
|
+
* @requires _layers.css, _variables.css, dialog.css (the native <dialog> motion, backdrop, and
|
|
15
|
+
* scroll lock in its reset layer; the surface and slots in the combined form)
|
|
16
|
+
* @uses Overrides --ui-dialog-* motion tokens: the dialog's open/close transition becomes a
|
|
17
|
+
* rise from the bottom edge, with the backdrop on the same duration and curve
|
|
18
|
+
* @uses translate — drawer.js writes the inline translate while a pointer drags the drawer
|
|
19
|
+
* (state `dragging`, transitions off); the dialog's transitions finish the release
|
|
20
|
+
* @uses Web Animations on ::backdrop — drawer.js scrubs a paused opacity animation so the
|
|
21
|
+
* backdrop fades with the drag without restyling the drawer's content on every move
|
|
22
|
+
* @uses @property (inherits: false) + `inherit` on ::backdrop — the same link in CSS, for
|
|
23
|
+
* an engine that cannot animate ::backdrop from script; where neither works the
|
|
24
|
+
* backdrop stays opaque until release
|
|
25
|
+
* @uses @media (width < 40rem) and (not (hover: hover)) — the combined form's drawer mode,
|
|
26
|
+
* the same phone test as dialog.css
|
|
27
|
+
* @uses scale, translate — the only properties the stack and the indent animate; the
|
|
28
|
+
* indent's corner radius is two corner pieces that scale up, so no border-radius or
|
|
29
|
+
* clip is animated and the page is never repainted for it
|
|
30
|
+
* @uses clip-path: inset() — a fixed rectangle while the page is indented, so the part of
|
|
31
|
+
* the page above and below the viewport stays out of the gaps the scale opens
|
|
32
|
+
* @uses :has() — the body takes the backing color while its page wrapper is indented
|
|
33
|
+
* @uses @starting-style — the corner pieces grow from nothing when they are generated
|
|
34
|
+
* @uses corner-shape — the corner pieces follow --radius-corner-shape where it is
|
|
35
|
+
* supported and are round elsewhere
|
|
36
|
+
* @uses env(safe-area-inset-top) — the indented page clears the status bar
|
|
37
|
+
* @uses env(safe-area-inset-bottom) — content clears the home indicator
|
|
38
|
+
* @uses visualViewport — drawer.js writes --_drawer-keyboard (the software
|
|
39
|
+
* keyboard's height) on the front drawer, and the sheet's bottom padding takes it,
|
|
40
|
+
* so content ends at the keyboard's top edge while the surface runs on under it
|
|
41
|
+
* @uses --_touch-min — the handle's hit area on touch screens
|
|
42
|
+
* @tokens --ui-drawer-* (@layer variables)
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
@layer variables {
|
|
46
|
+
:root {
|
|
47
|
+
/* surface */
|
|
48
|
+
--ui-drawer-bg: var(--ui-dialog-bg);
|
|
49
|
+
--ui-drawer-text: var(--ui-dialog-text);
|
|
50
|
+
--ui-drawer-radius: var(--radius-xl);
|
|
51
|
+
--ui-drawer-corner-shape: var(--ui-dialog-corner-shape);
|
|
52
|
+
--ui-drawer-shadow: var(--shadow-lg);
|
|
53
|
+
|
|
54
|
+
/* metrics: edge to edge, the layout-bleed band; cap it with a band to float a
|
|
55
|
+
narrower sheet, e.g. min(var(--layout-sm), 100%) */
|
|
56
|
+
--ui-drawer-w: 100%;
|
|
57
|
+
--ui-drawer-max-h: calc(100dvb - var(--space-lg));
|
|
58
|
+
|
|
59
|
+
/* stack: how much each drawer in front shrinks and lifts the one behind */
|
|
60
|
+
--ui-drawer-stack-scale: 0.05;
|
|
61
|
+
--ui-drawer-stack-lift: var(--space-sm);
|
|
62
|
+
/* the page is already dimmed by the first drawer's backdrop */
|
|
63
|
+
--ui-drawer-nested-backdrop-color: transparent;
|
|
64
|
+
|
|
65
|
+
/* indent: how far each side of the page pulls in, how far it drops, the radius of
|
|
66
|
+
its top corners, and the color behind it. Set these on :root: the body reads the
|
|
67
|
+
backing color too. */
|
|
68
|
+
--ui-drawer-indent-inset: calc(var(--spacing) * 3);
|
|
69
|
+
--ui-drawer-indent-offset: calc(env(safe-area-inset-top, 0px) + var(--space-sm));
|
|
70
|
+
--ui-drawer-indent-radius: var(--ui-drawer-radius);
|
|
71
|
+
--ui-drawer-indent-bg: var(--color-background);
|
|
72
|
+
--ui-drawer-indent-backing: var(--color-black);
|
|
73
|
+
|
|
74
|
+
/* handle */
|
|
75
|
+
--ui-drawer-handle-w: calc(var(--spacing) * 12);
|
|
76
|
+
--ui-drawer-handle-h: calc(var(--spacing) * 1.25);
|
|
77
|
+
--ui-drawer-handle-bg: var(--color-muted);
|
|
78
|
+
--ui-drawer-handle-bg--hover: var(--color-muted-foreground);
|
|
79
|
+
--ui-drawer-handle-bg--active: var(--color-muted-foreground);
|
|
80
|
+
--ui-drawer-handle-bg--dragging: var(--color-foreground);
|
|
81
|
+
|
|
82
|
+
/* motion: the iOS sheet curve, steep at the start so twice the default
|
|
83
|
+
duration still reads as quick; 0s under reduced motion like the default */
|
|
84
|
+
--ui-drawer-transition-duration: calc(var(--default-transition-duration) * 2);
|
|
85
|
+
--ui-drawer-transition-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* Drawer mode flag, read by drawer.js; and the backdrop's drag opacity, written by it.
|
|
90
|
+
Non-inheriting, so neither restyles the drawer's content. */
|
|
91
|
+
@property --_drawer-mode {
|
|
92
|
+
syntax: "*";
|
|
93
|
+
inherits: false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@property --_drawer-backdrop {
|
|
97
|
+
syntax: "*";
|
|
98
|
+
inherits: false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* Where a drawer with snap points rests, and how many drawers sit in front of it:
|
|
102
|
+
both written by drawer.js when they change (the depth also while the front drawer
|
|
103
|
+
is dragged), and non-inheriting, so neither restyles the drawer's content. */
|
|
104
|
+
@property --_drawer-snap {
|
|
105
|
+
syntax: "*";
|
|
106
|
+
inherits: false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@property --_drawer-depth {
|
|
110
|
+
syntax: "*";
|
|
111
|
+
inherits: false;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* The software keyboard's height while the drawer is the front one, written by
|
|
115
|
+
drawer.js from the visual viewport; the sheet's bottom padding takes it. */
|
|
116
|
+
@property --_drawer-keyboard {
|
|
117
|
+
syntax: "*";
|
|
118
|
+
inherits: false;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* The indent's measurements, written by drawer.js when a drawer opens, and how
|
|
122
|
+
indented the page is (0 to 1): 1 from the `active` state, or the drag's own
|
|
123
|
+
value while the last drawer is dragged. The corner pieces take them by explicit
|
|
124
|
+
inheritance. The inset is typed so the script reads the hook in px. */
|
|
125
|
+
@property --_drawer-indent-amount {
|
|
126
|
+
syntax: "*";
|
|
127
|
+
inherits: false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@property --_drawer-indent-scale {
|
|
131
|
+
syntax: "*";
|
|
132
|
+
inherits: false;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@property --_drawer-indent-top {
|
|
136
|
+
syntax: "*";
|
|
137
|
+
inherits: false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@property --_drawer-indent-bottom {
|
|
141
|
+
syntax: "*";
|
|
142
|
+
inherits: false;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@property --_drawer-indent-inset {
|
|
146
|
+
syntax: "<length>";
|
|
147
|
+
inherits: false;
|
|
148
|
+
initial-value: 0px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@layer ui.components {
|
|
152
|
+
/* ===========================================================================
|
|
153
|
+
DRAWER MODE: the declarations that make a dialog a bottom sheet. Written
|
|
154
|
+
twice, because the two forms enter it under different conditions: the
|
|
155
|
+
standalone form always, the combined form on a phone. Keep the two blocks
|
|
156
|
+
identical apart from the --_dialog-* lines, which feed the dialog's own
|
|
157
|
+
read chain in the combined form.
|
|
158
|
+
|
|
159
|
+
The sheet extends --_bleed past the bottom edge (padding inside,
|
|
160
|
+
an equal negative margin outside), so pulling it up against its resistance
|
|
161
|
+
never opens a gap under it.
|
|
162
|
+
=========================================================================== */
|
|
163
|
+
|
|
164
|
+
:where([data-ui~="drawer"]:not([data-ui~="dialog"])) {
|
|
165
|
+
--_drawer-mode: 1;
|
|
166
|
+
--_bleed: calc(var(--spacing) * 12);
|
|
167
|
+
--_handle-display: block;
|
|
168
|
+
--_content-row: 2;
|
|
169
|
+
--_header-select: none;
|
|
170
|
+
|
|
171
|
+
--ui-dialog-transition-duration: var(--ui-drawer-transition-duration);
|
|
172
|
+
--ui-dialog-transition-timing-function: var(--ui-drawer-transition-timing-function);
|
|
173
|
+
--ui-dialog-backdrop-transition-duration: var(--ui-dialog-transition-duration);
|
|
174
|
+
--ui-dialog-backdrop-transition-timing-function: var(--ui-drawer-transition-timing-function);
|
|
175
|
+
--ui-dialog-transition-delay--end: 0ms;
|
|
176
|
+
--ui-dialog-opacity--start: 1;
|
|
177
|
+
--ui-dialog-scale--start: 1;
|
|
178
|
+
--ui-dialog-translate--start: 0, 100%, 0;
|
|
179
|
+
|
|
180
|
+
margin-block: auto calc(var(--_bleed) * -1);
|
|
181
|
+
margin-inline: auto;
|
|
182
|
+
/* the keyboard covers the home indicator: the larger of the two, not both */
|
|
183
|
+
padding-block-end: calc(
|
|
184
|
+
var(--_bleed) + max(env(safe-area-inset-bottom, 0px), var(--_drawer-keyboard, 0px))
|
|
185
|
+
);
|
|
186
|
+
max-inline-size: 100%;
|
|
187
|
+
max-block-size: calc(var(--ui-drawer-max-h) + var(--_bleed));
|
|
188
|
+
grid-template-rows: auto minmax(0, 1fr);
|
|
189
|
+
border-block-end-width: 0;
|
|
190
|
+
border-end-start-radius: 0;
|
|
191
|
+
border-end-end-radius: 0;
|
|
192
|
+
/* a stacked drawer shrinks toward its top edge, the part that stays in view */
|
|
193
|
+
transform-origin: 50% 0;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
@media (width < 40rem) and (not (hover: hover)) {
|
|
197
|
+
:where([data-ui~="dialog"][data-ui~="drawer"]) {
|
|
198
|
+
--_drawer-mode: 1;
|
|
199
|
+
--_bleed: calc(var(--spacing) * 12);
|
|
200
|
+
--_handle-display: block;
|
|
201
|
+
--_content-row: 2;
|
|
202
|
+
--_header-select: none;
|
|
203
|
+
|
|
204
|
+
--_dialog-w: var(--ui-drawer-w);
|
|
205
|
+
--_dialog-radius: var(--ui-drawer-radius);
|
|
206
|
+
--_dialog-shadow: var(--ui-drawer-shadow);
|
|
207
|
+
|
|
208
|
+
--ui-dialog-transition-duration: var(--ui-drawer-transition-duration);
|
|
209
|
+
--ui-dialog-transition-timing-function: var(--ui-drawer-transition-timing-function);
|
|
210
|
+
--ui-dialog-backdrop-transition-duration: var(--ui-dialog-transition-duration);
|
|
211
|
+
--ui-dialog-backdrop-transition-timing-function: var(--ui-drawer-transition-timing-function);
|
|
212
|
+
--ui-dialog-transition-delay--end: 0ms;
|
|
213
|
+
--ui-dialog-opacity--start: 1;
|
|
214
|
+
--ui-dialog-scale--start: 1;
|
|
215
|
+
--ui-dialog-translate--start: 0, 100%, 0;
|
|
216
|
+
|
|
217
|
+
margin-block: auto calc(var(--_bleed) * -1);
|
|
218
|
+
margin-inline: auto;
|
|
219
|
+
/* the keyboard covers the home indicator: the larger of the two, not both */
|
|
220
|
+
padding-block-end: calc(
|
|
221
|
+
var(--_bleed) + max(env(safe-area-inset-bottom, 0px), var(--_drawer-keyboard, 0px))
|
|
222
|
+
);
|
|
223
|
+
max-inline-size: 100%;
|
|
224
|
+
max-block-size: calc(var(--ui-drawer-max-h) + var(--_bleed));
|
|
225
|
+
grid-template-rows: auto minmax(0, 1fr);
|
|
226
|
+
border-block-end-width: 0;
|
|
227
|
+
border-end-start-radius: 0;
|
|
228
|
+
border-end-end-radius: 0;
|
|
229
|
+
transform-origin: 50% 0;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* ===========================================================================
|
|
234
|
+
STANDALONE SURFACE: without the dialog identity the drawer paints itself.
|
|
235
|
+
The combined form takes all of this from dialog.css.
|
|
236
|
+
=========================================================================== */
|
|
237
|
+
|
|
238
|
+
:where([data-ui~="drawer"]:not([data-ui~="dialog"])) {
|
|
239
|
+
inline-size: var(--ui-drawer-w);
|
|
240
|
+
block-size: fit-content;
|
|
241
|
+
background-color: var(--_bg-resolved, var(--ui-drawer-bg));
|
|
242
|
+
color: var(--_text-resolved, var(--ui-drawer-text));
|
|
243
|
+
box-shadow: var(--_shadow-resolved, var(--ui-drawer-shadow));
|
|
244
|
+
/* the top corners only: the bottom edge sits past the viewport */
|
|
245
|
+
border-start-start-radius: var(--ui-drawer-radius);
|
|
246
|
+
border-start-end-radius: var(--ui-drawer-radius);
|
|
247
|
+
corner-shape: var(--_corner-shape-resolved, var(--ui-drawer-corner-shape));
|
|
248
|
+
font-size: var(--font-size-md);
|
|
249
|
+
overflow: hidden;
|
|
250
|
+
overscroll-behavior: contain;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
:where([data-ui~="drawer"]:not([data-ui~="dialog"])[open]) {
|
|
254
|
+
display: grid;
|
|
255
|
+
min-block-size: 0;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/* ===========================================================================
|
|
259
|
+
SNAP POINTS: a drawer with data-drawer-snap is as tall as a drawer may be and
|
|
260
|
+
rests pushed down by --_drawer-snap, which drawer.js writes when the stop
|
|
261
|
+
changes. The height is set per form, like drawer mode itself.
|
|
262
|
+
=========================================================================== */
|
|
263
|
+
|
|
264
|
+
:where([data-ui~="drawer"]:not([data-ui~="dialog"])[data-drawer-snap]) {
|
|
265
|
+
block-size: calc(var(--ui-drawer-max-h) + var(--_bleed));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
@media (width < 40rem) and (not (hover: hover)) {
|
|
269
|
+
:where([data-ui~="dialog"][data-ui~="drawer"][data-drawer-snap]) {
|
|
270
|
+
--_dialog-h: calc(var(--ui-drawer-max-h) + var(--_bleed));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
:where([data-ui~="drawer"][data-drawer-snap]) {
|
|
275
|
+
translate: 0 var(--_drawer-snap, 0px);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* ===========================================================================
|
|
279
|
+
STACK: a drawer with others open in front of it shrinks toward its top edge
|
|
280
|
+
and lifts, once per drawer in front. drawer.js writes the count, and while
|
|
281
|
+
the front drawer is dragged a fraction of it (state `following`, transitions
|
|
282
|
+
off). A drawer opened over another dims nothing more.
|
|
283
|
+
=========================================================================== */
|
|
284
|
+
|
|
285
|
+
:where([data-ui~="drawer"][data-drawer-state~="stacked"]) {
|
|
286
|
+
scale: calc(1 - var(--_drawer-depth, 0) * var(--ui-drawer-stack-scale));
|
|
287
|
+
translate: 0
|
|
288
|
+
calc(var(--_drawer-snap, 0px) - var(--_drawer-depth, 0) * var(--ui-drawer-stack-lift));
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
:where([data-ui~="drawer"][data-drawer-state~="following"]) {
|
|
292
|
+
transition: none;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
:where([data-ui~="drawer"][data-drawer-state~="nested"])::backdrop {
|
|
296
|
+
background-color: var(--ui-drawer-nested-backdrop-color);
|
|
297
|
+
backdrop-filter: none;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/* Each slot owns a row, as in the dialog: the body is the part that scrolls */
|
|
301
|
+
:where([data-ui~="drawer"]) [data-drawer-slot~="content"] {
|
|
302
|
+
display: grid;
|
|
303
|
+
grid-template-rows: auto minmax(0, 1fr) auto;
|
|
304
|
+
position: relative;
|
|
305
|
+
min-block-size: 0;
|
|
306
|
+
max-block-size: 100%;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
:where([data-ui~="drawer"]) [data-drawer-slot~="header"] {
|
|
310
|
+
grid-row: 1;
|
|
311
|
+
display: flex;
|
|
312
|
+
flex-direction: column;
|
|
313
|
+
padding-inline: var(--space-sm);
|
|
314
|
+
padding-block-start: var(--space-sm);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
:where([data-ui~="drawer"]) [data-drawer-slot~="body"] {
|
|
318
|
+
grid-row: 2;
|
|
319
|
+
display: grid;
|
|
320
|
+
align-content: start;
|
|
321
|
+
padding-inline: var(--space-sm);
|
|
322
|
+
padding-block: var(--space-md);
|
|
323
|
+
min-block-size: 0;
|
|
324
|
+
overflow-y: auto;
|
|
325
|
+
overscroll-behavior: contain;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
:where([data-ui~="drawer"]) [data-drawer-slot~="footer"] {
|
|
329
|
+
grid-row: 3;
|
|
330
|
+
display: flex;
|
|
331
|
+
justify-content: flex-end;
|
|
332
|
+
gap: var(--space-xs);
|
|
333
|
+
padding: var(--space-sm);
|
|
334
|
+
border-block-start: 1px solid var(--color-border);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
:where([data-ui~="drawer"]) [data-drawer-slot~="close"] {
|
|
338
|
+
position: absolute;
|
|
339
|
+
inset-block-start: var(--space-xs);
|
|
340
|
+
inset-inline-end: var(--space-xs);
|
|
341
|
+
z-index: 50;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/* ===========================================================================
|
|
345
|
+
PARTS IN DRAWER MODE: the handle shows and takes the first row; the content
|
|
346
|
+
slot (the drawer's own or the dialog's) takes the flexible second row, with
|
|
347
|
+
or without a handle before it. Both read the mode privates set above, so
|
|
348
|
+
neither rule is repeated per form.
|
|
349
|
+
=========================================================================== */
|
|
350
|
+
|
|
351
|
+
:where([data-ui~="drawer"]) :where([data-drawer-slot~="content"], [data-dialog-slot~="content"]) {
|
|
352
|
+
grid-row: var(--_content-row, auto);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/* The header is where a mouse grabs the drawer: a press on its text drags
|
|
356
|
+
instead of selecting. Body text stays selectable. */
|
|
357
|
+
:where([data-ui~="drawer"]) :where([data-drawer-slot~="header"], [data-dialog-slot~="header"]) {
|
|
358
|
+
-webkit-user-select: var(--_header-select, auto);
|
|
359
|
+
user-select: var(--_header-select, auto);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/* A pill, with a hit area that reaches the touch-target height. It always
|
|
363
|
+
drags, even over a scrolled body, so it opts out of native panning. */
|
|
364
|
+
:where([data-ui~="drawer"]) [data-drawer-slot~="handle"] {
|
|
365
|
+
display: var(--_handle-display, none);
|
|
366
|
+
grid-row: 1;
|
|
367
|
+
justify-self: center;
|
|
368
|
+
position: relative;
|
|
369
|
+
inline-size: var(--ui-drawer-handle-w);
|
|
370
|
+
block-size: var(--ui-drawer-handle-h);
|
|
371
|
+
margin-block: calc(var(--spacing) * 2.5) calc(var(--spacing) * 1);
|
|
372
|
+
border-radius: var(--radius-full);
|
|
373
|
+
background-color: var(--ui-drawer-handle-bg);
|
|
374
|
+
cursor: grab;
|
|
375
|
+
touch-action: none;
|
|
376
|
+
-webkit-user-select: none;
|
|
377
|
+
user-select: none;
|
|
378
|
+
transition: background-color var(--default-transition-duration)
|
|
379
|
+
var(--default-transition-timing-function);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
:where([data-ui~="drawer"]) [data-drawer-slot~="handle"]:hover {
|
|
383
|
+
background-color: var(--ui-drawer-handle-bg--hover);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
:where([data-ui~="drawer"]) [data-drawer-slot~="handle"]:active {
|
|
387
|
+
background-color: var(--ui-drawer-handle-bg--active);
|
|
388
|
+
cursor: grabbing;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
:where([data-ui~="drawer"]) [data-drawer-slot~="handle"]::before {
|
|
392
|
+
content: "";
|
|
393
|
+
position: absolute;
|
|
394
|
+
inset-inline: calc(var(--ui-drawer-handle-w) * -1);
|
|
395
|
+
inset-block: min(calc(var(--spacing) * -2), calc((100% - var(--_touch-min, 0px)) / 2));
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/* Below its largest snap point a drawer's content does not scroll: the drawer
|
|
399
|
+
moves first. After the slot rules, which it has to beat. */
|
|
400
|
+
:where([data-ui~="drawer"][data-drawer-state~="partial"])
|
|
401
|
+
:is([data-drawer-slot~="body"], [data-dialog-slot~="body"]) {
|
|
402
|
+
overflow-y: hidden;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/* ===========================================================================
|
|
406
|
+
DRAG: while a pointer drags the drawer, drawer.js writes its inline
|
|
407
|
+
translate and nothing may ease it: the drawer is the pointer. The backdrop
|
|
408
|
+
fades with the drag: drawer.js scrubs an animation on it, or, where
|
|
409
|
+
::backdrop cannot be animated from script, writes --_drawer-backdrop, which
|
|
410
|
+
the backdrop takes from the dialog by explicit inheritance. On release the state drops and the dialog's
|
|
411
|
+
own transitions finish the motion, to closed or back to rest.
|
|
412
|
+
=========================================================================== */
|
|
413
|
+
|
|
414
|
+
:where([data-ui~="drawer"][data-drawer-state~="dragging"]) [data-drawer-slot~="handle"] {
|
|
415
|
+
background-color: var(--ui-drawer-handle-bg--dragging);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
:where([data-ui~="drawer"][data-drawer-state~="dragging"]) {
|
|
419
|
+
transition: none;
|
|
420
|
+
cursor: grabbing;
|
|
421
|
+
/* a mouse drag that began beside text must not start selecting it */
|
|
422
|
+
-webkit-user-select: none;
|
|
423
|
+
user-select: none;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
:where([data-ui~="drawer"][data-drawer-state~="dragging"])::backdrop {
|
|
427
|
+
--_drawer-backdrop: inherit;
|
|
428
|
+
opacity: var(--_drawer-backdrop, 1);
|
|
429
|
+
transition: none;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/* ===========================================================================
|
|
433
|
+
INDENT: the page wrapper scales back behind an open drawer. drawer.js sets the
|
|
434
|
+
state (`on` while the machinery is engaged, `active` while a drawer is open,
|
|
435
|
+
`dragging` while the last drawer is dragged) and measures, once, the scale and
|
|
436
|
+
where the viewport sits inside the wrapper.
|
|
437
|
+
|
|
438
|
+
Only scale and translate animate. The wrapper is clipped to the viewport's
|
|
439
|
+
rectangle, a fixed clip, so the page above and below it stays out of the gaps;
|
|
440
|
+
the body paints the backing color there. The rounded top corners are two
|
|
441
|
+
corner pieces that grow from the corners, not a border-radius: nothing is
|
|
442
|
+
repainted while the page moves.
|
|
443
|
+
|
|
444
|
+
While `on` the wrapper is transformed, so it is the containing block of its
|
|
445
|
+
fixed and absolute descendants.
|
|
446
|
+
=========================================================================== */
|
|
447
|
+
|
|
448
|
+
:where(ui-drawer-indent, [data-ui~="drawer-indent"]) {
|
|
449
|
+
--_drawer-indent-inset: var(--ui-drawer-indent-inset);
|
|
450
|
+
display: block;
|
|
451
|
+
background-color: var(--ui-drawer-indent-bg);
|
|
452
|
+
transition:
|
|
453
|
+
scale var(--ui-drawer-transition-duration) var(--ui-drawer-transition-timing-function),
|
|
454
|
+
translate var(--ui-drawer-transition-duration) var(--ui-drawer-transition-timing-function);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
:where(ui-drawer-indent, [data-ui~="drawer-indent"])[data-drawer-indent-state~="on"] {
|
|
458
|
+
position: relative;
|
|
459
|
+
transform-origin: 50% var(--_drawer-indent-top, 0px);
|
|
460
|
+
scale: calc(1 - (1 - var(--_drawer-indent-scale, 1)) * var(--_drawer-indent-amount, 0));
|
|
461
|
+
translate: 0 calc(var(--ui-drawer-indent-offset) * var(--_drawer-indent-amount, 0));
|
|
462
|
+
clip-path: inset(var(--_drawer-indent-top, 0px) 0 var(--_drawer-indent-bottom, 0px) 0);
|
|
463
|
+
will-change: scale, translate;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
:where(ui-drawer-indent, [data-ui~="drawer-indent"])[data-drawer-indent-state~="active"] {
|
|
467
|
+
--_drawer-indent-amount: 1;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/* The backing shows in the gaps around the indented page. Important, because a
|
|
471
|
+
page's own <body style="--bg: …"> is a utility and would otherwise win; it holds
|
|
472
|
+
only while the wrapper is `on`. */
|
|
473
|
+
:where(body):has(
|
|
474
|
+
:is(ui-drawer-indent, [data-ui~="drawer-indent"])[data-drawer-indent-state~="on"]
|
|
475
|
+
) {
|
|
476
|
+
background-color: var(--ui-drawer-indent-backing) !important;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/* A corner piece: a square the size of the radius whose outer corner is rounded
|
|
480
|
+
and whose spread shadow, cut off at the square, paints only the notch outside
|
|
481
|
+
the curve. Scaling it from that corner is the radius growing. */
|
|
482
|
+
:where(ui-drawer-indent, [data-ui~="drawer-indent"])[data-drawer-indent-state~="on"]::before,
|
|
483
|
+
:where(ui-drawer-indent, [data-ui~="drawer-indent"])[data-drawer-indent-state~="on"]::after {
|
|
484
|
+
--_drawer-indent-amount: inherit;
|
|
485
|
+
--_drawer-indent-top: inherit;
|
|
486
|
+
content: "";
|
|
487
|
+
position: absolute;
|
|
488
|
+
z-index: 2147483647;
|
|
489
|
+
inset-block-start: var(--_drawer-indent-top, 0px);
|
|
490
|
+
inline-size: var(--ui-drawer-indent-radius);
|
|
491
|
+
block-size: var(--ui-drawer-indent-radius);
|
|
492
|
+
box-shadow: 0 0 0 var(--ui-drawer-indent-radius) var(--ui-drawer-indent-backing);
|
|
493
|
+
clip-path: inset(0);
|
|
494
|
+
corner-shape: var(--radius-corner-shape);
|
|
495
|
+
scale: var(--_drawer-indent-amount, 0);
|
|
496
|
+
pointer-events: none;
|
|
497
|
+
transition: scale var(--ui-drawer-transition-duration)
|
|
498
|
+
var(--ui-drawer-transition-timing-function);
|
|
499
|
+
|
|
500
|
+
@starting-style {
|
|
501
|
+
scale: 0;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
:where(ui-drawer-indent, [data-ui~="drawer-indent"])[data-drawer-indent-state~="on"]::before {
|
|
506
|
+
left: 0;
|
|
507
|
+
border-top-left-radius: 100%;
|
|
508
|
+
transform-origin: 0 0;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
:where(ui-drawer-indent, [data-ui~="drawer-indent"])[data-drawer-indent-state~="on"]::after {
|
|
512
|
+
right: 0;
|
|
513
|
+
border-top-right-radius: 100%;
|
|
514
|
+
transform-origin: 100% 0;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
:where(ui-drawer-indent, [data-ui~="drawer-indent"])[data-drawer-indent-state~="dragging"],
|
|
518
|
+
:where(
|
|
519
|
+
ui-drawer-indent,
|
|
520
|
+
[data-ui~="drawer-indent"]
|
|
521
|
+
)[data-drawer-indent-state~="dragging"]::before,
|
|
522
|
+
:where(
|
|
523
|
+
ui-drawer-indent,
|
|
524
|
+
[data-ui~="drawer-indent"]
|
|
525
|
+
)[data-drawer-indent-state~="dragging"]::after {
|
|
526
|
+
transition: none;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Binds drag-to-dismiss to an open drawer until it closes.
|
|
3
|
+
*
|
|
4
|
+
* @param dialog - The drawer.
|
|
5
|
+
*/
|
|
6
|
+
declare function bindDrawer(dialog: HTMLDialogElement): void;
|
|
7
|
+
/**
|
|
8
|
+
* @description Moves an open drawer to one of its snap points.
|
|
9
|
+
*
|
|
10
|
+
* @param dialog - The drawer.
|
|
11
|
+
* @param index - The snap point, counted from the smallest; clamped to the ones it has.
|
|
12
|
+
*/
|
|
13
|
+
declare function snapDrawer(dialog: HTMLDialogElement, index: number): void;
|
|
14
|
+
interface InitDrawersFn {
|
|
15
|
+
(): void;
|
|
16
|
+
_bound?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @description Starts drawer binding for the page: every drawer is bound when
|
|
20
|
+
* the dialog lifecycle reports it open and unbound when it closes. Idempotent.
|
|
21
|
+
*/
|
|
22
|
+
declare const initDrawers: InitDrawersFn;
|
|
23
|
+
export { bindDrawer, initDrawers, snapDrawer };
|
|
24
|
+
//# sourceMappingURL=drawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["drawer.ts"],"names":[],"mappings":"AAqgBA;;;;GAIG;AACH,iBAAS,UAAU,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CA2OnD;AAcD;;;;;GAKG;AACH,iBAAS,UAAU,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAElE;AAED,UAAU,aAAa;IACrB,IAAI,IAAI,CAAC;IACT,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,QAAA,MAAM,WAAW,EAAE,aAqBlB,CAAC;AAWF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<button data-ui="button" type="button" command="show-modal" commandfor="drawer-example-1">
|
|
2
|
+
Open drawer
|
|
3
|
+
</button>
|
|
4
|
+
<dialog id="drawer-example-1" data-ui="drawer" closedby="any">
|
|
5
|
+
<div data-drawer-slot="handle"></div>
|
|
6
|
+
<div data-drawer-slot="content">
|
|
7
|
+
<header data-drawer-slot="header">
|
|
8
|
+
<h2
|
|
9
|
+
style="
|
|
10
|
+
--font-size: var(--font-size-lg);
|
|
11
|
+
--font-weight: strong;
|
|
12
|
+
--font-family: var(--font-family-heading);
|
|
13
|
+
"
|
|
14
|
+
>
|
|
15
|
+
Notification settings
|
|
16
|
+
</h2>
|
|
17
|
+
<p style="--text: var(--color-muted-foreground)">
|
|
18
|
+
Drag the drawer down, or flick it, to dismiss it.
|
|
19
|
+
</p>
|
|
20
|
+
</header>
|
|
21
|
+
<div data-drawer-slot="body">
|
|
22
|
+
<p>
|
|
23
|
+
Scrolling content scrolls first. Once it is at the top, pulling down moves the drawer; the
|
|
24
|
+
handle always does.
|
|
25
|
+
</p>
|
|
26
|
+
</div>
|
|
27
|
+
<footer data-drawer-slot="footer">
|
|
28
|
+
<button data-ui="button" type="button" commandfor="drawer-example-1" command="close">
|
|
29
|
+
Cancel
|
|
30
|
+
</button>
|
|
31
|
+
<button
|
|
32
|
+
data-ui="button"
|
|
33
|
+
data-button-variant="primary"
|
|
34
|
+
type="button"
|
|
35
|
+
commandfor="drawer-example-1"
|
|
36
|
+
command="close"
|
|
37
|
+
>
|
|
38
|
+
Save
|
|
39
|
+
</button>
|
|
40
|
+
</footer>
|
|
41
|
+
</div>
|
|
42
|
+
</dialog>
|