cx 23.12.3 → 24.0.0

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
@@ -1465,60 +1465,91 @@ var ZIndexManager = /*#__PURE__*/ (function () {
1465
1465
 
1466
1466
  var Format = Format$1;
1467
1467
  var cultureSensitiveFormatsRegistered = false;
1468
+ function resolveNumberFormattingFlags(flags) {
1469
+ if (!flags) return null;
1470
+ var result = {};
1471
+ if (flags.indexOf("+") >= 0) result.signDisplay = "exceptZero";
1472
+ if (flags.indexOf("c") >= 0) result.notation = "compact";
1473
+ if (flags.indexOf("a") >= 0) result.currencySign = "accounting";
1474
+ return result;
1475
+ }
1468
1476
  function enableCultureSensitiveFormatting() {
1469
1477
  if (cultureSensitiveFormatsRegistered) return;
1470
1478
  cultureSensitiveFormatsRegistered = true;
1471
- Format$1.registerFactory(["number", "n"], function (format, minimumFractionDigits, maximumFractionDigits) {
1472
- var culture = Culture.getNumberCulture();
1473
- var formatter = culture.getFormatter(resolveMinMaxFractionDigits(minimumFractionDigits, maximumFractionDigits));
1474
- return function (value) {
1475
- return formatter.format(value);
1476
- };
1477
- });
1478
- Format$1.registerFactory("currency", function (format, currency, minimumFractionDigits, maximumFractionDigits) {
1479
- var culture = Culture.getNumberCulture();
1480
- currency = currency || Culture.defaultCurrency;
1481
- var formatter = culture.getFormatter(
1482
- _objectSpread2(
1483
- {
1484
- style: "currency",
1485
- currency: currency,
1486
- },
1487
- resolveMinMaxFractionDigits(minimumFractionDigits, maximumFractionDigits)
1488
- )
1489
- );
1490
- return function (value) {
1491
- return formatter.format(value);
1492
- };
1493
- });
1494
- Format$1.registerFactory(["percentage", "p", "%"], function (format, minimumFractionDigits, maximumFractionDigits) {
1479
+ Format$1.registerFactory(["number", "n"], function (format, minimumFractionDigits, maximumFractionDigits, flags) {
1495
1480
  var culture = Culture.getNumberCulture();
1496
1481
  var formatter = culture.getFormatter(
1497
1482
  _objectSpread2(
1498
- {
1499
- style: "percent",
1500
- },
1501
- resolveMinMaxFractionDigits(minimumFractionDigits, maximumFractionDigits)
1483
+ _objectSpread2({}, resolveMinMaxFractionDigits(minimumFractionDigits, maximumFractionDigits)),
1484
+ resolveNumberFormattingFlags(flags)
1502
1485
  )
1503
1486
  );
1504
1487
  return function (value) {
1505
1488
  return formatter.format(value);
1506
1489
  };
1507
1490
  });
1508
- Format$1.registerFactory(["percentSign", "ps"], function (format, minimumFractionDigits, maximumFractionDigits) {
1509
- var culture = Culture.getNumberCulture();
1510
- var formatter = culture.getFormatter(
1511
- _objectSpread2(
1512
- {
1513
- style: "percent",
1514
- },
1515
- resolveMinMaxFractionDigits(minimumFractionDigits, maximumFractionDigits)
1516
- )
1517
- );
1518
- return function (value) {
1519
- return formatter.format(value / 100);
1520
- };
1521
- });
1491
+ Format$1.registerFactory(
1492
+ "currency",
1493
+ function (format, currency, minimumFractionDigits, maximumFractionDigits, flags) {
1494
+ var culture = Culture.getNumberCulture();
1495
+ currency = currency || Culture.defaultCurrency;
1496
+ var formatter = culture.getFormatter(
1497
+ _objectSpread2(
1498
+ _objectSpread2(
1499
+ {
1500
+ style: "currency",
1501
+ currency: currency,
1502
+ },
1503
+ resolveMinMaxFractionDigits(minimumFractionDigits, maximumFractionDigits)
1504
+ ),
1505
+ resolveNumberFormattingFlags(flags)
1506
+ )
1507
+ );
1508
+ return function (value) {
1509
+ return formatter.format(value);
1510
+ };
1511
+ }
1512
+ );
1513
+ Format$1.registerFactory(
1514
+ ["percentage", "p", "%"],
1515
+ function (format, minimumFractionDigits, maximumFractionDigits, flags) {
1516
+ var culture = Culture.getNumberCulture();
1517
+ var formatter = culture.getFormatter(
1518
+ _objectSpread2(
1519
+ _objectSpread2(
1520
+ {
1521
+ style: "percent",
1522
+ },
1523
+ resolveMinMaxFractionDigits(minimumFractionDigits, maximumFractionDigits)
1524
+ ),
1525
+ resolveNumberFormattingFlags(flags)
1526
+ )
1527
+ );
1528
+ return function (value) {
1529
+ return formatter.format(value);
1530
+ };
1531
+ }
1532
+ );
1533
+ Format$1.registerFactory(
1534
+ ["percentSign", "ps"],
1535
+ function (format, minimumFractionDigits, maximumFractionDigits, flags) {
1536
+ var culture = Culture.getNumberCulture();
1537
+ var formatter = culture.getFormatter(
1538
+ _objectSpread2(
1539
+ _objectSpread2(
1540
+ {
1541
+ style: "percent",
1542
+ },
1543
+ resolveMinMaxFractionDigits(minimumFractionDigits, maximumFractionDigits)
1544
+ ),
1545
+ resolveNumberFormattingFlags(flags)
1546
+ )
1547
+ );
1548
+ return function (value) {
1549
+ return formatter.format(value / 100);
1550
+ };
1551
+ }
1552
+ );
1522
1553
  Format$1.registerFactory(["date", "d"], function (fmt, format) {
1523
1554
  if (format === void 0) {
1524
1555
  format = "yyyyMMdd";
@@ -4458,6 +4489,7 @@ export {
4458
4489
  preventFocus,
4459
4490
  preventFocusOnTouch,
4460
4491
  registerKeyboardShortcut,
4492
+ resolveNumberFormattingFlags,
4461
4493
  startAppLoop,
4462
4494
  startHotAppLoop,
4463
4495
  tpl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "23.12.3",
3
+ "version": "24.0.0",
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",
@@ -1,71 +1,71 @@
1
- import { VDOM } from "../ui/Widget";
2
- import { BoundedObject } from "../svg/BoundedObject";
3
- import { Rect } from "../svg/util/Rect";
4
- import { parseStyle } from "../util/parseStyle";
5
-
6
- export class PieLabel extends BoundedObject {
7
- init() {
8
- this.lineStyle = parseStyle(this.lineStyle);
9
- super.init();
10
- }
11
-
12
- declareData(...args) {
13
- super.declareData(...args, {
14
- distance: undefined,
15
- lineStyle: { structured: true },
16
- lineStroke: undefined,
17
- lineClass: { structured: true },
18
- lineColorIndex: undefined,
19
- });
20
- }
21
-
22
- calculateBounds(context, instance) {
23
- var { data } = instance;
24
- var bounds = Rect.add(Rect.add(Rect.multiply(instance.parentRect, data.anchors), data.offset), data.margin);
25
- instance.originalBounds = bounds;
26
- instance.actualBounds = context.placePieLabel(bounds, data.distance);
27
- return new Rect({ t: 0, r: bounds.width(), b: bounds.height(), l: 0 });
28
- }
29
-
30
- prepare(context, instance) {
31
- super.prepare(context, instance);
32
- if (!context.registerPieLabel)
33
- throw new Error("PieLabel components are allowed only within PieLabelsContainer components.");
34
- let right = instance.parentRect.r > instance.parentRect.l;
35
- context.push("textDirection", right ? "right" : "left");
36
- context.registerPieLabel(instance);
37
- }
38
-
39
- prepareCleanup(context, instance) {
40
- context.pop("textDirection");
41
- }
42
-
43
- render(context, instance, key) {
44
- let { originalBounds, actualBounds, data } = instance;
45
-
46
- return (
47
- <g key={key} className={data.classNames}>
48
- <line
49
- className={this.CSS.element(
50
- this.baseClass,
51
- "line",
52
- data.lineColorIndex != null && "color-" + data.lineColorIndex
53
- )}
54
- x1={actualBounds.l < originalBounds.l ? actualBounds.r : actualBounds.l}
55
- y1={(actualBounds.t + actualBounds.b) / 2}
56
- x2={(originalBounds.l + originalBounds.r) / 2}
57
- y2={(originalBounds.t + originalBounds.b) / 2}
58
- stroke={data.lineStroke}
59
- style={data.lineStyle}
60
- />
61
- <g transform={`translate(${instance.actualBounds.l} ${instance.actualBounds.t})`}>
62
- {this.renderChildren(context, instance)}
63
- </g>
64
- </g>
65
- );
66
- }
67
- }
68
-
69
- PieLabel.prototype.distance = 100;
70
- PieLabel.prototype.baseClass = "pielabel";
71
- PieLabel.prototype.styled = true;
1
+ import { VDOM } from "../ui/Widget";
2
+ import { BoundedObject } from "../svg/BoundedObject";
3
+ import { Rect } from "../svg/util/Rect";
4
+ import { parseStyle } from "../util/parseStyle";
5
+
6
+ export class PieLabel extends BoundedObject {
7
+ init() {
8
+ this.lineStyle = parseStyle(this.lineStyle);
9
+ super.init();
10
+ }
11
+
12
+ declareData(...args) {
13
+ super.declareData(...args, {
14
+ distance: undefined,
15
+ lineStyle: { structured: true },
16
+ lineStroke: undefined,
17
+ lineClass: { structured: true },
18
+ lineColorIndex: undefined,
19
+ });
20
+ }
21
+
22
+ calculateBounds(context, instance) {
23
+ var { data } = instance;
24
+ var bounds = Rect.add(Rect.add(Rect.multiply(instance.parentRect, data.anchors), data.offset), data.margin);
25
+ instance.originalBounds = bounds;
26
+ instance.actualBounds = context.placePieLabel(bounds, data.distance);
27
+ return new Rect({ t: 0, r: bounds.width(), b: bounds.height(), l: 0 });
28
+ }
29
+
30
+ prepare(context, instance) {
31
+ super.prepare(context, instance);
32
+ if (!context.registerPieLabel)
33
+ throw new Error("PieLabel components are allowed only within PieLabelsContainer components.");
34
+ let right = instance.parentRect.r > instance.parentRect.l;
35
+ context.push("textDirection", right ? "right" : "left");
36
+ context.registerPieLabel(instance);
37
+ }
38
+
39
+ prepareCleanup(context, instance) {
40
+ context.pop("textDirection");
41
+ }
42
+
43
+ render(context, instance, key) {
44
+ let { originalBounds, actualBounds, data } = instance;
45
+
46
+ return (
47
+ <g key={key} className={data.classNames}>
48
+ <line
49
+ className={this.CSS.element(
50
+ this.baseClass,
51
+ "line",
52
+ data.lineColorIndex != null && "color-" + data.lineColorIndex
53
+ )}
54
+ x1={actualBounds.l < originalBounds.l ? actualBounds.r : actualBounds.l}
55
+ y1={(actualBounds.t + actualBounds.b) / 2}
56
+ x2={(originalBounds.l + originalBounds.r) / 2}
57
+ y2={(originalBounds.t + originalBounds.b) / 2}
58
+ stroke={data.lineStroke}
59
+ style={data.lineStyle}
60
+ />
61
+ <g transform={`translate(${instance.actualBounds.l} ${instance.actualBounds.t})`}>
62
+ {this.renderChildren(context, instance)}
63
+ </g>
64
+ </g>
65
+ );
66
+ }
67
+ }
68
+
69
+ PieLabel.prototype.distance = 100;
70
+ PieLabel.prototype.baseClass = "pielabel";
71
+ PieLabel.prototype.styled = true;
@@ -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 {}