@etsoo/react 1.7.94 → 1.7.96

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 +2 -2
  15. package/lib/components/DynamicRouter.js +2 -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 +35 -35
  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,8 +1,8 @@
1
- import { EntityStatus } from '@etsoo/appscript';
2
- import { DataTypes } from '@etsoo/shared';
3
- import React from 'react';
4
- import { GridLoaderStates } from './GridLoader';
5
- import { ScrollerGridForwardRef } from './ScrollerGrid';
1
+ import { EntityStatus } from "@etsoo/appscript";
2
+ import { DataTypes } from "@etsoo/shared";
3
+ import React from "react";
4
+ import { GridLoaderStates } from "./GridLoader";
5
+ import { ScrollerGridForwardRef } from "./ScrollerGrid";
6
6
 
7
7
  /**
8
8
  * Grid data type
@@ -13,7 +13,7 @@ export { GridDataType };
13
13
  /**
14
14
  * Grid align
15
15
  */
16
- export type GridAlign = 'center' | 'inherit' | 'justify' | 'left' | 'right';
16
+ export type GridAlign = "center" | "inherit" | "justify" | "left" | "right";
17
17
 
18
18
  /**
19
19
  * Data align get
@@ -21,17 +21,17 @@ export type GridAlign = 'center' | 'inherit' | 'justify' | 'left' | 'right';
21
21
  * @param type Data type
22
22
  */
23
23
  export const GridAlignGet = (align?: GridAlign, type?: GridDataType) => {
24
- if (align == null && type != null) {
25
- if (
26
- type === GridDataType.Money ||
27
- type === GridDataType.IntMoney ||
28
- type === GridDataType.Int ||
29
- type === GridDataType.Number
30
- )
31
- return 'right';
32
- else if (type === GridDataType.Boolean) return 'center';
33
- }
34
- return align;
24
+ if (align == null && type != null) {
25
+ if (
26
+ type === GridDataType.Money ||
27
+ type === GridDataType.IntMoney ||
28
+ type === GridDataType.Int ||
29
+ type === GridDataType.Number
30
+ )
31
+ return "right";
32
+ else if (type === GridDataType.Boolean) return "center";
33
+ }
34
+ return align;
35
35
  };
36
36
 
37
37
  /**
@@ -40,21 +40,21 @@ export const GridAlignGet = (align?: GridAlign, type?: GridDataType) => {
40
40
  * @returns Result
41
41
  */
42
42
  export const GridDeletedCellBoxStyle = (
43
- data: undefined | { status: EntityStatus } | { entityStatus: EntityStatus }
43
+ data: undefined | { status: EntityStatus } | { entityStatus: EntityStatus }
44
44
  ): React.CSSProperties => {
45
- if (data == null) return {};
45
+ if (data == null) return {};
46
46
 
47
- const status =
48
- 'status' in data
49
- ? data.status
50
- : 'entityStatus' in data
51
- ? data.entityStatus
52
- : EntityStatus.Normal;
47
+ const status =
48
+ "status" in data
49
+ ? data.status
50
+ : "entityStatus" in data
51
+ ? data.entityStatus
52
+ : EntityStatus.Normal;
53
53
 
54
- if (status === EntityStatus.Inactivated || status === EntityStatus.Deleted)
55
- return { textDecoration: 'line-through' };
54
+ if (status === EntityStatus.Inactivated || status === EntityStatus.Deleted)
55
+ return { textDecoration: "line-through" };
56
56
 
57
- return {};
57
+ return {};
58
58
  };
59
59
 
60
60
  /**
@@ -66,201 +66,201 @@ export type GridCellValueType = string | number | Date | boolean | undefined;
66
66
  * Grid cell formatter props
67
67
  */
68
68
  export type GridCellFormatterProps<T> = {
69
- /**
70
- * Current data
71
- */
72
- data?: T;
73
-
74
- /**
75
- * Data field
76
- */
77
- field?: string;
78
-
79
- /**
80
- * Row index
81
- */
82
- rowIndex: number;
83
-
84
- /**
85
- * Column index
86
- */
87
- columnIndex: number;
69
+ /**
70
+ * Current data
71
+ */
72
+ data?: T;
73
+
74
+ /**
75
+ * Data field
76
+ */
77
+ field?: string;
78
+
79
+ /**
80
+ * Row index
81
+ */
82
+ rowIndex: number;
83
+
84
+ /**
85
+ * Column index
86
+ */
87
+ columnIndex: number;
88
88
  };
