@etsoo/react 1.7.93 → 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.
Files changed (93) hide show
  1. package/README.md +2 -1
  2. package/__tests__/EventWatcher.tsx +21 -21
  3. package/__tests__/ReactUtils.ts +4 -4
  4. package/__tests__/tsconfig.json +17 -17
  5. package/babel.config.json +8 -8
  6. package/lib/app/CoreConstants.js +2 -2
  7. package/lib/app/EventWatcher.d.ts +1 -1
  8. package/lib/app/EventWatcher.js +3 -5
  9. package/lib/app/InputDialogProps.d.ts +2 -2
  10. package/lib/app/ReactUtils.d.ts +2 -2
  11. package/lib/app/ReactUtils.js +20 -19
  12. package/lib/components/DnDList.d.ts +3 -3
  13. package/lib/components/DnDList.js +4 -4
  14. package/lib/components/DynamicRouter.d.ts +9 -1
  15. package/lib/components/DynamicRouter.js +18 -2
  16. package/lib/components/GridColumn.d.ts +6 -6
  17. package/lib/components/GridColumn.js +7 -7
  18. package/lib/components/GridLoader.d.ts +4 -4
  19. package/lib/components/GridLoader.js +2 -2
  20. package/lib/components/GridMethodRef.d.ts +2 -2
  21. package/lib/components/ListItemReact.d.ts +2 -2
  22. package/lib/components/ScrollRestoration.js +3 -3
  23. package/lib/components/ScrollerGrid.d.ts +7 -12
  24. package/lib/components/ScrollerGrid.js +13 -17
  25. package/lib/components/ScrollerList.d.ts +6 -10
  26. package/lib/components/ScrollerList.js +15 -14
  27. package/lib/custom/CustomFieldReact.d.ts +1 -1
  28. package/lib/index.d.ts +32 -32
  29. package/lib/index.js +31 -31
  30. package/lib/notifier/Notifier.d.ts +5 -5
  31. package/lib/notifier/Notifier.js +7 -7
  32. package/lib/states/CultureState.d.ts +3 -3
  33. package/lib/states/CultureState.js +3 -3
  34. package/lib/states/IState.d.ts +2 -2
  35. package/lib/states/PageState.d.ts +2 -2
  36. package/lib/states/PageState.js +2 -3
  37. package/lib/states/State.d.ts +3 -3
  38. package/lib/states/State.js +2 -2
  39. package/lib/states/UserState.d.ts +2 -2
  40. package/lib/states/UserState.js +5 -5
  41. package/lib/uses/useAsyncState.d.ts +1 -1
  42. package/lib/uses/useAsyncState.js +1 -1
  43. package/lib/uses/useCombinedRefs.js +2 -2
  44. package/lib/uses/useDelayedExecutor.d.ts +1 -1
  45. package/lib/uses/useDelayedExecutor.js +2 -2
  46. package/lib/uses/useDimensions.d.ts +1 -1
  47. package/lib/uses/useDimensions.js +3 -3
  48. package/lib/uses/useParamsEx.d.ts +1 -1
  49. package/lib/uses/useParamsEx.js +2 -2
  50. package/lib/uses/useRefs.d.ts +2 -2
  51. package/lib/uses/useRefs.js +1 -1
  52. package/lib/uses/useSearchParamsEx.d.ts +1 -1
  53. package/lib/uses/useSearchParamsEx.js +3 -3
  54. package/lib/uses/useTimeout.js +2 -2
  55. package/lib/uses/useWindowScroll.js +3 -3
  56. package/lib/uses/useWindowSize.js +4 -5
  57. package/package.json +72 -74
  58. package/src/app/CoreConstants.ts +8 -8
  59. package/src/app/EventWatcher.ts +50 -52
  60. package/src/app/InputDialogProps.ts +16 -16
  61. package/src/app/ReactUtils.ts +206 -208
  62. package/src/components/DnDList.tsx +268 -283
  63. package/src/components/DynamicRouter.tsx +46 -21
  64. package/src/components/GridColumn.ts +201 -201
  65. package/src/components/GridLoader.ts +121 -121
  66. package/src/components/GridMethodRef.ts +26 -26
  67. package/src/components/ListItemReact.ts +2 -2
  68. package/src/components/ScrollRestoration.tsx +24 -24
  69. package/src/components/ScrollerGrid.tsx +428 -448
  70. package/src/components/ScrollerList.tsx +320 -332
  71. package/src/custom/CustomFieldReact.ts +12 -12
  72. package/src/index.ts +35 -35
  73. package/src/notifier/Notifier.ts +229 -240
  74. package/src/states/CultureState.ts +51 -52
  75. package/src/states/IState.ts +19 -19
  76. package/src/states/PageState.ts +63 -66
  77. package/src/states/State.tsx +47 -51
  78. package/src/states/UserState.ts +98 -98
  79. package/src/uses/useAsyncState.ts +37 -39
  80. package/src/uses/useCombinedRefs.ts +16 -16
  81. package/src/uses/useDelayedExecutor.ts +8 -8
  82. package/src/uses/useDimensions.ts +102 -103
  83. package/src/uses/useParamsEx.ts +6 -6
  84. package/src/uses/useRefs.ts +6 -6
  85. package/src/uses/useSearchParamsEx.ts +13 -13
  86. package/src/uses/useTimeout.ts +17 -17
  87. package/src/uses/useWindowScroll.ts +43 -43
  88. package/src/uses/useWindowSize.ts +46 -49
  89. package/tsconfig.json +17 -17
  90. package/.eslintignore +0 -3
  91. package/.eslintrc.json +0 -38
  92. package/.prettierignore +0 -5
  93. package/.prettierrc +0 -6
