cx 24.3.1 → 24.3.3

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/util.js CHANGED
@@ -546,10 +546,12 @@ function findScrollableParent(sourceEl, horizontal) {
546
546
  }
547
547
 
548
548
  function getParentFrameBoundingClientRect(el) {
549
- if (el.ownerDocument != document) {
549
+ // if the ownerDocument is null, the element itself is the document
550
+ var ownerDocument = el.ownerDocument || el;
551
+ if (ownerDocument != document) {
550
552
  var frames = document.getElementsByTagName("iframe");
551
553
  for (var i = 0; i < frames.length; i++) {
552
- if (frames[i].contentDocument == el.ownerDocument) {
554
+ if (frames[i].contentDocument == ownerDocument) {
553
555
  return frames[i].getBoundingClientRect();
554
556
  }
555
557
  }
package/dist/widgets.js CHANGED
@@ -15439,7 +15439,7 @@ var Grid = /*#__PURE__*/ (function (_Container) {
15439
15439
  (c.header3 && c.header3.resizable)
15440
15440
  )
15441
15441
  row.hasResizableColumns = true;
15442
- if (c.aggregate && (c.aggregateField || isDefined(c.aggregateValue))) {
15442
+ if (c.aggregate && c.aggregateAlias && (c.aggregateField || isDefined(c.aggregateValue))) {
15443
15443
  aggregates[c.aggregateAlias] = {
15444
15444
  value: isDefined(c.aggregateValue)
15445
15445
  ? c.aggregateValue
@@ -16159,7 +16159,9 @@ var Grid = /*#__PURE__*/ (function (_Container) {
16159
16159
  var v,
16160
16160
  c = ci.widget,
16161
16161
  colSpan,
16162
- pad;
16162
+ pad,
16163
+ cls = "",
16164
+ style = null;
16163
16165
  if (c.caption) {
16164
16166
  if (c.caption.children)
16165
16167
  v = /*#__PURE__*/ jsx(Cx, {
@@ -16168,10 +16170,16 @@ var Grid = /*#__PURE__*/ (function (_Container) {
16168
16170
  parentInstance: instance,
16169
16171
  subscribe: true,
16170
16172
  });
16171
- else v = c.caption.value(data);
16173
+ else {
16174
+ v = c.caption.value(data);
16175
+ var fmt = c.caption.format(data);
16176
+ if (fmt) v = Format.value(v, fmt);
16177
+ }
16172
16178
  pad = c.caption.pad;
16173
16179
  colSpan = c.caption.colSpan;
16174
16180
  empty = false;
16181
+ cls = CSS.expand(c.caption["class"](data)) || "";
16182
+ style = parseStyle$1(c.caption.style(data));
16175
16183
  if (c.caption.expand) {
16176
16184
  colSpan = 1;
16177
16185
  for (
@@ -16184,12 +16192,12 @@ var Grid = /*#__PURE__*/ (function (_Container) {
16184
16192
  colSpan++;
16185
16193
  }
16186
16194
  if (colSpan > 1) skip = colSpan - 1;
16187
- } else if (c.aggregate && c.aggregateField && c.caption !== false) {
16195
+ } else if (c.aggregate && c.aggregateAlias && c.caption !== false) {
16188
16196
  empty = false;
16189
- v = group[c.aggregateField];
16197
+ v = group[c.aggregateAlias];
16190
16198
  if (isString(ci.data.format)) v = Format.value(v, ci.data.format);
16191
16199
  }
16192
- var cls = "";
16200
+ if (cls) cls += " ";
16193
16201
  if (c.align) cls += CSS.state("aligned-" + c.align);
16194
16202
  if (pad !== false) cls += (cls ? " " : "") + CSS.state("pad");
16195
16203
  return /*#__PURE__*/ jsx(
@@ -16197,6 +16205,7 @@ var Grid = /*#__PURE__*/ (function (_Container) {
16197
16205
  {
16198
16206
  className: cls,
16199
16207
  colSpan: colSpan,
16208
+ style: style,
16200
16209
  children: v,
16201
16210
  },
16202
16211
  i,
@@ -16275,9 +16284,9 @@ var Grid = /*#__PURE__*/ (function (_Container) {
16275
16284
  colSpan++;
16276
16285
  }
16277
16286
  if (colSpan > 1) skip = colSpan - 1;
16278
- } else if (c.aggregate && c.aggregateField && c.footer !== false) {
16287
+ } else if (c.aggregate && c.aggregateAlias && c.footer !== false) {
16279
16288
  empty = false;
16280
- v = group[c.aggregateField];
16289
+ v = group[c.aggregateAlias];
16281
16290
  if (isString(ci.data.format)) v = Format.value(v, ci.data.format);
16282
16291
  }
16283
16292
  if (cls) cls += " ";
@@ -18376,7 +18385,12 @@ var GridColumnHeader = /*#__PURE__*/ (function (_Widget) {
18376
18385
  if (children) {
18377
18386
  delete this.caption.items;
18378
18387
  this.caption.children = Widget.create(children);
18379
- } else this.caption.value = getSelector(this.caption.value);
18388
+ } else {
18389
+ this.caption.value = getSelector(this.caption.value);
18390
+ this.caption["class"] = getSelector(this.caption["class"]);
18391
+ this.caption.style = getSelector(this.caption.style);
18392
+ this.caption.format = getSelector(this.caption.format);
18393
+ }
18380
18394
  }
18381
18395
  _Widget.prototype.init.call(this);
18382
18396
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "24.3.1",
3
+ "version": "24.3.3",
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",
@@ -0,0 +1,41 @@
1
+ import * as Cx from "../core";
2
+ import { BoundedObject, BoundedObjectProps } from "../svg/BoundedObject";
3
+
4
+ interface SwimlanesProps extends BoundedObjectProps {
5
+ /**
6
+ * Name of the horizontal axis. The value should match one of the horizontal axes set
7
+ * in the `axes` configuration of the parent `Chart` component. Default value is `x`.
8
+ * Set to `false` to hide the grid lines in x direction.
9
+ */
10
+ xAxis?: string | boolean;
11
+
12
+ /**
13
+ * Name of the vertical axis. The value should match one of the vertical axes set
14
+ * in the `axes` configuration if the parent `Chart` component. Default value is `y`.
15
+ * Set to `false` to hide the grid lines in y direction.
16
+ */
17
+ yAxis?: string | boolean;
18
+
19
+ /** Base CSS class to be applied to the element. Defaults to `swimlanes`. */
20
+ baseClass?: string;
21
+
22
+ /** Represents a swimlane size. */
23
+ size?: number;
24
+
25
+ /**
26
+ * Represents a swimlane step. Define a step on which a swimlane will be rendered. (eg. step 2 will render
27
+ * every second swimlane in the chart.)
28
+ */
29
+ step?: number;
30
+
31
+ /** Switch to vertical swimlanes. */
32
+ vertical?: boolean;
33
+
34
+ /**The laneOffset property adjusts the positioning of lane elements, enhancing their alignment and readability. */
35
+ laneOffset?: number;
36
+
37
+ /** Style object applied to the swimlanes. */
38
+ laneStyle?: StyleProp;
39
+ }
40
+
41
+ export class Swimlanes extends Cx.Widget<SwimlanesProps> {}
@@ -0,0 +1,112 @@
1
+ import { BoundedObject } from "../svg/BoundedObject";
2
+ import { parseStyle } from "../util/parseStyle";
3
+ import { VDOM } from "../ui/Widget";
4
+
5
+ export class Swimlanes extends BoundedObject {
6
+ init() {
7
+ this.laneStyle = parseStyle(this.laneStyle);
8
+ super.init();
9
+ }
10
+ declareData(...args) {
11
+ super.declareData(...args, {
12
+ size: undefined,
13
+ step: undefined,
14
+ laneOffset: undefined,
15
+ laneStyle: { structured: true },
16
+ });
17
+ }
18
+
19
+ explore(context, instance) {
20
+ super.explore(context, instance);
21
+ instance.xAxis = context.axes[this.xAxis];
22
+ instance.yAxis = context.axes[this.yAxis];
23
+ }
24
+
25
+ prepare(context, instance) {
26
+ super.prepare(context, instance);
27
+ let { xAxis, yAxis } = instance;
28
+ if ((xAxis && xAxis.shouldUpdate) || (yAxis && yAxis.shouldUpdate)) instance.markShouldUpdate(context);
29
+ }
30
+
31
+ render(context, instance, key) {
32
+ let { data, xAxis, yAxis } = instance;
33
+ let { bounds } = data;
34
+ let { CSS, baseClass } = this;
35
+
36
+ let axis = this.vertical ? xAxis : yAxis;
37
+
38
+ if (!axis) return null;
39
+
40
+ let min, max, valueFunction;
41
+
42
+ if (axis.scale) {
43
+ min = axis.scale.min;
44
+ max = axis.scale.max;
45
+ let clamp = (value) => [Math.max(min, Math.min(max, value)), 0];
46
+ valueFunction = (value, offset) => clamp(value + offset);
47
+ } else if (axis.valueList) {
48
+ min = 0;
49
+ max = axis.valueList.length;
50
+ valueFunction = (value, offset) => [axis.valueList[value], offset];
51
+ }
52
+
53
+ if (!(min < max)) return null;
54
+
55
+ let rects = [];
56
+
57
+ let at = Math.ceil(min / data.step) * data.step;
58
+ let index = 0;
59
+
60
+ let rectClass = CSS.element(baseClass, "lane");
61
+
62
+ while (at - data.size / 2 < max) {
63
+ let c1 = axis.map(...valueFunction(at, -data.size / 2 + data.laneOffset));
64
+ let c2 = axis.map(...valueFunction(at, +data.size / 2 + data.laneOffset));
65
+ if (this.vertical) {
66
+ rects.push(
67
+ <rect
68
+ key={index++}
69
+ y={bounds.t}
70
+ x={Math.min(c1, c2)}
71
+ height={bounds.b - bounds.t}
72
+ width={Math.abs(c1 - c2)}
73
+ className={rectClass}
74
+ style={data.laneStyle}
75
+ />,
76
+ );
77
+ } else {
78
+ rects.push(
79
+ <rect
80
+ key={index++}
81
+ x={bounds.l}
82
+ y={Math.min(c1, c2)}
83
+ width={bounds.r - bounds.l}
84
+ height={Math.abs(c1 - c2)}
85
+ className={rectClass}
86
+ style={data.laneStyle}
87
+ />,
88
+ );
89
+ }
90
+
91
+ at += data.step;
92
+ }
93
+
94
+ return (
95
+ <g key={key} className={data.classNames}>
96
+ {rects}
97
+ </g>
98
+ );
99
+ }
100
+ }
101
+
102
+ Swimlanes.prototype.xAxis = "x";
103
+ Swimlanes.prototype.yAxis = "y";
104
+ Swimlanes.prototype.anchors = "0 1 1 0";
105
+ Swimlanes.prototype.baseClass = "swimlanes";
106
+ Swimlanes.prototype.size = 0.5;
107
+ Swimlanes.prototype.laneOffset = 0;
108
+ Swimlanes.prototype.step = 1;
109
+ Swimlanes.prototype.vertical = false;
110
+ Swimlanes.prototype.styled = true;
111
+
112
+ BoundedObject.alias("swimlanes", Swimlanes);
@@ -0,0 +1,14 @@
1
+ @mixin cx-swimlanes($name: "swimlanes", $besm: $cx-besm, $lane-color: $cx-default-swimlanes-lane-background-color) {
2
+ $block: map-get($besm, block);
3
+ $element: map-get($besm, element);
4
+ $state: map-get($besm, state);
5
+
6
+ .#{$element}#{$name}-lane {
7
+ fill: $lane-color;
8
+ stroke: none;
9
+ }
10
+ }
11
+
12
+ @if (cx-should-include("cx/charts/Swimlanes")) {
13
+ @include cx-swimlanes();
14
+ }
@@ -1,96 +1,96 @@
1
- import { Instance } from "./../../ui/Instance.d";
2
- import * as Cx from "../../core";
3
- import { BoundedObject, BoundedObjectProps } from "../../svg/BoundedObject";
4
-
5
- export interface AxisProps extends BoundedObjectProps {
6
- /** Set to `true` for vertical axes. */
7
- vertical?: boolean;
8
-
9
- /** Used as a secondary axis. Displayed at the top/right. */
10
- secondary?: boolean;
11
-
12
- /** When set to `true`, the values are displayed in descending order. */
13
- inverted?: Cx.BooleanProp;
14
-
15
- /** When set to `true`, rendering of visual elements of the axis, such as ticks and labels, is skipped, but their function is preserved. */
16
- hidden?: boolean;
17
-
18
- tickSize?: number;
19
- minTickDistance?: number;
20
- minLabelDistanceVertical?: number;
21
- minLabelDistanceHorizontal?: number;
22
-
23
- /** Distance between labels and the axis. */
24
- labelOffset?: number | string;
25
-
26
- /** Label rotation angle in degrees. */
27
- labelRotation?: Cx.Prop<number | string>;
28
-
29
- /** Label text-anchor value. Allowed values are start, end and middle. Default value is set based on the value of vertical and secondary flags. */
30
- labelAnchor?: "start" | "end" | "middle" | "auto";
31
-
32
- /** Horizontal text offset. */
33
- labelDx?: number | string;
34
-
35
- /** Vertical text offset which can be used for vertical alignment. */
36
- labelDy?: number | string;
37
-
38
- /** Set to `true` to break long labels into multiple lines. Default value is `false`. Text is split at space characters. See also `labelMaxLineLength` and `labelLineCountDyFactor`. */
39
- labelWrap?: boolean;
40
-
41
- /**
42
- * Used for vertical adjustment of multi-line labels. Default value is `auto` which means
43
- * that value is initialized based on axis configuration. Value `0` means that label will grow towards
44
- * the bottom of the screen. Value `-1` will make labels to grow towards the top of the screen.
45
- * `-0.5` will make labels vertically centered.
46
- */
47
- labelLineCountDyFactor?: number | string;
48
-
49
- /**
50
- * Used for vertical adjustment of multi-line labels. Default value is 1 which means
51
- * that labels are stacked without any space between them. Value of 1.4 will add 40% of the label height as a space between labels.
52
- */
53
- labelLineHeight?: number | string;
54
-
55
- /** If `labelWrap` is on, this number is used as a measure to split labels into multiple lines. Default value is `10`. */
56
- labelMaxLineLength?: number;
57
-
58
- /** Set to true to hide the axis labels. */
59
- hideLabels?: boolean;
60
-
61
- /** Set to true to hide the axis line. */
62
- hideLine?: boolean;
63
-
64
- /** Set to true to hide the axis ticks. */
65
- hideTicks?: boolean;
66
-
67
- /** Additional CSS style to be applied to the axis line. */
68
- lineStyle?: Cx.StyleProp;
69
-
70
- /** Additional CSS style to be applied to the axis ticks. */
71
- tickStyle?: Cx.StyleProp;
72
-
73
- /** Additional CSS style to be applied to the axis labels. */
74
- labelStyle?: Cx.StyleProp;
75
-
76
- /** Additional CSS class to be applied to the axis line. */
77
- lineClass?: Cx.ClassProp;
78
-
79
- /** Additional CSS class to be applied to the axis ticks. */
80
- tickClass?: Cx.ClassProp;
81
-
82
- /** Additional CSS class to be applied to the axis labels. */
83
- labelClass?: Cx.ClassProp;
84
-
85
- onMeasured?: (info: any, instance: Instance) => void;
86
-
87
- /** A function used to create a formatter function for axis labels. See Complex Labels example in the CxJS documentation for more info. */
88
- onCreateLabelFormatter?:
89
- | string
90
- | ((
91
- context: any,
92
- instance: Instance
93
- ) => (formattedValue: string, value: any) => { text: string; style?: any; className?: string }[]);
94
- }
95
-
96
- export class Axis extends BoundedObject {}
1
+ import { Instance } from "./../../ui/Instance.d";
2
+ import * as Cx from "../../core";
3
+ import { BoundedObject, BoundedObjectProps } from "../../svg/BoundedObject";
4
+
5
+ export interface AxisProps extends BoundedObjectProps {
6
+ /** Set to `true` for vertical axes. */
7
+ vertical?: boolean;
8
+
9
+ /** Used as a secondary axis. Displayed at the top/right. */
10
+ secondary?: boolean;
11
+
12
+ /** When set to `true`, the values are displayed in descending order. */
13
+ inverted?: Cx.BooleanProp;
14
+
15
+ /** When set to `true`, rendering of visual elements of the axis, such as ticks and labels, is skipped, but their function is preserved. */
16
+ hidden?: boolean;
17
+
18
+ tickSize?: number;
19
+ minTickDistance?: number;
20
+ minLabelDistanceVertical?: number;
21
+ minLabelDistanceHorizontal?: number;
22
+
23
+ /** Distance between labels and the axis. */
24
+ labelOffset?: number | string;
25
+
26
+ /** Label rotation angle in degrees. */
27
+ labelRotation?: Cx.Prop<number | string>;
28
+
29
+ /** Label text-anchor value. Allowed values are start, end and middle. Default value is set based on the value of vertical and secondary flags. */
30
+ labelAnchor?: "start" | "end" | "middle" | "auto";
31
+
32
+ /** Horizontal text offset. */
33
+ labelDx?: number | string;
34
+
35
+ /** Vertical text offset which can be used for vertical alignment. */
36
+ labelDy?: number | string;
37
+
38
+ /** Set to `true` to break long labels into multiple lines. Default value is `false`. Text is split at space characters. See also `labelMaxLineLength` and `labelLineCountDyFactor`. */
39
+ labelWrap?: boolean;
40
+
41
+ /**
42
+ * Used for vertical adjustment of multi-line labels. Default value is `auto` which means
43
+ * that value is initialized based on axis configuration. Value `0` means that label will grow towards
44
+ * the bottom of the screen. Value `-1` will make labels to grow towards the top of the screen.
45
+ * `-0.5` will make labels vertically centered.
46
+ */
47
+ labelLineCountDyFactor?: number | string;
48
+
49
+ /**
50
+ * Used for vertical adjustment of multi-line labels. Default value is 1 which means
51
+ * that labels are stacked without any space between them. Value of 1.4 will add 40% of the label height as a space between labels.
52
+ */
53
+ labelLineHeight?: number | string;
54
+
55
+ /** If `labelWrap` is on, this number is used as a measure to split labels into multiple lines. Default value is `10`. */
56
+ labelMaxLineLength?: number;
57
+
58
+ /** Set to true to hide the axis labels. */
59
+ hideLabels?: boolean;
60
+
61
+ /** Set to true to hide the axis line. */
62
+ hideLine?: boolean;
63
+
64
+ /** Set to true to hide the axis ticks. */
65
+ hideTicks?: boolean;
66
+
67
+ /** Additional CSS style to be applied to the axis line. */
68
+ lineStyle?: Cx.StyleProp;
69
+
70
+ /** Additional CSS style to be applied to the axis ticks. */
71
+ tickStyle?: Cx.StyleProp;
72
+
73
+ /** Additional CSS style to be applied to the axis labels. */
74
+ labelStyle?: Cx.StyleProp;
75
+
76
+ /** Additional CSS class to be applied to the axis line. */
77
+ lineClass?: Cx.ClassProp;
78
+
79
+ /** Additional CSS class to be applied to the axis ticks. */
80
+ tickClass?: Cx.ClassProp;
81
+
82
+ /** Additional CSS class to be applied to the axis labels. */
83
+ labelClass?: Cx.ClassProp;
84
+
85
+ onMeasured?: (info: any, instance: Instance) => void;
86
+
87
+ /** A function used to create a formatter function for axis labels. See Complex Labels example in the CxJS documentation for more info. */
88
+ onCreateLabelFormatter?:
89
+ | string
90
+ | ((
91
+ context: any,
92
+ instance: Instance
93
+ ) => (formattedValue: string, value: any) => { text: string; style?: any; className?: string }[]);
94
+ }
95
+
96
+ export class Axis extends BoundedObject {}