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.
Files changed (324) hide show
  1. package/build/charts/Chart.d.ts.map +1 -1
  2. package/build/charts/Chart.js +5 -4
  3. package/build/charts/ColumnBarBase.d.ts +3 -3
  4. package/build/charts/ColumnBarBase.d.ts.map +1 -1
  5. package/build/charts/ColumnBarBase.js +1 -1
  6. package/build/charts/Legend.d.ts.map +1 -1
  7. package/build/charts/Legend.js +11 -4
  8. package/build/charts/Marker.d.ts +3 -3
  9. package/build/charts/Marker.d.ts.map +1 -1
  10. package/build/charts/MarkerLine.d.ts +7 -7
  11. package/build/charts/MarkerLine.d.ts.map +1 -1
  12. package/build/charts/MarkerLine.js +14 -10
  13. package/build/charts/PieChart.d.ts +4 -4
  14. package/build/charts/PieChart.d.ts.map +1 -1
  15. package/build/charts/PieChart.js +36 -14
  16. package/build/charts/PieLabel.d.ts.map +1 -1
  17. package/build/charts/PieLabel.js +2 -1
  18. package/build/charts/RangeMarker.d.ts +3 -3
  19. package/build/charts/RangeMarker.d.ts.map +1 -1
  20. package/build/charts/RangeMarker.js +1 -1
  21. package/build/charts/axis/TimeAxis.d.ts +3 -3
  22. package/build/charts/axis/TimeAxis.d.ts.map +1 -1
  23. package/build/charts/axis/TimeAxis.js +70 -21
  24. package/build/charts/helpers/ValueAtFinder.d.ts +1 -1
  25. package/build/charts/helpers/ValueAtFinder.d.ts.map +1 -1
  26. package/build/charts/helpers/ValueAtFinder.js +5 -2
  27. package/build/data/StructuredSelector.js +3 -4
  28. package/build/data/createAccessorModelProxy.d.ts +6 -11
  29. package/build/data/createAccessorModelProxy.d.ts.map +1 -1
  30. package/build/data/createAccessorModelProxy.js +1 -3
  31. package/build/svg/Ellipse.d.ts +5 -4
  32. package/build/svg/Ellipse.d.ts.map +1 -1
  33. package/build/svg/Ellipse.js +9 -6
  34. package/build/svg/Line.d.ts +1 -0
  35. package/build/svg/Line.d.ts.map +1 -1
  36. package/build/svg/Line.js +4 -1
  37. package/build/svg/Text.d.ts +12 -6
  38. package/build/svg/Text.d.ts.map +1 -1
  39. package/build/svg/Text.js +12 -4
  40. package/build/ui/Controller.d.ts +2 -0
  41. package/build/ui/Controller.d.ts.map +1 -1
  42. package/build/ui/Controller.js +3 -0
  43. package/build/ui/HoverSync.d.ts.map +1 -1
  44. package/build/ui/HoverSync.js +7 -2
  45. package/build/ui/Prop.d.ts +1 -1
  46. package/build/ui/Prop.d.ts.map +1 -1
  47. package/build/ui/Text.d.ts +3 -3
  48. package/build/ui/Text.d.ts.map +1 -1
  49. package/build/ui/Text.js +5 -5
  50. package/build/ui/adapter/GroupAdapter.d.ts.map +1 -1
  51. package/build/ui/adapter/GroupAdapter.js +20 -10
  52. package/build/ui/app/History.js +1 -1
  53. package/build/widgets/List.d.ts.map +1 -1
  54. package/build/widgets/List.js +6 -7
  55. package/build/widgets/drag-drop/DropZone.d.ts +3 -3
  56. package/build/widgets/drag-drop/DropZone.d.ts.map +1 -1
  57. package/build/widgets/form/Calendar.d.ts.map +1 -1
  58. package/build/widgets/form/Calendar.js +30 -11
  59. package/build/widgets/form/ColorField.d.ts.map +1 -1
  60. package/build/widgets/form/ColorField.js +16 -7
  61. package/build/widgets/form/DateTimeField.d.ts.map +1 -1
  62. package/build/widgets/form/DateTimeField.js +23 -10
  63. package/build/widgets/form/Field.d.ts +2 -0
  64. package/build/widgets/form/Field.d.ts.map +1 -1
  65. package/build/widgets/form/Field.js +11 -5
  66. package/build/widgets/form/LookupField.d.ts +1 -1
  67. package/build/widgets/form/LookupField.d.ts.map +1 -1
  68. package/build/widgets/form/LookupField.js +6 -6
  69. package/build/widgets/form/MonthField.d.ts.map +1 -1
  70. package/build/widgets/form/MonthField.js +15 -7
  71. package/build/widgets/form/MonthPicker.d.ts +1 -2
  72. package/build/widgets/form/MonthPicker.d.ts.map +1 -1
  73. package/build/widgets/form/MonthPicker.js +84 -41
  74. package/build/widgets/form/NumberField.d.ts +2 -0
  75. package/build/widgets/form/NumberField.d.ts.map +1 -1
  76. package/build/widgets/form/NumberField.js +45 -15
  77. package/build/widgets/form/TextField.d.ts +1 -9
  78. package/build/widgets/form/TextField.d.ts.map +1 -1
  79. package/build/widgets/form/TextField.js +1 -1
  80. package/build/widgets/grid/Grid.d.ts +2 -2
  81. package/build/widgets/grid/Grid.d.ts.map +1 -1
  82. package/build/widgets/grid/Grid.js +9 -4
  83. package/build/widgets/grid/Pagination.d.ts.map +1 -1
  84. package/build/widgets/grid/Pagination.js +4 -4
  85. package/build/widgets/grid/TreeNode.d.ts.map +1 -1
  86. package/build/widgets/grid/TreeNode.js +10 -2
  87. package/build/widgets/icons/folder.d.ts.map +1 -1
  88. package/build/widgets/icons/folder.js +1 -0
  89. package/build/widgets/icons/forward.d.ts.map +1 -1
  90. package/build/widgets/icons/forward.js +4 -3
  91. package/build/widgets/icons/loading.d.ts.map +1 -1
  92. package/build/widgets/icons/loading.js +6 -5
  93. package/build/widgets/icons/square.d.ts.map +1 -1
  94. package/build/widgets/icons/square.js +3 -3
  95. package/build/widgets/index.d.ts +3 -1
  96. package/build/widgets/index.d.ts.map +1 -1
  97. package/build/widgets/index.js +3 -1
  98. package/build/widgets/overlay/ContextMenu.d.ts.map +1 -1
  99. package/build/widgets/overlay/ContextMenu.js +2 -0
  100. package/build/widgets/overlay/Dropdown.d.ts +2 -1
  101. package/build/widgets/overlay/Dropdown.d.ts.map +1 -1
  102. package/build/widgets/overlay/Dropdown.js +75 -20
  103. package/build/widgets/overlay/MsgBox.d.ts +1 -0
  104. package/build/widgets/overlay/MsgBox.d.ts.map +1 -1
  105. package/build/widgets/overlay/MsgBox.js +2 -2
  106. package/build/widgets/overlay/Overlay.d.ts +32 -2
  107. package/build/widgets/overlay/Overlay.d.ts.map +1 -1
  108. package/build/widgets/overlay/Overlay.js +47 -16
  109. package/build/widgets/overlay/Toast.d.ts +1 -1
  110. package/build/widgets/overlay/Toast.d.ts.map +1 -1
  111. package/build/widgets/overlay/Toast.js +4 -1
  112. package/build/widgets/overlay/Tooltip.d.ts +6 -0
  113. package/build/widgets/overlay/Tooltip.d.ts.map +1 -1
  114. package/build/widgets/overlay/Tooltip.js +24 -9
  115. package/build/widgets/overlay/Window.d.ts.map +1 -1
  116. package/build/widgets/overlay/Window.js +24 -9
  117. package/dist/charts.css +325 -272
  118. package/dist/charts.js +11 -5
  119. package/dist/data.js +2 -2
  120. package/dist/manifest.js +892 -880
  121. package/dist/svg.css +14 -8
  122. package/dist/svg.js +9 -1
  123. package/dist/ui.js +29 -16
  124. package/dist/widgets.css +997 -294
  125. package/dist/widgets.js +317 -121
  126. package/package.json +1 -1
  127. package/src/charts/Bar.scss +13 -10
  128. package/src/charts/BarGraph.scss +31 -29
  129. package/src/charts/BubbleGraph.scss +11 -8
  130. package/src/charts/Chart.ts +5 -3
  131. package/src/charts/Column.scss +13 -10
  132. package/src/charts/ColumnBarBase.tsx +255 -230
  133. package/src/charts/ColumnGraph.scss +13 -11
  134. package/src/charts/Gridlines.scss +10 -8
  135. package/src/charts/Legend.scss +57 -50
  136. package/src/charts/Legend.tsx +257 -213
  137. package/src/charts/LegendEntry.scss +35 -29
  138. package/src/charts/LineGraph.scss +28 -25
  139. package/src/charts/Marker.scss +12 -10
  140. package/src/charts/Marker.tsx +3 -2
  141. package/src/charts/MarkerLine.scss +11 -8
  142. package/src/charts/MarkerLine.tsx +196 -177
  143. package/src/charts/PieChart.scss +12 -9
  144. package/src/charts/PieChart.tsx +717 -591
  145. package/src/charts/PieLabel.tsx +99 -81
  146. package/src/charts/Range.scss +11 -8
  147. package/src/charts/RangeMarker.tsx +204 -187
  148. package/src/charts/ScatterGraph.scss +12 -9
  149. package/src/charts/axis/Axis.scss +6 -5
  150. package/src/charts/axis/CategoryAxis.scss +10 -8
  151. package/src/charts/axis/NumericAxis.scss +9 -6
  152. package/src/charts/axis/TimeAxis.scss +9 -6
  153. package/src/charts/axis/TimeAxis.tsx +753 -637
  154. package/src/charts/axis/index.scss +4 -5
  155. package/src/charts/axis/variables.scss +4 -2
  156. package/src/charts/helpers/ValueAtFinder.ts +19 -5
  157. package/src/charts/index.scss +16 -19
  158. package/src/charts/maps.scss +0 -0
  159. package/src/charts/palette.scss +11 -31
  160. package/src/charts/palette.variables.scss +23 -0
  161. package/src/charts/variables.scss +35 -3
  162. package/src/data/StructuredSelector.ts +2 -2
  163. package/src/data/createAccessorModelProxy.ts +66 -74
  164. package/src/index.scss +5 -6
  165. package/src/maps.scss +5 -0
  166. package/src/svg/Ellipse.tsx +62 -55
  167. package/src/svg/Line.tsx +57 -42
  168. package/src/svg/Svg.scss +6 -6
  169. package/src/svg/Text.scss +19 -0
  170. package/src/svg/Text.tsx +172 -116
  171. package/src/svg/index.scss +3 -2
  172. package/src/svg/maps.scss +0 -0
  173. package/src/svg/variables.scss +0 -0
  174. package/src/ui/Container.spec.ts +59 -0
  175. package/src/ui/Controller.spec.tsx +30 -0
  176. package/src/ui/Controller.ts +5 -0
  177. package/src/ui/HoverSync.tsx +179 -147
  178. package/src/ui/Prop.ts +1 -1
  179. package/src/ui/Text.ts +12 -9
  180. package/src/ui/adapter/GroupAdapter.spec.ts +42 -0
  181. package/src/ui/adapter/GroupAdapter.ts +25 -14
  182. package/src/ui/app/History.ts +1 -1
  183. package/src/ui/index.scss +1 -1
  184. package/src/ui/layout/LabelsLeftLayout.scss +5 -7
  185. package/src/ui/layout/LabelsTopLayout.scss +4 -6
  186. package/src/ui/layout/index.scss +2 -3
  187. package/src/ui/maps.scss +0 -0
  188. package/src/ui/variables.scss +1 -2
  189. package/src/util/index.scss +4 -2
  190. package/src/util/maps.scss +1 -0
  191. package/src/util/scss/besm.scss +15 -0
  192. package/src/util/scss/calc.scss +103 -11
  193. package/src/util/scss/defaults.scss +24 -0
  194. package/src/util/scss/elements.scss +78 -0
  195. package/src/util/scss/global.scss +15 -0
  196. package/src/util/scss/include.scss +17 -9
  197. package/src/util/scss/index.scss +1 -9
  198. package/src/util/scss/maps.scss +2 -0
  199. package/src/util/scss/pad-size.scss +9 -0
  200. package/src/util/scss/padding.scss +6 -0
  201. package/src/util/scss/screen-size.scss +5 -0
  202. package/src/util/scss/variables.scss +6 -0
  203. package/src/util/variables.scss +1 -0
  204. package/src/variables.scss +5 -217
  205. package/src/widgets/Button.maps.scss +103 -0
  206. package/src/widgets/Button.scss +33 -9
  207. package/src/widgets/Button.variables.scss +8 -104
  208. package/src/widgets/CxCredit.scss +2 -0
  209. package/src/widgets/FlexBox.scss +16 -11
  210. package/src/widgets/Heading.scss +6 -0
  211. package/src/widgets/HighlightedSearchText.scss +8 -1
  212. package/src/widgets/Icon.scss +6 -0
  213. package/src/widgets/List.scss +7 -0
  214. package/src/widgets/List.tsx +6 -7
  215. package/src/widgets/ProgressBar.scss +9 -0
  216. package/src/widgets/Resizer.scss +9 -7
  217. package/src/widgets/Section.scss +53 -56
  218. package/src/widgets/animations.scss +4 -2
  219. package/src/widgets/box.scss +47 -0
  220. package/src/widgets/drag-drop/DragClone.scss +12 -4
  221. package/src/widgets/drag-drop/DragHandle.scss +12 -6
  222. package/src/widgets/drag-drop/DragSource.scss +12 -6
  223. package/src/widgets/drag-drop/DropZone.scss +9 -0
  224. package/src/widgets/drag-drop/DropZone.tsx +3 -3
  225. package/src/widgets/drag-drop/index.scss +4 -4
  226. package/src/widgets/drag-drop/maps.scss +7 -0
  227. package/src/widgets/drag-drop/variables.scss +8 -5
  228. package/src/widgets/form/Calendar.maps.scss +54 -0
  229. package/src/widgets/form/Calendar.scss +49 -11
  230. package/src/widgets/form/Calendar.tsx +755 -653
  231. package/src/widgets/form/Calendar.variables.scss +3 -46
  232. package/src/widgets/form/Checkbox.maps.scss +34 -0
  233. package/src/widgets/form/Checkbox.scss +14 -3
  234. package/src/widgets/form/Checkbox.variables.scss +4 -36
  235. package/src/widgets/form/ColorField.scss +21 -2
  236. package/src/widgets/form/ColorField.tsx +485 -431
  237. package/src/widgets/form/ColorPicker.maps.scss +21 -0
  238. package/src/widgets/form/ColorPicker.scss +26 -9
  239. package/src/widgets/form/ColorPicker.variables.scss +3 -16
  240. package/src/widgets/form/DateTimeField.scss +54 -21
  241. package/src/widgets/form/DateTimeField.tsx +697 -615
  242. package/src/widgets/form/DateTimePicker.scss +14 -4
  243. package/src/widgets/form/Field.maps.scss +122 -0
  244. package/src/widgets/form/Field.scss +54 -18
  245. package/src/widgets/form/Field.tsx +611 -504
  246. package/src/widgets/form/Field.variables.scss +46 -0
  247. package/src/widgets/form/HelpText.scss +8 -5
  248. package/src/widgets/form/Label.scss +10 -3
  249. package/src/widgets/form/LookupField.maps.scss +26 -0
  250. package/src/widgets/form/LookupField.scss +54 -24
  251. package/src/widgets/form/LookupField.tsx +25 -21
  252. package/src/widgets/form/MonthField.scss +48 -26
  253. package/src/widgets/form/MonthField.tsx +645 -567
  254. package/src/widgets/form/MonthPicker.maps.scss +50 -0
  255. package/src/widgets/form/MonthPicker.scss +44 -35
  256. package/src/widgets/form/MonthPicker.tsx +954 -724
  257. package/src/widgets/form/MonthPicker.variables.scss +24 -0
  258. package/src/widgets/form/NumberField.scss +19 -2
  259. package/src/widgets/form/NumberField.tsx +576 -466
  260. package/src/widgets/form/Radio.maps.scss +36 -0
  261. package/src/widgets/form/Radio.scss +12 -2
  262. package/src/widgets/form/Radio.variables.scss +3 -42
  263. package/src/widgets/form/Select.scss +25 -9
  264. package/src/widgets/form/Slider.scss +23 -14
  265. package/src/widgets/form/Switch.scss +18 -8
  266. package/src/widgets/form/TextArea.scss +14 -1
  267. package/src/widgets/form/TextField.scss +24 -3
  268. package/src/widgets/form/TextField.tsx +9 -21
  269. package/src/widgets/form/UploadButton.scss +14 -6
  270. package/src/widgets/form/ValidationError.scss +10 -6
  271. package/src/widgets/form/Wheel.scss +14 -4
  272. package/src/widgets/form/index.scss +22 -24
  273. package/src/widgets/form/maps.scss +81 -0
  274. package/src/widgets/form/variables.scss +111 -355
  275. package/src/widgets/grid/Grid.scss +19 -2
  276. package/src/widgets/grid/Grid.spec.ts +42 -0
  277. package/src/widgets/grid/Grid.tsx +15 -7
  278. package/src/widgets/grid/Pagination.scss +11 -2
  279. package/src/widgets/grid/Pagination.tsx +110 -102
  280. package/src/widgets/grid/TreeNode.scss +25 -8
  281. package/src/widgets/grid/TreeNode.tsx +127 -116
  282. package/src/widgets/grid/index.scss +3 -4
  283. package/src/widgets/grid/maps.scss +110 -0
  284. package/src/widgets/grid/variables.scss +48 -137
  285. package/src/widgets/icons/folder.tsx +1 -2
  286. package/src/widgets/icons/forward.tsx +23 -20
  287. package/src/widgets/icons/loading.tsx +22 -19
  288. package/src/widgets/icons/square.tsx +20 -17
  289. package/src/widgets/index.scss +16 -16
  290. package/src/widgets/index.ts +63 -58
  291. package/src/widgets/lists.scss +42 -0
  292. package/src/widgets/maps.scss +139 -0
  293. package/src/widgets/nav/Link.scss +14 -1
  294. package/src/widgets/nav/Menu.scss +13 -7
  295. package/src/widgets/nav/Menu.variables.scss +1 -12
  296. package/src/widgets/nav/MenuItem.scss +21 -6
  297. package/src/widgets/nav/Scroller.scss +11 -2
  298. package/src/widgets/nav/Tab.maps.scss +78 -0
  299. package/src/widgets/nav/Tab.scss +12 -6
  300. package/src/widgets/nav/Tab.variables.scss +7 -76
  301. package/src/widgets/nav/cover.scss +6 -4
  302. package/src/widgets/nav/index.scss +6 -6
  303. package/src/widgets/nav/maps.scss +32 -0
  304. package/src/widgets/nav/variables.scss +4 -11
  305. package/src/widgets/overlay/ContextMenu.ts +3 -0
  306. package/src/widgets/overlay/Dropdown.scss +47 -16
  307. package/src/widgets/overlay/Dropdown.tsx +851 -676
  308. package/src/widgets/overlay/MsgBox.tsx +125 -111
  309. package/src/widgets/overlay/Overlay.scss +60 -40
  310. package/src/widgets/overlay/Overlay.tsx +948 -800
  311. package/src/widgets/overlay/Toast.scss +42 -34
  312. package/src/widgets/overlay/Toast.ts +11 -1
  313. package/src/widgets/overlay/Tooltip.scss +27 -96
  314. package/src/widgets/overlay/Tooltip.tsx +376 -309
  315. package/src/widgets/overlay/Window.maps.scss +51 -0
  316. package/src/widgets/overlay/Window.scss +17 -17
  317. package/src/widgets/overlay/Window.tsx +291 -236
  318. package/src/widgets/overlay/Window.variables.scss +2 -43
  319. package/src/widgets/overlay/index.d.ts +11 -11
  320. package/src/widgets/overlay/index.scss +6 -15
  321. package/src/widgets/overlay/maps.scss +44 -0
  322. package/src/widgets/overlay/variables.scss +11 -42
  323. package/src/widgets/variables.scss +33 -117
  324. 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 { TextualBoundedObject, TextualBoundedObjectConfig } from "./TextualBoundedObject";
