@agencecinq/utils 5.0.0 → 5.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.
Binary file
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @agencecinq/utils
2
2
 
3
+ ## 5.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Add `@agencecinq/disclosure-button` package with `DisclosureButton` class, open/close/toggle API, and typed event details. Export `DISCLOSURE_BUTTON_OPEN` and `DISCLOSURE_BUTTON_CLOSE` from `@agencecinq/utils`.
8
+
3
9
  ## 5.0.0
4
10
 
5
11
  ### Major Changes
package/dist/events.d.ts CHANGED
@@ -6,6 +6,8 @@ export declare const EVENTS: {
6
6
  MODAL_OPEN: string;
7
7
  MODAL_TOGGLE: string;
8
8
  SPINBUTTON_CHANGE: string;
9
+ DISCLOSURE_BUTTON_OPEN: string;
10
+ DISCLOSURE_BUTTON_CLOSE: string;
9
11
  TAB_BEFORE_ACTIVATE: string;
10
12
  TAB_ACTIVATE: string;
11
13
  TAB_DELETE: string;
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;CAiBlB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,OAAO,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,8 +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';
7
- export * from './clamp';
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';
8
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;AAC1B,cAAc,SAAS,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
@@ -1,119 +1,108 @@
1
- const S = {
2
- DRAWER_CLOSE: "drawer-close",
3
- DRAWER_OPEN: "drawer-open",
4
- DRAWER_TOGGLE: "drawer-toggle",
5
- MODAL_CLOSE: "modal-close",
6
- MODAL_OPEN: "modal-open",
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",
12
- CART_BEFORE_ADD: "cart-before-add",
13
- CART_BEFORE_UPDATE: "cart-before-update",
14
- CART_UPDATE: "cart-update",
15
- VARIANT_CHANGE: "variant-change"
16
- }, f = (e, t) => {
17
- let o = null, c = null;
18
- const s = () => {
19
- c && e(...c), o = null;
20
- };
21
- return (...r) => {
22
- c = r, o || (o = setTimeout(s, t));
23
- };
24
- }, l = document.documentElement, { body: d } = document, C = l.hasAttribute("data-debug"), n = {
25
- y: 0,
26
- x: 0
27
- }, i = {
28
- x: 0,
29
- y: 0
1
+ //#region src/events.ts
2
+ var e = {
3
+ DRAWER_CLOSE: "drawer-close",
4
+ DRAWER_OPEN: "drawer-open",
5
+ DRAWER_TOGGLE: "drawer-toggle",
6
+ MODAL_CLOSE: "modal-close",
7
+ MODAL_OPEN: "modal-open",
8
+ MODAL_TOGGLE: "modal-toggle",
9
+ SPINBUTTON_CHANGE: "spinbutton-change",
10
+ DISCLOSURE_BUTTON_OPEN: "disclosure-button:open",
11
+ DISCLOSURE_BUTTON_CLOSE: "disclosure-button:close",
12
+ TAB_BEFORE_ACTIVATE: "tab-before-activate",
13
+ TAB_ACTIVATE: "tab-activate",
14
+ TAB_DELETE: "tab-delete",
15
+ CART_BEFORE_ADD: "cart-before-add",
16
+ CART_BEFORE_UPDATE: "cart-before-update",
17
+ CART_UPDATE: "cart-update",
18
+ VARIANT_CHANGE: "variant-change"
19
+ }, t = (e, t) => {
20
+ let n = null, r = null, i = () => {
21
+ r && e(...r), n = null;
22
+ };
23
+ return (...e) => {
24
+ r = e, n ||= setTimeout(i, t);
25
+ };
26
+ }, n = document.documentElement, { body: r } = document, i = n.hasAttribute("data-debug"), a = {
27
+ y: 0,
28
+ x: 0
29
+ }, o = {
30
+ x: 0,
31
+ y: 0
30
32
  };
31
- window.addEventListener(
32
- "pointermove",
33
- f(({ x: e, y: t }) => {
34
- i.x = e, i.y = t;
35
- }, 100),
36
- { passive: !0 }
37
- );
38
- const N = {
39
- lg: window.matchMedia("(width >= 64rem)"),
40
- xl: window.matchMedia("(min-width: 1280px)"),
41
- "2xl": window.matchMedia("(min-width: 1440px)"),
42
- "3xl": window.matchMedia("(min-width: 1920px)")
43
- }, M = !0, u = (e, t) => {
44
- typeof e < "u" && (n.x = e), typeof t < "u" && (n.y = t), window.scrollTo(n.x, n.y);
33
+ window.addEventListener("pointermove", t(({ x: e, y: t }) => {
34
+ o.x = e, o.y = t;
35
+ }, 100), { passive: !0 });
36
+ var s = {
37
+ lg: window.matchMedia("(width >= 64rem)"),
38
+ xl: window.matchMedia("(min-width: 1280px)"),
39
+ "2xl": window.matchMedia("(min-width: 1440px)"),
40
+ "3xl": window.matchMedia("(min-width: 1920px)")
41
+ }, c = !0, l = (e, t) => {
42
+ e !== void 0 && (a.x = e), t !== void 0 && (a.y = t), window.scrollTo(a.x, a.y);
45
43
  };
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);
44
+ function u() {
45
+ let e = n.scrollLeft, t = n.scrollTop, i = r.scrollLeft, o = r.scrollTop;
46
+ a.x = window.scrollX || e || i, a.y = window.scrollY || t || o || 0, n.style.setProperty("overflow", "hidden"), n.style.setProperty("height", "100%"), n.style.setProperty("scroll-padding-top", "0px"), l(a.x, a.y);
49
47
  }
50
- function k(e = 0) {
51
- let t = !0, o = n.y;
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);
48
+ function d(e = 0) {
49
+ let t = !0, r = a.y;
50
+ typeof e == "number" ? r = e : typeof e == "boolean" && e === !1 && (t = !1), n.style.removeProperty("overflow"), n.style.removeProperty("height"), n.style.removeProperty("scroll-padding-top"), t && l(a.x, r);
53
51
  }
54
- const a = {};
55
- function E(e) {
56
- return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
52
+ //#endregion
53
+ //#region src/focus-trap.ts
54
+ var f = {};
55
+ function p(e) {
56
+ return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
57
57
  }
58
58
  function m(e) {
59
- if (!e) return [];
60
- const t = [
61
- "summary",
62
- "a[href]",
63
- "button:enabled",
64
- '[tabindex]:not([tabindex^="-"])',
65
- "input:not([type=hidden]):enabled",
66
- "select:enabled",
67
- "textarea:enabled",
68
- "object",
69
- "iframe",
70
- "[contenteditable]"
71
- ].join(",");
72
- return Array.from(e.querySelectorAll(t)).filter((o) => E(o) && o.getAttribute("tabindex") !== "-1");
59
+ if (!e) return [];
60
+ let t = [
61
+ "summary",
62
+ "a[href]",
63
+ "button:enabled",
64
+ "[tabindex]:not([tabindex^=\"-\"])",
65
+ "input:not([type=hidden]):enabled",
66
+ "select:enabled",
67
+ "textarea:enabled",
68
+ "object",
69
+ "iframe",
70
+ "[contenteditable]"
71
+ ].join(",");
72
+ return Array.from(e.querySelectorAll(t)).filter((e) => p(e) && e.getAttribute("tabindex") !== "-1");
73
73
  }
74
- function B(e, t = e) {
75
- const o = m(e);
76
- if (o.length === 0) return;
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);
74
+ function h(e, t = e) {
75
+ let n = m(e);
76
+ if (n.length === 0) return;
77
+ let r = n[0], i = n[n.length - 1];
78
+ g(), f.keydown = (t) => {
79
+ t.key === "Tab" && (t.shiftKey ? (document.activeElement === r || document.activeElement === e) && (t.preventDefault(), i.focus()) : document.activeElement === i && (t.preventDefault(), r.focus()));
80
+ }, document.addEventListener("keydown", f.keydown), t.focus(), t instanceof HTMLInputElement && [
81
+ "search",
82
+ "text",
83
+ "email",
84
+ "url"
85
+ ].includes(t.type) && t.value && t.setSelectionRange(0, t.value.length);
81
86
  }
82
- function y(e = null) {
83
- a.keydown && document.removeEventListener("keydown", a.keydown), e && e.focus();
87
+ function g(e = null) {
88
+ f.keydown && document.removeEventListener("keydown", f.keydown), e && e.focus();
84
89
  }
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,
90
- ESCAPE: h,
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,
99
- ARROW_DOWN: D,
100
- DELETE: L
101
- }, H = (e, t, o) => Math.min(Math.max(e, t), o);
102
- export {
103
- S as EVENTS,
104
- B as addTrapFocus,
105
- d as body,
106
- N as breakpoints,
107
- H as clamp,
108
- W as disableScroll,
109
- k as enableScroll,
110
- m as getFocusableElements,
111
- l as html,
112
- C as isDebug,
113
- G as keycode,
114
- i as mouse,
115
- M as production,
116
- y as removeTrapFocus,
117
- n as scroll,
118
- f as throttle
119
- };
90
+ var _ = {
91
+ BACKSPACE: 8,
92
+ TAB: 9,
93
+ ENTER: 13,
94
+ SHIFT: 16,
95
+ ESCAPE: 27,
96
+ SPACE: 32,
97
+ PAGE_UP: 33,
98
+ PAGE_DOWN: 34,
99
+ END: 35,
100
+ HOME: 36,
101
+ ARROW_LEFT: 37,
102
+ ARROW_UP: 38,
103
+ ARROW_RIGHT: 39,
104
+ ARROW_DOWN: 40,
105
+ DELETE: 46
106
+ }, v = (e, t, n) => Math.min(Math.max(e, t), n);
107
+ //#endregion
108
+ export { e as EVENTS, h as addTrapFocus, r as body, s as breakpoints, v as clamp, u as disableScroll, d as enableScroll, m as getFocusableElements, n as html, i as isDebug, _ as keycode, o as mouse, c as production, g as removeTrapFocus, a as scroll, t as throttle };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agencecinq/utils",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,9 +17,9 @@
17
17
  }
18
18
  },
19
19
  "devDependencies": {
20
- "typescript": "^5.9.3",
21
- "vite": "^7.3.1",
22
- "vite-plugin-dts": "^4.5.4"
20
+ "typescript": "^6.0.3",
21
+ "vite": "^8.1.3",
22
+ "vite-plugin-dts": "^5.0.3"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public"
@@ -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
@@ -6,6 +6,8 @@ export const EVENTS = {
6
6
  MODAL_OPEN: 'modal-open',
7
7
  MODAL_TOGGLE: 'modal-toggle',
8
8
  SPINBUTTON_CHANGE: 'spinbutton-change',
9
+ DISCLOSURE_BUTTON_OPEN: 'disclosure-button:open',
10
+ DISCLOSURE_BUTTON_CLOSE: 'disclosure-button:close',
9
11
  TAB_BEFORE_ACTIVATE: 'tab-before-activate',
10
12
  TAB_ACTIVATE: 'tab-activate',
11
13
  TAB_DELETE: 'tab-delete',
package/src/index.ts CHANGED
@@ -1,7 +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';
7
- export * from './clamp';
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
  ]