cx 25.6.0 → 25.6.1

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 (96) hide show
  1. package/dist/manifest.js +708 -708
  2. package/package.json +2 -2
  3. package/src/charts/Legend.d.ts +45 -45
  4. package/src/charts/LegendEntry.js +128 -128
  5. package/src/charts/LegendEntry.scss +27 -27
  6. package/src/charts/PieChart.d.ts +92 -92
  7. package/src/charts/RangeMarker.js +159 -159
  8. package/src/charts/axis/Axis.d.ts +113 -113
  9. package/src/charts/axis/Axis.js +280 -280
  10. package/src/charts/axis/CategoryAxis.d.ts +30 -30
  11. package/src/charts/axis/CategoryAxis.js +241 -241
  12. package/src/charts/axis/NumericAxis.js +351 -351
  13. package/src/charts/axis/Stack.js +55 -55
  14. package/src/charts/axis/TimeAxis.js +611 -611
  15. package/src/charts/helpers/SnapPointFinder.js +69 -69
  16. package/src/data/Binding.spec.js +69 -69
  17. package/src/data/Expression.js +229 -229
  18. package/src/data/Expression.spec.js +229 -229
  19. package/src/data/StringTemplate.js +92 -92
  20. package/src/data/StringTemplate.spec.js +132 -132
  21. package/src/data/StructuredSelector.js +132 -132
  22. package/src/data/getAccessor.spec.js +11 -11
  23. package/src/data/getSelector.js +49 -49
  24. package/src/hooks/createLocalStorageRef.d.ts +3 -3
  25. package/src/hooks/createLocalStorageRef.js +20 -20
  26. package/src/index.scss +6 -6
  27. package/src/ui/Culture.d.ts +57 -57
  28. package/src/ui/Culture.js +139 -139
  29. package/src/ui/FocusManager.js +171 -171
  30. package/src/ui/Format.js +108 -108
  31. package/src/ui/HoverSync.js +147 -147
  32. package/src/ui/Repeater.d.ts +61 -61
  33. package/src/ui/index.d.ts +42 -42
  34. package/src/ui/layout/ContentPlaceholder.d.ts +19 -19
  35. package/src/ui/layout/ContentPlaceholder.js +105 -105
  36. package/src/ui/layout/ContentPlaceholder.spec.js +579 -579
  37. package/src/ui/layout/LabelsTopLayout.js +134 -134
  38. package/src/util/Format.js +270 -270
  39. package/src/util/date/encodeDate.d.ts +1 -1
  40. package/src/util/date/encodeDate.js +8 -8
  41. package/src/util/date/encodeDateWithTimezoneOffset.d.ts +1 -1
  42. package/src/util/date/index.d.ts +11 -11
  43. package/src/util/date/index.js +11 -11
  44. package/src/util/date/parseDateInvariant.d.ts +3 -3
  45. package/src/util/date/parseDateInvariant.js +20 -20
  46. package/src/util/getSearchQueryPredicate.js +59 -59
  47. package/src/util/index.d.ts +51 -51
  48. package/src/util/index.js +54 -54
  49. package/src/util/isValidIdentifierName.d.ts +1 -1
  50. package/src/util/isValidIdentifierName.js +5 -5
  51. package/src/util/isValidIdentifierName.spec.js +33 -33
  52. package/src/util/scss/add-rules.scss +38 -38
  53. package/src/widgets/CxCredit.scss +37 -37
  54. package/src/widgets/HighlightedSearchText.js +36 -36
  55. package/src/widgets/HighlightedSearchText.scss +18 -18
  56. package/src/widgets/List.scss +91 -91
  57. package/src/widgets/drag-drop/DropZone.js +214 -214
  58. package/src/widgets/form/Calendar.js +618 -618
  59. package/src/widgets/form/Calendar.scss +196 -196
  60. package/src/widgets/form/Checkbox.scss +127 -127
  61. package/src/widgets/form/ColorField.js +397 -397
  62. package/src/widgets/form/ColorField.scss +96 -96
  63. package/src/widgets/form/ColorPicker.scss +283 -283
  64. package/src/widgets/form/DateTimeField.js +576 -576
  65. package/src/widgets/form/DateTimePicker.js +392 -392
  66. package/src/widgets/form/LookupField.d.ts +179 -179
  67. package/src/widgets/form/LookupField.scss +219 -219
  68. package/src/widgets/form/MonthPicker.scss +118 -118
  69. package/src/widgets/form/NumberField.js +459 -459
  70. package/src/widgets/form/NumberField.scss +61 -61
  71. package/src/widgets/form/Radio.scss +121 -121
  72. package/src/widgets/form/Select.scss +99 -99
  73. package/src/widgets/form/Slider.scss +118 -118
  74. package/src/widgets/form/Switch.scss +140 -140
  75. package/src/widgets/form/TextArea.scss +43 -43
  76. package/src/widgets/form/TextField.js +290 -290
  77. package/src/widgets/form/TextField.scss +55 -55
  78. package/src/widgets/form/UploadButton.d.ts +34 -34
  79. package/src/widgets/form/variables.scss +353 -353
  80. package/src/widgets/grid/Grid.d.ts +442 -442
  81. package/src/widgets/grid/GridRow.js +228 -228
  82. package/src/widgets/grid/TreeNode.d.ts +23 -23
  83. package/src/widgets/grid/TreeNode.scss +88 -88
  84. package/src/widgets/grid/variables.scss +133 -133
  85. package/src/widgets/nav/LinkButton.js +128 -128
  86. package/src/widgets/nav/Menu.scss +74 -74
  87. package/src/widgets/overlay/Dropdown.js +612 -612
  88. package/src/widgets/overlay/FlyweightTooltipTracker.js +39 -39
  89. package/src/widgets/overlay/Overlay.d.ts +73 -73
  90. package/src/widgets/overlay/Window.js +202 -202
  91. package/src/widgets/overlay/captureMouse.js +124 -124
  92. package/src/widgets/overlay/createHotPromiseWindowFactory.d.ts +18 -18
  93. package/src/widgets/overlay/createHotPromiseWindowFactory.js +56 -56
  94. package/src/widgets/overlay/index.d.ts +11 -11
  95. package/src/widgets/overlay/index.js +11 -11
  96. package/src/widgets/variables.scss +144 -144
