@reliability-design/web 1.0.3 → 1.1.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/dist/components/rel-accordion/README.md +132 -0
- package/dist/components/rel-accordion/rel-accordion.ts +47 -16
- package/dist/components/rel-alert/README.md +141 -0
- package/dist/components/rel-alert/rel-alert.ts +101 -20
- package/dist/components/rel-avatar/README.md +119 -0
- package/dist/components/rel-avatar/rel-avatar.ts +3 -2
- package/dist/components/rel-badge/README.md +86 -0
- package/dist/components/rel-badge/rel-badge.ts +11 -7
- package/dist/components/rel-breadcrumb/README.md +102 -0
- package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +12 -6
- package/dist/components/rel-button/README.md +130 -0
- package/dist/components/rel-button/rel-button.ts +64 -8
- package/dist/components/rel-calendar/README.md +109 -0
- package/dist/components/rel-calendar/index.ts +1 -0
- package/dist/components/rel-calendar/rel-calendar.ts +467 -0
- package/dist/components/rel-card/README.md +94 -0
- package/dist/components/rel-card/rel-card.ts +12 -3
- package/dist/components/rel-cardmedia/README.md +127 -0
- package/dist/components/rel-cardmedia/rel-cardmedia.ts +14 -4
- package/dist/components/rel-carousel/README.md +166 -0
- package/dist/components/rel-carousel/index.ts +1 -0
- package/dist/components/rel-carousel/rel-carousel.ts +468 -0
- package/dist/components/rel-chart/README.md +286 -0
- package/dist/components/rel-chart/index.ts +1 -0
- package/dist/components/rel-chart/rel-chart.ts +736 -0
- package/dist/components/rel-checkbox/README.md +77 -0
- package/dist/components/rel-checkbox/rel-checkbox.ts +51 -12
- package/dist/components/rel-chip/README.md +114 -0
- package/dist/components/rel-chip/rel-chip.ts +83 -9
- package/dist/components/rel-container/README.md +99 -0
- package/dist/components/rel-date-picker/README.md +253 -0
- package/dist/components/rel-date-picker/index.ts +1 -0
- package/dist/components/rel-date-picker/rel-date-picker.ts +916 -0
- package/dist/components/rel-divider/README.md +100 -0
- package/dist/components/rel-divider/rel-divider.ts +9 -0
- package/dist/components/rel-drawer/README.md +200 -0
- package/dist/components/rel-drawer/index.ts +1 -0
- package/dist/components/rel-drawer/rel-drawer-footer.ts +29 -0
- package/dist/components/rel-drawer/rel-drawer.ts +612 -0
- package/dist/components/rel-kbd/README.md +151 -0
- package/dist/components/rel-kbd/rel-kbd.ts +118 -0
- package/dist/components/rel-layout/README.md +88 -0
- package/dist/components/rel-menu/README.md +151 -0
- package/dist/components/rel-menu/rel-menu.ts +64 -24
- package/dist/components/rel-menubar/README.md +329 -0
- package/dist/components/rel-menubar/index.ts +2 -0
- package/dist/components/rel-menubar/rel-menubar-menu.ts +16 -0
- package/dist/components/rel-menubar/rel-menubar.ts +605 -0
- package/dist/components/rel-nav-menu/README.md +289 -0
- package/dist/components/rel-nav-menu/index.ts +3 -0
- package/dist/components/rel-nav-menu/rel-nav-menu-item.ts +240 -0
- package/dist/components/rel-nav-menu/rel-nav-menu-panel.ts +53 -0
- package/dist/components/rel-nav-menu/rel-nav-menu.ts +227 -0
- package/dist/components/rel-navbar/README.md +126 -0
- package/dist/components/rel-navbar/rel-navbar.ts +104 -0
- package/dist/components/rel-otp/README.md +440 -0
- package/dist/components/rel-otp/index.ts +1 -0
- package/dist/components/rel-otp/rel-otp.ts +504 -0
- package/dist/components/rel-pagination/README.md +410 -0
- package/dist/components/rel-pagination/index.ts +1 -0
- package/dist/components/rel-pagination/rel-pagination.ts +381 -0
- package/dist/components/rel-popover/README.md +568 -0
- package/dist/components/rel-popover/index.ts +2 -0
- package/dist/components/rel-popover/rel-popover-content.ts +55 -0
- package/dist/components/rel-popover/rel-popover.ts +330 -0
- package/dist/components/rel-progress/README.md +110 -0
- package/dist/components/rel-progress/rel-progress.ts +32 -5
- package/dist/components/rel-radio/README.md +120 -0
- package/dist/components/rel-radio/rel-radio.ts +31 -6
- package/dist/components/rel-resizable/README.md +140 -0
- package/dist/components/rel-resizable/index.ts +3 -0
- package/dist/components/rel-resizable/rel-resizable-group.ts +374 -0
- package/dist/components/rel-resizable/rel-resizable-handle.ts +145 -0
- package/dist/components/rel-resizable/rel-resizable-panel.ts +47 -0
- package/dist/components/rel-segmented-button/README.md +141 -0
- package/dist/components/rel-segmented-button/rel-segmented-button.ts +18 -13
- package/dist/components/rel-select/README.md +107 -0
- package/dist/components/rel-select/rel-select.ts +28 -14
- package/dist/components/rel-sheet/README.md +224 -0
- package/dist/components/rel-sheet/rel-sheet.ts +684 -0
- package/dist/components/rel-sidebar/README.md +209 -0
- package/dist/components/rel-sidebar/rel-sidebar.ts +1166 -0
- package/dist/components/rel-slider/README.md +135 -0
- package/dist/components/rel-slider/rel-slider.ts +44 -9
- package/dist/components/rel-snackbar/README.md +134 -0
- package/dist/components/rel-snackbar/rel-snackbar.ts +109 -14
- package/dist/components/rel-stepper/README.md +160 -0
- package/dist/components/rel-stepper/rel-stepper.ts +38 -27
- package/dist/components/rel-switch/README.md +102 -0
- package/dist/components/rel-switch/rel-switch.ts +34 -12
- package/dist/components/rel-tab/README.md +163 -0
- package/dist/components/rel-tab/rel-tab.ts +79 -23
- package/dist/components/rel-table/README.md +178 -0
- package/dist/components/rel-table/rel-table-body.ts +21 -0
- package/dist/components/rel-table/rel-table-caption.ts +27 -0
- package/dist/components/rel-table/rel-table-cell.ts +42 -0
- package/dist/components/rel-table/rel-table-footer.ts +23 -0
- package/dist/components/rel-table/rel-table-head.ts +45 -0
- package/dist/components/rel-table/rel-table-header.ts +21 -0
- package/dist/components/rel-table/rel-table-row.ts +36 -0
- package/dist/components/rel-table/rel-table.ts +53 -0
- package/dist/components/rel-textfield/README.md +90 -0
- package/dist/components/rel-textfield/rel-textfield.ts +55 -39
- package/dist/components/rel-toast/README.md +148 -0
- package/dist/components/rel-toast/rel-toast.ts +63 -24
- package/dist/components/rel-tooltip/README.md +103 -0
- package/dist/components/rel-tooltip/rel-tooltip.ts +123 -80
- package/dist/components/rel-topbar/rel-topbar-actions.ts +23 -0
- package/dist/components/rel-topbar/rel-topbar-brand.ts +46 -0
- package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +33 -0
- package/dist/components/rel-topbar/rel-topbar-dropdown.ts +28 -0
- package/dist/components/rel-topbar/rel-topbar-item.ts +315 -0
- package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +23 -0
- package/dist/components/rel-topbar/rel-topbar-profile.ts +248 -0
- package/dist/components/rel-topbar/rel-topbar-utilities.ts +23 -0
- package/dist/components/rel-topbar/rel-topbar.ts +329 -0
- package/dist/index.d.mts +831 -7
- package/dist/index.d.ts +831 -7
- package/dist/index.js +9500 -1564
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9240 -1344
- package/dist/index.mjs.map +1 -1
- package/dist/styles/vars.css +187 -25
- package/dist/vars-TBB4BMSD.css +346 -0
- package/package.json +2 -1
- package/dist/vars-6ZIUPIU4.css +0 -184
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
import { LitElement, html, css, nothing } from "lit";
|
|
2
|
+
import { customElement, property, state, query } from "lit/decorators.js";
|
|
3
|
+
|
|
4
|
+
@customElement("rel-carousel")
|
|
5
|
+
export class RelCarousel extends LitElement {
|
|
6
|
+
@property({ type: Number, reflect: true }) value = 0;
|
|
7
|
+
@property({ type: Boolean }) loop = false;
|
|
8
|
+
@property({ type: Boolean }) autoplay = false;
|
|
9
|
+
@property({ type: Number }) interval = 5000;
|
|
10
|
+
@property({ type: Boolean, attribute: "pause-on-hover" }) pauseOnHover = true;
|
|
11
|
+
@property({ type: Boolean, attribute: "show-buttons" }) showButtons = true;
|
|
12
|
+
@property({ type: Boolean, attribute: "show-dots" }) showDots = true;
|
|
13
|
+
@property({ type: String }) orientation: "horizontal" | "vertical" = "horizontal";
|
|
14
|
+
@property({ type: String }) label: string = "Carousel";
|
|
15
|
+
@property({ type: Number }) gap?: number;
|
|
16
|
+
@property({ type: Boolean, reflect: true }) disabled = false;
|
|
17
|
+
|
|
18
|
+
@state() private slideCount = 0;
|
|
19
|
+
@state() private isDragging = false;
|
|
20
|
+
@state() private dragStartX = 0;
|
|
21
|
+
@state() private currentTranslate = 0;
|
|
22
|
+
@state() private prevTranslate = 0;
|
|
23
|
+
|
|
24
|
+
@query(".viewport") private viewport?: HTMLElement;
|
|
25
|
+
@query(".track") private track?: HTMLElement;
|
|
26
|
+
@query("slot") private slotElement?: HTMLSlotElement;
|
|
27
|
+
|
|
28
|
+
private autoplayTimer?: number;
|
|
29
|
+
private animationId?: number;
|
|
30
|
+
private prefersReducedMotion = false;
|
|
31
|
+
|
|
32
|
+
static styles = css`
|
|
33
|
+
:host {
|
|
34
|
+
display: block;
|
|
35
|
+
font-family: var(--rel-fontFamilies-primary);
|
|
36
|
+
position: relative;
|
|
37
|
+
user-select: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
:host([disabled]) {
|
|
41
|
+
opacity: 0.6;
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.viewport {
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
position: relative;
|
|
48
|
+
width: 100%;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.track {
|
|
52
|
+
display: flex;
|
|
53
|
+
transition: transform 0.3s ease-out;
|
|
54
|
+
will-change: transform;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.track.dragging {
|
|
58
|
+
transition: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.track.no-transition {
|
|
62
|
+
transition: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
::slotted(*) {
|
|
66
|
+
flex: 0 0 100%;
|
|
67
|
+
min-width: 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* Navigation buttons */
|
|
71
|
+
.nav-button {
|
|
72
|
+
position: absolute;
|
|
73
|
+
top: 50%;
|
|
74
|
+
transform: translateY(-50%);
|
|
75
|
+
z-index: 10;
|
|
76
|
+
width: var(--rel-carousel-nav-size, 40px);
|
|
77
|
+
height: var(--rel-carousel-nav-size, 40px);
|
|
78
|
+
border-radius: 50%;
|
|
79
|
+
border: 1px solid var(--rel-color-border-default);
|
|
80
|
+
background: var(--rel-color-bg-primary);
|
|
81
|
+
color: var(--rel-colors-gray-primary);
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
display: flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
justify-content: center;
|
|
86
|
+
transition: all 0.15s ease;
|
|
87
|
+
box-shadow: var(--rel-shadows-shadow-100);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.nav-button:hover:not(:disabled) {
|
|
91
|
+
background: var(--rel-surface-secondary);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.nav-button:focus-visible {
|
|
95
|
+
outline: 2px solid var(--rel-colors-blue-primary);
|
|
96
|
+
outline-offset: 2px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.nav-button:disabled {
|
|
100
|
+
opacity: 0.4;
|
|
101
|
+
cursor: not-allowed;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.nav-button.prev {
|
|
105
|
+
left: 12px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.nav-button.next {
|
|
109
|
+
right: 12px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.nav-button svg {
|
|
113
|
+
width: 20px;
|
|
114
|
+
height: 20px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* Dots indicator */
|
|
118
|
+
.dots {
|
|
119
|
+
display: flex;
|
|
120
|
+
justify-content: center;
|
|
121
|
+
gap: var(--rel-spacing-space-xs);
|
|
122
|
+
margin-top: var(--rel-spacing-space-md);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.dot {
|
|
126
|
+
width: var(--rel-carousel-dot-size, 8px);
|
|
127
|
+
height: var(--rel-carousel-dot-size, 8px);
|
|
128
|
+
border-radius: 50%;
|
|
129
|
+
border: none;
|
|
130
|
+
background: var(--rel-colors-gray-border);
|
|
131
|
+
cursor: pointer;
|
|
132
|
+
padding: 0;
|
|
133
|
+
transition: all 0.15s ease;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.dot:hover {
|
|
137
|
+
background: var(--rel-colors-gray-divider);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.dot.active {
|
|
141
|
+
background: var(--rel-color-brand);
|
|
142
|
+
width: var(--rel-carousel-dot-size-active, 24px);
|
|
143
|
+
border-radius: 4px;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.dot:focus-visible {
|
|
147
|
+
outline: 2px solid var(--rel-colors-blue-primary);
|
|
148
|
+
outline-offset: 2px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* Reduced motion support */
|
|
152
|
+
@media (prefers-reduced-motion: reduce) {
|
|
153
|
+
.track {
|
|
154
|
+
transition: none;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
`;
|
|
158
|
+
|
|
159
|
+
connectedCallback() {
|
|
160
|
+
super.connectedCallback();
|
|
161
|
+
this.prefersReducedMotion = window.matchMedia(
|
|
162
|
+
"(prefers-reduced-motion: reduce)"
|
|
163
|
+
).matches;
|
|
164
|
+
|
|
165
|
+
if (this.autoplay) {
|
|
166
|
+
this.startAutoplay();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
disconnectedCallback() {
|
|
171
|
+
super.disconnectedCallback();
|
|
172
|
+
this.stopAutoplay();
|
|
173
|
+
if (this.animationId) {
|
|
174
|
+
cancelAnimationFrame(this.animationId);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private handleSlotChange() {
|
|
179
|
+
const slot = this.slotElement;
|
|
180
|
+
if (!slot) return;
|
|
181
|
+
|
|
182
|
+
const elements = slot.assignedElements();
|
|
183
|
+
this.slideCount = elements.length;
|
|
184
|
+
|
|
185
|
+
// Ensure value is within bounds
|
|
186
|
+
if (this.value >= this.slideCount) {
|
|
187
|
+
this.value = this.slideCount - 1;
|
|
188
|
+
}
|
|
189
|
+
if (this.value < 0) {
|
|
190
|
+
this.value = 0;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
this.updateTransform();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private updateTransform() {
|
|
197
|
+
if (!this.track || !this.viewport) return;
|
|
198
|
+
|
|
199
|
+
const slideWidth = this.viewport.offsetWidth;
|
|
200
|
+
const gapValue = this.gap ?? 0;
|
|
201
|
+
const translate = -(this.value * (slideWidth + gapValue));
|
|
202
|
+
|
|
203
|
+
this.currentTranslate = translate;
|
|
204
|
+
this.prevTranslate = translate;
|
|
205
|
+
this.track.style.transform = `translateX(${translate}px)`;
|
|
206
|
+
|
|
207
|
+
if (this.gap) {
|
|
208
|
+
this.track.style.gap = `${this.gap}px`;
|
|
209
|
+
} else {
|
|
210
|
+
this.track.style.gap = "";
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private goToPrevious() {
|
|
215
|
+
if (this.disabled) return;
|
|
216
|
+
|
|
217
|
+
if (this.value > 0) {
|
|
218
|
+
this.value--;
|
|
219
|
+
} else if (this.loop) {
|
|
220
|
+
this.value = this.slideCount - 1;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
this.updateTransform();
|
|
224
|
+
this.emitChange();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
private goToNext() {
|
|
228
|
+
if (this.disabled) return;
|
|
229
|
+
|
|
230
|
+
if (this.value < this.slideCount - 1) {
|
|
231
|
+
this.value++;
|
|
232
|
+
} else if (this.loop) {
|
|
233
|
+
this.value = 0;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
this.updateTransform();
|
|
237
|
+
this.emitChange();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
private goToSlide(index: number) {
|
|
241
|
+
if (this.disabled || index < 0 || index >= this.slideCount) return;
|
|
242
|
+
|
|
243
|
+
this.value = index;
|
|
244
|
+
this.updateTransform();
|
|
245
|
+
this.emitChange();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
private emitChange() {
|
|
249
|
+
this.dispatchEvent(
|
|
250
|
+
new CustomEvent("rel-change", {
|
|
251
|
+
detail: { value: this.value },
|
|
252
|
+
bubbles: true,
|
|
253
|
+
composed: true,
|
|
254
|
+
})
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private startAutoplay() {
|
|
259
|
+
if (!this.autoplay || this.disabled) return;
|
|
260
|
+
|
|
261
|
+
this.stopAutoplay();
|
|
262
|
+
this.autoplayTimer = window.setInterval(() => {
|
|
263
|
+
this.goToNext();
|
|
264
|
+
}, this.interval);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
private stopAutoplay() {
|
|
268
|
+
if (this.autoplayTimer) {
|
|
269
|
+
clearInterval(this.autoplayTimer);
|
|
270
|
+
this.autoplayTimer = undefined;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
private handlePointerDown(e: PointerEvent) {
|
|
275
|
+
if (this.disabled || !this.track) return;
|
|
276
|
+
|
|
277
|
+
this.isDragging = true;
|
|
278
|
+
this.dragStartX = e.clientX;
|
|
279
|
+
this.prevTranslate = this.currentTranslate;
|
|
280
|
+
|
|
281
|
+
this.track.classList.add("dragging");
|
|
282
|
+
|
|
283
|
+
if (this.autoplay && this.pauseOnHover) {
|
|
284
|
+
this.stopAutoplay();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
e.preventDefault();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
private handlePointerMove(e: PointerEvent) {
|
|
291
|
+
if (!this.isDragging || !this.track) return;
|
|
292
|
+
|
|
293
|
+
const currentX = e.clientX;
|
|
294
|
+
const deltaX = currentX - this.dragStartX;
|
|
295
|
+
this.currentTranslate = this.prevTranslate + deltaX;
|
|
296
|
+
|
|
297
|
+
if (!this.prefersReducedMotion && this.animationId) {
|
|
298
|
+
cancelAnimationFrame(this.animationId);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
this.animationId = requestAnimationFrame(() => {
|
|
302
|
+
if (this.track) {
|
|
303
|
+
this.track.style.transform = `translateX(${this.currentTranslate}px)`;
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
private handlePointerUp(e: PointerEvent) {
|
|
309
|
+
if (!this.isDragging || !this.track || !this.viewport) return;
|
|
310
|
+
|
|
311
|
+
this.isDragging = false;
|
|
312
|
+
this.track.classList.remove("dragging");
|
|
313
|
+
|
|
314
|
+
const deltaX = e.clientX - this.dragStartX;
|
|
315
|
+
const slideWidth = this.viewport.offsetWidth;
|
|
316
|
+
const threshold = slideWidth * 0.2; // 20% threshold
|
|
317
|
+
|
|
318
|
+
if (Math.abs(deltaX) > threshold) {
|
|
319
|
+
if (deltaX > 0 && (this.value > 0 || this.loop)) {
|
|
320
|
+
this.goToPrevious();
|
|
321
|
+
} else if (deltaX < 0 && (this.value < this.slideCount - 1 || this.loop)) {
|
|
322
|
+
this.goToNext();
|
|
323
|
+
} else {
|
|
324
|
+
this.updateTransform();
|
|
325
|
+
}
|
|
326
|
+
} else {
|
|
327
|
+
this.updateTransform();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (this.autoplay) {
|
|
331
|
+
this.startAutoplay();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
private handleKeyDown(e: KeyboardEvent) {
|
|
336
|
+
if (this.disabled) return;
|
|
337
|
+
|
|
338
|
+
switch (e.key) {
|
|
339
|
+
case "ArrowLeft":
|
|
340
|
+
e.preventDefault();
|
|
341
|
+
this.goToPrevious();
|
|
342
|
+
break;
|
|
343
|
+
case "ArrowRight":
|
|
344
|
+
e.preventDefault();
|
|
345
|
+
this.goToNext();
|
|
346
|
+
break;
|
|
347
|
+
case "Home":
|
|
348
|
+
e.preventDefault();
|
|
349
|
+
this.goToSlide(0);
|
|
350
|
+
break;
|
|
351
|
+
case "End":
|
|
352
|
+
e.preventDefault();
|
|
353
|
+
this.goToSlide(this.slideCount - 1);
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
private handleMouseEnter() {
|
|
359
|
+
if (this.autoplay && this.pauseOnHover) {
|
|
360
|
+
this.stopAutoplay();
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
private handleMouseLeave() {
|
|
365
|
+
if (this.autoplay && this.pauseOnHover) {
|
|
366
|
+
this.startAutoplay();
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
updated(changedProperties: Map<string, any>) {
|
|
371
|
+
if (changedProperties.has("autoplay") || changedProperties.has("interval")) {
|
|
372
|
+
if (this.autoplay) {
|
|
373
|
+
this.startAutoplay();
|
|
374
|
+
} else {
|
|
375
|
+
this.stopAutoplay();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (changedProperties.has("value")) {
|
|
380
|
+
this.updateTransform();
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
render() {
|
|
385
|
+
const canGoPrev = this.loop || this.value > 0;
|
|
386
|
+
const canGoNext = this.loop || this.value < this.slideCount - 1;
|
|
387
|
+
|
|
388
|
+
return html`
|
|
389
|
+
<div
|
|
390
|
+
class="viewport"
|
|
391
|
+
part="viewport"
|
|
392
|
+
role="region"
|
|
393
|
+
aria-roledescription="carousel"
|
|
394
|
+
aria-label=${this.label}
|
|
395
|
+
@keydown=${this.handleKeyDown}
|
|
396
|
+
@mouseenter=${this.handleMouseEnter}
|
|
397
|
+
@mouseleave=${this.handleMouseLeave}
|
|
398
|
+
tabindex="0"
|
|
399
|
+
>
|
|
400
|
+
<div
|
|
401
|
+
class="track"
|
|
402
|
+
part="track"
|
|
403
|
+
@pointerdown=${this.handlePointerDown}
|
|
404
|
+
@pointermove=${this.handlePointerMove}
|
|
405
|
+
@pointerup=${this.handlePointerUp}
|
|
406
|
+
@pointercancel=${this.handlePointerUp}
|
|
407
|
+
>
|
|
408
|
+
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
409
|
+
</div>
|
|
410
|
+
|
|
411
|
+
${this.showButtons
|
|
412
|
+
? html`
|
|
413
|
+
<button
|
|
414
|
+
class="nav-button prev"
|
|
415
|
+
part="prev-button"
|
|
416
|
+
aria-label="Previous slide"
|
|
417
|
+
?disabled=${!canGoPrev || this.disabled}
|
|
418
|
+
@click=${this.goToPrevious}
|
|
419
|
+
>
|
|
420
|
+
<svg viewBox="0 0 16 16" fill="none">
|
|
421
|
+
<path
|
|
422
|
+
d="M10 12L6 8L10 4"
|
|
423
|
+
stroke="currentColor"
|
|
424
|
+
stroke-width="2"
|
|
425
|
+
stroke-linecap="round"
|
|
426
|
+
stroke-linejoin="round"
|
|
427
|
+
/>
|
|
428
|
+
</svg>
|
|
429
|
+
</button>
|
|
430
|
+
|
|
431
|
+
<button
|
|
432
|
+
class="nav-button next"
|
|
433
|
+
part="next-button"
|
|
434
|
+
aria-label="Next slide"
|
|
435
|
+
?disabled=${!canGoNext || this.disabled}
|
|
436
|
+
@click=${this.goToNext}
|
|
437
|
+
>
|
|
438
|
+
<svg viewBox="0 0 16 16" fill="none">
|
|
439
|
+
<path
|
|
440
|
+
d="M6 4L10 8L6 12"
|
|
441
|
+
stroke="currentColor"
|
|
442
|
+
stroke-width="2"
|
|
443
|
+
stroke-linecap="round"
|
|
444
|
+
stroke-linejoin="round"
|
|
445
|
+
/>
|
|
446
|
+
</svg>
|
|
447
|
+
</button>
|
|
448
|
+
`
|
|
449
|
+
: nothing}
|
|
450
|
+
</div>
|
|
451
|
+
|
|
452
|
+
${this.showDots && this.slideCount > 1
|
|
453
|
+
? html`
|
|
454
|
+
<div class="dots" part="dots">
|
|
455
|
+
${Array.from({ length: this.slideCount }, (_, i) => html`
|
|
456
|
+
<button
|
|
457
|
+
class="dot ${i === this.value ? "active" : ""}"
|
|
458
|
+
part="dot"
|
|
459
|
+
aria-label="Go to slide ${i + 1}"
|
|
460
|
+
@click=${() => this.goToSlide(i)}
|
|
461
|
+
></button>
|
|
462
|
+
`)}
|
|
463
|
+
</div>
|
|
464
|
+
`
|
|
465
|
+
: nothing}
|
|
466
|
+
`;
|
|
467
|
+
}
|
|
468
|
+
}
|