@agencecinq/utils 4.0.1 → 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.1 build /Users/19h47/Sites/agencecinq-ui/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
- transforming (1) src/index.tstransforming (5) src/scroll.ts✓ 7 modules transformed.
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.41 kB │ gzip: 1.57 kB
11
- [vite:dts] Declaration files built in 1952ms.
10
+ computing gzip size (0)...computing gzip size (1)...dist/index.js 3.45 kB │ gzip: 1.58 kB
11
+ [vite:dts] Declaration files built in 1450ms.
12
12
  
13
- ✓ built in 2.35s
13
+ ✓ built in 1.64s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
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
+
3
9
  ## 4.0.1
4
10
 
5
11
  ### Patch Changes
package/dist/events.d.ts CHANGED
@@ -5,6 +5,7 @@ export declare const EVENTS: {
5
5
  MODAL_CLOSE: string;
6
6
  MODAL_OPEN: string;
7
7
  MODAL_TOGGLE: string;
8
+ CART_BEFORE_ADD: string;
8
9
  CART_BEFORE_UPDATE: string;
9
10
  CART_UPDATE: string;
10
11
  VARIANT_CHANGE: string;
@@ -1 +1 @@
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"}
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,11 @@
1
- const D = {
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",
8
9
  CART_BEFORE_UPDATE: "cart-before-update",
9
10
  CART_UPDATE: "cart-update",
10
11
  VARIANT_CHANGE: "variant-change"
@@ -47,10 +48,10 @@ function N(e = 0) {
47
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);
48
49
  }
49
50
  const d = {};
50
- function m(e) {
51
+ function E(e) {
51
52
  return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
52
53
  }
53
- function y(e) {
54
+ function m(e) {
54
55
  if (!e) return [];
55
56
  const t = [
56
57
  "summary",
@@ -64,50 +65,50 @@ function y(e) {
64
65
  "iframe",
65
66
  "[contenteditable]"
66
67
  ].join(",");
67
- 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");
68
69
  }
69
70
  function G(e, t = e) {
70
- const o = y(e);
71
+ const o = m(e);
71
72
  if (o.length === 0) return;
72
73
  const r = o[0], s = o[o.length - 1];
73
- E(), d.keydown = (c) => {
74
+ y(), d.keydown = (c) => {
74
75
  c.key === "Tab" && (c.shiftKey ? (document.activeElement === r || document.activeElement === e) && (c.preventDefault(), s.focus()) : document.activeElement === s && (c.preventDefault(), r.focus()));
75
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);
76
77
  }
77
- function E(e = null) {
78
+ function y(e = null) {
78
79
  d.keydown && document.removeEventListener("keydown", d.keydown), e && e.focus();
79
80
  }
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 = {
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 = {
81
82
  BACKSPACE: p,
82
83
  TAB: w,
83
84
  ENTER: A,
84
- SHIFT: h,
85
- ESCAPE: b,
86
- SPACE: g,
87
- PAGE_UP: R,
85
+ SHIFT: b,
86
+ ESCAPE: h,
87
+ SPACE: R,
88
+ PAGE_UP: g,
88
89
  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,
95
- DELETE: _
90
+ END: T,
91
+ HOME: O,
92
+ ARROW_LEFT: P,
93
+ ARROW_UP: _,
94
+ ARROW_RIGHT: v,
95
+ ARROW_DOWN: D,
96
+ DELETE: L
96
97
  };
97
98
  export {
98
- D as EVENTS,
99
+ S as EVENTS,
99
100
  G as addTrapFocus,
100
101
  i as body,
101
102
  W as breakpoints,
102
103
  M as disableScroll,
103
104
  N as enableScroll,
104
- y as getFocusableElements,
105
+ m as getFocusableElements,
105
106
  l as html,
106
107
  C as isDebug,
107
108
  H as keycode,
108
109
  a as mouse,
109
110
  k as production,
110
- E as removeTrapFocus,
111
+ y as removeTrapFocus,
111
112
  n as scroll,
112
113
  f as throttle
113
114
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agencecinq/utils",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
package/src/events.ts CHANGED
@@ -5,6 +5,7 @@ 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',
8
9
  CART_BEFORE_UPDATE: 'cart-before-update',
9
10
  CART_UPDATE: 'cart-update',
10
11
  VARIANT_CHANGE: 'variant-change',