@agencecinq/utils 5.0.1 → 5.0.3

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,17 @@
1
1
  # @agencecinq/utils
2
2
 
3
+ ## 5.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Add `@agencecinq/switch` Web Component (`<cinq-switch>`) with activate/deactivate/toggle API, WAI-ARIA switch pattern support, and interactive docs playground. Export `SWITCH_ACTIVATE` and `SWITCH_DEACTIVATE` from `@agencecinq/utils`. Align disclosure-button event handlers to `handle*` naming convention.
8
+
9
+ ## 5.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 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`.
14
+
3
15
  ## 5.0.0
4
16
 
5
17
  ### Major Changes
package/dist/events.d.ts CHANGED
@@ -6,6 +6,10 @@ 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;
11
+ SWITCH_ACTIVATE: string;
12
+ SWITCH_DEACTIVATE: string;
9
13
  TAB_BEFORE_ACTIVATE: string;
10
14
  TAB_ACTIVATE: string;
11
15
  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;;;;;;;;;;;;;;;;;;;CAmBlB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,OAAO,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC"}
package/dist/index.js CHANGED
@@ -1,119 +1,110 @@
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
+ SWITCH_ACTIVATE: "switch:activate",
13
+ SWITCH_DEACTIVATE: "switch:deactivate",
14
+ TAB_BEFORE_ACTIVATE: "tab-before-activate",
15
+ TAB_ACTIVATE: "tab-activate",
16
+ TAB_DELETE: "tab-delete",
17
+ CART_BEFORE_ADD: "cart-before-add",
18
+ CART_BEFORE_UPDATE: "cart-before-update",
19
+ CART_UPDATE: "cart-update",
20
+ VARIANT_CHANGE: "variant-change"
21
+ }, t = (e, t) => {
22
+ let n = null, r = null, i = () => {
23
+ r && e(...r), n = null;
24
+ };
25
+ return (...e) => {
26
+ r = e, n ||= setTimeout(i, t);
27
+ };
28
+ }, n = document.documentElement, { body: r } = document, i = n.hasAttribute("data-debug"), a = {
29
+ y: 0,
30
+ x: 0
31
+ }, o = {
32
+ x: 0,
33
+ y: 0
30
34
  };
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);
35
+ window.addEventListener("pointermove", t(({ x: e, y: t }) => {
36
+ o.x = e, o.y = t;
37
+ }, 100), { passive: !0 });
38
+ var s = {
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
+ }, c = !0, l = (e, t) => {
44
+ e !== void 0 && (a.x = e), t !== void 0 && (a.y = t), window.scrollTo(a.x, a.y);
45
45
  };
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);
46
+ function u() {
47
+ let e = n.scrollLeft, t = n.scrollTop, i = r.scrollLeft, o = r.scrollTop;
48
+ 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
49
  }
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);
50
+ function d(e = 0) {
51
+ let t = !0, r = a.y;
52
+ 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
53
  }
54
- const a = {};
55
- function E(e) {
56
- return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
54
+ //#endregion
55
+ //#region src/focus-trap.ts
56
+ var f = {};
57
+ function p(e) {
58
+ return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
57
59
  }
58
60
  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");
61
+ if (!e) return [];
62
+ let t = [
63
+ "summary",
64
+ "a[href]",
65
+ "button:enabled",
66
+ "[tabindex]:not([tabindex^=\"-\"])",
67
+ "input:not([type=hidden]):enabled",
68
+ "select:enabled",
69
+ "textarea:enabled",
70
+ "object",
71
+ "iframe",
72
+ "[contenteditable]"
73
+ ].join(",");
74
+ return Array.from(e.querySelectorAll(t)).filter((e) => p(e) && e.getAttribute("tabindex") !== "-1");
73
75
  }
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);
76
+ function h(e, t = e) {
77
+ let n = m(e);
78
+ if (n.length === 0) return;
79
+ let r = n[0], i = n[n.length - 1];
80
+ g(), f.keydown = (t) => {
81
+ t.key === "Tab" && (t.shiftKey ? (document.activeElement === r || document.activeElement === e) && (t.preventDefault(), i.focus()) : document.activeElement === i && (t.preventDefault(), r.focus()));
82
+ }, document.addEventListener("keydown", f.keydown), t.focus(), t instanceof HTMLInputElement && [
83
+ "search",
84
+ "text",
85
+ "email",
86
+ "url"
87
+ ].includes(t.type) && t.value && t.setSelectionRange(0, t.value.length);
81
88
  }
82
- function y(e = null) {
83
- a.keydown && document.removeEventListener("keydown", a.keydown), e && e.focus();
89
+ function g(e = null) {
90
+ f.keydown && document.removeEventListener("keydown", f.keydown), e && e.focus();
84
91
  }
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
- };
92
+ var _ = {
93
+ BACKSPACE: 8,
94
+ TAB: 9,
95
+ ENTER: 13,
96
+ SHIFT: 16,
97
+ ESCAPE: 27,
98
+ SPACE: 32,
99
+ PAGE_UP: 33,
100
+ PAGE_DOWN: 34,
101
+ END: 35,
102
+ HOME: 36,
103
+ ARROW_LEFT: 37,
104
+ ARROW_UP: 38,
105
+ ARROW_RIGHT: 39,
106
+ ARROW_DOWN: 40,
107
+ DELETE: 46
108
+ }, v = (e, t, n) => Math.min(Math.max(e, t), n);
109
+ //#endregion
110
+ 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.1",
3
+ "version": "5.0.3",
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.4",
22
+ "vite-plugin-dts": "^5.0.3"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public"
package/src/events.ts CHANGED
@@ -6,6 +6,10 @@ 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',
11
+ SWITCH_ACTIVATE: 'switch:activate',
12
+ SWITCH_DEACTIVATE: 'switch:deactivate',
9
13
  TAB_BEFORE_ACTIVATE: 'tab-before-activate',
10
14
  TAB_ACTIVATE: 'tab-activate',
11
15
  TAB_DELETE: 'tab-delete',