cx 25.5.2 → 25.6.0

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
@@ -10884,6 +10884,7 @@ MonthPicker.prototype.range = false;
10884
10884
  MonthPicker.prototype.startYear = 1980;
10885
10885
  MonthPicker.prototype.endYear = 2030;
10886
10886
  MonthPicker.prototype.bufferSize = 15;
10887
+ MonthPicker.prototype.hideQuarters = false;
10887
10888
 
10888
10889
  // Localization
10889
10890
  MonthPicker.prototype.maxValueErrorText = "Select {0:d} or before.";
@@ -10916,7 +10917,7 @@ var MonthPickerComponent = /*#__PURE__*/ (function (_VDOM$Component) {
10916
10917
  cursorQuarter: cursor.getMonth() / 3,
10917
10918
  column: "M",
10918
10919
  start: widget.startYear,
10919
- end: widget.startYear + widget.bufferSize,
10920
+ end: Math.min(widget.startYear + widget.bufferSize, widget.endYear),
10920
10921
  };
10921
10922
  _this.handleMouseDown = _this.handleMouseDown.bind(_this);
10922
10923
  _this.handleMouseUp = _this.handleMouseUp.bind(_this);
@@ -11237,13 +11238,14 @@ var MonthPickerComponent = /*#__PURE__*/ (function (_VDOM$Component) {
11237
11238
  };
11238
11239
  _proto2.render = function render() {
11239
11240
  var _this3 = this;
11240
- var _this$props$instance = this.props.instance,
11241
- data = _this$props$instance.data,
11242
- widget = _this$props$instance.widget;
11241
+ var instance = this.props.instance;
11242
+ var data = instance.data,
11243
+ widget = instance.widget;
11243
11244
  var CSS = widget.CSS,
11244
11245
  baseClass = widget.baseClass,
11245
11246
  startYear = widget.startYear,
11246
- endYear = widget.endYear;
11247
+ endYear = widget.endYear,
11248
+ hideQuarters = widget.hideQuarters;
11247
11249
  var years = [];
11248
11250
  var _this$state2 = this.state,
11249
11251
  start = _this$state2.start,
@@ -11327,23 +11329,27 @@ var MonthPickerComponent = /*#__PURE__*/ (function (_VDOM$Component) {
11327
11329
  ),
11328
11330
  );
11329
11331
  }
11330
- row.push(
11331
- /*#__PURE__*/ jsx(
11332
- "th",
11333
- {
11334
- className: CSS.state({
11335
- cursor:
11336
- showCursor && this.state.column == "Q" && y == this.state.cursorYear && q == this.state.cursorQuarter,
11337
- }),
11338
- "data-point": "Y-" + y + "-Q-" + q,
11339
- onMouseEnter: this.handleMouseEnter,
11340
- onMouseDown: this.handleMouseDown,
11341
- onMouseUp: this.handleMouseUp,
11342
- children: "Q" + (q + 1),
11343
- },
11344
- "q" + q,
11345
- ),
11346
- );
11332
+ if (!hideQuarters)
11333
+ row.push(
11334
+ /*#__PURE__*/ jsx(
11335
+ "th",
11336
+ {
11337
+ className: CSS.state({
11338
+ cursor:
11339
+ showCursor &&
11340
+ this.state.column == "Q" &&
11341
+ y == this.state.cursorYear &&
11342
+ q == this.state.cursorQuarter,
11343
+ }),
11344
+ "data-point": "Y-" + y + "-Q-" + q,
11345
+ onMouseEnter: this.handleMouseEnter,
11346
+ onMouseDown: this.handleMouseDown,
11347
+ onMouseUp: this.handleMouseUp,
11348
+ children: "Q" + (q + 1),
11349
+ },
11350
+ "q" + q,
11351
+ ),
11352
+ );
11347
11353
  rows.push(row);
11348
11354
  }
11349
11355
  years.push(rows);
@@ -12159,7 +12165,7 @@ var MonthField = /*#__PURE__*/ (function (_Field) {
12159
12165
  {
12160
12166
  data: instance.data,
12161
12167
  instance: instance,
12162
- monthPicker: {
12168
+ monthPicker: _extends({}, this.monthPickerOptions, {
12163
12169
  value: this.value,
12164
12170
  from: this.from,
12165
12171
  to: this.to,
@@ -12172,7 +12178,7 @@ var MonthField = /*#__PURE__*/ (function (_Field) {
12172
12178
  maxExclusiveErrorText: this.maxExclusiveErrorText,
12173
12179
  minValueErrorText: this.minValueErrorText,
12174
12180
  minExclusiveErrorText: this.minExclusiveErrorText,
12175
- },
12181
+ }),
12176
12182
  label: this.labelPlacement && getContent(this.renderLabel(context, instance, "label")),
12177
12183
  help: this.helpPlacement && getContent(this.renderHelp(context, instance, "help")),
12178
12184
  icon: this.renderIcon(context, instance, "icon"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "25.5.2",
3
+ "version": "25.6.0",
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",
@@ -103,7 +103,7 @@ export class LineGraph extends Widget {
103
103
  if (context.pointReducer && isArray(data.data)) {
104
104
  data.data.forEach((p, index) => {
105
105
  if (data.area && this.y0Field)
106
- context.pointReducer(p[this.xField], p[this.y0Field], data.name, p, data, index);
106
+ context.pointReducer(p[this.xField], p[this.y0Field], data.name, p, data.data, index);
107
107
  context.pointReducer(p[this.xField], p[this.yField], data.name, p, data.data, index);
108
108
  });
109
109
  }
@@ -1,46 +1,46 @@
1
- import * as Cx from "../../core";
2
- import { AxisProps } from "./Axis";
3
-
4
- interface NumericAxisProps extends AxisProps {
5
- /** Minimum value. */
6
- min?: Cx.NumberProp;
7
-
8
- /** Maximum value. */
9
- max?: Cx.NumberProp;
10
-
11
- /** Set to `true` to normalize the input range. */
12
- normalized?: Cx.BooleanProp;
13
-
14
- /** Number used to divide values before rendering axis labels. Default value is `1`. */
15
- labelDivisor?: Cx.NumberProp;
16
-
17
- /** Base CSS class to be applied to the element. Defaults to `numericaxis`. */
18
- baseClass?: string;
19
-
20
- tickDivisions?: Array<number[]>;
21
-
22
- /** A number ranged between `0-2`. `0` means that the range is aligned with the lowest ticks. Default value is `1`, which means that the range is aligned with medium ticks. Use value `2` to align with major ticks. */
23
- snapToTicks?: 0 | 1 | 2;
24
-
25
- /** Value format. Default is `n`. */
26
- format?: Cx.StringProp;
27
-
28
- /** Size of a zone reserved for labels for both lower and upper end of the axis. */
29
- deadZone?: Cx.NumberProp;
30
-
31
- /** Size of a zone reserved for labels near the upper (higher) end of the axis. */
32
- upperDeadZone?: Cx.NumberProp;
33
-
34
- /** Size of a zone reserved for labels near the lower end of the axis. */
35
- lowerDeadZone?: Cx.NumberProp;
36
-
37
- /** Specifies minimum value increment between labels. Useful when formatting is not flexible enough, i.e. set to 1 for integer axes to avoid duplicate labels. */
38
- minLabelTickSize?: number;
39
- }
40
-
41
- export class NumericAxis extends Cx.Widget<NumericAxisProps> {
42
- static XY(): {
43
- x: { type: NumericAxis };
44
- y: { type: NumericAxis; vertical: true };
45
- };
46
- }
1
+ import * as Cx from "../../core";
2
+ import { AxisProps } from "./Axis";
3
+
4
+ interface NumericAxisProps extends AxisProps {
5
+ /** Minimum value. */
6
+ min?: Cx.NumberProp;
7
+
8
+ /** Maximum value. */
9
+ max?: Cx.NumberProp;
10
+
11
+ /** Set to `true` to normalize the input range. */
12
+ normalized?: Cx.BooleanProp;
13
+
14
+ /** Number used to divide values before rendering axis labels. Default value is `1`. */
15
+ labelDivisor?: Cx.NumberProp;
16
+
17
+ /** Base CSS class to be applied to the element. Defaults to `numericaxis`. */
18
+ baseClass?: string;
19
+
20
+ tickDivisions?: Array<number[]>;
21
+
22
+ /** A number ranged between `0-2`. `0` means that the range is aligned with the lowest ticks. Default value is `1`, which means that the range is aligned with medium ticks. Use value `2` to align with major ticks. */
23
+ snapToTicks?: 0 | 1 | 2;
24
+
25
+ /** Value format. Default is `n`. */
26
+ format?: Cx.StringProp;
27
+
28
+ /** Size of a zone reserved for labels for both lower and upper end of the axis. */
29
+ deadZone?: Cx.NumberProp;
30
+
31
+ /** Size of a zone reserved for labels near the upper (higher) end of the axis. */
32
+ upperDeadZone?: Cx.NumberProp;
33
+
34
+ /** Size of a zone reserved for labels near the lower end of the axis. */
35
+ lowerDeadZone?: Cx.NumberProp;
36
+
37
+ /** Specifies minimum value increment between labels. Useful when formatting is not flexible enough, i.e. set to 1 for integer axes to avoid duplicate labels. */
38
+ minLabelTickSize?: number;
39
+ }
40
+
41
+ export class NumericAxis extends Cx.Widget<NumericAxisProps> {
42
+ static XY(): {
43
+ x: { type: NumericAxis };
44
+ y: { type: NumericAxis; vertical: true };
45
+ };
46
+ }
@@ -10,6 +10,15 @@ export interface PointReducerProps extends Cx.PureContainerProps {
10
10
 
11
11
  /** A callback function used to process accumulated information and write results. */
12
12
  onReduce?: (accumulator: Cx.Record, instance?: Instance) => void;
13
+
14
+ /** Parameters that trigger filter predicate re-creation. */
15
+ filterParams?: StructuredProp;
16
+
17
+ /** A callback function used to create a predicate for filtering points. */
18
+ onCreatePointFilter?: (
19
+ filterParams: any,
20
+ instance: Instance,
21
+ ) => (x: number, y: number, name: string, data: any, array?: any[], index?: number) => boolean;
13
22
  }
14
23
 
15
24
  export class PointReducer extends Cx.Widget<PointReducerProps> {}
@@ -1,34 +1,48 @@
1
1
  import { PureContainer } from "../../ui/PureContainer";
2
2
 
3
3
  export class PointReducer extends PureContainer {
4
+ declareData() {
5
+ super.declareData(...arguments, {
6
+ filterParams: {
7
+ structured: true,
8
+ },
9
+ });
10
+ }
11
+
12
+ prepareData(context, instance) {
13
+ super.prepareData(context, instance);
14
+
15
+ instance.resetAccumulator = () => {
16
+ let accumulator = {};
17
+ if (this.onInitAccumulator) {
18
+ instance.invoke("onInitAccumulator", accumulator, instance);
19
+ instance.accumulator = accumulator;
20
+ }
21
+ };
22
+
23
+ if (this.onCreatePointFilter)
24
+ instance.pointFilter = instance.invoke("onCreatePointFilter", instance.data.filterParams, instance);
25
+ }
26
+
4
27
  explore(context, instance) {
28
+ instance.resetAccumulator();
29
+
5
30
  let parentPointReducer = context.pointReducer;
6
31
  instance.parentPointTracker = parentPointReducer;
7
32
 
8
- if (!instance.pointReducer) {
9
- let onMap = this.onMap && instance.getCallback("onMap");
10
- let accumulator = {};
11
- instance.resetAccumulator = () => {
12
- accumulator = {};
13
- if (this.onInitAccumulator) instance.invoke("onInitAccumulator", accumulator, instance);
14
- };
15
-
16
- let pointFilter = null;
17
- if (this.onCreatePointFilter) pointFilter = instance.invoke("onCreatePointFilter", instance);
18
-
19
- instance.pointReducer = (x, y, name, data, array, index) => {
20
- if (!pointFilter || pointFilter(x, y, name, data, array, index))
21
- onMap(accumulator, x, y, name, data, array, index);
22
- if (parentPointReducer) parentPointReducer(x, y, name, data, array, index);
23
- };
24
- instance.write = () => {
25
- if (this.onReduce) instance.invoke("onReduce", accumulator, instance);
26
- };
27
- }
33
+ let pointFilter = instance.pointFilter;
34
+ let accumulator = instance.accumulator;
35
+ let onMap = this.onMap && instance.getCallback("onMap");
36
+ instance.pointReducer = (x, y, name, data, array, index) => {
37
+ if (!pointFilter || pointFilter(x, y, name, data, array, index))
38
+ onMap(accumulator, x, y, name, data, array, index);
39
+ if (parentPointReducer) parentPointReducer(x, y, name, data, array, index);
40
+ };
41
+ instance.write = () => {
42
+ if (this.onReduce) instance.invoke("onReduce", accumulator, instance);
43
+ };
28
44
 
29
- instance.resetAccumulator();
30
45
  context.push("pointReducer", instance.pointReducer);
31
-
32
46
  super.explore(context, instance);
33
47
  }
34
48
 
package/src/data/Ref.d.ts CHANGED
@@ -1,24 +1,24 @@
1
- import { View } from "./View";
2
-
3
- interface RefConfig {
4
- store: View;
5
- path: string;
6
- }
7
-
8
- export class Ref<T = any> {
9
- constructor(config: RefConfig);
10
-
11
- init(value: T): boolean;
12
-
13
- set(value: T): boolean;
14
-
15
- delete(): boolean;
16
-
17
- get(): T;
18
-
19
- toggle(): boolean;
20
-
21
- update(updateFn: (currentValue: T, ...args) => T, ...args): boolean;
22
-
23
- ref<ST = any>(path: string): Ref<ST>;
24
- }
1
+ import { View } from "./View";
2
+
3
+ interface RefConfig {
4
+ store: View;
5
+ path: string;
6
+ }
7
+
8
+ export class Ref<T = any> {
9
+ constructor(config: RefConfig);
10
+
11
+ init(value: T): boolean;
12
+
13
+ set(value: T): boolean;
14
+
15
+ delete(): boolean;
16
+
17
+ get(): T;
18
+
19
+ toggle(): boolean;
20
+
21
+ update(updateFn: (currentValue: T, ...args) => T, ...args): boolean;
22
+
23
+ ref<ST = any>(path: string): Ref<ST>;
24
+ }
@@ -1,79 +1,79 @@
1
- import assert from "assert";
2
- import { Store } from "./Store";
3
- import { Ref } from "./Ref";
4
- import { append } from "./ops/append";
5
- import { StoreRef } from "./StoreRef";
6
-
7
- const getStore = () => {
8
- return new Store({
9
- data: {
10
- a: 3,
11
- item: {
12
- firstName: "Jack",
13
- },
14
- array: [],
15
- },
16
- });
17
- };
18
-
19
- describe("Ref", () => {
20
- it("can init data", () => {
21
- let store = getStore();
22
- let b = store.ref("b", 1);
23
- assert.equal(store.get("b"), 1);
24
- });
25
-
26
- it("can set data", () => {
27
- let store = getStore();
28
- let b = store.ref("b", 1);
29
- b.set(2);
30
- assert.equal(store.get("b"), 2);
31
- });
32
-
33
- it("can delete data", () => {
34
- let store = getStore();
35
- let b = store.ref("item");
36
- b.delete();
37
- assert.equal(store.get("item"), undefined);
38
- });
39
-
40
- it("can cast itself to a ref of another type", () => {
41
- class ArrayRef extends StoreRef {
42
- append(...args) {
43
- this.update(append, ...args);
44
- }
45
- }
46
- let store = getStore();
47
- let array = store.ref("array").as(ArrayRef);
48
- array.append(1, 2, 3);
49
- assert.deepEqual(array.get(), [1, 2, 3]);
50
- });
51
-
52
- it("can extend itself in a functional way", () => {
53
- let store = getStore();
54
- let array = store.ref("array").as(({ update, set, path }) => ({
55
- append(...args) {
56
- update(path, append, ...args);
57
- },
58
-
59
- clear() {
60
- set(path, []);
61
- },
62
- }));
63
- array.append(1, 2, 3);
64
- assert.deepEqual(array.get(), [1, 2, 3]);
65
- array.clear();
66
- assert.deepEqual(array.get(), []);
67
- });
68
-
69
- it("can get subrefs", () => {
70
- let store = getStore();
71
- let person = new Ref({
72
- get: () => store.get("person"),
73
- set: (value) => store.set("person", value),
74
- });
75
- let name = person.ref("name");
76
- name.set("John");
77
- assert.equal(name.get(), "John");
78
- });
79
- });
1
+ import assert from "assert";
2
+ import { Store } from "./Store";
3
+ import { Ref } from "./Ref";
4
+ import { append } from "./ops/append";
5
+ import { StoreRef } from "./StoreRef";
6
+
7
+ const getStore = () => {
8
+ return new Store({
9
+ data: {
10
+ a: 3,
11
+ item: {
12
+ firstName: "Jack",
13
+ },
14
+ array: [],
15
+ },
16
+ });
17
+ };
18
+
19
+ describe("Ref", () => {
20
+ it("can init data", () => {
21
+ let store = getStore();
22
+ let b = store.ref("b", 1);
23
+ assert.equal(store.get("b"), 1);
24
+ });
25
+
26
+ it("can set data", () => {
27
+ let store = getStore();
28
+ let b = store.ref("b", 1);
29
+ b.set(2);
30
+ assert.equal(store.get("b"), 2);
31
+ });
32
+
33
+ it("can delete data", () => {
34
+ let store = getStore();
35
+ let b = store.ref("item");
36
+ b.delete();
37
+ assert.equal(store.get("item"), undefined);
38
+ });
39
+
40
+ it("can cast itself to a ref of another type", () => {
41
+ class ArrayRef extends StoreRef {
42
+ append(...args) {
43
+ this.update(append, ...args);
44
+ }
45
+ }
46
+ let store = getStore();
47
+ let array = store.ref("array").as(ArrayRef);
48
+ array.append(1, 2, 3);
49
+ assert.deepEqual(array.get(), [1, 2, 3]);
50
+ });
51
+
52
+ it("can extend itself in a functional way", () => {
53
+ let store = getStore();
54
+ let array = store.ref("array").as(({ update, set, path }) => ({
55
+ append(...args) {
56
+ update(path, append, ...args);
57
+ },
58
+
59
+ clear() {
60
+ set(path, []);
61
+ },
62
+ }));
63
+ array.append(1, 2, 3);
64
+ assert.deepEqual(array.get(), [1, 2, 3]);
65
+ array.clear();
66
+ assert.deepEqual(array.get(), []);
67
+ });
68
+
69
+ it("can get subrefs", () => {
70
+ let store = getStore();
71
+ let person = new Ref({
72
+ get: () => store.get("person"),
73
+ set: (value) => store.set("person", value),
74
+ });
75
+ let name = person.ref("name");
76
+ name.set("John");
77
+ assert.equal(name.get(), "John");
78
+ });
79
+ });
@@ -1,24 +1,24 @@
1
- import assert from "assert";
2
- import { Store } from "./Store";
3
- import { StoreRef } from "./StoreRef";
4
-
5
- const getStore = () => {
6
- return new Store({
7
- data: {
8
- person: {
9
- name: "Jack",
10
- },
11
- },
12
- });
13
- };
14
-
15
- describe("StoreRef", () => {
16
- it("can access child refs", () => {
17
- let store = getStore();
18
- let person = store.ref("person");
19
- let name = person.ref("name");
20
- assert.equal(name.get("person"), "Jack");
21
- name.set("John");
22
- assert.equal(name.get("person"), "John");
23
- });
24
- });
1
+ import assert from "assert";
2
+ import { Store } from "./Store";
3
+ import { StoreRef } from "./StoreRef";
4
+
5
+ const getStore = () => {
6
+ return new Store({
7
+ data: {
8
+ person: {
9
+ name: "Jack",
10
+ },
11
+ },
12
+ });
13
+ };
14
+
15
+ describe("StoreRef", () => {
16
+ it("can access child refs", () => {
17
+ let store = getStore();
18
+ let person = store.ref("person");
19
+ let name = person.ref("name");
20
+ assert.equal(name.get("person"), "Jack");
21
+ name.set("John");
22
+ assert.equal(name.get("person"), "John");
23
+ });
24
+ });
@@ -1,7 +1,7 @@
1
- export interface StructuredDataAccessor {
2
- getSelector(): (data: Cx.Record) => Cx.Record;
3
- get(): Cx.Record;
4
- setItem(key: string, value: any): boolean;
5
- containsKey(key): string;
6
- getKeys(): string[];
7
- }
1
+ export interface StructuredDataAccessor {
2
+ getSelector(): (data: Cx.Record) => Cx.Record;
3
+ get(): Cx.Record;
4
+ setItem(key: string, value: any): boolean;
5
+ containsKey(key): string;
6
+ getKeys(): string[];
7
+ }