@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.
@@ -1,13 +1,13 @@
1
1
 
2
2
  
3
- > @agencecinq/utils@4.0.0 build /Users/19h47/Sites/agencecinq-shopify/packages/utils
3
+ > @agencecinq/utils@4.0.2 build /Users/19h47/Sites/agencecinq-ui/packages/utils
4
4
  > vite build
5
5
 
6
6
  vite v7.3.1 building client environment for production...
7
7
  transforming (1) src/index.ts✓ 7 modules transformed.
8
8
  rendering chunks (1)...
9
9
  [vite:dts] Start generate declaration files...
10
- computing gzip size (0)...computing gzip size (1)...dist/index.js 3.37 kB │ gzip: 1.55 kB
10
+ computing gzip size (0)...computing gzip size (1)...dist/index.js 3.45 kB │ gzip: 1.58 kB
11
11
  [vite:dts] Declaration files built in 1450ms.
12
12
  
13
- ✓ built in 1.62s
13
+ ✓ built in 1.64s
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
@@ -5,6 +5,8 @@ export declare const EVENTS: {
5
5
  MODAL_CLOSE: string;
6
6
  MODAL_OPEN: string;
7
7
  MODAL_TOGGLE: string;
8
+ CART_BEFORE_ADD: string;
9
+ CART_BEFORE_UPDATE: string;
8
10
  CART_UPDATE: string;
9
11
  VARIANT_CHANGE: string;
10
12
  };
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;CASlB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,OAAO,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC"}
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, W = l.hasAttribute("data-debug"), n = {
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 k = {
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
- }, C = !0, u = (e, t) => {
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 m(e) {
51
+ function E(e) {
50
52
  return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
51
53
  }
52
- function y(e) {
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) => m(o) && o.getAttribute("tabindex") !== "-1");
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 = y(e);
71
+ const o = m(e);
70
72
  if (o.length === 0) return;
71
73
  const r = o[0], s = o[o.length - 1];
72
- E(), d.keydown = (c) => {
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 E(e = null) {
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, h = 13, A = 16, b = 27, g = 32, x = 33, R = 34, v = 35, L = 36, P = 37, O = 38, S = 39, T = 40, D = 46, H = {
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: h,
83
- SHIFT: A,
84
- ESCAPE: b,
85
- SPACE: g,
86
- PAGE_UP: x,
87
- PAGE_DOWN: R,
88
- END: v,
89
- HOME: L,
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: O,
92
- ARROW_RIGHT: S,
93
- ARROW_DOWN: T,
94
- DELETE: D
93
+ ARROW_UP: _,
94
+ ARROW_RIGHT: v,
95
+ ARROW_DOWN: D,
96
+ DELETE: L
95
97
  };
96
98
  export {
97
- _ as EVENTS,
99
+ S as EVENTS,
98
100
  G as addTrapFocus,
99
101
  i as body,
100
- k as breakpoints,
102
+ W as breakpoints,
101
103
  M as disableScroll,
102
104
  N as enableScroll,
103
- y as getFocusableElements,
105
+ m as getFocusableElements,
104
106
  l as html,
105
- W as isDebug,
107
+ C as isDebug,
106
108
  H as keycode,
107
109
  a as mouse,
108
- C as production,
109
- E as removeTrapFocus,
110
+ k as production,
111
+ y as removeTrapFocus,
110
112
  n as scroll,
111
113
  f as throttle
112
114
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agencecinq/utils",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
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
  };