cx 24.4.8 → 24.4.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "24.4.8",
3
+ "version": "24.4.9",
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,24 @@
1
+ import * as Cx from "../core";
2
+ import { BoundedObjectProps } from "../svg";
3
+
4
+ interface SwimlaneProps 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
+ /** Represents a swimlane size. */
12
+ size?: Cx.NumberProp;
13
+
14
+ /** Switch to vertical swimlanes. */
15
+ vertical?: boolean;
16
+
17
+ /**The laneOffset property adjusts the positioning of lane elements, enhancing their alignment and readability. */
18
+ laneOffset?: Cx.NumberProp;
19
+
20
+ /** Style object applied to the swimlanes. */
21
+ laneStyle?: StyleProp;
22
+ }
23
+
24
+ export class Swimlane extends Cx.Widget<SwimlaneProps> {}
@@ -0,0 +1,140 @@
1
+ import { BoundedObject } from "../svg/BoundedObject";
2
+ import { parseStyle } from "../util/parseStyle";
3
+ import { VDOM } from "../ui/Widget";
4
+ import { Rect } from "../svg/util/Rect";
5
+
6
+ export class Swimlane extends BoundedObject {
7
+ init() {
8
+ this.laneStyle = parseStyle(this.laneStyle);
9
+ super.init();
10
+ }
11
+
12
+ declareData(...args) {
13
+ super.declareData(...args, {
14
+ size: undefined,
15
+ laneOffset: undefined,
16
+ laneStyle: { structured: true },
17
+ vertical: undefined,
18
+ x: undefined,
19
+ y: undefined,
20
+ });
21
+ }
22
+
23
+ explore(context, instance) {
24
+ let { data } = instance;
25
+ super.explore(context, instance);
26
+ instance.xAxis = context.axes[this.xAxis];
27
+ instance.yAxis = context.axes[this.yAxis];
28
+
29
+ if (data.vertical) {
30
+ instance.xAxis.acknowledge(data.x, data.size, data.laneOffset);
31
+ } else {
32
+ instance.yAxis.acknowledge(data.y, data.size, data.laneOffset);
33
+ }
34
+ }
35
+
36
+ prepare(context, instance) {
37
+ super.prepare(context, instance);
38
+ instance.bounds = this.calculateRect(instance);
39
+ instance.cache("bounds", instance.bounds);
40
+ if (!instance.bounds.isEqual(instance.cached.bounds)) instance.markShouldUpdate(context);
41
+
42
+ context.push("parentRect", instance.bounds);
43
+ }
44
+
45
+ calculateRect(instance) {
46
+ var { data } = instance;
47
+ var { size, laneOffset } = data;
48
+
49
+ if (data.vertical) {
50
+ var x1 = instance.xAxis.map(data.x, laneOffset - size / 2);
51
+ var x2 = instance.xAxis.map(data.x, laneOffset + size / 2);
52
+ var bounds = new Rect({
53
+ l: Math.min(x1, x2),
54
+ r: Math.max(x1, x2),
55
+ t: data.bounds.t,
56
+ b: data.bounds.b,
57
+ });
58
+ } else {
59
+ var y1 = instance.yAxis.map(data.y, laneOffset - size / 2);
60
+ var y2 = instance.yAxis.map(data.y, laneOffset + size / 2);
61
+ var bounds = new Rect({
62
+ l: data.bounds.l,
63
+ r: data.bounds.r,
64
+ t: Math.min(y1, y2),
65
+ b: Math.max(y1, y2),
66
+ });
67
+ }
68
+
69
+ return bounds;
70
+ }
71
+
72
+ render(context, instance, key) {
73
+ let { data, xAxis, yAxis, bounds } = instance;
74
+ let { CSS, baseClass } = this;
75
+
76
+ let axis = this.vertical ? xAxis : yAxis;
77
+ if (!axis) return null;
78
+
79
+ let min, max, valueFunction;
80
+ if (axis.scale) {
81
+ min = axis.scale.min;
82
+ max = axis.scale.max;
83
+ let clamp = (value) => [Math.max(min, Math.min(max, value)), 0];
84
+ valueFunction = (value, offset) => clamp(value + offset);
85
+ } else if (axis.valueList) {
86
+ min = 0;
87
+ max = axis.valueList.length;
88
+ valueFunction = (value, offset) => [axis.valueList[value], offset];
89
+ }
90
+ if (!(min < max)) return null;
91
+
92
+ let rectClass = CSS.element(baseClass, "lane");
93
+
94
+ if (this.vertical) {
95
+ let c1 = axis.map(...valueFunction(data.x, -data.size / 2 + data.laneOffset));
96
+ let c2 = axis.map(...valueFunction(data.x, +data.size / 2 + data.laneOffset));
97
+ return (
98
+ <g key={key} className={data.classNames}>
99
+ <rect
100
+ key={key}
101
+ x={bounds.l}
102
+ y={bounds.t}
103
+ height={bounds.b - bounds.t}
104
+ width={Math.abs(c1 - c2)}
105
+ className={rectClass}
106
+ style={data.laneStyle}
107
+ />
108
+ {this.renderChildren(context, instance)};
109
+ </g>
110
+ );
111
+ } else {
112
+ let c1 = axis.map(...valueFunction(data.y, -data.size / 2 + data.laneOffset));
113
+ let c2 = axis.map(...valueFunction(data.y, +data.size / 2 + data.laneOffset));
114
+ return (
115
+ <g key={key} className={data.classNames}>
116
+ <rect
117
+ key={key}
118
+ x={bounds.l}
119
+ y={bounds.t}
120
+ width={bounds.r - bounds.l}
121
+ height={Math.abs(c1 - c2)}
122
+ className={rectClass}
123
+ style={data.laneStyle}
124
+ />
125
+ {this.renderChildren(context, instance)};
126
+ </g>
127
+ );
128
+ }
129
+ }
130
+ }
131
+
132
+ Swimlane.prototype.xAxis = "x";
133
+ Swimlane.prototype.yAxis = "y";
134
+ Swimlane.prototype.anchors = "0 1 1 0";
135
+ Swimlane.prototype.baseClass = "swimlane";
136
+ Swimlane.prototype.size = 0.5;
137
+ Swimlane.prototype.laneOffset = 0;
138
+ Swimlane.prototype.vertical = false;
139
+
140
+ BoundedObject.alias("swimlane", Swimlane);
@@ -0,0 +1,14 @@
1
+ @mixin cx-swimlane($name: "swimlane", $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/Swimlane")) {
13
+ @include cx-swimlane();
14
+ }
@@ -21,6 +21,7 @@ export * from "./BubbleGraph";
21
21
  export * from "./shapes";
