@orangesk/orange-design-system 3.12.0 → 3.13.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/build/components/index.js +1 -1
- package/build/components/index.js.map +1 -1
- package/build/lib/scripts.js +1 -1
- package/build/lib/scripts.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Carousel/Carousel.static.ts +0 -3
- package/src/components/Carousel/tests/Carousel.interactions.test.ts +116 -85
- package/src/components/CarouselHero/CarouselHero.static.ts +0 -3
- package/src/components/CarouselPromotions/CarouselPromotions.static.ts +0 -3
package/package.json
CHANGED
|
@@ -40,9 +40,6 @@ interface ExternalControlsState {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export const defaultConfig: SwiperOptions = {
|
|
43
|
-
// Keep pointer selection and click handlers available to CMS editors and integrations.
|
|
44
|
-
touchStartPreventDefault: false,
|
|
45
|
-
preventClicksPropagation: false,
|
|
46
43
|
navigation: {
|
|
47
44
|
nextEl: SELECTOR_NEXT,
|
|
48
45
|
prevEl: SELECTOR_PREV,
|
|
@@ -3,100 +3,131 @@ import CarouselHero from "../../CarouselHero/CarouselHero.static";
|
|
|
3
3
|
import CarouselPromotions from "../../CarouselPromotions/CarouselPromotions.static";
|
|
4
4
|
import Carousel from "../Carousel.static";
|
|
5
5
|
|
|
6
|
-
describe.each(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
describe.each(
|
|
7
|
+
[
|
|
8
|
+
{ name: "Carousel", Module: Carousel, prefix: "carousel" },
|
|
9
|
+
{ name: "CarouselHero", Module: CarouselHero, prefix: "carousel-hero" },
|
|
10
|
+
{
|
|
11
|
+
name: "CarouselPromotions",
|
|
12
|
+
Module: CarouselPromotions,
|
|
13
|
+
prefix: "carousel-promotions",
|
|
14
|
+
},
|
|
15
|
+
].flatMap((component) =>
|
|
16
|
+
["defaults", "data attribute", "constructor"].map((source) => ({
|
|
17
|
+
...component,
|
|
18
|
+
source,
|
|
19
|
+
editorMode: source !== "defaults",
|
|
20
|
+
})),
|
|
21
|
+
),
|
|
22
|
+
)(
|
|
23
|
+
"$name pointer interactions with real Swiper ($source)",
|
|
24
|
+
({ Module, prefix, source, editorMode }) => {
|
|
25
|
+
let carousel: Carousel | CarouselHero | CarouselPromotions;
|
|
26
|
+
let icon: SVGElement;
|
|
17
27
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
vi.useFakeTimers();
|
|
30
|
+
document.body.innerHTML = `<div class="${prefix}" data-${prefix}>
|
|
21
31
|
<div class="${prefix}__viewport-wrapper"><div class="${prefix}__viewport"><div class="${prefix}__track">
|
|
22
32
|
<div class="${prefix}__slide"><a href="#card"><svg><path d="M0 0h10v10z" /></svg></a></div>
|
|
23
33
|
<div class="${prefix}__slide">Second</div><div class="${prefix}__slide">Third</div>
|
|
24
34
|
</div></div></div>
|
|
25
35
|
</div>`;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
const element = document.body.firstElementChild as HTMLElement;
|
|
37
|
+
for (const node of [
|
|
38
|
+
element,
|
|
39
|
+
element.querySelector(`.${prefix}__viewport`)!,
|
|
40
|
+
]) {
|
|
41
|
+
Object.defineProperty(node, "clientWidth", { value: 600 });
|
|
42
|
+
Object.defineProperty(node, "clientHeight", { value: 200 });
|
|
43
|
+
}
|
|
44
|
+
const editorOptions = {
|
|
45
|
+
touchStartPreventDefault: false,
|
|
46
|
+
preventClicksPropagation: false,
|
|
47
|
+
};
|
|
48
|
+
if (source === "data attribute") {
|
|
49
|
+
element.setAttribute(
|
|
50
|
+
"data-swiper-options",
|
|
51
|
+
JSON.stringify(editorOptions),
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
carousel = new Module(element, {
|
|
55
|
+
loop: false,
|
|
56
|
+
breakpoints: {},
|
|
57
|
+
...(source === "constructor" ? editorOptions : {}),
|
|
58
|
+
});
|
|
59
|
+
vi.advanceTimersByTime(100);
|
|
60
|
+
icon = element.querySelector("path")!;
|
|
61
|
+
expect(carousel.instance.enabled).toBe(true);
|
|
62
|
+
});
|
|
46
63
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
clientY: 20,
|
|
53
|
-
button: 0,
|
|
64
|
+
afterEach(() => {
|
|
65
|
+
carousel?.destroy();
|
|
66
|
+
vi.clearAllTimers();
|
|
67
|
+
vi.useRealTimers();
|
|
68
|
+
document.body.innerHTML = "";
|
|
54
69
|
});
|
|
55
|
-
Object.assign(event, { pointerId: 1, pointerType });
|
|
56
|
-
icon.dispatchEvent(event);
|
|
57
|
-
return event;
|
|
58
|
-
}
|
|
59
70
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
function pointer(type: string, x: number, pointerType = "mouse") {
|
|
72
|
+
const event = new MouseEvent(type, {
|
|
73
|
+
bubbles: true,
|
|
74
|
+
cancelable: true,
|
|
75
|
+
clientX: x,
|
|
76
|
+
clientY: 20,
|
|
77
|
+
button: 0,
|
|
78
|
+
});
|
|
79
|
+
Object.assign(event, { pointerId: 1, pointerType });
|
|
80
|
+
icon.dispatchEvent(event);
|
|
81
|
+
return event;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
it.each(["mouse", "touch", "pen"])(
|
|
85
|
+
"applies the configured pointerdown behavior for %s",
|
|
86
|
+
(pointerType) => {
|
|
87
|
+
const onPointerDown = vi.fn();
|
|
88
|
+
carousel.element.addEventListener("pointerdown", onPointerDown);
|
|
89
|
+
const event = pointer("pointerdown", 400, pointerType);
|
|
90
|
+
expect(onPointerDown).toHaveBeenCalledOnce();
|
|
91
|
+
expect(event.defaultPrevented).toBe(!editorMode);
|
|
92
|
+
},
|
|
93
|
+
);
|
|
70
94
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
95
|
+
it("delivers an ordinary icon click without canceling it", () => {
|
|
96
|
+
const onClick = vi.fn();
|
|
97
|
+
carousel.element.addEventListener("click", onClick);
|
|
98
|
+
pointer("pointerdown", 400);
|
|
99
|
+
pointer("pointerup", 400);
|
|
100
|
+
const click = new MouseEvent("click", {
|
|
101
|
+
bubbles: true,
|
|
102
|
+
cancelable: true,
|
|
103
|
+
});
|
|
104
|
+
icon.dispatchEvent(click);
|
|
105
|
+
expect(onClick).toHaveBeenCalledOnce();
|
|
106
|
+
expect(click.defaultPrevented).toBe(false);
|
|
107
|
+
});
|
|
81
108
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
109
|
+
it("keeps swipe navigation and link protection with configured click propagation", () => {
|
|
110
|
+
const onIconClick = vi.fn();
|
|
111
|
+
const onClick = vi.fn();
|
|
112
|
+
icon.addEventListener("click", onIconClick);
|
|
113
|
+
carousel.element.addEventListener("click", onClick);
|
|
114
|
+
// The initial translation is zero; jsdom cannot parse CSS transforms with DOMMatrixReadOnly.
|
|
115
|
+
carousel.instance.wrapperEl.style.transform = "none";
|
|
116
|
+
pointer("pointerdown", 400);
|
|
117
|
+
pointer("pointermove", 350);
|
|
118
|
+
pointer("pointermove", 100);
|
|
119
|
+
pointer("pointerup", 100);
|
|
120
|
+
expect(carousel.instance.activeIndex).toBe(1);
|
|
121
|
+
expect(carousel.instance.animating).toBe(true);
|
|
95
122
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
123
|
+
const click = new MouseEvent("click", {
|
|
124
|
+
bubbles: true,
|
|
125
|
+
cancelable: true,
|
|
126
|
+
});
|
|
127
|
+
icon.dispatchEvent(click);
|
|
128
|
+
expect(onIconClick).toHaveBeenCalledTimes(editorMode ? 1 : 0);
|
|
129
|
+
expect(onClick).toHaveBeenCalledTimes(editorMode ? 1 : 0);
|
|
130
|
+
expect(click.defaultPrevented).toBe(true);
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
);
|
|
@@ -27,9 +27,6 @@ import {
|
|
|
27
27
|
} from "./constants";
|
|
28
28
|
|
|
29
29
|
export const defaultConfig: SwiperOptions = {
|
|
30
|
-
// Keep pointer selection and click handlers available to CMS editors and integrations.
|
|
31
|
-
touchStartPreventDefault: false,
|
|
32
|
-
preventClicksPropagation: false,
|
|
33
30
|
pagination: {
|
|
34
31
|
clickable: true,
|
|
35
32
|
bulletClass: CLASS_PAGINATION_ITEM,
|
|
@@ -22,9 +22,6 @@ import {
|
|
|
22
22
|
} from "./constants";
|
|
23
23
|
|
|
24
24
|
export const defaultConfig: SwiperOptions = {
|
|
25
|
-
// Keep pointer selection and click handlers available to CMS editors and integrations.
|
|
26
|
-
touchStartPreventDefault: false,
|
|
27
|
-
preventClicksPropagation: false,
|
|
28
25
|
pagination: {
|
|
29
26
|
el: SELECTOR_DOTS,
|
|
30
27
|
clickable: true,
|