@@ -1,16 +1,12 @@
1
- import { DataTypes } from '@etsoo/shared';
2
- import React from 'react';
3
- import { Align, ListChildComponentProps, ListProps } from 'react-window';
4
- import { GridLoader } from './GridLoader';
5
- import { GridMethodRef } from './GridMethodRef';
1
+ import { DataTypes } from "@etsoo/shared";
2
+ import React from "react";
3
+ import { Align, ListChildComponentProps, ListProps } from "react-window";
4
+ import { GridLoader } from "./GridLoader";
5
+ import { GridMethodRef } from "./GridMethodRef";
6
6
  /**
7
7
  * Scroller vertical list props
8
8
  */
9
- export interface ScrollerListProps<T extends object> extends GridLoader<T>, Omit<ListProps<T>, 'outerRef' | 'height' | 'width' | 'children' | 'itemCount'> {
10
- /**
11
- * Default order by asc/desc
12
- */
13
- defaultOrderByAsc?: boolean;
9
+ export interface ScrollerListProps<T extends object> extends GridLoader<T>, Omit<ListProps<T>, "outerRef" | "height" | "width" | "children" | "itemCount"> {
14
10
  /**
15
11
  * Methods ref
16
12
  */
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
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';
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, defaultOrderByAsc, 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;
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: '100%',
23
- height: '100%',
24
- display: 'inline-block'
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 += pageAdd;
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 === '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
+ 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
  };
@@ -1,4 +1,4 @@
1
- import { CustomFieldData, CustomFieldProps, CustomFieldRef, ICustomField } from '@etsoo/appscript';
1
+ import { CustomFieldData, CustomFieldProps, CustomFieldRef, ICustomField } from "@etsoo/appscript";
2
2
  /**
3
3
  * React custom field interface
4
4
  * React自定义字段接口
package/lib/index.d.ts CHANGED
@@ -1,32 +1,32 @@
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';
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 './app/CoreConstants';
3
- export * from './app/EventWatcher';
4
- export * from './app/InputDialogProps';
5
- export * from './app/ReactUtils';
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 './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';
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 './custom/CustomFieldReact';
17
+ export * from "./custom/CustomFieldReact";
18
18
  // notifier
19
- export * from './notifier/Notifier';
20
- export * from '@etsoo/notificationbase';
19
+ export * from "./notifier/Notifier";
20
+ export * from "@etsoo/notificationbase";
21
21
  // states
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';
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 './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';
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 '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';
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?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | false;
24
+ maxWidth?: "xs" | "sm" | "md" | "lg" | "xl" | false;
25
25
  /**
26
26
  * OK label
27
27
  */
@@ -1,6 +1,6 @@
1
- import React from 'react';
2
- import { Notification, NotificationContainer } from '@etsoo/notificationbase';
3
- import { State } from '../states/State';
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('NotifierReact.updateCallback', notification, dismiss, this.loadingCount);
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 + '-item' : 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('NotifierReact.createProvider', className, state, aligns);
62
+ console.debug("NotifierReact.createProvider", className, state, aligns);
63
63
  }
64
64
  // Generate the component
65
- return React.createElement('div', { className }, aligns);
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 '@etsoo/appscript';
2
- import { DataTypes } from '@etsoo/shared';
3
- import { IProviderProps, IUpdate } from './IState';
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 './State';
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 === 'object' ? resources[key] : undefined;
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 !== 'object')
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) => {
@@ -1,5 +1,5 @@
1
- import { IAction, IState, UserKey } from '@etsoo/appscript';
2
- import React from 'react';
1
+ import { IAction, IState, UserKey } from "@etsoo/appscript";
2
+ import React from "react";
3
3
  /**
4
4
  * State UI creator
5
5
  */
@@ -1,5 +1,5 @@
1
- import { IAction, IState } from '@etsoo/appscript';
2
- import { IProviderProps, IUpdate } from './IState';
1
+ import { IAction, IState } from "@etsoo/appscript";
2
+ import { IProviderProps, IUpdate } from "./IState";
3
3
  /**
4
4
  * Page data interface
5
5
  */
@@ -1,4 +1,4 @@
1
- import { State } from './State';
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 {
@@ -1,6 +1,6 @@
1
- import { IAction, IState } from '@etsoo/appscript';
2
- import React from 'react';
3
- import { IProviderProps, IUICreator, IUpdate } from './IState';
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
  */
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import React from 'react';
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 (_jsx(context.Provider, { value: value, children: children }));
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 '@etsoo/appscript';
2
- import { IProviderProps, IUpdate } from './IState';
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
@@ -1,5 +1,5 @@
1
- import { Utils } from '@etsoo/shared';
2
- import { State } from './State';
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
- 'authorized',
72
- 'seconds',
73
- 'lastChangedFields'
71
+ "authorized",
72
+ "seconds",
73
+ "lastChangedFields"
74
74
  ]);