6
+ import {
7
+ TextualBoundedObject,
8
+ TextualBoundedObjectConfig,
9
+ } from "./TextualBoundedObject";
7
10
 
8
11
  export interface LineConfig extends TextualBoundedObjectConfig {
9
- /**
10
- * Index of the color in the default color palette. Setting this property will set
11
- * both fill and stroke on the object. Use `style` or a CSS class to remove stroke or fill
12
- * if they are not necessary.
13
- */
14
- colorIndex?: NumberProp;
15
-
16
- /** A color used to paint the outline of the box. */
17
- stroke?: StringProp;
18
-
19
- /** Base CSS class to be applied to the element. Defaults to `line`. */
20
- baseClass?: string;
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
- declare baseClass: string;
25
- declare colorIndex?: NumberProp;
26
- declare stroke?: StringProp;
27
-
28
- declareData(...args: any[]) {
29
- super.declareData(...args, {
30
- colorIndex: undefined,
31
- stroke: undefined,
32
- });
33
- }
34
-
35
- render(context: RenderingContext, instance: Instance & { colorIndex: number }, key: string) {
36
- const { data, colorIndex } = instance;
37
- const { bounds } = data;
38
- return (
39
- <g key={key} className={data.classNames}>
40
- <line
41
- className={this.CSS.element(this.baseClass, "line", colorIndex != null && "color-" + colorIndex)}
42
- x1={bounds.l}
43
- y1={bounds.t}
44
- x2={bounds.r}
45
- y2={bounds.b}
46
- style={data.style}
47
- stroke={data.stroke}
48
- />
49
- {this.renderChildren(context, instance)}
50
- </g>
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('cx/svg/Svg')) {
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
- /** 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. Accepted values are `start`, `middle` and `end`. */
26
- textAnchor?: StringProp;
27
-
28
- /** Used for horizontal text alignment. Accepted values are `start`, `middle` and `end`. */
29
- ta?: StringProp;
30
-
31
- /** Sets text-body color. */
32
- fill?: StringProp;
33
-
34
- /** Sets text-outline color. */
35
- stroke?: StringProp;
36
-
37
- /** Base CSS class to be applied to the element. Defaults to `text`. */
38
- baseClass?: string;
39
-
40
- /** Set to true for the text to set the text anchor based on the direction of the parent element. See PieLabels example. */
41
- autoTextAnchor?: boolean;
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
- constructor(config?: TextConfig) {
46
- super(config);
47
- }
48
-
49
- declare value?: StringProp;
50
- declare bind?: string;
51
- declare tpl?: string;
52
- declare expr?: string;
53
- declare dx?: Prop<string | number>;
54
- declare dy?: Prop<string | number>;
55
- declare textAnchor?: StringProp;
56
- declare ta?: StringProp;
57
- declare fill?: StringProp;
58
- declare stroke?: StringProp;
59
- declare autoTextAnchor?: boolean;
60
-
61
- declareData(...args: any[]) {
62
- return super.declareData(...args, {
63
- value: undefined,
64
- dx: undefined,
65
- dy: undefined,
66
- textAnchor: undefined,
67
- fill: undefined,
68
- stroke: undefined,
69
- });
70
- }
71
-
72
- init() {
73
- if (this.ta) this.textAnchor = this.ta;
74
-
75
- if (this.bind) {
76
- this.value = {
77
- bind: this.bind,
78
- } as any;
79
- } else if (this.tpl) {
80
- this.value = {
81
- tpl: this.tpl,
82
- } as any;
83
- } else if (this.expr) {
84
- this.value = {
85
- expr: this.expr,
86
- } as any;
87
- }
88
-
89
- super.init();
90
- }
91
-
92
- prepare(context: RenderingContext, instance: Instance) {
93
- if (this.autoTextAnchor) {
94
- (instance as any).textAnchor =
95
- context.textDirection == "right" ? "start" : context.textDirection == "left" ? "end" : this.textAnchor;
96
- let changed = instance.cache("textAnchor", (instance as any).textAnchor);
97
- if (changed) (instance as any).markShouldUpdate(context);
98
- }
99
-
100
- super.prepare(context, instance);
101
- }
102
-
103
- render(context: RenderingContext, instance: Instance, key: string) {
104
- const { data } = instance;
105
- const { bounds } = data;
106
-
107
- let textAnchor = this.autoTextAnchor ? (instance as any).textAnchor : data.textAnchor;
108
-
109
- return (
110
- <text
111
- key={key}
112
- className={data.classNames}
113
- x={this.autoTextAnchor && textAnchor == "end" ? bounds.r : bounds.l}
114
- y={bounds.t}
115
- dx={data.dx}
116
- dy={data.dy}
117
- textAnchor={textAnchor}
118
- style={data.style}
119
- fill={data.fill}
120
- stroke={data.stroke}
121
- >
122
- {data.value}
123
- {this.renderChildren(context, instance)}
124
- </text>
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);
@@ -1,3 +1,6 @@
1
+ @use "Svg" as *;
2
+ @use "Text";
3
+
1
4
  .cxs-text-anchor-middle {
2
5
  text-anchor: middle;
3
6
  }
@@ -5,5 +8,3 @@
5
8
  .cxs-text-anchor-right {
6
9
  text-anchor: end;
7
10
  }
8
-
9
- @import "Svg";
File without changes
File without changes
@@ -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", () => {
@@ -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.";