cx 24.3.2 → 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/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
@@ -15775,7 +15775,10 @@ var Grid = /*#__PURE__*/ (function (_Container) {
15775
15775
  var headerTBody = e.target.parentElement.parentElement.parentElement;
15776
15776
  var uniqueColId = e.currentTarget.dataset.uniqueColId;
15777
15777
  var headerCell = findFirstChild(headerTBody, function (el) {
15778
- return el.tagName == "TH" && el.dataset && el.dataset.uniqueColId == uniqueColId;
15778
+ var _el$dataset;
15779
+ return (
15780
+ el.tagName == "TH" && ((_el$dataset = el.dataset) == null ? void 0 : _el$dataset.uniqueColId) == uniqueColId
15781
+ );
15779
15782
  });
15780
15783
  var scrollAreaEl = headerTBody.parentElement.parentElement;
15781
15784
  var gridEl = scrollAreaEl.parentElement;
@@ -15868,14 +15871,13 @@ var Grid = /*#__PURE__*/ (function (_Container) {
15868
15871
  var headerRows = [];
15869
15872
  if (!header) return null;
15870
15873
  var skip = {};
15871
- var lineIndex = 0;
15872
- header.children.forEach(function (line) {
15874
+ header.children.forEach(function (line, lineIndex) {
15873
15875
  var empty = [true, true, true];
15874
15876
  var result = [[], [], []];
15875
15877
  line.children.forEach(function (hdinst, colIndex) {
15876
15878
  var hdwidget = hdinst.widget;
15877
15879
  var _loop = function _loop(l) {
15878
- var colKey = lineIndex + l + "-" + colIndex;
15880
+ var colKey = lineIndex + "-" + colIndex + "-" + l;
15879
15881
  if (skip[colKey]) return 0; // continue
15880
15882
  if (Boolean(hdinst.data.fixed) != fixedColumns) return 0; // continue
15881
15883
  var header = hdinst.components["header" + (l + 1)];
@@ -15932,7 +15934,8 @@ var Grid = /*#__PURE__*/ (function (_Container) {
15932
15934
  colSpan = header.data.colSpan;
15933
15935
  rowSpan = header.data.rowSpan;
15934
15936
  for (var r = 0; r < header.data.rowSpan; r++)
15935
- for (var c = 0; c < header.data.colSpan; c++) skip[lineIndex + l + r + "-" + (colIndex + c)] = true;
15937
+ for (var c = 0; c < header.data.colSpan; c++)
15938
+ skip[lineIndex + "-" + (colIndex + c) + "-" + (l + r)] = true;
15936
15939
  }
15937
15940
  if ((hdwidget.resizable || header.data.resizable) && header.data.colSpan < 2) {
15938
15941
  resizer = _this3.renderResizer(instance, hdinst, header, colIndex);
@@ -16000,7 +16003,6 @@ var Grid = /*#__PURE__*/ (function (_Container) {
16000
16003
  result = result.filter(function (_, i) {
16001
16004
  return !empty[i];
16002
16005
  });
16003
- lineIndex += result.length;
16004
16006
  if (result[0]) {
16005
16007
  if (fixed && !fixedColumns) {
16006
16008
  result[0].push(
@@ -16157,7 +16159,9 @@ var Grid = /*#__PURE__*/ (function (_Container) {
16157
16159
  var v,
16158
16160
  c = ci.widget,
16159
16161
  colSpan,
16160
- pad;
16162
+ pad,
16163
+ cls = "",
16164
+ style = null;
16161
16165
  if (c.caption) {
16162
16166
  if (c.caption.children)
16163
16167
  v = /*#__PURE__*/ jsx(Cx, {
@@ -16166,10 +16170,16 @@ var Grid = /*#__PURE__*/ (function (_Container) {
16166
16170
  parentInstance: instance,
16167
16171
  subscribe: true,
16168
16172
  });
16169
- 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
+ }
16170
16178
  pad = c.caption.pad;
16171
16179
  colSpan = c.caption.colSpan;
16172
16180
  empty = false;
16181
+ cls = CSS.expand(c.caption["class"](data)) || "";
16182
+ style = parseStyle$1(c.caption.style(data));
16173
16183
  if (c.caption.expand) {
16174
16184
  colSpan = 1;
16175
16185
  for (
@@ -16182,12 +16192,12 @@ var Grid = /*#__PURE__*/ (function (_Container) {
16182
16192
  colSpan++;
16183
16193
  }
16184
16194
  if (colSpan > 1) skip = colSpan - 1;
16185
- } else if (c.aggregate && c.aggregateField && c.caption !== false) {
16195
+ } else if (c.aggregate && c.aggregateAlias && c.caption !== false) {
16186
16196
  empty = false;
16187
- v = group[c.aggregateField];
16197
+ v = group[c.aggregateAlias];
16188
16198
  if (isString(ci.data.format)) v = Format.value(v, ci.data.format);
16189
16199
  }
16190
- var cls = "";
16200
+ if (cls) cls += " ";
16191
16201
  if (c.align) cls += CSS.state("aligned-" + c.align);
16192
16202
  if (pad !== false) cls += (cls ? " " : "") + CSS.state("pad");
16193
16203
  return /*#__PURE__*/ jsx(
@@ -16195,6 +16205,7 @@ var Grid = /*#__PURE__*/ (function (_Container) {
16195
16205
  {
16196
16206
  className: cls,
16197
16207
  colSpan: colSpan,
16208
+ style: style,
16198
16209
  children: v,
16199
16210
  },
16200
16211
  i,
@@ -16273,9 +16284,9 @@ var Grid = /*#__PURE__*/ (function (_Container) {
16273
16284
  colSpan++;
16274
16285
  }
16275
16286
  if (colSpan > 1) skip = colSpan - 1;
16276
- } else if (c.aggregate && c.aggregateField && c.footer !== false) {
16287
+ } else if (c.aggregate && c.aggregateAlias && c.footer !== false) {
16277
16288
  empty = false;
16278
- v = group[c.aggregateField];
16289
+ v = group[c.aggregateAlias];
16279
16290
  if (isString(ci.data.format)) v = Format.value(v, ci.data.format);
16280
16291
  }
16281
16292
  if (cls) cls += " ";
@@ -16640,7 +16651,6 @@ var GridComponent = /*#__PURE__*/ (function (_VDOM$Component) {
16640
16651
  mod["draggable"] = draggable;
16641
16652
  mod["non-draggable"] = !draggable;
16642
16653
  var wrap = function wrap(children) {
16643
- var skipCells = {};
16644
16654
  return /*#__PURE__*/ jsx(
16645
16655
  GridRowComponent,
16646
16656
  {
@@ -16690,20 +16700,6 @@ var GridComponent = /*#__PURE__*/ (function (_VDOM$Component) {
16690
16700
  maxWidth: width + "px",
16691
16701
  });
16692
16702
  }
16693
- if (skipCells[line + "-" + cellIndex]) return null;
16694
- if (data.colSpan > 1 || data.rowSpan > 1) {
16695
- for (var r = line; r < line + ((_data$rowSpan = data.rowSpan) != null ? _data$rowSpan : 1); r++) {
16696
- var _data$rowSpan;
16697
- for (
16698
- var c = cellIndex;
16699
- c < cellIndex + ((_data$colSpan = data.colSpan) != null ? _data$colSpan : 1);
16700
- c++
16701
- ) {
16702
- var _data$colSpan;
16703
- skipCells[r + "-" + c] = true;
16704
- }
16705
- }
16706
- }
16707
16703
  if (cellWrap) content = cellWrap(content);
16708
16704
  return /*#__PURE__*/ jsx(
16709
16705
  "td",
@@ -18389,7 +18385,12 @@ var GridColumnHeader = /*#__PURE__*/ (function (_Widget) {
18389
18385
  if (children) {
18390
18386
  delete this.caption.items;
18391
18387
  this.caption.children = Widget.create(children);
18392
- } 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
+ }
18393
18394
  }
18394
18395
  _Widget.prototype.init.call(this);
18395
18396
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "24.3.2",
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 {}