@zazz-ui/core 0.13.1 → 0.14.1
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 +35 -31
- 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/navigation.d.ts +12 -1
- package/src/base/navigation.d.ts.map +1 -1
- package/src/base/navigation.js +65 -1
- package/src/base/navigation.ts +66 -1
- 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 +1 -1
- 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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* carousel.css —
|
|
2
|
+
* carousel.css — scroll-snap carousel (ui-carousel | [data-ui~="carousel"] + data-carousel-slot hooks)
|
|
3
3
|
*
|
|
4
4
|
* @layer variables, components
|
|
5
5
|
* @requires _layers.css, _variables.css
|
|
6
|
-
* @uses data-carousel attributes —
|
|
7
|
-
* @uses data-
|
|
6
|
+
* @uses data-carousel attributes — the viewport is a native scroll-snap container; base/carousel.js adds mouse drag, loop, controls, and state
|
|
7
|
+
* @uses data-carousel-state on the viewport — free | gliding | settling | jumping | dragging, written by base/carousel-scroll.js
|
|
8
8
|
* @uses container-type on viewport — basis-* / @sm:basis-* utils query [data-carousel-slot~="viewport"] width
|
|
9
9
|
* @tokens --ui-carousel-* (@layer variables)
|
|
10
10
|
* @consumedby lightbox.css
|
|
@@ -16,8 +16,12 @@
|
|
|
16
16
|
--ui-carousel-gap: 0px;
|
|
17
17
|
--ui-carousel-slide-basis: calc(100% - var(--ui-carousel-gap));
|
|
18
18
|
--ui-carousel-slide-min-w: 0;
|
|
19
|
-
--ui-carousel-touch-action: pan-y pinch-zoom;
|
|
20
19
|
--ui-carousel-cursor--grabbing: grabbing;
|
|
20
|
+
/* where slides rest (data-carousel-align sets it), and the rubber band's
|
|
21
|
+
return after a mouse drag past an end (0s under reduced motion) */
|
|
22
|
+
--ui-carousel-snap-align: start;
|
|
23
|
+
--ui-carousel-settle-duration: calc(var(--default-transition-duration) * 2);
|
|
24
|
+
--ui-carousel-settle-ease: var(--default-transition-timing-function);
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
|
|
@@ -27,25 +31,76 @@
|
|
|
27
31
|
display: block;
|
|
28
32
|
}
|
|
29
33
|
|
|
30
|
-
/* The grabbing cursor holds page-wide while a slide drags, since the pointer
|
|
31
|
-
leaves the viewport mid-drag. embla.js flags the root; a `body:has(…) *`
|
|
32
|
-
rule here made every DOM insertion restyle the whole page. */
|
|
33
|
-
:where(ui-carousel, [data-ui~="carousel"])
|
|
34
|
-
[data-carousel-slot~="viewport"][data-carousel-state~="dragging"],
|
|
35
|
-
:root[data-ui-dragging],
|
|
36
|
-
:root[data-ui-dragging] * {
|
|
37
|
-
cursor: var(--ui-carousel-cursor--grabbing);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
34
|
:where(ui-carousel, [data-ui~="carousel"]) {
|
|
41
35
|
position: relative;
|
|
42
36
|
isolation: isolate;
|
|
43
37
|
}
|
|
44
38
|
|
|
39
|
+
/* The viewport is a real scroll container: touch, wheel, trackpad, and keys
|
|
40
|
+
scroll it natively, and it still scrolls with no script at all. RTL needs
|
|
41
|
+
nothing here: the track follows the inherited direction. */
|
|
45
42
|
:where(ui-carousel, [data-ui~="carousel"]) [data-carousel-slot~="viewport"] {
|
|
46
|
-
overflow: clip;
|
|
47
43
|
max-block-size: 100%;
|
|
48
44
|
max-inline-size: 100%;
|
|
45
|
+
overflow-x: auto;
|
|
46
|
+
overflow-y: hidden;
|
|
47
|
+
overscroll-behavior-x: contain;
|
|
48
|
+
scroll-snap-type: var(--_snap-axis, x) mandatory;
|
|
49
|
+
scrollbar-width: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* vertical: data-carousel-axis="y" on the root (data-carousel-thumbs-axis="y"
|
|
53
|
+
on a thumbs slot). Give the viewport a block size; slides fill it by basis. */
|
|
54
|
+
:where(ui-carousel, [data-ui~="carousel"])
|
|
55
|
+
:is(
|
|
56
|
+
[data-carousel-axis="y"]
|
|
57
|
+
[data-carousel-slot~="viewport"]:not([data-carousel-slot~="thumbs"] *),
|
|
58
|
+
[data-carousel-thumbs-axis="y"] [data-carousel-slot~="viewport"]
|
|
59
|
+
) {
|
|
60
|
+
--_snap-axis: y;
|
|
61
|
+
overflow-x: hidden;
|
|
62
|
+
overflow-y: auto;
|
|
63
|
+
overscroll-behavior-x: auto;
|
|
64
|
+
overscroll-behavior-y: contain;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* free: drag-free (thumb strips by default), no snapping at all.
|
|
68
|
+
gliding: a mouse drag, its release scroll, or auto-scroll; snapping off
|
|
69
|
+
until it lands. settling: a loop rotation's compensating scroll, with the
|
|
70
|
+
axis locked too (iOS Safari otherwise paints the reordered frame before
|
|
71
|
+
the scroll lands). */
|
|
72
|
+
:where(ui-carousel, [data-ui~="carousel"])
|
|
73
|
+
[data-carousel-slot~="viewport"]:is(
|
|
74
|
+
[data-carousel-state~="free"],
|
|
75
|
+
[data-carousel-state~="gliding"],
|
|
76
|
+
[data-carousel-state~="settling"]
|
|
77
|
+
) {
|
|
78
|
+
scroll-snap-type: none;
|
|
79
|
+
scroll-behavior: auto;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* jumping: an instant scroll the script makes (start position, dialog start) */
|
|
83
|
+
:where(ui-carousel, [data-ui~="carousel"])
|
|
84
|
+
[data-carousel-slot~="viewport"][data-carousel-state~="jumping"] {
|
|
85
|
+
scroll-behavior: auto;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
:where(ui-carousel, [data-ui~="carousel"])
|
|
89
|
+
[data-carousel-slot~="viewport"][data-carousel-state~="settling"] {
|
|
90
|
+
overflow: hidden;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* a mouse drag would otherwise select the slides' text before the slop */
|
|
94
|
+
:where(ui-carousel, [data-ui~="carousel"]):not([data-carousel-draggable="false"])
|
|
95
|
+
[data-carousel-slot~="viewport"] {
|
|
96
|
+
user-select: none;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* The pointer is captured for the whole drag, so this one rule keeps the
|
|
100
|
+
grabbing cursor wherever the pointer goes; no page-wide flag. */
|
|
101
|
+
:where(ui-carousel, [data-ui~="carousel"])
|
|
102
|
+
[data-carousel-slot~="viewport"][data-carousel-state~="dragging"] {
|
|
103
|
+
cursor: var(--ui-carousel-cursor--grabbing);
|
|
49
104
|
}
|
|
50
105
|
|
|
51
106
|
:where(ui-carousel, [data-ui~="carousel"]) [data-carousel-slot~="container"] {
|
|
@@ -53,16 +108,30 @@
|
|
|
53
108
|
--_gap-len: var(--_gap-resolved, var(--ui-carousel-gap));
|
|
54
109
|
--_gap-num: var(--_gap-resolved, var(--ui-carousel-gap));
|
|
55
110
|
gap: calc(var(--_gap-len) + var(--_gap-num) * var(--spacing));
|
|
56
|
-
|
|
111
|
+
/* the rubber band past an end, springing back on release */
|
|
112
|
+
transition: translate var(--ui-carousel-settle-duration) var(--ui-carousel-settle-ease);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
:where(ui-carousel, [data-ui~="carousel"])
|
|
116
|
+
[data-carousel-state~="dragging"]
|
|
117
|
+
> [data-carousel-slot~="container"] {
|
|
118
|
+
transition: none;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
:where(ui-carousel, [data-ui~="carousel"])
|
|
122
|
+
:is(
|
|
123
|
+
[data-carousel-axis="y"]
|
|
124
|
+
[data-carousel-slot~="container"]:not([data-carousel-slot~="thumbs"] *),
|
|
125
|
+
[data-carousel-thumbs-axis="y"] [data-carousel-slot~="container"]
|
|
126
|
+
) {
|
|
127
|
+
flex-direction: column;
|
|
128
|
+
block-size: 100%;
|
|
57
129
|
}
|
|
58
130
|
|
|
59
131
|
:where(ui-carousel, [data-ui~="carousel"]) [data-carousel-slot~="slide"] {
|
|
60
132
|
flex: 0 0 var(--ui-carousel-slide-basis);
|
|
61
133
|
min-inline-size: var(--ui-carousel-slide-min-w);
|
|
62
|
-
|
|
63
|
-
it wraps; a transition on a slide (a link's default, say) sweeps it across
|
|
64
|
-
the viewport. Animate a slide's child. */
|
|
65
|
-
transition: none;
|
|
134
|
+
scroll-snap-align: var(--ui-carousel-snap-align);
|
|
66
135
|
}
|
|
67
136
|
|
|
68
137
|
:where(ui-carousel, [data-ui~="carousel"])
|
|
@@ -70,4 +139,18 @@
|
|
|
70
139
|
[data-carousel-slot~="slide"] {
|
|
71
140
|
flex: 0 0 auto;
|
|
72
141
|
}
|
|
142
|
+
|
|
143
|
+
:where(ui-carousel, [data-ui~="carousel"])[data-carousel-align="center"] {
|
|
144
|
+
--ui-carousel-snap-align: center;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
:where(ui-carousel, [data-ui~="carousel"])[data-carousel-align="end"] {
|
|
148
|
+
--ui-carousel-snap-align: end;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
152
|
+
:where(ui-carousel, [data-ui~="carousel"]) [data-carousel-slot~="viewport"] {
|
|
153
|
+
scroll-behavior: smooth;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
73
156
|
}
|
|
@@ -1,32 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @fileoverview `<ui-carousel>` — HTML web component for carousels.
|
|
3
|
-
* @description Light-DOM custom element that wraps standard carousel markup
|
|
4
|
-
* and owns the Embla lifecycle: it initializes on connect (via
|
|
5
|
-
* `EmblaInit.initRoot`) and destroys its instances on disconnect, so
|
|
6
|
-
* dynamically inserted or SPA-swapped carousels need no manual wiring.
|
|
7
|
-
*
|
|
8
|
-
* The element *is* the carousel root — CSS and `embla.js` target
|
|
9
|
-
* `:is(ui-carousel, [data-ui~="carousel"])` directly, and `data-carousel-*`
|
|
10
|
-
* configuration attributes are read off the element (see embla.js for the
|
|
11
|
-
* full attribute reference). No shadow DOM; children are regular markup.
|
|
12
|
-
*
|
|
13
|
-
* Carousels inside a closed `<dialog>` defer initialization until the dialog
|
|
14
|
-
* first opens (a closed dialog is `display: none`, so Embla cannot measure
|
|
15
|
-
* the viewport).
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* <ui-carousel data-carousel-loop="true">
|
|
19
|
-
* <div data-carousel-slot="viewport">
|
|
20
|
-
* <div data-carousel-slot="container">
|
|
21
|
-
* <div data-carousel-slot="slide">Slide 1</div>
|
|
22
|
-
* <div data-carousel-slot="slide">Slide 2</div>
|
|
23
|
-
* </div>
|
|
24
|
-
* </div>
|
|
25
|
-
* <button type="button" data-carousel-slot="prev">Prev</button>
|
|
26
|
-
* <button type="button" data-carousel-slot="next">Next</button>
|
|
27
|
-
* </ui-carousel>
|
|
28
|
-
*/
|
|
29
|
-
import type { EmblaCarouselType } from "embla-carousel";
|
|
1
|
+
import type { CarouselApi } from "../../base/carousel-scroll.ts";
|
|
30
2
|
import { ZazzElement } from "../../base/zazz-element.ts";
|
|
31
3
|
declare class UiCarouselElement extends ZazzElement {
|
|
32
4
|
protected setup(signal: AbortSignal): void;
|
|
@@ -37,10 +9,10 @@ declare class UiCarouselElement extends ZazzElement {
|
|
|
37
9
|
*/
|
|
38
10
|
init(): void;
|
|
39
11
|
/**
|
|
40
|
-
* @returns The
|
|
41
|
-
*
|
|
12
|
+
* @returns The carousel API (`goTo`, `goToNext`, `goToPrev`, `selectedSnap`,
|
|
13
|
+
* `play`, `stop`), or null before initialization.
|
|
42
14
|
*/
|
|
43
|
-
get api():
|
|
15
|
+
get api(): CarouselApi | null;
|
|
44
16
|
}
|
|
45
17
|
export { UiCarouselElement };
|
|
46
18
|
//# sourceMappingURL=carousel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.d.ts","sourceRoot":"","sources":["carousel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"carousel.d.ts","sourceRoot":"","sources":["carousel.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAqB,MAAM,4BAA4B,CAAC;AAE5E,cAAM,iBAAkB,SAAQ,WAAW;IACzC,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAUzC;IAED,SAAS,CAAC,QAAQ,IAAI,IAAI,CAQzB;IAED;;;OAGG;IACH,IAAI,IAAI,IAAI,CAEX;IAED;;;OAGG;IACH,IAAI,GAAG,IAAI,WAAW,GAAG,IAAI,CAE5B;CACF;AAID,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,11 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview `<ui-carousel>` — HTML web component for carousels.
|
|
4
|
+
* @description Light-DOM custom element that wraps standard carousel markup
|
|
5
|
+
* and owns the carousel's lifecycle: it initializes on connect (via
|
|
6
|
+
* `Carousel.initRoot`) and tears down on disconnect, so dynamically inserted
|
|
7
|
+
* or SPA-swapped carousels need no manual wiring.
|
|
8
|
+
*
|
|
9
|
+
* The element *is* the carousel root — CSS and `base/carousel.js` target
|
|
10
|
+
* `:is(ui-carousel, [data-ui~="carousel"])` directly, and `data-carousel-*`
|
|
11
|
+
* configuration attributes are read off the element (see base/carousel.js for
|
|
12
|
+
* the full attribute reference). No shadow DOM; children are regular markup.
|
|
13
|
+
*
|
|
14
|
+
* Carousels inside a closed `<dialog>` defer initialization until the dialog
|
|
15
|
+
* first opens (a closed dialog is `display: none`, so the viewport cannot be
|
|
16
|
+
* measured).
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* <ui-carousel data-carousel-loop="true">
|
|
20
|
+
* <div data-carousel-slot="viewport">
|
|
21
|
+
* <div data-carousel-slot="container">
|
|
22
|
+
* <div data-carousel-slot="slide">Slide 1</div>
|
|
23
|
+
* <div data-carousel-slot="slide">Slide 2</div>
|
|
24
|
+
* <div data-carousel-slot="slide">Slide 3</div>
|
|
25
|
+
* </div>
|
|
26
|
+
* </div>
|
|
27
|
+
* <button type="button" data-carousel-slot="prev">Prev</button>
|
|
28
|
+
* <button type="button" data-carousel-slot="next">Next</button>
|
|
29
|
+
* </ui-carousel>
|
|
30
|
+
*/
|
|
31
|
+
import { Carousel } from "../../base/carousel.js";
|
|
3
32
|
import { ZazzElement, defineZazzElement } from "../../base/zazz-element.js";
|
|
4
33
|
class UiCarouselElement extends ZazzElement {
|
|
5
34
|
setup(signal) {
|
|
6
35
|
const dialog = this.closest("dialog");
|
|
7
36
|
if (dialog && !dialog.open) {
|
|
8
|
-
// Closed dialogs are display:none —
|
|
37
|
+
// Closed dialogs are display:none — the viewport can't be measured.
|
|
9
38
|
// Initialize on the dialog's open instead (zazz:dialog-open).
|
|
10
39
|
dialog.addEventListener("zazz:dialog-open", () => this.init(), { signal });
|
|
11
40
|
return;
|
|
@@ -13,14 +42,10 @@ class UiCarouselElement extends ZazzElement {
|
|
|
13
42
|
this.init();
|
|
14
43
|
}
|
|
15
44
|
teardown() {
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
this.
|
|
19
|
-
delete this.
|
|
20
|
-
this._emblaApi?.destroy();
|
|
21
|
-
this._emblaApiThumb?.destroy();
|
|
22
|
-
delete this._emblaApi;
|
|
23
|
-
delete this._emblaApiThumb;
|
|
45
|
+
// Aborting removes every listener and observer the engine bound and
|
|
46
|
+
// restores the markup (slide order, the template dot, state tokens).
|
|
47
|
+
this._carouselController?.abort();
|
|
48
|
+
delete this._carouselController;
|
|
24
49
|
// Allow re-initialization if the element is re-inserted.
|
|
25
50
|
this.removeAttribute("data-carousel-init");
|
|
26
51
|
}
|
|
@@ -29,14 +54,14 @@ class UiCarouselElement extends ZazzElement {
|
|
|
29
54
|
* roots and roots inside closed dialogs are skipped by `initRoot`.
|
|
30
55
|
*/
|
|
31
56
|
init() {
|
|
32
|
-
|
|
57
|
+
Carousel.initRoot(this);
|
|
33
58
|
}
|
|
34
59
|
/**
|
|
35
|
-
* @returns The
|
|
36
|
-
*
|
|
60
|
+
* @returns The carousel API (`goTo`, `goToNext`, `goToPrev`, `selectedSnap`,
|
|
61
|
+
* `play`, `stop`), or null before initialization.
|
|
37
62
|
*/
|
|
38
63
|
get api() {
|
|
39
|
-
return this.
|
|
64
|
+
return this._carousel ?? null;
|
|
40
65
|
}
|
|
41
66
|
}
|
|
42
67
|
defineZazzElement("ui-carousel", UiCarouselElement);
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview `<ui-carousel>` — HTML web component for carousels.
|
|
5
5
|
* @description Light-DOM custom element that wraps standard carousel markup
|
|
6
|
-
* and owns the
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
6
|
+
* and owns the carousel's lifecycle: it initializes on connect (via
|
|
7
|
+
* `Carousel.initRoot`) and tears down on disconnect, so dynamically inserted
|
|
8
|
+
* or SPA-swapped carousels need no manual wiring.
|
|
9
9
|
*
|
|
10
|
-
* The element *is* the carousel root — CSS and `
|
|
10
|
+
* The element *is* the carousel root — CSS and `base/carousel.js` target
|
|
11
11
|
* `:is(ui-carousel, [data-ui~="carousel"])` directly, and `data-carousel-*`
|
|
12
|
-
* configuration attributes are read off the element (see
|
|
13
|
-
* full attribute reference). No shadow DOM; children are regular markup.
|
|
12
|
+
* configuration attributes are read off the element (see base/carousel.js for
|
|
13
|
+
* the full attribute reference). No shadow DOM; children are regular markup.
|
|
14
14
|
*
|
|
15
15
|
* Carousels inside a closed `<dialog>` defer initialization until the dialog
|
|
16
|
-
* first opens (a closed dialog is `display: none`, so
|
|
17
|
-
*
|
|
16
|
+
* first opens (a closed dialog is `display: none`, so the viewport cannot be
|
|
17
|
+
* measured).
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* <ui-carousel data-carousel-loop="true">
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* <div data-carousel-slot="container">
|
|
23
23
|
* <div data-carousel-slot="slide">Slide 1</div>
|
|
24
24
|
* <div data-carousel-slot="slide">Slide 2</div>
|
|
25
|
+
* <div data-carousel-slot="slide">Slide 3</div>
|
|
25
26
|
* </div>
|
|
26
27
|
* </div>
|
|
27
28
|
* <button type="button" data-carousel-slot="prev">Prev</button>
|
|
@@ -29,15 +30,15 @@
|
|
|
29
30
|
* </ui-carousel>
|
|
30
31
|
*/
|
|
31
32
|
|
|
32
|
-
import
|
|
33
|
-
import {
|
|
33
|
+
import { Carousel } from "../../base/carousel.ts";
|
|
34
|
+
import type { CarouselApi } from "../../base/carousel-scroll.ts";
|
|
34
35
|
import { ZazzElement, defineZazzElement } from "../../base/zazz-element.ts";
|
|
35
36
|
|
|
36
37
|
class UiCarouselElement extends ZazzElement {
|
|
37
38
|
protected setup(signal: AbortSignal): void {
|
|
38
39
|
const dialog = this.closest("dialog");
|
|
39
40
|
if (dialog && !dialog.open) {
|
|
40
|
-
// Closed dialogs are display:none —
|
|
41
|
+
// Closed dialogs are display:none — the viewport can't be measured.
|
|
41
42
|
// Initialize on the dialog's open instead (zazz:dialog-open).
|
|
42
43
|
dialog.addEventListener("zazz:dialog-open", () => this.init(), { signal });
|
|
43
44
|
return;
|
|
@@ -47,15 +48,10 @@ class UiCarouselElement extends ZazzElement {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
protected teardown(): void {
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
this.
|
|
53
|
-
delete this.
|
|
54
|
-
|
|
55
|
-
this._emblaApi?.destroy();
|
|
56
|
-
this._emblaApiThumb?.destroy();
|
|
57
|
-
delete this._emblaApi;
|
|
58
|
-
delete this._emblaApiThumb;
|
|
51
|
+
// Aborting removes every listener and observer the engine bound and
|
|
52
|
+
// restores the markup (slide order, the template dot, state tokens).
|
|
53
|
+
this._carouselController?.abort();
|
|
54
|
+
delete this._carouselController;
|
|
59
55
|
|
|
60
56
|
// Allow re-initialization if the element is re-inserted.
|
|
61
57
|
this.removeAttribute("data-carousel-init");
|
|
@@ -66,15 +62,15 @@ class UiCarouselElement extends ZazzElement {
|
|
|
66
62
|
* roots and roots inside closed dialogs are skipped by `initRoot`.
|
|
67
63
|
*/
|
|
68
64
|
init(): void {
|
|
69
|
-
|
|
65
|
+
Carousel.initRoot(this);
|
|
70
66
|
}
|
|
71
67
|
|
|
72
68
|
/**
|
|
73
|
-
* @returns The
|
|
74
|
-
*
|
|
69
|
+
* @returns The carousel API (`goTo`, `goToNext`, `goToPrev`, `selectedSnap`,
|
|
70
|
+
* `play`, `stop`), or null before initialization.
|
|
75
71
|
*/
|
|
76
|
-
get api():
|
|
77
|
-
return this.
|
|
72
|
+
get api(): CarouselApi | null {
|
|
73
|
+
return this._carousel ?? null;
|
|
78
74
|
}
|
|
79
75
|
}
|
|
80
76
|
|
|
@@ -20,7 +20,10 @@
|
|
|
20
20
|
* by default) over its preset; a narrow window with a mouse keeps the preset; style
|
|
21
21
|
* queries are Firefox 151+, Chrome 111+, Safari 18+, an older engine keeps the preset
|
|
22
22
|
* @uses env(safe-area-inset-bottom) — the full-height content slot clears the home indicator
|
|
23
|
-
* @
|
|
23
|
+
* @uses translate, scale — in the transition list for consumers that move a dialog with
|
|
24
|
+
* them (drawer.js drags with an inline translate and releases into these
|
|
25
|
+
* transitions; a drawer behind another is scaled back)
|
|
26
|
+
* @consumedby alert-dialog.css, command.css, drawer.css, lightbox.css, mobile-menu.css
|
|
24
27
|
*/
|
|
25
28
|
|
|
26
29
|
@layer variables {
|
|
@@ -49,7 +52,7 @@
|
|
|
49
52
|
--ui-dialog-translate--start: 0, 0, 0;
|
|
50
53
|
--ui-dialog-translate--end: 0, 0, 0;
|
|
51
54
|
--ui-dialog-transition-delay--start: 0ms;
|
|
52
|
-
--ui-dialog-transition-delay--end:
|
|
55
|
+
--ui-dialog-transition-delay--end: 0ms;
|
|
53
56
|
}
|
|
54
57
|
}
|
|
55
58
|
|
|
@@ -86,6 +89,8 @@
|
|
|
86
89
|
transition:
|
|
87
90
|
opacity var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
|
|
88
91
|
transform var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
|
|
92
|
+
translate var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
|
|
93
|
+
scale var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
|
|
89
94
|
padding var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
|
|
90
95
|
block-size var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
|
|
91
96
|
inline-size var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
|
|
@@ -345,25 +350,26 @@
|
|
|
345
350
|
query reads the hook on the dialog's parent, never on the dialog itself: set it on :root
|
|
346
351
|
for the site, or on one dialog's parent for that dialog alone. A viewport query, not a
|
|
347
352
|
container one, because a top-layer dialog is sized by the viewport. Style queries are
|
|
348
|
-
Firefox 151+; an older engine keeps the preset.
|
|
353
|
+
Firefox 151+; an older engine keeps the preset. A drawer (drawer.css) is a bottom sheet
|
|
354
|
+
here instead, so every rule steps aside for it. */
|
|
349
355
|
@media (width < 40rem) and (not (hover: hover)) {
|
|
350
356
|
@container style(--ui-dialog-mobile-size: layout-bleed) {
|
|
351
357
|
/* Not :where(): the viewport decides the height here, over a consumer's own cap
|
|
352
358
|
on the same element (command's list max-block-size loads later at equal
|
|
353
359
|
specificity). Utilities still win through the layer order. */
|
|
354
|
-
[data-ui~="dialog"] [data-dialog-slot~="content"] {
|
|
360
|
+
[data-ui~="dialog"]:where(:not([data-ui~="drawer"])) [data-dialog-slot~="content"] {
|
|
355
361
|
place-content: start stretch;
|
|
356
362
|
block-size: 100%;
|
|
357
363
|
padding-block-end: env(safe-area-inset-bottom, 0px);
|
|
358
364
|
}
|
|
359
365
|
|
|
360
|
-
[data-ui~="dialog"] [data-dialog-slot~="body"] {
|
|
366
|
+
[data-ui~="dialog"]:where(:not([data-ui~="drawer"])) [data-dialog-slot~="body"] {
|
|
361
367
|
block-size: 100%;
|
|
362
368
|
max-block-size: 100%;
|
|
363
369
|
margin-block-end: auto;
|
|
364
370
|
}
|
|
365
371
|
|
|
366
|
-
:where([data-ui~="dialog"]) {
|
|
372
|
+
:where([data-ui~="dialog"]:not([data-ui~="drawer"])) {
|
|
367
373
|
--ui-dialog-border-color: transparent;
|
|
368
374
|
|
|
369
375
|
--_dialog-w: 100dvi;
|
|
@@ -378,7 +384,7 @@
|
|
|
378
384
|
container: none;
|
|
379
385
|
}
|
|
380
386
|
|
|
381
|
-
:where(dialog)::backdrop {
|
|
387
|
+
:where(dialog:not([data-ui~="drawer"]))::backdrop {
|
|
382
388
|
inline-size: 100dvi;
|
|
383
389
|
block-size: 100dvb;
|
|
384
390
|
inset: 0;
|
|
@@ -389,7 +395,7 @@
|
|
|
389
395
|
}
|
|
390
396
|
|
|
391
397
|
@container style(--ui-dialog-mobile-size: layout-full) {
|
|
392
|
-
:where([data-ui~="dialog"]) {
|
|
398
|
+
:where([data-ui~="dialog"]:not([data-ui~="drawer"])) {
|
|
393
399
|
--_dialog-w: calc(100dvi - var(--gutters) * 2);
|
|
394
400
|
}
|
|
395
401
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<ui-drawer-indent style="--p: 6">
|
|
2
|
+
<button data-ui="button" type="button" command="show-modal" commandfor="drawer-indent-1">
|
|
3
|
+
Open drawer
|
|
4
|
+
</button>
|
|
5
|
+
</ui-drawer-indent>
|
|
6
|
+
<dialog id="drawer-indent-1" data-ui="drawer" closedby="any">
|
|
7
|
+
<div data-drawer-slot="handle"></div>
|
|
8
|
+
<div data-drawer-slot="content">
|
|
9
|
+
<header data-drawer-slot="header">
|
|
10
|
+
<h2
|
|
11
|
+
style="
|
|
12
|
+
--font-size: var(--font-size-lg);
|
|
13
|
+
--font-weight: strong;
|
|
14
|
+
--font-family: var(--font-family-heading);
|
|
15
|
+
"
|
|
16
|
+
>
|
|
17
|
+
Share this page
|
|
18
|
+
</h2>
|
|
19
|
+
<p style="--text: var(--color-muted-foreground)">
|
|
20
|
+
The page behind steps back while the drawer is open, and follows as you drag it down.
|
|
21
|
+
</p>
|
|
22
|
+
</header>
|
|
23
|
+
<div data-drawer-slot="body">
|
|
24
|
+
<p>Wrap the page in the indent element once; every drawer on the page uses it.</p>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</dialog>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<button data-ui="button" type="button" command="show-modal" commandfor="drawer-nested-1">
|
|
2
|
+
Open drawer
|
|
3
|
+
</button>
|
|
4
|
+
<dialog id="drawer-nested-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
|
+
Your order
|
|
16
|
+
</h2>
|
|
17
|
+
<p style="--text: var(--color-muted-foreground)">
|
|
18
|
+
Open the second drawer: this one steps back behind it.
|
|
19
|
+
</p>
|
|
20
|
+
</header>
|
|
21
|
+
<div data-drawer-slot="body">
|
|
22
|
+
<p>Two items, arriving Thursday.</p>
|
|
23
|
+
</div>
|
|
24
|
+
<footer data-drawer-slot="footer">
|
|
25
|
+
<button data-ui="button" type="button" commandfor="drawer-nested-1" command="close">
|
|
26
|
+
Close
|
|
27
|
+
</button>
|
|
28
|
+
<button
|
|
29
|
+
data-ui="button"
|
|
30
|
+
data-button-variant="primary"
|
|
31
|
+
type="button"
|
|
32
|
+
command="show-modal"
|
|
33
|
+
commandfor="drawer-nested-2"
|
|
34
|
+
>
|
|
35
|
+
Change address
|
|
36
|
+
</button>
|
|
37
|
+
</footer>
|
|
38
|
+
</div>
|
|
39
|
+
</dialog>
|
|
40
|
+
<dialog id="drawer-nested-2" data-ui="drawer" closedby="any">
|
|
41
|
+
<div data-drawer-slot="handle"></div>
|
|
42
|
+
<div data-drawer-slot="content">
|
|
43
|
+
<header data-drawer-slot="header">
|
|
44
|
+
<h2
|
|
45
|
+
style="
|
|
46
|
+
--font-size: var(--font-size-lg);
|
|
47
|
+
--font-weight: strong;
|
|
48
|
+
--font-family: var(--font-family-heading);
|
|
49
|
+
"
|
|
50
|
+
>
|
|
51
|
+
Delivery address
|
|
52
|
+
</h2>
|
|
53
|
+
<p style="--text: var(--color-muted-foreground)">
|
|
54
|
+
Drag this drawer down and the one behind follows it back.
|
|
55
|
+
</p>
|
|
56
|
+
</header>
|
|
57
|
+
<div data-drawer-slot="body">
|
|
58
|
+
<p>14 Harbour Street, Flat 3.</p>
|
|
59
|
+
</div>
|
|
60
|
+
<footer data-drawer-slot="footer">
|
|
61
|
+
<button
|
|
62
|
+
data-ui="button"
|
|
63
|
+
data-button-variant="primary"
|
|
64
|
+
type="button"
|
|
65
|
+
commandfor="drawer-nested-2"
|
|
66
|
+
command="close"
|
|
67
|
+
>
|
|
68
|
+
Done
|
|
69
|
+
</button>
|
|
70
|
+
</footer>
|
|
71
|
+
</div>
|
|
72
|
+
</dialog>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<button data-ui="button" type="button" command="show-modal" commandfor="drawer-responsive-dialog-1">
|
|
2
|
+
Open dialog
|
|
3
|
+
</button>
|
|
4
|
+
<dialog id="drawer-responsive-dialog-1" data-ui="dialog drawer" closedby="any">
|
|
5
|
+
<div data-drawer-slot="handle"></div>
|
|
6
|
+
<div data-dialog-slot="content">
|
|
7
|
+
<header data-dialog-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
|
+
Confirm your order
|
|
16
|
+
</h2>
|
|
17
|
+
<p style="--text: var(--color-muted-foreground)">
|
|
18
|
+
A dialog on a desktop, and a drawer you can swipe away on a phone.
|
|
19
|
+
</p>
|
|
20
|
+
</header>
|
|
21
|
+
<div data-dialog-slot="body">
|
|
22
|
+
<p>The markup is a dialog with its usual slots, plus the drawer identity and a handle.</p>
|
|
23
|
+
</div>
|
|
24
|
+
<footer data-dialog-slot="footer">
|
|
25
|
+
<button
|
|
26
|
+
data-ui="button"
|
|
27
|
+
type="button"
|
|
28
|
+
commandfor="drawer-responsive-dialog-1"
|
|
29
|
+
command="close"
|
|
30
|
+
>
|
|
31
|
+
Cancel
|
|
32
|
+
</button>
|
|
33
|
+
<button
|
|
34
|
+
data-ui="button"
|
|
35
|
+
data-button-variant="primary"
|
|
36
|
+
type="button"
|
|
37
|
+
commandfor="drawer-responsive-dialog-1"
|
|
38
|
+
command="close"
|
|
39
|
+
>
|
|
40
|
+
Confirm
|
|
41
|
+
</button>
|
|
42
|
+
</footer>
|
|
43
|
+
</div>
|
|
44
|
+
</dialog>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<button data-ui="button" type="button" command="show-modal" commandfor="drawer-snap-1">
|
|
2
|
+
Open drawer
|
|
3
|
+
</button>
|
|
4
|
+
<dialog id="drawer-snap-1" data-ui="drawer" data-drawer-snap="12rem 0.5 1" closedby="any">
|
|
5
|
+
<button type="button" data-drawer-slot="handle" aria-label="Resize drawer"></button>
|
|
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
|
+
Nearby places
|
|
16
|
+
</h2>
|
|
17
|
+
<p style="--text: var(--color-muted-foreground)">
|
|
18
|
+
Drag up for more, or press the handle to step through the sizes.
|
|
19
|
+
</p>
|
|
20
|
+
</header>
|
|
21
|
+
<div data-drawer-slot="body">
|
|
22
|
+
<p>The drawer rests at three heights. Its content scrolls once it is fully open.</p>
|
|
23
|
+
<p>Flick down from the smallest height to close it.</p>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</dialog>
|