cx 22.1.2 → 22.1.3
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 +600 -600
- package/dist/ui.js +12 -7
- package/dist/widgets.css +8 -0
- package/dist/widgets.js +116 -97
- package/package.json +1 -1
- package/src/ui/app/History.d.ts +4 -2
- package/src/ui/app/History.js +50 -51
- package/src/widgets/grid/Grid.js +103 -85
- package/src/widgets/grid/Grid.scss +9 -0
- package/src/widgets/nav/Tab.js +34 -35
package/src/widgets/grid/Grid.js
CHANGED
|
@@ -486,6 +486,100 @@ export class Grid extends Widget {
|
|
|
486
486
|
);
|
|
487
487
|
}
|
|
488
488
|
|
|
489
|
+
renderResizer(instance, hdinst, header, colIndex, forPreviousColumn) {
|
|
490
|
+
let { widget } = instance;
|
|
491
|
+
|
|
492
|
+
let { CSS, baseClass } = widget;
|
|
493
|
+
|
|
494
|
+
let hdwidget = hdinst.widget;
|
|
495
|
+
|
|
496
|
+
let resizerClassName = "col-resizer";
|
|
497
|
+
if (forPreviousColumn) resizerClassName += "-prev-col";
|
|
498
|
+
|
|
499
|
+
return (
|
|
500
|
+
<div
|
|
501
|
+
className={CSS.element(baseClass, resizerClassName)}
|
|
502
|
+
onClick={(e) => {
|
|
503
|
+
e.stopPropagation();
|
|
504
|
+
}}
|
|
505
|
+
onMouseDown={(e) => {
|
|
506
|
+
if (e.buttons != 1) return;
|
|
507
|
+
let resizeOverlayEl = document.createElement("div");
|
|
508
|
+
let headerCell = e.target.parentElement;
|
|
509
|
+
if (forPreviousColumn) headerCell = headerCell.previousSibling;
|
|
510
|
+
|
|
511
|
+
let scrollAreaEl = headerCell.parentElement.parentElement.parentElement.parentElement;
|
|
512
|
+
let gridEl = scrollAreaEl.parentElement;
|
|
513
|
+
let initialWidth = headerCell.offsetWidth;
|
|
514
|
+
let initialPosition = getCursorPos(e);
|
|
515
|
+
resizeOverlayEl.className = CSS.element(baseClass, "resize-overlay");
|
|
516
|
+
resizeOverlayEl.style.width = `${initialWidth}px`;
|
|
517
|
+
resizeOverlayEl.style.left = `${
|
|
518
|
+
headerCell.getBoundingClientRect().left - gridEl.getBoundingClientRect().left
|
|
519
|
+
}px`;
|
|
520
|
+
gridEl.appendChild(resizeOverlayEl);
|
|
521
|
+
captureMouse2(e, {
|
|
522
|
+
onMouseMove: (e) => {
|
|
523
|
+
let cursor = getCursorPos(e);
|
|
524
|
+
let width = Math.max(30, Math.round(initialWidth + cursor.clientX - initialPosition.clientX));
|
|
525
|
+
resizeOverlayEl.style.width = `${width}px`;
|
|
526
|
+
},
|
|
527
|
+
onMouseUp: (e) => {
|
|
528
|
+
if (!resizeOverlayEl) return; //dblclick
|
|
529
|
+
let width = resizeOverlayEl.offsetWidth;
|
|
530
|
+
hdinst.assignedWidth = width;
|
|
531
|
+
gridEl.removeChild(resizeOverlayEl);
|
|
532
|
+
resizeOverlayEl = null;
|
|
533
|
+
if (widget.onColumnResize) instance.invoke("onColumnResize", { width, column: hdwidget }, hdinst);
|
|
534
|
+
header.set("width", width);
|
|
535
|
+
instance.setState({
|
|
536
|
+
dimensionsVersion: instance.state.dimensionsVersion + 1,
|
|
537
|
+
colWidth: {
|
|
538
|
+
...instance.state.colWidth,
|
|
539
|
+
[hdwidget.uniqueColumnId]: width,
|
|
540
|
+
},
|
|
541
|
+
});
|
|
542
|
+
},
|
|
543
|
+
onDblClick: () => {
|
|
544
|
+
let table = gridEl.querySelector("table");
|
|
545
|
+
let parentEl = table.parentElement;
|
|
546
|
+
let tableClone = table.cloneNode(true);
|
|
547
|
+
tableClone.childNodes.forEach((tbody) => {
|
|
548
|
+
tbody.childNodes.forEach((tr) => {
|
|
549
|
+
tr.childNodes.forEach((td, index) => {
|
|
550
|
+
if (index == colIndex) {
|
|
551
|
+
td.style.maxWidth = null;
|
|
552
|
+
td.style.minWidth = null;
|
|
553
|
+
td.style.width = "auto";
|
|
554
|
+
} else {
|
|
555
|
+
td.style.display = "none";
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
});
|
|
559
|
+
});
|
|
560
|
+
tableClone.style.position = "absolute";
|
|
561
|
+
tableClone.style.visibility = "hidden";
|
|
562
|
+
tableClone.style.top = 0;
|
|
563
|
+
tableClone.style.left = 0;
|
|
564
|
+
tableClone.style.width = "auto";
|
|
565
|
+
parentEl.appendChild(tableClone);
|
|
566
|
+
let width = tableClone.offsetWidth;
|
|
567
|
+
parentEl.removeChild(tableClone);
|
|
568
|
+
header.set("width", width);
|
|
569
|
+
instance.setState({
|
|
570
|
+
dimensionsVersion: instance.state.dimensionsVersion + 1,
|
|
571
|
+
colWidth: {
|
|
572
|
+
...instance.state.colWidth,
|
|
573
|
+
[hdwidget.uniqueColumnId]: width,
|
|
574
|
+
},
|
|
575
|
+
});
|
|
576
|
+
},
|
|
577
|
+
});
|
|
578
|
+
}}
|
|
579
|
+
/>
|
|
580
|
+
);
|
|
581
|
+
}
|
|
582
|
+
|
|
489
583
|
renderHeader(context, instance, key, fixed, fixedColumns) {
|
|
490
584
|
let { data, widget, header } = instance;
|
|
491
585
|
|
|
@@ -520,7 +614,8 @@ export class Grid extends Widget {
|
|
|
520
614
|
sortIcon,
|
|
521
615
|
tool;
|
|
522
616
|
|
|
523
|
-
let resizer = null
|
|
617
|
+
let resizer = null,
|
|
618
|
+
prevColumnResizer = null;
|
|
524
619
|
|
|
525
620
|
if (header) {
|
|
526
621
|
empty[l] = false;
|
|
@@ -578,90 +673,12 @@ export class Grid extends Widget {
|
|
|
578
673
|
}
|
|
579
674
|
|
|
580
675
|
if ((hdwidget.resizable || header.data.resizable) && header.data.colSpan < 2) {
|
|
581
|
-
resizer = (
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
onMouseDown={(e) => {
|
|
588
|
-
if (e.buttons != 1) return;
|
|
589
|
-
let resizeOverlayEl = document.createElement("div");
|
|
590
|
-
let headerCell = e.target.parentElement;
|
|
591
|
-
let scrollAreaEl = headerCell.parentElement.parentElement.parentElement.parentElement;
|
|
592
|
-
let gridEl = scrollAreaEl.parentElement;
|
|
593
|
-
let initialWidth = headerCell.offsetWidth;
|
|
594
|
-
let initialPosition = getCursorPos(e);
|
|
595
|
-
resizeOverlayEl.className = CSS.element(baseClass, "resize-overlay");
|
|
596
|
-
resizeOverlayEl.style.width = `${initialWidth}px`;
|
|
597
|
-
resizeOverlayEl.style.left = `${
|
|
598
|
-
headerCell.getBoundingClientRect().left - gridEl.getBoundingClientRect().left
|
|
599
|
-
}px`;
|
|
600
|
-
gridEl.appendChild(resizeOverlayEl);
|
|
601
|
-
captureMouse2(e, {
|
|
602
|
-
onMouseMove: (e) => {
|
|
603
|
-
let cursor = getCursorPos(e);
|
|
604
|
-
let width = Math.max(
|
|
605
|
-
30,
|
|
606
|
-
Math.round(initialWidth + cursor.clientX - initialPosition.clientX)
|
|
607
|
-
);
|
|
608
|
-
resizeOverlayEl.style.width = `${width}px`;
|
|
609
|
-
},
|
|
610
|
-
onMouseUp: (e) => {
|
|
611
|
-
if (!resizeOverlayEl) return; //dblclick
|
|
612
|
-
let width = resizeOverlayEl.offsetWidth;
|
|
613
|
-
hdinst.assignedWidth = width;
|
|
614
|
-
gridEl.removeChild(resizeOverlayEl);
|
|
615
|
-
resizeOverlayEl = null;
|
|
616
|
-
if (widget.onColumnResize)
|
|
617
|
-
instance.invoke("onColumnResize", { width, column: hdwidget }, hdinst);
|
|
618
|
-
header.set("width", width);
|
|
619
|
-
instance.setState({
|
|
620
|
-
dimensionsVersion: instance.state.dimensionsVersion + 1,
|
|
621
|
-
colWidth: {
|
|
622
|
-
...instance.state.colWidth,
|
|
623
|
-
[hdwidget.uniqueColumnId]: width,
|
|
624
|
-
},
|
|
625
|
-
});
|
|
626
|
-
},
|
|
627
|
-
onDblClick: () => {
|
|
628
|
-
let table = gridEl.querySelector("table");
|
|
629
|
-
let parentEl = table.parentElement;
|
|
630
|
-
let tableClone = table.cloneNode(true);
|
|
631
|
-
tableClone.childNodes.forEach((tbody) => {
|
|
632
|
-
tbody.childNodes.forEach((tr) => {
|
|
633
|
-
tr.childNodes.forEach((td, index) => {
|
|
634
|
-
if (index == colIndex) {
|
|
635
|
-
td.style.maxWidth = null;
|
|
636
|
-
td.style.minWidth = null;
|
|
637
|
-
td.style.width = "auto";
|
|
638
|
-
} else {
|
|
639
|
-
td.style.display = "none";
|
|
640
|
-
}
|
|
641
|
-
});
|
|
642
|
-
});
|
|
643
|
-
});
|
|
644
|
-
tableClone.style.position = "absolute";
|
|
645
|
-
tableClone.style.visibility = "hidden";
|
|
646
|
-
tableClone.style.top = 0;
|
|
647
|
-
tableClone.style.left = 0;
|
|
648
|
-
tableClone.style.width = "auto";
|
|
649
|
-
parentEl.appendChild(tableClone);
|
|
650
|
-
let width = tableClone.offsetWidth;
|
|
651
|
-
parentEl.removeChild(tableClone);
|
|
652
|
-
header.set("width", width);
|
|
653
|
-
instance.setState({
|
|
654
|
-
dimensionsVersion: instance.state.dimensionsVersion + 1,
|
|
655
|
-
colWidth: {
|
|
656
|
-
...instance.state.colWidth,
|
|
657
|
-
[hdwidget.uniqueColumnId]: width,
|
|
658
|
-
},
|
|
659
|
-
});
|
|
660
|
-
},
|
|
661
|
-
});
|
|
662
|
-
}}
|
|
663
|
-
/>
|
|
664
|
-
);
|
|
676
|
+
resizer = this.renderResizer(instance, hdinst, header, colIndex);
|
|
677
|
+
if (colIndex > 0) {
|
|
678
|
+
let hdinstPrev = line.children[colIndex - 1];
|
|
679
|
+
let headerPrev = hdinstPrev.components[`header${l + 1}`];
|
|
680
|
+
prevColumnResizer = this.renderResizer(instance, hdinstPrev, headerPrev, colIndex, true);
|
|
681
|
+
}
|
|
665
682
|
}
|
|
666
683
|
}
|
|
667
684
|
|
|
@@ -687,6 +704,7 @@ export class Grid extends Widget {
|
|
|
687
704
|
{getContent(content)}
|
|
688
705
|
{sortIcon}
|
|
689
706
|
{tool}
|
|
707
|
+
{prevColumnResizer}
|
|
690
708
|
{resizer}
|
|
691
709
|
</th>
|
|
692
710
|
);
|
|
@@ -613,6 +613,15 @@
|
|
|
613
613
|
cursor: col-resize;
|
|
614
614
|
}
|
|
615
615
|
|
|
616
|
+
.#{$element}#{$name}-col-resizer-prev-col {
|
|
617
|
+
position: absolute;
|
|
618
|
+
left: 0;
|
|
619
|
+
top: 0;
|
|
620
|
+
bottom: 0;
|
|
621
|
+
width: 5px;
|
|
622
|
+
cursor: col-resize;
|
|
623
|
+
}
|
|
624
|
+
|
|
616
625
|
.#{$element}#{$name}-resize-overlay {
|
|
617
626
|
position: absolute;
|
|
618
627
|
display: block;
|
package/src/widgets/nav/Tab.js
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
import {Widget, VDOM} from
|
|
2
|
-
import {HtmlElement} from
|
|
3
|
-
import {preventFocusOnTouch} from
|
|
4
|
-
import {isUndefined} from
|
|
1
|
+
import { Widget, VDOM } from "../../ui/Widget";
|
|
2
|
+
import { HtmlElement } from "../HtmlElement";
|
|
3
|
+
import { preventFocusOnTouch } from "../../ui/FocusManager";
|
|
4
|
+
import { isUndefined } from "../../util/isUndefined";
|
|
5
5
|
|
|
6
6
|
export class Tab extends HtmlElement {
|
|
7
|
-
|
|
8
7
|
declareData() {
|
|
9
|
-
super.declareData(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
super.declareData(
|
|
9
|
+
{
|
|
10
|
+
tab: undefined,
|
|
11
|
+
value: undefined,
|
|
12
|
+
disabled: undefined,
|
|
13
|
+
text: undefined,
|
|
14
|
+
},
|
|
15
|
+
...arguments
|
|
16
|
+
);
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
prepareData(context, instance) {
|
|
18
|
-
let {data} = instance;
|
|
20
|
+
let { data } = instance;
|
|
19
21
|
data.stateMods = {
|
|
20
22
|
active: data.tab == data.value,
|
|
21
23
|
disabled: data.disabled,
|
|
22
|
-
shape: this.shape
|
|
24
|
+
shape: this.shape,
|
|
23
25
|
};
|
|
24
|
-
if (this.default && isUndefined(data.value))
|
|
25
|
-
instance.set('value', data.tab);
|
|
26
|
+
if (this.default && isUndefined(data.value)) instance.set("value", data.tab);
|
|
26
27
|
super.prepareData(context, instance);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
isValidHtmlAttribute(attrName) {
|
|
30
31
|
switch (attrName) {
|
|
31
|
-
case
|
|
32
|
-
case
|
|
33
|
-
case
|
|
34
|
-
case
|
|
35
|
-
case
|
|
32
|
+
case "value":
|
|
33
|
+
case "tab":
|
|
34
|
+
case "text":
|
|
35
|
+
case "disabled":
|
|
36
|
+
case "default":
|
|
36
37
|
return false;
|
|
37
38
|
|
|
38
39
|
default:
|
|
@@ -43,41 +44,39 @@ export class Tab extends HtmlElement {
|
|
|
43
44
|
attachProps(context, instance, props) {
|
|
44
45
|
super.attachProps(context, instance, props);
|
|
45
46
|
|
|
46
|
-
let {data} = instance;
|
|
47
|
+
let { data } = instance;
|
|
47
48
|
if (!data.disabled) {
|
|
48
|
-
props.href =
|
|
49
|
+
props.href = "#";
|
|
49
50
|
delete props.value;
|
|
50
51
|
|
|
51
|
-
props.onMouseDown = e => {
|
|
52
|
-
if (this.onMouseDown)
|
|
53
|
-
instance.invoke('onMouseDown', e, instance);
|
|
52
|
+
props.onMouseDown = (e) => {
|
|
53
|
+
if (this.onMouseDown) instance.invoke("onMouseDown", e, instance);
|
|
54
54
|
preventFocusOnTouch(e);
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
props.onClick = e => this.handleClick(e, instance);
|
|
57
|
+
props.onClick = (e) => this.handleClick(e, instance);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
handleClick(e, instance) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
if (this.onClick && instance.invoke("onClick", e, instance) === false) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
65
|
|
|
66
66
|
e.preventDefault();
|
|
67
67
|
e.stopPropagation();
|
|
68
68
|
|
|
69
|
-
let {data} = instance;
|
|
69
|
+
let { data } = instance;
|
|
70
70
|
|
|
71
|
-
if (data.disabled)
|
|
72
|
-
return;
|
|
71
|
+
if (data.disabled) return;
|
|
73
72
|
|
|
74
|
-
instance.set(
|
|
73
|
+
instance.set("value", data.tab);
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
Tab.prototype.baseClass = "tab";
|
|
79
|
-
Tab.prototype.tag =
|
|
78
|
+
Tab.prototype.tag = "a";
|
|
80
79
|
Tab.prototype.focusOnMouseDown = false;
|
|
81
80
|
Tab.prototype.default = false;
|
|
82
81
|
|
|
83
|
-
Widget.alias(
|
|
82
|
+
Widget.alias("tab", Tab);
|