cx 22.1.1 → 22.1.2
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/manifest.js +501 -501
- package/dist/widgets.js +28 -11
- package/package.json +1 -1
- package/src/ui/FocusManager.d.ts +12 -10
- package/src/widgets/grid/Grid.d.ts +3 -0
- package/src/widgets/grid/Grid.js +47 -33
package/dist/widgets.js
CHANGED
|
@@ -20116,16 +20116,33 @@ var GridComponent = /*#__PURE__*/ (function(_VDOM$Component) {
|
|
|
20116
20116
|
}
|
|
20117
20117
|
}
|
|
20118
20118
|
|
|
20119
|
-
if (futureState.cellEdit && !wasCellEditing)
|
|
20120
|
-
|
|
20119
|
+
if (futureState.cellEdit && !wasCellEditing) {
|
|
20120
|
+
var _record = _this11.getRecordAt(futureState.cursor);
|
|
20121
|
+
|
|
20122
|
+
var cellEditUndoData = _record.data;
|
|
20123
|
+
if (
|
|
20124
|
+
widget.onBeforeCellEdit &&
|
|
20125
|
+
_this11.props.instance.invoke(
|
|
20126
|
+
"onBeforeCellEdit",
|
|
20127
|
+
{
|
|
20128
|
+
column: visibleColumns[futureState.cursorCellIndex],
|
|
20129
|
+
data: cellEditUndoData,
|
|
20130
|
+
field: visibleColumns[futureState.cursorCellIndex].field
|
|
20131
|
+
},
|
|
20132
|
+
_record
|
|
20133
|
+
) === false
|
|
20134
|
+
)
|
|
20135
|
+
return;
|
|
20136
|
+
_this11.cellEditUndoData = cellEditUndoData;
|
|
20137
|
+
}
|
|
20121
20138
|
|
|
20122
20139
|
_this11.setState(newState, function() {
|
|
20123
20140
|
if (_this11.state.focused && !_this11.state.cellEdit && wasCellEditing) FocusManager.focus(_this11.dom.el);
|
|
20124
20141
|
|
|
20125
20142
|
if (scrollIntoView) {
|
|
20126
|
-
var
|
|
20143
|
+
var _record2 = _this11.getRecordAt(index);
|
|
20127
20144
|
|
|
20128
|
-
var item =
|
|
20145
|
+
var item = _record2 && _this11.dom.table.querySelector('tbody[data-record-key="' + _record2.key + '"]');
|
|
20129
20146
|
|
|
20130
20147
|
var hscroll = false;
|
|
20131
20148
|
|
|
@@ -20136,7 +20153,7 @@ var GridComponent = /*#__PURE__*/ (function(_VDOM$Component) {
|
|
|
20136
20153
|
item =
|
|
20137
20154
|
item.firstChild.children[_this11.state.cursorCellIndex - _this11.props.instance.fixedColumnCount];
|
|
20138
20155
|
} else {
|
|
20139
|
-
var fixedItem = _this11.dom.fixedTable.querySelector('tbody[data-record-key="' +
|
|
20156
|
+
var fixedItem = _this11.dom.fixedTable.querySelector('tbody[data-record-key="' + _record2.key + '"]');
|
|
20140
20157
|
|
|
20141
20158
|
var cell = fixedItem && fixedItem.firstChild.children[_this11.state.cursorCellIndex];
|
|
20142
20159
|
if (cell) scrollElementIntoView(cell, false, true, 10);
|
|
@@ -20347,10 +20364,10 @@ var GridComponent = /*#__PURE__*/ (function(_VDOM$Component) {
|
|
|
20347
20364
|
|
|
20348
20365
|
case KeyCode.down:
|
|
20349
20366
|
for (var _cursor = this.state.cursor + 1; ; _cursor++) {
|
|
20350
|
-
var
|
|
20367
|
+
var _record3 = this.getRecordAt(_cursor);
|
|
20351
20368
|
|
|
20352
|
-
if (!
|
|
20353
|
-
if (
|
|
20369
|
+
if (!_record3) break;
|
|
20370
|
+
if (_record3.type != "data") continue;
|
|
20354
20371
|
this.moveCursor(_cursor, {
|
|
20355
20372
|
focused: true,
|
|
20356
20373
|
scrollIntoView: true,
|
|
@@ -20366,10 +20383,10 @@ var GridComponent = /*#__PURE__*/ (function(_VDOM$Component) {
|
|
|
20366
20383
|
|
|
20367
20384
|
case KeyCode.up:
|
|
20368
20385
|
for (var _cursor2 = this.state.cursor - 1; _cursor2 >= 0; _cursor2--) {
|
|
20369
|
-
var
|
|
20386
|
+
var _record4 = this.getRecordAt(_cursor2);
|
|
20370
20387
|
|
|
20371
|
-
if (!
|
|
20372
|
-
if (
|
|
20388
|
+
if (!_record4) break;
|
|
20389
|
+
if (_record4.type != "data") continue;
|
|
20373
20390
|
this.moveCursor(_cursor2, {
|
|
20374
20391
|
focused: true,
|
|
20375
20392
|
scrollIntoView: true,
|
package/package.json
CHANGED
package/src/ui/FocusManager.d.ts
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import * as Cx from
|
|
1
|
+
import * as Cx from "../core";
|
|
2
2
|
|
|
3
3
|
declare type FocusOutCallback = (Element) => void;
|
|
4
4
|
|
|
5
5
|
export class FocusManager {
|
|
6
|
-
|
|
6
|
+
static subscribe(callback: FocusOutCallback): void;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
static onFocusOut(el: Element, callback: FocusOutCallback): () => void;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
static oneFocusOut(el: Element, callback: FocusOutCallback): () => void;
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
static nudge(): () => void;
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
static focus(el: Element): () => void;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
static focusFirst(el: Element): () => void;
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
static setInterval(interval: number): void;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function oneFocusOut(component: any, el: Element, callback: FocusOutCallback);
|
|
22
22
|
|
|
23
|
-
export function offFocusOut(component: any)
|
|
23
|
+
export function offFocusOut(component: any): void;
|
|
24
24
|
|
|
25
|
-
export function preventFocus(e: Event)
|
|
25
|
+
export function preventFocus(e: Event): void;
|
|
26
26
|
|
|
27
27
|
export function preventFocusOnTouch(e: Event, force?: boolean): void;
|
|
28
|
+
|
|
29
|
+
export function unfocusElement(target?: Element, forceBlur?: boolean): void;
|
|
@@ -305,6 +305,9 @@ interface GridProps extends Cx.StyledContainerProps {
|
|
|
305
305
|
/** Set to true to enable cell editing. Please note that all editable columns should specify the editor field. */
|
|
306
306
|
cellEditable?: boolean;
|
|
307
307
|
|
|
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. */
|
|
309
|
+
onBeforeCellEdit?: (change, record) => any;
|
|
310
|
+
|
|
308
311
|
/** A callback function which is executed after a cell has been successfully edited. */
|
|
309
312
|
onCellEdited?: (change, record) => void;
|
|
310
313
|
|
package/src/widgets/grid/Grid.js
CHANGED
|
@@ -162,16 +162,16 @@ export class Grid extends Widget {
|
|
|
162
162
|
value: isDefined(c.aggregateValue)
|
|
163
163
|
? c.aggregateValue
|
|
164
164
|
: isDefined(c.value)
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
? c.value
|
|
166
|
+
: c.aggregateField
|
|
167
|
+
? { bind: this.recordName + "." + c.aggregateField }
|
|
168
|
+
: null,
|
|
169
169
|
weight:
|
|
170
170
|
c.weight != null
|
|
171
171
|
? c.weight
|
|
172
172
|
: c.weightField && {
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
bind: this.recordName + "." + c.weightField,
|
|
174
|
+
},
|
|
175
175
|
type: c.aggregate,
|
|
176
176
|
};
|
|
177
177
|
}
|
|
@@ -594,8 +594,9 @@ export class Grid extends Widget {
|
|
|
594
594
|
let initialPosition = getCursorPos(e);
|
|
595
595
|
resizeOverlayEl.className = CSS.element(baseClass, "resize-overlay");
|
|
596
596
|
resizeOverlayEl.style.width = `${initialWidth}px`;
|
|
597
|
-
resizeOverlayEl.style.left = `${
|
|
598
|
-
|
|
597
|
+
resizeOverlayEl.style.left = `${
|
|
598
|
+
headerCell.getBoundingClientRect().left - gridEl.getBoundingClientRect().left
|
|
599
|
+
}px`;
|
|
599
600
|
gridEl.appendChild(resizeOverlayEl);
|
|
600
601
|
captureMouse2(e, {
|
|
601
602
|
onMouseMove: (e) => {
|
|
@@ -743,7 +744,7 @@ export class Grid extends Widget {
|
|
|
743
744
|
widget: () => <div className={CSS.element(baseClass, "col-header-drag-clone")}>{data.text}</div>,
|
|
744
745
|
},
|
|
745
746
|
},
|
|
746
|
-
() => {
|
|
747
|
+
() => {}
|
|
747
748
|
);
|
|
748
749
|
}
|
|
749
750
|
}
|
|
@@ -769,14 +770,14 @@ export class Grid extends Widget {
|
|
|
769
770
|
|
|
770
771
|
let sorters = direction
|
|
771
772
|
? [
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
773
|
+
{
|
|
774
|
+
field,
|
|
775
|
+
direction,
|
|
776
|
+
value,
|
|
777
|
+
comparer,
|
|
778
|
+
sortOptions,
|
|
779
|
+
},
|
|
780
|
+
]
|
|
780
781
|
: null;
|
|
781
782
|
|
|
782
783
|
instance.set("sorters", sorters);
|
|
@@ -1018,7 +1019,6 @@ export class Grid extends Widget {
|
|
|
1018
1019
|
)
|
|
1019
1020
|
);
|
|
1020
1021
|
|
|
1021
|
-
|
|
1022
1022
|
if (g.showHeader) {
|
|
1023
1023
|
record.vdom.push(this.renderHeader(context, instance, record.key + "-header", false, false));
|
|
1024
1024
|
if (hasFixedColumns)
|
|
@@ -1076,7 +1076,7 @@ export class Grid extends Widget {
|
|
|
1076
1076
|
instance,
|
|
1077
1077
|
record.grouping,
|
|
1078
1078
|
record.level,
|
|
1079
|
-
record.group || {
|
|
1079
|
+
record.group || { $key: "fixed-footer" },
|
|
1080
1080
|
record.key + "-footer",
|
|
1081
1081
|
record.store,
|
|
1082
1082
|
true,
|
|
@@ -1089,7 +1089,7 @@ export class Grid extends Widget {
|
|
|
1089
1089
|
instance,
|
|
1090
1090
|
record.grouping,
|
|
1091
1091
|
record.level,
|
|
1092
|
-
record.group || {
|
|
1092
|
+
record.group || { $key: "fixed-footer" },
|
|
1093
1093
|
record.key + "-footer",
|
|
1094
1094
|
record.store,
|
|
1095
1095
|
true,
|
|
@@ -1215,8 +1215,8 @@ class GridComponent extends VDOM.Component {
|
|
|
1215
1215
|
style={
|
|
1216
1216
|
this.rowHeight > 0
|
|
1217
1217
|
? {
|
|
1218
|
-
|
|
1219
|
-
|
|
1218
|
+
height: this.rowHeight + 1,
|
|
1219
|
+
}
|
|
1220
1220
|
: null
|
|
1221
1221
|
}
|
|
1222
1222
|
>
|
|
@@ -1484,8 +1484,6 @@ class GridComponent extends VDOM.Component {
|
|
|
1484
1484
|
true
|
|
1485
1485
|
)
|
|
1486
1486
|
);
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
1487
|
}
|
|
1490
1488
|
}
|
|
1491
1489
|
}
|
|
@@ -1915,8 +1913,7 @@ class GridComponent extends VDOM.Component {
|
|
|
1915
1913
|
};
|
|
1916
1914
|
instance.invoke("onColumnDrop", e, instance);
|
|
1917
1915
|
}
|
|
1918
|
-
}
|
|
1919
|
-
catch (err) {
|
|
1916
|
+
} catch (err) {
|
|
1920
1917
|
console.error("Grid drop operation failed. Please fix this error:", err);
|
|
1921
1918
|
}
|
|
1922
1919
|
|
|
@@ -2483,8 +2480,26 @@ class GridComponent extends VDOM.Component {
|
|
|
2483
2480
|
}
|
|
2484
2481
|
}
|
|
2485
2482
|
|
|
2486
|
-
if (futureState.cellEdit && !wasCellEditing)
|
|
2487
|
-
|
|
2483
|
+
if (futureState.cellEdit && !wasCellEditing) {
|
|
2484
|
+
let record = this.getRecordAt(futureState.cursor);
|
|
2485
|
+
let cellEditUndoData = record.data;
|
|
2486
|
+
|
|
2487
|
+
if (
|
|
2488
|
+
widget.onBeforeCellEdit &&
|
|
2489
|
+
this.props.instance.invoke(
|
|
2490
|
+
"onBeforeCellEdit",
|
|
2491
|
+
{
|
|
2492
|
+
column: visibleColumns[futureState.cursorCellIndex],
|
|
2493
|
+
data: cellEditUndoData,
|
|
2494
|
+
field: visibleColumns[futureState.cursorCellIndex].field,
|
|
2495
|
+
},
|
|
2496
|
+
record
|
|
2497
|
+
) === false
|
|
2498
|
+
)
|
|
2499
|
+
return;
|
|
2500
|
+
|
|
2501
|
+
this.cellEditUndoData = cellEditUndoData;
|
|
2502
|
+
}
|
|
2488
2503
|
|
|
2489
2504
|
this.setState(newState, () => {
|
|
2490
2505
|
if (this.state.focused && !this.state.cellEdit && wasCellEditing) FocusManager.focus(this.dom.el);
|
|
@@ -2501,7 +2516,7 @@ class GridComponent extends VDOM.Component {
|
|
|
2501
2516
|
hscroll = true;
|
|
2502
2517
|
item =
|
|
2503
2518
|
item.firstChild.children[
|
|
2504
|
-
|
|
2519
|
+
this.state.cursorCellIndex - this.props.instance.fixedColumnCount
|
|
2505
2520
|
];
|
|
2506
2521
|
} else {
|
|
2507
2522
|
let fixedItem = this.dom.fixedTable.querySelector(`tbody[data-record-key="${record.key}"]`);
|
|
@@ -3155,7 +3170,6 @@ class AvgHeight {
|
|
|
3155
3170
|
}
|
|
3156
3171
|
}
|
|
3157
3172
|
|
|
3158
|
-
|
|
3159
3173
|
function getDragDropEvent(ev) {
|
|
3160
3174
|
return {
|
|
3161
3175
|
event: ev,
|
|
@@ -3164,7 +3178,7 @@ function getDragDropEvent(ev) {
|
|
|
3164
3178
|
source: {
|
|
3165
3179
|
width: 32,
|
|
3166
3180
|
height: 32,
|
|
3167
|
-
margin: []
|
|
3168
|
-
}
|
|
3181
|
+
margin: [],
|
|
3182
|
+
},
|
|
3169
3183
|
};
|
|
3170
|
-
}
|
|
3184
|
+
}
|