cx 24.4.5 → 24.4.7

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/widgets.js CHANGED
@@ -19323,7 +19323,7 @@ var DropZoneComponent = /*#__PURE__*/ (function (_VDOM$Component) {
19323
19323
  var nearDistance = widget.nearDistance;
19324
19324
  var over = rect.left <= clientX && clientX < rect.right && rect.top <= clientY && clientY < rect.bottom;
19325
19325
  return {
19326
- over: over && distance,
19326
+ over: over && Math.abs(clientX - (rect.left + rect.right) / 2) + Math.abs(clientY - (rect.top + rect.bottom) / 2),
19327
19327
  near: nearDistance && (over || distance < nearDistance),
19328
19328
  };
19329
19329
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "24.4.5",
3
+ "version": "24.4.7",
4
4
  "description": "Advanced JavaScript UI framework for admin and dashboard applications with ready to use grid, form and chart components.",
5
5
  "main": "index.js",
6
6
  "jsnext:main": "src/index.js",
@@ -1,14 +1,12 @@
1
- import { Widget, VDOM, getContent } from '../ui/Widget';
2
- import { BoundedObject } from '../svg/BoundedObject';
3
- import { Axis } from './axis/Axis';
1
+ import { Widget, VDOM, getContent } from "../ui/Widget";
2
+ import { BoundedObject } from "../svg/BoundedObject";
3
+ import { Axis } from "./axis/Axis";
4
4
 
5
5
  export class Chart extends BoundedObject {
6
-
7
6
  init() {
8
7
  super.init();
9
8
 
10
- if (!this.axes)
11
- this.axes = {};
9
+ if (!this.axes) this.axes = {};
12
10
 
13
11
  for (let axis in this.axes) {
14
12
  this.axes[axis] = Axis.create(this.axes[axis]);
@@ -16,10 +14,9 @@ export class Chart extends BoundedObject {
16
14
  }
17
15
 
18
16
  explore(context, instance) {
19
-
20
17
  instance.calculators = { ...context.axes };
21
18
 
22
- context.push('axes', instance.calculators);
19
+ context.push("axes", instance.calculators);
23
20
  instance.axes = {};
24
21
 
25
22
  //axes need to be registered before children to be processed first
@@ -35,16 +32,20 @@ export class Chart extends BoundedObject {
35
32
  }
36
33
 
37
34
  exploreCleanup(context, instance) {
38
- context.pop('axes');
35
+ context.pop("axes");
36
+
37
+ for (let axis in instance.axes) {
38
+ instance.axes[axis].widget.reportData(context, instance.axes[axis]);
39
+ }
39
40
  }
40
41
 
41
42
  prepare(context, instance) {
42
- context.push('axes', instance.calculators);
43
+ context.push("axes", instance.calculators);
43
44
  super.prepare(context, instance);
44
45
  }
45
46
 
46
47
  prepareCleanup(context, instance) {
47
- context.pop('axes');
48
+ context.pop("axes");
48
49
  super.prepareCleanup(context, instance);
49
50
  }
50
51
 
@@ -56,22 +57,19 @@ export class Chart extends BoundedObject {
56
57
 
57
58
  let result = [];
58
59
 
59
- if (!this.axesOnTop)
60
- result.push(axes);
60
+ if (!this.axesOnTop) result.push(axes);
61
61
 
62
62
  result.push(this.renderChildren(context, instance));
63
63
 
64
- if (this.axesOnTop)
65
- result.push(axes);
64
+ if (this.axesOnTop) result.push(axes);
66
65
 
67
66
  return result;
68
67
  }
69
68
  }
70
69
 
71
- Chart.prototype.anchors = '0 1 1 0';
70
+ Chart.prototype.anchors = "0 1 1 0";
72
71
  Chart.prototype.styled = true;
73
72
  Chart.prototype.isPureContainer = true;
74
73
  Chart.prototype.axesOnTop = false;
75
74
 
76
- Widget.alias('chart', Chart);
77
-
75
+ Widget.alias("chart", Chart);
@@ -48,8 +48,8 @@ interface ColumnBarBaseProps extends Cx.StyledContainerProps {
48
48
  */
49
49
  yAxis?: string;
50
50
 
51
- /** Name of the legend to be used. Default is `legend`. */
52
- legend?: string;
51
+ /** Name of the legend to be used. Default is `legend`. Set to `false` to hide the legend entry. */
52
+ legend?: string | false;
53
53
 
54
54
  legendAction?: string;
55
55
  legendShape?: string;
@@ -60,8 +60,8 @@ interface ColumnBarGraphBaseProps extends Cx.WidgetProps {
60
60
 
61
61
  colorIndexField?: boolean;
62
62
 
63
- /** Name of the legend to be used. Default is `legend`. */
64
- legend?: string;
63
+ /** Name of the legend to be used. Default is `legend`. Set to `false` to hide the legend entry. */
64
+ legend?: string | false;
65
65
 
66
66
  legendAction?: string;
67
67
  legendShape?: string;
@@ -1,148 +1,151 @@
1
- import { Widget, VDOM } from "../ui/Widget";
2
- import { HtmlElement } from "../widgets/HtmlElement";
3
- import { PureContainer } from "../ui/PureContainer";
4
- import { getShape } from "./shapes";
5
- import { isUndefined } from "../util/isUndefined";
6
- import { isArray } from "../util/isArray";
7
- import { withHoverSync } from "../ui/HoverSync";
8
-
9
- export class Legend extends HtmlElement {
10
- prepareData(context, instance) {
11
- let { data } = instance;
12
- data.stateMods = Object.assign(data.stateMods || {}, {
13
- vertical: this.vertical,
14
- });
15
- super.prepareData(context, instance);
16
- }
17
-
18
- declareData() {
19
- super.declareData(...arguments, {
20
- shape: undefined,
21
- });
22
- }
23
-
24
- isValidHtmlAttribute(attrName) {
25
- switch (attrName) {
26
- case "shapeSize":
27
- case "svgSize":
28
- return false;
29
-
30
- default:
31
- return super.isValidHtmlAttribute(attrName);
32
- }
33
- }
34
-
35
- explore(context, instance) {
36
- if (!context.legends) context.legends = {};
37
-
38
- instance.legends = context.legends;
39
-
40
- context.addLegendEntry = (legendName, entry) => {
41
- //case when all legends are scoped and new entry is added outside the scope
42
- if (!context.legends) return;
43
-
44
- let legend = context.legends[legendName];
45
- if (!legend)
46
- legend = context.legends[legendName] = {
47
- entries: [],
48
- names: {},
49
- };
50
-
51
- if (!legend.names[entry.name]) {
52
- legend.entries.push(entry);
53
- legend.names[entry.name] = entry;
54
- }
55
- };
56
-
57
- super.explore(context, instance);
58
- }
59
-
60
- renderChildren(context, instance) {
61
- const CSS = this.CSS;
62
-
63
- let entries = instance.legends[this.name] && instance.legends[this.name].entries,
64
- list;
65
-
66
- if (isArray(entries) && entries.length > 0) {
67
- list = (
68
- <div key="wrap" className={CSS.element(this.baseClass, "wrap")}>
69
- {entries.map((e, i) =>
70
- withHoverSync(i, e.hoverSync, e.hoverChannel, e.hoverId, ({ onMouseMove, onMouseLeave, hover }) => (
71
- <div
72
- key={i}
73
- className={CSS.element(this.baseClass, "entry", {
74
- "color-root": true,
75
- hover,
76
- disabled: e.disabled,
77
- selected: e.selected,
78
- })}
79
- onClick={e.onClick}
80
- onMouseMove={onMouseMove}
81
- onMouseLeave={onMouseLeave}
82
- >
83
- {this.renderShape(e, instance.data.shape)}
84
- {e.name}
85
- </div>
86
- ))
87
- )}
88
- </div>
89
- );
90
- }
91
-
92
- return [list, super.renderChildren(context, instance)];
93
- }
94
-
95
- renderShape(entry, legendEntriesShape) {
96
- const className = this.CSS.element(this.baseClass, "shape", {
97
- [`color-${entry.colorIndex}`]: entry.colorIndex != null && (isUndefined(entry.active) || entry.active),
98
- });
99
- const shape = getShape(legendEntriesShape || entry.shape || "square");
100
-
101
- return (
102
- <svg
103
- className={this.CSS.element(this.baseClass, "svg")}
104
- style={{
105
- width: `${this.svgSize}px`,
106
- height: `${this.svgSize}px`,
107
- marginTop: `${-this.svgSize / 2}px`,
108
- }}
109
- >
110
- {shape(this.svgSize / 2, this.svgSize / 2, entry.shapeSize || this.shapeSize, {
111
- style: entry.style,
112
- className: className,
113
- })}
114
- </svg>
115
- );
116
- }
117
- }
118
-
119
- Legend.prototype.name = "legend";
120
- Legend.prototype.baseClass = "legend";
121
- Legend.prototype.vertical = false;
122
- Legend.prototype.memoize = false;
123
- Legend.prototype.shapeSize = 18;
124
- Legend.prototype.shape = null;
125
- Legend.prototype.svgSize = 20;
126
-
127
- Widget.alias("legend", Legend);
128
-
129
- Legend.Scope = class extends PureContainer {
130
- explore(context, instance) {
131
- context.push("legends", (instance.legends = {}));
132
- super.explore(context, instance);
133
- }
134
-
135
- exploreCleanup(context, instance) {
136
- context.pop("legends");
137
- }
138
-
139
- prepare(context, instance) {
140
- context.push("legends", instance.legends);
141
- }
142
-
143
- prepareCleanup(context, instance) {
144
- context.pop("legends");
145
- }
146
- };
147
-
148
- export const LegendScope = Legend.Scope;
1
+ import { Widget, VDOM } from "../ui/Widget";
2
+ import { HtmlElement } from "../widgets/HtmlElement";
3
+ import { PureContainer } from "../ui/PureContainer";
4
+ import { getShape } from "./shapes";
5
+ import { isUndefined } from "../util/isUndefined";
6
+ import { isArray } from "../util/isArray";
7
+ import { withHoverSync } from "../ui/HoverSync";
8
+
9
+ export class Legend extends HtmlElement {
10
+ prepareData(context, instance) {
11
+ let { data } = instance;
12
+ data.stateMods = Object.assign(data.stateMods || {}, {
13
+ vertical: this.vertical,
14
+ });
15
+ super.prepareData(context, instance);
16
+ }
17
+
18
+ declareData() {
19
+ super.declareData(...arguments, {
20
+ shape: undefined,
21
+ });
22
+ }
23
+
24
+ isValidHtmlAttribute(attrName) {
25
+ switch (attrName) {
26
+ case "shapeSize":
27
+ case "svgSize":
28
+ case "shape":
29
+ return false;
30
+
31
+ default:
32
+ return super.isValidHtmlAttribute(attrName);
33
+ }
34
+ }
35
+
36
+ explore(context, instance) {
37
+ if (!context.legends) context.legends = {};
38
+
39
+ instance.legends = context.legends;
40
+
41
+ context.addLegendEntry = (legendName, entry) => {
42
+ if (!legendName) return;
43
+
44
+ //case when all legends are scoped and new entry is added outside the scope
45
+ if (!context.legends) return;
46
+
47
+ let legend = context.legends[legendName];
48
+ if (!legend)
49
+ legend = context.legends[legendName] = {
50
+ entries: [],
51
+ names: {},
52
+ };
53
+
54
+ if (!legend.names[entry.name]) {
55
+ legend.entries.push(entry);
56
+ legend.names[entry.name] = entry;
57
+ }
58
+ };
59
+
60
+ super.explore(context, instance);
61
+ }
62
+
63
+ renderChildren(context, instance) {
64
+ const CSS = this.CSS;
65
+
66
+ let entries = instance.legends[this.name] && instance.legends[this.name].entries,
67
+ list;
68
+
69
+ if (isArray(entries) && entries.length > 0) {
70
+ list = (
71
+ <div key="wrap" className={CSS.element(this.baseClass, "wrap")}>
72
+ {entries.map((e, i) =>
73
+ withHoverSync(i, e.hoverSync, e.hoverChannel, e.hoverId, ({ onMouseMove, onMouseLeave, hover }) => (
74
+ <div
75
+ key={i}
76
+ className={CSS.element(this.baseClass, "entry", {
77
+ "color-root": true,
78
+ hover,
79
+ disabled: e.disabled,
80
+ selected: e.selected,
81
+ })}
82
+ onClick={e.onClick}
83
+ onMouseMove={onMouseMove}
84
+ onMouseLeave={onMouseLeave}
85
+ >
86
+ {this.renderShape(e, instance.data.shape)}
87
+ {e.name}
88
+ </div>
89
+ )),
90
+ )}
91
+ </div>
92
+ );
93
+ }
94
+
95
+ return [list, super.renderChildren(context, instance)];
96
+ }
97
+
98
+ renderShape(entry, legendEntriesShape) {
99
+ const className = this.CSS.element(this.baseClass, "shape", {
100
+ [`color-${entry.colorIndex}`]: entry.colorIndex != null && (isUndefined(entry.active) || entry.active),
101
+ });
102
+ const shape = getShape(legendEntriesShape || entry.shape || "square");
103
+
104
+ return (
105
+ <svg
106
+ className={this.CSS.element(this.baseClass, "svg")}
107
+ style={{
108
+ width: `${this.svgSize}px`,
109
+ height: `${this.svgSize}px`,
110
+ marginTop: `${-this.svgSize / 2}px`,
111
+ }}
112
+ >
113
+ {shape(this.svgSize / 2, this.svgSize / 2, entry.shapeSize || this.shapeSize, {
114
+ style: entry.style,
115
+ className: className,
116
+ })}
117
+ </svg>
118
+ );
119
+ }
120
+ }
121
+
122
+ Legend.prototype.name = "legend";
123
+ Legend.prototype.baseClass = "legend";
124
+ Legend.prototype.vertical = false;
125
+ Legend.prototype.memoize = false;
126
+ Legend.prototype.shapeSize = 18;
127
+ Legend.prototype.shape = null;
128
+ Legend.prototype.svgSize = 20;
129
+
130
+ Widget.alias("legend", Legend);
131
+
132
+ Legend.Scope = class extends PureContainer {
133
+ explore(context, instance) {
134
+ context.push("legends", (instance.legends = {}));
135
+ super.explore(context, instance);
136
+ }
137
+
138
+ exploreCleanup(context, instance) {
139
+ context.pop("legends");
140
+ }
141
+
142
+ prepare(context, instance) {
143
+ context.push("legends", instance.legends);
144
+ }
145
+
146
+ prepareCleanup(context, instance) {
147
+ context.pop("legends");
148
+ }
149
+ };
150
+
151
+ export const LegendScope = Legend.Scope;
@@ -79,8 +79,8 @@ interface LineGraphProps extends Cx.WidgetProps {
79
79
  /** Name of the property which holds the y0 value. Default value is `false`, which means y0 value is not read from the data array. */
80
80
  y0Field?: string | false;
81
81
 
82
- /** Name of the legend to be used. Default is `legend`. */
83
- legend?: string;
82
+ /** Name of the legend to be used. Default is `legend`. Set to `false` to hide the legend entry. */
83
+ legend?: string | false;
84
84
 
85
85
  legendAction?: string;
86
86
  legendShape?: string;
@@ -52,8 +52,8 @@ interface ScatterGraphProps extends Cx.StyledContainerProps {
52
52
  /** Name of the property which holds the size value. Do not set if `size` is used. */
53
53
  sizeField?: string | false;
54
54
 
55
- /** Name of the legend to be used. Default is legend. */
56
- legend?: string;
55
+ /** Name of the legend to be used. Default is `legend`. Set to `false` to hide the legend entry. */
56
+ legend?: string | false;
57
57
 
58
58
  legendAction?: string;
59
59