89
89
 
90
90
  /**
91
91
  * Grid cell renderer props
92
92
  */
93
93
  export type GridCellRendererProps<T, P = any> = GridCellFormatterProps<T> & {
94
- /**
95
- * Cell props
96
- */
97
- cellProps: P;
98
-
99
- /**
100
- * Formatted value
101
- */
102
- formattedValue?: GridCellValueType;
103
-
104
- /**
105
- * Item selected
106
- */
107
- selected: boolean;
108
-
109
- /**
110
- * Data type
111
- */
112
- type?: GridDataType;
113
-
114
- /**
115
- * Render props
116
- */
117
- renderProps?: GridColumnRenderProps;
118
-
119
- /**
120
- * Set items for rerenderer
121
- * @param callback Callback
122
- */
123
- setItems: (
124
- callback: (
125
- items: T[],
126
- ref?: ScrollerGridForwardRef<T>
127
- ) => T[] | undefined | void
128
- ) => void;
94
+ /**
95
+ * Cell props
96
+ */
97
+ cellProps: P;
98
+
99
+ /**
100
+ * Formatted value
101
+ */
102
+ formattedValue?: GridCellValueType;
103
+
104
+ /**
105
+ * Item selected
106
+ */
107
+ selected: boolean;
108
+
109
+ /**
110
+ * Data type
111
+ */
112
+ type?: GridDataType;
113
+
114
+ /**
115
+ * Render props
116
+ */
117
+ renderProps?: GridColumnRenderProps;
118
+
119
+ /**
120
+ * Set items for rerenderer
121
+ * @param callback Callback
122
+ */
123
+ setItems: (
124
+ callback: (
125
+ items: T[],
126
+ ref?: ScrollerGridForwardRef<T>
127
+ ) => T[] | undefined | void
128
+ ) => void;
129
129
  };
130
130
 
131
131
  /**
132
132
  * Grid header cell renderer props
133
133
  */
134
134
  export type GridHeaderCellRendererProps<T, P = any> = {
135
- /**
136
- * Cell props
137
- */
138
- cellProps: P;
139
-
140
- /**
141
- * Column
142
- */
143
- column: GridColumn<T>;
144
-
145
- /**
146
- * Column index
147
- */
148
- columnIndex: number;
149
-
150
- /**
151
- * States
152
- */
153
- states: GridLoaderStates<T>;
135
+ /**
136
+ * Cell props
137
+ */
138
+ cellProps: P;
139
+
140
+ /**
141
+ * Column
142
+ */
143
+ column: GridColumn<T>;
144
+
145
+ /**
146
+ * Column index
147
+ */
148
+ columnIndex: number;
149
+
150
+ /**
151
+ * States
152
+ */
153
+ states: GridLoaderStates<T>;
154
154
  };
155
155
 
156
156
  /**
157
157
  * Grid column render props
158
158
  */
159
159
  export type GridColumnRenderProps = {
160
- /**
161
- * Culture, like zh-CN
162
- */
163
- readonly culture?: string;
164
-
165
- /**
166
- * Time zone
167
- */
168
- readonly timeZone?: string;
169
-
170
- /**
171
- * Currency, like USD for US dollar
172
- */
173
- readonly currency?: string;
174
-
175
- /**
176
- * Number format options
177
- */
178
- readonly numberFormatOptions?: Intl.NumberFormatOptions;
179
-
180
- /**
181
- * Near days to show alert
182
- */
183
- readonly nearDays?: number;
184
-
185
- /**
186
- * Additional data
187
- */
188
- readonly data?: Readonly<Record<string, any>>;
160
+ /**
161
+ * Culture, like zh-CN
162
+ */
163
+ readonly culture?: string;
164
+
165
+ /**
166
+ * Time zone
167
+ */
168
+ readonly timeZone?: string;
169
+
170
+ /**
171
+ * Currency, like USD for US dollar
172
+ */
173
+ readonly currency?: string;
174
+
175
+ /**
176
+ * Number format options
177
+ */
178
+ readonly numberFormatOptions?: Intl.NumberFormatOptions;
179
+
180
+ /**
181
+ * Near days to show alert
182
+ */
183
+ readonly nearDays?: number;
184
+
185
+ /**
186
+ * Additional data
187
+ */
188
+ readonly data?: Readonly<Record<string, any>>;
189
189
  };
