@etsoo/react 1.7.94 → 1.7.95
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/README.md +2 -1
- package/__tests__/EventWatcher.tsx +21 -21
- package/__tests__/ReactUtils.ts +4 -4
- package/__tests__/tsconfig.json +17 -17
- package/babel.config.json +8 -8
- package/lib/app/CoreConstants.js +2 -2
- package/lib/app/EventWatcher.d.ts +1 -1
- package/lib/app/EventWatcher.js +3 -5
- package/lib/app/InputDialogProps.d.ts +2 -2
- package/lib/app/ReactUtils.d.ts +2 -2
- package/lib/app/ReactUtils.js +20 -19
- package/lib/components/DnDList.d.ts +3 -3
- package/lib/components/DnDList.js +4 -4
- package/lib/components/DynamicRouter.d.ts +2 -2
- package/lib/components/DynamicRouter.js +2 -2
- package/lib/components/GridColumn.d.ts +6 -6
- package/lib/components/GridColumn.js +7 -7
- package/lib/components/GridLoader.d.ts +4 -4
- package/lib/components/GridLoader.js +2 -2
- package/lib/components/GridMethodRef.d.ts +2 -2
- package/lib/components/ListItemReact.d.ts +2 -2
- package/lib/components/ScrollRestoration.js +3 -3
- package/lib/components/ScrollerGrid.d.ts +7 -12
- package/lib/components/ScrollerGrid.js +13 -17
- package/lib/components/ScrollerList.d.ts +6 -10
- package/lib/components/ScrollerList.js +15 -14
- package/lib/custom/CustomFieldReact.d.ts +1 -1
- package/lib/index.d.ts +32 -32
- package/lib/index.js +31 -31
- package/lib/notifier/Notifier.d.ts +5 -5
- package/lib/notifier/Notifier.js +7 -7
- package/lib/states/CultureState.d.ts +3 -3
- package/lib/states/CultureState.js +3 -3
- package/lib/states/IState.d.ts +2 -2
- package/lib/states/PageState.d.ts +2 -2
- package/lib/states/PageState.js +2 -3
- package/lib/states/State.d.ts +3 -3
- package/lib/states/State.js +2 -2
- package/lib/states/UserState.d.ts +2 -2
- package/lib/states/UserState.js +5 -5
- package/lib/uses/useAsyncState.d.ts +1 -1
- package/lib/uses/useAsyncState.js +1 -1
- package/lib/uses/useCombinedRefs.js +2 -2
- package/lib/uses/useDelayedExecutor.d.ts +1 -1
- package/lib/uses/useDelayedExecutor.js +2 -2
- package/lib/uses/useDimensions.d.ts +1 -1
- package/lib/uses/useDimensions.js +3 -3
- package/lib/uses/useParamsEx.d.ts +1 -1
- package/lib/uses/useParamsEx.js +2 -2
- package/lib/uses/useRefs.d.ts +2 -2
- package/lib/uses/useRefs.js +1 -1
- package/lib/uses/useSearchParamsEx.d.ts +1 -1
- package/lib/uses/useSearchParamsEx.js +3 -3
- package/lib/uses/useTimeout.js +2 -2
- package/lib/uses/useWindowScroll.js +3 -3
- package/lib/uses/useWindowSize.js +4 -5
- package/package.json +72 -74
- package/src/app/CoreConstants.ts +8 -8
- package/src/app/EventWatcher.ts +50 -52
- package/src/app/InputDialogProps.ts +16 -16
- package/src/app/ReactUtils.ts +206 -208
- package/src/components/DnDList.tsx +268 -283
- package/src/components/DynamicRouter.tsx +35 -35
- package/src/components/GridColumn.ts +201 -201
- package/src/components/GridLoader.ts +121 -121
- package/src/components/GridMethodRef.ts +26 -26
- package/src/components/ListItemReact.ts +2 -2
- package/src/components/ScrollRestoration.tsx +24 -24
- package/src/components/ScrollerGrid.tsx +428 -448
- package/src/components/ScrollerList.tsx +320 -332
- package/src/custom/CustomFieldReact.ts +12 -12
- package/src/index.ts +35 -35
- package/src/notifier/Notifier.ts +229 -240
- package/src/states/CultureState.ts +51 -52
- package/src/states/IState.ts +19 -19
- package/src/states/PageState.ts +63 -66
- package/src/states/State.tsx +47 -51
- package/src/states/UserState.ts +98 -98
- package/src/uses/useAsyncState.ts +37 -39
- package/src/uses/useCombinedRefs.ts +16 -16
- package/src/uses/useDelayedExecutor.ts +8 -8
- package/src/uses/useDimensions.ts +102 -103
- package/src/uses/useParamsEx.ts +6 -6
- package/src/uses/useRefs.ts +6 -6
- package/src/uses/useSearchParamsEx.ts +13 -13
- package/src/uses/useTimeout.ts +17 -17
- package/src/uses/useWindowScroll.ts +43 -43
- package/src/uses/useWindowSize.ts +46 -49
- package/tsconfig.json +17 -17
- package/.eslintignore +0 -3
- package/.eslintrc.json +0 -38
- package/.prettierignore +0 -5
- package/.prettierrc +0 -6
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { DataTypes, DomUtils } from
|
|
2
|
-
import { useSearchParams } from
|
|
1
|
+
import { DataTypes, DomUtils } from "@etsoo/shared";
|
|
2
|
+
import { useSearchParams } from "react-router-dom";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Extended useSearchParams of react-router-dom
|
|
6
6
|
* Provide exact type data
|
|
7
7
|
*/
|
|
8
8
|
export function useSearchParamsEx<T extends DataTypes.BasicTemplate>(
|
|
9
|
-
|
|
9
|
+
template: T
|
|
10
10
|
) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
// Get parameters
|
|
12
|
+
const [sp] = useSearchParams();
|
|
13
|
+
const paras = Object.fromEntries(
|
|
14
|
+
Object.keys(template).map((key) => {
|
|
15
|
+
const type = template[key];
|
|
16
|
+
return [key, type.endsWith("[]") ? sp.getAll(key) : sp.get(key)];
|
|
17
|
+
})
|
|
18
|
+
);
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
// Return
|
|
21
|
+
return DomUtils.dataAs(paras, template, false);
|
|
22
22
|
}
|
package/src/uses/useTimeout.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExtendUtils } from
|
|
2
|
-
import React from
|
|
1
|
+
import { ExtendUtils } from "@etsoo/shared";
|
|
2
|
+
import React from "react";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* For setTimeout to merge actions
|
|
@@ -7,23 +7,23 @@ import React from 'react';
|
|
|
7
7
|
* @param milliseconds Interval of milliseconds
|
|
8
8
|
*/
|
|
9
9
|
export const useTimeout = (
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
action: (...args: any[]) => void,
|
|
11
|
+
milliseconds: number
|
|
12
12
|
) => {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
// Delayed
|
|
14
|
+
const d = ExtendUtils.delayedExecutor(action, milliseconds);
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
// Merge into the life cycle
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
d.call();
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
}, []);
|
|
24
|
-
|
|
25
|
-
// Return cancel method
|
|
26
|
-
return {
|
|
27
|
-
cancel: d.clear
|
|
20
|
+
return () => {
|
|
21
|
+
d.clear();
|
|
28
22
|
};
|
|
23
|
+
}, []);
|
|
24
|
+
|
|
25
|
+
// Return cancel method
|
|
26
|
+
return {
|
|
27
|
+
cancel: d.clear
|
|
28
|
+
};
|
|
29
29
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from "react";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Window scroll position
|
|
5
5
|
*/
|
|
6
6
|
export interface IScrollPos {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -13,51 +13,51 @@ export interface IScrollPos {
|
|
|
13
13
|
* @returns Scroll location
|
|
14
14
|
*/
|
|
15
15
|
export const useWindowScroll = () => {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// State
|
|
17
|
+
const [pos, setPos] = React.useState<IScrollPos>({
|
|
18
|
+
x: window.scrollX,
|
|
19
|
+
y: window.scrollY
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
let ticking = false;
|
|
24
|
+
let lastPos: IScrollPos;
|
|
25
|
+
let requestAnimationFrameSeed = 0;
|
|
26
|
+
|
|
27
|
+
const scrollHandler = () => {
|
|
28
|
+
lastPos = {
|
|
18
29
|
x: window.scrollX,
|
|
19
30
|
y: window.scrollY
|
|
20
|
-
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
if (!ticking) {
|
|
34
|
+
requestAnimationFrameSeed = window.requestAnimationFrame(() => {
|
|
35
|
+
ticking = false;
|
|
36
|
+
requestAnimationFrameSeed = 0;
|
|
21
37
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
let requestAnimationFrameSeed = 0;
|
|
26
|
-
|
|
27
|
-
const scrollHandler = () => {
|
|
28
|
-
lastPos = {
|
|
29
|
-
x: window.scrollX,
|
|
30
|
-
y: window.scrollY
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
if (!ticking) {
|
|
34
|
-
requestAnimationFrameSeed = window.requestAnimationFrame(() => {
|
|
35
|
-
ticking = false;
|
|
36
|
-
requestAnimationFrameSeed = 0;
|
|
37
|
-
|
|
38
|
-
if (lastPos.x != pos.x || lastPos.y != pos.y) {
|
|
39
|
-
setPos(lastPos);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
ticking = true;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
window.addEventListener('scroll', scrollHandler, {
|
|
47
|
-
passive: true,
|
|
48
|
-
capture: false
|
|
38
|
+
if (lastPos.x != pos.x || lastPos.y != pos.y) {
|
|
39
|
+
setPos(lastPos);
|
|
40
|
+
}
|
|
49
41
|
});
|
|
42
|
+
ticking = true;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
window.addEventListener("scroll", scrollHandler, {
|
|
47
|
+
passive: true,
|
|
48
|
+
capture: false
|
|
49
|
+
});
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
return () => {
|
|
52
|
+
// Cancel animation frame
|
|
53
|
+
if (requestAnimationFrameSeed > 0)
|
|
54
|
+
window.cancelAnimationFrame(requestAnimationFrameSeed);
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
// Remove scroll event
|
|
57
|
+
window.removeEventListener("scroll", scrollHandler);
|
|
58
|
+
};
|
|
59
|
+
}, []);
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
// Return
|
|
62
|
+
return pos;
|
|
63
63
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from "react";
|
|
2
2
|
|
|
3
3
|
interface ISize {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -10,54 +10,51 @@ interface ISize {
|
|
|
10
10
|
* @returns Window size
|
|
11
11
|
*/
|
|
12
12
|
export const useWindowSize = () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
) {
|
|
39
|
-
setSize(lastSize);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
ticking = true;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
window.addEventListener('resize', resizeHandler, {
|
|
47
|
-
passive: true,
|
|
48
|
-
capture: false
|
|
13
|
+
// State
|
|
14
|
+
const [size, setSize] = React.useState<ISize>({
|
|
15
|
+
width: 0,
|
|
16
|
+
height: 0
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
let ticking = false;
|
|
21
|
+
let lastSize: ISize;
|
|
22
|
+
let requestAnimationFrameSeed = 0;
|
|
23
|
+
|
|
24
|
+
const resizeHandler = () => {
|
|
25
|
+
lastSize = {
|
|
26
|
+
width: document.documentElement.clientWidth,
|
|
27
|
+
height: document.documentElement.clientHeight
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
if (!ticking) {
|
|
31
|
+
requestAnimationFrameSeed = window.requestAnimationFrame(() => {
|
|
32
|
+
ticking = false;
|
|
33
|
+
requestAnimationFrameSeed = 0;
|
|
34
|
+
|
|
35
|
+
if (lastSize.width != size.width || lastSize.height != size.height) {
|
|
36
|
+
setSize(lastSize);
|
|
37
|
+
}
|
|
49
38
|
});
|
|
39
|
+
ticking = true;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
window.addEventListener("resize", resizeHandler, {
|
|
44
|
+
passive: true,
|
|
45
|
+
capture: false
|
|
46
|
+
});
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
return () => {
|
|
49
|
+
// Cancel animation frame
|
|
50
|
+
if (requestAnimationFrameSeed > 0)
|
|
51
|
+
window.cancelAnimationFrame(requestAnimationFrameSeed);
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
// Remove resize event
|
|
54
|
+
window.removeEventListener("resize", resizeHandler);
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
60
57
|
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
// Return
|
|
59
|
+
return size;
|
|
63
60
|
};
|
package/tsconfig.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
+
"target": "ES2020",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"allowJs": false,
|
|
8
|
+
"isolatedModules": true,
|
|
9
|
+
"outDir": "./lib",
|
|
10
|
+
"noEmit": false,
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"jsx": "react-jsx",
|
|
16
|
+
"forceConsistentCasingInFileNames": true
|
|
17
|
+
},
|
|
18
|
+
"include": ["src"]
|
|
19
19
|
}
|
package/.eslintignore
DELETED
package/.eslintrc.json
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"node": true,
|
|
5
|
-
"es6": true,
|
|
6
|
-
"jest": true
|
|
7
|
-
},
|
|
8
|
-
"extends": ["plugin:react/recommended", "airbnb-base", "prettier"],
|
|
9
|
-
"parser": "@typescript-eslint/parser",
|
|
10
|
-
"parserOptions": {
|
|
11
|
-
"ecmaFeatures": {
|
|
12
|
-
"jsx": true
|
|
13
|
-
},
|
|
14
|
-
"ecmaVersion": 6,
|
|
15
|
-
"sourceType": "module"
|
|
16
|
-
},
|
|
17
|
-
"plugins": ["@typescript-eslint"],
|
|
18
|
-
"rules": {
|
|
19
|
-
"class-methods-use-this": "off",
|
|
20
|
-
"import/extensions": ["error", "never"],
|
|
21
|
-
"import/prefer-default-export": "off",
|
|
22
|
-
"@typescript-eslint/no-unused-vars": ["error"]
|
|
23
|
-
},
|
|
24
|
-
"settings": {
|
|
25
|
-
"import/resolver": {
|
|
26
|
-
"node": {
|
|
27
|
-
"paths": ["src"],
|
|
28
|
-
"extensions": [".ts", ".tsx"]
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"react": {
|
|
32
|
-
"createClass": "createReactClass",
|
|
33
|
-
"pragma": "React",
|
|
34
|
-
"version": "detect",
|
|
35
|
-
"flowVersion": "0.53"
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
package/.prettierignore
DELETED