cx 24.10.6 → 24.10.7

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
@@ -3906,21 +3906,41 @@ var ContentPlaceholder = /*#__PURE__*/ (function (_PureContainer) {
3906
3906
  };
3907
3907
  _proto.prepare = function prepare(context, instance) {
3908
3908
  var content = instance.content;
3909
- if (instance.cache("content", content) || (content && content.shouldUpdate)) instance.markShouldUpdate(context);
3909
+ if (this.allowMultiple) {
3910
+ var contentId = "";
3911
+ var shouldUpdate = false;
3912
+ if (content) {
3913
+ for (var i = 0; i < content.length; i++) {
3914
+ var c = content[i];
3915
+ contentId += c.id + "+";
3916
+ shouldUpdate = shouldUpdate || c.shouldUpdate;
3917
+ }
3918
+ }
3919
+ if (instance.cache("content", contentId) || shouldUpdate) instance.markShouldUpdate(context);
3920
+ } else if (instance.cache("content", content) || (content && content.shouldUpdate))
3921
+ instance.markShouldUpdate(context);
3910
3922
  };
3911
3923
  _proto.setContent = function setContent(context, instance, content) {
3912
- instance.content = content;
3924
+ if (this.allowMultiple) {
3925
+ if (instance.content == null) instance.content = [];
3926
+ instance.content.push(content);
3927
+ } else instance.content = content;
3913
3928
  content.contentPlaceholder = instance;
3914
3929
  };
3915
3930
  _proto.render = function render(context, instance, key) {
3916
3931
  var content = instance.content;
3917
- if (content) return content.contentVDOM;
3918
- return _PureContainer.prototype.render.call(this, context, instance, key);
3932
+ if (!content) return _PureContainer.prototype.render.call(this, context, instance, key);
3933
+ if (this.allowMultiple)
3934
+ return content.map(function (x) {
3935
+ return x.contentVDOM;
3936
+ });
3937
+ return content.contentVDOM;
3919
3938
  };
3920
3939
  return ContentPlaceholder;
3921
3940
  })(PureContainer);
3922
3941
  ContentPlaceholder.prototype.name = "body";
3923
3942
  ContentPlaceholder.prototype.scoped = false;
3943
+ ContentPlaceholder.prototype.allowMultiple = false;
3924
3944
  Widget.alias("content-placeholder", ContentPlaceholder);
