cx 24.2.0 → 24.3.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.
@@ -1,34 +1,34 @@
1
- import * as Cx from "../../core";
2
- import { FieldProps } from "./Field";
3
-
4
- interface UploadButtonProps extends FieldProps {
5
- /** Text description. */
6
- text?: Cx.StringProp;
7
-
8
- url?: Cx.StringProp;
9
-
10
- /** Base CSS class to be applied to the element. Default is 'uploadbutton'. */
11
- baseClass?: string;
12
-
13
- /** Defaults to `false`. Set to `true` to enable multiple selection. */
14
- multiple?: boolean;
15
-
16
- method?: string;
17
- uploadInProgressText?: string;
18
-
19
- /** Defaults to `false`. Set to `true` to abort uploads if the button is destroyed (unmounted). */
20
- abortOnDestroy?: boolean;
21
-
22
- /** Defines file types that are accepted for upload. */
23
- accept?: Cx.StringProp;
24
-
25
- /** Name of the icon to be put on the left side of the button. */
26
- icon?: Cx.StringProp;
27
-
28
- onUploadStarting?: ((xhr: XMLHttpRequest, instance: any, file: File, formData: FormData) => boolean) | string;
29
- onUploadComplete?: ((xhr: XMLHttpRequest, instance: any, file: File, formData: FormData) => void) | string;
30
- onUploadProgress?: ((event: ProgressEvent, instance: any, file: File, formData: FormData) => void) | string;
31
- onUploadError?: ((event: ProgressEvent, instance: any, file: File, formData: FormData) => void) | string;
32
- }
33
-
34
- export class UploadButton extends Cx.Widget<UploadButtonProps> {}
1
+ import * as Cx from "../../core";
2
+ import { FieldProps } from "./Field";
3
+
4
+ interface UploadButtonProps extends FieldProps {
5
+ /** Text description. */
6
+ text?: Cx.StringProp;
7
+
8
+ url?: Cx.StringProp;
9
+
10
+ /** Base CSS class to be applied to the element. Default is 'uploadbutton'. */
11
+ baseClass?: string;
12
+
13
+ /** Defaults to `false`. Set to `true` to enable multiple selection. */
14
+ multiple?: boolean;
15
+
16
+ method?: string;
17
+ uploadInProgressText?: string;
18
+
19
+ /** Defaults to `false`. Set to `true` to abort uploads if the button is destroyed (unmounted). */
20
+ abortOnDestroy?: boolean;
21
+
22
+ /** Defines file types that are accepted for upload. */
23
+ accept?: Cx.StringProp;
24
+
25
+ /** Name of the icon to be put on the left side of the button. */
26
+ icon?: Cx.StringProp;
27
+
28
+ onUploadStarting?: ((xhr: XMLHttpRequest, instance: any, file: File, formData: FormData) => boolean) | string;
29
+ onUploadComplete?: ((xhr: XMLHttpRequest, instance: any, file: File, formData: FormData) => void) | string;
30
+ onUploadProgress?: ((event: ProgressEvent, instance: any, file: File, formData: FormData) => void) | string;
31
+ onUploadError?: ((event: ProgressEvent, instance: any, file: File, formData: FormData) => void) | string;
32
+ }
33
+
34
+ export class UploadButton extends Cx.Widget<UploadButtonProps> {}
@@ -752,19 +752,17 @@ export class Grid extends Container {
752
752
  );
753
753
  }
754
754
 
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
- );
755
+ headerRows.push(...result.map((h, i) => <tr key={`${lineIndex}-${i}`}>{h}</tr>));
762
756
  }
763
757
  });
764
758
 
765
759
  if (headerRows.length == 0) return null;
766
760
 
767
- return headerRows;
761
+ return (
762
+ <tbody key={"h" + key} className={CSS.element(baseClass, "header")}>
763
+ {headerRows}
764
+ </tbody>
765
+ );
768
766
  }
769
767
 
