cx 24.3.0 → 24.3.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/data.js +15 -26
- package/dist/manifest.js +668 -668
- package/dist/util.js +4 -2
- package/dist/widgets.js +53 -32
- package/package.json +1 -1
- package/src/data/Expression.js +212 -212
- package/src/data/Expression.spec.js +174 -174
- package/src/ui/Format.js +87 -87
- package/src/util/getParentFrameBoundingClientRect.js +6 -4
- package/src/widgets/form/ColorPicker.scss +275 -275
- package/src/widgets/form/ColorPicker.variables.scss +22 -22
- package/src/widgets/grid/Grid.js +85 -74
- package/src/widgets/overlay/captureMouse.js +37 -46
package/src/widgets/grid/Grid.js
CHANGED
|
@@ -524,7 +524,7 @@ export class Grid extends Container {
|
|
|
524
524
|
|
|
525
525
|
let headerCell = findFirstChild(
|
|
526
526
|
headerTBody,
|
|
527
|
-
(el) => el.tagName == "TH" && el.dataset
|
|
527
|
+
(el) => el.tagName == "TH" && el.dataset && el.dataset.uniqueColId == uniqueColId,
|
|
528
528
|
);
|
|
529
529
|
let scrollAreaEl = headerTBody.parentElement.parentElement;
|
|
530
530
|
let gridEl = scrollAreaEl.parentElement;
|
|
@@ -608,15 +608,16 @@ export class Grid extends Container {
|
|
|
608
608
|
if (!header) return null;
|
|
609
609
|
|
|
610
610
|
let skip = {};
|
|
611
|
+
let lineIndex = 0;
|
|
611
612
|
|
|
612
|
-
header.children.forEach((line
|
|
613
|
+
header.children.forEach((line) => {
|
|
613
614
|
let empty = [true, true, true];
|
|
614
615
|
let result = [[], [], []];
|
|
615
616
|
|
|
616
617
|
line.children.forEach((hdinst, colIndex) => {
|
|
617
618
|
let hdwidget = hdinst.widget;
|
|
618
619
|
for (let l = 0; l < 3; l++) {
|
|
619
|
-
let colKey = `${lineIndex}-${colIndex}
|
|
620
|
+
let colKey = `${lineIndex + l}-${colIndex}`;
|
|
620
621
|
|
|
621
622
|
if (skip[colKey]) continue;
|
|
622
623
|
|
|
@@ -689,7 +690,7 @@ export class Grid extends Container {
|
|
|
689
690
|
|
|
690
691
|
for (let r = 0; r < header.data.rowSpan; r++)
|
|
691
692
|
for (let c = 0; c < header.data.colSpan; c++)
|
|
692
|
-
skip[`${lineIndex
|
|
693
|
+
skip[`${lineIndex + l + r}-${colIndex + c}`] = true;
|
|
693
694
|
}
|
|
694
695
|
|
|
695
696
|
if ((hdwidget.resizable || header.data.resizable) && header.data.colSpan < 2) {
|
|
@@ -744,6 +745,7 @@ export class Grid extends Container {
|
|
|
744
745
|
});
|
|
745
746
|
|
|
746
747
|
result = result.filter((_, i) => !empty[i]);
|
|
748
|
+
lineIndex += result.length;
|
|
747
749
|
|
|
748
750
|
if (result[0]) {
|
|
749
751
|
if (fixed && !fixedColumns) {
|
|
@@ -752,19 +754,17 @@ export class Grid extends Container {
|
|
|
752
754
|
);
|
|
753
755
|
}
|
|
754
756
|
|
|
755
|
-
headerRows.push(
|
|
756
|
-
<tbody key={"h" + key + lineIndex} className={CSS.element(baseClass, "header")}>
|
|
757
|
-
{result.map((h, i) => (
|
|
758
|
-
<tr key={i}>{h}</tr>
|
|
759
|
-
))}
|
|
760
|
-
</tbody>,
|
|
761
|
-
);
|
|
757
|
+
headerRows.push(...result.map((h, i) => <tr key={`${lineIndex}-${i}`}>{h}</tr>));
|
|
762
758
|
}
|
|
763
759
|
});
|
|
764
760
|
|
|
765
761
|
if (headerRows.length == 0) return null;
|
|
766
762
|
|
|
767
|
-
return
|
|
763
|
+
return (
|
|
764
|
+
<tbody key={"h" + key} className={CSS.element(baseClass, "header")}>
|
|
765
|
+
{headerRows}
|
|
766
|
+
</tbody>
|
|
767
|
+
);
|
|
768
768
|
}
|
|
769
769
|
|
|
770
770
|
onHeaderMouseMove(e, column, columnInstance, gridInstance, headerLine) {
|
|
@@ -1333,68 +1333,79 @@ class GridComponent extends VDOM.Component {
|
|
|
1333
1333
|
mod["draggable"] = draggable;
|
|
1334
1334
|
mod["non-draggable"] = !draggable;
|
|
1335
1335
|
|
|
1336
|
-
let wrap = (children) =>
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
if (
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
style =
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1336
|
+
let wrap = (children) => {
|
|
1337
|
+
let skipCells = {};
|
|
1338
|
+
return (
|
|
1339
|
+
<GridRowComponent
|
|
1340
|
+
key={key}
|
|
1341
|
+
className={CSS.state(mod)}
|
|
1342
|
+
store={store}
|
|
1343
|
+
dragSource={dragSource}
|
|
1344
|
+
instance={row}
|
|
1345
|
+
grid={instance}
|
|
1346
|
+
record={record}
|
|
1347
|
+
parent={this}
|
|
1348
|
+
cursorIndex={index}
|
|
1349
|
+
selected={row.selected}
|
|
1350
|
+
isBeingDragged={dragged}
|
|
1351
|
+
isDraggedOver={mod.over}
|
|
1352
|
+
cursor={mod.cursor}
|
|
1353
|
+
cursorCellIndex={index == cursor && cursorCellIndex}
|
|
1354
|
+
cellEdit={index == cursor && cursorCellIndex != null && cellEdit}
|
|
1355
|
+
shouldUpdate={row.shouldUpdate}
|
|
1356
|
+
dimensionsVersion={dimensionsVersion}
|
|
1357
|
+
fixed={fixed}
|
|
1358
|
+
>
|
|
1359
|
+
{children.content.map(({ key, data, content }, line) => (
|
|
1360
|
+
<tr key={key} className={data.classNames} style={data.style}>
|
|
1361
|
+
{content.map(({ key, data, content, uniqueColumnId }, cellIndex) => {
|
|
1362
|
+
if (Boolean(data.fixed) !== fixed) return null;
|
|
1363
|
+
let cellected =
|
|
1364
|
+
index == cursor && cellIndex == cursorCellIndex && widget.cellEditable && line == 0;
|
|
1365
|
+
let className = cellected
|
|
1366
|
+
? CSS.expand(data.classNames, CSS.state("cellected"))
|
|
1367
|
+
: data.classNames;
|
|
1368
|
+
if (cellected && cellEdit) {
|
|
1369
|
+
let column = visibleColumns[cursorCellIndex];
|
|
1370
|
+
if (column && column.editor && data.editable)
|
|
1371
|
+
return this.renderCellEditor(key, CSS, baseClass, row, column);
|
|
1372
|
+
}
|
|
1373
|
+
let width = colWidth[uniqueColumnId];
|
|
1374
|
+
let style = data.style;
|
|
1375
|
+
if (width) {
|
|
1376
|
+
style = {
|
|
1377
|
+
...style,
|
|
1378
|
+
maxWidth: `${width}px`,
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
if (skipCells[`${line}-${cellIndex}`]) return null;
|
|
1383
|
+
|
|
1384
|
+
if (data.colSpan > 1 || data.rowSpan > 1) {
|
|
1385
|
+
for (let r = line; r < line + (data.rowSpan ?? 1); r++)
|
|
1386
|
+
for (let c = cellIndex; c < cellIndex + (data.colSpan ?? 1); c++)
|
|
1387
|
+
skipCells[`${r}-${c}`] = true;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
if (cellWrap) content = cellWrap(content);
|
|
1391
|
+
|
|
1392
|
+
return (
|
|
1393
|
+
<td
|
|
1394
|
+
key={key}
|
|
1395
|
+
className={className}
|
|
1396
|
+
style={style}
|
|
1397
|
+
colSpan={data.colSpan}
|
|
1398
|
+
rowSpan={data.rowSpan}
|
|
1399
|
+
>
|
|
1400
|
+
{content}
|
|
1401
|
+
</td>
|
|
1402
|
+
);
|
|
1403
|
+
})}
|
|
1404
|
+
</tr>
|
|
1405
|
+
))}
|
|
1406
|
+
</GridRowComponent>
|
|
1407
|
+
);
|
|
1408
|
+
};
|
|
1398
1409
|
|
|
1399
1410
|
if (!standalone) return wrap(record.vdom);
|
|
1400
1411
|
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import { batchUpdates } from
|
|
2
|
-
import { getParentFrameBoundingClientRect } from
|
|
1
|
+
import { batchUpdates } from "../../ui/batchUpdates";
|
|
2
|
+
import { getParentFrameBoundingClientRect } from "../../util/getParentFrameBoundingClientRect";
|
|
3
3
|
|
|
4
4
|
export function captureMouse2(e, { onMouseMove, onMouseUp, onDblClick, captureData, cursor }) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
surface.className = 'cxb-mousecapture';
|
|
5
|
+
let surface = document.createElement("div");
|
|
6
|
+
surface.className = "cxb-mousecapture";
|
|
8
7
|
surface.style.cursor = cursor || getComputedStyle(e.currentTarget).cursor;
|
|
9
8
|
|
|
10
9
|
document.body.appendChild(surface);
|
|
11
10
|
|
|
11
|
+
// In case when the event originates from an iframe,
|
|
12
|
+
// we use that document as events do not bubble up. //
|
|
13
|
+
let parentDocument = e.target.ownerDocument;
|
|
14
|
+
let options = { capture: true };
|
|
15
|
+
|
|
12
16
|
let active = true;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (onDblClick)
|
|
16
|
-
surface.addEventListener('dblclick', doubleClick);
|
|
17
|
+
parentDocument.addEventListener("mousemove", move, options);
|
|
18
|
+
parentDocument.addEventListener("mouseup", end, options);
|
|
19
|
+
if (onDblClick) parentDocument.addEventListener("dblclick", doubleClick), options;
|
|
17
20
|
|
|
18
21
|
function tear() {
|
|
19
22
|
if (surface == null) return;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (onDblClick)
|
|
23
|
-
surface.removeEventListener('dblclick', onDblClick);
|
|
23
|
+
parentDocument.removeEventListener("mousemove", move, options);
|
|
24
|
+
parentDocument.removeEventListener("mouseup", end, options);
|
|
25
|
+
if (onDblClick) parentDocument.removeEventListener("dblclick", onDblClick, options);
|
|
24
26
|
document.body.removeChild(surface);
|
|
25
27
|
surface = null;
|
|
26
28
|
}
|
|
@@ -45,8 +47,7 @@ export function captureMouse2(e, { onMouseMove, onMouseUp, onDblClick, captureDa
|
|
|
45
47
|
onDblClick = null;
|
|
46
48
|
|
|
47
49
|
batchUpdates(() => {
|
|
48
|
-
if (onMouseMove)
|
|
49
|
-
onMouseMove(e, captureData);
|
|
50
|
+
if (onMouseMove) onMouseMove(e, captureData);
|
|
50
51
|
e.stopPropagation();
|
|
51
52
|
e.preventDefault(); //disable text selection
|
|
52
53
|
});
|
|
@@ -58,69 +59,59 @@ export function captureMouse2(e, { onMouseMove, onMouseUp, onDblClick, captureDa
|
|
|
58
59
|
// if (surface.releaseCapture)
|
|
59
60
|
// surface.releaseCapture();
|
|
60
61
|
|
|
61
|
-
if (!onDblClick)
|
|
62
|
-
surface.style.display = "none";
|
|
62
|
+
if (!onDblClick) surface.style.display = "none";
|
|
63
63
|
try {
|
|
64
|
-
if (onMouseUp)
|
|
65
|
-
onMouseUp(e, captureData);
|
|
64
|
+
if (onMouseUp) onMouseUp(e, captureData);
|
|
66
65
|
} finally {
|
|
67
66
|
if (onDblClick) {
|
|
68
67
|
//keep the surface a little longer to detect double clicks
|
|
69
68
|
setTimeout(tear, 1500);
|
|
70
|
-
} else
|
|
71
|
-
tear();
|
|
69
|
+
} else tear();
|
|
72
70
|
}
|
|
73
71
|
});
|
|
74
72
|
}
|
|
75
73
|
}
|
|
76
74
|
|
|
77
75
|
export function captureMouseOrTouch2(e, { onMouseMove, onMouseUp, onDblClick, captureData, cursor }) {
|
|
78
|
-
|
|
79
|
-
if (e.type.indexOf('touch') == 0) {
|
|
80
|
-
|
|
76
|
+
if (e.type.indexOf("touch") == 0) {
|
|
81
77
|
let el = e.currentTarget;
|
|
82
78
|
|
|
83
|
-
let move = e => {
|
|
79
|
+
let move = (e) => {
|
|
84
80
|
batchUpdates(() => {
|
|
85
|
-
if (onMouseMove)
|
|
86
|
-
onMouseMove(e, captureData);
|
|
81
|
+
if (onMouseMove) onMouseMove(e, captureData);
|
|
87
82
|
e.preventDefault();
|
|
88
|
-
})
|
|
83
|
+
});
|
|
89
84
|
};
|
|
90
85
|
|
|
91
|
-
let end = e=> {
|
|
86
|
+
let end = (e) => {
|
|
92
87
|
batchUpdates(() => {
|
|
93
|
-
el.removeEventListener(
|
|
94
|
-
el.removeEventListener(
|
|
88
|
+
el.removeEventListener("touchmove", move);
|
|
89
|
+
el.removeEventListener("touchend", end);
|
|
95
90
|
|
|
96
|
-
if (onMouseUp)
|
|
97
|
-
onMouseUp(e);
|
|
91
|
+
if (onMouseUp) onMouseUp(e);
|
|
98
92
|
|
|
99
93
|
e.preventDefault();
|
|
100
|
-
})
|
|
94
|
+
});
|
|
101
95
|
};
|
|
102
96
|
|
|
103
|
-
el.addEventListener(
|
|
104
|
-
el.addEventListener(
|
|
97
|
+
el.addEventListener("touchmove", move);
|
|
98
|
+
el.addEventListener("touchend", end);
|
|
105
99
|
|
|
106
100
|
e.stopPropagation();
|
|
107
|
-
}
|
|
108
|
-
else
|
|
109
|
-
captureMouse2(e, { onMouseMove, onMouseUp, captureData, onDblClick, cursor });
|
|
101
|
+
} else captureMouse2(e, { onMouseMove, onMouseUp, captureData, onDblClick, cursor });
|
|
110
102
|
}
|
|
111
103
|
|
|
112
104
|
export function captureMouse(e, onMouseMove, onMouseUp, captureData, cursor) {
|
|
113
|
-
|
|
114
105
|
captureMouse2(e, {
|
|
115
106
|
onMouseMove,
|
|
116
107
|
onMouseUp,
|
|
117
108
|
captureData,
|
|
118
|
-
cursor
|
|
119
|
-
})
|
|
109
|
+
cursor,
|
|
110
|
+
});
|
|
120
111
|
}
|
|
121
112
|
|
|
122
113
|
export function captureMouseOrTouch(e, onMouseMove, onMouseUp, captureData, cursor) {
|
|
123
|
-
captureMouseOrTouch2(e, {onMouseMove, onMouseUp, captureData, cursor});
|
|
114
|
+
captureMouseOrTouch2(e, { onMouseMove, onMouseUp, captureData, cursor });
|
|
124
115
|
}
|
|
125
116
|
|
|
126
117
|
export function getCursorPos(e) {
|
|
@@ -128,6 +119,6 @@ export function getCursorPos(e) {
|
|
|
128
119
|
let offset = getParentFrameBoundingClientRect(e.target);
|
|
129
120
|
return {
|
|
130
121
|
clientX: p.clientX + offset.left,
|
|
131
|
-
clientY: p.clientY + offset.top
|
|
132
|
-
}
|
|
133
|
-
}
|
|
122
|
+
clientY: p.clientY + offset.top,
|
|
123
|
+
};
|
|
124
|
+
}
|