@@ -1,442 +1,442 @@
1
- import * as React from "react";
2
- import { Instance } from "../../ui/Instance";
3
- import { DragEvent } from "../drag-drop/ops";
4
- import { View } from "../../data/View";
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
- UnknownProp,
21
- Widget,
22
- } from "../../core";
23
- import { DataAdapterRecord } from "../../ui/adapter/DataAdapter";
24
-
25
- type FetchRecordsResult<T> = T[] | { records: T[]; lastPage?: boolean; totalRecordCount?: number };
26
-
27
- interface MappedGridRecord<T = unknown> extends DataAdapterRecord<T> {
28
- row: Instance;
29
- vdom: unknown;
30
- }
31
-
32
- interface GridDragEvent<T> extends DragEvent {
33
- target: {
34
- recordBefore: MappedGridRecord<T>;
35
- recordAfter: MappedGridRecord<T>;
36
- insertionIndex: number;
37
- totalRecordCount: number;
38
- };
39
- }
40
-
41
- interface GridRowDragEvent<T> extends DragEvent {
42
- target: {
43
- record: MappedGridRecord<T>;
44
- index: number;
45
- };
46
- }
47
-
48
- interface GridColumnDropEvent extends DragEvent {
49
- target: {
50
- grid: any;
51
- instance: Instance;
52
- index: number;
53
- };
54
- }
55
-
56
- interface GridGroupingKey {
57
- [key: string]:
58
- | Prop<any>
59
- | {
60
- value: Prop<any>;
61
- direction: SortDirection;
62
- };
63
- }
64
-
65
- interface GroupingResult<T> {
66
- key: any;
67
- aggregates: any;
68
- name: string;
69
- indexes: number[];
70
- records: MappedGridRecord<T>[];
71
- }
72
-
73
- type GridColumnAlignment = "left" | "right" | "center";
74
-
75
- interface GridGroupingConfig<T> {
76
- key: GridGroupingKey;
77
- aggregates?: StructuredProp;
78
- showCaption?: boolean;
79
- showFooter?: boolean;
80
- showHeader?: boolean;
81
- caption?: StringProp;
82
- name?: StringProp;
83
- text?: StringProp;
84
- comparer?: (a: GroupingResult<T>, b: GroupingResult<T>) => number;
85
- }
86
-
87
- // TODO: Check Column config
88
- // Props are in order based on docs
89
-
90
- interface GridColumnHeaderConfig {
91
- text?: StringProp;
92
- colSpan?: NumberProp;
93
- rowSpan?: NumberProp;
94
- align?: GridColumnAlignment;
95
- allowSorting?: boolean;
96
- items?: React.ReactNode;
97
- children?: React.ReactNode;
98
- tool?: React.ReactNode;
99
- style?: StyleProp;
100
- class?: ClassProp;
101
- className?: ClassProp;
102
- tooltip?: StringProp | StructuredProp;
103
- defaultWidth?: NumberProp;
104
- width?: NumberProp;
105
- resizable?: boolean;
106
- }
107
-
108
- interface GridColumnFooterConfig {
109
- value?: Prop<any>;
110
- format?: StringProp;
111
- style?: StyleProp;
112
- class?: StyleProp;
113
- expand?: boolean;
114
- }
115
-
116
- interface GridColumnCaptionConfig {
117
- value?: Prop<any>;
118
- format?: StringProp;
119
- style?: StyleProp;
120
- class?: StyleProp;
121
- children?: React.ReactNode;
122
- items?: React.ReactNode;
123
- expand?: boolean;
124
- }
125
-
126
- interface GridColumnConfig {
127
- align?: GridColumnAlignment;
128
- field?: string;
129
- format?: StringProp;
130
- header?: StringProp | GridColumnHeaderConfig;
131
- header1?: StringProp | GridColumnHeaderConfig;
132
- header2?: StringProp | GridColumnHeaderConfig;
133
- header3?: StringProp | GridColumnHeaderConfig;
134
- fixed?: BooleanProp;
135
- sortable?: boolean;
136
- aggregate?: "min" | "max" | "count" | "sum" | "distinct" | "avg";
137
- aggregateAlias?: string;
138
- aggregateField?: string;
139
- aggregateValue?: UnknownProp;
140
- caption?: GridColumnCaptionConfig | StringProp | false;
141
- class?: ClassProp;
142
- className?: ClassProp;
143
- draggable?: boolean;
144
- editable?: boolean;
145
- editor?: React.ReactNode;
146
- footer?: GridColumnFooterConfig | StringProp | false;
147
- items?: React.ReactNode;
148
- children?: React.ReactNode;
149
- key?: string;
150
- pad?: boolean;
151
- sortField?: string;
152
- sortValue?: Prop<any>;
153
- style?: StyleProp;
154
- trimWhitespace?: boolean;
155
- visible?: BooleanProp;
156
- if?: BooleanProp;
157
- weightField?: string;
158
-
159
- // Not in docs
160
- value?: Prop<any>;
161
- defaultWidth?: NumberProp;
162
- width?: NumberProp;
163
- resizable?: boolean;
164
- comparer?: (a: any, b: any) => number;
165
-
166
- /** Options for data sorting. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator */
167
- sortOptions?: CollatorOptions;
168
- colSpan?: NumberProp;
169
-
170
- mergeCells?: Prop<null | false | "same-value" | "always">;
171
- primarySortDirection?: "ASC" | "DESC";
172
- }
173
-
174
- interface GridRowLineConfig {
175
- visible?: BooleanProp;
176
- columns: GridColumnConfig[];
177
- }
178
-
179
- interface GridRowConfig {
180
- invalid?: BooleanProp;
181
- valid?: BooleanProp;
182
- style?: StyleProp;
183
- class?: ClassProp;
184
- className?: ClassProp;
185
- line1?: GridRowLineConfig;
186
- line2?: GridRowLineConfig;
187
- line3?: GridRowLineConfig;
188
- mod?: StringProp | Prop<string[]> | StructuredProp;
189
- }
190
-
191
- interface GridProps<T = unknown> extends StyledContainerProps {
192
- /** An array of records to be displayed in the grid. */
193
- records?: Prop<T[]>;
194
-
195
- /** Set to true to add a vertical scroll and a fixed header to the grid. */
196
- scrollable?: boolean;
197
-
198
- /** A binding used to store the sorting order list. Commonly used for server-side sorting. */
199
- sorters?: SortersProp;
200
-
201
- /** A list of sorters to be prepended to the actual list of sorters. */
202
- preSorters?: SortersProp;
203
-
204
- /** A binding used to store the name of the field used for sorting grids. Available only if sorters are not used. */
205
- sortField?: StringProp;
206
-
207
- /** A binding used to store the sort direction. Available only if sorters are not used. Possible values are "ASC" and "DESC". Defaults to "ASC". */
208
- sortDirection?: StringProp;
209
-
210
- /** Default sort field. Used if neither sortField or sorters are set. */
211
- defaultSortField?: string;
212
-
213
- /** Default sort direction. */
214
- defaultSortDirection?: "ASC" | "DESC";
215
-
216
- /** Set to true to add vertical gridlines. */
217
- vlines?: boolean;
218
-
219
- /** Text to be displayed instead of an empty table. */
220
- emptyText?: StringProp;
221
-
222
- /** Drag source configuration. Define mode as 'move' or 'copy` and additional data. */
223
- dragSource?: StructuredProp;
224
-
225
- /** Drop zone configuration. Define mode as either preview or insertion. */
226
- dropZone?: StructuredProp;
227
-
228
- /** Row configuration. See grid examples. */
229
- row?: GridRowConfig;
230
-
231
- /**An array of columns. Check column configuration options in the section below. */
232
- columns?: GridColumnConfig[];
233
-
234
- /** Whenever columnParams change, columns are recalculated using the onGetColumn callback. */
235
- columnParams?: Config;
236
-
237
- /** Selection configuration. */
238
- selection?: Config;
239
-
240
- /** An array of grouping level definitions. Check allowed grouping level properties in the section below. */
241
- grouping?: GridGroupingConfig<T>[];
242
-
243
- /** Params for grouping. Whenever params change grouping is recalculated using the onGetGrouping callback. */
244
- groupingParams?: Config;
245
-
246
- /**
247
- * Determines header appearance. Supported values are plain and default. Default mode is used if some of the columns are sortable.
248
- * Plain mode better suits reports and other scenarios in which users do not interact with the grid.
249
- */
250
- headerMode?: StringProp;
251
-
252
- /** Set to true to add default border around the table. Automatically set if grid is scrollable. */
253
- border?: BooleanProp;
254
-
255
- /** Base CSS class to be applied to the element. Default is 'grid'. */
256
- baseClass?: string;
257
-
258
- /** A field used to get the unique identifier of the record. Setting keyField improves grid performance on sort operations as the widget is able to identify row movement inside the grid. */
259
- keyField?: string;
260
-
261
- /** Show grid header within the group. Useful for long report-like (printable) grids. Defaults to false. */
262
- showHeader?: boolean;
263
-
264
- /** Show grid footer. Defaults to false. */
265
- showFooter?: boolean;
266
-
267
- /** Record alias. Default is $record. */
268
- recordName?: RecordAlias;
269
-
270
- /** Record alias. Default is $record. */
271
- recordAlias?: RecordAlias;
272
-
273
- /** Set to true if sorting is done remotely, on the server-side. Default value is false. */
274
- remoteSort?: boolean;
275
-
276
- /** Set to true to enable row caching. This greatly improves grid performance
277
- on subsequent render operations, however, only changes on records
278
- are allowed. If grid rows display any data outside records, changes on that
279
- data will be ignored. */
280
- cached?: boolean;
281
-
282
- /** Render only rows visible on the screen. */
283
- buffered?: boolean;
284
-
285
- /** Specifies how many rows should be visible on the screen */
286
- bufferSize?: number;
287
-
288
- /** Specifies how many rows needs to be scrolled in order to recalculate buffer */
289
- bufferStep?: number;
290
-
291
- /** Used when rows have variable heights to improve buffered rendering by measuring and caching rendered row heights. Default value is false. */
292
- measureRowHeights?: boolean;
293
-
294
- /** Scrolls selection into the view. Default value is false. */
295
- scrollSelectionIntoView?: boolean;
296
-
297
- /**
298
- * Set to true to lock column widths after the first render.
299
- * This is helpful in pagination scenarios to maintain consistent looks across pages.
300
- */
301
- lockColumnWidths?: boolean;
302
-
303
- lockColumnWidthsRequiredRowCount?: number;
304
- focused?: boolean;
305
- showBorder?: boolean;
306
-
307
- /** Data adapter used to convert data in list of records. Used to enable grouping and tree operations. */
308
- dataAdapter?: any;
309
-
310
- /** Additional CSS class to be added to each grid row. */
311
- rowClass?: ClassProp;
312
-
313
- /** Additional CSS styles to be added to each grid row. */
314
- rowStyle?: StyleProp;
315
-
316
- // drag-drop handlers
317
- onDrop?: string | ((e: GridDragEvent<T>, instance: Instance) => void);
318
- onDropTest?: string | ((e: DragEvent, instance: Instance) => boolean);
319
- onDragStart?: string | ((e: DragEvent, instance: Instance) => void);
320
- onDragEnd?: string | ((e: DragEvent, instance: Instance) => void);
321
- onDragOver?: string | ((e: GridDragEvent<T>, instance: Instance) => void | boolean);
322
-
323
- onRowDropTest?: string | ((e: DragEvent, instance: Instance) => boolean);
324
- onRowDragOver?: string | ((e: GridRowDragEvent<T>, instance: Instance) => void | boolean);
325
- onRowDrop?: string | ((e: GridRowDragEvent<T>, instance: Instance) => void | boolean);
326
-
327
- onColumnDrop?: string | ((e: GridColumnDropEvent, instance: Instance) => void);
328
- onColumnDropTest?: string | ((e: DragEvent, instance: Instance) => boolean);
329
-
330
- /** Parameters that affect filtering. */
331
- filterParams?: StructuredProp;
332
-
333
- /** Callback function to be executed when a row is right-clicked. */
334
- onRowContextMenu?: string | ((e: React.SyntheticEvent<any>, instance: Instance) => void);
335
-
336
- /** Callback to create a filter function for given filter params. */
337
- onCreateFilter?: (filterParams: any, instance?: Instance) => (record: T) => boolean;
338
-
339
- /** Enable infinite scrolling */
340
- infinite?: boolean;
341
-
342
- /** If set, clicking on the column header will loop between ASC, DESC and no sorting order, instead of ASC and DESC only. */
343
- clearableSort?: boolean;
344
-
345
- /** A callback to fetch records during infinite loading */
346
- onFetchRecords?: (
347
- pageInfo: {
348
- page: number;
349
- pageSize: number;
350
- sorters?: Record[];
351
- sortField?: string;
352
- sortDirection?: string;
353
- },
354
- instance?: Instance,
355
- ) => FetchRecordsResult<T> | Promise<FetchRecordsResult<T>>;
356
-
357
- /** Callback function to be executed when a row is double-clicked. */
358
- onRowDoubleClick?: string | ((e: React.SyntheticEvent<any>, instance: Instance) => void);
359
-
360
- /** Callback function to be executed on key down. Accepts instance of the currently focused record as the second argument. */
361
- onRowKeyDown?: string | ((e: React.SyntheticEvent<any>, instance: Instance) => void);
362
-
363
- /** Callback function to be executed when a row is clicked. */
364
- onRowClick?: string | ((e: React.SyntheticEvent<any>, instance: Instance) => void);
365
-
366
- /** Set to true to add a fixed footer at the bottom of the grid. */
367
- fixedFooter?: boolean;
368
-
369
- /** Set to true to enable cell editing. Please note that all editable columns should specify the editor field. */
370
- cellEditable?: boolean;
371
-
372
- /** 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. */
373
- onBeforeCellEdit?: string | ((change: GridCellBeforeEditInfo, record: DataAdapterRecord<T>) => any);
374
-
375
- /** A callback function which is executed after a cell has been successfully edited. */
376
- onCellEdited?: string | ((change: GridCellEditInfo<T>, record: DataAdapterRecord<T>) => void);
377
-
378
- /** A callback function which is executed after a column has been resized. */
379
- onColumnResize?: (data: { width: number; column: Record }, instance: Instance) => void;
380
-
381
- /** Options for data sorting. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator */
382
- sortOptions?: CollatorOptions;
383
-
384
- /** Callback to create a function that can be used to check whether a record is selectable. */
385
- onCreateIsRecordSelectable?: (
386
- params: any,
387
- instance: Instance,
388
- ) => (record: T, options?: { range?: boolean; toggle?: boolean }) => boolean;
389
-
390
- /** Parameters whose change will cause scroll to be reset. */
391
- scrollResetParams?: StructuredProp;
392
-
393
- /** Enable precise (sub-pixel) measurements. Useful for grids with many columns. Better behavior at small zoom factors. */
394
- preciseMeasurements?: boolean;
395
-
396
- /** A value used to identify the group of components participating in hover effect synchronization. */
397
- hoverChannel?: string;
398
-
399
- /** A value used to uniquely identify the record within the hover sync group. */
400
- rowHoverId?: Prop<string | number>;
401
-
402
- /** Set to true or false to explicitly define if grid is allowed to receive focus. */
403
- focusable?: boolean;
404
-
405
- /** Callback function to retrieve grouping data. */
406
- onGetGrouping?: (params: any, instance: Instance) => GridGroupingConfig<T>[];
407
-
408
- /** Callback function to dynamically calculate columns. */
409
- onGetColumns?: (params: any, instance: Instance) => GridColumnConfig[] | GridRowConfig;
410
-
411
- /** Allow grid to receive drag and drop operations containing files. */
412
- allowsFileDrops?: boolean;
413
-
414
- /**
415
- * Callback function to track and retrieve displayed records.
416
- * Accepts new records as a first argument.
417
- * If onCreateFilter callback is defined, filtered records can be retrieved using this callback.
418
- */
419
- onTrackMappedRecords?: string | ((records: DataAdapterRecord<T>[], instance: Instance) => void);
420
-
421
- /** Callback to create a function that can be used to check whether a record is draggable. */
422
- onCreateIsRecordDraggable?: (params: any, instance: Instance) => (record: T) => boolean;
423
-
424
- /** Callback function to get grid component and instance references on component init. */
425
- onRef?: string | ((element: any, instance: Instance) => void);
426
- }
427
-
428
- interface GridCellInfo {
429
- column: any;
430
- field: string;
431
- }
432
-
433
- interface GridCellBeforeEditInfo extends GridCellInfo {
434
- data: any;
435
- }
436
-
437
- interface GridCellEditInfo<T> extends GridCellInfo {
438
- oldData: T;
439
- newData: T;
440
- }
441
-
442
- export class Grid<T = unknown> extends Widget<GridProps<T>> {}
1
+ import * as React from "react";
2
+ import { Instance } from "../../ui/Instance";
3
+ import { DragEvent } from "../drag-drop/ops";
4
+ import { View } from "../../data/View";
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
+ UnknownProp,
21
+ Widget,
22
+ } from "../../core";
23
+ import { DataAdapterRecord } from "../../ui/adapter/DataAdapter";
24
+
25
+ type FetchRecordsResult<T> = T[] | { records: T[]; lastPage?: boolean; totalRecordCount?: number };
26
+
27
+ interface MappedGridRecord<T = unknown> extends DataAdapterRecord<T> {
28
+ row: Instance;
29
+ vdom: unknown;
30
+ }
31
+
32
+ interface GridDragEvent<T> extends DragEvent {
33
+ target: {
34
+ recordBefore: MappedGridRecord<T>;
35
+ recordAfter: MappedGridRecord<T>;
36
+ insertionIndex: number;
37
+ totalRecordCount: number;
38
+ };
39
+ }
40
+
41
+ interface GridRowDragEvent<T> extends DragEvent {
42
+ target: {
43
+ record: MappedGridRecord<T>;
44
+ index: number;
45
+ };
46
+ }
47
+
48
+ interface GridColumnDropEvent extends DragEvent {
49
+ target: {
50
+ grid: any;
51
+ instance: Instance;
52
+ index: number;
53
+ };
54
+ }
55
+
56
+ interface GridGroupingKey {
57
+ [key: string]:
58
+ | Prop<any>
59
+ | {
60
+ value: Prop<any>;
61
+ direction: SortDirection;
62
+ };
63
+ }
64
+
65
+ interface GroupingResult<T> {
66
+ key: any;
67
+ aggregates: any;
68
+ name: string;
69
+ indexes: number[];
70
+ records: MappedGridRecord<T>[];
71
+ }
72
+
73
+ type GridColumnAlignment = "left" | "right" | "center";
74
+
75
+ interface GridGroupingConfig<T> {
76
+ key: GridGroupingKey;
77
+ aggregates?: StructuredProp;
78
+ showCaption?: boolean;
79
+ showFooter?: boolean;
80
+ showHeader?: boolean;
81
+ caption?: StringProp;
82
+ name?: StringProp;
83
+ text?: StringProp;
84
+ comparer?: (a: GroupingResult<T>, b: GroupingResult<T>) => number;
85
+ }
86
+
87
+ // TODO: Check Column config
88
+ // Props are in order based on docs
89
+
90
+ interface GridColumnHeaderConfig {
91
+ text?: StringProp;
92
+ colSpan?: NumberProp;
93
+ rowSpan?: NumberProp;
94
+ align?: GridColumnAlignment;
95
+ allowSorting?: boolean;
96
+ items?: React.ReactNode;
97
+ children?: React.ReactNode;
98
+ tool?: React.ReactNode;
99
+ style?: StyleProp;
100
+ class?: ClassProp;
101
+ className?: ClassProp;
102
+ tooltip?: StringProp | StructuredProp;
103
+ defaultWidth?: NumberProp;
104
+ width?: NumberProp;
105
+ resizable?: boolean;
106
+ }
107
+
108
+ interface GridColumnFooterConfig {
109
+ value?: Prop<any>;
110
+ format?: StringProp;
111
+ style?: StyleProp;
112
+ class?: StyleProp;
113
+ expand?: boolean;
114
+ }
115
+
116
+ interface GridColumnCaptionConfig {
117
+ value?: Prop<any>;
118
+ format?: StringProp;
119
+ style?: StyleProp;
120
+ class?: StyleProp;
121
+ children?: React.ReactNode;
122
+ items?: React.ReactNode;
123
+ expand?: boolean;
124
+ }
125
+
126
+ interface GridColumnConfig {
127
+ align?: GridColumnAlignment;
128
+ field?: string;
129
+ format?: StringProp;
130
+ header?: StringProp | GridColumnHeaderConfig;
131
+ header1?: StringProp | GridColumnHeaderConfig;
132
+ header2?: StringProp | GridColumnHeaderConfig;
133
+ header3?: StringProp | GridColumnHeaderConfig;
134
+ fixed?: BooleanProp;
135
+ sortable?: boolean;
136
+ aggregate?: "min" | "max" | "count" | "sum" | "distinct" | "avg";
137
+ aggregateAlias?: string;
138
+ aggregateField?: string;
139
+ aggregateValue?: UnknownProp;
140
+ caption?: GridColumnCaptionConfig | StringProp | false;
141
+ class?: ClassProp;
142
+ className?: ClassProp;
143
+ draggable?: boolean;
144
+ editable?: boolean;
145
+ editor?: React.ReactNode;
146
+ footer?: GridColumnFooterConfig | StringProp | false;
147
+ items?: React.ReactNode;
148
+ children?: React.ReactNode;
149
+ key?: string;
150
+ pad?: boolean;
151
+ sortField?: string;
152
+ sortValue?: Prop<any>;
153
+ style?: StyleProp;
154
+ trimWhitespace?: boolean;
155
+ visible?: BooleanProp;
156
+ if?: BooleanProp;
157
+ weightField?: string;
158
+
159
+ // Not in docs
160
+ value?: Prop<any>;
161
+ defaultWidth?: NumberProp;
162
+ width?: NumberProp;
163
+ resizable?: boolean;
164
+ comparer?: (a: any, b: any) => number;
165
+
166
+ /** Options for data sorting. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator */
167
+ sortOptions?: CollatorOptions;
168
+ colSpan?: NumberProp;
169
+
170
+ mergeCells?: Prop<null | false | "same-value" | "always">;
171
+ primarySortDirection?: "ASC" | "DESC";
172
+ }
173
+
174
+ interface GridRowLineConfig {
175
+ visible?: BooleanProp;
176
+ columns: GridColumnConfig[];
177
+ }
178
+
179
+ interface GridRowConfig {
180
+ invalid?: BooleanProp;
181
+ valid?: BooleanProp;
182
+ style?: StyleProp;
183
+ class?: ClassProp;
184
+ className?: ClassProp;
185
+ line1?: GridRowLineConfig;
186
+ line2?: GridRowLineConfig;
187
+ line3?: GridRowLineConfig;
188
+ mod?: StringProp | Prop<string[]> | StructuredProp;
189
+ }
190
+
191
+ interface GridProps<T = unknown> extends StyledContainerProps {
192
+ /** An array of records to be displayed in the grid. */
193
+ records?: Prop<T[]>;
194
+
195
+ /** Set to true to add a vertical scroll and a fixed header to the grid. */
196
+ scrollable?: boolean;
197
+
198
+ /** A binding used to store the sorting order list. Commonly used for server-side sorting. */
199
+ sorters?: SortersProp;
200
+
201
+ /** A list of sorters to be prepended to the actual list of sorters. */
202
+ preSorters?: SortersProp;
203
+
204
+ /** A binding used to store the name of the field used for sorting grids. Available only if sorters are not used. */
205
+ sortField?: StringProp;
206
+
207
+ /** A binding used to store the sort direction. Available only if sorters are not used. Possible values are "ASC" and "DESC". Defaults to "ASC". */
208
+ sortDirection?: StringProp;
209
+
210
+ /** Default sort field. Used if neither sortField or sorters are set. */
211
+ defaultSortField?: string;
212
+
213
+ /** Default sort direction. */
214
+ defaultSortDirection?: "ASC" | "DESC";
215
+
216
+ /** Set to true to add vertical gridlines. */
217
+ vlines?: boolean;
218
+
219
+ /** Text to be displayed instead of an empty table. */
220
+ emptyText?: StringProp;
221
+
222
+ /** Drag source configuration. Define mode as 'move' or 'copy` and additional data. */
223
+ dragSource?: StructuredProp;
224
+
225
+ /** Drop zone configuration. Define mode as either preview or insertion. */
226
+ dropZone?: StructuredProp;
227
+
228
+ /** Row configuration. See grid examples. */
229
+ row?: GridRowConfig;
230
+
231
+ /**An array of columns. Check column configuration options in the section below. */
232
+ columns?: GridColumnConfig[];
233
+
234
+ /** Whenever columnParams change, columns are recalculated using the onGetColumn callback. */
235
+ columnParams?: Config;
236
+
237
+ /** Selection configuration. */
238
+ selection?: Config;
239
+
240
+ /** An array of grouping level definitions. Check allowed grouping level properties in the section below. */
241
+ grouping?: GridGroupingConfig<T>[];
242
+
243
+ /** Params for grouping. Whenever params change grouping is recalculated using the onGetGrouping callback. */
244
+ groupingParams?: Config;
245
+
246
+ /**
247
+ * Determines header appearance. Supported values are plain and default. Default mode is used if some of the columns are sortable.
248
+ * Plain mode better suits reports and other scenarios in which users do not interact with the grid.
249
+ */
250
+ headerMode?: StringProp;
251
+
252
+ /** Set to true to add default border around the table. Automatically set if grid is scrollable. */
253
+ border?: BooleanProp;
254
+
255
+ /** Base CSS class to be applied to the element. Default is 'grid'. */
256
+ baseClass?: string;
257
+
258
+ /** A field used to get the unique identifier of the record. Setting keyField improves grid performance on sort operations as the widget is able to identify row movement inside the grid. */
259
+ keyField?: string;
260
+
261
+ /** Show grid header within the group. Useful for long report-like (printable) grids. Defaults to false. */
262
+ showHeader?: boolean;
263
+
264
+ /** Show grid footer. Defaults to false. */
265
+ showFooter?: boolean;
266
+
267
+ /** Record alias. Default is $record. */
268
+ recordName?: RecordAlias;
269
+
270
+ /** Record alias. Default is $record. */
271
+ recordAlias?: RecordAlias;
272
+
273
+ /** Set to true if sorting is done remotely, on the server-side. Default value is false. */
274
+ remoteSort?: boolean;
275
+
276
+ /** Set to true to enable row caching. This greatly improves grid performance
277
+ on subsequent render operations, however, only changes on records
278
+ are allowed. If grid rows display any data outside records, changes on that
279
+ data will be ignored. */
280
+ cached?: boolean;
281
+
282
+ /** Render only rows visible on the screen. */
283
+ buffered?: boolean;
284
+
285
+ /** Specifies how many rows should be visible on the screen */
286
+ bufferSize?: number;
287
+
288
+ /** Specifies how many rows needs to be scrolled in order to recalculate buffer */
289
+ bufferStep?: number;
290
+
291
+ /** Used when rows have variable heights to improve buffered rendering by measuring and caching rendered row heights. Default value is false. */
292
+ measureRowHeights?: boolean;
293
+
294
+ /** Scrolls selection into the view. Default value is false. */
295
+ scrollSelectionIntoView?: boolean;
296
+
297
+ /**
298
+ * Set to true to lock column widths after the first render.
299
+ * This is helpful in pagination scenarios to maintain consistent looks across pages.
300
+ */
301
+ lockColumnWidths?: boolean;
302
+
303
+ lockColumnWidthsRequiredRowCount?: number;
304
+ focused?: boolean;
305
+ showBorder?: boolean;
306
+
307
+ /** Data adapter used to convert data in list of records. Used to enable grouping and tree operations. */
308
+ dataAdapter?: any;
309
+
310
+ /** Additional CSS class to be added to each grid row. */
311
+ rowClass?: ClassProp;
312
+
313
+ /** Additional CSS styles to be added to each grid row. */
314
+ rowStyle?: StyleProp;
315
+
316
+ // drag-drop handlers
317
+ onDrop?: string | ((e: GridDragEvent<T>, instance: Instance) => void);
318
+ onDropTest?: string | ((e: DragEvent, instance: Instance) => boolean);
319
+ onDragStart?: string | ((e: DragEvent, instance: Instance) => void);
320
+ onDragEnd?: string | ((e: DragEvent, instance: Instance) => void);
321
+ onDragOver?: string | ((e: GridDragEvent<T>, instance: Instance) => void | boolean);
322
+
323
+ onRowDropTest?: string | ((e: DragEvent, instance: Instance) => boolean);
324
+ onRowDragOver?: string | ((e: GridRowDragEvent<T>, instance: Instance) => void | boolean);
325
+ onRowDrop?: string | ((e: GridRowDragEvent<T>, instance: Instance) => void | boolean);
326
+
327
+ onColumnDrop?: string | ((e: GridColumnDropEvent, instance: Instance) => void);
328
+ onColumnDropTest?: string | ((e: DragEvent, instance: Instance) => boolean);
329
+
330
+ /** Parameters that affect filtering. */
331
+ filterParams?: StructuredProp;
332
+
333
+ /** Callback function to be executed when a row is right-clicked. */
334
+ onRowContextMenu?: string | ((e: React.SyntheticEvent<any>, instance: Instance) => void);
335
+
336
+ /** Callback to create a filter function for given filter params. */
337
+ onCreateFilter?: (filterParams: any, instance?: Instance) => (record: T) => boolean;
338
+
339
+ /** Enable infinite scrolling */
340
+ infinite?: boolean;
341
+
342
+ /** If set, clicking on the column header will loop between ASC, DESC and no sorting order, instead of ASC and DESC only. */
343
+ clearableSort?: boolean;
344
+
345
+ /** A callback to fetch records during infinite loading */
346
+ onFetchRecords?: (
347
+ pageInfo: {
348
+ page: number;
349
+ pageSize: number;
350
+ sorters?: Record[];
351
+ sortField?: string;
352
+ sortDirection?: string;
353
+ },
354
+ instance?: Instance,
355
+ ) => FetchRecordsResult<T> | Promise<FetchRecordsResult<T>>;
356
+
357
+ /** Callback function to be executed when a row is double-clicked. */
358
+ onRowDoubleClick?: string | ((e: React.SyntheticEvent<any>, instance: Instance) => void);
359
+
360
+ /** Callback function to be executed on key down. Accepts instance of the currently focused record as the second argument. */
361
+ onRowKeyDown?: string | ((e: React.SyntheticEvent<any>, instance: Instance) => void);
362
+
363
+ /** Callback function to be executed when a row is clicked. */
364
+ onRowClick?: string | ((e: React.SyntheticEvent<any>, instance: Instance) => void);
365
+
366
+ /** Set to true to add a fixed footer at the bottom of the grid. */
367
+ fixedFooter?: boolean;
368
+
369
+ /** Set to true to enable cell editing. Please note that all editable columns should specify the editor field. */
370
+ cellEditable?: boolean;
371
+
372
+ /** 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. */
373
+ onBeforeCellEdit?: string | ((change: GridCellBeforeEditInfo, record: DataAdapterRecord<T>) => any);
374
+
375
+ /** A callback function which is executed after a cell has been successfully edited. */
376
+ onCellEdited?: string | ((change: GridCellEditInfo<T>, record: DataAdapterRecord<T>) => void);
377
+
378
+ /** A callback function which is executed after a column has been resized. */
379
+ onColumnResize?: (data: { width: number; column: Record }, instance: Instance) => void;
380
+
381
+ /** Options for data sorting. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator */
382
+ sortOptions?: CollatorOptions;
383
+
384
+ /** Callback to create a function that can be used to check whether a record is selectable. */
385
+ onCreateIsRecordSelectable?: (
386
+ params: any,
387
+ instance: Instance,
388
+ ) => (record: T, options?: { range?: boolean; toggle?: boolean }) => boolean;
389
+
390
+ /** Parameters whose change will cause scroll to be reset. */
391
+ scrollResetParams?: StructuredProp;
392
+
393
+ /** Enable precise (sub-pixel) measurements. Useful for grids with many columns. Better behavior at small zoom factors. */
394
+ preciseMeasurements?: boolean;
395
+
396
+ /** A value used to identify the group of components participating in hover effect synchronization. */
397
+ hoverChannel?: string;
398
+
399
+ /** A value used to uniquely identify the record within the hover sync group. */
400
+ rowHoverId?: Prop<string | number>;
401
+
402
+ /** Set to true or false to explicitly define if grid is allowed to receive focus. */
403
+ focusable?: boolean;
404
+
405
+ /** Callback function to retrieve grouping data. */
406
+ onGetGrouping?: (params: any, instance: Instance) => GridGroupingConfig<T>[];
407
+
408
+ /** Callback function to dynamically calculate columns. */
409
+ onGetColumns?: (params: any, instance: Instance) => GridColumnConfig[] | GridRowConfig;
410
+
411
+ /** Allow grid to receive drag and drop operations containing files. */
412
+ allowsFileDrops?: boolean;
413
+
414
+ /**
415
+ * Callback function to track and retrieve displayed records.
416
+ * Accepts new records as a first argument.
417
+ * If onCreateFilter callback is defined, filtered records can be retrieved using this callback.
418
+ */
419
+ onTrackMappedRecords?: string | ((records: DataAdapterRecord<T>[], instance: Instance) => void);
420
+
421
+ /** Callback to create a function that can be used to check whether a record is draggable. */
422
+ onCreateIsRecordDraggable?: (params: any, instance: Instance) => (record: T) => boolean;
423
+
424
+ /** Callback function to get grid component and instance references on component init. */
425
+ onRef?: string | ((element: any, instance: Instance) => void);
426
+ }
427
+
428
+ interface GridCellInfo {
429
+ column: any;
430
+ field: string;
431
+ }
432
+
433
+ interface GridCellBeforeEditInfo extends GridCellInfo {
434
+ data: any;
435
+ }
436
+
437
+ interface GridCellEditInfo<T> extends GridCellInfo {
438
+ oldData: T;
439
+ newData: T;
440
+ }
441
+
442
+ export class Grid<T = unknown> extends Widget<GridProps<T>> {}