190
190
 
191
191
  /**
192
192
  * Grid column
193
193
  */
194
194
  export type GridColumn<T> = {
195
- /**
196
- * The column identifier. It's used to map with row data
197
- */
198
- field?: string & keyof T;
199
-
200
- /**
201
- * The title of the column rendered in the column header cell
202
- */
203
- header?: string;
204
-
205
- /**
206
- * Set the width of the column
207
- */
208
- width?: number;
209
-
210
- /**
211
- * Sets the minimum width of a column
212
- */
213
- minWidth?: number;
214
-
215
- /**
216
- * Align
217
- */
218
- align?: GridAlign;
219
-
220
- /**
221
- * If `true`, the column is sortable
222
- * @default true
223
- */
224
- sortable?: boolean;
225
-
226
- /**
227
- * Sort ascending or descending
228
- */
229
- sortAsc?: boolean;
230
-
231
- /**
232
- * Data type
233
- */
234
- type?: GridDataType;
235
-
236
- /**
237
- * Cell value formatter
238
- */
239
- valueFormatter?: (props: GridCellFormatterProps<T>) => GridCellValueType;
240
-
241
- /**
242
- * Cell renderer
243
- */
244
- cellRenderer?: (props: GridCellRendererProps<T>) => React.ReactNode;
245
-
246
- /**
247
- * Cell box style
248
- */
249
- cellBoxStyle?:
250
- | ((data: T | undefined) => React.CSSProperties)
251
- | React.CSSProperties;
252
-
253
- /**
254
- * Render props
255
- */
256
- renderProps?:
257
- | GridColumnRenderProps
258
- | ((data: T | undefined) => GridColumnRenderProps);
259
-
260
- /**
261
- * Header cell renderer
262
- */
263
- headerCellRenderer?: (
264
- props: GridHeaderCellRendererProps<T>
265
- ) => React.ReactNode;
195
+ /**
196
+ * The column identifier. It's used to map with row data
197
+ */
198
+ field?: string & keyof T;
199
+
200
+ /**
201
+ * The title of the column rendered in the column header cell
202
+ */
203
+ header?: string;
204
+
205
+ /**
206
+ * Set the width of the column
207
+ */
208
+ width?: number;
209
+
210
+ /**
211
+ * Sets the minimum width of a column
212
+ */
213
+ minWidth?: number;
214
+
215
+ /**
216
+ * Align
217
+ */
218
+ align?: GridAlign;
219
+
220
+ /**
221
+ * If `true`, the column is sortable
222
+ * @default true
223
+ */
224
+ sortable?: boolean;
225
+
226
+ /**
227
+ * Sort ascending or descending
228
+ */
229
+ sortAsc?: boolean;
230
+
231
+ /**
232
+ * Data type
233
+ */
234
+ type?: GridDataType;
235
+
236
+ /**
237
+ * Cell value formatter
238
+ */
239
+ valueFormatter?: (props: GridCellFormatterProps<T>) => GridCellValueType;
240
+
241
+ /**
242
+ * Cell renderer
243
+ */
244
+ cellRenderer?: (props: GridCellRendererProps<T>) => React.ReactNode;
245
+
246
+ /**
247
+ * Cell box style
248
+ */
249
+ cellBoxStyle?:
250
+ | ((data: T | undefined) => React.CSSProperties)
251
+ | React.CSSProperties;
252
+
253
+ /**
254
+ * Render props
255
+ */
256
+ renderProps?:
257
+ | GridColumnRenderProps
258
+ | ((data: T | undefined) => GridColumnRenderProps);
259
+
260
+ /**
261
+ * Header cell renderer
262
+ */
263
+ headerCellRenderer?: (
264
+ props: GridHeaderCellRendererProps<T>
265
+ ) => React.ReactNode;
266
266
  };