@availity/analytics-core 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/src/util.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ declare const isLeftClickEvent: (event: any) => boolean;
3
+
4
+ declare const isModifiedEvent: (event: any) => boolean;
5
+
6
+ declare const isValidEventTypeOnTarget: (event: any) => boolean;
7
+
8
+ declare const isPluginEnabled: (plugin: any) => any;
9
+
10
+ declare const camelCase: (str: any) => any;
11
+
12
+ declare const getComposedPath: (node: any) => any;
13
+
14
+ export { isLeftClickEvent, isModifiedEvent, isValidEventTypeOnTarget, isPluginEnabled, camelCase, getComposedPath };
package/src/util.js ADDED
@@ -0,0 +1,39 @@
1
+ export const isLeftClickEvent = (event) => event.button === 0;
2
+
3
+ export const isModifiedEvent = (event) => !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
4
+
5
+ const trackMap = {
6
+ select: ['focus', 'blur'],
7
+ textarea: ['focus', 'blur'],
8
+ input: ['focus', 'blur'],
9
+ default: ['click'],
10
+ };
11
+
12
+ export const isValidEventTypeOnTarget = (event) =>
13
+ (trackMap[event.target.nodeName.toLowerCase()] || trackMap.default).indexOf(event.type) > -1;
14
+
15
+ export const isPluginEnabled = (plugin) =>
16
+ typeof plugin.isEnabled === 'function' ? plugin.isEnabled() : plugin.isEnabled;
17
+
18
+ export const camelCase = (str) => str.replace(/-([\da-z])/gi, (match, char) => char.toUpperCase());
19
+
20
+ /**
21
+ * Polyfill for [`Event.composedPath()`][1].
22
+ * https://gist.github.com/kleinfreund/e9787d73776c0e3750dcfcdc89f100ec
23
+ */
24
+ export const getComposedPath = (node) => {
25
+ let parent;
26
+ if (node.parentNode) {
27
+ parent = node.parentNode;
28
+ } else if (node.host) {
29
+ parent = node.host;
30
+ } else if (node.defaultView) {
31
+ parent = node.defaultView;
32
+ }
33
+
34
+ if (parent !== undefined) {
35
+ return [node, ...getComposedPath(parent)];
36
+ }
37
+
38
+ return [node];
39
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "include": ["."],
4
+ "exclude": ["dist", "build", "node_modules"]
5
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "types": ["jest", "node"],
7
+ "allowJs": true
8
+ },
9
+ "include": ["**/*.test.ts", "**/*.d.ts"]
10
+ }