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.
Files changed (45) hide show
  1. package/dist/data.js +94 -25
  2. package/dist/manifest.js +474 -468
  3. package/dist/ui.js +27 -6
  4. package/dist/widgets.js +1 -1
  5. package/package.json +1 -1
  6. package/src/core.d.ts +41 -6
  7. package/src/data/Binding.d.ts +4 -3
  8. package/src/data/Binding.js +12 -8
  9. package/src/data/Store.d.ts +5 -5
  10. package/src/data/Store.js +2 -2
  11. package/src/data/StoreRef.js +2 -0
  12. package/src/data/StructuredSelector.js +43 -57
  13. package/src/data/StructuredSelector.spec.js +54 -39
  14. package/src/data/View.d.ts +40 -16
  15. package/src/data/View.js +27 -19
  16. package/src/data/comparer.js +15 -10
  17. package/src/data/computable.d.ts +27 -4
  18. package/src/data/computable.js +2 -1
  19. package/src/data/computable.spec.js +8 -0
  20. package/src/data/createAccessorModelProxy.d.ts +6 -0
  21. package/src/data/createAccessorModelProxy.js +24 -0
  22. package/src/data/createAccessorModelProxy.spec.tsx +23 -0
  23. package/src/data/createStructuredSelector.js +9 -8
  24. package/src/data/getAccessor.js +24 -15
  25. package/src/data/getSelector.js +4 -1
  26. package/src/data/getSelector.spec.js +7 -0
  27. package/src/data/index.d.ts +2 -0
  28. package/src/data/index.js +2 -0
  29. package/src/ui/Controller.d.ts +13 -8
  30. package/src/ui/Instance.d.ts +6 -6
  31. package/src/ui/Instance.js +6 -5
  32. package/src/ui/Repeater.d.ts +25 -15
  33. package/src/ui/Restate.spec.js +0 -1
  34. package/src/ui/adapter/ArrayAdapter.d.ts +9 -10
  35. package/src/ui/adapter/ArrayAdapter.js +30 -37
  36. package/src/ui/bind.d.ts +3 -2
  37. package/src/ui/bind.js +4 -3
  38. package/src/ui/expr.d.ts +23 -2
  39. package/src/ui/expr.js +16 -4
  40. package/src/widgets/AccessorBindings.spec.tsx +66 -0
  41. package/src/widgets/HtmlElement.d.ts +1 -1
  42. package/src/widgets/List.d.ts +36 -24
  43. package/src/widgets/form/ValidationGroup.spec.js +1 -1
  44. package/src/widgets/grid/Grid.d.ts +86 -68
  45. 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
- type FetchRecordsResult = Cx.Record[] | { records: Cx.Record[]; lastPage?: boolean; totalRecordCount?: number };
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: Cx.Record;
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
- | Cx.Prop<any>
56
+ | Prop<any>
41
57
  | {
42
- value: Cx.Prop<any>;
43
- direction: Cx.SortDirection;
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?: Cx.StructuredProp;
67
+ aggregates?: StructuredProp;
52
68
  showCaption?: boolean;
53
69
  showFooter?: boolean;
54
70
  showHeader?: boolean;
55
- caption?: Cx.StringProp;
56
- name?: Cx.StringProp;
57
- text?: Cx.StringProp;
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?: Cx.StringProp;
65
- colSpan?: Cx.NumberProp;
66
- rowSpan?: Cx.NumberProp;
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?: Cx.StringProp;
78
- header?: Cx.StringProp | GridColumnHeaderConfig;
79
- header1?: Cx.StringProp | GridColumnHeaderConfig;
80
- header2?: Cx.StringProp | GridColumnHeaderConfig;
81
- header3?: Cx.StringProp | GridColumnHeaderConfig;
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?: Cx.StringProp;
87
- class?: Cx.ClassProp;
88
- className?: Cx.ClassProp;
105
+ caption?: StringProp;
106
+ class?: ClassProp;
107
+ className?: ClassProp;
89
108
  draggable?: boolean;
90
109
  editable?: boolean;
91
110
  editor?: React.ReactNode;
92
- footer?: Cx.StringProp | false;
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?: Cx.Prop<any>;
100
- style?: Cx.StyleProp;
117
+ sortValue?: Prop<any>;
118
+ style?: StyleProp;
101
119
  trimWhitespace?: boolean;
102
- visible?: Cx.BooleanProp;
103
- if?: Cx.BooleanProp;
120
+ visible?: BooleanProp;
121
+ if?: BooleanProp;
104
122
  weightField?: string;
105
123
 
106
124
  // Not in docs
107
- value?: Cx.Prop<any>;
108
- defaultWidth?: Cx.NumberProp;
109
- width?: Cx.NumberProp;
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?: Cx.CollatorOptions;
132
+ sortOptions?: CollatorOptions;
115
133
  }
