cx 22.3.4 → 22.3.5
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/dist/data.js +94 -25
- package/dist/manifest.js +474 -468
- package/dist/ui.js +27 -6
- package/dist/widgets.js +1 -1
- package/package.json +1 -1
- package/src/core.d.ts +41 -6
- package/src/data/Binding.d.ts +4 -3
- package/src/data/Binding.js +12 -8
- package/src/data/Store.d.ts +5 -5
- package/src/data/Store.js +2 -2
- package/src/data/StoreRef.js +2 -0
- package/src/data/StructuredSelector.js +43 -57
- package/src/data/StructuredSelector.spec.js +54 -39
- package/src/data/View.d.ts +40 -16
- package/src/data/View.js +27 -19
- package/src/data/comparer.js +15 -10
- package/src/data/computable.d.ts +27 -4
- package/src/data/computable.js +2 -1
- package/src/data/computable.spec.js +8 -0
- package/src/data/createAccessorModelProxy.d.ts +6 -0
- package/src/data/createAccessorModelProxy.js +24 -0
- package/src/data/createAccessorModelProxy.spec.tsx +23 -0
- package/src/data/createStructuredSelector.js +9 -8
- package/src/data/getAccessor.js +24 -15
- package/src/data/getSelector.js +4 -1
- package/src/data/getSelector.spec.js +7 -0
- package/src/data/index.d.ts +2 -0
- package/src/data/index.js +2 -0
- package/src/ui/Controller.d.ts +13 -8
- package/src/ui/Instance.d.ts +6 -6
- package/src/ui/Instance.js +6 -5
- package/src/ui/Repeater.d.ts +25 -15
- package/src/ui/Restate.spec.js +0 -1
- package/src/ui/adapter/ArrayAdapter.d.ts +9 -10
- package/src/ui/adapter/ArrayAdapter.js +30 -37
- package/src/ui/bind.d.ts +3 -2
- package/src/ui/bind.js +4 -3
- package/src/ui/expr.d.ts +23 -2
- package/src/ui/expr.js +16 -4
- package/src/widgets/AccessorBindings.spec.tsx +66 -0
- package/src/widgets/HtmlElement.d.ts +1 -1
- package/src/widgets/List.d.ts +36 -24
- package/src/widgets/form/ValidationGroup.spec.js +1 -1
- package/src/widgets/grid/Grid.d.ts +86 -68
- package/src/widgets/grid/Grid.js +1 -1
|
@@ -1,13 +1,29 @@
|
|
|
1
|
-
import * as Cx from "../../core";
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
import { Instance } from "../../ui/Instance";
|
|
4
3
|
import { DragEvent } from "../drag-drop/ops";
|
|
5
4
|
import { View } from "../../data/View";
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import {
|
|
6
|
+
BooleanProp,
|
|
7
|
+
ClassProp,
|
|
8
|
+
CollatorOptions,
|
|
9
|
+
Config,
|
|
10
|
+
NumberProp,
|
|
11
|
+
Prop,
|
|
12
|
+
Record,
|
|
13
|
+
RecordAlias,
|
|
14
|
+
SortDirection,
|
|
15
|
+
SortersProp,
|
|
16
|
+
StringProp,
|
|
17
|
+
StructuredProp,
|
|
18
|
+
StyledContainerProps,
|
|
19
|
+
StyleProp,
|
|
20
|
+
Widget,
|
|
21
|
+
} from "../../core";
|
|
22
|
+
|
|
23
|
+
type FetchRecordsResult = Record[] | { records: Record[]; lastPage?: boolean; totalRecordCount?: number };
|
|
8
24
|
|
|
9
25
|
interface MappedGridRecord {
|
|
10
|
-
data:
|
|
26
|
+
data: Record;
|
|
11
27
|
store: View;
|
|
12
28
|
}
|
|
13
29
|
|
|
@@ -37,10 +53,10 @@ interface GridColumnDropEvent extends DragEvent {
|
|
|
37
53
|
|
|
38
54
|
interface GridGroupingKey {
|
|
39
55
|
[key: string]:
|
|
40
|
-
|
|
|
56
|
+
| Prop<any>
|
|
41
57
|
| {
|
|
42
|
-
value:
|
|
43
|
-
direction:
|
|
58
|
+
value: Prop<any>;
|
|
59
|
+
direction: SortDirection;
|
|
44
60
|
};
|
|
45
61
|
}
|
|
46
62
|
|
|
@@ -48,106 +64,108 @@ type GridColumnAlignment = "left" | "right" | "center";
|
|
|
48
64
|
|
|
49
65
|
interface GridGroupingConfig {
|
|
50
66
|
key: GridGroupingKey;
|
|
51
|
-
aggregates?:
|
|
67
|
+
aggregates?: StructuredProp;
|
|
52
68
|
showCaption?: boolean;
|
|
53
69
|
showFooter?: boolean;
|
|
54
70
|
showHeader?: boolean;
|
|
55
|
-
caption?:
|
|
56
|
-
name?:
|
|
57
|
-
text?:
|
|
71
|
+
caption?: StringProp;
|
|
72
|
+
name?: StringProp;
|
|
73
|
+
text?: StringProp;
|
|
58
74
|
}
|
|
59
75
|
|
|
60
76
|
// TODO: Check Column config
|
|
61
77
|
// Props are in order based on docs
|
|
62
78
|
|
|
63
79
|
interface GridColumnHeaderConfig {
|
|
64
|
-
text?:
|
|
65
|
-
colSpan?:
|
|
66
|
-
rowSpan?:
|
|
80
|
+
text?: StringProp;
|
|
81
|
+
colSpan?: NumberProp;
|
|
82
|
+
rowSpan?: NumberProp;
|
|
67
83
|
align?: GridColumnAlignment;
|
|
68
84
|
allowSorting?: boolean;
|
|
69
85
|
items?: React.ReactNode;
|
|
70
86
|
children?: React.ReactNode;
|
|
71
87
|
tool?: React.ReactNode;
|
|
88
|
+
style?: StyleProp;
|
|
89
|
+
class?: ClassProp;
|
|
90
|
+
className?: ClassProp;
|
|
72
91
|
}
|
|
73
92
|
|
|
74
93
|
interface GridColumnConfig {
|
|
75
94
|
align?: GridColumnAlignment;
|
|
76
95
|
field?: string;
|
|
77
|
-
format?:
|
|
78
|
-
header?:
|
|
79
|
-
header1?:
|
|
80
|
-
header2?:
|
|
81
|
-
header3?:
|
|
96
|
+
format?: StringProp;
|
|
97
|
+
header?: StringProp | GridColumnHeaderConfig;
|
|
98
|
+
header1?: StringProp | GridColumnHeaderConfig;
|
|
99
|
+
header2?: StringProp | GridColumnHeaderConfig;
|
|
100
|
+
header3?: StringProp | GridColumnHeaderConfig;
|
|
82
101
|
sortable?: boolean;
|
|
83
102
|
aggregate?: "min" | "max" | "count" | "sum" | "distinct" | "avg";
|
|
84
103
|
aggregateAlias?: string;
|
|
85
104
|
aggregateField?: string;
|
|
86
|
-
caption?:
|
|
87
|
-
class?:
|
|
88
|
-
className?:
|
|
105
|
+
caption?: StringProp;
|
|
106
|
+
class?: ClassProp;
|
|
107
|
+
className?: ClassProp;
|
|
89
108
|
draggable?: boolean;
|
|
90
109
|
editable?: boolean;
|
|
91
110
|
editor?: React.ReactNode;
|
|
92
|
-
footer?:
|
|
111
|
+
footer?: StringProp | false;
|
|
93
112
|
items?: React.ReactNode;
|
|
94
113
|
children?: React.ReactNode;
|
|
95
|
-
layout?: Cx.StringProp;
|
|
96
114
|
key?: string;
|
|
97
115
|
pad?: boolean;
|
|
98
116
|
sortField?: string;
|
|
99
|
-
sortValue?:
|
|
100
|
-
style?:
|
|
117
|
+
sortValue?: Prop<any>;
|
|
118
|
+
style?: StyleProp;
|
|
101
119
|
trimWhitespace?: boolean;
|
|
102
|
-
visible?:
|
|
103
|
-
if?:
|
|
120
|
+
visible?: BooleanProp;
|
|
121
|
+
if?: BooleanProp;
|
|
104
122
|
weightField?: string;
|
|
105
123
|
|
|
106
124
|
// Not in docs
|
|
107
|
-
value?:
|
|
108
|
-
defaultWidth?:
|
|
109
|
-
width?:
|
|
125
|
+
value?: Prop<any>;
|
|
126
|
+
defaultWidth?: NumberProp;
|
|
127
|
+
width?: NumberProp;
|
|
110
128
|
resizable?: boolean;
|
|
111
129
|
comparer?: (a: any, b: any) => number;
|
|
112
130
|
|
|
113
131
|
/** Options for data sorting. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator */
|
|
114
|
-
sortOptions?:
|
|
132
|
+
sortOptions?: CollatorOptions;
|
|
115
133
|
}
|
|
116
134
|
|
|
117
135
|
interface GridRowLineConfig {
|
|
118
|
-
visible?:
|
|
136
|
+
visible?: BooleanProp;
|
|
119
137
|
columns: GridColumnConfig[];
|
|
120
138
|
}
|
|
121
139
|
|
|
122
140
|
interface GridRowConfig {
|
|
123
|
-
invalid?:
|
|
124
|
-
valid?:
|
|
125
|
-
style?:
|
|
126
|
-
class?:
|
|
127
|
-
className?:
|
|
141
|
+
invalid?: BooleanProp;
|
|
142
|
+
valid?: BooleanProp;
|
|
143
|
+
style?: StyleProp;
|
|
144
|
+
class?: ClassProp;
|
|
145
|
+
className?: ClassProp;
|
|
128
146
|
line1?: GridRowLineConfig;
|
|
129
147
|
line2?: GridRowLineConfig;
|
|
130
148
|
line3?: GridRowLineConfig;
|
|
131
149
|
}
|
|
132
150
|
|
|
133
|
-
interface GridProps extends
|
|
151
|
+
interface GridProps extends StyledContainerProps {
|
|
134
152
|
/** An array of records to be displayed in the grid. */
|
|
135
|
-
records?:
|
|
153
|
+
records?: Prop<Record[]>;
|
|
136
154
|
|
|
137
155
|
/** Set to true to add a vertical scroll and a fixed header to the grid. */
|
|
138
156
|
scrollable?: boolean;
|
|
139
157
|
|
|
140
158
|
/** A binding used to store the sorting order list. Commonly used for server-side sorting. */
|
|
141
|
-
sorters?:
|
|
159
|
+
sorters?: SortersProp;
|
|
142
160
|
|
|
143
161
|
/** A list of sorters to be prepended to the actual list of sorters. */
|
|
144
|
-
preSorters?:
|
|
162
|
+
preSorters?: SortersProp;
|
|
145
163
|
|
|
146
164
|
/** A binding used to store the name of the field used for sorting grids. Available only if sorters are not used. */
|
|
147
|
-
sortField?:
|
|
165
|
+
sortField?: StringProp;
|
|
148
166
|
|
|
149
|
-
/** A binding used to store the sort direction. Available only if sorters are not used. Possible values are "ASC" and "DESC".
|
|
150
|
-
sortDirection?:
|
|
167
|
+
/** A binding used to store the sort direction. Available only if sorters are not used. Possible values are "ASC" and "DESC". Defaults to "ASC". */
|
|
168
|
+
sortDirection?: StringProp;
|
|
151
169
|
|
|
152
170
|
/** Default sort field. Used if neither sortField or sorters are set. */
|
|
153
171
|
defaultSortField?: string;
|
|
@@ -159,13 +177,13 @@ interface GridProps extends Cx.StyledContainerProps {
|
|
|
159
177
|
vlines?: boolean;
|
|
160
178
|
|
|
161
179
|
/** Text to be displayed instead of an empty table. */
|
|
162
|
-
emptyText?:
|
|
180
|
+
emptyText?: StringProp;
|
|
163
181
|
|
|
164
182
|
/** Drag source configuration. Define mode as 'move' or 'copy` and additional data. */
|
|
165
|
-
dragSource?:
|
|
183
|
+
dragSource?: StructuredProp;
|
|
166
184
|
|
|
167
185
|
/** Drop zone configuration. Define mode as either preview or insertion. */
|
|
168
|
-
dropZone?:
|
|
186
|
+
dropZone?: StructuredProp;
|
|
169
187
|
|
|
170
188
|
/** Row configuration. See grid examples. */
|
|
171
189
|
row?: GridRowConfig;
|
|
@@ -174,25 +192,25 @@ interface GridProps extends Cx.StyledContainerProps {
|
|
|
174
192
|
columns?: GridColumnConfig[];
|
|
175
193
|
|
|
176
194
|
/** Whenever columnParams change, columns are recalculated using the onGetColumn callback. */
|
|
177
|
-
columnParams?:
|
|
195
|
+
columnParams?: Config;
|
|
178
196
|
|
|
179
197
|
/** Selection configuration. */
|
|
180
|
-
selection?:
|
|
198
|
+
selection?: Config;
|
|
181
199
|
|
|
182
200
|
/** An array of grouping level definitions. Check allowed grouping level properties in the section below. */
|
|
183
201
|
grouping?: GridGroupingConfig[];
|
|
184
202
|
|
|
185
203
|
/** Params for grouping. Whenever params change grouping is recalculated using the onGetGrouping callback. */
|
|
186
|
-
groupingParams?:
|
|
204
|
+
groupingParams?: Config;
|
|
187
205
|
|
|
188
206
|
/**
|
|
189
207
|
* Determines header appearance. Supported values are plain and default. Default mode is used if some of the columns are sortable.
|
|
190
208
|
* Plain mode better suits reports and other scenarios in which users do not interact with the grid.
|
|
191
209
|
*/
|
|
192
|
-
headerMode?:
|
|
210
|
+
headerMode?: StringProp;
|
|
193
211
|
|
|
194
212
|
/** Set to true to add default border around the table. Automatically set if grid is scrollable. */
|
|
195
|
-
border?:
|
|
213
|
+
border?: BooleanProp;
|
|
196
214
|
|
|
197
215
|
/** Base CSS class to be applied to the element. Default is 'grid'. */
|
|
198
216
|
baseClass?: string;
|
|
@@ -207,10 +225,10 @@ interface GridProps extends Cx.StyledContainerProps {
|
|
|
207
225
|
showFooter?: boolean;
|
|
208
226
|
|
|
209
227
|
/** Record alias. Default is $record. */
|
|
210
|
-
recordName?:
|
|
228
|
+
recordName?: RecordAlias;
|
|
211
229
|
|
|
212
230
|
/** Record alias. Default is $record. */
|
|
213
|
-
recordAlias?:
|
|
231
|
+
recordAlias?: RecordAlias;
|
|
214
232
|
|
|
215
233
|
/** Set to true if sorting is done remotely, on the server-side. Default value is false. */
|
|
216
234
|
remoteSort?: boolean;
|
|
@@ -250,10 +268,10 @@ interface GridProps extends Cx.StyledContainerProps {
|
|
|
250
268
|
dataAdapter?: any;
|
|
251
269
|
|
|
252
270
|
/** Additional CSS class to be added to each grid row. */
|
|
253
|
-
rowClass?:
|
|
271
|
+
rowClass?: ClassProp;
|
|
254
272
|
|
|
255
273
|
/** Additional CSS styles to be added to each grid row. */
|
|
256
|
-
rowStyle?:
|
|
274
|
+
rowStyle?: StyleProp;
|
|
257
275
|
|
|
258
276
|
// drag-drop handlers
|
|
259
277
|
onDrop?: (e: GridDragEvent, instance: Instance) => void;
|
|
@@ -270,10 +288,10 @@ interface GridProps extends Cx.StyledContainerProps {
|
|
|
270
288
|
onColumnDropTest?: (e: DragEvent, instance: Instance) => boolean;
|
|
271
289
|
|
|
272
290
|
/** Parameters that affect filtering. */
|
|
273
|
-
filterParams?:
|
|
291
|
+
filterParams?: StructuredProp;
|
|
274
292
|
|
|
275
293
|
/** Callback to create a filter function for given filter params. */
|
|
276
|
-
onCreateFilter?: (filterParams: any, instance?: Instance) => (record:
|
|
294
|
+
onCreateFilter?: (filterParams: any, instance?: Instance) => (record: Record) => boolean;
|
|
277
295
|
|
|
278
296
|
/** Enable infinite scrolling */
|
|
279
297
|
infinite?: boolean;
|
|
@@ -286,7 +304,7 @@ interface GridProps extends Cx.StyledContainerProps {
|
|
|
286
304
|
pageInfo: {
|
|
287
305
|
page: number;
|
|
288
306
|
pageSize: number;
|
|
289
|
-
sorters?:
|
|
307
|
+
sorters?: Record[];
|
|
290
308
|
sortField?: string;
|
|
291
309
|
sortDirection?: string;
|
|
292
310
|
},
|
|
@@ -305,25 +323,25 @@ interface GridProps extends Cx.StyledContainerProps {
|
|
|
305
323
|
/** Set to true to enable cell editing. Please note that all editable columns should specify the editor field. */
|
|
306
324
|
cellEditable?: boolean;
|
|
307
325
|
|
|
308
|
-
/** A callback function which is executed before a cell editor is
|
|
326
|
+
/** A callback function which is executed before a cell editor is initialized. Return false from the callback to prevent the cell from going into the edit mode. */
|
|
309
327
|
onBeforeCellEdit?: (change, record) => any;
|
|
310
328
|
|
|
311
329
|
/** A callback function which is executed after a cell has been successfully edited. */
|
|
312
330
|
onCellEdited?: (change, record) => void;
|
|
313
331
|
|
|
314
332
|
/** A callback function which is executed after a column has been resized. */
|
|
315
|
-
onColumnResize?: (data: { width: number; column:
|
|
333
|
+
onColumnResize?: (data: { width: number; column: Record }, instance: Instance) => void;
|
|
316
334
|
|
|
317
335
|
/** Options for data sorting. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator */
|
|
318
|
-
sortOptions?:
|
|
336
|
+
sortOptions?: CollatorOptions;
|
|
319
337
|
|
|
320
338
|
onCreateIsRecordSelectable?: (
|
|
321
339
|
params: any,
|
|
322
340
|
instance: Instance
|
|
323
|
-
) => (record:
|
|
341
|
+
) => (record: Record, options?: { range?: boolean; toggle?: boolean }) => boolean;
|
|
324
342
|
|
|
325
|
-
/** Parameters whose change will
|
|
326
|
-
scrollResetParams?:
|
|
343
|
+
/** Parameters whose change will cause scroll to be reset. */
|
|
344
|
+
scrollResetParams?: StructuredProp;
|
|
327
345
|
|
|
328
346
|
/** Enable precise (sub-pixel) measurements. Useful for grids with many columns. Better behavior at small zoom factors. */
|
|
329
347
|
preciseMeasurements?: boolean;
|
|
@@ -332,7 +350,7 @@ interface GridProps extends Cx.StyledContainerProps {
|
|
|
332
350
|
hoverChannel?: string;
|
|
333
351
|
|
|
334
352
|
/** A value used to uniquely identify the record within the hover sync group. */
|
|
335
|
-
rowHoverId?:
|
|
353
|
+
rowHoverId?: StringProp;
|
|
336
354
|
|
|
337
355
|
/** Set to true or false to explicitly define if grid is allowed to receive focus. */
|
|
338
356
|
focusable?: boolean;
|
|
@@ -347,4 +365,4 @@ interface GridProps extends Cx.StyledContainerProps {
|
|
|
347
365
|
allowsFileDrops?: boolean;
|
|
348
366
|
}
|
|
349
367
|
|
|
350
|
-
export class Grid extends
|
|
368
|
+
export class Grid extends Widget<GridProps> {}
|
package/src/widgets/grid/Grid.js
CHANGED
|
@@ -679,7 +679,7 @@ export class Grid extends Widget {
|
|
|
679
679
|
(hdinstPrev.widget.resizable || (headerPrev && headerPrev.data.resizable)) &&
|
|
680
680
|
headerPrev.data.colSpan < 2
|
|
681
681
|
) {
|
|
682
|
-
prevColumnResizer = this.renderResizer(instance, hdinstPrev, headerPrev, colIndex, true);
|
|
682
|
+
prevColumnResizer = this.renderResizer(instance, hdinstPrev, headerPrev, colIndex - 1, true);
|
|
683
683
|
}
|
|
684
684
|
}
|
|
685
685
|
}
|