@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.
- 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 +9 -1
- package/lib/components/DynamicRouter.js +18 -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 +46 -21
- 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,8 +1,8 @@
|
|
|
1
|
-
import { EntityStatus } from
|
|
2
|
-
import { DataTypes } from
|
|
3
|
-
import React from
|
|
4
|
-
import { GridLoaderStates } from
|
|
5
|
-
import { ScrollerGridForwardRef } from
|
|
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 =
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
43
|
+
data: undefined | { status: EntityStatus } | { entityStatus: EntityStatus }
|
|
44
44
|
): React.CSSProperties => {
|
|
45
|
-
|
|
45
|
+
if (data == null) return {};
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
const status =
|
|
48
|
+
"status" in data
|
|
49
|
+
? data.status
|
|
50
|
+
: "entityStatus" in data
|
|
51
|
+
? data.entityStatus
|
|
52
|
+
: EntityStatus.Normal;
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
if (status === EntityStatus.Inactivated || status === EntityStatus.Deleted)
|
|
55
|
+
return { textDecoration: "line-through" };
|
|
56
56
|
|
|
57
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
};
|