@zircon-labs/carousel 0.0.0-stage → 0.1.0-beta.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/LICENSE +201 -0
- package/README.md +229 -2
- package/dist/document-BD0NGsow.js +557 -0
- package/dist/editor.css +125 -0
- package/dist/editor.js +562 -0
- package/dist/index.js +1 -0
- package/dist/styles.css +370 -0
- package/dist/types/Carousel.d.ts +9 -0
- package/dist/types/CarouselControls.d.ts +15 -0
- package/dist/types/CarouselImage.d.ts +8 -0
- package/dist/types/assets.d.ts +34 -0
- package/dist/types/document.d.ts +13 -0
- package/dist/types/editor/CarouselEditor.d.ts +19 -0
- package/dist/types/editor/draft.d.ts +31 -0
- package/dist/types/editor/index.d.ts +2 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/model.d.ts +80 -0
- package/dist/types/slideNavigation.d.ts +13 -0
- package/dist/types/urls.d.ts +2 -0
- package/package.json +42 -4
package/dist/styles.css
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
.zircon-carousel {
|
|
2
|
+
min-inline-size: 0;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.zircon-carousel__list {
|
|
6
|
+
margin: 0;
|
|
7
|
+
padding: 0;
|
|
8
|
+
list-style: none;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.zircon-carousel__list--scrollable {
|
|
12
|
+
display: flex;
|
|
13
|
+
gap: var(--zircon-carousel-gap);
|
|
14
|
+
overflow-x: auto;
|
|
15
|
+
scroll-snap-type: x mandatory;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.zircon-carousel__list--scrollable:focus-visible {
|
|
19
|
+
outline: 2px solid currentColor;
|
|
20
|
+
outline-offset: 2px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.zircon-carousel__slide {
|
|
24
|
+
flex: 0 0 100%;
|
|
25
|
+
min-inline-size: 0;
|
|
26
|
+
scroll-snap-align: start;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.zircon-carousel__media {
|
|
30
|
+
position: relative;
|
|
31
|
+
display: block;
|
|
32
|
+
aspect-ratio: var(--zircon-carousel-ratio);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.zircon-carousel__media img {
|
|
36
|
+
position: absolute;
|
|
37
|
+
inset: 0;
|
|
38
|
+
display: block;
|
|
39
|
+
inline-size: 100%;
|
|
40
|
+
block-size: 100%;
|
|
41
|
+
object-fit: var(--zircon-carousel-fit);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.zircon-carousel__media:focus-visible {
|
|
45
|
+
outline: 2px solid white;
|
|
46
|
+
outline-offset: -4px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.zircon-carousel__media:focus-visible::after {
|
|
50
|
+
position: absolute;
|
|
51
|
+
inset: 4px;
|
|
52
|
+
border: 2px solid black;
|
|
53
|
+
pointer-events: none;
|
|
54
|
+
content: '';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.zircon-carousel__controls {
|
|
58
|
+
display: grid;
|
|
59
|
+
grid-template-columns: auto minmax(0, 1fr) auto;
|
|
60
|
+
align-items: start;
|
|
61
|
+
gap: 0.25rem;
|
|
62
|
+
padding: 0.25rem;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.zircon-carousel__indicators {
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-wrap: wrap;
|
|
68
|
+
justify-content: center;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.zircon-carousel__arrow,
|
|
72
|
+
.zircon-carousel__indicator {
|
|
73
|
+
display: inline-grid;
|
|
74
|
+
place-items: center;
|
|
75
|
+
inline-size: 44px;
|
|
76
|
+
block-size: 44px;
|
|
77
|
+
padding: 0;
|
|
78
|
+
border: 1px solid transparent;
|
|
79
|
+
border-radius: 0.25rem;
|
|
80
|
+
background: Canvas;
|
|
81
|
+
color: CanvasText;
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.zircon-carousel__arrow {
|
|
86
|
+
border-color: currentColor;
|
|
87
|
+
font: inherit;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.zircon-carousel__arrow[aria-disabled='true'] {
|
|
91
|
+
color: GrayText;
|
|
92
|
+
cursor: default;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.zircon-carousel__arrow:dir(rtl) span {
|
|
96
|
+
transform: scaleX(-1);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.zircon-carousel__dot {
|
|
100
|
+
box-sizing: border-box;
|
|
101
|
+
inline-size: 10px;
|
|
102
|
+
block-size: 10px;
|
|
103
|
+
border: 2px solid currentColor;
|
|
104
|
+
border-radius: 50%;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.zircon-carousel__indicator[aria-current='true'] .zircon-carousel__dot {
|
|
108
|
+
border-radius: 1px;
|
|
109
|
+
background: currentColor;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.zircon-carousel__arrow:focus-visible,
|
|
113
|
+
.zircon-carousel__indicator:focus-visible {
|
|
114
|
+
outline: 2px solid currentColor;
|
|
115
|
+
outline-offset: -4px;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.zircon-carousel__viewport {
|
|
119
|
+
position: relative;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.zircon-carousel__list--fade {
|
|
123
|
+
display: grid;
|
|
124
|
+
isolation: isolate;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.zircon-carousel__list--fade .zircon-carousel__slide {
|
|
128
|
+
grid-area: 1 / 1;
|
|
129
|
+
opacity: 0;
|
|
130
|
+
transition: opacity 240ms ease;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.zircon-carousel__list--fade .zircon-carousel__slide[data-active-slide] {
|
|
134
|
+
z-index: 1;
|
|
135
|
+
opacity: 1;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.zircon-carousel__list--fade .zircon-carousel__slide[inert] {
|
|
139
|
+
pointer-events: none;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.zircon-carousel__controls[data-variant='advanced'] {
|
|
143
|
+
align-items: center;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.zircon-carousel__controls[data-variant='advanced']
|
|
147
|
+
.zircon-carousel__indicators {
|
|
148
|
+
grid-column: 1 / -1;
|
|
149
|
+
gap: 0.25rem;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.zircon-carousel__controls[data-variant='basic'] {
|
|
153
|
+
grid-template-columns: auto auto;
|
|
154
|
+
justify-content: center;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.zircon-carousel__controls[data-variant='advanced']
|
|
158
|
+
.zircon-carousel__indicator {
|
|
159
|
+
inline-size: 64px;
|
|
160
|
+
padding: 3px;
|
|
161
|
+
border: 2px solid transparent;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.zircon-carousel__controls[data-variant='advanced']
|
|
165
|
+
.zircon-carousel__indicator[aria-current='true'] {
|
|
166
|
+
border-color: currentColor;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.zircon-carousel__indicator img {
|
|
170
|
+
display: block;
|
|
171
|
+
inline-size: 100%;
|
|
172
|
+
block-size: 32px;
|
|
173
|
+
object-fit: cover;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.zircon-carousel__counter {
|
|
177
|
+
justify-self: center;
|
|
178
|
+
font-variant-numeric: tabular-nums;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.zircon-carousel__sr-only {
|
|
182
|
+
position: absolute;
|
|
183
|
+
inline-size: 1px;
|
|
184
|
+
block-size: 1px;
|
|
185
|
+
padding: 0;
|
|
186
|
+
overflow: hidden;
|
|
187
|
+
clip-path: inset(50%);
|
|
188
|
+
white-space: nowrap;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.zircon-carousel__effects {
|
|
192
|
+
position: absolute;
|
|
193
|
+
z-index: 2;
|
|
194
|
+
inset-block-start: 0;
|
|
195
|
+
inset-inline: 0;
|
|
196
|
+
aspect-ratio: var(--zircon-carousel-ratio);
|
|
197
|
+
overflow: hidden;
|
|
198
|
+
pointer-events: none;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.zircon-carousel__effects[data-moving] {
|
|
202
|
+
visibility: hidden;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.zircon-carousel__snake,
|
|
206
|
+
.zircon-carousel__sparkle {
|
|
207
|
+
position: absolute;
|
|
208
|
+
inset: 0;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
@property --zircon-carousel-angle {
|
|
212
|
+
syntax: '<angle>';
|
|
213
|
+
initial-value: 0deg;
|
|
214
|
+
inherits: false;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.zircon-carousel__snake {
|
|
218
|
+
border: 2px solid #bdeaff;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.zircon-carousel__snake::before {
|
|
222
|
+
position: absolute;
|
|
223
|
+
inset: -2px;
|
|
224
|
+
padding: 2px;
|
|
225
|
+
background: conic-gradient(
|
|
226
|
+
from var(--zircon-carousel-angle),
|
|
227
|
+
transparent 0 74%,
|
|
228
|
+
#58b5ef 84%,
|
|
229
|
+
white 92%,
|
|
230
|
+
transparent 100%
|
|
231
|
+
);
|
|
232
|
+
mask:
|
|
233
|
+
linear-gradient(black 0 0) content-box,
|
|
234
|
+
linear-gradient(black 0 0);
|
|
235
|
+
mask-composite: exclude;
|
|
236
|
+
animation: zircon-carousel-snake 700ms ease-out both;
|
|
237
|
+
content: '';
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
@keyframes zircon-carousel-snake {
|
|
241
|
+
from {
|
|
242
|
+
--zircon-carousel-angle: 0deg;
|
|
243
|
+
}
|
|
244
|
+
80% {
|
|
245
|
+
opacity: 1;
|
|
246
|
+
}
|
|
247
|
+
to {
|
|
248
|
+
--zircon-carousel-angle: 1turn;
|
|
249
|
+
opacity: 0;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.zircon-carousel__sparkle {
|
|
254
|
+
background: linear-gradient(
|
|
255
|
+
112deg,
|
|
256
|
+
transparent 30%,
|
|
257
|
+
#fff6 48%,
|
|
258
|
+
transparent 60%
|
|
259
|
+
);
|
|
260
|
+
animation: zircon-carousel-sparkle 650ms ease-out both;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
@keyframes zircon-carousel-sparkle {
|
|
264
|
+
from {
|
|
265
|
+
opacity: 0;
|
|
266
|
+
transform: translateX(-50%);
|
|
267
|
+
}
|
|
268
|
+
30% {
|
|
269
|
+
opacity: 0.65;
|
|
270
|
+
}
|
|
271
|
+
to {
|
|
272
|
+
opacity: 0;
|
|
273
|
+
transform: translateX(50%);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
@property --zircon-carousel-line-progress {
|
|
278
|
+
syntax: '<number>';
|
|
279
|
+
initial-value: 1;
|
|
280
|
+
inherits: true;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/* The clock stays on the region so moving a keyed indicator cannot restart it. */
|
|
284
|
+
.zircon-carousel[data-line-pulse='false'] {
|
|
285
|
+
animation: zircon-carousel-line-start 340ms ease-out both;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.zircon-carousel[data-line-pulse='true'] {
|
|
289
|
+
animation: zircon-carousel-line-next 340ms ease-out both;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
@keyframes zircon-carousel-line-start {
|
|
293
|
+
from {
|
|
294
|
+
--zircon-carousel-line-progress: 0;
|
|
295
|
+
}
|
|
296
|
+
to {
|
|
297
|
+
--zircon-carousel-line-progress: 1;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
@keyframes zircon-carousel-line-next {
|
|
302
|
+
from {
|
|
303
|
+
--zircon-carousel-line-progress: 0;
|
|
304
|
+
}
|
|
305
|
+
to {
|
|
306
|
+
--zircon-carousel-line-progress: 1;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.zircon-carousel__indicator {
|
|
311
|
+
position: relative;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.zircon-carousel__line {
|
|
315
|
+
position: absolute;
|
|
316
|
+
inset-inline: 0.35rem;
|
|
317
|
+
inset-block-end: 3px;
|
|
318
|
+
block-size: 2px;
|
|
319
|
+
background: currentColor;
|
|
320
|
+
pointer-events: none;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.zircon-carousel__line[data-animate] {
|
|
324
|
+
transform: scaleX(var(--zircon-carousel-line-progress, 1));
|
|
325
|
+
transform-origin: left center;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.zircon-carousel__line:dir(rtl) {
|
|
329
|
+
transform-origin: right center;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
@media (prefers-reduced-motion: reduce) {
|
|
333
|
+
.zircon-carousel__list--fade .zircon-carousel__slide {
|
|
334
|
+
transition: none;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.zircon-carousel[data-line-pulse],
|
|
338
|
+
.zircon-carousel__snake::before,
|
|
339
|
+
.zircon-carousel__sparkle {
|
|
340
|
+
animation: none;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.zircon-carousel__snake::before {
|
|
344
|
+
display: none;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.zircon-carousel__sparkle {
|
|
348
|
+
opacity: 0.35;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.zircon-carousel__placeholder {
|
|
353
|
+
display: grid;
|
|
354
|
+
place-items: center;
|
|
355
|
+
inline-size: 100%;
|
|
356
|
+
block-size: 100%;
|
|
357
|
+
background: Canvas;
|
|
358
|
+
color: CanvasText;
|
|
359
|
+
overflow: hidden;
|
|
360
|
+
text-align: center;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.zircon-carousel__media > .zircon-carousel__placeholder {
|
|
364
|
+
position: absolute;
|
|
365
|
+
inset: 0;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.zircon-carousel__indicator .zircon-carousel__placeholder {
|
|
369
|
+
font-size: 0.6rem;
|
|
370
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GetAssetState } from './assets.js';
|
|
2
|
+
import { type CarouselConfig } from './model.js';
|
|
3
|
+
export type CarouselProps = {
|
|
4
|
+
config: CarouselConfig;
|
|
5
|
+
ariaLabel: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
getAssetState?: GetAssetState;
|
|
8
|
+
};
|
|
9
|
+
export declare function Carousel(props: CarouselProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CarouselSlide, CarouselVariant, ImageSource } from './model.js';
|
|
2
|
+
import type { AssetState } from './assets.js';
|
|
3
|
+
type ControlsProps = {
|
|
4
|
+
variant: CarouselVariant;
|
|
5
|
+
slides: readonly CarouselSlide<ImageSource>[];
|
|
6
|
+
images: readonly AssetState[];
|
|
7
|
+
activeIndex: number;
|
|
8
|
+
destinationIndex: number;
|
|
9
|
+
indicatorLine: boolean;
|
|
10
|
+
settledId?: string;
|
|
11
|
+
move: (step: -1 | 1) => void;
|
|
12
|
+
select: (id: string) => void;
|
|
13
|
+
};
|
|
14
|
+
export declare function CarouselControls({ variant, slides, images, activeIndex, destinationIndex, indicatorLine, settledId, move, select, }: ControlsProps): import("react").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AssetState, GetAssetState } from './assets.js';
|
|
2
|
+
import type { ImageSource } from './model.js';
|
|
3
|
+
export declare function imageState(source: ImageSource, getAssetState?: GetAssetState): AssetState;
|
|
4
|
+
export declare function CarouselImage({ state, alt, thumbnail, }: {
|
|
5
|
+
state: AssetState;
|
|
6
|
+
alt: string;
|
|
7
|
+
thumbnail?: boolean;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CarouselConfig, ImageSource, RenderableImage } from './model.js';
|
|
2
|
+
export type AssetState = {
|
|
3
|
+
status: 'loading';
|
|
4
|
+
} | {
|
|
5
|
+
status: 'ready';
|
|
6
|
+
image: RenderableImage;
|
|
7
|
+
} | {
|
|
8
|
+
status: 'missing';
|
|
9
|
+
} | {
|
|
10
|
+
status: 'error';
|
|
11
|
+
message?: string;
|
|
12
|
+
};
|
|
13
|
+
export type GetAssetState = (id: string) => AssetState | undefined;
|
|
14
|
+
export type Operation = {
|
|
15
|
+
signal: AbortSignal;
|
|
16
|
+
};
|
|
17
|
+
export type ResolvedAsset = {
|
|
18
|
+
image: RenderableImage;
|
|
19
|
+
expiresAt?: number;
|
|
20
|
+
release?: () => void;
|
|
21
|
+
};
|
|
22
|
+
export type ImageAdapter = {
|
|
23
|
+
uploadImage(file: File, options: Operation): Promise<ImageSource>;
|
|
24
|
+
resolveAsset(id: string, options: Operation): Promise<ResolvedAsset | null>;
|
|
25
|
+
};
|
|
26
|
+
export type ConfigStore = {
|
|
27
|
+
load(options: Operation): Promise<{
|
|
28
|
+
found: false;
|
|
29
|
+
} | {
|
|
30
|
+
found: true;
|
|
31
|
+
document: unknown;
|
|
32
|
+
}>;
|
|
33
|
+
save(snapshot: CarouselConfig, options: Operation): Promise<void>;
|
|
34
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type CarouselConfig, type ImageSource } from './model.js';
|
|
2
|
+
export declare function validSrcSet(value: string): boolean;
|
|
3
|
+
export declare function validImageSource(value: unknown): value is ImageSource;
|
|
4
|
+
export declare function serializeCarouselConfig(config: CarouselConfig): string;
|
|
5
|
+
type ParseResult = {
|
|
6
|
+
ok: true;
|
|
7
|
+
value: CarouselConfig;
|
|
8
|
+
} | {
|
|
9
|
+
ok: false;
|
|
10
|
+
issue: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function parseCarouselConfig(input: unknown): ParseResult;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { GetAssetState, ImageAdapter } from '../assets.js';
|
|
2
|
+
import { type CarouselConfig } from '../model.js';
|
|
3
|
+
export type CarouselEditorProps = {
|
|
4
|
+
value: CarouselConfig;
|
|
5
|
+
/** Async hosts must discard superseded results before updating `value`. */
|
|
6
|
+
onChange: (next: CarouselConfig) => void;
|
|
7
|
+
previewLabel: string;
|
|
8
|
+
getAssetState?: GetAssetState;
|
|
9
|
+
uploadImage?: ImageAdapter['uploadImage'];
|
|
10
|
+
onRetryAsset?: (id: string) => void;
|
|
11
|
+
assetOptions?: readonly {
|
|
12
|
+
id: string;
|
|
13
|
+
label: string;
|
|
14
|
+
}[];
|
|
15
|
+
onDraftStatusChange?: (status: {
|
|
16
|
+
canExport: boolean;
|
|
17
|
+
}) => void;
|
|
18
|
+
};
|
|
19
|
+
export declare function CarouselEditor({ value, onChange, previewLabel, onDraftStatusChange, getAssetState, uploadImage, onRetryAsset, assetOptions, }: CarouselEditorProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type CarouselConfig, type CarouselEffects, type CarouselTransition, type CarouselVariant } from '../model.js';
|
|
2
|
+
export { serializeCarouselConfig } from '../document.js';
|
|
3
|
+
export type DraftSlide = {
|
|
4
|
+
id: string;
|
|
5
|
+
assetId?: string;
|
|
6
|
+
src: string;
|
|
7
|
+
alt: string;
|
|
8
|
+
href: string;
|
|
9
|
+
srcSet?: string;
|
|
10
|
+
sizes?: string;
|
|
11
|
+
};
|
|
12
|
+
export type EditorDraft = {
|
|
13
|
+
schemaVersion: 1 | 2;
|
|
14
|
+
slides: DraftSlide[];
|
|
15
|
+
variant: CarouselVariant;
|
|
16
|
+
transition: CarouselTransition;
|
|
17
|
+
effects: CarouselEffects;
|
|
18
|
+
aspectRatio: string;
|
|
19
|
+
gapPx: string;
|
|
20
|
+
imageFit: 'cover' | 'contain';
|
|
21
|
+
};
|
|
22
|
+
type SlideErrors = Partial<Record<'src' | 'alt' | 'href', string>>;
|
|
23
|
+
export type DraftValidation = {
|
|
24
|
+
config?: CarouselConfig;
|
|
25
|
+
slides: Map<string, SlideErrors>;
|
|
26
|
+
aspectRatio?: string;
|
|
27
|
+
gapPx?: string;
|
|
28
|
+
firstError?: string;
|
|
29
|
+
};
|
|
30
|
+
export declare function createDraft(config: CarouselConfig): EditorDraft;
|
|
31
|
+
export declare function validateDraft(draft: EditorDraft): DraftValidation;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { Carousel, type CarouselProps } from './Carousel.js';
|
|
2
|
+
export { carouselDefaults, type BasicCarouselConfig, type CarouselConfig, type CarouselEffects, type CarouselLayout, type CarouselSlide, type CarouselTransition, type CarouselVariant, type ImageSource, type AssetImageSource, type UrlImageSource, type RenderableImage, type SlideCarouselConfig, } from './model.js';
|
|
3
|
+
export { parseCarouselConfig } from './document.js';
|
|
4
|
+
export type { AssetState, GetAssetState, ImageAdapter, ConfigStore, Operation, ResolvedAsset, } from './assets.js';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export type CarouselVariant = 'basic' | 'standard' | 'advanced';
|
|
2
|
+
export type CarouselTransition = 'slide' | 'fade';
|
|
3
|
+
export type CarouselEffects = {
|
|
4
|
+
snakeBorder: boolean;
|
|
5
|
+
sparkle: boolean;
|
|
6
|
+
indicatorLine: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type RenderableImage = {
|
|
9
|
+
src: string;
|
|
10
|
+
srcSet?: string;
|
|
11
|
+
sizes?: string;
|
|
12
|
+
};
|
|
13
|
+
export type UrlImageSource = {
|
|
14
|
+
kind: 'url';
|
|
15
|
+
} & RenderableImage;
|
|
16
|
+
export type AssetImageSource = {
|
|
17
|
+
kind: 'asset';
|
|
18
|
+
id: string;
|
|
19
|
+
};
|
|
20
|
+
export type ImageSource = UrlImageSource | AssetImageSource;
|
|
21
|
+
export type CarouselSlide<Source extends ImageSource = UrlImageSource> = {
|
|
22
|
+
id: string;
|
|
23
|
+
image: {
|
|
24
|
+
source: Source;
|
|
25
|
+
alt: string;
|
|
26
|
+
};
|
|
27
|
+
href?: string;
|
|
28
|
+
};
|
|
29
|
+
export type CarouselLayout = {
|
|
30
|
+
aspectRatio?: number;
|
|
31
|
+
gapPx?: number;
|
|
32
|
+
imageFit?: 'cover' | 'contain';
|
|
33
|
+
};
|
|
34
|
+
type CarouselPresentation = {
|
|
35
|
+
variant?: CarouselVariant;
|
|
36
|
+
transition?: CarouselTransition;
|
|
37
|
+
effects?: Partial<CarouselEffects>;
|
|
38
|
+
layout?: CarouselLayout;
|
|
39
|
+
};
|
|
40
|
+
export type CarouselConfig = CarouselPresentation & ({
|
|
41
|
+
schemaVersion: 1;
|
|
42
|
+
slides: readonly CarouselSlide[];
|
|
43
|
+
} | {
|
|
44
|
+
schemaVersion: 2;
|
|
45
|
+
slides: readonly CarouselSlide<ImageSource>[];
|
|
46
|
+
});
|
|
47
|
+
export type SlideCarouselConfig = Omit<Extract<CarouselConfig, {
|
|
48
|
+
schemaVersion: 1;
|
|
49
|
+
}>, 'variant' | 'transition' | 'effects'> & {
|
|
50
|
+
variant?: 'basic' | 'standard';
|
|
51
|
+
transition?: 'slide';
|
|
52
|
+
effects?: Partial<Record<keyof CarouselEffects, false>>;
|
|
53
|
+
};
|
|
54
|
+
export type BasicCarouselConfig = SlideCarouselConfig & {
|
|
55
|
+
variant?: 'basic';
|
|
56
|
+
};
|
|
57
|
+
export declare const carouselDefaults: {
|
|
58
|
+
readonly variant: "basic";
|
|
59
|
+
readonly transition: "slide";
|
|
60
|
+
readonly effects: {
|
|
61
|
+
readonly snakeBorder: false;
|
|
62
|
+
readonly sparkle: false;
|
|
63
|
+
readonly indicatorLine: false;
|
|
64
|
+
};
|
|
65
|
+
readonly layout: {
|
|
66
|
+
readonly aspectRatio: number;
|
|
67
|
+
readonly gapPx: 16;
|
|
68
|
+
readonly imageFit: "cover";
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
export declare function resolveLayout(layout?: CarouselLayout): Required<CarouselLayout>;
|
|
72
|
+
export declare function resolveEffects(effects?: Partial<CarouselEffects>): CarouselEffects;
|
|
73
|
+
export declare function replacementSlideId(previousIds: readonly string[], nextIds: readonly string[], activeId?: string): string | undefined;
|
|
74
|
+
export declare function resolvePresentation(config: CarouselConfig): {
|
|
75
|
+
variant: CarouselVariant;
|
|
76
|
+
transition: CarouselTransition;
|
|
77
|
+
effects: CarouselEffects;
|
|
78
|
+
layout: Required<CarouselLayout>;
|
|
79
|
+
};
|
|
80
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type SlideSelection = {
|
|
2
|
+
activeId?: string;
|
|
3
|
+
pendingId?: string;
|
|
4
|
+
settledId?: string;
|
|
5
|
+
moving: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function readVisibleSlide(list: HTMLUListElement, ids: readonly string[], previousId?: string): string | undefined;
|
|
8
|
+
export declare function alignSlide(list: HTMLUListElement, index: number, behavior: ScrollBehavior): void;
|
|
9
|
+
export declare function trackSlides(list: HTMLUListElement, ids: readonly string[], initialId: string | undefined, onSelection: (selection: SlideSelection) => void): {
|
|
10
|
+
move: (step: -1 | 1) => void;
|
|
11
|
+
select: (id: string) => void;
|
|
12
|
+
dispose: () => void;
|
|
13
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zircon-labs/carousel",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
|
+
"description": "Accessible React carousel with a controlled editor.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/GeorgeValle/zircon-carousel.git",
|
|
10
|
+
"directory": "packages/carousel"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/types/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./editor": {
|
|
21
|
+
"types": "./dist/types/editor/index.d.ts",
|
|
22
|
+
"import": "./dist/editor.js"
|
|
23
|
+
},
|
|
24
|
+
"./styles.css": "./dist/styles.css",
|
|
25
|
+
"./editor.css": "./dist/editor.css"
|
|
26
|
+
},
|
|
27
|
+
"sideEffects": [
|
|
28
|
+
"./dist/styles.css",
|
|
29
|
+
"./dist/editor.css"
|
|
30
|
+
],
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": "^19.0.0",
|
|
33
|
+
"@zircon-labs/primitives": "0.1.0-beta.4"
|
|
34
|
+
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"@zircon-labs/primitives": {
|
|
37
|
+
"optional": true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public",
|
|
42
|
+
"tag": "beta"
|
|
43
|
+
}
|
|
44
|
+
}
|