cognite-create 0.3.5 → 0.3.7
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/package.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import reactHooks from "eslint-plugin-react-hooks";
|
|
4
|
+
import reactRefresh from "eslint-plugin-react-refresh";
|
|
5
|
+
import tseslint from "typescript-eslint";
|
|
6
|
+
import { defineConfig, globalIgnores } from "eslint/config";
|
|
7
|
+
|
|
8
|
+
export default defineConfig([
|
|
9
|
+
globalIgnores(["dist"]),
|
|
10
|
+
{
|
|
11
|
+
files: ["**/*.{ts,tsx}"],
|
|
12
|
+
extends: [
|
|
13
|
+
js.configs.recommended,
|
|
14
|
+
tseslint.configs.recommended,
|
|
15
|
+
reactHooks.configs["recommended-latest"],
|
|
16
|
+
reactRefresh.configs.vite,
|
|
17
|
+
],
|
|
18
|
+
languageOptions: {
|
|
19
|
+
ecmaVersion: 2020,
|
|
20
|
+
globals: globals.browser,
|
|
21
|
+
},
|
|
22
|
+
rules: {
|
|
23
|
+
"react-refresh/only-export-components": [
|
|
24
|
+
"warn",
|
|
25
|
+
{ allowConstantExport: true },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
files: ["src/components/ui/**/*.{ts,tsx}"],
|
|
31
|
+
rules: {
|
|
32
|
+
"react-refresh/only-export-components": "off",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
]);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
const MOBILE_BREAKPOINT = 768
|
|
4
|
+
|
|
5
|
+
export function useIsMobile() {
|
|
6
|
+
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
|
|
7
|
+
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
|
|
10
|
+
const onChange = () => {
|
|
11
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
|
12
|
+
}
|
|
13
|
+
mql.addEventListener("change", onChange)
|
|
14
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
|
15
|
+
return () => mql.removeEventListener("change", onChange)
|
|
16
|
+
}, [])
|
|
17
|
+
|
|
18
|
+
return !!isMobile
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useEffect, RefObject } from "react";
|
|
2
|
+
|
|
3
|
+
export function useOutsideClick<T extends HTMLElement = HTMLElement>(
|
|
4
|
+
ref: RefObject<T>,
|
|
5
|
+
handler: (event: MouseEvent | TouchEvent) => void
|
|
6
|
+
) {
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const listener = (event: MouseEvent | TouchEvent) => {
|
|
9
|
+
const el = ref?.current;
|
|
10
|
+
if (!el || el.contains((event?.target as Node) || null)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
handler(event);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
document.addEventListener("mousedown", listener);
|
|
18
|
+
document.addEventListener("touchstart", listener);
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
document.removeEventListener("mousedown", listener);
|
|
22
|
+
document.removeEventListener("touchstart", listener);
|
|
23
|
+
};
|
|
24
|
+
}, [ref, handler]);
|
|
25
|
+
}
|