116
134
 
117
135
  interface GridRowLineConfig {
118
- visible?: Cx.BooleanProp;
136
+ visible?: BooleanProp;
119
137
  columns: GridColumnConfig[];
120
138
  }
121
139
 
122
140
  interface GridRowConfig {
123
- invalid?: Cx.BooleanProp;
124
- valid?: Cx.BooleanProp;
125
- style?: Cx.StyleProp;
126
- class?: Cx.ClassProp;
127
- className?: Cx.ClassProp;
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 Cx.StyledContainerProps {
151
+ interface GridProps extends StyledContainerProps {
134
152
  /** An array of records to be displayed in the grid. */
135
- records?: Cx.Prop<Cx.Record[]>;
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?: Cx.SortersProp;
159
+ sorters?: SortersProp;
142
160
 
143
161
  /** A list of sorters to be prepended to the actual list of sorters. */
144
- preSorters?: Cx.SortersProp;
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?: Cx.StringProp;
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". Deafults to "ASC". */
150
- sortDirection?: Cx.StringProp;
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?: Cx.StringProp;
180
+ emptyText?: StringProp;
163
181
 
164
182
  /** Drag source configuration. Define mode as 'move' or 'copy` and additional data. */
165
- dragSource?: Cx.StructuredProp;
183
+ dragSource?: StructuredProp;
166
184
 
167
185
  /** Drop zone configuration. Define mode as either preview or insertion. */
168
- dropZone?: Cx.StructuredProp;
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?: Cx.Config;
195
+ columnParams?: Config;
178
196
 
179
197
  /** Selection configuration. */
180
- selection?: Cx.Config;
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?: Cx.Config;
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?: Cx.StringProp;
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?: Cx.BooleanProp;
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?: string;
228
+ recordName?: RecordAlias;
211
229
 
212
230
  /** Record alias. Default is $record. */
213
- recordAlias?: string;
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?: Cx.ClassProp;
271
+ rowClass?: ClassProp;
254
272
 
255
273
  /** Additional CSS styles to be added to each grid row. */
256
- rowStyle?: Cx.StyleProp;
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?: Cx.StructuredProp;
291
+ filterParams?: StructuredProp;
274
292
 
275
293
  /** Callback to create a filter function for given filter params. */
276
- onCreateFilter?: (filterParams: any, instance?: Instance) => (record: Cx.Record) => boolean;
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?: Cx.Record[];
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 initalized. Return false from the callback to prevent the cell from going into the edit mode. */
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: Cx.Record }, instance: Instance) => void;
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?: Cx.CollatorOptions;
336
+ sortOptions?: CollatorOptions;
319
337
 
320
338
  onCreateIsRecordSelectable?: (
321
339
  params: any,
322
340
  instance: Instance
323
- ) => (record: Cx.Record, options?: { range?: boolean; toggle?: boolean }) => boolean;
341
+ ) => (record: Record, options?: { range?: boolean; toggle?: boolean }) => boolean;
324
342
 
325
- /** Parameters whose change will casuse scroll to be reset. */
326
- scrollResetParams?: Cx.StructuredProp;
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?: Cx.StringProp;
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 Cx.Widget<GridProps> {}
368
+ export class Grid extends Widget<GridProps> {}
@@ -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
  }