75
75
  }
76
76
  }
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  export declare function useAsyncState<S = undefined>(): [
3
3
  S | undefined,
4
4
  (newState: React.SetStateAction<S | undefined>) => Promise<S | undefined>
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  /**
3
3
  * Returns a stateful value, and a async function to update it.
4
4
  * @param initialState initial stat
@@ -14,12 +14,12 @@ export function useCombinedRefs(...refs) {
14
14
  if (!ref)
15
15
  return;
16
16
  // Callback function
17
- if (typeof ref === 'function') {
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, 'current', target);
22
+ Reflect.set(ref, "current", target);
23
23
  }
24
24
  });
25
25
  };
@@ -1,4 +1,4 @@
1
- import { DelayedExecutorType } from '@etsoo/shared';
1
+ import { DelayedExecutorType } from "@etsoo/shared";
2
2
  /**
3
3
  * Create delayed executor
4
4
  */
@@ -1,5 +1,5 @@
1
- import { ExtendUtils } from '@etsoo/shared';
2
- import React from 'react';
1
+ import { ExtendUtils } from "@etsoo/shared";
2
+ import React from "react";
3
3
  /**
4
4
  * Create delayed executor
5
5
  */
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  interface states {
3
3
  count: number;
4
4
  indices: number[];
@@ -1,6 +1,6 @@
1
- import { DomUtils } from '@etsoo/shared';
2
- import React from 'react';
3
- import { useDelayedExecutor } from './useDelayedExecutor';
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
@@ -1,4 +1,4 @@
1
- import { DataTypes } from '@etsoo/shared';
1
+ import { DataTypes } from "@etsoo/shared";
2
2
  /**
3
3
  * Extended useParams of react-router-dom
4
4
  * Provide exact type data
@@ -1,5 +1,5 @@
1
- import { DomUtils } from '@etsoo/shared';
2
- import { useParams } from 'react-router-dom';
1
+ import { DomUtils } from "@etsoo/shared";
2
+ import { useParams } from "react-router-dom";
3
3
  /**
4
4
  * Extended useParams of react-router-dom
5
5
  * Provide exact type data
@@ -1,5 +1,5 @@
1
- import { DataTypes } from '@etsoo/shared';
2
- import React from 'react';
1
+ import { DataTypes } from "@etsoo/shared";
2
+ import React from "react";
3
3
  /**
4
4
  * Create multiple refs
5
5
  * @param fields Fields
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  /**
3
3
  * Create multiple refs
4
4
  * @param fields Fields
@@ -1,4 +1,4 @@
1
- import { DataTypes } from '@etsoo/shared';
1
+ import { DataTypes } from "@etsoo/shared";
2
2
  /**
3
3
  * Extended useSearchParams of react-router-dom
4
4
  * Provide exact type data
@@ -1,5 +1,5 @@
1
- import { DomUtils } from '@etsoo/shared';
2
- import { useSearchParams } from 'react-router-dom';
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('[]') ? sp.getAll(key) : sp.get(key)];
12
+ return [key, type.endsWith("[]") ? sp.getAll(key) : sp.get(key)];
13
13
  }));
14
14
  // Return
15
15
  return DomUtils.dataAs(paras, template, false);
@@ -1,5 +1,5 @@
1
- import { ExtendUtils } from '@etsoo/shared';
2
- import React from 'react';
1
+ import { ExtendUtils } from "@etsoo/shared";
2
+ import React from "react";
3
3
  /**
4
4
  * For setTimeout to merge actions
5
5
  * @param action Action function
@@ -1,4 +1,4 @@
1
- import React from 'react';
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('scroll', scrollHandler, {
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('scroll', scrollHandler);
41
+ window.removeEventListener("scroll", scrollHandler);
42
42
  };
43
43
  }, []);
44
44
  // Return
@@ -1,4 +1,4 @@
1
- import React from 'react';
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('resize', resizeHandler, {
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('resize', resizeHandler);
41
+ window.removeEventListener("resize", resizeHandler);
43
42
  };
44
43
  }, []);
45
44
  // Return