@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orangesk/orange-design-system",
3
- "version": "3.12.0",
3
+ "version": "3.13.0",
4
4
  "private": false,
5
5
  "engines": {
6
6
  "node": ">=20.x"
@@ -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
- { name: "Carousel", Module: Carousel, prefix: "carousel" },
8
- { name: "CarouselHero", Module: CarouselHero, prefix: "carousel-hero" },
9
- {
10
- name: "CarouselPromotions",
11
- Module: CarouselPromotions,
12
- prefix: "carousel-promotions",
13
- },
14
- ])("$name pointer interactions with real Swiper", ({ Module, prefix }) => {
15
- let carousel: Carousel | CarouselHero | CarouselPromotions;
16
- let icon: SVGElement;
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
- beforeEach(() => {
19
- vi.useFakeTimers();
20
- document.body.innerHTML = `<div class="${prefix}" data-${prefix}>
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
- const element = document.body.firstElementChild as HTMLElement;
27
- for (const node of [
28
- element,
29
- element.querySelector(`.${prefix}__viewport`)!,
30
- ]) {
31
- Object.defineProperty(node, "clientWidth", { value: 600 });
32
- Object.defineProperty(node, "clientHeight", { value: 200 });
33
- }
34
- carousel = new Module(element, { loop: false, breakpoints: {} });
35
- vi.advanceTimersByTime(100);
36
- icon = element.querySelector("path")!;
37
- expect(carousel.instance.enabled).toBe(true);
38
- });
39
-
40
- afterEach(() => {
41
- carousel?.destroy();
42
- vi.clearAllTimers();
43
- vi.useRealTimers();
44
- document.body.innerHTML = "";
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
- function pointer(type: string, x: number, pointerType = "mouse") {
48
- const event = new MouseEvent(type, {
49
- bubbles: true,
50
- cancelable: true,
51
- clientX: x,
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
- it.each(["mouse", "touch", "pen"])(
61
- "allows SVG icon selection with %s without canceling pointerdown",
62
- (pointerType) => {
63
- const onPointerDown = vi.fn();
64
- carousel.element.addEventListener("pointerdown", onPointerDown);
65
- const event = pointer("pointerdown", 400, pointerType);
66
- expect(onPointerDown).toHaveBeenCalledOnce();
67
- expect(event.defaultPrevented).toBe(false);
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
- it("delivers an ordinary icon click without canceling it", () => {
72
- const onClick = vi.fn();
73
- carousel.element.addEventListener("click", onClick);
74
- pointer("pointerdown", 400);
75
- pointer("pointerup", 400);
76
- const click = new MouseEvent("click", { bubbles: true, cancelable: true });
77
- icon.dispatchEvent(click);
78
- expect(onClick).toHaveBeenCalledOnce();
79
- expect(click.defaultPrevented).toBe(false);
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
- it("keeps swipe navigation and link protection while letting click handlers run", () => {
83
- const onIconClick = vi.fn();
84
- const onClick = vi.fn();
85
- icon.addEventListener("click", onIconClick);
86
- carousel.element.addEventListener("click", onClick);
87
- // The initial translation is zero; jsdom cannot parse CSS transforms with DOMMatrixReadOnly.
88
- carousel.instance.wrapperEl.style.transform = "none";
89
- pointer("pointerdown", 400);
90
- pointer("pointermove", 350);
91
- pointer("pointermove", 100);
92
- pointer("pointerup", 100);
93
- expect(carousel.instance.activeIndex).toBe(1);
94
- expect(carousel.instance.animating).toBe(true);
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
- const click = new MouseEvent("click", { bubbles: true, cancelable: true });
97
- icon.dispatchEvent(click);
98
- expect(onIconClick).toHaveBeenCalledOnce();
99
- expect(onClick).toHaveBeenCalledOnce();
100
- expect(click.defaultPrevented).toBe(true);
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,