@solid-design-system/components 1.17.0 → 1.18.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/es/accordion-group.js +1 -1
- package/dist/components/es/accordion.js +1 -1
- package/dist/components/es/animation-registry.js +1 -0
- package/dist/components/es/autoplay-controller.js +1 -0
- package/dist/components/es/carousel-item.js +1 -0
- package/dist/components/es/carousel.js +11 -0
- package/dist/components/es/drawer.js +1 -1
- package/dist/components/es/dropdown.js +1 -1
- package/dist/components/es/event.js +1 -1
- package/dist/components/es/scroll-controller.js +1 -0
- package/dist/components/es/solid-components2.js +1 -1
- package/dist/components/es/solid-element.js +1 -1
- package/dist/components/umd/solid-components.js +26 -16
- package/dist/custom-elements.json +1 -1
- package/dist/package/components/accordion/accordion.js +1 -1
- package/dist/package/components/carousel/autoplay-controller.d.ts +18 -0
- package/dist/package/components/carousel/autoplay-controller.js +65 -0
- package/dist/package/components/carousel/carousel.d.ts +46 -0
- package/dist/package/components/carousel/carousel.js +366 -0
- package/dist/package/components/carousel/scroll-controller.d.ts +25 -0
- package/dist/package/components/carousel/scroll-controller.js +141 -0
- package/dist/package/components/carousel-item/carousel-item.d.ts +12 -0
- package/dist/package/components/carousel-item/carousel-item.js +37 -0
- package/dist/package/components/icon/library.system.d.ts +2 -0
- package/dist/package/components/icon/library.system.js +10 -1
- package/dist/package/internal/debounce.d.ts +1 -0
- package/dist/package/internal/debounce.js +15 -0
- package/dist/package/internal/math.d.ts +1 -0
- package/dist/package/internal/math.js +13 -0
- package/dist/package/solid-components.d.ts +2 -0
- package/dist/package/solid-components.js +26 -22
- package/dist/package/styles/interactive/interactive.css.js +4 -0
- package/dist/package/styles/tailwind.css.js +1 -1
- package/dist/package/translations/en.js +6 -1
- package/dist/package/utilities/localize.d.ts +6 -1
- package/dist/versioned-components/es/accordion-group.js +1 -1
- package/dist/versioned-components/es/accordion.js +1 -1
- package/dist/versioned-components/es/animation-registry.js +1 -0
- package/dist/versioned-components/es/autoplay-controller.js +1 -0
- package/dist/versioned-components/es/badge.js +1 -1
- package/dist/versioned-components/es/brandshape.js +1 -1
- package/dist/versioned-components/es/button.js +1 -1
- package/dist/versioned-components/es/carousel-item.js +1 -0
- package/dist/versioned-components/es/carousel.js +11 -0
- package/dist/versioned-components/es/divider.js +1 -1
- package/dist/versioned-components/es/drawer.js +1 -1
- package/dist/versioned-components/es/dropdown.js +1 -1
- package/dist/versioned-components/es/event.js +1 -1
- package/dist/versioned-components/es/icon.js +1 -1
- package/dist/versioned-components/es/include.js +1 -1
- package/dist/versioned-components/es/link.js +1 -1
- package/dist/versioned-components/es/navigation-item.js +1 -1
- package/dist/versioned-components/es/popup.js +1 -1
- package/dist/versioned-components/es/scroll-controller.js +1 -0
- package/dist/versioned-components/es/solid-components2.js +1 -1
- package/dist/versioned-components/es/solid-element.js +1 -1
- package/dist/versioned-components/es/spinner.js +1 -1
- package/dist/versioned-components/es/tag.js +1 -1
- package/dist/versioned-components/es/teaser.js +1 -1
- package/dist/versioned-package/components/accordion/accordion.d.ts +1 -1
- package/dist/versioned-package/components/accordion/accordion.js +2 -2
- package/dist/versioned-package/components/accordion-group/accordion-group.d.ts +1 -1
- package/dist/versioned-package/components/accordion-group/accordion-group.js +3 -3
- package/dist/versioned-package/components/badge/badge.d.ts +1 -1
- package/dist/versioned-package/components/badge/badge.js +1 -1
- package/dist/versioned-package/components/brandshape/brandshape.d.ts +1 -1
- package/dist/versioned-package/components/brandshape/brandshape.js +1 -1
- package/dist/versioned-package/components/button/button.d.ts +1 -1
- package/dist/versioned-package/components/button/button.js +4 -4
- package/dist/versioned-package/components/carousel/autoplay-controller.d.ts +18 -0
- package/dist/versioned-package/components/carousel/autoplay-controller.js +65 -0
- package/dist/versioned-package/components/carousel/carousel.d.ts +46 -0
- package/dist/versioned-package/components/carousel/carousel.js +366 -0
- package/dist/versioned-package/components/carousel/scroll-controller.d.ts +25 -0
- package/dist/versioned-package/components/carousel/scroll-controller.js +141 -0
- package/dist/versioned-package/components/carousel-item/carousel-item.d.ts +12 -0
- package/dist/versioned-package/components/carousel-item/carousel-item.js +37 -0
- package/dist/versioned-package/components/divider/divider.d.ts +1 -1
- package/dist/versioned-package/components/divider/divider.js +2 -2
- package/dist/versioned-package/components/drawer/drawer.d.ts +1 -1
- package/dist/versioned-package/components/drawer/drawer.js +2 -2
- package/dist/versioned-package/components/dropdown/dropdown.d.ts +1 -1
- package/dist/versioned-package/components/dropdown/dropdown.js +6 -6
- package/dist/versioned-package/components/icon/icon.d.ts +1 -1
- package/dist/versioned-package/components/icon/icon.js +1 -1
- package/dist/versioned-package/components/icon/library.system.d.ts +2 -0
- package/dist/versioned-package/components/icon/library.system.js +10 -1
- package/dist/versioned-package/components/include/include.d.ts +1 -1
- package/dist/versioned-package/components/include/include.js +1 -1
- package/dist/versioned-package/components/link/link.d.ts +1 -1
- package/dist/versioned-package/components/link/link.js +2 -2
- package/dist/versioned-package/components/navigation-item/navigation-item.d.ts +1 -1
- package/dist/versioned-package/components/navigation-item/navigation-item.js +3 -3
- package/dist/versioned-package/components/popup/popup.d.ts +1 -1
- package/dist/versioned-package/components/popup/popup.js +1 -1
- package/dist/versioned-package/components/spinner/spinner.d.ts +1 -1
- package/dist/versioned-package/components/spinner/spinner.js +1 -1
- package/dist/versioned-package/components/tag/tag.d.ts +1 -1
- package/dist/versioned-package/components/tag/tag.js +2 -2
- package/dist/versioned-package/components/teaser/teaser.js +1 -1
- package/dist/versioned-package/internal/debounce.d.ts +1 -0
- package/dist/versioned-package/internal/debounce.js +15 -0
- package/dist/versioned-package/internal/form.js +1 -1
- package/dist/versioned-package/internal/math.d.ts +1 -0
- package/dist/versioned-package/internal/math.js +13 -0
- package/dist/versioned-package/solid-components.d.ts +2 -0
- package/dist/versioned-package/solid-components.js +26 -22
- package/dist/versioned-package/styles/interactive/interactive.css.js +4 -0
- package/dist/versioned-package/styles/tailwind.css.js +1 -1
- package/dist/versioned-package/translations/en.js +6 -1
- package/dist/versioned-package/utilities/localize.d.ts +6 -1
- package/dist/versioned-styles/solid-styles.css +1 -1
- package/dist/vscode.html-custom-data.json +118 -18
- package/dist/web-types.json +621 -17
- package/package.json +4 -4
|
@@ -48,16 +48,16 @@ let SdAccordionGroup = class extends SolidElement {
|
|
|
48
48
|
SdAccordionGroup.styles = [
|
|
49
49
|
componentStyles,
|
|
50
50
|
SolidElement.styles,
|
|
51
|
-
css`:host{display:block}::slotted(sd-1-
|
|
51
|
+
css`:host{display:block}::slotted(sd-1-18-1-accordion:not(:first-of-type)){margin-top:-1px}`
|
|
52
52
|
];
|
|
53
53
|
__decorateClass([
|
|
54
|
-
queryAssignedElements({ selector: "sd-1-
|
|
54
|
+
queryAssignedElements({ selector: "sd-1-18-1-accordion" })
|
|
55
55
|
], SdAccordionGroup.prototype, "_accordionsInDefaultSlot", 2);
|
|
56
56
|
__decorateClass([
|
|
57
57
|
property({ attribute: "close-others", type: Boolean })
|
|
58
58
|
], SdAccordionGroup.prototype, "closeOthers", 2);
|
|
59
59
|
SdAccordionGroup = __decorateClass([
|
|
60
|
-
customElement("sd-1-
|
|
60
|
+
customElement("sd-1-18-1-accordion-group")
|
|
61
61
|
], SdAccordionGroup);
|
|
62
62
|
export {
|
|
63
63
|
SdAccordionGroup as default
|
|
@@ -123,7 +123,7 @@ __decorateClass([
|
|
|
123
123
|
state()
|
|
124
124
|
], SdBrandshape.prototype, "componentBreakpoint", 2);
|
|
125
125
|
SdBrandshape = __decorateClass([
|
|
126
|
-
customElement("sd-1-
|
|
126
|
+
customElement("sd-1-18-1-brandshape")
|
|
127
127
|
], SdBrandshape);
|
|
128
128
|
export {
|
|
129
129
|
SdBrandshape as default
|
|
@@ -191,19 +191,19 @@ let SdButton = class extends SolidElement {
|
|
|
191
191
|
md: "ml-2",
|
|
192
192
|
lg: "ml-2"
|
|
193
193
|
}[this.size]
|
|
194
|
-
)}"></slot>${this.loading ? html`<sd-1-
|
|
194
|
+
)}"></slot>${this.loading ? html`<sd-1-18-1-spinner class="${cx("absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2")}"></sd-1-18-1-spinner>` : ""}</${tag}>`;
|
|
195
195
|
}
|
|
196
196
|
};
|
|
197
197
|
SdButton.styles = [
|
|
198
198
|
componentStyles,
|
|
199
199
|
SolidElement.styles,
|
|
200
|
-
css`:host{display:inline-block;position:relative;width:auto;cursor:pointer}sd-1-
|
|
200
|
+
css`:host{display:inline-block;position:relative;width:auto;cursor:pointer}sd-1-18-1-spinner{--indicator-color:currentColor;--track-color:var(--tw-varcolor-200)}::slotted(sd-1-18-1-badge){position:absolute;top:0;right:0;translate:50% -50%;pointer-events:none}::slotted(sd-1-18-1-icon),sd-1-18-1-spinner{font-size:calc(var(--tw-varspacing)/ 2)}`
|
|
201
201
|
];
|
|
202
202
|
__decorateClass([
|
|
203
203
|
query("a, button")
|
|
204
204
|
], SdButton.prototype, "button", 2);
|
|
205
205
|
__decorateClass([
|
|
206
|
-
queryAssignedElements({ selector: "sd-1-
|
|
206
|
+
queryAssignedElements({ selector: "sd-1-18-1-icon" })
|
|
207
207
|
], SdButton.prototype, "_iconsInDefaultSlot", 2);
|
|
208
208
|
__decorateClass([
|
|
209
209
|
state()
|
|
@@ -266,7 +266,7 @@ __decorateClass([
|
|
|
266
266
|
watch("disabled", { waitUntilFirstUpdate: true })
|
|
267
267
|
], SdButton.prototype, "handleDisabledChange", 1);
|
|
268
268
|
SdButton = __decorateClass([
|
|
269
|
-
customElement("sd-1-
|
|
269
|
+
customElement("sd-1-18-1-button")
|
|
270
270
|
], SdButton);
|
|
271
271
|
export {
|
|
272
272
|
SdButton as default
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveElement } from 'lit';
|
|
2
|
+
export declare class AutoplayController implements ReactiveController {
|
|
3
|
+
private host;
|
|
4
|
+
private timerId;
|
|
5
|
+
private tickCallback;
|
|
6
|
+
private activeInteractions;
|
|
7
|
+
paused: boolean;
|
|
8
|
+
stopped: boolean;
|
|
9
|
+
constructor(host: ReactiveElement, tickCallback: () => void);
|
|
10
|
+
hostConnected(): void;
|
|
11
|
+
hostDisconnected(): void;
|
|
12
|
+
start(interval: number): void;
|
|
13
|
+
stop(): void;
|
|
14
|
+
pause: () => void;
|
|
15
|
+
resume: () => void;
|
|
16
|
+
controlledPause: () => void;
|
|
17
|
+
controlledResume: () => void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
class AutoplayController {
|
|
2
|
+
constructor(host, tickCallback) {
|
|
3
|
+
this.timerId = 0;
|
|
4
|
+
this.activeInteractions = 0;
|
|
5
|
+
this.paused = false;
|
|
6
|
+
this.stopped = true;
|
|
7
|
+
this.pause = () => {
|
|
8
|
+
if (!this.activeInteractions++) {
|
|
9
|
+
this.paused = true;
|
|
10
|
+
this.host.requestUpdate();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
this.resume = () => {
|
|
14
|
+
if (!--this.activeInteractions) {
|
|
15
|
+
this.paused = false;
|
|
16
|
+
this.host.requestUpdate();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
this.controlledPause = () => {
|
|
20
|
+
this.paused = true;
|
|
21
|
+
this.host.requestUpdate();
|
|
22
|
+
};
|
|
23
|
+
this.controlledResume = () => {
|
|
24
|
+
this.paused = false;
|
|
25
|
+
this.host.requestUpdate();
|
|
26
|
+
};
|
|
27
|
+
host.addController(this);
|
|
28
|
+
this.host = host;
|
|
29
|
+
this.tickCallback = tickCallback;
|
|
30
|
+
}
|
|
31
|
+
hostConnected() {
|
|
32
|
+
this.host.addEventListener("mouseenter", this.pause);
|
|
33
|
+
this.host.addEventListener("mouseleave", this.resume);
|
|
34
|
+
this.host.addEventListener("focusin", this.pause);
|
|
35
|
+
this.host.addEventListener("focusout", this.resume);
|
|
36
|
+
this.host.addEventListener("touchstart", this.pause, { passive: true });
|
|
37
|
+
this.host.addEventListener("touchend", this.resume);
|
|
38
|
+
}
|
|
39
|
+
hostDisconnected() {
|
|
40
|
+
this.stop();
|
|
41
|
+
this.host.removeEventListener("mouseenter", this.pause);
|
|
42
|
+
this.host.removeEventListener("mouseleave", this.resume);
|
|
43
|
+
this.host.removeEventListener("focusin", this.pause);
|
|
44
|
+
this.host.removeEventListener("focusout", this.resume);
|
|
45
|
+
this.host.removeEventListener("touchstart", this.pause);
|
|
46
|
+
this.host.removeEventListener("touchend", this.resume);
|
|
47
|
+
}
|
|
48
|
+
start(interval) {
|
|
49
|
+
this.stop();
|
|
50
|
+
this.stopped = false;
|
|
51
|
+
this.timerId = window.setInterval(() => {
|
|
52
|
+
if (!this.paused) {
|
|
53
|
+
this.tickCallback();
|
|
54
|
+
}
|
|
55
|
+
}, interval);
|
|
56
|
+
}
|
|
57
|
+
stop() {
|
|
58
|
+
clearInterval(this.timerId);
|
|
59
|
+
this.stopped = true;
|
|
60
|
+
this.host.requestUpdate();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
AutoplayController
|
|
65
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import '../icon/icon.js';
|
|
2
|
+
import SolidElement from '../../internal/solid-element.js';
|
|
3
|
+
export default class SdCarousel extends SolidElement {
|
|
4
|
+
variant: 'dot' | 'number';
|
|
5
|
+
inverted: boolean;
|
|
6
|
+
loop: boolean;
|
|
7
|
+
autoplay: boolean;
|
|
8
|
+
slidesPerPage: number;
|
|
9
|
+
slidesPerMove: number;
|
|
10
|
+
defaultSlot: HTMLSlotElement;
|
|
11
|
+
scrollContainer: HTMLElement;
|
|
12
|
+
paginationContainer: HTMLElement;
|
|
13
|
+
activeSlide: number;
|
|
14
|
+
pausedAutoplay: boolean;
|
|
15
|
+
private autoplayController;
|
|
16
|
+
private scrollController;
|
|
17
|
+
private readonly slides;
|
|
18
|
+
private intersectionObserver;
|
|
19
|
+
private readonly intersectionObserverEntries;
|
|
20
|
+
private readonly localize;
|
|
21
|
+
private mutationObserver;
|
|
22
|
+
connectedCallback(): void;
|
|
23
|
+
disconnectedCallback(): void;
|
|
24
|
+
protected firstUpdated(): void;
|
|
25
|
+
private getPageCount;
|
|
26
|
+
private getCurrentPage;
|
|
27
|
+
private getSlides;
|
|
28
|
+
private handleKeyDown;
|
|
29
|
+
private handleScrollEnd;
|
|
30
|
+
private handleSlotChange;
|
|
31
|
+
handlePausedAutoplay(): void;
|
|
32
|
+
initializeSlides(): void;
|
|
33
|
+
handelSlideChange(): void;
|
|
34
|
+
handleSlidesPerMoveChange(): void;
|
|
35
|
+
handleAutoplayChange(): void;
|
|
36
|
+
previous(behavior?: ScrollBehavior): void;
|
|
37
|
+
next(behavior?: ScrollBehavior): void;
|
|
38
|
+
goToSlide(index: number, behavior?: ScrollBehavior): void;
|
|
39
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
40
|
+
static styles: import("lit").CSSResultGroup[];
|
|
41
|
+
}
|
|
42
|
+
declare global {
|
|
43
|
+
interface HTMLElementTagNameMap {
|
|
44
|
+
'sd-1-18-1-carousel': SdCarousel;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import "../icon/icon.js";
|
|
2
|
+
import { AutoplayController } from "./autoplay-controller.js";
|
|
3
|
+
import { clamp } from "../../internal/math.js";
|
|
4
|
+
import { unsafeCSS, css, html } from "lit";
|
|
5
|
+
import { customElement } from "../../internal/register-custom-element.js";
|
|
6
|
+
import { LocalizeController } from "../../utilities/localize.js";
|
|
7
|
+
import { map } from "lit/directives/map.js";
|
|
8
|
+
import { prefersReducedMotion } from "../../internal/animate.js";
|
|
9
|
+
import { property, query, state } from "lit/decorators.js";
|
|
10
|
+
import { range } from "lit/directives/range.js";
|
|
11
|
+
import { ScrollController } from "./scroll-controller.js";
|
|
12
|
+
import { watch } from "../../internal/watch.js";
|
|
13
|
+
import componentStyles from "../../styles/component.styles.js";
|
|
14
|
+
import cx from "classix";
|
|
15
|
+
import InteractiveStyles from "../../styles/interactive/interactive.css.js";
|
|
16
|
+
import SdCarouselItem from "../carousel-item/carousel-item.js";
|
|
17
|
+
import SolidElement from "../../internal/solid-element.js";
|
|
18
|
+
var __defProp = Object.defineProperty;
|
|
19
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
20
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
21
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
22
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
23
|
+
if (decorator = decorators[i])
|
|
24
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
25
|
+
if (kind && result)
|
|
26
|
+
__defProp(target, key, result);
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
let SdCarousel = class extends SolidElement {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.variant = "number";
|
|
33
|
+
this.inverted = false;
|
|
34
|
+
this.loop = false;
|
|
35
|
+
this.autoplay = false;
|
|
36
|
+
this.slidesPerPage = 1;
|
|
37
|
+
this.slidesPerMove = 1;
|
|
38
|
+
this.activeSlide = 0;
|
|
39
|
+
this.pausedAutoplay = false;
|
|
40
|
+
this.autoplayController = new AutoplayController(this, () => this.next());
|
|
41
|
+
this.scrollController = new ScrollController(this);
|
|
42
|
+
this.slides = this.getElementsByTagName("sd-1-18-1-carousel-item");
|
|
43
|
+
this.intersectionObserverEntries = /* @__PURE__ */ new Map();
|
|
44
|
+
this.localize = new LocalizeController(this);
|
|
45
|
+
this.handleSlotChange = (mutations) => {
|
|
46
|
+
const needsInitialization = mutations.some(
|
|
47
|
+
(mutation) => [...mutation.addedNodes, ...mutation.removedNodes].some(
|
|
48
|
+
(node) => SdCarouselItem.isCarouselItem(node) && !node.hasAttribute("data-clone")
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
if (needsInitialization) {
|
|
52
|
+
this.initializeSlides();
|
|
53
|
+
}
|
|
54
|
+
this.requestUpdate();
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
connectedCallback() {
|
|
58
|
+
super.connectedCallback();
|
|
59
|
+
this.setAttribute("role", "region");
|
|
60
|
+
this.setAttribute("aria-label", this.localize.term("carousel"));
|
|
61
|
+
const intersectionObserver = new IntersectionObserver(
|
|
62
|
+
(entries) => {
|
|
63
|
+
entries.forEach((entry) => {
|
|
64
|
+
this.intersectionObserverEntries.set(entry.target, entry);
|
|
65
|
+
const slide = entry.target;
|
|
66
|
+
slide.toggleAttribute("inert", !entry.isIntersecting);
|
|
67
|
+
slide.classList.toggle("--in-view", entry.isIntersecting);
|
|
68
|
+
slide.setAttribute("aria-hidden", entry.isIntersecting ? "false" : "true");
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
root: this,
|
|
73
|
+
threshold: 0.6
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
this.intersectionObserver = intersectionObserver;
|
|
77
|
+
intersectionObserver.takeRecords().forEach((entry) => {
|
|
78
|
+
this.intersectionObserverEntries.set(entry.target, entry);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
disconnectedCallback() {
|
|
82
|
+
super.disconnectedCallback();
|
|
83
|
+
this.intersectionObserver.disconnect();
|
|
84
|
+
this.mutationObserver.disconnect();
|
|
85
|
+
}
|
|
86
|
+
firstUpdated() {
|
|
87
|
+
this.initializeSlides();
|
|
88
|
+
this.mutationObserver = new MutationObserver(this.handleSlotChange);
|
|
89
|
+
this.mutationObserver.observe(this, { childList: true, subtree: false });
|
|
90
|
+
}
|
|
91
|
+
getPageCount() {
|
|
92
|
+
return Math.ceil(this.getSlides().length / this.slidesPerPage);
|
|
93
|
+
}
|
|
94
|
+
getCurrentPage() {
|
|
95
|
+
return Math.ceil(this.activeSlide / this.slidesPerPage);
|
|
96
|
+
}
|
|
97
|
+
getSlides({ excludeClones = true } = {}) {
|
|
98
|
+
return [...this.slides].filter((slide) => !excludeClones || !slide.hasAttribute("data-clone"));
|
|
99
|
+
}
|
|
100
|
+
handleKeyDown(event) {
|
|
101
|
+
if (["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
|
|
102
|
+
const target = event.target;
|
|
103
|
+
const isRtl = this.localize.dir() === "rtl";
|
|
104
|
+
const isFocusInPagination = target.closest('[part~="pagination-item"]') !== null;
|
|
105
|
+
const isNext = event.key === "ArrowDown" || !isRtl && event.key === "ArrowRight" || isRtl && event.key === "ArrowLeft";
|
|
106
|
+
const isPrevious = event.key === "ArrowUp" || !isRtl && event.key === "ArrowLeft" || isRtl && event.key === "ArrowRight";
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
if (isPrevious) {
|
|
109
|
+
this.previous();
|
|
110
|
+
}
|
|
111
|
+
if (isNext) {
|
|
112
|
+
this.next();
|
|
113
|
+
}
|
|
114
|
+
if (event.key === "Home") {
|
|
115
|
+
this.goToSlide(0);
|
|
116
|
+
}
|
|
117
|
+
if (event.key === "End") {
|
|
118
|
+
this.goToSlide(this.getSlides().length - 1);
|
|
119
|
+
}
|
|
120
|
+
if (isFocusInPagination) {
|
|
121
|
+
this.updateComplete.then(() => {
|
|
122
|
+
var _a;
|
|
123
|
+
const activePaginationItem = (_a = this.shadowRoot) == null ? void 0 : _a.querySelector(
|
|
124
|
+
'[part~="pagination-item--active"]'
|
|
125
|
+
);
|
|
126
|
+
if (activePaginationItem) {
|
|
127
|
+
activePaginationItem.focus();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
handleScrollEnd() {
|
|
134
|
+
const slides = this.getSlides();
|
|
135
|
+
const entries = [...this.intersectionObserverEntries.values()];
|
|
136
|
+
const firstIntersecting = entries.find((entry) => entry.isIntersecting);
|
|
137
|
+
if (this.loop && (firstIntersecting == null ? void 0 : firstIntersecting.target.hasAttribute("data-clone"))) {
|
|
138
|
+
const clonePosition = Number(firstIntersecting.target.getAttribute("data-clone"));
|
|
139
|
+
this.goToSlide(clonePosition, "auto");
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (firstIntersecting) {
|
|
143
|
+
this.activeSlide = slides.indexOf(firstIntersecting.target);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
handlePausedAutoplay() {
|
|
147
|
+
if (this.pausedAutoplay) {
|
|
148
|
+
this.autoplayController.controlledPause();
|
|
149
|
+
} else if (this.autoplay) {
|
|
150
|
+
this.autoplayController.controlledResume();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
initializeSlides() {
|
|
154
|
+
const slides = this.getSlides();
|
|
155
|
+
const intersectionObserver = this.intersectionObserver;
|
|
156
|
+
this.intersectionObserverEntries.clear();
|
|
157
|
+
this.getSlides({ excludeClones: false }).forEach((slide, index) => {
|
|
158
|
+
intersectionObserver.unobserve(slide);
|
|
159
|
+
slide.classList.remove("--in-view");
|
|
160
|
+
slide.classList.remove("--is-active");
|
|
161
|
+
slide.setAttribute("aria-label", this.localize.term("slideNum", index + 1));
|
|
162
|
+
if (slide.hasAttribute("data-clone")) {
|
|
163
|
+
slide.remove();
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
if (this.loop) {
|
|
167
|
+
const slidesPerPage = this.slidesPerPage;
|
|
168
|
+
const lastSlides = slides.slice(-slidesPerPage);
|
|
169
|
+
const firstSlides = slides.slice(0, slidesPerPage);
|
|
170
|
+
lastSlides.reverse().forEach((slide, i) => {
|
|
171
|
+
const clone = slide.cloneNode(true);
|
|
172
|
+
clone.setAttribute("data-clone", String(slides.length - i - 1));
|
|
173
|
+
this.prepend(clone);
|
|
174
|
+
});
|
|
175
|
+
firstSlides.forEach((slide, i) => {
|
|
176
|
+
const clone = slide.cloneNode(true);
|
|
177
|
+
clone.setAttribute("data-clone", String(i));
|
|
178
|
+
this.append(clone);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
this.getSlides({ excludeClones: false }).forEach((slide) => {
|
|
182
|
+
intersectionObserver.observe(slide);
|
|
183
|
+
});
|
|
184
|
+
this.goToSlide(this.activeSlide, "auto");
|
|
185
|
+
}
|
|
186
|
+
handelSlideChange() {
|
|
187
|
+
const slides = this.getSlides();
|
|
188
|
+
slides.forEach((slide, i) => {
|
|
189
|
+
slide.classList.toggle("--is-active", i === this.activeSlide);
|
|
190
|
+
});
|
|
191
|
+
if (this.hasUpdated) {
|
|
192
|
+
this.emit("sd-slide-change", {
|
|
193
|
+
detail: {
|
|
194
|
+
index: this.activeSlide,
|
|
195
|
+
slide: slides[this.activeSlide]
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
handleSlidesPerMoveChange() {
|
|
201
|
+
const slides = this.getSlides({ excludeClones: false });
|
|
202
|
+
const slidesPerMove = this.slidesPerMove;
|
|
203
|
+
slides.forEach((slide, i) => {
|
|
204
|
+
const shouldSnap = Math.abs(i - slidesPerMove) % slidesPerMove === 0;
|
|
205
|
+
if (shouldSnap) {
|
|
206
|
+
slide.style.removeProperty("scroll-snap-align");
|
|
207
|
+
} else {
|
|
208
|
+
slide.style.setProperty("scroll-snap-align", "none");
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
handleAutoplayChange() {
|
|
213
|
+
this.autoplayController.stop();
|
|
214
|
+
if (this.autoplay && !this.pausedAutoplay) {
|
|
215
|
+
this.autoplayController.start(3e3);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Move the carousel backward by `slides-per-move` slides.
|
|
220
|
+
*
|
|
221
|
+
* @param behavior - The behavior used for scrolling.
|
|
222
|
+
*/
|
|
223
|
+
previous(behavior = "smooth") {
|
|
224
|
+
let previousIndex = this.activeSlide || this.activeSlide - this.slidesPerMove;
|
|
225
|
+
let canSnap = false;
|
|
226
|
+
while (!canSnap && previousIndex > 0) {
|
|
227
|
+
previousIndex -= 1;
|
|
228
|
+
canSnap = Math.abs(previousIndex - this.slidesPerMove) % this.slidesPerMove === 0;
|
|
229
|
+
}
|
|
230
|
+
this.goToSlide(previousIndex, behavior);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Move the carousel forward by `slides-per-move` slides.
|
|
234
|
+
*
|
|
235
|
+
* @param behavior - The behavior used for scrolling.
|
|
236
|
+
*/
|
|
237
|
+
next(behavior = "smooth") {
|
|
238
|
+
this.goToSlide(this.activeSlide + this.slidesPerMove, behavior);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Scrolls the carousel to the slide specified by `index`.
|
|
242
|
+
*
|
|
243
|
+
* @param index - The slide index.
|
|
244
|
+
* @param behavior - The behavior used for scrolling.
|
|
245
|
+
*/
|
|
246
|
+
goToSlide(index, behavior = "smooth") {
|
|
247
|
+
const { slidesPerPage, loop, scrollContainer } = this;
|
|
248
|
+
const slides = this.getSlides();
|
|
249
|
+
const slidesWithClones = this.getSlides({ excludeClones: false });
|
|
250
|
+
const newActiveSlide = (index + slides.length) % slides.length;
|
|
251
|
+
this.activeSlide = newActiveSlide;
|
|
252
|
+
const nextSlideIndex = clamp(index + (loop ? slidesPerPage : 0), 0, slidesWithClones.length - 1);
|
|
253
|
+
const nextSlide = slidesWithClones[nextSlideIndex];
|
|
254
|
+
const scrollContainerRect = scrollContainer.getBoundingClientRect();
|
|
255
|
+
const nextSlideRect = nextSlide.getBoundingClientRect();
|
|
256
|
+
scrollContainer.scrollTo({
|
|
257
|
+
left: nextSlideRect.left - scrollContainerRect.left + scrollContainer.scrollLeft,
|
|
258
|
+
top: nextSlideRect.top - scrollContainerRect.top + scrollContainer.scrollTop,
|
|
259
|
+
behavior: prefersReducedMotion() ? "auto" : behavior
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
render() {
|
|
263
|
+
const { scrollController, slidesPerPage } = this;
|
|
264
|
+
const pagesCount = this.getPageCount();
|
|
265
|
+
const currentPage = this.getCurrentPage();
|
|
266
|
+
const prevEnabled = this.loop || currentPage > 0;
|
|
267
|
+
const nextEnabled = this.loop || currentPage < pagesCount - 1;
|
|
268
|
+
const isLtr = this.localize.dir() === "ltr";
|
|
269
|
+
return html`<div part="base" class="${cx(`carousel h-full w-full`)}"><div id="scroll-container" part="scroll-container" class="${cx(
|
|
270
|
+
`carousel__slides mb-6
|
|
271
|
+
grid max-h-full w-full items-center justify-items-center overflow-auto`,
|
|
272
|
+
this.inverted ? "focus-visible:focus-outline-inverted" : "focus-visible:focus-outline",
|
|
273
|
+
`overscroll-x-contain grid-flow-col auto-rows-[100%]
|
|
274
|
+
snap-x snap-mandatory overflow-y-hidden`
|
|
275
|
+
)}" style="--slides-per-page:${this.slidesPerPage}" aria-busy="${scrollController.scrolling ? "true" : "false"}" aria-atomic="true" tabindex="0" @keydown="${this.handleKeyDown}" @scrollend="${this.handleScrollEnd}"><slot></slot></div><div part="controls" class="${cx("w-full flex items-center justify-center relative")}"><div part="navigation" class="${cx("carousel__navigation flex items-center justify-center")}"><button part="navigation-button navigation-button--previous" id="carousel__navigation-button--previous" ?disabled="${!prevEnabled ? true : false}" class="${cx(
|
|
276
|
+
"!mr-6 !rounded-sm sd-interactive",
|
|
277
|
+
!prevEnabled && "sd-interactive--disabled",
|
|
278
|
+
this.inverted ? "sd-interactive--inverted" : "sd-interactive--reset"
|
|
279
|
+
)}" aria-label="${this.localize.term("previousSlide")}" aria-controls="scroll-container" aria-disabled="${prevEnabled ? "false" : "true"}" @click="${prevEnabled ? () => this.previous() : null}"><slot name="previous-icon"><sd-1-18-1-icon class="${cx("h-6 w-6 rotate-90 grid place-items-center")}" library="system" name="${isLtr ? "chevron-down" : "chevron-up"}"></sd-1-18-1-icon></slot></button> ${this.variant === "dot" ? html`<div part="pagination-dot" role="tablist" class="${cx("carousel__pagination dot flex wrap items-center gap-2")}" aria-controls="scroll-container">${map(range(pagesCount), (index) => {
|
|
280
|
+
const isActive = index === currentPage;
|
|
281
|
+
return html`<button part="pagination-item ${isActive ? "pagination-item--active" : ""}" class="${cx(
|
|
282
|
+
"carousel__pagination-item",
|
|
283
|
+
"block cursor-pointer bg-none border-0 rounded-full",
|
|
284
|
+
isActive ? "bg-accent" : "",
|
|
285
|
+
this.inverted ? "focus-within:focus-outline-inverted" : "focus-within:focus-outline"
|
|
286
|
+
)}" role="tab" tabindex="0" aria-selected="${isActive ? "true" : "false"}" aria-label="${this.localize.term("goToSlide", index + 1, pagesCount)}" @click="${() => this.goToSlide(index * slidesPerPage)}" @keydown="${this.handleKeyDown}"><span class="${cx(
|
|
287
|
+
"h-4 w-4 block border hover:border-primary-500 rounded-full",
|
|
288
|
+
this.inverted ? "border-white hover:border-primary-500" : "border-primary",
|
|
289
|
+
isActive && "bg-accent border-none",
|
|
290
|
+
isActive ? this.inverted ? "hover:bg-accent-300" : "hover:bg-accent-550" : ""
|
|
291
|
+
)}"></span></button>`;
|
|
292
|
+
})}</div>` : html`<span part="pagination-number" class="carousel__pagination number flex gap-0.5 cursor-default select-none" aria-controls="scroll-container"><span part="pagination-item" class="${cx("w-5 text-center border-b-2 border-accent", this.inverted ? "text-white" : "text-black")}">${currentPage + 1}</span> <span part="pagination-divider" class="${cx("scale-y-[1.5]", "text-center", this.inverted ? "text-white" : "text-black")}">/</span> <span part="pagination-item" class="${cx("w-5 text-center", this.inverted ? "text-white" : "text-black")}">${pagesCount}</span></span>`} <button part="navigation-button navigation-button--next" id="carousel__navigation-button--next" ?disabled="${!nextEnabled ? true : false}" class="${cx(
|
|
293
|
+
"!ml-6 !rounded-sm sd-interactive ",
|
|
294
|
+
!nextEnabled && "sd-interactive--disabled",
|
|
295
|
+
this.inverted ? "sd-interactive--inverted" : "sd-interactive--reset"
|
|
296
|
+
)}" aria-label="${this.localize.term("nextSlide")}" aria-controls="scroll-container" aria-disabled="${nextEnabled ? "false" : "true"}" @click="${nextEnabled ? () => {
|
|
297
|
+
console.log("click-next");
|
|
298
|
+
this.next();
|
|
299
|
+
} : null}"><slot name="next-icon"><sd-1-18-1-icon class="${cx("h-6 w-6 rotate-90 grid place-items-center")}" library="system" name="${isLtr ? "chevron-up" : "chevron-down"}"></sd-1-18-1-icon></slot></button></div><button class="${cx(
|
|
300
|
+
"ml-6 !rounded-sm",
|
|
301
|
+
"!absolute !right-0 sd-interactive",
|
|
302
|
+
this.inverted ? "sd-interactive--inverted" : "sd-interactive--reset",
|
|
303
|
+
!this.autoplay && "!hidden"
|
|
304
|
+
)}" part="autoplay-controls" @click="${() => this.pausedAutoplay = !this.pausedAutoplay}"><slot name="autoplay-start" class="${cx(!this.pausedAutoplay ? "hidden" : "")}"><sd-1-18-1-icon class="h-6 w-6 grid place-items-center" library="system" name="start"></sd-1-18-1-icon></slot><slot name="autoplay-pause" class="${cx(this.pausedAutoplay ? "hidden" : "")}"><sd-1-18-1-icon class="h-6 w-6 grid place-items-center" library="system" name="pause"></sd-1-18-1-icon></slot></button></div></div>`;
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
SdCarousel.styles = [
|
|
308
|
+
SolidElement.styles,
|
|
309
|
+
unsafeCSS(InteractiveStyles),
|
|
310
|
+
css`${componentStyles}:host{--slide-gap:var(--sl-spacing-medium, 1rem);--scroll-hint:0px;display:flex}.carousel{grid-template-areas:'. slides .' '. pagination .'}.carousel__pagination{grid-area:pagination}.carousel__slides{grid-area:slides;scrollbar-width:none;--slide-size:calc((100% - (var(--slides-per-page) - 1) * var(--slide-gap)) / var(--slides-per-page));grid-auto-columns:var(--slide-size);column-gap:var(--slide-gap);scroll-padding-inline:var(--scroll-hint);padding-inline:var(--scroll-hint)}@media (prefers-reduced-motion){:where(.carousel__slides){scroll-behavior:auto}}.carousel__slides--dragging,.carousel__slides--dropping{scroll-snap-type:unset}.carousel__slides::-webkit-scrollbar{display:none}.carousel__navigation{grid-area:navigation}sd-1-18-1-button::part(label){display:flex;flex:1 1 auto;align-items:center;pointer-events:none}`
|
|
311
|
+
];
|
|
312
|
+
__decorateClass([
|
|
313
|
+
property({ type: String, reflect: true })
|
|
314
|
+
], SdCarousel.prototype, "variant", 2);
|
|
315
|
+
__decorateClass([
|
|
316
|
+
property({ type: Boolean, reflect: true })
|
|
317
|
+
], SdCarousel.prototype, "inverted", 2);
|
|
318
|
+
__decorateClass([
|
|
319
|
+
property({ type: Boolean, reflect: true })
|
|
320
|
+
], SdCarousel.prototype, "loop", 2);
|
|
321
|
+
__decorateClass([
|
|
322
|
+
property({ type: Boolean, reflect: true })
|
|
323
|
+
], SdCarousel.prototype, "autoplay", 2);
|
|
324
|
+
__decorateClass([
|
|
325
|
+
property({ type: Number, attribute: "slides-per-page" })
|
|
326
|
+
], SdCarousel.prototype, "slidesPerPage", 2);
|
|
327
|
+
__decorateClass([
|
|
328
|
+
property({ type: Number, attribute: "slides-per-move" })
|
|
329
|
+
], SdCarousel.prototype, "slidesPerMove", 2);
|
|
330
|
+
__decorateClass([
|
|
331
|
+
query("slot:not([name])")
|
|
332
|
+
], SdCarousel.prototype, "defaultSlot", 2);
|
|
333
|
+
__decorateClass([
|
|
334
|
+
query(".carousel__slides")
|
|
335
|
+
], SdCarousel.prototype, "scrollContainer", 2);
|
|
336
|
+
__decorateClass([
|
|
337
|
+
query(".carousel__pagination")
|
|
338
|
+
], SdCarousel.prototype, "paginationContainer", 2);
|
|
339
|
+
__decorateClass([
|
|
340
|
+
state()
|
|
341
|
+
], SdCarousel.prototype, "activeSlide", 2);
|
|
342
|
+
__decorateClass([
|
|
343
|
+
state()
|
|
344
|
+
], SdCarousel.prototype, "pausedAutoplay", 2);
|
|
345
|
+
__decorateClass([
|
|
346
|
+
watch("pausedAutoplay")
|
|
347
|
+
], SdCarousel.prototype, "handlePausedAutoplay", 1);
|
|
348
|
+
__decorateClass([
|
|
349
|
+
watch("loop", { waitUntilFirstUpdate: true }),
|
|
350
|
+
watch("slidesPerPage", { waitUntilFirstUpdate: true })
|
|
351
|
+
], SdCarousel.prototype, "initializeSlides", 1);
|
|
352
|
+
__decorateClass([
|
|
353
|
+
watch("activeSlide")
|
|
354
|
+
], SdCarousel.prototype, "handelSlideChange", 1);
|
|
355
|
+
__decorateClass([
|
|
356
|
+
watch("slidesPerMove")
|
|
357
|
+
], SdCarousel.prototype, "handleSlidesPerMoveChange", 1);
|
|
358
|
+
__decorateClass([
|
|
359
|
+
watch("autoplay")
|
|
360
|
+
], SdCarousel.prototype, "handleAutoplayChange", 1);
|
|
361
|
+
SdCarousel = __decorateClass([
|
|
362
|
+
customElement("sd-1-18-1-carousel")
|
|
363
|
+
], SdCarousel);
|
|
364
|
+
export {
|
|
365
|
+
SdCarousel as default
|
|
366
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveElement } from 'lit';
|
|
2
|
+
interface ScrollHost extends ReactiveElement {
|
|
3
|
+
scrollContainer: HTMLElement;
|
|
4
|
+
}
|
|
5
|
+
export declare class ScrollController<T extends ScrollHost> implements ReactiveController {
|
|
6
|
+
private host;
|
|
7
|
+
private pointers;
|
|
8
|
+
dragging: boolean;
|
|
9
|
+
scrolling: boolean;
|
|
10
|
+
mouseDragging: boolean;
|
|
11
|
+
constructor(host: T);
|
|
12
|
+
hostConnected(): Promise<void>;
|
|
13
|
+
hostDisconnected(): void;
|
|
14
|
+
handleScroll: () => void;
|
|
15
|
+
handleScrollEnd(): void;
|
|
16
|
+
handlePointerDown: (event: PointerEvent) => void;
|
|
17
|
+
handlePointerMove: (event: PointerEvent) => void;
|
|
18
|
+
handlePointerUp: (event: PointerEvent) => void;
|
|
19
|
+
handleTouchEnd: (event: TouchEvent) => void;
|
|
20
|
+
handleTouchStart: (event: TouchEvent) => void;
|
|
21
|
+
handleDragStart(): void;
|
|
22
|
+
handleDrag(event: PointerEvent): void;
|
|
23
|
+
handleDragEnd(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|