cx 24.7.1 → 24.7.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/ui.js CHANGED
@@ -3958,15 +3958,15 @@ function startAppLoop(parentDOMElement, storeOrInstance, widget, options) {
3958
3958
  return function () {
3959
3959
  if (stopped) return;
3960
3960
  stopped = true;
3961
- if (!options.destroyDelay) destroy(parentDOMElement, options);
3961
+ if (!options.destroyDelay) destroy(parentDOMElement, options, root);
3962
3962
  else {
3963
3963
  setTimeout(function () {
3964
- destroy(parentDOMElement, options);
3964
+ destroy(parentDOMElement, options, root);
3965
3965
  }, options.destroyDelay);
3966
3966
  }
3967
3967
  };
3968
3968
  }
3969
- function destroy(parentDOMElement, options) {
3969
+ function destroy(parentDOMElement, options, root) {
3970
3970
  if (root) root.unmount();
3971
3971
  else VDOM.DOM.unmountComponentAtNode(parentDOMElement);
3972
3972
  if (options.removeParentDOMElement && parentDOMElement.parentNode)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "24.7.1",
3
+ "version": "24.7.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,151 +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
- 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;
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;
@@ -1,96 +1,96 @@
1
- import * as Cx from "../core";
2
- import { BoundedObject, BoundedObjectProps } from "../svg/BoundedObject";
3
-
4
- interface MarkerProps extends BoundedObjectProps {
5
- /** The `x` value binding or expression. */
6
- x?: Cx.Prop<string | number>;
7
-
8
- /** The `y` value binding or expression. */
9
- y?: Cx.Prop<string | number>;
10
-
11
- /** Used to indicate if the data should affect axis span. */
12
- affectsAxes?: Cx.BooleanProp;
13
-
14
- /** Shape kind. `circle`, `square`, `triangle`, etc. */
15
- shape?: Cx.StringProp;
16
-
17
- disabled?: Cx.BooleanProp;
18
-
19
- /** Index of a color from the standard palette of colors. 0-15. */
20
- colorIndex?: Cx.Prop<string | number>;
21
-
22
- /** Used to automatically assign a color based on the `name` and the contextual `ColorMap` widget. */
23
- colorMap?: Cx.StringProp;
24
-
25
- /** Name used to resolve the color. If not provided, `name` is used instead. */
26
- colorName?: Cx.StringProp;
27
-
28
- legendColorIndex?: Cx.NumberProp;
29
-
30
- /** Name of the item as it will appear in the legend. */
31
- name?: Cx.StringProp;
32
-
33
- /** Used to indicate if an item is active or not. Inactive items are shown only in the legend. */
34
- active?: Cx.BooleanProp;
35
-
36
- xOffset?: number;
37
- yOffset?: number;
38
-
39
- /** Size of the shape in pixels. */
40
- size?: Cx.NumberProp;
41
-
42
- /**
43
- * Name of the horizontal axis. The value should match one of the horizontal axes set
44
- * in the `axes` configuration of the parent `Chart` component. Default value is `x`.
45
- */
46
- xAxis?: string;
47
-
48
- /**
49
- * Name of the vertical axis. The value should match one of the vertical axes set
50
- * in the `axes` configuration if the parent `Chart` component. Default value is `y`.
51
- */
52
- yAxis?: string;
53
-
54
- /** Base CSS class to be applied to the element. Defaults to `marker`. */
55
- baseClass?: string;
56
-
57
- /** Set to `true` to make the shape draggable along the X axis. */
58
- draggableX?: boolean;
59
-
60
- /** Set to `true` to make the shape draggable along the Y axis. */
61
- draggableY?: boolean;
62
-
63
- /** Set to `true` to make the shape draggable along the X and Y axis. */
64
- draggable?: boolean;
65
-
66
- /** Constrain the marker position to min/max values of the X axis during drag operations. */
67
- constrainX?: boolean;
68
-
69
- /** Constrain the marker position to min/max values of the Y axis during drag operations. */
70
- constrainY?: boolean;
71
-
72
- /** When set to `true`, it is equivalent to setting `constrainX` and `constrainY` to true. */
73
- constrain?: boolean;
74
-
75
- /** Name of the legend to be used. Default is `legend`. */
76
- legend?: string;
77
-
78
- legendAction?: string;
79
-
80
- /** Tooltip configuration. For more info see Tooltips. */
81
- tooltip?: Cx.StringProp | Cx.StructuredProp;
82
-
83
- /** Set to true to hide the marker. The marker will still participate in axis range calculations. */
84
- hidden?: boolean;
85
-
86
- /** Indicate that markers should be stacked horizontally. Default value is `false`. */
87
- stackedX?: Cx.BooleanProp;
88
-
89
- /** Indicate that markers should be stacked vertically. Default value is `false`. */
90
- stackedY?: Cx.BooleanProp;
91
-
92
- /** Name of the stack. If multiple stacks are used, each should have a unique name. Default value is `stack`. */
93
- stack?: Cx.StringProp;
94
- }
95
-
96
- export class Marker extends Cx.Widget<MarkerProps> {}
1
+ import * as Cx from "../core";
2
+ import { BoundedObject, BoundedObjectProps } from "../svg/BoundedObject";
3
+
4
+ interface MarkerProps extends BoundedObjectProps {
5
+ /** The `x` value binding or expression. */
6
+ x?: Cx.Prop<string | number>;
7
+
8
+ /** The `y` value binding or expression. */
9
+ y?: Cx.Prop<string | number>;
10
+
11
+ /** Used to indicate if the data should affect axis span. */
12
+ affectsAxes?: Cx.BooleanProp;
13
+
14
+ /** Shape kind. `circle`, `square`, `triangle`, etc. */
15
+ shape?: Cx.StringProp;
16
+
17
+ disabled?: Cx.BooleanProp;
18
+
19
+ /** Index of a color from the standard palette of colors. 0-15. */
20
+ colorIndex?: Cx.Prop<string | number>;
21
+
22
+ /** Used to automatically assign a color based on the `name` and the contextual `ColorMap` widget. */
23
+ colorMap?: Cx.StringProp;
24
+
25
+ /** Name used to resolve the color. If not provided, `name` is used instead. */
26
+ colorName?: Cx.StringProp;
27
+
28
+ legendColorIndex?: Cx.NumberProp;
29
+
30
+ /** Name of the item as it will appear in the legend. */
31
+ name?: Cx.StringProp;
32
+
33
+ /** Used to indicate if an item is active or not. Inactive items are shown only in the legend. */
34
+ active?: Cx.BooleanProp;
35
+
36
+ xOffset?: number;
37
+ yOffset?: number;
38
+
39
+ /** Size of the shape in pixels. */
40
+ size?: Cx.NumberProp;
41
+
42
+ /**
43
+ * Name of the horizontal axis. The value should match one of the horizontal axes set
44
+ * in the `axes` configuration of the parent `Chart` component. Default value is `x`.
45
+ */
46
+ xAxis?: string;
47
+
48
+ /**
49
+ * Name of the vertical axis. The value should match one of the vertical axes set
50
+ * in the `axes` configuration if the parent `Chart` component. Default value is `y`.
51
+ */
52
+ yAxis?: string;
53
+
54
+ /** Base CSS class to be applied to the element. Defaults to `marker`. */
55
+ baseClass?: string;
56
+
57
+ /** Set to `true` to make the shape draggable along the X axis. */
58
+ draggableX?: boolean;
59
+
60
+ /** Set to `true` to make the shape draggable along the Y axis. */
61
+ draggableY?: boolean;
62
+
63
+ /** Set to `true` to make the shape draggable along the X and Y axis. */
64
+ draggable?: boolean;
65
+
66
+ /** Constrain the marker position to min/max values of the X axis during drag operations. */
67
+ constrainX?: boolean;
68
+
69
+ /** Constrain the marker position to min/max values of the Y axis during drag operations. */
70
+ constrainY?: boolean;
71
+
72
+ /** When set to `true`, it is equivalent to setting `constrainX` and `constrainY` to true. */
73
+ constrain?: boolean;
74
+
75
+ /** Name of the legend to be used. Default is `legend`. */
76
+ legend?: string;
77
+
78
+ legendAction?: string;
79
+
80
+ /** Tooltip configuration. For more info see Tooltips. */
81
+ tooltip?: Cx.StringProp | Cx.StructuredProp;
82
+
83
+ /** Set to true to hide the marker. The marker will still participate in axis range calculations. */
84
+ hidden?: boolean;
85
+
86
+ /** Indicate that markers should be stacked horizontally. Default value is `false`. */
87
+ stackedX?: Cx.BooleanProp;
88
+
89
+ /** Indicate that markers should be stacked vertically. Default value is `false`. */
90
+ stackedY?: Cx.BooleanProp;
91
+
92
+ /** Name of the stack. If multiple stacks are used, each should have a unique name. Default value is `stack`. */
93
+ stack?: Cx.StringProp;
94
+ }
95
+
96
+ export class Marker extends Cx.Widget<MarkerProps> {}