@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.
- package/.turbo/turbo-build.log +0 -0
- package/CHANGELOG.md +12 -0
- package/dist/events.d.ts +4 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/index.js +101 -110
- package/package.json +4 -4
- package/src/events.ts +4 -0
package/.turbo/turbo-build.log
CHANGED
|
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;
|
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
|
83
|
-
|
|
89
|
+
function g(e = null) {
|
|
90
|
+
f.keydown && document.removeEventListener("keydown", f.keydown), e && e.focus();
|
|
84
91
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
|
|
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.
|
|
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": "^
|
|
21
|
-
"vite": "^
|
|
22
|
-
"vite-plugin-dts": "^
|
|
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',
|