cx 24.5.2 → 24.6.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/svg.js CHANGED
@@ -137,11 +137,7 @@ function _arrayLikeToArray(arr, len) {
137
137
  function _createForOfIteratorHelperLoose(o, allowArrayLike) {
138
138
  var it = (typeof Symbol !== "undefined" && o[Symbol.iterator]) || o["@@iterator"];
139
139
  if (it) return (it = it.call(o)).next.bind(it);
140
- if (
141
- Array.isArray(o) ||
142
- (it = _unsupportedIterableToArray(o)) ||
143
- (allowArrayLike && o && typeof o.length === "number")
144
- ) {
140
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike) {
145
141
  if (it) o = it;
146
142
  var i = 0;
147
143
  return function () {
package/dist/ui.js CHANGED
@@ -75,11 +75,11 @@ function _toPrimitive(t, r) {
75
75
  if ("object" != typeof t || !t) return t;
76
76
  var e = t[Symbol.toPrimitive];
77
77
  if (void 0 !== e) {
78
- var i = e.call(t, r || "default");
78
+ var i = e.call(t, r);
79
79
  if ("object" != typeof i) return i;
80
80
  throw new TypeError("@@toPrimitive must return a primitive value.");
81
81
  }
82
- return ("string" === r ? String : Number)(t);
82
+ return String(t);
83
83
  }
84
84
  function _toPropertyKey(t) {
85
85
  var i = _toPrimitive(t, "string");
@@ -95,7 +95,6 @@ function _defineProperties(target, props) {
95
95
  }
96
96
  }
97
97
  function _createClass(Constructor, protoProps, staticProps) {
98
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
99
98
  if (staticProps) _defineProperties(Constructor, staticProps);
100
99
  Object.defineProperty(Constructor, "prototype", {
101
100
  writable: false,
package/dist/widgets.js CHANGED
@@ -173,12 +173,11 @@ function _setPrototypeOf(o, p) {
173
173
  function _objectWithoutPropertiesLoose(source, excluded) {
174
174
  if (source == null) return {};
175
175
  var target = {};
176
- var sourceKeys = Object.keys(source);
177
- var key, i;
178
- for (i = 0; i < sourceKeys.length; i++) {
179
- key = sourceKeys[i];
180
- if (excluded.indexOf(key) >= 0) continue;
181
- target[key] = source[key];
176
+ for (var key in source) {
177
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
178
+ if (excluded.indexOf(key) >= 0) continue;
179
+ target[key] = source[key];
180
+ }
182
181
  }
183
182
  return target;
184
183
  }
@@ -6593,6 +6592,7 @@ var Field = /*#__PURE__*/ (function (_PureContainer) {
6593
6592
  data._readOnly = data.readOnly;
6594
6593
  data._viewMode = data.mode === "view" || data.viewMode;
6595
6594
  data._tabOnEnterKey = data.tabOnEnterKey;
6595
+ data.validationValue = this.getValidationValue(data);
6596
6596
  instance.parentDisabled = context.parentDisabled;
6597
6597
  instance.parentReadOnly = context.parentReadOnly;
6598
6598
  instance.parentViewMode = context.parentViewMode;
@@ -6688,6 +6688,9 @@ var Field = /*#__PURE__*/ (function (_PureContainer) {
6688
6688
  var data = instance.data;
6689
6689
  if (this.isEmpty(data)) return this.requiredText;
6690
6690
  };
6691
+ _proto.getValidationValue = function getValidationValue(data) {
6692
+ return data.value;
6693
+ };
6691
6694
  _proto.validate = function validate(context, instance) {
6692
6695
  var _this = this;
6693
6696
  var data = instance.data,
@@ -6699,7 +6702,7 @@ var Field = /*#__PURE__*/ (function (_PureContainer) {
6699
6702
  else if (state.validating && !empty) data.error = this.validatingText;
6700
6703
  else if (
6701
6704
  state.validationError &&
6702
- data.value === state.lastValidatedValue &&
6705
+ data.validationValue === state.lastValidatedValue &&
6703
6706
  shallowEquals(data.validationParams, state.lastValidationParams)
6704
6707
  )
6705
6708
  data.error = state.validationError;
@@ -6711,15 +6714,15 @@ var Field = /*#__PURE__*/ (function (_PureContainer) {
6711
6714
  !data.error &&
6712
6715
  this.onValidate &&
6713
6716
  (!state.previouslyValidated ||
6714
- data.value != state.lastValidatedValue ||
6717
+ data.validationValue != state.lastValidatedValue ||
6715
6718
  data.validationParams != state.lastValidationParams)
6716
6719
  ) {
6717
- var result = instance.invoke("onValidate", data.value, instance, data.validationParams);
6720
+ var result = instance.invoke("onValidate", data.validationValue, instance, data.validationParams);
6718
6721
  if (isPromise(result)) {
6719
6722
  data.error = this.validatingText;
6720
6723
  instance.setState({
6721
6724
  validating: true,
6722
- lastValidatedValue: data.value,
6725
+ lastValidatedValue: data.validationValue,
6723
6726
  previouslyValidated: true,
6724
6727
  lastValidationParams: data.validationParams,
6725
6728
  });
@@ -6728,7 +6731,8 @@ var Field = /*#__PURE__*/ (function (_PureContainer) {
6728
6731
  var data = instance.data,
6729
6732
  state = instance.state;
6730
6733
  var error =
6731
- data.value == state.lastValidatedValue && shallowEquals(data.validationParams, state.lastValidationParams)
6734
+ data.validationValue == state.lastValidatedValue &&
6735
+ shallowEquals(data.validationParams, state.lastValidationParams)
6732
6736
  ? r
6733
6737
  : _this.validatingText; //parameters changed, this will be revalidated
6734
6738
 
@@ -8685,6 +8689,11 @@ var LookupField = /*#__PURE__*/ (function (_Field) {
8685
8689
  if (this.multiple) return !isNonEmptyArray(data.values) && !isNonEmptyArray(data.records);
8686
8690
  return _Field.prototype.isEmpty.call(this, data);
8687
8691
  };
8692
+ _proto.getValidationValue = function getValidationValue(data) {
8693
+ var _data$records;
8694
+ if (this.multiple) return (_data$records = data.records) != null ? _data$records : data.values;
8695
+ return _Field.prototype.getValidationValue.call(this, data);
8696
+ };
8688
8697
  _proto.formatValue = function formatValue(context, instance) {
8689
8698
  var _this3 = this;
8690
8699
  if (!this.multiple) return _Field.prototype.formatValue.call(this, context, instance);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "24.5.2",
3
+ "version": "24.6.2",
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,112 +1,112 @@
1
- import { Widget, VDOM } from "../ui/Widget";
2
- import { ColumnBarGraphBase } from "./ColumnBarGraphBase";
3
- import { tooltipMouseMove, tooltipMouseLeave } from "../widgets/overlay/tooltip-ops";
4
- import { isArray } from "../util/isArray";
5
-
6
- export class ColumnGraph extends ColumnBarGraphBase {
7
- explore(context, instance) {
8
- super.explore(context, instance);
9
-
10
- let { data, xAxis, yAxis } = instance;
11
-
12
- if (isArray(data.data)) {
13
- data.data.forEach((p, index) => {
14
- var y0 = this.y0Field ? p[this.y0Field] : data.y0;
15
- var x = p[this.xField];
16
- var y = p[this.yField];
17
-
18
- xAxis.acknowledge(x, data.size, data.offset);
19
-
20
- if (data.autoSize) xAxis.book(x, data.stacked ? data.stack : data.name);
21
-
22
- if (data.stacked) {
23
- yAxis.stacknowledge(data.stack, x, y0);
24
- yAxis.stacknowledge(data.stack, x, y);
25
- } else {
26
- if (!this.hiddenBase) yAxis.acknowledge(y0);
27
- yAxis.acknowledge(y);
28
- }
29
-
30
- if (context.pointReducer) context.pointReducer(x, y, data.name, p, data, index);
31
- });
32
- }
33
- }
34
-
35
- renderGraph(context, instance) {
36
- var { data, xAxis, yAxis, store } = instance;
37
- if (!isArray(data.data)) return false;
38
-
39
- var isSelected = this.selection.getIsSelectedDelegate(store);
40
-
41
- return data.data.map((p, i) => {
42
- var { offset, size } = data;
43
-
44
- var y0 = this.y0Field ? p[this.y0Field] : data.y0;
45
- var x = p[this.xField];
46
- var y = p[this.yField];
47
-
48
- if (data.autoSize) {
49
- var [index, count] = instance.xAxis.locate(x, data.stacked ? data.stack : data.name);
50
- offset = (size / count) * (index - count / 2 + 0.5);
51
- size = size / count;
52
- }
53
-
54
- var x1 = xAxis.map(x, offset - size / 2);
55
- var x2 = xAxis.map(x, offset + size / 2);
56
- var y1 = data.stacked ? yAxis.stack(data.stack, x, y0) : yAxis.map(y0);
57
- var y2 = data.stacked ? yAxis.stack(data.stack, x, y) : yAxis.map(y);
58
-
59
- var color = this.colorIndexField ? p[this.colorIndexField] : data.colorIndex;
60
- var state = {
61
- selected: isSelected(p, i),
62
- selectable: !this.selection.isDummy,
63
- [`color-${color}`]: color != null,
64
- };
65
-
66
- let mmove, mleave;
67
-
68
- if (this.tooltip) {
69
- mmove = (e) =>
70
- tooltipMouseMove(e, instance, this.tooltip, {
71
- target: e.target.parent,
72
- data: {
73
- $record: p,
74
- },
75
- });
76
- mleave = (e) =>
77
- tooltipMouseLeave(e, instance, this.tooltip, {
78
- target: e.target.parent,
79
- data: {
80
- $record: p,
81
- },
82
- });
83
- }
84
-
85
- return (
86
- <rect
87
- key={i}
88
- className={this.CSS.element(this.baseClass, "column", state)}
89
- onClick={(e) => {
90
- this.handleClick(e, instance, p, i);
91
- }}
92
- x={Math.min(x1, x2)}
93
- y={Math.min(y1, y2)}
94
- width={Math.abs(x2 - x1)}
95
- height={Math.abs(y2 - y1)}
96
- style={data.style}
97
- onMouseMove={mmove}
98
- onMouseLeave={mleave}
99
- rx={data.borderRadius}
100
- />
101
- );
102
- });
103
- }
104
- }
105
-
106
- ColumnGraph.prototype.baseClass = "columngraph";
107
- ColumnGraph.prototype.y0Field = false;
108
- ColumnGraph.prototype.y0 = 0;
109
- ColumnGraph.prototype.legendShape = "column";
110
- ColumnGraph.prototype.hiddenBase = false;
111
-
112
- Widget.alias("columngraph", ColumnGraph);
1
+ import { Widget, VDOM } from "../ui/Widget";
2
+ import { ColumnBarGraphBase } from "./ColumnBarGraphBase";
3
+ import { tooltipMouseMove, tooltipMouseLeave } from "../widgets/overlay/tooltip-ops";
4
+ import { isArray } from "../util/isArray";
5
+
6
+ export class ColumnGraph extends ColumnBarGraphBase {
7
+ explore(context, instance) {
8
+ super.explore(context, instance);
9
+
10
+ let { data, xAxis, yAxis } = instance;
11
+
12
+ if (isArray(data.data)) {
13
+ data.data.forEach((p, index) => {
14
+ var y0 = this.y0Field ? p[this.y0Field] : data.y0;
15
+ var x = p[this.xField];
16
+ var y = p[this.yField];
17
+
18
+ xAxis.acknowledge(x, data.size, data.offset);
19
+
20
+ if (data.autoSize) xAxis.book(x, data.stacked ? data.stack : data.name);
21
+
22
+ if (data.stacked) {
23
+ yAxis.stacknowledge(data.stack, x, y0);
24
+ yAxis.stacknowledge(data.stack, x, y);
25
+ } else {
26
+ if (!this.hiddenBase) yAxis.acknowledge(y0);
27
+ yAxis.acknowledge(y);
28
+ }
29
+
30
+ if (context.pointReducer) context.pointReducer(x, y, data.name, p, data.data, index);
31
+ });
32
+ }
33
+ }
34
+
35
+ renderGraph(context, instance) {
36
+ var { data, xAxis, yAxis, store } = instance;
37
+ if (!isArray(data.data)) return false;
38
+
39
+ var isSelected = this.selection.getIsSelectedDelegate(store);
40
+
41
+ return data.data.map((p, i) => {
42
+ var { offset, size } = data;
43
+
44
+ var y0 = this.y0Field ? p[this.y0Field] : data.y0;
45
+ var x = p[this.xField];
46
+ var y = p[this.yField];
47
+
48
+ if (data.autoSize) {
49
+ var [index, count] = instance.xAxis.locate(x, data.stacked ? data.stack : data.name);
50
+ offset = (size / count) * (index - count / 2 + 0.5);
51
+ size = size / count;
52
+ }
53
+
54
+ var x1 = xAxis.map(x, offset - size / 2);
55
+ var x2 = xAxis.map(x, offset + size / 2);
56
+ var y1 = data.stacked ? yAxis.stack(data.stack, x, y0) : yAxis.map(y0);
57
+ var y2 = data.stacked ? yAxis.stack(data.stack, x, y) : yAxis.map(y);
58
+
59
+ var color = this.colorIndexField ? p[this.colorIndexField] : data.colorIndex;
60
+ var state = {
61
+ selected: isSelected(p, i),
62
+ selectable: !this.selection.isDummy,
63
+ [`color-${color}`]: color != null,
64
+ };
65
+
66
+ let mmove, mleave;
67
+
68
+ if (this.tooltip) {
69
+ mmove = (e) =>
70
+ tooltipMouseMove(e, instance, this.tooltip, {
71
+ target: e.target.parent,
72
+ data: {
73
+ $record: p,
74
+ },
75
+ });
76
+ mleave = (e) =>
77
+ tooltipMouseLeave(e, instance, this.tooltip, {
78
+ target: e.target.parent,
79
+ data: {
80
+ $record: p,
81
+ },
82
+ });
83
+ }
84
+
85
+ return (
86
+ <rect
87
+ key={i}
88
+ className={this.CSS.element(this.baseClass, "column", state)}
89
+ onClick={(e) => {
90
+ this.handleClick(e, instance, p, i);
91
+ }}
92
+ x={Math.min(x1, x2)}
93
+ y={Math.min(y1, y2)}
94
+ width={Math.abs(x2 - x1)}
95
+ height={Math.abs(y2 - y1)}
96
+ style={data.style}
97
+ onMouseMove={mmove}
98
+ onMouseLeave={mleave}
99
+ rx={data.borderRadius}
100
+ />
101
+ );
102
+ });
103
+ }
104
+ }
105
+
106
+ ColumnGraph.prototype.baseClass = "columngraph";
107
+ ColumnGraph.prototype.y0Field = false;
108
+ ColumnGraph.prototype.y0 = 0;
109
+ ColumnGraph.prototype.legendShape = "column";
110
+ ColumnGraph.prototype.hiddenBase = false;
111
+
112
+ Widget.alias("columngraph", ColumnGraph);
@@ -65,7 +65,7 @@ export class LineGraph extends Widget {
65
65
  context.pointReducer(x, p[this.y0Field], data.name, p, data, index);
66
66
  }
67
67
  }
68
- if (context.pointReducer) context.pointReducer(x, p[this.yField], data.name, p, data, index);
68
+ if (context.pointReducer) context.pointReducer(x, p[this.yField], data.name, p, data.data, index);
69
69
  });
70
70
  }
71
71
  }
@@ -1,24 +1,30 @@
1
- import * as Cx from "../../core";
2
- import { PointReducerProps } from "./PointReducer";
3
-
4
- interface SnapPointFinderProps extends PointReducerProps {
5
- /* Cursor X value. */
6
- cursorX?: Cx.NumberProp;
7
-
8
- /* Cursor Y value */
9
- cursorY?: Cx.NumberProp;
10
-
11
- /* A binding used to receive the x value of the nearest point.*/
12
- snapX?: Cx.Prop<any>;
13
-
14
- /* A binding used to receive the y value of the nearest point. */
15
- snapY?: Cx.Prop<any>;
16
-
17
- /* A binding used to receive the record prop */
18
- snapRecord?: Cx.Prop<Cx.Record>;
19
-
20
- /* Maximum distance between cursor and the snap point. */
21
- maxDistance?: number;
22
- }
23
-
24
- export class SnapPointFinder extends Cx.Widget<SnapPointFinderProps> {}
1
+ import * as Cx from "../../core";
2
+ import { PointReducerProps } from "./PointReducer";
3
+
4
+ interface SnapPointFinderProps extends PointReducerProps {
5
+ /* Cursor X value. */
6
+ cursorX?: Cx.NumberProp;
7
+
8
+ /* Cursor Y value */
9
+ cursorY?: Cx.NumberProp;
10
+
11
+ /* A binding used to receive the x value of the nearest point.*/
12
+ snapX?: Cx.NumberProp | Cx.StringProp;
13
+
14
+ /* A binding used to receive the y value of the nearest point. */
15
+ snapY?: Cx.NumberProp | Cx.StringProp;
16
+
17
+ /* A binding used to receive the record prop */
18
+ snapRecord?: Cx.Prop<Cx.Record>;
19
+
20
+ /* Maximum distance between cursor and the snap point. Default value is 50. Adjust accordingly for large distances, e.g. set to Infinity when using TimeAxis */
21
+ maxDistance?: number;
22
+
23
+ /* A function used to convert x values into numeric format. Commonly used with dates. */
24
+ convertX?: (value: number | string) => number;
25
+
26
+ /* A function used to convert y values into numeric format. Commonly used with dates. */
27
+ convertY?: (value: number | string) => number;
28
+ }
29
+
30
+ export class SnapPointFinder extends Cx.Widget<SnapPointFinderProps> {}
@@ -1,47 +1,49 @@
1
- import {PointReducer} from "./PointReducer";
2
-
3
- export class SnapPointFinder extends PointReducer {
4
- declareData() {
5
- return super.declareData(...arguments, {
6
- cursorX: undefined,
7
- cursorY: undefined,
8
- snapX: undefined,
9
- snapY: undefined,
10
- snapRecord: undefined,
11
- maxDistance: undefined
12
- })
13
- }
14
-
15
- onInitAccumulator(acc, {data}) {
16
- acc.cursorX = data.cursorX;
17
- acc.cursorY = data.cursorY;
18
- acc.dist = data.maxDistance > 0 ? Math.pow(data.maxDistance, 2) : Number.POSITIVE_INFINITY;
19
- acc.snapX = null;
20
- acc.snapY = null;
21
- }
22
-
23
- onMap(acc, x, y, name, p) {
24
- let d = null;
25
-
26
- if (acc.cursorX != null && x != null)
27
- d = (d || 0) + Math.pow(Math.abs(x - acc.cursorX), 2);
28
-
29
- if (acc.cursorY != null && y != null)
30
- d = (d || 0) + Math.pow(Math.abs(y - acc.cursorY), 2);
31
-
32
- if (d != null && d < acc.dist) {
33
- acc.dist = d;
34
- acc.snapX = x;
35
- acc.snapY = y;
36
- acc.snapRecord = p;
37
- }
38
- }
39
-
40
- onReduce(acc, instance) {
41
- instance.set('snapX', acc.snapX);
42
- instance.set('snapY', acc.snapY);
43
- instance.set('snapRecord', acc.snapRecord);
44
- }
45
- }
46
-
47
- SnapPointFinder.prototype.maxDistance = 50;
1
+ import { PointReducer } from "./PointReducer";
2
+
3
+ export class SnapPointFinder extends PointReducer {
4
+ declareData() {
5
+ return super.declareData(...arguments, {
6
+ cursorX: undefined,
7
+ cursorY: undefined,
8
+ snapX: undefined,
9
+ snapY: undefined,
10
+ snapRecord: undefined,
11
+ maxDistance: undefined,
12
+ });
13
+ }
14
+
15
+ onInitAccumulator(acc, { data }) {
16
+ acc.cursorX = data.cursorX;
17
+ acc.cursorY = data.cursorY;
18
+ acc.dist = data.maxDistance > 0 ? Math.pow(data.maxDistance, 2) : Number.POSITIVE_INFINITY;
19
+ acc.snapX = null;
20
+ acc.snapY = null;
21
+ }
22
+
23
+ onMap(acc, x, y, name, p) {
24
+ let d = null;
25
+ let cx = this.convertX(x);
26
+ let cy = this.convertY(y);
27
+
28
+ if (acc.cursorX != null && cx != null) d = (d || 0) + Math.pow(Math.abs(cx - acc.cursorX), 2);
29
+
30
+ if (acc.cursorY != null && cy != null) d = (d || 0) + Math.pow(Math.abs(cy - acc.cursorY), 2);
31
+
32
+ if (d != null && d < acc.dist) {
33
+ acc.dist = d;
34
+ acc.snapX = x;
35
+ acc.snapY = y;
36
+ acc.snapRecord = p;
37
+ }
38
+ }
39
+
40
+ onReduce(acc, instance) {
41
+ instance.set("snapX", acc.snapX);
42
+ instance.set("snapY", acc.snapY);
43
+ instance.set("snapRecord", acc.snapRecord);
44
+ }
45
+ }
46
+
47
+ SnapPointFinder.prototype.maxDistance = 50;
48
+ SnapPointFinder.prototype.convertX = (x) => x;
49
+ SnapPointFinder.prototype.convertY = (y) => y;
@@ -1,17 +1,16 @@
1
- import * as Cx from '../../core';
2
- import {PointReducerProps} from './PointReducer';
3
-
4
- interface ValueAtFinderProps extends PointReducerProps {
5
-
6
- /* Probe value. */
7
- at?: Cx.NumberProp,
8
-
9
- /* A binding used to receive the measured value */
10
- value?: Cx.Bind,
11
-
12
- /* A function used to convert x values into numeric format. Commonly used with dates. */
13
- convert?: (value: any) => number
14
- }
15
-
16
- /** Calculate value at a given point on the graph */
17
- export class ValueAtFinder extends Cx.Widget<ValueAtFinderProps> {}
1
+ import * as Cx from "../../core";
2
+ import { PointReducerProps } from "./PointReducer";
3
+
4
+ interface ValueAtFinderProps extends PointReducerProps {
5
+ /* X axis probe value. */
6
+ at?: Cx.NumberProp | Cx.StringProp;
7
+
8
+ /* A binding used to receive the measured y axis value */
9
+ value?: Cx.Bind | Cx.AccessorChain<number>;
10
+
11
+ /* A function used to convert x values into numeric format. Commonly used with dates. */
12
+ convert?: (value: number | string) => number;
13
+ }
14
+
15
+ /** Calculate value at a given point on the graph */
16
+ export class ValueAtFinder extends Cx.Widget<ValueAtFinderProps> {}