cx 23.4.3 → 23.4.4
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/charts.css +649 -0
- package/dist/charts.js +4811 -0
- package/dist/data.js +2109 -0
- package/dist/hooks.js +146 -0
- package/dist/manifest.js +1373 -0
- package/dist/reset.css +89 -0
- package/dist/svg.css +19 -0
- package/dist/svg.js +807 -0
- package/dist/ui.js +4456 -0
- package/dist/util.js +1538 -0
- package/dist/widgets.css +5242 -0
- package/dist/widgets.js +19417 -0
- package/package.json +1 -1
package/dist/svg.js
ADDED
|
@@ -0,0 +1,807 @@
|
|
|
1
|
+
import { isNumber, isArray, innerTextTrim, addEventListenerWithOptions } from "cx/util";
|
|
2
|
+
import { PureContainer, Widget, ResizeManager, VDOM } from "cx/ui";
|
|
3
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
var Rect = /*#__PURE__*/ (function () {
|
|
6
|
+
function Rect(config) {
|
|
7
|
+
Object.assign(this, config);
|
|
8
|
+
}
|
|
9
|
+
var _proto = Rect.prototype;
|
|
10
|
+
_proto.width = function width() {
|
|
11
|
+
return this.r - this.l;
|
|
12
|
+
};
|
|
13
|
+
_proto.height = function height() {
|
|
14
|
+
return this.b - this.t;
|
|
15
|
+
};
|
|
16
|
+
_proto.valid = function valid() {
|
|
17
|
+
return this.r > this.l && this.b > this.t;
|
|
18
|
+
};
|
|
19
|
+
_proto.makeValid = function makeValid() {
|
|
20
|
+
return new Rect({
|
|
21
|
+
l: Math.min(this.l, this.r),
|
|
22
|
+
r: Math.max(this.l, this.r),
|
|
23
|
+
t: Math.min(this.t, this.b),
|
|
24
|
+
b: Math.max(this.t, this.b),
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
_proto.isEqual = function isEqual(r) {
|
|
28
|
+
if (!r || !r.isRect) return false;
|
|
29
|
+
return r.l == this.l && r.r == this.r && r.t == this.t && r.b == this.b;
|
|
30
|
+
};
|
|
31
|
+
Rect.add = function add(a, b) {
|
|
32
|
+
return new Rect({
|
|
33
|
+
l: a.l + b.l,
|
|
34
|
+
t: a.t + b.t,
|
|
35
|
+
r: a.r + b.r,
|
|
36
|
+
b: a.b + b.b,
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
Rect.multiply = function multiply(a, b) {
|
|
40
|
+
return new Rect({
|
|
41
|
+
l: a.l + (a.r - a.l) * b.l,
|
|
42
|
+
r: a.l + (a.r - a.l) * b.r,
|
|
43
|
+
t: a.t + (a.b - a.t) * b.t,
|
|
44
|
+
b: a.t + (a.b - a.t) * b.b,
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
Rect.margin = function margin(r, m) {
|
|
48
|
+
var mr = Rect.convertMargin(m);
|
|
49
|
+
return Rect.add(r, mr);
|
|
50
|
+
};
|
|
51
|
+
Rect.convertMargin = function convertMargin(m) {
|
|
52
|
+
if (!m) return new Rect();
|
|
53
|
+
if (m.isRect) return m;
|
|
54
|
+
if (isNumber(m))
|
|
55
|
+
return new Rect({
|
|
56
|
+
l: m,
|
|
57
|
+
t: m,
|
|
58
|
+
r: -m,
|
|
59
|
+
b: -m,
|
|
60
|
+
});
|
|
61
|
+
var m = Rect.convert(m);
|
|
62
|
+
m.b = -m.b;
|
|
63
|
+
m.r = -m.r;
|
|
64
|
+
return m;
|
|
65
|
+
};
|
|
66
|
+
Rect.convert = function convert(r) {
|
|
67
|
+
if (!r)
|
|
68
|
+
return new Rect({
|
|
69
|
+
l: 0,
|
|
70
|
+
r: 0,
|
|
71
|
+
t: 0,
|
|
72
|
+
b: 0,
|
|
73
|
+
});
|
|
74
|
+
if (r.isRect) return r;
|
|
75
|
+
if (typeof r === "string") r = r.split(" ");
|
|
76
|
+
if (isArray(r)) {
|
|
77
|
+
return new Rect({
|
|
78
|
+
t: parseFloat(r[0]),
|
|
79
|
+
r: parseFloat(r[1]),
|
|
80
|
+
b: parseFloat(r[2]),
|
|
81
|
+
l: parseFloat(r[3]),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return new Rect(r);
|
|
85
|
+
};
|
|
86
|
+
return Rect;
|
|
87
|
+
})();
|
|
88
|
+
Rect.prototype.isRect = true;
|
|
89
|
+
Rect.prototype.l = 0; //left;
|
|
90
|
+
Rect.prototype.r = 0; //right
|
|
91
|
+
Rect.prototype.t = 0; //top
|
|
92
|
+
Rect.prototype.b = 0; //bottom
|
|
93
|
+
|
|
94
|
+
function ownKeys(object, enumerableOnly) {
|
|
95
|
+
var keys = Object.keys(object);
|
|
96
|
+
if (Object.getOwnPropertySymbols) {
|
|
97
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
98
|
+
enumerableOnly &&
|
|
99
|
+
(symbols = symbols.filter(function (sym) {
|
|
100
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
101
|
+
})),
|
|
102
|
+
keys.push.apply(keys, symbols);
|
|
103
|
+
}
|
|
104
|
+
return keys;
|
|
105
|
+
}
|
|
106
|
+
function _objectSpread2(target) {
|
|
107
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
108
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
109
|
+
i % 2
|
|
110
|
+
? ownKeys(Object(source), !0).forEach(function (key) {
|
|
111
|
+
_defineProperty(target, key, source[key]);
|
|
112
|
+
})
|
|
113
|
+
: Object.getOwnPropertyDescriptors
|
|
114
|
+
? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source))
|
|
115
|
+
: ownKeys(Object(source)).forEach(function (key) {
|
|
116
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return target;
|
|
120
|
+
}
|
|
121
|
+
function _defineProperty(obj, key, value) {
|
|
122
|
+
key = _toPropertyKey(key);
|
|
123
|
+
if (key in obj) {
|
|
124
|
+
Object.defineProperty(obj, key, {
|
|
125
|
+
value: value,
|
|
126
|
+
enumerable: true,
|
|
127
|
+
configurable: true,
|
|
128
|
+
writable: true,
|
|
129
|
+
});
|
|
130
|
+
} else {
|
|
131
|
+
obj[key] = value;
|
|
132
|
+
}
|
|
133
|
+
return obj;
|
|
134
|
+
}
|
|
135
|
+
function _inheritsLoose(subClass, superClass) {
|
|
136
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
137
|
+
subClass.prototype.constructor = subClass;
|
|
138
|
+
_setPrototypeOf(subClass, superClass);
|
|
139
|
+
}
|
|
140
|
+
function _setPrototypeOf(o, p) {
|
|
141
|
+
_setPrototypeOf = Object.setPrototypeOf
|
|
142
|
+
? Object.setPrototypeOf.bind()
|
|
143
|
+
: function _setPrototypeOf(o, p) {
|
|
144
|
+
o.__proto__ = p;
|
|
145
|
+
return o;
|
|
146
|
+
};
|
|
147
|
+
return _setPrototypeOf(o, p);
|
|
148
|
+
}
|
|
149
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
150
|
+
if (!o) return;
|
|
151
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
152
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
153
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
154
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
155
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
156
|
+
}
|
|
157
|
+
function _arrayLikeToArray(arr, len) {
|
|
158
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
159
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
160
|
+
return arr2;
|
|
161
|
+
}
|
|
162
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
163
|
+
var it = (typeof Symbol !== "undefined" && o[Symbol.iterator]) || o["@@iterator"];
|
|
164
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
165
|
+
if (
|
|
166
|
+
Array.isArray(o) ||
|
|
167
|
+
(it = _unsupportedIterableToArray(o)) ||
|
|
168
|
+
(allowArrayLike && o && typeof o.length === "number")
|
|
169
|
+
) {
|
|
170
|
+
if (it) o = it;
|
|
171
|
+
var i = 0;
|
|
172
|
+
return function () {
|
|
173
|
+
if (i >= o.length)
|
|
174
|
+
return {
|
|
175
|
+
done: true,
|
|
176
|
+
};
|
|
177
|
+
return {
|
|
178
|
+
done: false,
|
|
179
|
+
value: o[i++],
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
throw new TypeError(
|
|
184
|
+
"Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
function _toPrimitive(input, hint) {
|
|
188
|
+
if (typeof input !== "object" || input === null) return input;
|
|
189
|
+
var prim = input[Symbol.toPrimitive];
|
|
190
|
+
if (prim !== undefined) {
|
|
191
|
+
var res = prim.call(input, hint || "default");
|
|
192
|
+
if (typeof res !== "object") return res;
|
|
193
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
194
|
+
}
|
|
195
|
+
return (hint === "string" ? String : Number)(input);
|
|
196
|
+
}
|
|
197
|
+
function _toPropertyKey(arg) {
|
|
198
|
+
var key = _toPrimitive(arg, "string");
|
|
199
|
+
return typeof key === "symbol" ? key : String(key);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
var BoundedObject = /*#__PURE__*/ (function (_PureContainer) {
|
|
203
|
+
_inheritsLoose(BoundedObject, _PureContainer);
|
|
204
|
+
function BoundedObject() {
|
|
205
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
206
|
+
}
|
|
207
|
+
var _proto = BoundedObject.prototype;
|
|
208
|
+
_proto.declareData = function declareData() {
|
|
209
|
+
var _PureContainer$protot;
|
|
210
|
+
return (_PureContainer$protot = _PureContainer.prototype.declareData).call.apply(
|
|
211
|
+
_PureContainer$protot,
|
|
212
|
+
[
|
|
213
|
+
this,
|
|
214
|
+
{
|
|
215
|
+
anchors: undefined,
|
|
216
|
+
offset: undefined,
|
|
217
|
+
margin: undefined,
|
|
218
|
+
padding: undefined,
|
|
219
|
+
},
|
|
220
|
+
].concat(Array.prototype.slice.call(arguments))
|
|
221
|
+
);
|
|
222
|
+
};
|
|
223
|
+
_proto.prepareData = function prepareData(context, instance) {
|
|
224
|
+
_PureContainer.prototype.prepareData.call(this, context, instance);
|
|
225
|
+
var data = instance.data;
|
|
226
|
+
data.anchors = Rect.convert(data.anchors);
|
|
227
|
+
data.offset = Rect.convert(data.offset);
|
|
228
|
+
data.margin = Rect.convertMargin(data.margin);
|
|
229
|
+
data.padding = Rect.convertMargin(data.padding);
|
|
230
|
+
};
|
|
231
|
+
_proto.calculateBounds = function calculateBounds(context, instance) {
|
|
232
|
+
var data = instance.data;
|
|
233
|
+
return Rect.add(Rect.add(Rect.multiply(instance.parentRect, data.anchors), data.offset), data.margin);
|
|
234
|
+
};
|
|
235
|
+
_proto.prepareBounds = function prepareBounds(context, instance) {
|
|
236
|
+
var data = instance.data;
|
|
237
|
+
if (
|
|
238
|
+
instance.shouldUpdate ||
|
|
239
|
+
!instance.cached.parentRect ||
|
|
240
|
+
!instance.cached.parentRect.isEqual(context.parentRect) ||
|
|
241
|
+
!data.bounds
|
|
242
|
+
) {
|
|
243
|
+
if (!context.parentRect) throw new Error("Parent bounds were not provided through the context.");
|
|
244
|
+
instance.parentRect = context.parentRect;
|
|
245
|
+
instance.cache("parentRect", context.parentRect);
|
|
246
|
+
instance.markShouldUpdate(context);
|
|
247
|
+
data.bounds = this.calculateBounds(context, instance);
|
|
248
|
+
data.childrenBounds = Rect.add(data.bounds, data.padding);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
_proto.prepare = function prepare(context, instance) {
|
|
252
|
+
this.prepareBounds(context, instance);
|
|
253
|
+
context.push("parentRect", instance.data.childrenBounds);
|
|
254
|
+
};
|
|
255
|
+
_proto.prepareCleanup = function prepareCleanup(context, instance) {
|
|
256
|
+
context.pop("parentRect");
|
|
257
|
+
};
|
|
258
|
+
return BoundedObject;
|
|
259
|
+
})(PureContainer);
|
|
260
|
+
BoundedObject.prototype.anchors = 0;
|
|
261
|
+
BoundedObject.prototype.margin = 0;
|
|
262
|
+
BoundedObject.prototype.offset = 0;
|
|
263
|
+
BoundedObject.prototype.padding = 0;
|
|
264
|
+
BoundedObject.prototype.isPureContainer = false;
|
|
265
|
+
BoundedObject.prototype.styled = true;
|
|
266
|
+
|
|
267
|
+
var Text = /*#__PURE__*/ (function (_BoundedObject) {
|
|
268
|
+
_inheritsLoose(Text, _BoundedObject);
|
|
269
|
+
function Text() {
|
|
270
|
+
return _BoundedObject.apply(this, arguments) || this;
|
|
271
|
+
}
|
|
272
|
+
var _proto = Text.prototype;
|
|
273
|
+
_proto.declareData = function declareData() {
|
|
274
|
+
var _BoundedObject$protot;
|
|
275
|
+
return (_BoundedObject$protot = _BoundedObject.prototype.declareData).call.apply(
|
|
276
|
+
_BoundedObject$protot,
|
|
277
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
278
|
+
{
|
|
279
|
+
value: undefined,
|
|
280
|
+
dx: undefined,
|
|
281
|
+
dy: undefined,
|
|
282
|
+
textAnchor: undefined,
|
|
283
|
+
fill: undefined,
|
|
284
|
+
stroke: undefined,
|
|
285
|
+
},
|
|
286
|
+
])
|
|
287
|
+
);
|
|
288
|
+
};
|
|
289
|
+
_proto.init = function init() {
|
|
290
|
+
if (this.ta) this.textAnchor = this.ta;
|
|
291
|
+
if (this.bind) {
|
|
292
|
+
this.value = {
|
|
293
|
+
bind: this.bind,
|
|
294
|
+
};
|
|
295
|
+
} else if (this.tpl) {
|
|
296
|
+
this.value = {
|
|
297
|
+
tpl: this.tpl,
|
|
298
|
+
};
|
|
299
|
+
} else if (this.expr) {
|
|
300
|
+
this.value = {
|
|
301
|
+
expr: this.expr,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
_BoundedObject.prototype.init.call(this);
|
|
305
|
+
};
|
|
306
|
+
_proto.render = function render(context, instance, key) {
|
|
307
|
+
var data = instance.data;
|
|
308
|
+
var bounds = data.bounds;
|
|
309
|
+
return /*#__PURE__*/ jsxs(
|
|
310
|
+
"text",
|
|
311
|
+
{
|
|
312
|
+
className: data.classNames,
|
|
313
|
+
x: bounds.l,
|
|
314
|
+
y: bounds.t,
|
|
315
|
+
dx: data.dx,
|
|
316
|
+
dy: data.dy,
|
|
317
|
+
textAnchor: data.textAnchor,
|
|
318
|
+
style: data.style,
|
|
319
|
+
fill: data.fill,
|
|
320
|
+
stroke: data.stroke,
|
|
321
|
+
children: [data.value, this.renderChildren(context, instance)],
|
|
322
|
+
},
|
|
323
|
+
key
|
|
324
|
+
);
|
|
325
|
+
};
|
|
326
|
+
return Text;
|
|
327
|
+
})(BoundedObject);
|
|
328
|
+
Text.prototype.anchors = "0.5 0.5 0.5 0.5";
|
|
329
|
+
Text.prototype.baseClass = "text";
|
|
330
|
+
Widget.alias("svg.text", Text);
|
|
331
|
+
|
|
332
|
+
var TextualBoundedObject = /*#__PURE__*/ (function (_BoundedObject) {
|
|
333
|
+
_inheritsLoose(TextualBoundedObject, _BoundedObject);
|
|
334
|
+
function TextualBoundedObject() {
|
|
335
|
+
return _BoundedObject.apply(this, arguments) || this;
|
|
336
|
+
}
|
|
337
|
+
var _proto = TextualBoundedObject.prototype;
|
|
338
|
+
_proto.add = function add(widget) {
|
|
339
|
+
if (typeof widget != "string") return _BoundedObject.prototype.add.apply(this, arguments);
|
|
340
|
+
if (this.trimWhitespace) widget = innerTextTrim(widget);
|
|
341
|
+
if (!widget) return;
|
|
342
|
+
return this.add({
|
|
343
|
+
type: Text,
|
|
344
|
+
value: widget,
|
|
345
|
+
textAnchor: "middle",
|
|
346
|
+
dy: "0.4em",
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
return TextualBoundedObject;
|
|
350
|
+
})(BoundedObject);
|
|
351
|
+
|
|
352
|
+
var Svg = /*#__PURE__*/ (function (_BoundedObject) {
|
|
353
|
+
_inheritsLoose(Svg, _BoundedObject);
|
|
354
|
+
function Svg() {
|
|
355
|
+
return _BoundedObject.apply(this, arguments) || this;
|
|
356
|
+
}
|
|
357
|
+
var _proto = Svg.prototype;
|
|
358
|
+
_proto.initState = function initState(context, instance) {
|
|
359
|
+
var size = {
|
|
360
|
+
width: 0,
|
|
361
|
+
height: 0,
|
|
362
|
+
};
|
|
363
|
+
instance.state = {
|
|
364
|
+
size: size,
|
|
365
|
+
};
|
|
366
|
+
};
|
|
367
|
+
_proto.explore = function explore(context, instance) {
|
|
368
|
+
context.push("inSvg", true);
|
|
369
|
+
_BoundedObject.prototype.explore.call(this, context, instance);
|
|
370
|
+
};
|
|
371
|
+
_proto.exploreCleanup = function exploreCleanup(context, instance) {
|
|
372
|
+
context.pop("inSvg");
|
|
373
|
+
};
|
|
374
|
+
_proto.prepare = function prepare(context, instance) {
|
|
375
|
+
var size = instance.state.size;
|
|
376
|
+
context.parentRect = new Rect({
|
|
377
|
+
l: 0,
|
|
378
|
+
t: 0,
|
|
379
|
+
r: size.width,
|
|
380
|
+
b: size.height,
|
|
381
|
+
});
|
|
382
|
+
instance.clipRects = {};
|
|
383
|
+
instance.clipRectId = 0;
|
|
384
|
+
context.push("addClipRect", function (rect) {
|
|
385
|
+
var id = "clip-" + instance.id + "-" + ++instance.clipRectId;
|
|
386
|
+
instance.clipRects[id] = rect;
|
|
387
|
+
return id;
|
|
388
|
+
});
|
|
389
|
+
context.push("inSvg", true);
|
|
390
|
+
_BoundedObject.prototype.prepare.call(this, context, instance);
|
|
391
|
+
};
|
|
392
|
+
_proto.prepareCleanup = function prepareCleanup(context, instance) {
|
|
393
|
+
_BoundedObject.prototype.prepareCleanup.call(this, context, instance);
|
|
394
|
+
context.pop("addClipRect");
|
|
395
|
+
context.pop("inSvg");
|
|
396
|
+
};
|
|
397
|
+
_proto.render = function render(context, instance, key) {
|
|
398
|
+
var eventHandlers = instance.getJsxEventProps();
|
|
399
|
+
if (eventHandlers) {
|
|
400
|
+
delete eventHandlers["onWheelActive"];
|
|
401
|
+
}
|
|
402
|
+
return /*#__PURE__*/ jsx(
|
|
403
|
+
SvgComponent,
|
|
404
|
+
{
|
|
405
|
+
instance: instance,
|
|
406
|
+
data: instance.data,
|
|
407
|
+
options: context.options,
|
|
408
|
+
size: instance.state.size,
|
|
409
|
+
eventHandlers: eventHandlers,
|
|
410
|
+
children: this.renderChildren(context, instance),
|
|
411
|
+
},
|
|
412
|
+
key
|
|
413
|
+
);
|
|
414
|
+
};
|
|
415
|
+
return Svg;
|
|
416
|
+
})(BoundedObject);
|
|
417
|
+
Svg.prototype.anchors = "0 1 1 0";
|
|
418
|
+
Svg.prototype.baseClass = "svg";
|
|
419
|
+
Svg.prototype.autoWidth = false;
|
|
420
|
+
Svg.prototype.autoHeight = false;
|
|
421
|
+
Svg.prototype.aspectRatio = 1.618;
|
|
422
|
+
function sameSize(a, b) {
|
|
423
|
+
if (!a || !b) return false;
|
|
424
|
+
return a.width == b.width && a.height == b.height;
|
|
425
|
+
}
|
|
426
|
+
var SvgComponent = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
427
|
+
_inheritsLoose(SvgComponent, _VDOM$Component);
|
|
428
|
+
function SvgComponent() {
|
|
429
|
+
return _VDOM$Component.apply(this, arguments) || this;
|
|
430
|
+
}
|
|
431
|
+
var _proto2 = SvgComponent.prototype;
|
|
432
|
+
_proto2.render = function render() {
|
|
433
|
+
var _this = this;
|
|
434
|
+
var _this$props = this.props,
|
|
435
|
+
instance = _this$props.instance,
|
|
436
|
+
data = _this$props.data,
|
|
437
|
+
size = _this$props.size,
|
|
438
|
+
children = _this$props.children,
|
|
439
|
+
eventHandlers = _this$props.eventHandlers;
|
|
440
|
+
var widget = instance.widget;
|
|
441
|
+
var defs = [];
|
|
442
|
+
for (var k in instance.clipRects) {
|
|
443
|
+
var cr = instance.clipRects[k];
|
|
444
|
+
defs.push(
|
|
445
|
+
/*#__PURE__*/ jsx(
|
|
446
|
+
"clipPath",
|
|
447
|
+
{
|
|
448
|
+
id: k,
|
|
449
|
+
children: /*#__PURE__*/ jsx("rect", {
|
|
450
|
+
x: cr.l,
|
|
451
|
+
y: cr.t,
|
|
452
|
+
width: Math.max(0, cr.width()),
|
|
453
|
+
height: Math.max(0, cr.height()),
|
|
454
|
+
}),
|
|
455
|
+
},
|
|
456
|
+
k
|
|
457
|
+
)
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
var style = data.style;
|
|
461
|
+
if (widget.autoHeight)
|
|
462
|
+
style = _objectSpread2(
|
|
463
|
+
_objectSpread2({}, style),
|
|
464
|
+
{},
|
|
465
|
+
{
|
|
466
|
+
height: size.height + "px",
|
|
467
|
+
}
|
|
468
|
+
);
|
|
469
|
+
if (widget.autoWidth)
|
|
470
|
+
style = _objectSpread2(
|
|
471
|
+
_objectSpread2({}, style),
|
|
472
|
+
{},
|
|
473
|
+
{
|
|
474
|
+
width: size.width + "px",
|
|
475
|
+
}
|
|
476
|
+
);
|
|
477
|
+
|
|
478
|
+
//parent div is needed because clientWidth doesn't work on the svg element in FF
|
|
479
|
+
|
|
480
|
+
return /*#__PURE__*/ jsx(
|
|
481
|
+
"div",
|
|
482
|
+
_objectSpread2(
|
|
483
|
+
_objectSpread2(
|
|
484
|
+
{
|
|
485
|
+
ref: function ref(el) {
|
|
486
|
+
_this.el = el;
|
|
487
|
+
},
|
|
488
|
+
className: data.classNames,
|
|
489
|
+
style: style,
|
|
490
|
+
},
|
|
491
|
+
eventHandlers
|
|
492
|
+
),
|
|
493
|
+
{},
|
|
494
|
+
{
|
|
495
|
+
children:
|
|
496
|
+
size.width > 0 &&
|
|
497
|
+
size.height > 0 &&
|
|
498
|
+
/*#__PURE__*/ jsxs("svg", {
|
|
499
|
+
children: [
|
|
500
|
+
/*#__PURE__*/ jsx("defs", {
|
|
501
|
+
children: defs,
|
|
502
|
+
}),
|
|
503
|
+
children,
|
|
504
|
+
],
|
|
505
|
+
}),
|
|
506
|
+
}
|
|
507
|
+
)
|
|
508
|
+
);
|
|
509
|
+
};
|
|
510
|
+
_proto2.onResize = function onResize() {
|
|
511
|
+
var instance = this.props.instance;
|
|
512
|
+
var widget = this.props.instance.widget;
|
|
513
|
+
var size = {
|
|
514
|
+
width: this.el.clientWidth,
|
|
515
|
+
height: this.el.clientHeight,
|
|
516
|
+
};
|
|
517
|
+
if (widget.autoHeight) size.height = size.width / widget.aspectRatio;
|
|
518
|
+
if (widget.autoWidth) size.width = size.height * widget.aspectRatio;
|
|
519
|
+
if (!sameSize(instance.state.size, size))
|
|
520
|
+
instance.setState({
|
|
521
|
+
size: size,
|
|
522
|
+
});
|
|
523
|
+
};
|
|
524
|
+
_proto2.componentDidMount = function componentDidMount() {
|
|
525
|
+
var _this2 = this;
|
|
526
|
+
this.offResize = ResizeManager.trackElement(this.el, this.onResize.bind(this));
|
|
527
|
+
this.onResize();
|
|
528
|
+
if (this.props.instance.widget.onWheelActive) {
|
|
529
|
+
this.offWheelActive = addEventListenerWithOptions(
|
|
530
|
+
this.el,
|
|
531
|
+
"wheel",
|
|
532
|
+
function (event) {
|
|
533
|
+
var instance = _this2.props.instance;
|
|
534
|
+
instance.invoke("onWheelActive", event, instance);
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
passive: false,
|
|
538
|
+
}
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
_proto2.componentDidUpdate = function componentDidUpdate() {
|
|
543
|
+
this.onResize();
|
|
544
|
+
};
|
|
545
|
+
_proto2.componentWillUnmount = function componentWillUnmount() {
|
|
546
|
+
this.offResize && this.offResize();
|
|
547
|
+
this.offWheelActive && this.offWheelActive();
|
|
548
|
+
};
|
|
549
|
+
return SvgComponent;
|
|
550
|
+
})(VDOM.Component);
|
|
551
|
+
Widget.alias("svg", Svg);
|
|
552
|
+
|
|
553
|
+
var Rectangle = /*#__PURE__*/ (function (_TextualBoundedObject) {
|
|
554
|
+
_inheritsLoose(Rectangle, _TextualBoundedObject);
|
|
555
|
+
function Rectangle() {
|
|
556
|
+
return _TextualBoundedObject.apply(this, arguments) || this;
|
|
557
|
+
}
|
|
558
|
+
var _proto = Rectangle.prototype;
|
|
559
|
+
_proto.declareData = function declareData() {
|
|
560
|
+
var _TextualBoundedObject2;
|
|
561
|
+
(_TextualBoundedObject2 = _TextualBoundedObject.prototype.declareData).call.apply(
|
|
562
|
+
_TextualBoundedObject2,
|
|
563
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
564
|
+
{
|
|
565
|
+
colorIndex: undefined,
|
|
566
|
+
fill: undefined,
|
|
567
|
+
stroke: undefined,
|
|
568
|
+
},
|
|
569
|
+
])
|
|
570
|
+
);
|
|
571
|
+
};
|
|
572
|
+
_proto.render = function render(context, instance, key) {
|
|
573
|
+
var data = instance.data;
|
|
574
|
+
var bounds = data.bounds,
|
|
575
|
+
colorIndex = data.colorIndex;
|
|
576
|
+
if (!bounds.valid()) return false;
|
|
577
|
+
return /*#__PURE__*/ jsxs(
|
|
578
|
+
"g",
|
|
579
|
+
{
|
|
580
|
+
className: data.classNames,
|
|
581
|
+
children: [
|
|
582
|
+
/*#__PURE__*/ jsx("rect", {
|
|
583
|
+
className: this.CSS.element(this.baseClass, "rect", colorIndex != null && "color-" + colorIndex),
|
|
584
|
+
x: bounds.l,
|
|
585
|
+
y: bounds.t,
|
|
586
|
+
width: bounds.width(),
|
|
587
|
+
height: bounds.height(),
|
|
588
|
+
style: data.style,
|
|
589
|
+
fill: data.fill,
|
|
590
|
+
stroke: data.stroke,
|
|
591
|
+
}),
|
|
592
|
+
this.renderChildren(context, instance),
|
|
593
|
+
],
|
|
594
|
+
},
|
|
595
|
+
key
|
|
596
|
+
);
|
|
597
|
+
};
|
|
598
|
+
return Rectangle;
|
|
599
|
+
})(TextualBoundedObject);
|
|
600
|
+
Rectangle.prototype.baseClass = "rectangle";
|
|
601
|
+
Rectangle.prototype.anchors = "0 1 1 0";
|
|
602
|
+
Widget.alias("rectangle", Rectangle);
|
|
603
|
+
|
|
604
|
+
var ClipRect = /*#__PURE__*/ (function (_BoundedObject) {
|
|
605
|
+
_inheritsLoose(ClipRect, _BoundedObject);
|
|
606
|
+
function ClipRect() {
|
|
607
|
+
return _BoundedObject.apply(this, arguments) || this;
|
|
608
|
+
}
|
|
609
|
+
var _proto = ClipRect.prototype;
|
|
610
|
+
_proto.prepareBounds = function prepareBounds(context, instance) {
|
|
611
|
+
_BoundedObject.prototype.prepareBounds.call(this, context, instance);
|
|
612
|
+
var data = instance.data;
|
|
613
|
+
data.clipId = context.addClipRect(data.bounds);
|
|
614
|
+
};
|
|
615
|
+
_proto.render = function render(context, instance, key) {
|
|
616
|
+
var data = instance.data;
|
|
617
|
+
return /*#__PURE__*/ jsx(
|
|
618
|
+
"g",
|
|
619
|
+
{
|
|
620
|
+
clipPath: "url(#" + data.clipId + ")",
|
|
621
|
+
children: this.renderChildren(context, instance),
|
|
622
|
+
},
|
|
623
|
+
key
|
|
624
|
+
);
|
|
625
|
+
};
|
|
626
|
+
return ClipRect;
|
|
627
|
+
})(BoundedObject);
|
|
628
|
+
ClipRect.prototype.anchors = "0 1 1 0";
|
|
629
|
+
|
|
630
|
+
var Ellipse = /*#__PURE__*/ (function (_TextualBoundedObject) {
|
|
631
|
+
_inheritsLoose(Ellipse, _TextualBoundedObject);
|
|
632
|
+
function Ellipse() {
|
|
633
|
+
return _TextualBoundedObject.apply(this, arguments) || this;
|
|
634
|
+
}
|
|
635
|
+
var _proto = Ellipse.prototype;
|
|
636
|
+
_proto.declareData = function declareData() {
|
|
637
|
+
var _TextualBoundedObject2;
|
|
638
|
+
(_TextualBoundedObject2 = _TextualBoundedObject.prototype.declareData).call.apply(
|
|
639
|
+
_TextualBoundedObject2,
|
|
640
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
641
|
+
{
|
|
642
|
+
colorIndex: undefined,
|
|
643
|
+
fill: undefined,
|
|
644
|
+
stroke: undefined,
|
|
645
|
+
},
|
|
646
|
+
])
|
|
647
|
+
);
|
|
648
|
+
};
|
|
649
|
+
_proto.render = function render(context, instance, key) {
|
|
650
|
+
var data = instance.data;
|
|
651
|
+
var bounds = data.bounds,
|
|
652
|
+
colorIndex = data.colorIndex;
|
|
653
|
+
if (!bounds.valid()) return false;
|
|
654
|
+
return /*#__PURE__*/ jsxs(
|
|
655
|
+
"g",
|
|
656
|
+
{
|
|
657
|
+
className: data.classNames,
|
|
658
|
+
children: [
|
|
659
|
+
/*#__PURE__*/ jsx("ellipse", {
|
|
660
|
+
className: this.CSS.element(this.baseClass, "rect", colorIndex != null && "color-" + colorIndex),
|
|
661
|
+
cx: (bounds.l + bounds.r) / 2,
|
|
662
|
+
cy: (bounds.t + bounds.b) / 2,
|
|
663
|
+
rx: bounds.width() / 2,
|
|
664
|
+
ry: bounds.height() / 2,
|
|
665
|
+
style: data.style,
|
|
666
|
+
fill: data.fill,
|
|
667
|
+
stroke: data.stroke,
|
|
668
|
+
}),
|
|
669
|
+
this.renderChildren(context, instance),
|
|
670
|
+
],
|
|
671
|
+
},
|
|
672
|
+
key
|
|
673
|
+
);
|
|
674
|
+
};
|
|
675
|
+
return Ellipse;
|
|
676
|
+
})(TextualBoundedObject);
|
|
677
|
+
Ellipse.prototype.baseClass = "ellipse";
|
|
678
|
+
Ellipse.prototype.anchors = "0 1 1 0";
|
|
679
|
+
Widget.alias("ellipse", Ellipse);
|
|
680
|
+
|
|
681
|
+
var Line = /*#__PURE__*/ (function (_TextualBoundedObject) {
|
|
682
|
+
_inheritsLoose(Line, _TextualBoundedObject);
|
|
683
|
+
function Line() {
|
|
684
|
+
return _TextualBoundedObject.apply(this, arguments) || this;
|
|
685
|
+
}
|
|
686
|
+
var _proto = Line.prototype;
|
|
687
|
+
_proto.declareData = function declareData() {
|
|
688
|
+
var _TextualBoundedObject2;
|
|
689
|
+
(_TextualBoundedObject2 = _TextualBoundedObject.prototype.declareData).call.apply(
|
|
690
|
+
_TextualBoundedObject2,
|
|
691
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
692
|
+
{
|
|
693
|
+
colorIndex: undefined,
|
|
694
|
+
stroke: undefined,
|
|
695
|
+
},
|
|
696
|
+
])
|
|
697
|
+
);
|
|
698
|
+
};
|
|
699
|
+
_proto.render = function render(context, instance, key) {
|
|
700
|
+
var data = instance.data,
|
|
701
|
+
colorIndex = instance.colorIndex;
|
|
702
|
+
var bounds = data.bounds;
|
|
703
|
+
return /*#__PURE__*/ jsxs(
|
|
704
|
+
"g",
|
|
705
|
+
{
|
|
706
|
+
className: data.classNames,
|
|
707
|
+
children: [
|
|
708
|
+
/*#__PURE__*/ jsx("line", {
|
|
709
|
+
className: this.CSS.element(this.baseClass, "line", colorIndex != null && "color-" + colorIndex),
|
|
710
|
+
x1: bounds.l,
|
|
711
|
+
y1: bounds.t,
|
|
712
|
+
x2: bounds.r,
|
|
713
|
+
y2: bounds.b,
|
|
714
|
+
style: data.style,
|
|
715
|
+
stroke: data.stroke,
|
|
716
|
+
}),
|
|
717
|
+
this.renderChildren(context, instance),
|
|
718
|
+
],
|
|
719
|
+
},
|
|
720
|
+
key
|
|
721
|
+
);
|
|
722
|
+
};
|
|
723
|
+
return Line;
|
|
724
|
+
})(TextualBoundedObject);
|
|
725
|
+
Line.prototype.anchors = "0 1 1 0";
|
|
726
|
+
Line.prototype.baseClass = "line";
|
|
727
|
+
Widget.alias("line", Line);
|
|
728
|
+
|
|
729
|
+
var NonOverlappingRect = /*#__PURE__*/ (function (_BoundedObject) {
|
|
730
|
+
_inheritsLoose(NonOverlappingRect, _BoundedObject);
|
|
731
|
+
function NonOverlappingRect() {
|
|
732
|
+
return _BoundedObject.apply(this, arguments) || this;
|
|
733
|
+
}
|
|
734
|
+
var _proto = NonOverlappingRect.prototype;
|
|
735
|
+
_proto.prepare = function prepare(context, instance) {
|
|
736
|
+
_BoundedObject.prototype.prepare.call(this, context, instance); //calculate bounds
|
|
737
|
+
if (!context.addNonOverlappingBoundingObject)
|
|
738
|
+
throw new Error("Components of type NonOverlappingRect can appaear only within a NonOverlappingRectGroup.");
|
|
739
|
+
context.addNonOverlappingBoundingObject(instance);
|
|
740
|
+
};
|
|
741
|
+
_proto.render = function render(context, instance, key) {
|
|
742
|
+
if (instance.overlapping) return null;
|
|
743
|
+
return _BoundedObject.prototype.render.call(this, context, instance, key);
|
|
744
|
+
};
|
|
745
|
+
return NonOverlappingRect;
|
|
746
|
+
})(BoundedObject);
|
|
747
|
+
|
|
748
|
+
var NonOverlappingRectGroup = /*#__PURE__*/ (function (_PureContainer) {
|
|
749
|
+
_inheritsLoose(NonOverlappingRectGroup, _PureContainer);
|
|
750
|
+
function NonOverlappingRectGroup() {
|
|
751
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
752
|
+
}
|
|
753
|
+
var _proto = NonOverlappingRectGroup.prototype;
|
|
754
|
+
_proto.prepare = function prepare(context, instance) {
|
|
755
|
+
instance.nonOverlappingObjects = [];
|
|
756
|
+
context.push("addNonOverlappingBoundingObject", function (objectInstance) {
|
|
757
|
+
instance.nonOverlappingObjects.push(objectInstance);
|
|
758
|
+
});
|
|
759
|
+
};
|
|
760
|
+
_proto.prepareCleanup = function prepareCleanup(context, instance) {
|
|
761
|
+
context.pop("addNonOverlappingBoundingObject");
|
|
762
|
+
instance.nonOverlappingObjects.sort(function (a, b) {
|
|
763
|
+
return a.data.bounds.r - b.data.bounds.r;
|
|
764
|
+
});
|
|
765
|
+
var visibleObjects = [];
|
|
766
|
+
for (
|
|
767
|
+
var _iterator = _createForOfIteratorHelperLoose(instance.nonOverlappingObjects), _step;
|
|
768
|
+
!(_step = _iterator()).done;
|
|
769
|
+
|
|
770
|
+
) {
|
|
771
|
+
var item = _step.value;
|
|
772
|
+
var overlapping = false;
|
|
773
|
+
var at = visibleObjects.length - 1;
|
|
774
|
+
while (at >= 0 && visibleObjects[at].data.bounds.r > item.data.bounds.l) {
|
|
775
|
+
var r1 = visibleObjects[at].data.bounds;
|
|
776
|
+
var r2 = item.data.bounds;
|
|
777
|
+
var width = Math.min(r1.r, r2.r) - Math.max(r1.l, r2.l);
|
|
778
|
+
var height = Math.min(r1.b, r2.b) - Math.max(r1.t, r2.t);
|
|
779
|
+
if (width > 0 && height > 0) {
|
|
780
|
+
overlapping = true;
|
|
781
|
+
break;
|
|
782
|
+
}
|
|
783
|
+
at--;
|
|
784
|
+
}
|
|
785
|
+
if (item.overlapping !== overlapping) {
|
|
786
|
+
item.overlapping = overlapping;
|
|
787
|
+
item.markShouldUpdate(context);
|
|
788
|
+
}
|
|
789
|
+
if (!overlapping) visibleObjects.push(item);
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
return NonOverlappingRectGroup;
|
|
793
|
+
})(PureContainer);
|
|
794
|
+
|
|
795
|
+
export {
|
|
796
|
+
BoundedObject,
|
|
797
|
+
ClipRect,
|
|
798
|
+
Ellipse,
|
|
799
|
+
Line,
|
|
800
|
+
NonOverlappingRect,
|
|
801
|
+
NonOverlappingRectGroup,
|
|
802
|
+
Rect,
|
|
803
|
+
Rectangle,
|
|
804
|
+
Svg,
|
|
805
|
+
Text,
|
|
806
|
+
TextualBoundedObject,
|
|
807
|
+
};
|