cx 26.2.1 → 26.2.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/build/charts/Chart.d.ts.map +1 -1
- package/build/charts/Chart.js +5 -4
- package/build/charts/ColumnBarBase.d.ts +3 -3
- package/build/charts/ColumnBarBase.d.ts.map +1 -1
- package/build/charts/ColumnBarBase.js +1 -1
- package/build/charts/Legend.d.ts.map +1 -1
- package/build/charts/Legend.js +11 -4
- package/build/charts/Marker.d.ts +3 -3
- package/build/charts/Marker.d.ts.map +1 -1
- package/build/charts/MarkerLine.d.ts +7 -7
- package/build/charts/MarkerLine.d.ts.map +1 -1
- package/build/charts/MarkerLine.js +14 -10
- package/build/charts/PieChart.d.ts +4 -4
- package/build/charts/PieChart.d.ts.map +1 -1
- package/build/charts/PieChart.js +36 -14
- package/build/charts/PieLabel.d.ts.map +1 -1
- package/build/charts/PieLabel.js +2 -1
- package/build/charts/RangeMarker.d.ts +3 -3
- package/build/charts/RangeMarker.d.ts.map +1 -1
- package/build/charts/RangeMarker.js +1 -1
- package/build/charts/axis/TimeAxis.d.ts +3 -3
- package/build/charts/axis/TimeAxis.d.ts.map +1 -1
- package/build/charts/axis/TimeAxis.js +70 -21
- package/build/charts/helpers/ValueAtFinder.d.ts +1 -1
- package/build/charts/helpers/ValueAtFinder.d.ts.map +1 -1
- package/build/charts/helpers/ValueAtFinder.js +5 -2
- package/build/data/StructuredSelector.js +3 -4
- package/build/data/createAccessorModelProxy.d.ts +6 -11
- package/build/data/createAccessorModelProxy.d.ts.map +1 -1
- package/build/data/createAccessorModelProxy.js +1 -3
- package/build/svg/Ellipse.d.ts +5 -4
- package/build/svg/Ellipse.d.ts.map +1 -1
- package/build/svg/Ellipse.js +9 -6
- package/build/svg/Line.d.ts +1 -0
- package/build/svg/Line.d.ts.map +1 -1
- package/build/svg/Line.js +4 -1
- package/build/svg/Text.d.ts +12 -6
- package/build/svg/Text.d.ts.map +1 -1
- package/build/svg/Text.js +12 -4
- package/build/ui/Controller.d.ts +2 -0
- package/build/ui/Controller.d.ts.map +1 -1
- package/build/ui/Controller.js +3 -0
- package/build/ui/HoverSync.d.ts.map +1 -1
- package/build/ui/HoverSync.js +7 -2
- package/build/ui/Prop.d.ts +1 -1
- package/build/ui/Prop.d.ts.map +1 -1
- package/build/ui/Text.d.ts +3 -3
- package/build/ui/Text.d.ts.map +1 -1
- package/build/ui/Text.js +5 -5
- package/build/ui/adapter/GroupAdapter.d.ts.map +1 -1
- package/build/ui/adapter/GroupAdapter.js +20 -10
- package/build/ui/app/History.js +1 -1
- package/build/widgets/List.d.ts.map +1 -1
- package/build/widgets/List.js +6 -7
- package/build/widgets/drag-drop/DropZone.d.ts +3 -3
- package/build/widgets/drag-drop/DropZone.d.ts.map +1 -1
- package/build/widgets/form/Calendar.d.ts.map +1 -1
- package/build/widgets/form/Calendar.js +30 -11
- package/build/widgets/form/ColorField.d.ts.map +1 -1
- package/build/widgets/form/ColorField.js +16 -7
- package/build/widgets/form/DateTimeField.d.ts.map +1 -1
- package/build/widgets/form/DateTimeField.js +23 -10
- package/build/widgets/form/Field.d.ts +2 -0
- package/build/widgets/form/Field.d.ts.map +1 -1
- package/build/widgets/form/Field.js +11 -5
- package/build/widgets/form/LookupField.d.ts +1 -1
- package/build/widgets/form/LookupField.d.ts.map +1 -1
- package/build/widgets/form/LookupField.js +6 -6
- package/build/widgets/form/MonthField.d.ts.map +1 -1
- package/build/widgets/form/MonthField.js +15 -7
- package/build/widgets/form/MonthPicker.d.ts +1 -2
- package/build/widgets/form/MonthPicker.d.ts.map +1 -1
- package/build/widgets/form/MonthPicker.js +84 -41
- package/build/widgets/form/NumberField.d.ts +2 -0
- package/build/widgets/form/NumberField.d.ts.map +1 -1
- package/build/widgets/form/NumberField.js +45 -15
- package/build/widgets/form/TextField.d.ts +1 -9
- package/build/widgets/form/TextField.d.ts.map +1 -1
- package/build/widgets/form/TextField.js +1 -1
- package/build/widgets/grid/Grid.d.ts +2 -2
- package/build/widgets/grid/Grid.d.ts.map +1 -1
- package/build/widgets/grid/Grid.js +9 -4
- package/build/widgets/grid/Pagination.d.ts.map +1 -1
- package/build/widgets/grid/Pagination.js +4 -4
- package/build/widgets/grid/TreeNode.d.ts.map +1 -1
- package/build/widgets/grid/TreeNode.js +10 -2
- package/build/widgets/icons/folder.d.ts.map +1 -1
- package/build/widgets/icons/folder.js +1 -0
- package/build/widgets/icons/forward.d.ts.map +1 -1
- package/build/widgets/icons/forward.js +4 -3
- package/build/widgets/icons/loading.d.ts.map +1 -1
- package/build/widgets/icons/loading.js +6 -5
- package/build/widgets/icons/square.d.ts.map +1 -1
- package/build/widgets/icons/square.js +3 -3
- package/build/widgets/index.d.ts +3 -1
- package/build/widgets/index.d.ts.map +1 -1
- package/build/widgets/index.js +3 -1
- package/build/widgets/overlay/ContextMenu.d.ts.map +1 -1
- package/build/widgets/overlay/ContextMenu.js +2 -0
- package/build/widgets/overlay/Dropdown.d.ts +2 -1
- package/build/widgets/overlay/Dropdown.d.ts.map +1 -1
- package/build/widgets/overlay/Dropdown.js +75 -20
- package/build/widgets/overlay/MsgBox.d.ts +1 -0
- package/build/widgets/overlay/MsgBox.d.ts.map +1 -1
- package/build/widgets/overlay/MsgBox.js +2 -2
- package/build/widgets/overlay/Overlay.d.ts +32 -2
- package/build/widgets/overlay/Overlay.d.ts.map +1 -1
- package/build/widgets/overlay/Overlay.js +47 -16
- package/build/widgets/overlay/Toast.d.ts +1 -1
- package/build/widgets/overlay/Toast.d.ts.map +1 -1
- package/build/widgets/overlay/Toast.js +4 -1
- package/build/widgets/overlay/Tooltip.d.ts +6 -0
- package/build/widgets/overlay/Tooltip.d.ts.map +1 -1
- package/build/widgets/overlay/Tooltip.js +24 -9
- package/build/widgets/overlay/Window.d.ts.map +1 -1
- package/build/widgets/overlay/Window.js +24 -9
- package/dist/charts.css +325 -272
- package/dist/charts.js +11 -5
- package/dist/data.js +2 -2
- package/dist/manifest.js +892 -880
- package/dist/svg.css +14 -8
- package/dist/svg.js +9 -1
- package/dist/ui.js +29 -16
- package/dist/widgets.css +997 -294
- package/dist/widgets.js +317 -121
- package/package.json +1 -1
- package/src/charts/Bar.scss +13 -10
- package/src/charts/BarGraph.scss +31 -29
- package/src/charts/BubbleGraph.scss +11 -8
- package/src/charts/Chart.ts +5 -3
- package/src/charts/Column.scss +13 -10
- package/src/charts/ColumnBarBase.tsx +255 -230
- package/src/charts/ColumnGraph.scss +13 -11
- package/src/charts/Gridlines.scss +10 -8
- package/src/charts/Legend.scss +57 -50
- package/src/charts/Legend.tsx +257 -213
- package/src/charts/LegendEntry.scss +35 -29
- package/src/charts/LineGraph.scss +28 -25
- package/src/charts/Marker.scss +12 -10
- package/src/charts/Marker.tsx +3 -2
- package/src/charts/MarkerLine.scss +11 -8
- package/src/charts/MarkerLine.tsx +196 -177
- package/src/charts/PieChart.scss +12 -9
- package/src/charts/PieChart.tsx +717 -591
- package/src/charts/PieLabel.tsx +99 -81
- package/src/charts/Range.scss +11 -8
- package/src/charts/RangeMarker.tsx +204 -187
- package/src/charts/ScatterGraph.scss +12 -9
- package/src/charts/axis/Axis.scss +6 -5
- package/src/charts/axis/CategoryAxis.scss +10 -8
- package/src/charts/axis/NumericAxis.scss +9 -6
- package/src/charts/axis/TimeAxis.scss +9 -6
- package/src/charts/axis/TimeAxis.tsx +753 -637
- package/src/charts/axis/index.scss +4 -5
- package/src/charts/axis/variables.scss +4 -2
- package/src/charts/helpers/ValueAtFinder.ts +19 -5
- package/src/charts/index.scss +16 -19
- package/src/charts/maps.scss +0 -0
- package/src/charts/palette.scss +11 -31
- package/src/charts/palette.variables.scss +23 -0
- package/src/charts/variables.scss +35 -3
- package/src/data/StructuredSelector.ts +2 -2
- package/src/data/createAccessorModelProxy.ts +66 -74
- package/src/index.scss +5 -6
- package/src/maps.scss +5 -0
- package/src/svg/Ellipse.tsx +62 -55
- package/src/svg/Line.tsx +57 -42
- package/src/svg/Svg.scss +6 -6
- package/src/svg/Text.scss +19 -0
- package/src/svg/Text.tsx +172 -116
- package/src/svg/index.scss +3 -2
- package/src/svg/maps.scss +0 -0
- package/src/svg/variables.scss +0 -0
- package/src/ui/Container.spec.ts +59 -0
- package/src/ui/Controller.spec.tsx +30 -0
- package/src/ui/Controller.ts +5 -0
- package/src/ui/HoverSync.tsx +179 -147
- package/src/ui/Prop.ts +1 -1
- package/src/ui/Text.ts +12 -9
- package/src/ui/adapter/GroupAdapter.spec.ts +42 -0
- package/src/ui/adapter/GroupAdapter.ts +25 -14
- package/src/ui/app/History.ts +1 -1
- package/src/ui/index.scss +1 -1
- package/src/ui/layout/LabelsLeftLayout.scss +5 -7
- package/src/ui/layout/LabelsTopLayout.scss +4 -6
- package/src/ui/layout/index.scss +2 -3
- package/src/ui/maps.scss +0 -0
- package/src/ui/variables.scss +1 -2
- package/src/util/index.scss +4 -2
- package/src/util/maps.scss +1 -0
- package/src/util/scss/besm.scss +15 -0
- package/src/util/scss/calc.scss +103 -11
- package/src/util/scss/defaults.scss +24 -0
- package/src/util/scss/elements.scss +78 -0
- package/src/util/scss/global.scss +15 -0
- package/src/util/scss/include.scss +17 -9
- package/src/util/scss/index.scss +1 -9
- package/src/util/scss/maps.scss +2 -0
- package/src/util/scss/pad-size.scss +9 -0
- package/src/util/scss/padding.scss +6 -0
- package/src/util/scss/screen-size.scss +5 -0
- package/src/util/scss/variables.scss +6 -0
- package/src/util/variables.scss +1 -0
- package/src/variables.scss +5 -217
- package/src/widgets/Button.maps.scss +103 -0
- package/src/widgets/Button.scss +33 -9
- package/src/widgets/Button.variables.scss +8 -104
- package/src/widgets/CxCredit.scss +2 -0
- package/src/widgets/FlexBox.scss +16 -11
- package/src/widgets/Heading.scss +6 -0
- package/src/widgets/HighlightedSearchText.scss +8 -1
- package/src/widgets/Icon.scss +6 -0
- package/src/widgets/List.scss +7 -0
- package/src/widgets/List.tsx +6 -7
- package/src/widgets/ProgressBar.scss +9 -0
- package/src/widgets/Resizer.scss +9 -7
- package/src/widgets/Section.scss +53 -56
- package/src/widgets/animations.scss +4 -2
- package/src/widgets/box.scss +47 -0
- package/src/widgets/drag-drop/DragClone.scss +12 -4
- package/src/widgets/drag-drop/DragHandle.scss +12 -6
- package/src/widgets/drag-drop/DragSource.scss +12 -6
- package/src/widgets/drag-drop/DropZone.scss +9 -0
- package/src/widgets/drag-drop/DropZone.tsx +3 -3
- package/src/widgets/drag-drop/index.scss +4 -4
- package/src/widgets/drag-drop/maps.scss +7 -0
- package/src/widgets/drag-drop/variables.scss +8 -5
- package/src/widgets/form/Calendar.maps.scss +54 -0
- package/src/widgets/form/Calendar.scss +49 -11
- package/src/widgets/form/Calendar.tsx +755 -653
- package/src/widgets/form/Calendar.variables.scss +3 -46
- package/src/widgets/form/Checkbox.maps.scss +34 -0
- package/src/widgets/form/Checkbox.scss +14 -3
- package/src/widgets/form/Checkbox.variables.scss +4 -36
- package/src/widgets/form/ColorField.scss +21 -2
- package/src/widgets/form/ColorField.tsx +485 -431
- package/src/widgets/form/ColorPicker.maps.scss +21 -0
- package/src/widgets/form/ColorPicker.scss +26 -9
- package/src/widgets/form/ColorPicker.variables.scss +3 -16
- package/src/widgets/form/DateTimeField.scss +54 -21
- package/src/widgets/form/DateTimeField.tsx +697 -615
- package/src/widgets/form/DateTimePicker.scss +14 -4
- package/src/widgets/form/Field.maps.scss +122 -0
- package/src/widgets/form/Field.scss +54 -18
- package/src/widgets/form/Field.tsx +611 -504
- package/src/widgets/form/Field.variables.scss +46 -0
- package/src/widgets/form/HelpText.scss +8 -5
- package/src/widgets/form/Label.scss +10 -3
- package/src/widgets/form/LookupField.maps.scss +26 -0
- package/src/widgets/form/LookupField.scss +54 -24
- package/src/widgets/form/LookupField.tsx +25 -21
- package/src/widgets/form/MonthField.scss +48 -26
- package/src/widgets/form/MonthField.tsx +645 -567
- package/src/widgets/form/MonthPicker.maps.scss +50 -0
- package/src/widgets/form/MonthPicker.scss +44 -35
- package/src/widgets/form/MonthPicker.tsx +954 -724
- package/src/widgets/form/MonthPicker.variables.scss +24 -0
- package/src/widgets/form/NumberField.scss +19 -2
- package/src/widgets/form/NumberField.tsx +576 -466
- package/src/widgets/form/Radio.maps.scss +36 -0
- package/src/widgets/form/Radio.scss +12 -2
- package/src/widgets/form/Radio.variables.scss +3 -42
- package/src/widgets/form/Select.scss +25 -9
- package/src/widgets/form/Slider.scss +23 -14
- package/src/widgets/form/Switch.scss +18 -8
- package/src/widgets/form/TextArea.scss +14 -1
- package/src/widgets/form/TextField.scss +24 -3
- package/src/widgets/form/TextField.tsx +9 -21
- package/src/widgets/form/UploadButton.scss +14 -6
- package/src/widgets/form/ValidationError.scss +10 -6
- package/src/widgets/form/Wheel.scss +14 -4
- package/src/widgets/form/index.scss +22 -24
- package/src/widgets/form/maps.scss +81 -0
- package/src/widgets/form/variables.scss +111 -355
- package/src/widgets/grid/Grid.scss +19 -2
- package/src/widgets/grid/Grid.spec.ts +42 -0
- package/src/widgets/grid/Grid.tsx +15 -7
- package/src/widgets/grid/Pagination.scss +11 -2
- package/src/widgets/grid/Pagination.tsx +110 -102
- package/src/widgets/grid/TreeNode.scss +25 -8
- package/src/widgets/grid/TreeNode.tsx +127 -116
- package/src/widgets/grid/index.scss +3 -4
- package/src/widgets/grid/maps.scss +110 -0
- package/src/widgets/grid/variables.scss +48 -137
- package/src/widgets/icons/folder.tsx +1 -2
- package/src/widgets/icons/forward.tsx +23 -20
- package/src/widgets/icons/loading.tsx +22 -19
- package/src/widgets/icons/square.tsx +20 -17
- package/src/widgets/index.scss +16 -16
- package/src/widgets/index.ts +63 -58
- package/src/widgets/lists.scss +42 -0
- package/src/widgets/maps.scss +139 -0
- package/src/widgets/nav/Link.scss +14 -1
- package/src/widgets/nav/Menu.scss +13 -7
- package/src/widgets/nav/Menu.variables.scss +1 -12
- package/src/widgets/nav/MenuItem.scss +21 -6
- package/src/widgets/nav/Scroller.scss +11 -2
- package/src/widgets/nav/Tab.maps.scss +78 -0
- package/src/widgets/nav/Tab.scss +12 -6
- package/src/widgets/nav/Tab.variables.scss +7 -76
- package/src/widgets/nav/cover.scss +6 -4
- package/src/widgets/nav/index.scss +6 -6
- package/src/widgets/nav/maps.scss +32 -0
- package/src/widgets/nav/variables.scss +4 -11
- package/src/widgets/overlay/ContextMenu.ts +3 -0
- package/src/widgets/overlay/Dropdown.scss +47 -16
- package/src/widgets/overlay/Dropdown.tsx +851 -676
- package/src/widgets/overlay/MsgBox.tsx +125 -111
- package/src/widgets/overlay/Overlay.scss +60 -40
- package/src/widgets/overlay/Overlay.tsx +948 -800
- package/src/widgets/overlay/Toast.scss +42 -34
- package/src/widgets/overlay/Toast.ts +11 -1
- package/src/widgets/overlay/Tooltip.scss +27 -96
- package/src/widgets/overlay/Tooltip.tsx +376 -309
- package/src/widgets/overlay/Window.maps.scss +51 -0
- package/src/widgets/overlay/Window.scss +17 -17
- package/src/widgets/overlay/Window.tsx +291 -236
- package/src/widgets/overlay/Window.variables.scss +2 -43
- package/src/widgets/overlay/index.d.ts +11 -11
- package/src/widgets/overlay/index.scss +6 -15
- package/src/widgets/overlay/maps.scss +44 -0
- package/src/widgets/overlay/variables.scss +11 -42
- package/src/widgets/variables.scss +33 -117
- package/src/global.scss +0 -14
package/src/svg/Line.tsx
CHANGED
|
@@ -3,53 +3,68 @@ import { Instance } from "../ui/Instance";
|
|
|
3
3
|
import { RenderingContext } from "../ui/RenderingContext";
|
|
4
4
|
import { Widget } from "../ui/Widget";
|
|
5
5
|
import { NumberProp, StringProp } from "../ui/Prop";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
TextualBoundedObject,
|
|
8
|
+
TextualBoundedObjectConfig,
|
|
9
|
+
} from "./TextualBoundedObject";
|
|
7
10
|
|
|
8
11
|
export interface LineConfig extends TextualBoundedObjectConfig {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Index of the color in the default color palette. Setting this property will set
|
|
14
|
+
* both fill and stroke on the object. Use `style` or a CSS class to remove stroke or fill
|
|
15
|
+
* if they are not necessary.
|
|
16
|
+
*/
|
|
17
|
+
colorIndex?: NumberProp;
|
|
18
|
+
|
|
19
|
+
/** A color used to paint the outline of the box. */
|
|
20
|
+
stroke?: StringProp;
|
|
21
|
+
|
|
22
|
+
/** Base CSS class to be applied to the element. Defaults to `line`. */
|
|
23
|
+
baseClass?: string;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export class Line extends TextualBoundedObject {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
27
|
+
declare baseClass: string;
|
|
28
|
+
declare colorIndex?: NumberProp;
|
|
29
|
+
declare stroke?: StringProp;
|
|
30
|
+
|
|
31
|
+
constructor(config?: LineConfig) {
|
|
32
|
+
super(config);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declareData(...args: any[]) {
|
|
36
|
+
super.declareData(...args, {
|
|
37
|
+
colorIndex: undefined,
|
|
38
|
+
stroke: undefined,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
render(
|
|
43
|
+
context: RenderingContext,
|
|
44
|
+
instance: Instance & { colorIndex: number },
|
|
45
|
+
key: string,
|
|
46
|
+
) {
|
|
47
|
+
const { data, colorIndex } = instance;
|
|
48
|
+
const { bounds } = data;
|
|
49
|
+
return (
|
|
50
|
+
<g key={key} className={data.classNames}>
|
|
51
|
+
<line
|
|
52
|
+
className={this.CSS.element(
|
|
53
|
+
this.baseClass,
|
|
54
|
+
"line",
|
|
55
|
+
colorIndex != null && "color-" + colorIndex,
|
|
56
|
+
)}
|
|
57
|
+
x1={bounds.l}
|
|
58
|
+
y1={bounds.t}
|
|
59
|
+
x2={bounds.r}
|
|
60
|
+
y2={bounds.b}
|
|
61
|
+
style={data.style}
|
|
62
|
+
stroke={data.stroke}
|
|
63
|
+
/>
|
|
64
|
+
{this.renderChildren(context, instance)}
|
|
65
|
+
</g>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
53
68
|
}
|
|
54
69
|
|
|
55
70
|
Line.prototype.anchors = "0 1 1 0";
|
package/src/svg/Svg.scss
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
@use "sass:map";
|
|
2
|
+
@use "../util/scss/include.scss" as *;
|
|
3
|
+
@use "../util/scss/clockwise.scss" as *;
|
|
4
|
+
@use "../util/scss/besm.scss" as *;
|
|
2
5
|
|
|
3
|
-
@mixin cx-svg(
|
|
4
|
-
$name: 'svg',
|
|
5
|
-
$besm: $cx-besm
|
|
6
|
-
) {
|
|
6
|
+
@mixin cx-svg($name: "svg", $besm: $cx-besm) {
|
|
7
7
|
$block: map.get($besm, block);
|
|
8
8
|
$element: map.get($besm, element);
|
|
9
9
|
$state: map.get($besm, state);
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
@if (cx-should-include(
|
|
26
|
+
@if (cx-should-include("cx/svg/Svg")) {
|
|
27
27
|
@include cx-svg;
|
|
28
|
-
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@use "sass:map";
|
|
2
|
+
@use "../util/scss/besm.scss" as *;
|
|
3
|
+
@use "../util/scss/include.scss" as *;
|
|
4
|
+
|
|
5
|
+
@mixin cx-text($name: "text", $besm: $cx-besm) {
|
|
6
|
+
$block: map.get($besm, block);
|
|
7
|
+
$element: map.get($besm, element);
|
|
8
|
+
$state: map.get($besm, state);
|
|
9
|
+
$mod: map.get($besm, mod);
|
|
10
|
+
|
|
11
|
+
.#{$block}#{$name} {
|
|
12
|
+
fill: currentColor;
|
|
13
|
+
stroke: none;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@if (cx-should-include("cx/svg/Text")) {
|
|
18
|
+
@include cx-text;
|
|
19
|
+
}
|
package/src/svg/Text.tsx
CHANGED
|
@@ -6,129 +6,185 @@ import { Instance } from "../ui/Instance";
|
|
|
6
6
|
import { Prop, StringProp } from "../ui/Prop";
|
|
7
7
|
|
|
8
8
|
export interface TextConfig extends BoundedObjectConfig {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
9
|
+
/** Text to be displayed. */
|
|
10
|
+
value?: StringProp;
|
|
11
|
+
|
|
12
|
+
bind?: string;
|
|
13
|
+
tpl?: string;
|
|
14
|
+
expr?: string;
|
|
15
|
+
|
|
16
|
+
/** Offset along the x-axis. */
|
|
17
|
+
dx?: Prop<string | number>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Offset along the y-axis. This property is commonly used for vertical text alignment.
|
|
21
|
+
* Set dy="0.8em" to align the text with the top and dy="0.4em" to center it vertically.
|
|
22
|
+
*/
|
|
23
|
+
dy?: Prop<string | number>;
|
|
24
|
+
|
|
25
|
+
/** Used for horizontal text alignment. */
|
|
26
|
+
textAnchor?: Prop<"start" | "middle" | "end">;
|
|
27
|
+
|
|
28
|
+
/** Shorthand for textAnchor. */
|
|
29
|
+
ta?: Prop<"start" | "middle" | "end">;
|
|
30
|
+
|
|
31
|
+
/** Used for vertical text alignment. */
|
|
32
|
+
dominantBaseline?: Prop<
|
|
33
|
+
| "auto"
|
|
34
|
+
| "text-bottom"
|
|
35
|
+
| "alphabetic"
|
|
36
|
+
| "ideographic"
|
|
37
|
+
| "middle"
|
|
38
|
+
| "central"
|
|
39
|
+
| "mathematical"
|
|
40
|
+
| "hanging"
|
|
41
|
+
| "text-top"
|
|
42
|
+
>;
|
|
43
|
+
|
|
44
|
+
/** Shorthand for dominantBaseline. */
|
|
45
|
+
db?: Prop<
|
|
46
|
+
| "auto"
|
|
47
|
+
| "text-bottom"
|
|
48
|
+
| "alphabetic"
|
|
49
|
+
| "ideographic"
|
|
50
|
+
| "middle"
|
|
51
|
+
| "central"
|
|
52
|
+
| "mathematical"
|
|
53
|
+
| "hanging"
|
|
54
|
+
| "text-top"
|
|
55
|
+
>;
|
|
56
|
+
|
|
57
|
+
/** Sets text-body color. */
|
|
58
|
+
fill?: StringProp;
|
|
59
|
+
|
|
60
|
+
/** Sets text-outline color. */
|
|
61
|
+
stroke?: StringProp;
|
|
62
|
+
|
|
63
|
+
/** Base CSS class to be applied to the element. Defaults to `text`. */
|
|
64
|
+
baseClass?: string;
|
|
65
|
+
|
|
66
|
+
/** Set to true for the text to set the text anchor based on the direction of the parent element. See PieLabels example. */
|
|
67
|
+
autoTextAnchor?: boolean;
|
|
42
68
|
}
|
|
43
69
|
|
|
44
70
|
export class Text extends BoundedObject<TextConfig> {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
);
|
|
126
|
-
|
|
71
|
+
constructor(config?: TextConfig) {
|
|
72
|
+
super(config);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
declare value?: StringProp;
|
|
76
|
+
declare bind?: string;
|
|
77
|
+
declare tpl?: string;
|
|
78
|
+
declare expr?: string;
|
|
79
|
+
declare dx?: Prop<string | number>;
|
|
80
|
+
declare dy?: Prop<string | number>;
|
|
81
|
+
declare textAnchor?: Prop<"start" | "middle" | "end">;
|
|
82
|
+
declare ta?: Prop<"start" | "middle" | "end">;
|
|
83
|
+
declare dominantBaseline?: Prop<
|
|
84
|
+
| "auto"
|
|
85
|
+
| "text-bottom"
|
|
86
|
+
| "alphabetic"
|
|
87
|
+
| "ideographic"
|
|
88
|
+
| "middle"
|
|
89
|
+
| "central"
|
|
90
|
+
| "mathematical"
|
|
91
|
+
| "hanging"
|
|
92
|
+
| "text-top"
|
|
93
|
+
>;
|
|
94
|
+
declare db?: Prop<
|
|
95
|
+
| "auto"
|
|
96
|
+
| "text-bottom"
|
|
97
|
+
| "alphabetic"
|
|
98
|
+
| "ideographic"
|
|
99
|
+
| "middle"
|
|
100
|
+
| "central"
|
|
101
|
+
| "mathematical"
|
|
102
|
+
| "hanging"
|
|
103
|
+
| "text-top"
|
|
104
|
+
>;
|
|
105
|
+
declare fill?: StringProp;
|
|
106
|
+
declare stroke?: StringProp;
|
|
107
|
+
declare autoTextAnchor?: boolean;
|
|
108
|
+
|
|
109
|
+
declareData(...args: any[]) {
|
|
110
|
+
return super.declareData(...args, {
|
|
111
|
+
value: undefined,
|
|
112
|
+
dx: undefined,
|
|
113
|
+
dy: undefined,
|
|
114
|
+
textAnchor: undefined,
|
|
115
|
+
dominantBaseline: undefined,
|
|
116
|
+
fill: undefined,
|
|
117
|
+
stroke: undefined,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
init() {
|
|
122
|
+
if (this.ta) this.textAnchor = this.ta;
|
|
123
|
+
if (this.db) this.dominantBaseline = this.db;
|
|
124
|
+
|
|
125
|
+
if (this.bind) {
|
|
126
|
+
this.value = {
|
|
127
|
+
bind: this.bind,
|
|
128
|
+
} as any;
|
|
129
|
+
} else if (this.tpl) {
|
|
130
|
+
this.value = {
|
|
131
|
+
tpl: this.tpl,
|
|
132
|
+
} as any;
|
|
133
|
+
} else if (this.expr) {
|
|
134
|
+
this.value = {
|
|
135
|
+
expr: this.expr,
|
|
136
|
+
} as any;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
super.init();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
prepare(context: RenderingContext, instance: Instance) {
|
|
143
|
+
if (this.autoTextAnchor) {
|
|
144
|
+
(instance as any).textAnchor =
|
|
145
|
+
context.textDirection == "right"
|
|
146
|
+
? "start"
|
|
147
|
+
: context.textDirection == "left"
|
|
148
|
+
? "end"
|
|
149
|
+
: this.textAnchor;
|
|
150
|
+
let changed = instance.cache("textAnchor", (instance as any).textAnchor);
|
|
151
|
+
if (changed) (instance as any).markShouldUpdate(context);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
super.prepare(context, instance);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
render(context: RenderingContext, instance: Instance, key: string) {
|
|
158
|
+
const { data } = instance;
|
|
159
|
+
const { bounds } = data;
|
|
160
|
+
|
|
161
|
+
let textAnchor = this.autoTextAnchor
|
|
162
|
+
? (instance as any).textAnchor
|
|
163
|
+
: data.textAnchor;
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<text
|
|
167
|
+
key={key}
|
|
168
|
+
className={data.classNames}
|
|
169
|
+
x={this.autoTextAnchor && textAnchor == "end" ? bounds.r : bounds.l}
|
|
170
|
+
y={bounds.t}
|
|
171
|
+
dx={data.dx}
|
|
172
|
+
dy={data.dy}
|
|
173
|
+
textAnchor={textAnchor}
|
|
174
|
+
dominantBaseline={data.dominantBaseline}
|
|
175
|
+
style={data.style}
|
|
176
|
+
fill={data.fill}
|
|
177
|
+
stroke={data.stroke}
|
|
178
|
+
>
|
|
179
|
+
{data.value}
|
|
180
|
+
{this.renderChildren(context, instance)}
|
|
181
|
+
</text>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
127
184
|
}
|
|
128
185
|
|
|
129
186
|
Text.prototype.anchors = "0.5 0.5 0.5 0.5";
|
|
130
187
|
Text.prototype.baseClass = "text";
|
|
131
188
|
Text.prototype.autoTextAnchor = false;
|
|
132
|
-
(Text.prototype as any).autoAnchor = false;
|
|
133
189
|
|
|
134
190
|
Widget.alias("svg.text", Text);
|
package/src/svg/index.scss
CHANGED
|
File without changes
|
|
File without changes
|
package/src/ui/Container.spec.ts
CHANGED
|
@@ -1,5 +1,64 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
2
|
import { ContainerBase, ContainerConfig } from "./Container";
|
|
3
|
+
import { Store } from "../data";
|
|
4
|
+
import { Instance } from "./Instance";
|
|
5
|
+
import { RenderingContext } from "./RenderingContext";
|
|
6
|
+
import { HtmlElement } from "../widgets/HtmlElement";
|
|
7
|
+
import { Widget } from "./Widget";
|
|
8
|
+
|
|
9
|
+
function collectKeys(obj: any, path = "", result: Record<string, boolean> = {}, seen = new WeakSet()): Record<string, boolean> {
|
|
10
|
+
if (!obj || typeof obj !== "object" || seen.has(obj)) return result;
|
|
11
|
+
seen.add(obj);
|
|
12
|
+
for (const key of Object.keys(obj)) {
|
|
13
|
+
const fullPath = path ? `${path}.${key}` : key;
|
|
14
|
+
result[fullPath] = true;
|
|
15
|
+
collectKeys(obj[key], fullPath, result, seen);
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe("Container", function () {
|
|
21
|
+
it("should not mutate config during init", function () {
|
|
22
|
+
const config = {
|
|
23
|
+
type: HtmlElement,
|
|
24
|
+
tag: "div",
|
|
25
|
+
children: [
|
|
26
|
+
{ type: HtmlElement, tag: "span", text: "Hello" },
|
|
27
|
+
{ type: HtmlElement, tag: "span", text: "World" },
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const keysBefore = collectKeys(config);
|
|
32
|
+
|
|
33
|
+
const widget = Widget.create(config);
|
|
34
|
+
const store = new Store();
|
|
35
|
+
const context = new RenderingContext();
|
|
36
|
+
const instance = new Instance(widget, "1", null as any, store);
|
|
37
|
+
instance.init(context);
|
|
38
|
+
|
|
39
|
+
const keysAfter = collectKeys(config);
|
|
40
|
+
const newKeys = Object.keys(keysAfter).filter((k) => !keysBefore[k]);
|
|
41
|
+
|
|
42
|
+
assert.deepStrictEqual(newKeys, [], `Config was mutated. New keys: ${newKeys.join(", ")}`);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("should not use the same children array instance as config", function () {
|
|
46
|
+
const configChildren = [
|
|
47
|
+
{ type: HtmlElement, tag: "span", text: "Hello" },
|
|
48
|
+
{ type: HtmlElement, tag: "span", text: "World" },
|
|
49
|
+
];
|
|
50
|
+
const config = {
|
|
51
|
+
type: HtmlElement,
|
|
52
|
+
tag: "div",
|
|
53
|
+
children: configChildren,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const widget = Widget.create(config) as HtmlElement;
|
|
57
|
+
widget.init();
|
|
58
|
+
|
|
59
|
+
assert.notStrictEqual(widget.items, configChildren, "Widget should not use the same children array instance as config");
|
|
60
|
+
});
|
|
61
|
+
});
|
|
3
62
|
|
|
4
63
|
describe("ContainerConfig", function () {
|
|
5
64
|
describe("reserved props cannot be introduced by subclasses", function () {
|
|
@@ -431,6 +431,36 @@ describe("Controller", () => {
|
|
|
431
431
|
// let tree = component.toJSON();
|
|
432
432
|
assert.deepStrictEqual(testValid, [1, 2]);
|
|
433
433
|
});
|
|
434
|
+
|
|
435
|
+
it("getParentControllerByType returns typed parent controller", async () => {
|
|
436
|
+
let parentValue = 0;
|
|
437
|
+
|
|
438
|
+
class ParentController extends Controller {
|
|
439
|
+
getValue() {
|
|
440
|
+
return 42;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
class ChildController extends Controller {
|
|
445
|
+
onInit() {
|
|
446
|
+
let parent = this.getParentControllerByType(ParentController);
|
|
447
|
+
parentValue = parent.getValue();
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
let store = new Store();
|
|
452
|
+
|
|
453
|
+
const component = await createTestRenderer(
|
|
454
|
+
store,
|
|
455
|
+
<cx>
|
|
456
|
+
<div controller={ParentController}>
|
|
457
|
+
<div controller={ChildController} />
|
|
458
|
+
</div>
|
|
459
|
+
</cx>,
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
assert.equal(parentValue, 42);
|
|
463
|
+
});
|
|
434
464
|
});
|
|
435
465
|
|
|
436
466
|
describe("Controller types", () => {
|
package/src/ui/Controller.ts
CHANGED
|
@@ -24,6 +24,7 @@ export interface ControllerMethods {
|
|
|
24
24
|
instance: Instance;
|
|
25
25
|
widget?: Widget;
|
|
26
26
|
invokeParentMethod(method: string, ...args: any[]): any;
|
|
27
|
+
getParentControllerByType<T extends Controller>(type: new (...args: any[]) => T): T;
|
|
27
28
|
addTrigger<Selectors extends readonly ComputableSelector[]>(
|
|
28
29
|
name: string,
|
|
29
30
|
args: [...Selectors],
|
|
@@ -168,6 +169,10 @@ export class Controller<D = any> extends Component implements ControllerMethods
|
|
|
168
169
|
invokeMethod(methodName: string, ...args: any[]): any {
|
|
169
170
|
return this.instance.invokeControllerMethod(methodName, ...args);
|
|
170
171
|
}
|
|
172
|
+
|
|
173
|
+
getParentControllerByType<T extends Controller>(type: new (...args: any[]) => T): T {
|
|
174
|
+
return this.instance.getControllerByType(type);
|
|
175
|
+
}
|
|
171
176
|
}
|
|
172
177
|
|
|
173
178
|
Controller.namespace = "ui.controller.";
|