@agencecinq/utils 2.0.0 → 2.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.
@@ -0,0 +1,13 @@
1
+
2
+ 
3
+ > @agencecinq/utils@2.0.1 build /Users/19h47/Sites/agencecinq-shopify/packages/utils
4
+ > vite build
5
+
6
+ vite v7.3.1 building client environment for production...
7
+ transforming (1) src/index.tstransforming (3) src/events.ts✓ 7 modules transformed.
8
+ rendering chunks (1)...
9
+ [vite:dts] Start generate declaration files...
10
+ computing gzip size (0)...computing gzip size (1)...dist/index.js 3.28 kB │ gzip: 1.52 kB
11
+ [vite:dts] Declaration files built in 2669ms.
12
+ 
13
+ ✓ built in 3.22s
@@ -0,0 +1,19 @@
1
+ declare const html: HTMLElement;
2
+ declare const body: HTMLElement;
3
+ declare const isDebug: boolean;
4
+ declare const scroll: {
5
+ y: number;
6
+ x: number;
7
+ };
8
+ declare const mouse: {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ declare const breakpoints: {
13
+ lg: MediaQueryList;
14
+ xl: MediaQueryList;
15
+ '2xl': MediaQueryList;
16
+ '3xl': MediaQueryList;
17
+ };
18
+ declare const production: boolean;
19
+ export { html, body, isDebug, scroll, mouse, breakpoints, production };
@@ -0,0 +1,8 @@
1
+ export declare const EVENTS: {
2
+ DRAWER_CLOSE: string;
3
+ DRAWER_OPEN: string;
4
+ DRAWER_TOGGLE: string;
5
+ CART_UPDATE: string;
6
+ VARIANT_CHANGE: string;
7
+ };
8
+ export type EventNames = typeof EVENTS[keyof typeof EVENTS];
@@ -0,0 +1,4 @@
1
+ declare function getFocusableElements(container: HTMLElement): HTMLElement[];
2
+ declare function addTrapFocus(container: HTMLElement, elementToFocus?: HTMLElement): void;
3
+ declare function removeTrapFocus(elementToFocus?: HTMLElement | null): void;
4
+ export { addTrapFocus, removeTrapFocus, getFocusableElements };
@@ -0,0 +1,6 @@
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';
package/dist/index.js ADDED
@@ -0,0 +1,109 @@
1
+ const O = {
2
+ DRAWER_CLOSE: "drawer-close",
3
+ DRAWER_OPEN: "drawer-open",
4
+ DRAWER_TOGGLE: "drawer-toggle",
5
+ CART_UPDATE: "cart-update",
6
+ VARIANT_CHANGE: "variant-change"
7
+ }, f = (e, t) => {
8
+ let n = null, r = null;
9
+ const s = () => {
10
+ r && e(...r), n = null;
11
+ };
12
+ return (...c) => {
13
+ r = c, n || (n = setTimeout(s, t));
14
+ };
15
+ }, l = document.documentElement, { body: d } = document, W = l.hasAttribute("data-debug"), o = {
16
+ y: 0,
17
+ x: 0
18
+ }, a = {
19
+ x: 0,
20
+ y: 0
21
+ };
22
+ window.addEventListener(
23
+ "pointermove",
24
+ f(({ x: e, y: t }) => {
25
+ a.x = e, a.y = t;
26
+ }, 100),
27
+ { passive: !0 }
28
+ );
29
+ const k = {
30
+ lg: window.matchMedia("(width >= 64rem)"),
31
+ xl: window.matchMedia("(min-width: 1280px)"),
32
+ "2xl": window.matchMedia("(min-width: 1440px)"),
33
+ "3xl": window.matchMedia("(min-width: 1920px)")
34
+ }, C = !0, u = (e, t) => {
35
+ typeof e < "u" && (o.x = e), typeof t < "u" && (o.y = t), window.scrollTo(o.x, o.y);
36
+ };
37
+ function N() {
38
+ const e = l.scrollLeft, t = l.scrollTop, n = d.scrollLeft, r = d.scrollTop;
39
+ o.x = window.scrollX || e || n, o.y = window.scrollY || t || r || 0, l.style.setProperty("overflow", "hidden"), l.style.setProperty("height", "100%"), l.style.setProperty("scroll-padding-top", "0px"), u(o.x, o.y);
40
+ }
41
+ function H(e = 0) {
42
+ let t = !0, n = o.y;
43
+ typeof e == "number" ? n = e : typeof e == "boolean" && e === !1 && (t = !1), l.style.removeProperty("overflow"), l.style.removeProperty("height"), l.style.removeProperty("scroll-padding-top"), t && u(o.x, n);
44
+ }
45
+ const i = {};
46
+ function y(e) {
47
+ return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
48
+ }
49
+ function m(e) {
50
+ if (!e) return [];
51
+ const t = [
52
+ "summary",
53
+ "a[href]",
54
+ "button:enabled",
55
+ '[tabindex]:not([tabindex^="-"])',
56
+ "input:not([type=hidden]):enabled",
57
+ "select:enabled",
58
+ "textarea:enabled",
59
+ "object",
60
+ "iframe",
61
+ "[contenteditable]"
62
+ ].join(",");
63
+ return Array.from(e.querySelectorAll(t)).filter((n) => y(n) && n.getAttribute("tabindex") !== "-1");
64
+ }
65
+ function G(e, t = e) {
66
+ const n = m(e);
67
+ if (n.length === 0) return;
68
+ const r = n[0], s = n[n.length - 1];
69
+ E(), i.keydown = (c) => {
70
+ c.key === "Tab" && (c.shiftKey ? (document.activeElement === r || document.activeElement === e) && (c.preventDefault(), s.focus()) : document.activeElement === s && (c.preventDefault(), r.focus()));
71
+ }, document.addEventListener("keydown", i.keydown), t.focus(), t instanceof HTMLInputElement && ["search", "text", "email", "url"].includes(t.type) && t.value && t.setSelectionRange(0, t.value.length);
72
+ }
73
+ function E(e = null) {
74
+ i.keydown && document.removeEventListener("keydown", i.keydown), e && e.focus();
75
+ }
76
+ const p = 8, w = 9, h = 13, b = 16, A = 27, x = 32, g = 33, R = 34, v = 35, P = 36, S = 37, T = 38, L = 39, D = 40, _ = 46, M = {
77
+ BACKSPACE: p,
78
+ TAB: w,
79
+ ENTER: h,
80
+ SHIFT: b,
81
+ ESCAPE: A,
82
+ SPACE: x,
83
+ PAGE_UP: g,
84
+ PAGE_DOWN: R,
85
+ END: v,
86
+ HOME: P,
87
+ ARROW_LEFT: S,
88
+ ARROW_UP: T,
89
+ ARROW_RIGHT: L,
90
+ ARROW_DOWN: D,
91
+ DELETE: _
92
+ };
93
+ export {
94
+ O as EVENTS,
95
+ G as addTrapFocus,
96
+ d as body,
97
+ k as breakpoints,
98
+ N as disableScroll,
99
+ H as enableScroll,
100
+ m as getFocusableElements,
101
+ l as html,
102
+ W as isDebug,
103
+ M as keycode,
104
+ a as mouse,
105
+ C as production,
106
+ E as removeTrapFocus,
107
+ o as scroll,
108
+ f as throttle
109
+ };
@@ -0,0 +1,17 @@
1
+ export declare const keycode: {
2
+ BACKSPACE: number;
3
+ TAB: number;
4
+ ENTER: number;
5
+ SHIFT: number;
6
+ ESCAPE: number;
7
+ SPACE: number;
8
+ PAGE_UP: number;
9
+ PAGE_DOWN: number;
10
+ END: number;
11
+ HOME: number;
12
+ ARROW_LEFT: number;
13
+ ARROW_UP: number;
14
+ ARROW_RIGHT: number;
15
+ ARROW_DOWN: number;
16
+ DELETE: number;
17
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * disableScroll
3
+ *
4
+ * Lock scroll position, but retain settings for later
5
+ *
6
+ * @see http://stackoverflow.com/a/3656618
7
+ */
8
+ export declare function disableScroll(): void;
9
+ export declare function enableScroll(position?: number | boolean | undefined): void;
@@ -0,0 +1,12 @@
1
+ interface ThrottleFunction {
2
+ (func: (...args: any[]) => void, wait: number): (...args: any[]) => void;
3
+ }
4
+ /**
5
+ * Creates a throttled function that only invokes `func` at most once per every `wait` milliseconds.
6
+ *
7
+ * @param func - The function to throttle.
8
+ * @param wait - The number of milliseconds to wait before allowing `func` to be called again.
9
+ * @returns A new throttled function.
10
+ */
11
+ export declare const throttle: ThrottleFunction;
12
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agencecinq/utils",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,22 +10,22 @@
10
10
  "type": "module",
11
11
  "main": "./dist/index.js",
12
12
  "module": "./dist/index.js",
13
- "types": "./dist/index.d.ts",
14
13
  "exports": {
15
14
  ".": {
16
- "types": "./dist/index.d.ts",
17
- "import": "./dist/index.js"
15
+ "import": "./dist/index.js",
16
+ "types": "./dist/index.d.ts"
18
17
  }
19
18
  },
20
- "scripts": {
21
- "dev": "vite",
22
- "build": "vite build"
23
- },
24
19
  "devDependencies": {
25
- "vite": "^5.0.0",
26
- "vite-plugin-dts": "^3.0.0"
20
+ "typescript": "^5.9.3",
21
+ "vite": "^7.3.1",
22
+ "vite-plugin-dts": "^4.5.4"
27
23
  },
28
24
  "publishConfig": {
29
25
  "access": "public"
26
+ },
27
+ "scripts": {
28
+ "dev": "vite",
29
+ "build": "vite build"
30
30
  }
31
31
  }
@@ -30,6 +30,6 @@ const breakpoints = {
30
30
  '3xl': window.matchMedia('(min-width: 1920px)'),
31
31
  };
32
32
 
33
- const production = 'production' === process.env.NODE_ENV;
33
+ const production = import.meta.env.PROD;
34
34
 
35
35
  export { html, body, isDebug, scroll, mouse, breakpoints, production };
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "declaration": true,
8
+ "outDir": "./dist",
9
+ "baseUrl": ".",
10
+ "paths": {
11
+ "@agencecinq/utils": ["./src/index.ts"]
12
+ },
13
+ "types": ["vite/client"]
14
+ },
15
+ "include": ["src/**/*"]
16
+ }
package/vite.config.ts CHANGED
@@ -6,10 +6,9 @@ export default defineConfig({
6
6
  build: {
7
7
  lib: {
8
8
  entry: resolve(__dirname, 'src/index.ts'),
9
- name: 'Utils',
10
9
  fileName: 'index',
11
10
  formats: ['es']
12
- }
11
+ },
13
12
  },
14
13
  plugins: [
15
14
  dts({
package/CHANGELOG.md DELETED
@@ -1,13 +0,0 @@
1
- # @agencecinq/utils
2
-
3
- ## 2.0.0
4
-
5
- ### Major Changes
6
-
7
- - Publish on npm
8
-
9
- ## 1.0.0
10
-
11
- ### Major Changes
12
-
13
- - Setup CINQ Shopify monorepo