@agencecinq/utils 3.0.0 → 4.0.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/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +12 -0
- package/dist/events.d.ts +4 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/focus-trap.d.ts.map +1 -1
- package/dist/index.js +51 -47
- package/package.json +1 -1
- package/src/events.ts +4 -0
- package/src/focus-trap.ts +1 -9
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @agencecinq/utils@
|
|
3
|
+
> @agencecinq/utils@4.0.1 build /Users/19h47/Sites/agencecinq-ui/packages/utils
|
|
4
4
|
> vite build
|
|
5
5
|
|
|
6
6
|
[36mvite v7.3.1 [32mbuilding client environment for production...[36m[39m
|
|
7
|
-
[2K[1Gtransforming (1) [2msrc/index.ts[22m[2K[1Gtransforming (
|
|
7
|
+
[2K[1Gtransforming (1) [2msrc/index.ts[22m[2K[1Gtransforming (5) [2msrc/scroll.ts[22m[2K[1G[32m✓[39m 7 modules transformed.
|
|
8
8
|
[2K[1Grendering chunks (1)...[2K[1G[32m
|
|
9
9
|
[36m[vite:dts][32m Start generate declaration files...[39m
|
|
10
|
-
[2K[1Gcomputing gzip size (0)...[2K[1Gcomputing gzip size (1)...[2K[1G[2mdist/[22m[36mindex.js [39m[1m[2m3.
|
|
11
|
-
[32m[36m[vite:dts][32m Declaration files built in
|
|
10
|
+
[2K[1Gcomputing gzip size (0)...[2K[1Gcomputing gzip size (1)...[2K[1G[2mdist/[22m[36mindex.js [39m[1m[2m3.41 kB[22m[1m[22m[2m │ gzip: 1.57 kB[22m
|
|
11
|
+
[32m[36m[vite:dts][32m Declaration files built in 1952ms.
|
|
12
12
|
[39m
|
|
13
|
-
[32m✓ built in
|
|
13
|
+
[32m✓ built in 2.35s[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @agencecinq/utils
|
|
2
2
|
|
|
3
|
+
## 4.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add `CART_BEFORE_UPDATE` event constant to coordinate cart pre-update flows. Listeners can call `event.preventDefault()` on the dispatched `CustomEvent` to take ownership of subsequent section rendering (e.g. a free-samples controller batching its own sync into a single render).
|
|
8
|
+
|
|
9
|
+
## 4.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- Create a new package in @agencecinq/shopify
|
|
14
|
+
|
|
3
15
|
## 3.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
package/dist/events.d.ts
CHANGED
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;CAUlB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,OAAO,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC"}
|
package/dist/focus-trap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus-trap.d.ts","sourceRoot":"","sources":["../src/focus-trap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"focus-trap.d.ts","sourceRoot":"","sources":["../src/focus-trap.ts"],"names":[],"mappings":"AAUA,iBAAS,oBAAoB,CAAC,SAAS,EAAE,WAAW,GAAG,WAAW,EAAE,CAkBnE;AAED,iBAAS,YAAY,CAAC,SAAS,EAAE,WAAW,EAAE,cAAc,GAAE,WAAuB,GAAG,IAAI,CAoC3F;AAED,iBAAS,eAAe,CAAC,cAAc,GAAE,WAAW,GAAG,IAAW,GAAG,IAAI,CAQxE;AAED,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
const
|
|
1
|
+
const D = {
|
|
2
2
|
DRAWER_CLOSE: "drawer-close",
|
|
3
3
|
DRAWER_OPEN: "drawer-open",
|
|
4
4
|
DRAWER_TOGGLE: "drawer-toggle",
|
|
5
|
+
MODAL_CLOSE: "modal-close",
|
|
6
|
+
MODAL_OPEN: "modal-open",
|
|
7
|
+
MODAL_TOGGLE: "modal-toggle",
|
|
8
|
+
CART_BEFORE_UPDATE: "cart-before-update",
|
|
5
9
|
CART_UPDATE: "cart-update",
|
|
6
10
|
VARIANT_CHANGE: "variant-change"
|
|
7
11
|
}, f = (e, t) => {
|
|
8
|
-
let
|
|
12
|
+
let o = null, r = null;
|
|
9
13
|
const s = () => {
|
|
10
|
-
r && e(...r),
|
|
14
|
+
r && e(...r), o = null;
|
|
11
15
|
};
|
|
12
16
|
return (...c) => {
|
|
13
|
-
r = c,
|
|
17
|
+
r = c, o || (o = setTimeout(s, t));
|
|
14
18
|
};
|
|
15
|
-
}, l = document.documentElement, { body:
|
|
19
|
+
}, l = document.documentElement, { body: i } = document, C = l.hasAttribute("data-debug"), n = {
|
|
16
20
|
y: 0,
|
|
17
21
|
x: 0
|
|
18
22
|
}, a = {
|
|
@@ -26,27 +30,27 @@ window.addEventListener(
|
|
|
26
30
|
}, 100),
|
|
27
31
|
{ passive: !0 }
|
|
28
32
|
);
|
|
29
|
-
const
|
|
33
|
+
const W = {
|
|
30
34
|
lg: window.matchMedia("(width >= 64rem)"),
|
|
31
35
|
xl: window.matchMedia("(min-width: 1280px)"),
|
|
32
36
|
"2xl": window.matchMedia("(min-width: 1440px)"),
|
|
33
37
|
"3xl": window.matchMedia("(min-width: 1920px)")
|
|
34
|
-
},
|
|
35
|
-
typeof e < "u" && (
|
|
38
|
+
}, k = !0, u = (e, t) => {
|
|
39
|
+
typeof e < "u" && (n.x = e), typeof t < "u" && (n.y = t), window.scrollTo(n.x, n.y);
|
|
36
40
|
};
|
|
37
|
-
function
|
|
38
|
-
const e = l.scrollLeft, t = l.scrollTop,
|
|
39
|
-
|
|
41
|
+
function M() {
|
|
42
|
+
const e = l.scrollLeft, t = l.scrollTop, o = i.scrollLeft, r = i.scrollTop;
|
|
43
|
+
n.x = window.scrollX || e || o, n.y = window.scrollY || t || r || 0, l.style.setProperty("overflow", "hidden"), l.style.setProperty("height", "100%"), l.style.setProperty("scroll-padding-top", "0px"), u(n.x, n.y);
|
|
40
44
|
}
|
|
41
|
-
function
|
|
42
|
-
let t = !0,
|
|
43
|
-
typeof e == "number" ?
|
|
45
|
+
function N(e = 0) {
|
|
46
|
+
let t = !0, o = n.y;
|
|
47
|
+
typeof e == "number" ? o = e : typeof e == "boolean" && e === !1 && (t = !1), l.style.removeProperty("overflow"), l.style.removeProperty("height"), l.style.removeProperty("scroll-padding-top"), t && u(n.x, o);
|
|
44
48
|
}
|
|
45
|
-
const
|
|
46
|
-
function
|
|
49
|
+
const d = {};
|
|
50
|
+
function m(e) {
|
|
47
51
|
return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
|
|
48
52
|
}
|
|
49
|
-
function
|
|
53
|
+
function y(e) {
|
|
50
54
|
if (!e) return [];
|
|
51
55
|
const t = [
|
|
52
56
|
"summary",
|
|
@@ -60,50 +64,50 @@ function m(e) {
|
|
|
60
64
|
"iframe",
|
|
61
65
|
"[contenteditable]"
|
|
62
66
|
].join(",");
|
|
63
|
-
return Array.from(e.querySelectorAll(t)).filter((
|
|
67
|
+
return Array.from(e.querySelectorAll(t)).filter((o) => m(o) && o.getAttribute("tabindex") !== "-1");
|
|
64
68
|
}
|
|
65
69
|
function G(e, t = e) {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
const r =
|
|
69
|
-
E(),
|
|
70
|
+
const o = y(e);
|
|
71
|
+
if (o.length === 0) return;
|
|
72
|
+
const r = o[0], s = o[o.length - 1];
|
|
73
|
+
E(), d.keydown = (c) => {
|
|
70
74
|
c.key === "Tab" && (c.shiftKey ? (document.activeElement === r || document.activeElement === e) && (c.preventDefault(), s.focus()) : document.activeElement === s && (c.preventDefault(), r.focus()));
|
|
71
|
-
}, document.addEventListener("keydown",
|
|
75
|
+
}, document.addEventListener("keydown", d.keydown), t.focus(), t instanceof HTMLInputElement && ["search", "text", "email", "url"].includes(t.type) && t.value && t.setSelectionRange(0, t.value.length);
|
|
72
76
|
}
|
|
73
77
|
function E(e = null) {
|
|
74
|
-
|
|
78
|
+
d.keydown && document.removeEventListener("keydown", d.keydown), e && e.focus();
|
|
75
79
|
}
|
|
76
|
-
const p = 8, w = 9,
|
|
80
|
+
const p = 8, w = 9, A = 13, h = 16, b = 27, g = 32, R = 33, x = 34, P = 35, T = 36, v = 37, L = 38, O = 39, S = 40, _ = 46, H = {
|
|
77
81
|
BACKSPACE: p,
|
|
78
82
|
TAB: w,
|
|
79
|
-
ENTER:
|
|
80
|
-
SHIFT:
|
|
81
|
-
ESCAPE:
|
|
82
|
-
SPACE:
|
|
83
|
-
PAGE_UP:
|
|
84
|
-
PAGE_DOWN:
|
|
85
|
-
END:
|
|
86
|
-
HOME:
|
|
87
|
-
ARROW_LEFT:
|
|
88
|
-
ARROW_UP:
|
|
89
|
-
ARROW_RIGHT:
|
|
90
|
-
ARROW_DOWN:
|
|
83
|
+
ENTER: A,
|
|
84
|
+
SHIFT: h,
|
|
85
|
+
ESCAPE: b,
|
|
86
|
+
SPACE: g,
|
|
87
|
+
PAGE_UP: R,
|
|
88
|
+
PAGE_DOWN: x,
|
|
89
|
+
END: P,
|
|
90
|
+
HOME: T,
|
|
91
|
+
ARROW_LEFT: v,
|
|
92
|
+
ARROW_UP: L,
|
|
93
|
+
ARROW_RIGHT: O,
|
|
94
|
+
ARROW_DOWN: S,
|
|
91
95
|
DELETE: _
|
|
92
96
|
};
|
|
93
97
|
export {
|
|
94
|
-
|
|
98
|
+
D as EVENTS,
|
|
95
99
|
G as addTrapFocus,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
i as body,
|
|
101
|
+
W as breakpoints,
|
|
102
|
+
M as disableScroll,
|
|
103
|
+
N as enableScroll,
|
|
104
|
+
y as getFocusableElements,
|
|
101
105
|
l as html,
|
|
102
|
-
|
|
103
|
-
|
|
106
|
+
C as isDebug,
|
|
107
|
+
H as keycode,
|
|
104
108
|
a as mouse,
|
|
105
|
-
|
|
109
|
+
k as production,
|
|
106
110
|
E as removeTrapFocus,
|
|
107
|
-
|
|
111
|
+
n as scroll,
|
|
108
112
|
f as throttle
|
|
109
113
|
};
|
package/package.json
CHANGED
package/src/events.ts
CHANGED
|
@@ -2,6 +2,10 @@ export const EVENTS = {
|
|
|
2
2
|
DRAWER_CLOSE: 'drawer-close',
|
|
3
3
|
DRAWER_OPEN: 'drawer-open',
|
|
4
4
|
DRAWER_TOGGLE: 'drawer-toggle',
|
|
5
|
+
MODAL_CLOSE: 'modal-close',
|
|
6
|
+
MODAL_OPEN: 'modal-open',
|
|
7
|
+
MODAL_TOGGLE: 'modal-toggle',
|
|
8
|
+
CART_BEFORE_UPDATE: 'cart-before-update',
|
|
5
9
|
CART_UPDATE: 'cart-update',
|
|
6
10
|
VARIANT_CHANGE: 'variant-change',
|
|
7
11
|
};
|
package/src/focus-trap.ts
CHANGED
|
@@ -4,9 +4,6 @@ const trapFocusHandlers: {
|
|
|
4
4
|
keydown?: (event: KeyboardEvent) => void;
|
|
5
5
|
} = {};
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Filtre les éléments réellement visibles et focalisables
|
|
9
|
-
*/
|
|
10
7
|
function isVisible(el: HTMLElement): boolean {
|
|
11
8
|
return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
|
|
12
9
|
}
|
|
@@ -38,20 +35,17 @@ function addTrapFocus(container: HTMLElement, elementToFocus: HTMLElement = cont
|
|
|
38
35
|
const first = elements[0];
|
|
39
36
|
const last = elements[elements.length - 1];
|
|
40
37
|
|
|
41
|
-
// Nettoyage avant d'ajouter (pour éviter les doublons)
|
|
42
38
|
removeTrapFocus();
|
|
43
39
|
|
|
44
40
|
trapFocusHandlers.keydown = (event: KeyboardEvent): void => {
|
|
45
41
|
if (event.key !== 'Tab') return;
|
|
46
42
|
|
|
47
43
|
if (event.shiftKey) {
|
|
48
|
-
// Tab arrière
|
|
49
44
|
if (document.activeElement === first || document.activeElement === container) {
|
|
50
45
|
event.preventDefault();
|
|
51
46
|
last.focus();
|
|
52
47
|
}
|
|
53
48
|
} else {
|
|
54
|
-
// Tab avant
|
|
55
49
|
if (document.activeElement === last) {
|
|
56
50
|
event.preventDefault();
|
|
57
51
|
first.focus();
|
|
@@ -61,10 +55,8 @@ function addTrapFocus(container: HTMLElement, elementToFocus: HTMLElement = cont
|
|
|
61
55
|
|
|
62
56
|
document.addEventListener('keydown', trapFocusHandlers.keydown);
|
|
63
57
|
|
|
64
|
-
// Focus initial
|
|
65
58
|
elementToFocus.focus();
|
|
66
59
|
|
|
67
|
-
// Support spécifique pour les inputs texte (sélection du contenu)
|
|
68
60
|
if (
|
|
69
61
|
elementToFocus instanceof HTMLInputElement &&
|
|
70
62
|
['search', 'text', 'email', 'url'].includes(elementToFocus.type) &&
|
|
@@ -84,4 +76,4 @@ function removeTrapFocus(elementToFocus: HTMLElement | null = null): void {
|
|
|
84
76
|
}
|
|
85
77
|
}
|
|
86
78
|
|
|
87
|
-
export { addTrapFocus, removeTrapFocus, getFocusableElements };
|
|
79
|
+
export { addTrapFocus, removeTrapFocus, getFocusableElements };
|