@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,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { DataTypes, Utils } from
|
|
3
|
-
import React from
|
|
4
|
-
import { FixedSizeList, VariableSizeList } from
|
|
5
|
-
import { useCombinedRefs } from
|
|
6
|
-
import { GridSizeGet } from
|
|
2
|
+
import { DataTypes, Utils } from "@etsoo/shared";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { FixedSizeList, VariableSizeList } from "react-window";
|
|
5
|
+
import { useCombinedRefs } from "../uses/useCombinedRefs";
|
|
6
|
+
import { GridSizeGet } from "./GridLoader";
|
|
7
7
|
// Calculate loadBatchSize
|
|
8
8
|
const calculateBatchSize = (height, itemSize) => {
|
|
9
9
|
const size = Utils.getResult(itemSize, 0);
|
|
@@ -16,12 +16,12 @@ const calculateBatchSize = (height, itemSize) => {
|
|
|
16
16
|
*/
|
|
17
17
|
export const ScrollerList = (props) => {
|
|
18
18
|
// Destruct
|
|
19
|
-
const { autoLoad = true, defaultOrderBy,
|
|
19
|
+
const { autoLoad = true, defaultOrderBy, height = document.documentElement.clientHeight, width = "100%", mRef, oRef, style = {}, idField = "id", itemRenderer, itemSize, loadBatchSize = calculateBatchSize(height, itemSize), loadData, threshold = GridSizeGet(loadBatchSize, height) / 2, onItemsRendered, onInitLoad, onUpdateRows, ...rest } = props;
|
|
20
20
|
// Style
|
|
21
21
|
Object.assign(style, {
|
|
22
|
-
width:
|
|
23
|
-
height:
|
|
24
|
-
display:
|
|
22
|
+
width: "100%",
|
|
23
|
+
height: "100%",
|
|
24
|
+
display: "inline-block"
|
|
25
25
|
});
|
|
26
26
|
// Refs
|
|
27
27
|
const listRef = React.useRef();
|
|
@@ -41,7 +41,6 @@ export const ScrollerList = (props) => {
|
|
|
41
41
|
queryPaging: {
|
|
42
42
|
currentPage: 0,
|
|
43
43
|
orderBy: defaultOrderBy,
|
|
44
|
-
orderByAsc: defaultOrderByAsc,
|
|
45
44
|
batchSize
|
|
46
45
|
},
|
|
47
46
|
autoLoad,
|
|
@@ -54,8 +53,7 @@ export const ScrollerList = (props) => {
|
|
|
54
53
|
// Load data
|
|
55
54
|
const loadDataLocal = (pageAdd = 1) => {
|
|
56
55
|
// Prevent multiple loadings
|
|
57
|
-
if (!stateRefs.current.hasNextPage ||
|
|
58
|
-
stateRefs.current.isNextPageLoading)
|
|
56
|
+
if (!stateRefs.current.hasNextPage || stateRefs.current.isNextPageLoading)
|
|
59
57
|
return;
|
|
60
58
|
// Update state
|
|
61
59
|
stateRefs.current.isNextPageLoading = true;
|
|
@@ -90,7 +88,10 @@ export const ScrollerList = (props) => {
|
|
|
90
88
|
setRows(newRows);
|
|
91
89
|
}
|
|
92
90
|
else {
|
|
93
|
-
stateRefs.current.queryPaging.currentPage
|
|
91
|
+
if (stateRefs.current.queryPaging.currentPage == null)
|
|
92
|
+
stateRefs.current.queryPaging.currentPage = pageAdd;
|
|
93
|
+
else
|
|
94
|
+
stateRefs.current.queryPaging.currentPage += pageAdd;
|
|
94
95
|
// Update rows, avoid duplicate items
|
|
95
96
|
const newRows = [...rows];
|
|
96
97
|
for (const item of result) {
|
|
@@ -191,5 +192,5 @@ export const ScrollerList = (props) => {
|
|
|
191
192
|
loadDataLocal();
|
|
192
193
|
}
|
|
193
194
|
// Layout
|
|
194
|
-
return typeof itemSize ===
|
|
195
|
+
return typeof itemSize === "function" ? (_jsx(VariableSizeList, { height: height, width: width, itemCount: itemCount, itemKey: (index, data) => DataTypes.getIdValue1(data, idField) ?? index, itemSize: itemSize, outerRef: refs, ref: listRef, style: style, onItemsRendered: onItemsRenderedLocal, ...rest, children: itemRendererLocal })) : (_jsx(FixedSizeList, { height: height, width: width, itemCount: itemCount, itemKey: (index, data) => DataTypes.getIdValue1(data, idField) ?? index, itemSize: itemSize, outerRef: refs, ref: listRef, style: style, onItemsRendered: onItemsRenderedLocal, ...rest, children: itemRendererLocal }));
|
|
195
196
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export type { ListOnScrollProps, GridOnScrollProps, VariableSizeGrid } from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
19
|
-
export * from
|
|
20
|
-
export * from
|
|
21
|
-
export * from
|
|
22
|
-
export * from
|
|
23
|
-
export * from
|
|
24
|
-
export * from
|
|
25
|
-
export * from
|
|
26
|
-
export * from
|
|
27
|
-
export * from
|
|
28
|
-
export * from
|
|
29
|
-
export * from
|
|
30
|
-
export * from
|
|
31
|
-
export * from
|
|
32
|
-
export * from
|
|
1
|
+
export * from "./app/CoreConstants";
|
|
2
|
+
export * from "./app/EventWatcher";
|
|
3
|
+
export * from "./app/InputDialogProps";
|
|
4
|
+
export * from "./app/ReactUtils";
|
|
5
|
+
export * from "./components/DnDList";
|
|
6
|
+
export * from "./components/DynamicRouter";
|
|
7
|
+
export * from "./components/GridColumn";
|
|
8
|
+
export * from "./components/GridLoader";
|
|
9
|
+
export * from "./components/GridMethodRef";
|
|
10
|
+
export * from "./components/ListItemReact";
|
|
11
|
+
export * from "./components/ScrollerGrid";
|
|
12
|
+
export * from "./components/ScrollerList";
|
|
13
|
+
export * from "./components/ScrollRestoration";
|
|
14
|
+
export type { ListOnScrollProps, GridOnScrollProps, VariableSizeGrid } from "react-window";
|
|
15
|
+
export * from "./custom/CustomFieldReact";
|
|
16
|
+
export * from "./notifier/Notifier";
|
|
17
|
+
export * from "@etsoo/notificationbase";
|
|
18
|
+
export * from "./states/CultureState";
|
|
19
|
+
export * from "./states/IState";
|
|
20
|
+
export * from "./states/PageState";
|
|
21
|
+
export * from "./states/State";
|
|
22
|
+
export * from "./states/UserState";
|
|
23
|
+
export * from "./uses/useAsyncState";
|
|
24
|
+
export * from "./uses/useCombinedRefs";
|
|
25
|
+
export * from "./uses/useDelayedExecutor";
|
|
26
|
+
export * from "./uses/useDimensions";
|
|
27
|
+
export * from "./uses/useParamsEx";
|
|
28
|
+
export * from "./uses/useRefs";
|
|
29
|
+
export * from "./uses/useSearchParamsEx";
|
|
30
|
+
export * from "./uses/useTimeout";
|
|
31
|
+
export * from "./uses/useWindowScroll";
|
|
32
|
+
export * from "./uses/useWindowSize";
|
package/lib/index.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
// app
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
2
|
+
export * from "./app/CoreConstants";
|
|
3
|
+
export * from "./app/EventWatcher";
|
|
4
|
+
export * from "./app/InputDialogProps";
|
|
5
|
+
export * from "./app/ReactUtils";
|
|
6
6
|
// components
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
7
|
+
export * from "./components/DnDList";
|
|
8
|
+
export * from "./components/DynamicRouter";
|
|
9
|
+
export * from "./components/GridColumn";
|
|
10
|
+
export * from "./components/GridLoader";
|
|
11
|
+
export * from "./components/GridMethodRef";
|
|
12
|
+
export * from "./components/ListItemReact";
|
|
13
|
+
export * from "./components/ScrollerGrid";
|
|
14
|
+
export * from "./components/ScrollerList";
|
|
15
|
+
export * from "./components/ScrollRestoration";
|
|
16
16
|
// custom
|
|
17
|
-
export * from
|
|
17
|
+
export * from "./custom/CustomFieldReact";
|
|
18
18
|
// notifier
|
|
19
|
-
export * from
|
|
20
|
-
export * from
|
|
19
|
+
export * from "./notifier/Notifier";
|
|
20
|
+
export * from "@etsoo/notificationbase";
|
|
21
21
|
// states
|
|
22
|
-
export * from
|
|
23
|
-
export * from
|
|
24
|
-
export * from
|
|
25
|
-
export * from
|
|
26
|
-
export * from
|
|
22
|
+
export * from "./states/CultureState";
|
|
23
|
+
export * from "./states/IState";
|
|
24
|
+
export * from "./states/PageState";
|
|
25
|
+
export * from "./states/State";
|
|
26
|
+
export * from "./states/UserState";
|
|
27
27
|
// uses
|
|
28
|
-
export * from
|
|
29
|
-
export * from
|
|
30
|
-
export * from
|
|
31
|
-
export * from
|
|
32
|
-
export * from
|
|
33
|
-
export * from
|
|
34
|
-
export * from
|
|
35
|
-
export * from
|
|
36
|
-
export * from
|
|
37
|
-
export * from
|
|
28
|
+
export * from "./uses/useAsyncState";
|
|
29
|
+
export * from "./uses/useCombinedRefs";
|
|
30
|
+
export * from "./uses/useDelayedExecutor";
|
|
31
|
+
export * from "./uses/useDimensions";
|
|
32
|
+
export * from "./uses/useParamsEx";
|
|
33
|
+
export * from "./uses/useRefs";
|
|
34
|
+
export * from "./uses/useSearchParamsEx";
|
|
35
|
+
export * from "./uses/useTimeout";
|
|
36
|
+
export * from "./uses/useWindowScroll";
|
|
37
|
+
export * from "./uses/useWindowSize";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { INotificaseBase, INotification, INotifier, Notification, NotificationAlign, NotificationCallProps, NotificationContainer, NotificationRenderProps } from
|
|
3
|
-
import { IAction } from
|
|
4
|
-
import { IProviderProps } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { INotificaseBase, INotification, INotifier, Notification, NotificationAlign, NotificationCallProps, NotificationContainer, NotificationRenderProps } from "@etsoo/notificationbase";
|
|
3
|
+
import { IAction } from "@etsoo/appscript";
|
|
4
|
+
import { IProviderProps } from "../states/IState";
|
|
5
5
|
/**
|
|
6
6
|
* React notification call props
|
|
7
7
|
*/
|
|
@@ -21,7 +21,7 @@ export interface NotificationReactCallProps extends NotificationCallProps {
|
|
|
21
21
|
/**
|
|
22
22
|
* Max width
|
|
23
23
|
*/
|
|
24
|
-
maxWidth?:
|
|
24
|
+
maxWidth?: "xs" | "sm" | "md" | "lg" | "xl" | false;
|
|
25
25
|
/**
|
|
26
26
|
* OK label
|
|
27
27
|
*/
|
package/lib/notifier/Notifier.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Notification, NotificationContainer } from
|
|
3
|
-
import { State } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Notification, NotificationContainer } from "@etsoo/notificationbase";
|
|
3
|
+
import { State } from "../states/State";
|
|
4
4
|
/**
|
|
5
5
|
* React notification
|
|
6
6
|
*/
|
|
@@ -30,7 +30,7 @@ export class NotifierReact extends NotificationContainer {
|
|
|
30
30
|
super((notification, dismiss) => {
|
|
31
31
|
// Debug
|
|
32
32
|
if (this.debug) {
|
|
33
|
-
console.debug(
|
|
33
|
+
console.debug("NotifierReact.updateCallback", notification, dismiss, this.loadingCount);
|
|
34
34
|
}
|
|
35
35
|
// Make sure the state update is set
|
|
36
36
|
if (this.stateUpdate)
|
|
@@ -53,16 +53,16 @@ export class NotifierReact extends NotificationContainer {
|
|
|
53
53
|
// Notifications under the align
|
|
54
54
|
const notifications = state[align];
|
|
55
55
|
// UI collections
|
|
56
|
-
const ui = notifications.map((notification) => notification.render(props, className ? className +
|
|
56
|
+
const ui = notifications.map((notification) => notification.render(props, className ? className + "-item" : className));
|
|
57
57
|
// Add to the collection
|
|
58
58
|
aligns.push(this.createContainer(Number(align), ui));
|
|
59
59
|
}
|
|
60
60
|
// Debug
|
|
61
61
|
if (debug) {
|
|
62
|
-
console.debug(
|
|
62
|
+
console.debug("NotifierReact.createProvider", className, state, aligns);
|
|
63
63
|
}
|
|
64
64
|
// Generate the component
|
|
65
|
-
return React.createElement(
|
|
65
|
+
return React.createElement("div", { className }, aligns);
|
|
66
66
|
};
|
|
67
67
|
// Create state
|
|
68
68
|
const { provider } = State.create((state, _action) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IAction, ICulture } from
|
|
2
|
-
import { DataTypes } from
|
|
3
|
-
import { IProviderProps, IUpdate } from
|
|
1
|
+
import { IAction, ICulture } from "@etsoo/appscript";
|
|
2
|
+
import { DataTypes } from "@etsoo/shared";
|
|
3
|
+
import { IProviderProps, IUpdate } from "./IState";
|
|
4
4
|
/**
|
|
5
5
|
* Culture action to manage resources
|
|
6
6
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { State } from
|
|
1
|
+
import { State } from "./State";
|
|
2
2
|
// Calls
|
|
3
3
|
const calls = {
|
|
4
4
|
/**
|
|
@@ -7,7 +7,7 @@ const calls = {
|
|
|
7
7
|
*/
|
|
8
8
|
get(key) {
|
|
9
9
|
const resources = this.state.resources;
|
|
10
|
-
const value = typeof resources ===
|
|
10
|
+
const value = typeof resources === "object" ? resources[key] : undefined;
|
|
11
11
|
if (value == null)
|
|
12
12
|
return undefined;
|
|
13
13
|
return value;
|
|
@@ -26,7 +26,7 @@ export class CultureState {
|
|
|
26
26
|
// Default
|
|
27
27
|
const defaultItem = item ?? {};
|
|
28
28
|
// Load resources
|
|
29
|
-
if (item != null && typeof item.resources !==
|
|
29
|
+
if (item != null && typeof item.resources !== "object")
|
|
30
30
|
item.resources().then((result) => (item.resources = result));
|
|
31
31
|
// Act
|
|
32
32
|
const { context, provider } = State.create((state, action) => {
|
package/lib/states/IState.d.ts
CHANGED
package/lib/states/PageState.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { State } from
|
|
1
|
+
import { State } from "./State";
|
|
2
2
|
/**
|
|
3
3
|
* Page action type
|
|
4
4
|
*/
|
|
@@ -25,8 +25,7 @@ export class PageState {
|
|
|
25
25
|
return { ...state, ...data };
|
|
26
26
|
case PageActionType.Title:
|
|
27
27
|
// Same title
|
|
28
|
-
if (state.title === data.title &&
|
|
29
|
-
state.subtitle === data.subtitle)
|
|
28
|
+
if (state.title === data.title && state.subtitle === data.subtitle)
|
|
30
29
|
return state;
|
|
31
30
|
// Set page title
|
|
32
31
|
return {
|
package/lib/states/State.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IAction, IState } from
|
|
2
|
-
import React from
|
|
3
|
-
import { IProviderProps, IUICreator, IUpdate } from
|
|
1
|
+
import { IAction, IState } from "@etsoo/appscript";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { IProviderProps, IUICreator, IUpdate } from "./IState";
|
|
4
4
|
/**
|
|
5
5
|
* State
|
|
6
6
|
*/
|
package/lib/states/State.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from
|
|
2
|
+
import React from "react";
|
|
3
3
|
/**
|
|
4
4
|
* State
|
|
5
5
|
*/
|
|
@@ -29,7 +29,7 @@ export class State {
|
|
|
29
29
|
else {
|
|
30
30
|
// Context new value
|
|
31
31
|
const value = { ...calls, state, dispatch };
|
|
32
|
-
return
|
|
32
|
+
return _jsx(context.Provider, { value: value, children: children });
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
// Return
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IAction, IUser, IUserData } from
|
|
2
|
-
import { IProviderProps, IUpdate } from
|
|
1
|
+
import { IAction, IUser, IUserData } from "@etsoo/appscript";
|
|
2
|
+
import { IProviderProps, IUpdate } from "./IState";
|
|
3
3
|
/**
|
|
4
4
|
* User action type
|
|
5
5
|
* Style like 'const enum' will remove definition of the enum and cause module errors
|
package/lib/states/UserState.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Utils } from
|
|
2
|
-
import { State } from
|
|
1
|
+
import { Utils } from "@etsoo/shared";
|
|
2
|
+
import { State } from "./State";
|
|
3
3
|
/**
|
|
4
4
|
* User action type
|
|
5
5
|
* Style like 'const enum' will remove definition of the enum and cause module errors
|
|
@@ -68,9 +68,9 @@ export class UserState {
|
|
|
68
68
|
}
|
|
69
69
|
getChangedFields(input, init) {
|
|
70
70
|
return Utils.objectUpdated(input, init, [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
"authorized",
|
|
72
|
+
"seconds",
|
|
73
|
+
"lastChangedFields"
|
|
74
74
|
]);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -14,12 +14,12 @@ export function useCombinedRefs(...refs) {
|
|
|
14
14
|
if (!ref)
|
|
15
15
|
return;
|
|
16
16
|
// Callback function
|
|
17
|
-
if (typeof ref ===
|
|
17
|
+
if (typeof ref === "function") {
|
|
18
18
|
ref(target);
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
21
|
// as any to update readonly property
|
|
22
|
-
Reflect.set(ref,
|
|
22
|
+
Reflect.set(ref, "current", target);
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DomUtils } from
|
|
2
|
-
import React from
|
|
3
|
-
import { useDelayedExecutor } from
|
|
1
|
+
import { DomUtils } from "@etsoo/shared";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { useDelayedExecutor } from "./useDelayedExecutor";
|
|
4
4
|
/**
|
|
5
5
|
* Calculate element(s) dimensions
|
|
6
6
|
* @param elements Observed elments count
|
package/lib/uses/useParamsEx.js
CHANGED
package/lib/uses/useRefs.d.ts
CHANGED
package/lib/uses/useRefs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DomUtils } from
|
|
2
|
-
import { useSearchParams } from
|
|
1
|
+
import { DomUtils } from "@etsoo/shared";
|
|
2
|
+
import { useSearchParams } from "react-router-dom";
|
|
3
3
|
/**
|
|
4
4
|
* Extended useSearchParams of react-router-dom
|
|
5
5
|
* Provide exact type data
|
|
@@ -9,7 +9,7 @@ export function useSearchParamsEx(template) {
|
|
|
9
9
|
const [sp] = useSearchParams();
|
|
10
10
|
const paras = Object.fromEntries(Object.keys(template).map((key) => {
|
|
11
11
|
const type = template[key];
|
|
12
|
-
return [key, type.endsWith(
|
|
12
|
+
return [key, type.endsWith("[]") ? sp.getAll(key) : sp.get(key)];
|
|
13
13
|
}));
|
|
14
14
|
// Return
|
|
15
15
|
return DomUtils.dataAs(paras, template, false);
|
package/lib/uses/useTimeout.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from "react";
|
|
2
2
|
/**
|
|
3
3
|
* Detect window scroll
|
|
4
4
|
* @returns Scroll location
|
|
@@ -29,7 +29,7 @@ export const useWindowScroll = () => {
|
|
|
29
29
|
ticking = true;
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
window.addEventListener(
|
|
32
|
+
window.addEventListener("scroll", scrollHandler, {
|
|
33
33
|
passive: true,
|
|
34
34
|
capture: false
|
|
35
35
|
});
|
|
@@ -38,7 +38,7 @@ export const useWindowScroll = () => {
|
|
|
38
38
|
if (requestAnimationFrameSeed > 0)
|
|
39
39
|
window.cancelAnimationFrame(requestAnimationFrameSeed);
|
|
40
40
|
// Remove scroll event
|
|
41
|
-
window.removeEventListener(
|
|
41
|
+
window.removeEventListener("scroll", scrollHandler);
|
|
42
42
|
};
|
|
43
43
|
}, []);
|
|
44
44
|
// Return
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from "react";
|
|
2
2
|
/**
|
|
3
3
|
* Detect window size
|
|
4
4
|
* @returns Window size
|
|
@@ -22,15 +22,14 @@ export const useWindowSize = () => {
|
|
|
22
22
|
requestAnimationFrameSeed = window.requestAnimationFrame(() => {
|
|
23
23
|
ticking = false;
|
|
24
24
|
requestAnimationFrameSeed = 0;
|
|
25
|
-
if (lastSize.width != size.width ||
|
|
26
|
-
lastSize.height != size.height) {
|
|
25
|
+
if (lastSize.width != size.width || lastSize.height != size.height) {
|
|
27
26
|
setSize(lastSize);
|
|
28
27
|
}
|
|
29
28
|
});
|
|
30
29
|
ticking = true;
|
|
31
30
|
}
|
|
32
31
|
};
|
|
33
|
-
window.addEventListener(
|
|
32
|
+
window.addEventListener("resize", resizeHandler, {
|
|
34
33
|
passive: true,
|
|
35
34
|
capture: false
|
|
36
35
|
});
|
|
@@ -39,7 +38,7 @@ export const useWindowSize = () => {
|
|
|
39
38
|
if (requestAnimationFrameSeed > 0)
|
|
40
39
|
window.cancelAnimationFrame(requestAnimationFrameSeed);
|
|
41
40
|
// Remove resize event
|
|
42
|
-
window.removeEventListener(
|
|
41
|
+
window.removeEventListener("resize", resizeHandler);
|
|
43
42
|
};
|
|
44
43
|
}, []);
|
|
45
44
|
// Return
|