770
768
  onHeaderMouseMove(e, column, columnInstance, gridInstance, headerLine) {
@@ -1,133 +1,124 @@
1
- import { batchUpdates } from '../../ui/batchUpdates';
2
- import { getParentFrameBoundingClientRect } from '../../util/getParentFrameBoundingClientRect';
3
-
4
- export function captureMouse2(e, { onMouseMove, onMouseUp, onDblClick, captureData, cursor }) {
5
-
6
- let surface = document.createElement('div');
7
- surface.className = 'cxb-mousecapture';
8
- surface.style.cursor = cursor || getComputedStyle(e.currentTarget).cursor;
9
-
10
- document.body.appendChild(surface);
11
-
12
- let active = true;
13
- surface.addEventListener('mousemove', move);
14
- surface.addEventListener('mouseup', end);
15
- if (onDblClick)
16
- surface.addEventListener('dblclick', doubleClick);
17
-
18
- function tear() {
19
- if (surface == null) return;
20
- surface.removeEventListener('mousemove', move);
21
- surface.removeEventListener('mouseup', end);
22
- if (onDblClick)
23
- surface.removeEventListener('dblclick', onDblClick);
24
- document.body.removeChild(surface);
25
- surface = null;
26
- }
27
-
28
- function doubleClick(e) {
29
- try {
30
- onDblClick(e);
31
- } finally {
32
- tear();
33
- }
34
- }
35
-
36
- e.stopPropagation();
37
-
38
- function move(e) {
39
- if (!active) {
40
- tear();
41
- return;
42
- }
43
-
44
- //if mouse moves double clicking is off
45
- onDblClick = null;
46
-
47
- batchUpdates(() => {
48
- if (onMouseMove)
49
- onMouseMove(e, captureData);
50
- e.stopPropagation();
51
- e.preventDefault(); //disable text selection
52
- });
53
- }
54
-
55
- function end(e) {
56
- active = false;
57
- batchUpdates(() => {
58
- // if (surface.releaseCapture)
59
- // surface.releaseCapture();
60
-
61
- if (!onDblClick)
62
- surface.style.display = "none";
63
- try {
64
- if (onMouseUp)
65
- onMouseUp(e, captureData);
66
- } finally {
67
- if (onDblClick) {
68
- //keep the surface a little longer to detect double clicks
69
- setTimeout(tear, 1500);
70
- } else
71
- tear();
72
- }
73
- });
74
- }
75
- }
76
-
77
- export function captureMouseOrTouch2(e, { onMouseMove, onMouseUp, onDblClick, captureData, cursor }) {
78
-
79
- if (e.type.indexOf('touch') == 0) {
80
-
81
- let el = e.currentTarget;
82
-
83
- let move = e => {
84
- batchUpdates(() => {
85
- if (onMouseMove)
86
- onMouseMove(e, captureData);
87
- e.preventDefault();
88
- })
89
- };
90
-
91
- let end = e=> {
92
- batchUpdates(() => {
93
- el.removeEventListener('touchmove', move);
94
- el.removeEventListener('touchend', end);
95
-
96
- if (onMouseUp)
97
- onMouseUp(e);
98
-
99
- e.preventDefault();
100
- })
101
- };
102
-
103
- el.addEventListener('touchmove', move);
104
- el.addEventListener('touchend', end);
105
-
106
- e.stopPropagation();
107
- }
108
- else
109
- captureMouse2(e, { onMouseMove, onMouseUp, captureData, onDblClick, cursor });
110
- }
111
-
112
- export function captureMouse(e, onMouseMove, onMouseUp, captureData, cursor) {
113
-
114
- captureMouse2(e, {
115
- onMouseMove,
116
- onMouseUp,
117
- captureData,
118
- cursor
119
- })
120
- }
121
-
122
- export function captureMouseOrTouch(e, onMouseMove, onMouseUp, captureData, cursor) {
123
- captureMouseOrTouch2(e, {onMouseMove, onMouseUp, captureData, cursor});
124
- }
125
-
126
- export function getCursorPos(e) {
127
- let p = (e.touches && e.touches[0]) || e;
128
- let offset = getParentFrameBoundingClientRect(e.target);
129
- return {
130
- clientX: p.clientX + offset.left,
131
- clientY: p.clientY + offset.top
132
- }
133
- }
1
+ import { batchUpdates } from "../../ui/batchUpdates";
2
+ import { getParentFrameBoundingClientRect } from "../../util/getParentFrameBoundingClientRect";
3
+
4
+ export function captureMouse2(e, { onMouseMove, onMouseUp, onDblClick, captureData, cursor }) {
5
+ let surface = document.createElement("div");
6
+ surface.className = "cxb-mousecapture";
7
+ surface.style.cursor = cursor || getComputedStyle(e.currentTarget).cursor;
8
+
9
+ document.body.appendChild(surface);
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
+
16
+ let active = true;
17
+ parentDocument.addEventListener("mousemove", move, options);
18
+ parentDocument.addEventListener("mouseup", end, options);
19
+ if (onDblClick) parentDocument.addEventListener("dblclick", doubleClick), options;
20
+
21
+ function tear() {
22
+ if (surface == null) return;
23
+ parentDocument.removeEventListener("mousemove", move, options);
24
+ parentDocument.removeEventListener("mouseup", end, options);
25
+ if (onDblClick) parentDocument.removeEventListener("dblclick", onDblClick, options);
26
+ document.body.removeChild(surface);
27
+ surface = null;
28
+ }
29
+
30
+ function doubleClick(e) {
31
+ try {
32
+ onDblClick(e);
33
+ } finally {
34
+ tear();
35
+ }
36
+ }
37
+
38
+ e.stopPropagation();
39
+
40
+ function move(e) {
41
+ if (!active) {
42
+ tear();
43
+ return;
44
+ }
45
+
46
+ //if mouse moves double clicking is off
47
+ onDblClick = null;
48
+
49
+ batchUpdates(() => {
50
+ if (onMouseMove) onMouseMove(e, captureData);
51
+ e.stopPropagation();
52
+ e.preventDefault(); //disable text selection
53
+ });
54
+ }
55
+
56
+ function end(e) {
57
+ active = false;
58
+ batchUpdates(() => {
59
+ // if (surface.releaseCapture)
60
+ // surface.releaseCapture();
61
+
62
+ if (!onDblClick) surface.style.display = "none";
63
+ try {
64
+ if (onMouseUp) onMouseUp(e, captureData);
65
+ } finally {
66
+ if (onDblClick) {
67
+ //keep the surface a little longer to detect double clicks
68
+ setTimeout(tear, 1500);
69
+ } else tear();
70
+ }
71
+ });
72
+ }
73
+ }
74
+
75
+ export function captureMouseOrTouch2(e, { onMouseMove, onMouseUp, onDblClick, captureData, cursor }) {
76
+ if (e.type.indexOf("touch") == 0) {
77
+ let el = e.currentTarget;
78
+
79
+ let move = (e) => {
80
+ batchUpdates(() => {
81
+ if (onMouseMove) onMouseMove(e, captureData);
82
+ e.preventDefault();
83
+ });
84
+ };
85
+
86
+ let end = (e) => {
87
+ batchUpdates(() => {
88
+ el.removeEventListener("touchmove", move);
89
+ el.removeEventListener("touchend", end);
90
+
91
+ if (onMouseUp) onMouseUp(e);
92
+
93
+ e.preventDefault();
94
+ });
95
+ };
96
+
97
+ el.addEventListener("touchmove", move);
98
+ el.addEventListener("touchend", end);
99
+
100
+ e.stopPropagation();
101
+ } else captureMouse2(e, { onMouseMove, onMouseUp, captureData, onDblClick, cursor });
102
+ }
103
+
104
+ export function captureMouse(e, onMouseMove, onMouseUp, captureData, cursor) {
105
+ captureMouse2(e, {
106
+ onMouseMove,
107
+ onMouseUp,
108
+ captureData,
109
+ cursor,
110
+ });
111
+ }
112
+
113
+ export function captureMouseOrTouch(e, onMouseMove, onMouseUp, captureData, cursor) {
114
+ captureMouseOrTouch2(e, { onMouseMove, onMouseUp, captureData, cursor });
115
+ }
116
+
117
+ export function getCursorPos(e) {
118
+ let p = (e.touches && e.touches[0]) || e;
119
+ let offset = getParentFrameBoundingClientRect(e.target);
120
+ return {
121
+ clientX: p.clientX + offset.left,
122
+ clientY: p.clientY + offset.top,
123
+ };
124
+ }