22
22
  export * from "./MouseTracker";
23
23
  export * from "./RangeMarker";
24
+ export * from "./Swimlane";
24
25
 
25
26
  export * from "./axis/index";
26
27
  export * from "./helpers/index";
@@ -17,6 +17,7 @@ export * from "./MarkerLine";
17
17
  export * from "./Range";
18
18
  export * from "./Gridlines";
19
19
  export * from "./Swimlanes";
20
+ export * from "./Swimlane";
20
21
  export * from "./RangeMarker";
21
22
 
22
23
  export * from "./LineGraph";
@@ -16,6 +16,7 @@
16
16
  @import "MarkerLine";
17
17
  @import "Range";
18
18
  @import "RangeMarker";
19
+ @import "Swimlane";
19
20
 
20
21
  //define last for higher priority
21
22
  @import "palette";
@@ -3,6 +3,8 @@ import { Record, AccessorChain, Bind } from "../core";
3
3
  export class Binding<V = any> {
4
4
  constructor(path: string);
5
5
 
6
+ readonly path: string;
7
+
6
8
  set(state: Record, value: V): Record;
7
9
 
8
10
  delete(state: Record): Record;
@@ -3,4 +3,4 @@ import { AccessorChain } from "../core";
3
3
  export function isAccessorChain(value: any): boolean;
4
4
  export function isAccessorChain<V>(value: any): value is AccessorChain<V>;
5
5
 
6
- export function createAccessorModelProxy<M>(): AccessorChain<M>;
6
+ export function createAccessorModelProxy<M>(basePath: string = ""): AccessorChain<M>;