@agencecinq/utils 4.0.0 → 4.0.2
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 +3 -3
- package/CHANGELOG.md +12 -0
- package/dist/events.d.ts +2 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/index.js +31 -29
- package/package.json +1 -1
- package/src/events.ts +2 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @agencecinq/utils@4.0.
|
|
3
|
+
> @agencecinq/utils@4.0.2 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
7
|
[2K[1Gtransforming (1) [2msrc/index.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.
|
|
10
|
+
[2K[1Gcomputing gzip size (0)...[2K[1Gcomputing gzip size (1)...[2K[1G[2mdist/[22m[36mindex.js [39m[1m[2m3.45 kB[22m[1m[22m[2m │ gzip: 1.58 kB[22m
|
|
11
11
|
[32m[36m[vite:dts][32m Declaration files built in 1450ms.
|
|
12
12
|
[39m
|
|
13
|
-
[32m✓ built in 1.
|
|
13
|
+
[32m✓ built in 1.64s[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @agencecinq/utils
|
|
2
2
|
|
|
3
|
+
## 4.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add `CART_BEFORE_ADD` event constant for batching extra items into a single `/cart/add.js` request. Listeners receive a mutable `items` array in `event.detail` and can push their own additions (e.g. free samples) before the AddToCart caller fires the request.
|
|
8
|
+
|
|
9
|
+
## 4.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 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).
|
|
14
|
+
|
|
3
15
|
## 4.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;;;;;;;;;;;CAWlB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,OAAO,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
const
|
|
1
|
+
const S = {
|
|
2
2
|
DRAWER_CLOSE: "drawer-close",
|
|
3
3
|
DRAWER_OPEN: "drawer-open",
|
|
4
4
|
DRAWER_TOGGLE: "drawer-toggle",
|
|
5
5
|
MODAL_CLOSE: "modal-close",
|
|
6
6
|
MODAL_OPEN: "modal-open",
|
|
7
7
|
MODAL_TOGGLE: "modal-toggle",
|
|
8
|
+
CART_BEFORE_ADD: "cart-before-add",
|
|
9
|
+
CART_BEFORE_UPDATE: "cart-before-update",
|
|
8
10
|
CART_UPDATE: "cart-update",
|
|
9
11
|
VARIANT_CHANGE: "variant-change"
|
|
10
12
|
}, f = (e, t) => {
|
|
@@ -15,7 +17,7 @@ const _ = {
|
|
|
15
17
|
return (...c) => {
|
|
16
18
|
r = c, o || (o = setTimeout(s, t));
|
|
17
19
|
};
|
|
18
|
-
}, l = document.documentElement, { body: i } = document,
|
|
20
|
+
}, l = document.documentElement, { body: i } = document, C = l.hasAttribute("data-debug"), n = {
|
|
19
21
|
y: 0,
|
|
20
22
|
x: 0
|
|
21
23
|
}, a = {
|
|
@@ -29,12 +31,12 @@ window.addEventListener(
|
|
|
29
31
|
}, 100),
|
|
30
32
|
{ passive: !0 }
|
|
31
33
|
);
|
|
32
|
-
const
|
|
34
|
+
const W = {
|
|
33
35
|
lg: window.matchMedia("(width >= 64rem)"),
|
|
34
36
|
xl: window.matchMedia("(min-width: 1280px)"),
|
|
35
37
|
"2xl": window.matchMedia("(min-width: 1440px)"),
|
|
36
38
|
"3xl": window.matchMedia("(min-width: 1920px)")
|
|
37
|
-
},
|
|
39
|
+
}, k = !0, u = (e, t) => {
|
|
38
40
|
typeof e < "u" && (n.x = e), typeof t < "u" && (n.y = t), window.scrollTo(n.x, n.y);
|
|
39
41
|
};
|
|
40
42
|
function M() {
|
|
@@ -46,10 +48,10 @@ function N(e = 0) {
|
|
|
46
48
|
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);
|
|
47
49
|
}
|
|
48
50
|
const d = {};
|
|
49
|
-
function
|
|
51
|
+
function E(e) {
|
|
50
52
|
return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
|
|
51
53
|
}
|
|
52
|
-
function
|
|
54
|
+
function m(e) {
|
|
53
55
|
if (!e) return [];
|
|
54
56
|
const t = [
|
|
55
57
|
"summary",
|
|
@@ -63,50 +65,50 @@ function y(e) {
|
|
|
63
65
|
"iframe",
|
|
64
66
|
"[contenteditable]"
|
|
65
67
|
].join(",");
|
|
66
|
-
return Array.from(e.querySelectorAll(t)).filter((o) =>
|
|
68
|
+
return Array.from(e.querySelectorAll(t)).filter((o) => E(o) && o.getAttribute("tabindex") !== "-1");
|
|
67
69
|
}
|
|
68
70
|
function G(e, t = e) {
|
|
69
|
-
const o =
|
|
71
|
+
const o = m(e);
|
|
70
72
|
if (o.length === 0) return;
|
|
71
73
|
const r = o[0], s = o[o.length - 1];
|
|
72
|
-
|
|
74
|
+
y(), d.keydown = (c) => {
|
|
73
75
|
c.key === "Tab" && (c.shiftKey ? (document.activeElement === r || document.activeElement === e) && (c.preventDefault(), s.focus()) : document.activeElement === s && (c.preventDefault(), r.focus()));
|
|
74
76
|
}, 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);
|
|
75
77
|
}
|
|
76
|
-
function
|
|
78
|
+
function y(e = null) {
|
|
77
79
|
d.keydown && document.removeEventListener("keydown", d.keydown), e && e.focus();
|
|
78
80
|
}
|
|
79
|
-
const p = 8, w = 9,
|
|
81
|
+
const p = 8, w = 9, A = 13, b = 16, h = 27, R = 32, g = 33, x = 34, T = 35, O = 36, P = 37, _ = 38, v = 39, D = 40, L = 46, H = {
|
|
80
82
|
BACKSPACE: p,
|
|
81
83
|
TAB: w,
|
|
82
|
-
ENTER:
|
|
83
|
-
SHIFT:
|
|
84
|
-
ESCAPE:
|
|
85
|
-
SPACE:
|
|
86
|
-
PAGE_UP:
|
|
87
|
-
PAGE_DOWN:
|
|
88
|
-
END:
|
|
89
|
-
HOME:
|
|
84
|
+
ENTER: A,
|
|
85
|
+
SHIFT: b,
|
|
86
|
+
ESCAPE: h,
|
|
87
|
+
SPACE: R,
|
|
88
|
+
PAGE_UP: g,
|
|
89
|
+
PAGE_DOWN: x,
|
|
90
|
+
END: T,
|
|
91
|
+
HOME: O,
|
|
90
92
|
ARROW_LEFT: P,
|
|
91
|
-
ARROW_UP:
|
|
92
|
-
ARROW_RIGHT:
|
|
93
|
-
ARROW_DOWN:
|
|
94
|
-
DELETE:
|
|
93
|
+
ARROW_UP: _,
|
|
94
|
+
ARROW_RIGHT: v,
|
|
95
|
+
ARROW_DOWN: D,
|
|
96
|
+
DELETE: L
|
|
95
97
|
};
|
|
96
98
|
export {
|
|
97
|
-
|
|
99
|
+
S as EVENTS,
|
|
98
100
|
G as addTrapFocus,
|
|
99
101
|
i as body,
|
|
100
|
-
|
|
102
|
+
W as breakpoints,
|
|
101
103
|
M as disableScroll,
|
|
102
104
|
N as enableScroll,
|
|
103
|
-
|
|
105
|
+
m as getFocusableElements,
|
|
104
106
|
l as html,
|
|
105
|
-
|
|
107
|
+
C as isDebug,
|
|
106
108
|
H as keycode,
|
|
107
109
|
a as mouse,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
k as production,
|
|
111
|
+
y as removeTrapFocus,
|
|
110
112
|
n as scroll,
|
|
111
113
|
f as throttle
|
|
112
114
|
};
|
package/package.json
CHANGED
package/src/events.ts
CHANGED
|
@@ -5,6 +5,8 @@ export const EVENTS = {
|
|
|
5
5
|
MODAL_CLOSE: 'modal-close',
|
|
6
6
|
MODAL_OPEN: 'modal-open',
|
|
7
7
|
MODAL_TOGGLE: 'modal-toggle',
|
|
8
|
+
CART_BEFORE_ADD: 'cart-before-add',
|
|
9
|
+
CART_BEFORE_UPDATE: 'cart-before-update',
|
|
8
10
|
CART_UPDATE: 'cart-update',
|
|
9
11
|
VARIANT_CHANGE: 'variant-change',
|
|
10
12
|
};
|