@cybertools/grommet 0.0.0-stage → 1.0.0
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/LICENSE +201 -0
- package/README.md +42 -2
- package/dist/Alert.cjs +58 -0
- package/dist/Alert.d.cts +11 -0
- package/dist/Alert.d.mts +11 -0
- package/dist/Alert.mjs +54 -0
- package/dist/BoxDirection.cjs +17 -0
- package/dist/BoxDirection.d.cts +6 -0
- package/dist/BoxDirection.d.mts +6 -0
- package/dist/BoxDirection.mjs +14 -0
- package/dist/ContactUs.cjs +39 -0
- package/dist/ContactUs.d.cts +10 -0
- package/dist/ContactUs.d.mts +10 -0
- package/dist/ContactUs.mjs +36 -0
- package/dist/ExternalLink.cjs +24 -0
- package/dist/ExternalLink.d.cts +9 -0
- package/dist/ExternalLink.d.mts +9 -0
- package/dist/ExternalLink.mjs +20 -0
- package/dist/Image.cjs +20 -0
- package/dist/Image.d.cts +81 -0
- package/dist/Image.d.mts +81 -0
- package/dist/Image.mjs +16 -0
- package/dist/Loader.cjs +21 -0
- package/dist/Loader.d.cts +8 -0
- package/dist/Loader.d.mts +8 -0
- package/dist/Loader.mjs +18 -0
- package/dist/MockNextRouterProvider.cjs +25 -0
- package/dist/MockNextRouterProvider.d.cts +8 -0
- package/dist/MockNextRouterProvider.d.mts +8 -0
- package/dist/MockNextRouterProvider.mjs +23 -0
- package/dist/Notification.cjs +54 -0
- package/dist/Notification.d.cts +13 -0
- package/dist/Notification.d.mts +13 -0
- package/dist/Notification.mjs +51 -0
- package/dist/NotificationsProvider.cjs +40 -0
- package/dist/NotificationsProvider.d.cts +18 -0
- package/dist/NotificationsProvider.d.mts +18 -0
- package/dist/NotificationsProvider.mjs +35 -0
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/index.cjs +26 -0
- package/dist/index.d.cts +12 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.mjs +12 -0
- package/dist/interop.cjs +9 -0
- package/dist/interop.mjs +9 -0
- package/dist/testing.cjs +3 -0
- package/dist/testing.d.cts +2 -0
- package/dist/testing.d.mts +2 -0
- package/dist/testing.mjs +2 -0
- package/dist/useIsLarge.cjs +8 -0
- package/dist/useIsLarge.d.cts +3 -0
- package/dist/useIsLarge.d.mts +3 -0
- package/dist/useIsLarge.mjs +7 -0
- package/dist/useResponsive.cjs +9 -0
- package/dist/useResponsive.d.cts +3 -0
- package/dist/useResponsive.d.mts +3 -0
- package/dist/useResponsive.mjs +8 -0
- package/dist/useTrackEvents.cjs +39 -0
- package/dist/useTrackEvents.d.cts +9 -0
- package/dist/useTrackEvents.d.mts +9 -0
- package/dist/useTrackEvents.mjs +37 -0
- package/package.json +112 -3
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Information, Warning } from "./Alert.mjs";
|
|
2
|
+
import { useResponsive } from "./useResponsive.mjs";
|
|
3
|
+
import { useIsLarge } from "./useIsLarge.mjs";
|
|
4
|
+
import { BoxDirection } from "./BoxDirection.mjs";
|
|
5
|
+
import { ContactUs } from "./ContactUs.mjs";
|
|
6
|
+
import { ExternalLink } from "./ExternalLink.mjs";
|
|
7
|
+
import { Image } from "./Image.mjs";
|
|
8
|
+
import { Loader } from "./Loader.mjs";
|
|
9
|
+
import { NotificationsProvider, useNotifications } from "./NotificationsProvider.mjs";
|
|
10
|
+
import { Notification } from "./Notification.mjs";
|
|
11
|
+
import { reportEvent, useTrackEvents } from "./useTrackEvents.mjs";
|
|
12
|
+
export { BoxDirection, ContactUs, ExternalLink, Image, Information, Loader, Notification, NotificationsProvider, Warning, reportEvent, useIsLarge, useNotifications, useResponsive, useTrackEvents };
|
package/dist/interop.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/interop.ts
|
|
2
|
+
/**
|
|
3
|
+
* Node's native ESM loader hands CommonJS modules over as an exports object,
|
|
4
|
+
* so a default import of a CJS package (styled-components, next/image, ...) can
|
|
5
|
+
* be `{ default: value }` instead of `value`. Returns the original value.
|
|
6
|
+
*/
|
|
7
|
+
const unwrapCjsDefault = (value) => value !== null && typeof value === "object" && "default" in value ? value.default : value;
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.unwrapCjsDefault = unwrapCjsDefault;
|
package/dist/interop.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/interop.ts
|
|
2
|
+
/**
|
|
3
|
+
* Node's native ESM loader hands CommonJS modules over as an exports object,
|
|
4
|
+
* so a default import of a CJS package (styled-components, next/image, ...) can
|
|
5
|
+
* be `{ default: value }` instead of `value`. Returns the original value.
|
|
6
|
+
*/
|
|
7
|
+
const unwrapCjsDefault = (value) => value !== null && typeof value === "object" && "default" in value ? value.default : value;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { unwrapCjsDefault };
|
package/dist/testing.cjs
ADDED
package/dist/testing.mjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_useResponsive = require("./useResponsive.cjs");
|
|
3
|
+
//#region src/useIsLarge.ts
|
|
4
|
+
function useIsLarge() {
|
|
5
|
+
return require_useResponsive.useResponsive() !== "small";
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
exports.useIsLarge = useIsLarge;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let react = require("react");
|
|
3
|
+
let grommet = require("grommet");
|
|
4
|
+
//#region src/useResponsive.ts
|
|
5
|
+
function useResponsive() {
|
|
6
|
+
return (0, react.useContext)(grommet.ResponsiveContext);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.useResponsive = useResponsive;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_useIsLarge = require("./useIsLarge.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
//#region src/useTrackEvents.ts
|
|
5
|
+
function reportEvent(category, action, label, value = NaN, dimension = "", event = "gaCustomEvent") {
|
|
6
|
+
if (!window.dataLayer) return;
|
|
7
|
+
setTimeout(() => {
|
|
8
|
+
const eventData = {
|
|
9
|
+
event,
|
|
10
|
+
category,
|
|
11
|
+
action,
|
|
12
|
+
label,
|
|
13
|
+
...!isNaN(+value) && { value: +value },
|
|
14
|
+
dimension
|
|
15
|
+
};
|
|
16
|
+
window.dataLayer?.push(eventData);
|
|
17
|
+
}, 0);
|
|
18
|
+
}
|
|
19
|
+
function useTrackEvents() {
|
|
20
|
+
const largeRef = (0, react.useRef)(void 0);
|
|
21
|
+
largeRef.current = require_useIsLarge.useIsLarge();
|
|
22
|
+
(0, react.useEffect)(() => {
|
|
23
|
+
const click = (event) => {
|
|
24
|
+
if (!window.dataLayer) return;
|
|
25
|
+
const gaEl = event.target.closest("[data-ga]");
|
|
26
|
+
if (!gaEl) return;
|
|
27
|
+
const ga = gaEl.getAttribute("data-ga");
|
|
28
|
+
if (!ga) return;
|
|
29
|
+
const [eventCategory, eventAction, eventLabel, eventValue] = ga.split("::");
|
|
30
|
+
if (!eventCategory) return;
|
|
31
|
+
reportEvent(eventCategory, eventAction, eventLabel, eventValue, largeRef.current ? "large" : "small");
|
|
32
|
+
};
|
|
33
|
+
document.addEventListener("click", click);
|
|
34
|
+
return () => document.removeEventListener("click", click);
|
|
35
|
+
}, []);
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.reportEvent = reportEvent;
|
|
39
|
+
exports.useTrackEvents = useTrackEvents;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/useTrackEvents.d.ts
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
dataLayer?: Record<string, unknown>[];
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare function reportEvent(category: string, action?: string, label?: string, value?: unknown, dimension?: string, event?: string): void;
|
|
8
|
+
export declare function useTrackEvents(): void;
|
|
9
|
+
//#endregion
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/useTrackEvents.d.ts
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
dataLayer?: Record<string, unknown>[];
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare function reportEvent(category: string, action?: string, label?: string, value?: unknown, dimension?: string, event?: string): void;
|
|
8
|
+
export declare function useTrackEvents(): void;
|
|
9
|
+
//#endregion
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useIsLarge } from "./useIsLarge.mjs";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
//#region src/useTrackEvents.ts
|
|
4
|
+
function reportEvent(category, action, label, value = NaN, dimension = "", event = "gaCustomEvent") {
|
|
5
|
+
if (!window.dataLayer) return;
|
|
6
|
+
setTimeout(() => {
|
|
7
|
+
const eventData = {
|
|
8
|
+
event,
|
|
9
|
+
category,
|
|
10
|
+
action,
|
|
11
|
+
label,
|
|
12
|
+
...!isNaN(+value) && { value: +value },
|
|
13
|
+
dimension
|
|
14
|
+
};
|
|
15
|
+
window.dataLayer?.push(eventData);
|
|
16
|
+
}, 0);
|
|
17
|
+
}
|
|
18
|
+
function useTrackEvents() {
|
|
19
|
+
const largeRef = useRef(void 0);
|
|
20
|
+
largeRef.current = useIsLarge();
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const click = (event) => {
|
|
23
|
+
if (!window.dataLayer) return;
|
|
24
|
+
const gaEl = event.target.closest("[data-ga]");
|
|
25
|
+
if (!gaEl) return;
|
|
26
|
+
const ga = gaEl.getAttribute("data-ga");
|
|
27
|
+
if (!ga) return;
|
|
28
|
+
const [eventCategory, eventAction, eventLabel, eventValue] = ga.split("::");
|
|
29
|
+
if (!eventCategory) return;
|
|
30
|
+
reportEvent(eventCategory, eventAction, eventLabel, eventValue, largeRef.current ? "large" : "small");
|
|
31
|
+
};
|
|
32
|
+
document.addEventListener("click", click);
|
|
33
|
+
return () => document.removeEventListener("click", click);
|
|
34
|
+
}, []);
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { reportEvent, useTrackEvents };
|
package/package.json
CHANGED
|
@@ -1,6 +1,115 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cybertools/grommet",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "grommet + Next.js UI components, notifications and responsive/analytics hooks for Cyberscope apps.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/cyberscope-io/cybertools.git",
|
|
9
|
+
"directory": "packages/grommet"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"grommet": "^2.32.0",
|
|
21
|
+
"grommet-icons": "^4.11.0",
|
|
22
|
+
"next": ">=13.5.0 <17",
|
|
23
|
+
"react": "^18.2.0 || ^19.0.0",
|
|
24
|
+
"react-dom": "^18.2.0 || ^19.0.0",
|
|
25
|
+
"styled-components": "^5.3.11 || ^6.0.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
29
|
+
"@cybertools/eslint-config": "0.0.0",
|
|
30
|
+
"@cybertools/tsconfig": "0.0.0",
|
|
31
|
+
"@testing-library/dom": "^10.4.2",
|
|
32
|
+
"@testing-library/react": "^16.3.3",
|
|
33
|
+
"@types/node": "^24.19.1",
|
|
34
|
+
"@types/react": "^19.3.0",
|
|
35
|
+
"@types/react-dom": "^19.3.0",
|
|
36
|
+
"eslint": "^10.12.0",
|
|
37
|
+
"grommet": "^2.57.0",
|
|
38
|
+
"grommet-icons": "^4.14.0",
|
|
39
|
+
"jsdom": "^30.1.2",
|
|
40
|
+
"next": "^16.3.8",
|
|
41
|
+
"publint": "^0.3.25",
|
|
42
|
+
"react": "^19.3.0",
|
|
43
|
+
"react-dom": "^19.3.0",
|
|
44
|
+
"styled-components": "^6.5.3",
|
|
45
|
+
"tsdown": "0.23.0",
|
|
46
|
+
"typescript": "6.0.3",
|
|
47
|
+
"vite": "^8.3.2",
|
|
48
|
+
"vitest": "^5.0.3"
|
|
49
|
+
},
|
|
50
|
+
"main": "./dist/index.cjs",
|
|
51
|
+
"module": "./dist/index.mjs",
|
|
52
|
+
"types": "./dist/index.d.cts",
|
|
53
|
+
"exports": {
|
|
54
|
+
".": {
|
|
55
|
+
"import": "./dist/index.mjs",
|
|
56
|
+
"require": "./dist/index.cjs"
|
|
57
|
+
},
|
|
58
|
+
"./Alert": {
|
|
59
|
+
"import": "./dist/Alert.mjs",
|
|
60
|
+
"require": "./dist/Alert.cjs"
|
|
61
|
+
},
|
|
62
|
+
"./BoxDirection": {
|
|
63
|
+
"import": "./dist/BoxDirection.mjs",
|
|
64
|
+
"require": "./dist/BoxDirection.cjs"
|
|
65
|
+
},
|
|
66
|
+
"./ContactUs": {
|
|
67
|
+
"import": "./dist/ContactUs.mjs",
|
|
68
|
+
"require": "./dist/ContactUs.cjs"
|
|
69
|
+
},
|
|
70
|
+
"./ExternalLink": {
|
|
71
|
+
"import": "./dist/ExternalLink.mjs",
|
|
72
|
+
"require": "./dist/ExternalLink.cjs"
|
|
73
|
+
},
|
|
74
|
+
"./Image": {
|
|
75
|
+
"import": "./dist/Image.mjs",
|
|
76
|
+
"require": "./dist/Image.cjs"
|
|
77
|
+
},
|
|
78
|
+
"./Loader": {
|
|
79
|
+
"import": "./dist/Loader.mjs",
|
|
80
|
+
"require": "./dist/Loader.cjs"
|
|
81
|
+
},
|
|
82
|
+
"./Notification": {
|
|
83
|
+
"import": "./dist/Notification.mjs",
|
|
84
|
+
"require": "./dist/Notification.cjs"
|
|
85
|
+
},
|
|
86
|
+
"./NotificationsProvider": {
|
|
87
|
+
"import": "./dist/NotificationsProvider.mjs",
|
|
88
|
+
"require": "./dist/NotificationsProvider.cjs"
|
|
89
|
+
},
|
|
90
|
+
"./testing": {
|
|
91
|
+
"import": "./dist/testing.mjs",
|
|
92
|
+
"require": "./dist/testing.cjs"
|
|
93
|
+
},
|
|
94
|
+
"./useIsLarge": {
|
|
95
|
+
"import": "./dist/useIsLarge.mjs",
|
|
96
|
+
"require": "./dist/useIsLarge.cjs"
|
|
97
|
+
},
|
|
98
|
+
"./useResponsive": {
|
|
99
|
+
"import": "./dist/useResponsive.mjs",
|
|
100
|
+
"require": "./dist/useResponsive.cjs"
|
|
101
|
+
},
|
|
102
|
+
"./useTrackEvents": {
|
|
103
|
+
"import": "./dist/useTrackEvents.mjs",
|
|
104
|
+
"require": "./dist/useTrackEvents.cjs"
|
|
105
|
+
},
|
|
106
|
+
"./package.json": "./package.json"
|
|
107
|
+
},
|
|
108
|
+
"scripts": {
|
|
109
|
+
"build": "tsdown",
|
|
110
|
+
"typecheck": "tsc --noEmit",
|
|
111
|
+
"lint": "eslint .",
|
|
112
|
+
"check:package": "publint && attw --pack . --profile node16 && node scripts/check-native-esm.mjs",
|
|
113
|
+
"test": "vitest run"
|
|
114
|
+
}
|
|
6
115
|
}
|