3925
3945
  var ContentPlaceholderScope = /*#__PURE__*/ (function (_PureContainer2) {
3926
3946
  function ContentPlaceholderScope() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "24.10.6",
3
+ "version": "24.10.7",
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",
@@ -320,7 +320,7 @@ class TimeScale {
320
320
  return date.getTimezoneOffset() * 60 * 1000;
321
321
  }
322
322
 
323
- getScale(tickSize, measure) {
323
+ getScale(tickSize, measure, minRange = 1000) {
324
324
  let { min, max, upperDeadZone, lowerDeadZone } = this;
325
325
 
326
326
  let smin = min;
@@ -368,6 +368,12 @@ class TimeScale {
368
368
  if (this.maxValue == max) smax = this.maxValuePadded;
369
369
  }
370
370
 
371
+ if (smax - smin < minRange) {
372
+ let delta = (minRange - (smax - smin)) / 2;
373
+ smin -= delta;
374
+ smax += delta;
375
+ }
376
+
371
377
  //padding should be activated only if using min/max obtained from the data
372
378
  let minPadding = this.minValue === min ? Math.max(0, smin - this.minValuePadded) : 0;
373
379
  let maxPadding = this.maxValue === max ? Math.max(0, this.maxValuePadded - smax) : 0;
@@ -420,7 +426,7 @@ class TimeScale {
420
426
  }
421
427
 
422
428
  findTickSize(minPxDist) {
423
- return this.tickSizes.find(({ size }) => size * Math.abs(this.scale.factor) >= minPxDist);
429
+ return this.tickSizes.find(({ size, noLabels }) => !noLabels && size * Math.abs(this.scale.factor) >= minPxDist);
424
430
  }
425
431
 
426
432
  getTickSizes() {
@@ -430,6 +436,8 @@ class TimeScale {
430
436
  calculateTicks() {
431
437
  let minReached = false;
432
438
 
439
+ let minRange = 1000;
440
+
433
441
  for (let unit in miliSeconds) {
434
442
  if (!minReached) {
435
443
  if (unit == this.minTickUnit) minReached = true;
@@ -458,7 +466,7 @@ class TimeScale {
458
466
  for (let d = 0; d < divs.length; d++) {
459
467
  //if (useSnapToTicks && d < Math.min(divs.length - 1, this.snapToTicks)) continue;
460
468
  let tickSize = divs[d] * unitSize;
461
- let scale = this.getScale(null, unit);
469
+ let scale = this.getScale(null, unit, tickSize);
462
470
  let format = this.format ?? this.getFormat(unit, scale);
463
471
  let minLabelDistance = this.minLabelDistanceFormatOverride[format] ?? this.minLabelDistance;
464
472
  let labelDistance = tickSize * Math.abs(scale.factor);
@@ -468,6 +476,7 @@ class TimeScale {
468
476
  bestLabelDistance = labelDistance;
469
477
  bestFormat = format;
470
478
  bestMinLabelDistance = minLabelDistance;
479
+ minRange = tickSize;
471
480
  }
472
481
  }
473
482
  }
@@ -516,10 +525,10 @@ class TimeScale {
516
525
  }
517
526
  }
518
527
  if (bestMinorTickSize != Infinity) {
519
- this.tickSizes.unshift({ size: bestMinorTickSize, measure: lowerTickUnit });
528
+ this.tickSizes.unshift({ size: bestMinorTickSize, measure: lowerTickUnit, noLabels: true });
520
529
  if (this.tickSizes.length > 1) {
521
530
  let labelStep = this.tickSizes[1].size;
522
- let lowerScale = this.getScale(null, lowerTickUnit);
531
+ let lowerScale = this.getScale(null, lowerTickUnit, minRange);
523
532
  if (lowerScale.max - lowerScale.min >= labelStep) this.scale = lowerScale;
524
533
  }
525
534
  }
@@ -527,7 +536,7 @@ class TimeScale {
527
536
 
528
537
  if (isNumber(this.snapToTicks) && this.snapToTicks >= 0) {
529
538
  let tickSize = this.tickSizes[Math.min(this.tickSizes.length - 1, this.snapToTicks)];
530
- this.scale = this.getScale(tickSize.size, tickSize.measure);
539
+ this.scale = this.getScale(tickSize.size, tickSize.measure, minRange);
531
540
  }
532
541
  }
533
542
 
@@ -13,8 +13,12 @@ export class PointReducer extends PureContainer {
13
13
  if (this.onInitAccumulator) instance.invoke("onInitAccumulator", accumulator, instance);
14
14
  };
15
15
 
16
+ let pointFilter = null;
17
+ if (this.onCreatePointFilter) pointFilter = instance.invoke("onCreatePointFilter", instance);
18
+
16
19
  instance.pointReducer = (x, y, name, data, array, index) => {
17
- onMap(accumulator, x, y, name, data, array, index);
20
+ if (!pointFilter || pointFilter(x, y, name, data, array, index))
21
+ onMap(accumulator, x, y, name, data, array, index);
18
22
  if (parentPointReducer) parentPointReducer(x, y, name, data, array, index);
19
23
  };
20
24
  instance.write = () => {
@@ -1,18 +1,19 @@
1
- import * as Cx from '../../core';
2
- import {RenderingContext} from '../RenderingContext';
3
-
4
- interface ContentPlaceholderProps extends Cx.PureContainerProps {
5
-
6
- name?: Cx.StringProp,
7
-
8
- scoped?: boolean
9
- }
10
-
11
- export class ContentPlaceholder extends Cx.Widget<ContentPlaceholderProps> {}
12
-
13
-
14
- interface ContentPlaceholderScopeProps extends Cx.PureContainerProps {
15
- name?: string | string[]
16
- }
17
-
18
- export class ContentPlaceholderScope extends Cx.Widget<ContentPlaceholderScopeProps> {}
1
+ import * as Cx from "../../core";
2
+ import { RenderingContext } from "../RenderingContext";
3
+
4
+ interface ContentPlaceholderProps extends Cx.PureContainerProps {
5
+ name?: Cx.StringProp;
6
+
7
+ scoped?: boolean;
8
+
9
+ /* Set to true to allow all registered content elements to render inside the placeholder. Otherwise only one element is rendered. */
10
+ allowMultiple?: boolean;
11
+ }
12
+
13
+ export class ContentPlaceholder extends Cx.Widget<ContentPlaceholderProps> {}
14
+
15
+ interface ContentPlaceholderScopeProps extends Cx.PureContainerProps {
16
+ name?: string | string[];
17
+ }
18
+
19
+ export class ContentPlaceholderScope extends Cx.Widget<ContentPlaceholderScopeProps> {}
@@ -1,80 +1,91 @@
1
- import {Widget} from '../Widget';
2
- import {PureContainer} from '../PureContainer';
3
- import {isString} from "../../util/isString";
4
-
5
- export class ContentPlaceholder extends PureContainer {
6
-
7
- declareData() {
8
- super.declareData(...arguments, {
9
- name: undefined
10
- });
11
- }
12
-
13
- explore(context, instance) {
14
- instance.content = null;
15
- let {data} = instance;
16
-
17
- const content = context.content && context.content[data.name];
18
- if (content && !this.scoped)
19
- this.setContent(context, instance, content);
20
- else
21
- context.pushNamedValue('contentPlaceholder', data.name, (content) => {
22
- this.setContent(context, instance, content);
23
- });
24
-
25
- if (this.scoped)
26
- instance.unregisterContentPlaceholder = () => {
27
- context.popNamedValue("contentPlaceholder", data.name);
28
- };
29
-
30
- super.explore(context, instance);
31
- }
32
-
33
- prepare(context, instance) {
34
- let {content} = instance;
35
- if (instance.cache('content', content) || (content && content.shouldUpdate))
36
- instance.markShouldUpdate(context);
37
- }
38
-
39
- setContent(context, instance, content) {
40
- instance.content = content;
41
- content.contentPlaceholder = instance;
42
- }
43
-
44
- render(context, instance, key) {
45
- const {content} = instance;
46
- if (content)
47
- return content.contentVDOM;
48
-
49
- return super.render(context, instance, key);
50
- }
51
- }
52
-
53
- ContentPlaceholder.prototype.name = 'body';
54
- ContentPlaceholder.prototype.scoped = false;
55
-
56
- Widget.alias('content-placeholder', ContentPlaceholder);
57
-
58
- export class ContentPlaceholderScope extends PureContainer {
59
- init() {
60
- super.init();
61
-
62
- if (isString(this.name))
63
- this.name = [this.name];
64
- }
65
-
66
- explore(context, instance) {
67
- this.name.forEach(name => {
68
- context.pushNamedValue('contentPlaceholder', name, null);
69
- context.pushNamedValue('content', name, null);
70
- });
71
- super.explore(context, instance);
72
- }
73
-
74
- exploreCleanup(context, instance) {
75
- this.name.forEach(name => {
76
- context.popNamedValue('contentPlaceholder', name);
77
- context.popNamedValue('content', name);
78
- });
79
- }
80
- }
1
+ import { Widget } from "../Widget";
2
+ import { PureContainer } from "../PureContainer";
3
+ import { isString } from "../../util/isString";
4
+
5
+ export class ContentPlaceholder extends PureContainer {
6
+ declareData() {
7
+ super.declareData(...arguments, {
8
+ name: undefined,
9
+ });
10
+ }
11
+
12
+ explore(context, instance) {
13
+ instance.content = null;
14
+ let { data } = instance;
15
+
16
+ const content = context.content && context.content[data.name];
17
+ if (content && !this.scoped) this.setContent(context, instance, content);
18
+ else
19
+ context.pushNamedValue("contentPlaceholder", data.name, (content) => {
20
+ this.setContent(context, instance, content);
21
+ });
22
+
23
+ if (this.scoped)
24
+ instance.unregisterContentPlaceholder = () => {
25
+ context.popNamedValue("contentPlaceholder", data.name);
26
+ };
27
+
28
+ super.explore(context, instance);
29
+ }
30
+
31
+ prepare(context, instance) {
32
+ let { content } = instance;
33
+ if (this.allowMultiple) {
34
+ let contentId = "";
35
+ let shouldUpdate = false;
36
+ if (content) {
37
+ for (let i = 0; i < content.length; i++) {
38
+ let c = content[i];
39
+ contentId += c.id + "+";
40
+ shouldUpdate = shouldUpdate || c.shouldUpdate;
41
+ }
42
+ }
43
+ if (instance.cache("content", contentId) || shouldUpdate) instance.markShouldUpdate(context);
44
+ } else if (instance.cache("content", content) || (content && content.shouldUpdate))
45
+ instance.markShouldUpdate(context);
46
+ }
47
+
48
+ setContent(context, instance, content) {
49
+ if (this.allowMultiple) {
50
+ if (instance.content == null) instance.content = [];
51
+ instance.content.push(content);
52
+ } else instance.content = content;
53
+ content.contentPlaceholder = instance;
54
+ }
55
+
56
+ render(context, instance, key) {
57
+ const { content } = instance;
58
+ if (!content) return super.render(context, instance, key);
59
+ if (this.allowMultiple) return content.map((x) => x.contentVDOM);
60
+ return content.contentVDOM;
61
+ }
62
+ }
63
+
64
+ ContentPlaceholder.prototype.name = "body";
65
+ ContentPlaceholder.prototype.scoped = false;
66
+ ContentPlaceholder.prototype.allowMultiple = false;
67
+
68
+ Widget.alias("content-placeholder", ContentPlaceholder);
69
+
70
+ export class ContentPlaceholderScope extends PureContainer {
71
+ init() {
72
+ super.init();
73
+
74
+ if (isString(this.name)) this.name = [this.name];
75
+ }
76
+
77
+ explore(context, instance) {
78
+ this.name.forEach((name) => {
79
+ context.pushNamedValue("contentPlaceholder", name, null);
80
+ context.pushNamedValue("content", name, null);
81
+ });
82
+ super.explore(context, instance);
83
+ }
84
+
85
+ exploreCleanup(context, instance) {
86
+ this.name.forEach((name) => {
87
+ context.popNamedValue("contentPlaceholder", name);
88
+ context.popNamedValue("content", name);
89
+ });
90
+ }
91
+ }