@agencecinq/utils 4.0.2 → 5.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.
@@ -1,13 +1,13 @@
1
1
 
2
2
  
3
- > @agencecinq/utils@4.0.2 build /Users/19h47/Sites/agencecinq-ui/packages/utils
3
+ > @agencecinq/utils@5.0.0 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.ts✓ 7 modules transformed.
7
+ transforming (1) src/index.ts✓ 8 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.45 kB │ gzip: 1.58 kB
11
- [vite:dts] Declaration files built in 1450ms.
10
+ computing gzip size (0)...computing gzip size (1)...dist/index.js 3.66 kB │ gzip: 1.66 kB
11
+ [vite:dts] Declaration files built in 1458ms.
12
12
  
13
- ✓ built in 1.64s
13
+ ✓ built in 1.65s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @agencecinq/utils
2
2
 
3
+ ## 5.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 3594668: Spinbutton package
8
+
3
9
  ## 4.0.2
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Clamps a number between a minimum and a maximum value.
3
+ *
4
+ * @example
5
+ * clamp(10, 1, 5); // 5
6
+ * clamp(-1, 0, 10); // 0
7
+ * clamp(7, 3, 9); // 7
8
+ */
9
+ export declare const clamp: (value: number, min: number, max: number) => number;
10
+ //# sourceMappingURL=clamp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clamp.d.ts","sourceRoot":"","sources":["../src/clamp.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,MAC3B,CAAC"}
package/dist/events.d.ts CHANGED
@@ -5,6 +5,10 @@ export declare const EVENTS: {
5
5
  MODAL_CLOSE: string;
6
6
  MODAL_OPEN: string;
7
7
  MODAL_TOGGLE: string;
8
+ SPINBUTTON_CHANGE: string;
9
+ TAB_BEFORE_ACTIVATE: string;
10
+ TAB_ACTIVATE: string;
11
+ TAB_DELETE: string;
8
12
  CART_BEFORE_ADD: string;
9
13
  CART_BEFORE_UPDATE: string;
10
14
  CART_UPDATE: string;
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;CAelB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,OAAO,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- export * from './events';
2
- export * from './scroll';
3
- export * from './throttle';
4
- export * from './environment';
5
- export * from './focus-trap';
6
- export * from './keycode';
1
+ export * from './events.js';
2
+ export * from './scroll.js';
3
+ export * from './throttle.js';
4
+ export * from './environment.js';
5
+ export * from './focus-trap.js';
6
+ export * from './keycode.js';
7
+ export * from './clamp.js';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -5,49 +5,53 @@ const S = {
5
5
  MODAL_CLOSE: "modal-close",
6
6
  MODAL_OPEN: "modal-open",
7
7
  MODAL_TOGGLE: "modal-toggle",
8
+ SPINBUTTON_CHANGE: "spinbutton-change",
9
+ TAB_BEFORE_ACTIVATE: "tab-before-activate",
10
+ TAB_ACTIVATE: "tab-activate",
11
+ TAB_DELETE: "tab-delete",
8
12
  CART_BEFORE_ADD: "cart-before-add",
9
13
  CART_BEFORE_UPDATE: "cart-before-update",
10
14
  CART_UPDATE: "cart-update",
11
15
  VARIANT_CHANGE: "variant-change"
12
16
  }, f = (e, t) => {
13
- let o = null, r = null;
17
+ let o = null, c = null;
14
18
  const s = () => {
15
- r && e(...r), o = null;
19
+ c && e(...c), o = null;
16
20
  };
17
- return (...c) => {
18
- r = c, o || (o = setTimeout(s, t));
21
+ return (...r) => {
22
+ c = r, o || (o = setTimeout(s, t));
19
23
  };
20
- }, l = document.documentElement, { body: i } = document, C = l.hasAttribute("data-debug"), n = {
24
+ }, l = document.documentElement, { body: d } = document, C = l.hasAttribute("data-debug"), n = {
21
25
  y: 0,
22
26
  x: 0
23
- }, a = {
27
+ }, i = {
24
28
  x: 0,
25
29
  y: 0
26
30
  };
27
31
  window.addEventListener(
28
32
  "pointermove",
29
33
  f(({ x: e, y: t }) => {
30
- a.x = e, a.y = t;
34
+ i.x = e, i.y = t;
31
35
  }, 100),
32
36
  { passive: !0 }
33
37
  );
34
- const W = {
38
+ const N = {
35
39
  lg: window.matchMedia("(width >= 64rem)"),
36
40
  xl: window.matchMedia("(min-width: 1280px)"),
37
41
  "2xl": window.matchMedia("(min-width: 1440px)"),
38
42
  "3xl": window.matchMedia("(min-width: 1920px)")
39
- }, k = !0, u = (e, t) => {
43
+ }, M = !0, u = (e, t) => {
40
44
  typeof e < "u" && (n.x = e), typeof t < "u" && (n.y = t), window.scrollTo(n.x, n.y);
41
45
  };
42
- function M() {
43
- const e = l.scrollLeft, t = l.scrollTop, o = i.scrollLeft, r = i.scrollTop;
44
- 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);
46
+ function W() {
47
+ const e = l.scrollLeft, t = l.scrollTop, o = d.scrollLeft, c = d.scrollTop;
48
+ n.x = window.scrollX || e || o, n.y = window.scrollY || t || c || 0, l.style.setProperty("overflow", "hidden"), l.style.setProperty("height", "100%"), l.style.setProperty("scroll-padding-top", "0px"), u(n.x, n.y);
45
49
  }
46
- function N(e = 0) {
50
+ function k(e = 0) {
47
51
  let t = !0, o = n.y;
48
52
  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);
49
53
  }
50
- const d = {};
54
+ const a = {};
51
55
  function E(e) {
52
56
  return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
53
57
  }
@@ -67,47 +71,48 @@ function m(e) {
67
71
  ].join(",");
68
72
  return Array.from(e.querySelectorAll(t)).filter((o) => E(o) && o.getAttribute("tabindex") !== "-1");
69
73
  }
70
- function G(e, t = e) {
74
+ function B(e, t = e) {
71
75
  const o = m(e);
72
76
  if (o.length === 0) return;
73
- const r = o[0], s = o[o.length - 1];
74
- y(), d.keydown = (c) => {
75
- c.key === "Tab" && (c.shiftKey ? (document.activeElement === r || document.activeElement === e) && (c.preventDefault(), s.focus()) : document.activeElement === s && (c.preventDefault(), r.focus()));
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);
77
+ const c = o[0], s = o[o.length - 1];
78
+ y(), a.keydown = (r) => {
79
+ r.key === "Tab" && (r.shiftKey ? (document.activeElement === c || document.activeElement === e) && (r.preventDefault(), s.focus()) : document.activeElement === s && (r.preventDefault(), c.focus()));
80
+ }, document.addEventListener("keydown", a.keydown), t.focus(), t instanceof HTMLInputElement && ["search", "text", "email", "url"].includes(t.type) && t.value && t.setSelectionRange(0, t.value.length);
77
81
  }
78
82
  function y(e = null) {
79
- d.keydown && document.removeEventListener("keydown", d.keydown), e && e.focus();
83
+ a.keydown && document.removeEventListener("keydown", a.keydown), e && e.focus();
80
84
  }
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 = {
82
- BACKSPACE: p,
83
- TAB: w,
84
- ENTER: A,
85
- SHIFT: b,
85
+ const A = 8, p = 9, b = 13, w = 16, h = 27, T = 32, R = 33, g = 34, _ = 35, x = 36, O = 37, v = 38, P = 39, D = 40, L = 46, G = {
86
+ BACKSPACE: A,
87
+ TAB: p,
88
+ ENTER: b,
89
+ SHIFT: w,
86
90
  ESCAPE: h,
87
- SPACE: R,
88
- PAGE_UP: g,
89
- PAGE_DOWN: x,
90
- END: T,
91
- HOME: O,
92
- ARROW_LEFT: P,
93
- ARROW_UP: _,
94
- ARROW_RIGHT: v,
91
+ SPACE: T,
92
+ PAGE_UP: R,
93
+ PAGE_DOWN: g,
94
+ END: _,
95
+ HOME: x,
96
+ ARROW_LEFT: O,
97
+ ARROW_UP: v,
98
+ ARROW_RIGHT: P,
95
99
  ARROW_DOWN: D,
96
100
  DELETE: L
97
- };
101
+ }, H = (e, t, o) => Math.min(Math.max(e, t), o);
98
102
  export {
99
103
  S as EVENTS,
100
- G as addTrapFocus,
101
- i as body,
102
- W as breakpoints,
103
- M as disableScroll,
104
- N as enableScroll,
104
+ B as addTrapFocus,
105
+ d as body,
106
+ N as breakpoints,
107
+ H as clamp,
108
+ W as disableScroll,
109
+ k as enableScroll,
105
110
  m as getFocusableElements,
106
111
  l as html,
107
112
  C as isDebug,
108
- H as keycode,
109
- a as mouse,
110
- k as production,
113
+ G as keycode,
114
+ i as mouse,
115
+ M as production,
111
116
  y as removeTrapFocus,
112
117
  n as scroll,
113
118
  f as throttle
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agencecinq/utils",
3
- "version": "4.0.2",
3
+ "version": "5.0.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
package/src/clamp.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Clamps a number between a minimum and a maximum value.
3
+ *
4
+ * @example
5
+ * clamp(10, 1, 5); // 5
6
+ * clamp(-1, 0, 10); // 0
7
+ * clamp(7, 3, 9); // 7
8
+ */
9
+ export const clamp = (value: number, min: number, max: number): number =>
10
+ Math.min(Math.max(value, min), max);
@@ -1,4 +1,4 @@
1
- import { throttle } from "./throttle";
1
+ import { throttle } from "./throttle.js";
2
2
 
3
3
  const html = document.documentElement;
4
4
  const { body } = document;
package/src/events.ts CHANGED
@@ -5,6 +5,10 @@ export const EVENTS = {
5
5
  MODAL_CLOSE: 'modal-close',
6
6
  MODAL_OPEN: 'modal-open',
7
7
  MODAL_TOGGLE: 'modal-toggle',
8
+ SPINBUTTON_CHANGE: 'spinbutton-change',
9
+ TAB_BEFORE_ACTIVATE: 'tab-before-activate',
10
+ TAB_ACTIVATE: 'tab-activate',
11
+ TAB_DELETE: 'tab-delete',
8
12
  CART_BEFORE_ADD: 'cart-before-add',
9
13
  CART_BEFORE_UPDATE: 'cart-before-update',
10
14
  CART_UPDATE: 'cart-update',
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
- export * from './events';
2
- export * from './scroll';
3
- export * from './throttle';
4
- export * from './environment';
5
- export * from './focus-trap';
6
- export * from './keycode';
1
+ export * from './events.js';
2
+ export * from './scroll.js';
3
+ export * from './throttle.js';
4
+ export * from './environment.js';
5
+ export * from './focus-trap.js';
6
+ export * from './keycode.js';
7
+ export * from './clamp.js';
package/src/scroll.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { html, body, scroll } from "./environment";
1
+ import { html, body, scroll } from "./environment.js";
2
2
 
3
3
 
4
4
  /**
package/vite.config.ts CHANGED
@@ -11,7 +11,7 @@ export default defineConfig({
11
11
  },
12
12
  },
13
13
  plugins: [
14
- dts({
14
+ dts({
15
15
  insertTypesEntry: true,
16
16
  })
17
17
  ]