@sap-ux/ui-components 1.8.0 → 1.8.2

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 (288) hide show
  1. package/dist/components/Icons.d.ts +139 -139
  2. package/dist/components/Icons.js +582 -582
  3. package/dist/components/UIActionCallout/UIActionCallout.d.ts +61 -61
  4. package/dist/components/UIActionCallout/UIActionCallout.js +63 -63
  5. package/dist/components/UIActionCallout/UIActionCallout.scss +31 -31
  6. package/dist/components/UIActionCallout/index.d.ts +1 -1
  7. package/dist/components/UIActionCallout/index.js +17 -17
  8. package/dist/components/UIBreadcrumb/UIBreadcrumb.d.ts +23 -23
  9. package/dist/components/UIBreadcrumb/UIBreadcrumb.js +38 -38
  10. package/dist/components/UIBreadcrumb/index.d.ts +1 -1
  11. package/dist/components/UIBreadcrumb/index.js +17 -17
  12. package/dist/components/UIButton/UIActionButton.d.ts +23 -23
  13. package/dist/components/UIButton/UIActionButton.js +89 -89
  14. package/dist/components/UIButton/UIDefaultButton.d.ts +23 -23
  15. package/dist/components/UIButton/UIDefaultButton.js +229 -229
  16. package/dist/components/UIButton/UIIconButton.d.ts +37 -37
  17. package/dist/components/UIButton/UIIconButton.js +106 -106
  18. package/dist/components/UIButton/UISmallButton.d.ts +34 -34
  19. package/dist/components/UIButton/UISmallButton.js +115 -115
  20. package/dist/components/UIButton/UISplitButton.d.ts +36 -36
  21. package/dist/components/UIButton/UISplitButton.js +71 -71
  22. package/dist/components/UIButton/index.d.ts +7 -7
  23. package/dist/components/UIButton/index.js +21 -21
  24. package/dist/components/UICallout/UICallout.d.ts +37 -37
  25. package/dist/components/UICallout/UICallout.js +90 -90
  26. package/dist/components/UICallout/index.d.ts +1 -1
  27. package/dist/components/UICallout/index.js +17 -17
  28. package/dist/components/UICheckbox/UICheckbox.d.ts +34 -34
  29. package/dist/components/UICheckbox/UICheckbox.js +135 -135
  30. package/dist/components/UICheckbox/index.d.ts +1 -1
  31. package/dist/components/UICheckbox/index.js +17 -17
  32. package/dist/components/UIChoiceGroup/UIChoiceGroup.d.ts +28 -28
  33. package/dist/components/UIChoiceGroup/UIChoiceGroup.js +182 -182
  34. package/dist/components/UIChoiceGroup/index.d.ts +1 -1
  35. package/dist/components/UIChoiceGroup/index.js +17 -17
  36. package/dist/components/UIComboBox/Callout.scss +7 -7
  37. package/dist/components/UIComboBox/UIComboBox.d.ts +198 -198
  38. package/dist/components/UIComboBox/UIComboBox.js +516 -516
  39. package/dist/components/UIComboBox/UIComboBox.scss +268 -268
  40. package/dist/components/UIComboBox/_mixins.scss +32 -32
  41. package/dist/components/UIComboBox/index.d.ts +1 -1
  42. package/dist/components/UIComboBox/index.js +17 -17
  43. package/dist/components/UIContextualMenu/UIContextualMenu.d.ts +31 -31
  44. package/dist/components/UIContextualMenu/UIContextualMenu.js +123 -123
  45. package/dist/components/UIContextualMenu/UIContextualMenu.scss +211 -211
  46. package/dist/components/UIContextualMenu/UIHighlightMenuOption.d.ts +19 -19
  47. package/dist/components/UIContextualMenu/UIHighlightMenuOption.js +50 -50
  48. package/dist/components/UIContextualMenu/UIHighlightMenuOption.scss +23 -23
  49. package/dist/components/UIContextualMenu/_variables.scss +30 -30
  50. package/dist/components/UIContextualMenu/index.d.ts +2 -2
  51. package/dist/components/UIContextualMenu/index.js +18 -18
  52. package/dist/components/UIDatePicker/UIDatePicker.d.ts +49 -49
  53. package/dist/components/UIDatePicker/UIDatePicker.js +72 -72
  54. package/dist/components/UIDatePicker/UIDatePicker.scss +38 -38
  55. package/dist/components/UIDatePicker/index.d.ts +1 -1
  56. package/dist/components/UIDatePicker/index.js +17 -17
  57. package/dist/components/UIDialog/UIDialog.d.ts +116 -116
  58. package/dist/components/UIDialog/UIDialog.js +279 -279
  59. package/dist/components/UIDialog/index.d.ts +1 -1
  60. package/dist/components/UIDialog/index.js +17 -17
  61. package/dist/components/UIDropdown/UIDropdown.d.ts +90 -90
  62. package/dist/components/UIDropdown/UIDropdown.js +216 -216
  63. package/dist/components/UIDropdown/UIDropdown.scss +115 -115
  64. package/dist/components/UIDropdown/index.d.ts +2 -2
  65. package/dist/components/UIDropdown/index.js +18 -18
  66. package/dist/components/UIDropdown/utils.d.ts +8 -8
  67. package/dist/components/UIDropdown/utils.js +20 -20
  68. package/dist/components/UIFlexibleTable/RowActions.d.ts +16 -16
  69. package/dist/components/UIFlexibleTable/RowActions.js +73 -73
  70. package/dist/components/UIFlexibleTable/RowData.d.ts +16 -16
  71. package/dist/components/UIFlexibleTable/RowData.js +111 -111
  72. package/dist/components/UIFlexibleTable/UIFlexibleTable.d.ts +11 -11
  73. package/dist/components/UIFlexibleTable/UIFlexibleTable.js +280 -280
  74. package/dist/components/UIFlexibleTable/UIFlexibleTable.scss +433 -433
  75. package/dist/components/UIFlexibleTable/UIFlexibleTableActionButton.d.ts +20 -20
  76. package/dist/components/UIFlexibleTable/UIFlexibleTableActionButton.js +20 -20
  77. package/dist/components/UIFlexibleTable/UIFlexibleTableRow.d.ts +26 -26
  78. package/dist/components/UIFlexibleTable/UIFlexibleTableRow.js +165 -165
  79. package/dist/components/UIFlexibleTable/UIFlexibleTableRowActionButton.d.ts +20 -20
  80. package/dist/components/UIFlexibleTable/UIFlexibleTableRowActionButton.js +19 -19
  81. package/dist/components/UIFlexibleTable/UIFlexibleTableRowNoData.d.ts +15 -15
  82. package/dist/components/UIFlexibleTable/UIFlexibleTableRowNoData.js +28 -28
  83. package/dist/components/UIFlexibleTable/index.d.ts +5 -5
  84. package/dist/components/UIFlexibleTable/index.js +21 -21
  85. package/dist/components/UIFlexibleTable/types.d.ts +142 -142
  86. package/dist/components/UIFlexibleTable/types.js +14 -14
  87. package/dist/components/UIFlexibleTable/utils.d.ts +25 -25
  88. package/dist/components/UIFlexibleTable/utils.js +49 -49
  89. package/dist/components/UIFocusZone/UIFocusTrapZone.d.ts +22 -22
  90. package/dist/components/UIFocusZone/UIFocusTrapZone.js +33 -33
  91. package/dist/components/UIFocusZone/UIFocusZone.d.ts +23 -23
  92. package/dist/components/UIFocusZone/UIFocusZone.js +35 -35
  93. package/dist/components/UIFocusZone/index.d.ts +2 -2
  94. package/dist/components/UIFocusZone/index.js +18 -18
  95. package/dist/components/UIIcon/UIIcon.d.ts +24 -24
  96. package/dist/components/UIIcon/UIIcon.js +37 -37
  97. package/dist/components/UIIcon/UIIcon.scss +3 -3
  98. package/dist/components/UIIcon/index.d.ts +1 -1
  99. package/dist/components/UIIcon/index.js +17 -17
  100. package/dist/components/UIInput/UITextInput.d.ts +48 -48
  101. package/dist/components/UIInput/UITextInput.js +238 -238
  102. package/dist/components/UIInput/index.d.ts +1 -1
  103. package/dist/components/UIInput/index.js +17 -17
  104. package/dist/components/UILabel/UILabel.d.ts +30 -30
  105. package/dist/components/UILabel/UILabel.js +64 -64
  106. package/dist/components/UILabel/index.d.ts +1 -1
  107. package/dist/components/UILabel/index.js +17 -17
  108. package/dist/components/UILink/UILink.d.ts +25 -25
  109. package/dist/components/UILink/UILink.js +71 -71
  110. package/dist/components/UILink/index.d.ts +1 -1
  111. package/dist/components/UILink/index.js +17 -17
  112. package/dist/components/UIList/UIList.d.ts +31 -31
  113. package/dist/components/UIList/UIList.js +120 -120
  114. package/dist/components/UIList/UIList.scss +16 -16
  115. package/dist/components/UIList/index.d.ts +1 -1
  116. package/dist/components/UIList/index.js +17 -17
  117. package/dist/components/UILoader/UILoader.d.ts +27 -27
  118. package/dist/components/UILoader/UILoader.js +78 -78
  119. package/dist/components/UILoader/UILoader.scss +32 -32
  120. package/dist/components/UILoader/index.d.ts +1 -1
  121. package/dist/components/UILoader/index.js +17 -17
  122. package/dist/components/UIMessageBar/UIMessageBar.d.ts +25 -25
  123. package/dist/components/UIMessageBar/UIMessageBar.js +56 -56
  124. package/dist/components/UIMessageBar/index.d.ts +1 -1
  125. package/dist/components/UIMessageBar/index.js +17 -17
  126. package/dist/components/UIModal/UIModal.d.ts +23 -23
  127. package/dist/components/UIModal/UIModal.js +43 -43
  128. package/dist/components/UIModal/index.d.ts +1 -1
  129. package/dist/components/UIModal/index.js +17 -17
  130. package/dist/components/UIOverlay/UIOverlay.d.ts +22 -22
  131. package/dist/components/UIOverlay/UIOverlay.js +38 -38
  132. package/dist/components/UIOverlay/index.d.ts +1 -1
  133. package/dist/components/UIOverlay/index.js +17 -17
  134. package/dist/components/UIPersona/UIPersona.d.ts +27 -27
  135. package/dist/components/UIPersona/UIPersona.js +48 -48
  136. package/dist/components/UIPersona/index.d.ts +1 -1
  137. package/dist/components/UIPersona/index.js +17 -17
  138. package/dist/components/UISearchBox/UISearchBox.d.ts +22 -22
  139. package/dist/components/UISearchBox/UISearchBox.js +153 -153
  140. package/dist/components/UISearchBox/index.d.ts +3 -3
  141. package/dist/components/UISearchBox/index.js +17 -17
  142. package/dist/components/UISection/UISection.d.ts +34 -34
  143. package/dist/components/UISection/UISection.js +44 -44
  144. package/dist/components/UISection/UISection.scss +76 -76
  145. package/dist/components/UISection/UISections.d.ts +249 -249
  146. package/dist/components/UISection/UISections.js +707 -707
  147. package/dist/components/UISection/UISections.scss +62 -62
  148. package/dist/components/UISection/UISplitter.d.ts +96 -96
  149. package/dist/components/UISection/UISplitter.js +220 -220
  150. package/dist/components/UISection/UISplitter.scss +212 -212
  151. package/dist/components/UISection/_mixins.scss +14 -14
  152. package/dist/components/UISection/_variables.scss +1 -1
  153. package/dist/components/UISection/index.d.ts +3 -3
  154. package/dist/components/UISection/index.js +19 -19
  155. package/dist/components/UISeparator/UISeparator.d.ts +25 -25
  156. package/dist/components/UISeparator/UISeparator.js +65 -65
  157. package/dist/components/UISeparator/index.d.ts +1 -1
  158. package/dist/components/UISeparator/index.js +17 -17
  159. package/dist/components/UITable/UITable-helper.d.ts +79 -79
  160. package/dist/components/UITable/UITable-helper.js +259 -259
  161. package/dist/components/UITable/UITable.d.ts +212 -212
  162. package/dist/components/UITable/UITable.d.ts.map +1 -1
  163. package/dist/components/UITable/UITable.js +775 -773
  164. package/dist/components/UITable/UITable.js.map +1 -1
  165. package/dist/components/UITable/UITable.scss +194 -194
  166. package/dist/components/UITable/index.d.ts +2 -2
  167. package/dist/components/UITable/index.js +18 -18
  168. package/dist/components/UITable/types.d.ts +77 -77
  169. package/dist/components/UITable/types.js +28 -28
  170. package/dist/components/UITabs/UITabs.d.ts +28 -28
  171. package/dist/components/UITabs/UITabs.js +70 -70
  172. package/dist/components/UITabs/index.d.ts +1 -1
  173. package/dist/components/UITabs/index.js +17 -17
  174. package/dist/components/UIToggle/UIToggle.d.ts +39 -39
  175. package/dist/components/UIToggle/UIToggle.js +181 -181
  176. package/dist/components/UIToggle/index.d.ts +1 -1
  177. package/dist/components/UIToggle/index.js +17 -17
  178. package/dist/components/UIToggleGroup/UIToggleGroup.d.ts +31 -31
  179. package/dist/components/UIToggleGroup/UIToggleGroup.js +136 -136
  180. package/dist/components/UIToggleGroup/UIToggleGroup.scss +13 -13
  181. package/dist/components/UIToggleGroup/UIToggleGroup.types.d.ts +22 -22
  182. package/dist/components/UIToggleGroup/UIToggleGroup.types.js +2 -2
  183. package/dist/components/UIToggleGroup/UIToggleGroupOption/UIToggleGroupOption.d.ts +25 -25
  184. package/dist/components/UIToggleGroup/UIToggleGroupOption/UIToggleGroupOption.js +77 -77
  185. package/dist/components/UIToggleGroup/UIToggleGroupOption/UIToggleGroupOption.scss +74 -74
  186. package/dist/components/UIToggleGroup/UIToggleGroupOption/UIToggleGroupOption.types.d.ts +10 -10
  187. package/dist/components/UIToggleGroup/UIToggleGroupOption/UIToggleGroupOption.types.js +2 -2
  188. package/dist/components/UIToggleGroup/UIToggleGroupOption/index.d.ts +2 -2
  189. package/dist/components/UIToggleGroup/UIToggleGroupOption/index.js +18 -18
  190. package/dist/components/UIToggleGroup/index.d.ts +2 -2
  191. package/dist/components/UIToggleGroup/index.js +18 -18
  192. package/dist/components/UIToolbar/UIToolbar.d.ts +36 -36
  193. package/dist/components/UIToolbar/UIToolbar.js +104 -104
  194. package/dist/components/UIToolbar/UIToolbar.scss +48 -48
  195. package/dist/components/UIToolbar/UIToolbarColumn.d.ts +7 -7
  196. package/dist/components/UIToolbar/UIToolbarColumn.js +33 -33
  197. package/dist/components/UIToolbar/UIToolbarDivider.d.ts +27 -27
  198. package/dist/components/UIToolbar/UIToolbarDivider.js +56 -56
  199. package/dist/components/UIToolbar/index.d.ts +3 -3
  200. package/dist/components/UIToolbar/index.js +19 -19
  201. package/dist/components/UITooltip/UITooltip.d.ts +29 -29
  202. package/dist/components/UITooltip/UITooltip.js +77 -77
  203. package/dist/components/UITooltip/UITooltipUtils.d.ts +17 -17
  204. package/dist/components/UITooltip/UITooltipUtils.js +45 -45
  205. package/dist/components/UITooltip/index.d.ts +2 -2
  206. package/dist/components/UITooltip/index.js +18 -18
  207. package/dist/components/UITranslationInput/UIFormattedText.d.ts +46 -46
  208. package/dist/components/UITranslationInput/UIFormattedText.js +121 -121
  209. package/dist/components/UITranslationInput/UILoadButton.d.ts +52 -52
  210. package/dist/components/UITranslationInput/UILoadButton.js +109 -109
  211. package/dist/components/UITranslationInput/UILoadButton.scss +14 -14
  212. package/dist/components/UITranslationInput/UITranslationButton.d.ts +14 -14
  213. package/dist/components/UITranslationInput/UITranslationButton.js +88 -88
  214. package/dist/components/UITranslationInput/UITranslationButton.types.d.ts +67 -67
  215. package/dist/components/UITranslationInput/UITranslationButton.types.js +21 -21
  216. package/dist/components/UITranslationInput/UITranslationInput.d.ts +25 -25
  217. package/dist/components/UITranslationInput/UITranslationInput.js +169 -169
  218. package/dist/components/UITranslationInput/UITranslationInput.scss +40 -40
  219. package/dist/components/UITranslationInput/UITranslationUtils.d.ts +64 -64
  220. package/dist/components/UITranslationInput/UITranslationUtils.js +168 -168
  221. package/dist/components/UITranslationInput/defaults.d.ts +2 -2
  222. package/dist/components/UITranslationInput/defaults.js +15 -15
  223. package/dist/components/UITranslationInput/index.d.ts +2 -2
  224. package/dist/components/UITranslationInput/index.js +18 -18
  225. package/dist/components/UITreeDropdown/UITreeDropdown.d.ts +265 -265
  226. package/dist/components/UITreeDropdown/UITreeDropdown.js +661 -661
  227. package/dist/components/UITreeDropdown/UITreeDropdown.scss +64 -64
  228. package/dist/components/UITreeDropdown/index.d.ts +1 -1
  229. package/dist/components/UITreeDropdown/index.js +17 -17
  230. package/dist/components/UIVerticalDivider/UIVerticalDivider.d.ts +23 -23
  231. package/dist/components/UIVerticalDivider/UIVerticalDivider.js +41 -41
  232. package/dist/components/UIVerticalDivider/index.d.ts +1 -1
  233. package/dist/components/UIVerticalDivider/index.js +17 -17
  234. package/dist/components/UIVirtualList/UIAutoSizer.d.ts +22 -22
  235. package/dist/components/UIVirtualList/UIAutoSizer.js +33 -33
  236. package/dist/components/UIVirtualList/UICellMeasurer.d.ts +23 -23
  237. package/dist/components/UIVirtualList/UICellMeasurer.js +33 -33
  238. package/dist/components/UIVirtualList/UIVirtualList.d.ts +43 -43
  239. package/dist/components/UIVirtualList/UIVirtualList.js +70 -70
  240. package/dist/components/UIVirtualList/index.d.ts +3 -3
  241. package/dist/components/UIVirtualList/index.js +19 -19
  242. package/dist/components/index.d.ts +37 -37
  243. package/dist/components/index.js +53 -53
  244. package/dist/helper/ValidationMessage/MessageWrapper.d.ts +17 -17
  245. package/dist/helper/ValidationMessage/MessageWrapper.js +34 -34
  246. package/dist/helper/ValidationMessage/MessageWrapper.scss +44 -44
  247. package/dist/helper/ValidationMessage/index.d.ts +2 -2
  248. package/dist/helper/ValidationMessage/index.js +18 -18
  249. package/dist/helper/ValidationMessage/utils.d.ts +31 -31
  250. package/dist/helper/ValidationMessage/utils.js +121 -121
  251. package/dist/index.d.ts +2 -2
  252. package/dist/index.js +18 -18
  253. package/dist/styles/_mixins.scss +15 -15
  254. package/dist/styles/_typography.scss +72 -72
  255. package/dist/styles/_variables.scss +26 -26
  256. package/dist/styles/ui-components.scss +3 -3
  257. package/dist/utilities/DeepMerge.d.ts +10 -10
  258. package/dist/utilities/DeepMerge.js +48 -48
  259. package/dist/utilities/Focus.d.ts +4 -4
  260. package/dist/utilities/Focus.js +7 -7
  261. package/dist/utilities/Id.d.ts +2 -2
  262. package/dist/utilities/Id.js +5 -5
  263. package/dist/utilities/Keys.d.ts +2 -2
  264. package/dist/utilities/Keys.js +5 -5
  265. package/dist/utilities/index.d.ts +3 -3
  266. package/dist/utilities/index.js +19 -19
  267. package/package.json +1 -1
  268. package/storybook/{308.3ef1252cf4e6f4ea4f87.manager.bundle.js → 275.a8ff63b0ed4a5d620142.manager.bundle.js} +1 -1
  269. package/storybook/{775.2c32f5dec8245bf06a35.manager.bundle.js → 453.af4e8cc44257a27c435f.manager.bundle.js} +1 -1
  270. package/storybook/{151.f31eae3b7704470d2f0c.manager.bundle.js → 458.a8cb7c68775e3858b342.manager.bundle.js} +1 -1
  271. package/storybook/594.4816ff3f4edb5b8b0949.manager.bundle.js +1 -0
  272. package/storybook/637.173c8d06.iframe.bundle.js +1 -0
  273. package/storybook/713.ec72f301.iframe.bundle.js +292 -0
  274. package/storybook/{822.55c0b8c38a0421b3fdcb.manager.bundle.js → 756.edf22bba3c06d7815c54.manager.bundle.js} +8 -8
  275. package/storybook/{527.5ad8ca17f37f0faebdb5.manager.bundle.js → 966.bc8dd3d7eec539544b33.manager.bundle.js} +1 -1
  276. package/storybook/{869.9c11e9955598ae6cadd2.manager.bundle.js → 987.81102a5d201c9f5a1528.manager.bundle.js} +1 -1
  277. package/storybook/iframe.html +17 -17
  278. package/storybook/index.html +119 -119
  279. package/storybook/main.4bf0e1ff.iframe.bundle.js +99 -0
  280. package/storybook/{main.8a2df1189b7472718896.manager.bundle.js → main.73db1398c1704e93ba73.manager.bundle.js} +1 -1
  281. package/storybook/project.json +1 -1
  282. package/storybook/{runtime~main.ded4beec.iframe.bundle.js → runtime~main.769376b3.iframe.bundle.js} +2 -2
  283. package/storybook/runtime~main.eabd5638d9f3e40b3501.manager.bundle.js +2 -0
  284. package/storybook/215.f4718a88.iframe.bundle.js +0 -292
  285. package/storybook/24.699b5db7d897cafb43de.manager.bundle.js +0 -1
  286. package/storybook/851.7748d349.iframe.bundle.js +0 -1
  287. package/storybook/main.3b29bdd5.iframe.bundle.js +0 -99
  288. package/storybook/runtime~main.3b601f8d200b50936280.manager.bundle.js +0 -2
@@ -1,708 +1,708 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.UISections = exports.ANIMATION_TIME = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const UISection_1 = require("./UISection");
9
- const UISplitter_1 = require("./UISplitter");
10
- require("./UISections.scss");
11
- exports.ANIMATION_TIME = 300;
12
- const SECTIONS_ANIMATION_CLASS = 'sections--animated';
13
- /**
14
- * UISections component.
15
- *
16
- * @exports
17
- * @class {UISections}
18
- * @extends {React.Component<UISectionsProps, UISectionsState>}
19
- */
20
- class UISections extends react_1.default.Component {
21
- /**
22
- * Initializes component properties.
23
- *
24
- * @param {UISectionsProps} props
25
- */
26
- constructor(props) {
27
- super(props);
28
- this.resizeSections = [];
29
- this.isFullScreen = false;
30
- this.rootSize = 0;
31
- this.ignoreAnimation = false;
32
- this.state = {
33
- sizes: undefined
34
- };
35
- this.onWindowResize = this.onWindowResize.bind(this);
36
- this.rootRef = react_1.default.createRef();
37
- this.sizeProperty = props.vertical ? 'height' : 'width';
38
- this.domSizeProperty = props.vertical ? 'clientHeight' : 'clientWidth';
39
- this.startPositionProperty = props.vertical ? 'top' : 'left';
40
- this.endPositionProperty = props.vertical ? 'bottom' : 'right';
41
- this.sizeProperty = props.vertical ? 'height' : 'width';
42
- window.addEventListener('resize', this.onWindowResize);
43
- }
44
- /**
45
- * Updates state sizes.
46
- *
47
- * @param {number} layoutSize
48
- * @param {Array<number | UISectionSize | undefine>} sizes
49
- * @returns {UISectionSize[]}
50
- */
51
- updateStateSizes(layoutSize, sizes) {
52
- let uiSizes = sizes;
53
- const dynamicSectionIndex = this.getDynamicSectionIndex();
54
- // Calculate size for dynamic section
55
- let availableSize = 0;
56
- sizes.forEach((section, index) => {
57
- if (typeof section === 'object' && section.size === undefined) {
58
- const position = this.getSectionPosition(section);
59
- section.size = Math.abs(this.rootSize - position.end - position.start);
60
- }
61
- if (index !== dynamicSectionIndex) {
62
- availableSize += (typeof section === 'object' ? section.size : section) || 0;
63
- }
64
- });
65
- availableSize = layoutSize - availableSize;
66
- // Check if number array is passed as sizes. Convert array of number to array of UISectionSize
67
- if (typeof sizes[0] !== 'object') {
68
- uiSizes = [];
69
- let start = 0;
70
- sizes.forEach((size, index) => {
71
- size = dynamicSectionIndex !== index ? size : availableSize;
72
- uiSizes.push({
73
- percentage: false,
74
- size,
75
- start
76
- });
77
- start += size || 0;
78
- });
79
- }
80
- // Apply size for dynamic section
81
- const dynamicSection = uiSizes[dynamicSectionIndex];
82
- if (dynamicSection) {
83
- dynamicSection.size = availableSize;
84
- }
85
- // Recalculate start and end positions
86
- this.recalculatePositions(uiSizes);
87
- // Validate min sizes
88
- this.validateStateMinSizes(uiSizes);
89
- return uiSizes;
90
- }
91
- componentDidMount() {
92
- const { sizesAsPercents, sizes } = this.props;
93
- this.rootSize = this.getRootSize();
94
- if (!sizesAsPercents && sizes) {
95
- // Calculate state
96
- this.setState({
97
- sizes: this.updateStateSizes(this.rootSize, sizes)
98
- });
99
- }
100
- }
101
- componentDidUpdate() {
102
- this.ignoreAnimation = false;
103
- }
104
- /**
105
- * Gets derived state from properties.
106
- *
107
- * @param {UISectionProps} nextProps
108
- * @param {UISectionsState} prevState
109
- * @returns {UISectionsState | null}
110
- */
111
- static getDerivedStateFromProps(nextProps, prevState) {
112
- // Handle property "animation" as array
113
- let animate = prevState.animate;
114
- let visibleSections;
115
- let dynamicSection = 0;
116
- if (Array.isArray(nextProps.animation)) {
117
- visibleSections = UISections.getVisibleSections(nextProps.children);
118
- // Check if there is transition for section with enabled animation
119
- let transitionAnimation;
120
- for (let i = 0; i < nextProps.animation.length; i++) {
121
- if (visibleSections?.includes(i) !== prevState.visibleSections?.includes(i)) {
122
- transitionAnimation = transitionAnimation || nextProps.animation[i];
123
- }
124
- }
125
- if (transitionAnimation !== undefined) {
126
- // Visibility of sections changed - apply animation for transition section
127
- animate = transitionAnimation;
128
- }
129
- }
130
- else {
131
- animate = nextProps.animation;
132
- }
133
- // Find dynamic section index
134
- nextProps.sizes?.forEach((size, index) => {
135
- if (size === undefined) {
136
- dynamicSection = index;
137
- }
138
- });
139
- return {
140
- animate,
141
- visibleSections,
142
- dynamicSection
143
- };
144
- }
145
- /**
146
- * Validates state min sizes.
147
- *
148
- * @param {UISectionSize[]} sizes
149
- */
150
- validateStateMinSizes(sizes) {
151
- // Prerequisite. Get size infos
152
- let minSizesSum = 0;
153
- let recalculateSizes = false;
154
- const sizesInfo = [];
155
- for (let i = 0; i < this.props.children.length; i++) {
156
- //const size = this.getSectionCurrentSize(i);
157
- const size = sizes[i].size || 0;
158
- const minSize = this.getMinSectionSize(i);
159
- if (minSize > size) {
160
- recalculateSizes = true;
161
- }
162
- minSizesSum += minSize;
163
- // Sizes data
164
- sizesInfo.push({
165
- size,
166
- minSize,
167
- spareSize: size - minSize
168
- });
169
- }
170
- // First Part. Check if full screen required
171
- const layoutSize = this.getRootSize();
172
- // Second Part. Calculate sections which less than min size.
173
- if (recalculateSizes && layoutSize >= minSizesSum) {
174
- const recalculatedSizes = this.calculateSectionSizes(sizesInfo);
175
- for (let i = 0; i < sizes.length; i++) {
176
- sizes[i] = recalculatedSizes[i];
177
- }
178
- }
179
- // Check full screen toggle
180
- const isFullScreen = layoutSize < minSizesSum;
181
- if (isFullScreen !== this.isFullScreen) {
182
- this.isFullScreen = isFullScreen;
183
- this.props.onToggleFullscreen?.(isFullScreen);
184
- }
185
- }
186
- onWindowResize() {
187
- let { sizes } = this.state;
188
- // Dynamic section index
189
- const layoutSize = this.getRootSize();
190
- if (sizes) {
191
- // Update sizes after resize
192
- sizes = this.updateStateSizes(layoutSize, sizes);
193
- // Apply state
194
- this.ignoreAnimation = true;
195
- this.setState({
196
- sizes: sizes
197
- });
198
- }
199
- this.rootSize = layoutSize;
200
- }
201
- /**
202
- * Method returns indices of visible sections.
203
- *
204
- * @param {React.ReactNodeArray} sections Section elements.
205
- * @returns {number[]} Indices of visible sections.
206
- */
207
- static getVisibleSections(sections) {
208
- const visibleSections = [];
209
- sections.forEach((child, i) => {
210
- if (!UISections.isSectionVisible(child)) {
211
- visibleSections.push(i);
212
- }
213
- });
214
- return visibleSections;
215
- }
216
- /**
217
- * Method checks is passed child section visible or not.
218
- *
219
- * @param {React.ReactElement | undefined} node React child node.
220
- * @returns {boolean} True if section visible.
221
- */
222
- static isSectionVisible(node) {
223
- if (node && node.type === UISection_1.UISection) {
224
- return !node.props.hidden;
225
- }
226
- return false;
227
- }
228
- /**
229
- * Method called when resizing of section started.
230
- */
231
- onSplitterResizeStart() {
232
- const rootDom = this.rootRef.current;
233
- const resizeSections = [];
234
- if (rootDom && rootDom.childNodes) {
235
- rootDom.classList.remove(SECTIONS_ANIMATION_CLASS);
236
- for (let i = 0; i < rootDom.childNodes.length; i++) {
237
- const minSectionSize = this.getMinSectionSize(i);
238
- const siblingMinSectionSize = this.getMinSectionSize(i === 0 ? 1 : 0);
239
- const sectionDom = rootDom.children[i];
240
- const maxSize = Math.max(minSectionSize, rootDom[this.domSizeProperty] - siblingMinSectionSize);
241
- resizeSections.push({
242
- size: sectionDom[this.domSizeProperty],
243
- dom: sectionDom,
244
- maxSize,
245
- section: this.resizeSections[i]
246
- ? this.resizeSections[i].section
247
- : {
248
- percentage: false
249
- }
250
- });
251
- }
252
- }
253
- this.resizeSections = resizeSections;
254
- }
255
- /**
256
- * Method called when resizing of section is happening.
257
- *
258
- * @param {number} position Delta position in pixels.
259
- * @returns {boolean} If resizing was happened - it can return false when splitter meets resizing limitation.
260
- */
261
- onSplitterResize(position) {
262
- const resizeSections = position !== 0 ? this.resizeSections : [];
263
- let left = 0;
264
- for (let i = 0; i < resizeSections.length; i++) {
265
- const minSectionSize = this.getMinSectionSize(i);
266
- const resizeSection = resizeSections[i];
267
- let newSize = resizeSection.size + (i === 0 ? position : -position);
268
- if (minSectionSize === resizeSection.maxSize) {
269
- // Ignore resize - section is not resizable
270
- continue;
271
- }
272
- // Do not allow size exceed min and max boundaries
273
- if (newSize < minSectionSize) {
274
- position = this.correctBoundaryPosition(position, minSectionSize, newSize, i === 0);
275
- newSize = minSectionSize;
276
- }
277
- else if (newSize > resizeSection.maxSize) {
278
- position = this.correctBoundaryPosition(position, resizeSection.maxSize, newSize, i === 0);
279
- newSize = resizeSection.maxSize;
280
- }
281
- const sectionSize = {
282
- percentage: false
283
- };
284
- const nextSession = resizeSections[i + 1];
285
- const right = nextSession ? nextSession.size - position : 0;
286
- if (i > 0) {
287
- sectionSize.size = newSize;
288
- sectionSize.start = left;
289
- resizeSection.dom.style[this.startPositionProperty] = left + 'px';
290
- }
291
- else {
292
- sectionSize.start = 0;
293
- resizeSection.dom.style[this.startPositionProperty] = '0px';
294
- }
295
- sectionSize.end = right;
296
- resizeSection.dom.style[this.endPositionProperty] = right + 'px';
297
- resizeSection.section = sectionSize;
298
- left += newSize;
299
- }
300
- return false;
301
- }
302
- /**
303
- * Method returns corrected position based on boundary and size.
304
- *
305
- * @param {number} position Delta position in pixels.
306
- * @param {number} boundary Boundary position.
307
- * @param {number} size Section size.
308
- * @param {boolean} positive Direction.
309
- * @returns {number} Position after correction based on boundary.
310
- */
311
- correctBoundaryPosition(position, boundary, size, positive) {
312
- const diff = boundary - size;
313
- return position + (positive ? diff : -diff);
314
- }
315
- /**
316
- * Method called when resizing session ended.
317
- */
318
- onSplitterResizeEnd() {
319
- const rootDom = this.rootRef.current;
320
- if (rootDom && this.isAnimationEnabled()) {
321
- rootDom.classList.add(SECTIONS_ANIMATION_CLASS);
322
- }
323
- const sizes = this.resizeSections.map((resizeSection) => resizeSection.section);
324
- if (sizes.some((size) => size.end !== undefined || size.start !== undefined || size.size !== undefined)) {
325
- this.setState({
326
- sizes
327
- });
328
- }
329
- this.props.onResize?.(sizes);
330
- }
331
- /**
332
- * Method called when splitter with type 'Toggle' was toggled.
333
- */
334
- onSplitterToggle() {
335
- if (this.props.onClose) {
336
- this.props.onClose();
337
- }
338
- }
339
- /**
340
- * Method returns visible children sections count.
341
- *
342
- * @returns {number} Count of visible children sections.
343
- */
344
- getVisibleChildrenCount() {
345
- return this.props.children.filter((child) => child && UISections.isSectionVisible(child))
346
- .length;
347
- }
348
- /**
349
- * Method returns size of section in percents.
350
- *
351
- * @param {number} index Target section index.
352
- * @param {number} childrenCount Count of children.
353
- * @param {boolean} [reverse=false] Reverse calculation(width vs right).
354
- * @returns {number} Size of section in percents. For example 50% => 0.5.
355
- */
356
- getSizePercents(index, childrenCount, reverse = false) {
357
- const { sizes = [], sizesAsPercents } = this.props;
358
- let propSize = sizes[index];
359
- if (propSize === undefined && index === this.state.dynamicSection) {
360
- // Find available size
361
- let newSize = 100;
362
- sizes.every((size) => {
363
- if (size) {
364
- newSize -= size;
365
- }
366
- });
367
- propSize = newSize;
368
- }
369
- if (propSize && sizesAsPercents) {
370
- return reverse ? 100 - propSize : propSize;
371
- }
372
- return childrenCount > 0 ? 100 / childrenCount : 0;
373
- }
374
- /**
375
- * Method gets section size when section size is not percent based and 'sizes' prop is passed from outside.
376
- *
377
- * @param {number} index Section index to look up.
378
- * @param {number} childrenCount Count of visible children.
379
- * @returns {React.CSSProperties | undefined} CSS Style object or undefined if no style from 'sizes' prop.
380
- */
381
- getSectionSize(index, childrenCount) {
382
- if (this.props.sizesAsPercents ||
383
- !this.props.sizes ||
384
- childrenCount < 2 ||
385
- (index >= this.props.sizes.length && index >= childrenCount)) {
386
- return undefined;
387
- }
388
- const sectionStyle = {
389
- [this.sizeProperty]: this.props.sizes[index] ? this.props.sizes[index] + 'px' : this.props.sizes[index]
390
- };
391
- if (index === 0) {
392
- sectionStyle[this.startPositionProperty] = 0;
393
- }
394
- if (index === this.props.sizes.length - 1) {
395
- sectionStyle[this.endPositionProperty] = 0;
396
- }
397
- else if (this.props.sizes[index + 1]) {
398
- sectionStyle[this.endPositionProperty] = this.props.sizes[index + 1] + 'px';
399
- }
400
- return sectionStyle;
401
- }
402
- /**
403
- * Gets position style value.
404
- *
405
- * @param {number} childrenCount
406
- * @param {string} value
407
- * @returns {string}
408
- */
409
- getPositionStyleValue(childrenCount, value) {
410
- return childrenCount === 1 ? '0%' : value;
411
- }
412
- /**
413
- * Method returns style object for passed visible section.
414
- * Method calculates size of section depending on several points.
415
- * 1. Section - resized or not.
416
- * 2. Animation - off or on.
417
- *
418
- * @param {number} index Index of section.
419
- * @returns {SectionStyleCalculation} Object which contains visibility state and styles to apply.
420
- */
421
- getVisibleSectionStyle(index) {
422
- const sectionStyle = {
423
- visible: true,
424
- style: {}
425
- };
426
- // Use values from state or calculate initial percents
427
- const childrenCount = this.getVisibleChildrenCount();
428
- const stateSize = this.state.sizes && this.state.sizes[index];
429
- if (childrenCount === this.props.children.length && stateSize) {
430
- sectionStyle.style = {
431
- ...(stateSize.start !== undefined && { [this.startPositionProperty]: stateSize.start + 'px' }),
432
- ...(stateSize.end !== undefined && { [this.endPositionProperty]: stateSize.end + 'px' })
433
- };
434
- if (stateSize.size !== undefined && (stateSize.start === undefined || stateSize.end === undefined)) {
435
- // No need to provide size if start and end defined
436
- sectionStyle.style[this.sizeProperty] = stateSize.size + 'px';
437
- }
438
- }
439
- else {
440
- const toggleSectionSize = this.getSectionSize(index, childrenCount);
441
- if (toggleSectionSize) {
442
- sectionStyle.style = { ...sectionStyle.style, ...toggleSectionSize };
443
- }
444
- else {
445
- const size = this.getSizePercents(index, childrenCount, true);
446
- sectionStyle.style = {
447
- [this.startPositionProperty]: this.getPositionStyleValue(childrenCount, `${index * size}%`),
448
- [this.endPositionProperty]: this.getPositionStyleValue(childrenCount, `${(childrenCount - (index + 1)) * size}%`)
449
- };
450
- }
451
- }
452
- return sectionStyle;
453
- }
454
- /**
455
- * Method returns style object for passed hidden section.
456
- * Method calculates size of section depending on several points.
457
- * 1. Section - resized or not.
458
- * 2. Animation - off or on.
459
- *
460
- * @param {number} index Index of section.
461
- * @returns {SectionStyleCalculation} Object which contains visibility state and styles to apply.
462
- */
463
- getHiddenSectionStyle(index) {
464
- const sectionStyle = {
465
- visible: false
466
- };
467
- // Hidden section when animation is ON
468
- let stateSize = this.state.sizes && this.state.sizes[index];
469
- if (!stateSize &&
470
- this.props.splitterType === UISplitter_1.UISplitterType.Toggle &&
471
- this.props.sizes &&
472
- this.props.sizes[index]) {
473
- stateSize = {
474
- size: this.props.sizes[index],
475
- percentage: false
476
- };
477
- }
478
- let unit;
479
- let size = 0;
480
- if (stateSize) {
481
- unit = 'px';
482
- if (stateSize.size) {
483
- size = stateSize.size;
484
- }
485
- else if (stateSize?.start !== undefined && stateSize?.end !== undefined) {
486
- size = this.getRootSize() - stateSize.end - stateSize.start;
487
- }
488
- }
489
- else {
490
- const childrenCount = this.props.children.length;
491
- const sectionSize = this.getSectionSize(index, childrenCount);
492
- if (sectionSize && sectionSize.width) {
493
- size = parseFloat(sectionSize.width.toString());
494
- unit = 'px';
495
- }
496
- else {
497
- size = this.getSizePercents(index, childrenCount);
498
- unit = '%';
499
- }
500
- }
501
- const hiddenPosition = -size + unit;
502
- sectionStyle.style = {
503
- [this.endPositionProperty]: index === 0 ? '100%' : hiddenPosition,
504
- [this.startPositionProperty]: index === 0 ? hiddenPosition : '100%'
505
- };
506
- return sectionStyle;
507
- }
508
- /**
509
- * Method returns minimal size for passed section.
510
- *
511
- * @param {number} index Index of section.
512
- * @returns {number} Minimal size of section.
513
- */
514
- getMinSectionSize(index) {
515
- const minSectionSize = this.props.minSectionSize;
516
- let minSize = 0;
517
- if (minSectionSize) {
518
- minSize = Array.isArray(minSectionSize) ? minSectionSize[index] : minSectionSize;
519
- }
520
- return minSize;
521
- }
522
- /**
523
- * Method returns class names string depending on props and component state.
524
- *
525
- * @param {boolean} fullSizeMode Is full size mode - only ine sction visible.
526
- * @returns {number} Minimal size of section.
527
- */
528
- getClassNames(fullSizeMode) {
529
- let classNames = ` ${this.props.vertical ? 'sections--vertical' : 'sections--horizontal'}`;
530
- // Animation
531
- const sectionsAnimationClass = ` ${SECTIONS_ANIMATION_CLASS}`;
532
- classNames += `${this.isAnimationEnabled() ? sectionsAnimationClass : ''}`;
533
- // Full 'screen' mode - only one section visible
534
- classNames += `${fullSizeMode ? ' sections--full' : ''}`;
535
- return classNames;
536
- }
537
- /**
538
- * Method returns section's react element based on passed section index.
539
- *
540
- * @param {number} index Section index.
541
- * @param {boolean} isSectionHidden Is section hidden.
542
- * @returns {React.ReactElement | undefined} Section's react element.
543
- */
544
- getSection(index, isSectionHidden) {
545
- const childNode = this.props.children[index];
546
- const sectionStyle = UISections.isSectionVisible(childNode)
547
- ? this.getVisibleSectionStyle(index)
548
- : this.getHiddenSectionStyle(index);
549
- if (!sectionStyle) {
550
- return undefined;
551
- }
552
- const splitterType = this.props.splitterType || UISplitter_1.UISplitterType.Resize;
553
- const splitterLayoutType = this.props.splitterLayoutType || UISplitter_1.UISplitterLayoutType.Standard;
554
- let isSplitterVisible = this.props.splitter && index > 0;
555
- const isSingleSection = this.getVisibleChildrenCount() === 1;
556
- if (isSingleSection && !this.isAnimationEnabled()) {
557
- isSplitterVisible = false;
558
- }
559
- return (react_1.default.createElement("div", { key: index, className: `sections__item${isSplitterVisible ? ' sections__item--' + splitterType : ''}${!sectionStyle.visible ? ' sections__item--hidden' : ''}`, style: sectionStyle.style },
560
- isSplitterVisible && childNode && (react_1.default.createElement(UISplitter_1.UISplitter, { vertical: this.props.vertical, onResize: this.onSplitterResize.bind(this), onResizeStart: this.onSplitterResizeStart.bind(this), onResizeEnd: this.onSplitterResizeEnd.bind(this), onToggle: this.onSplitterToggle.bind(this), hidden: isSectionHidden || isSingleSection, type: splitterType, title: this.props.splitterTitle, splitterLayoutType: splitterLayoutType })),
561
- childNode));
562
- }
563
- /**
564
- * Method checks if animation enabled with current state.
565
- *
566
- * @returns {boolean} True if animation is enabled.
567
- */
568
- isAnimationEnabled() {
569
- return !this.ignoreAnimation && (this.props.animation === true || this.state.animate);
570
- }
571
- /**
572
- * Method returns index of dynamicly sized section.
573
- *
574
- * @returns {number} Index of dynamicly sized section.
575
- */
576
- getDynamicSectionIndex() {
577
- return this.state.dynamicSection !== undefined ? this.state.dynamicSection : 0;
578
- }
579
- /**
580
- * Method converts passed positions to section position object.
581
- *
582
- * @param {UISectionSize} section Section size.
583
- * @returns Position object.
584
- */
585
- getSectionPosition(section) {
586
- return { start: section.start || 0, end: section.end || 0 };
587
- }
588
- /**
589
- * Method calculates spare size for passed section.
590
- *
591
- * @param {SizeCalculationInfo} origin Section size.
592
- * @param {SizeCalculationInfo[]} sizes All section sizes.
593
- * @returns {number} Spare size.
594
- */
595
- getSpareSize(origin, sizes) {
596
- let increaseSize = 0;
597
- let target = origin.minSize - origin.size;
598
- for (const info of sizes) {
599
- if (info === origin) {
600
- continue;
601
- }
602
- if (info.spareSize > 0) {
603
- const useSize = Math.min(info.spareSize, target);
604
- // Update targets
605
- increaseSize += useSize;
606
- info.spareSize -= useSize;
607
- info.size -= useSize;
608
- target -= useSize;
609
- }
610
- if (target <= 0) {
611
- // Desireable target meet requirement
612
- break;
613
- }
614
- }
615
- return increaseSize;
616
- }
617
- /**
618
- * Method converts SizeCalculationInfo into UISectionSize before applying sizes to state.
619
- *
620
- * @param {SizeCalculationInfo[]} sizes Section sizes.
621
- * @returns {UISectionSize[]} Section sizes applyable for state.
622
- */
623
- calculateSectionSizes(sizes) {
624
- // Calculate sizes
625
- for (const section of sizes) {
626
- if (section.size < section.minSize) {
627
- const diff = this.getSpareSize(section, sizes);
628
- if (diff) {
629
- section.size += diff;
630
- }
631
- }
632
- }
633
- // Apply sizes to state
634
- const stateSizes = [];
635
- for (let i = 0; i < sizes.length; i++) {
636
- const sectionSize = {
637
- percentage: false
638
- };
639
- const current = sizes[i];
640
- const next = sizes[i + 1];
641
- const right = next ? next.size : 0;
642
- if (i > 0) {
643
- sectionSize.size = current.size;
644
- sectionSize.start = undefined;
645
- }
646
- else {
647
- sectionSize.start = 0;
648
- }
649
- sectionSize.end = right;
650
- stateSizes.push(sectionSize);
651
- }
652
- return stateSizes;
653
- }
654
- /**
655
- * Method recalculates "start" and "end" position based on size property.
656
- *
657
- * @param {UISectionSize[]} sizes Section sizes.
658
- */
659
- recalculatePositions(sizes) {
660
- // Recalculate positions - START
661
- let start = 0;
662
- sizes.forEach((section) => {
663
- section.start = start;
664
- // Next start
665
- start += section.size || 0;
666
- });
667
- // Recalculate positions - END
668
- let end = 0;
669
- for (let i = sizes.length - 1; i >= 0; i--) {
670
- sizes[i].end = end;
671
- // Next start
672
- end += sizes[i].size || 0;
673
- }
674
- }
675
- /**
676
- * Method returns size of sections container.
677
- *
678
- * @returns {UISectionSize[]} Size of sections container.
679
- */
680
- getRootSize() {
681
- const rootDom = this.rootRef.current;
682
- return rootDom?.getBoundingClientRect()[this.sizeProperty] || 0;
683
- }
684
- /**
685
- * @returns {React.ReactElement}
686
- */
687
- render() {
688
- const sections = [];
689
- let visibleSections = 0;
690
- for (let i = 0; i < this.props.children.length; i++) {
691
- const childNode = this.props.children[i];
692
- const isSectionHidden = !UISections.isSectionVisible(childNode);
693
- if (!isSectionHidden) {
694
- visibleSections++;
695
- }
696
- const section = this.getSection(i, isSectionHidden);
697
- if (section) {
698
- sections.push(section);
699
- }
700
- }
701
- return (react_1.default.createElement("div", { ref: this.rootRef, className: `sections ${this.getClassNames(visibleSections === 1)}`, style: {
702
- ...(this.props.height && { height: this.props.height })
703
- } }, sections));
704
- }
705
- }
706
- exports.UISections = UISections;
707
- UISections.Section = UISection_1.UISection;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UISections = exports.ANIMATION_TIME = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const UISection_1 = require("./UISection");
9
+ const UISplitter_1 = require("./UISplitter");
10
+ require("./UISections.scss");
11
+ exports.ANIMATION_TIME = 300;
12
+ const SECTIONS_ANIMATION_CLASS = 'sections--animated';
13
+ /**
14
+ * UISections component.
15
+ *
16
+ * @exports
17
+ * @class {UISections}
18
+ * @extends {React.Component<UISectionsProps, UISectionsState>}
19
+ */
20
+ class UISections extends react_1.default.Component {
21
+ /**
22
+ * Initializes component properties.
23
+ *
24
+ * @param {UISectionsProps} props
25
+ */
26
+ constructor(props) {
27
+ super(props);
28
+ this.resizeSections = [];
29
+ this.isFullScreen = false;
30
+ this.rootSize = 0;
31
+ this.ignoreAnimation = false;
32
+ this.state = {
33
+ sizes: undefined
34
+ };
35
+ this.onWindowResize = this.onWindowResize.bind(this);
36
+ this.rootRef = react_1.default.createRef();
37
+ this.sizeProperty = props.vertical ? 'height' : 'width';
38
+ this.domSizeProperty = props.vertical ? 'clientHeight' : 'clientWidth';
39
+ this.startPositionProperty = props.vertical ? 'top' : 'left';
40
+ this.endPositionProperty = props.vertical ? 'bottom' : 'right';
41
+ this.sizeProperty = props.vertical ? 'height' : 'width';
42
+ window.addEventListener('resize', this.onWindowResize);
43
+ }
44
+ /**
45
+ * Updates state sizes.
46
+ *
47
+ * @param {number} layoutSize
48
+ * @param {Array<number | UISectionSize | undefine>} sizes
49
+ * @returns {UISectionSize[]}
50
+ */
51
+ updateStateSizes(layoutSize, sizes) {
52
+ let uiSizes = sizes;
53
+ const dynamicSectionIndex = this.getDynamicSectionIndex();
54
+ // Calculate size for dynamic section
55
+ let availableSize = 0;
56
+ sizes.forEach((section, index) => {
57
+ if (typeof section === 'object' && section.size === undefined) {
58
+ const position = this.getSectionPosition(section);
59
+ section.size = Math.abs(this.rootSize - position.end - position.start);
60
+ }
61
+ if (index !== dynamicSectionIndex) {
62
+ availableSize += (typeof section === 'object' ? section.size : section) || 0;
63
+ }
64
+ });
65
+ availableSize = layoutSize - availableSize;
66
+ // Check if number array is passed as sizes. Convert array of number to array of UISectionSize
67
+ if (typeof sizes[0] !== 'object') {
68
+ uiSizes = [];
69
+ let start = 0;
70
+ sizes.forEach((size, index) => {
71
+ size = dynamicSectionIndex !== index ? size : availableSize;
72
+ uiSizes.push({
73
+ percentage: false,
74
+ size,
75
+ start
76
+ });
77
+ start += size || 0;
78
+ });
79
+ }
80
+ // Apply size for dynamic section
81
+ const dynamicSection = uiSizes[dynamicSectionIndex];
82
+ if (dynamicSection) {
83
+ dynamicSection.size = availableSize;
84
+ }
85
+ // Recalculate start and end positions
86
+ this.recalculatePositions(uiSizes);
87
+ // Validate min sizes
88
+ this.validateStateMinSizes(uiSizes);
89
+ return uiSizes;
90
+ }
91
+ componentDidMount() {
92
+ const { sizesAsPercents, sizes } = this.props;
93
+ this.rootSize = this.getRootSize();
94
+ if (!sizesAsPercents && sizes) {
95
+ // Calculate state
96
+ this.setState({
97
+ sizes: this.updateStateSizes(this.rootSize, sizes)
98
+ });
99
+ }
100
+ }
101
+ componentDidUpdate() {
102
+ this.ignoreAnimation = false;
103
+ }
104
+ /**
105
+ * Gets derived state from properties.
106
+ *
107
+ * @param {UISectionProps} nextProps
108
+ * @param {UISectionsState} prevState
109
+ * @returns {UISectionsState | null}
110
+ */
111
+ static getDerivedStateFromProps(nextProps, prevState) {
112
+ // Handle property "animation" as array
113
+ let animate = prevState.animate;
114
+ let visibleSections;
115
+ let dynamicSection = 0;
116
+ if (Array.isArray(nextProps.animation)) {
117
+ visibleSections = UISections.getVisibleSections(nextProps.children);
118
+ // Check if there is transition for section with enabled animation
119
+ let transitionAnimation;
120
+ for (let i = 0; i < nextProps.animation.length; i++) {
121
+ if (visibleSections?.includes(i) !== prevState.visibleSections?.includes(i)) {
122
+ transitionAnimation = transitionAnimation || nextProps.animation[i];
123
+ }
124
+ }
125
+ if (transitionAnimation !== undefined) {
126
+ // Visibility of sections changed - apply animation for transition section
127
+ animate = transitionAnimation;
128
+ }
129
+ }
130
+ else {
131
+ animate = nextProps.animation;
132
+ }
133
+ // Find dynamic section index
134
+ nextProps.sizes?.forEach((size, index) => {
135
+ if (size === undefined) {
136
+ dynamicSection = index;
137
+ }
138
+ });
139
+ return {
140
+ animate,
141
+ visibleSections,
142
+ dynamicSection
143
+ };
144
+ }
145
+ /**
146
+ * Validates state min sizes.
147
+ *
148
+ * @param {UISectionSize[]} sizes
149
+ */
150
+ validateStateMinSizes(sizes) {
151
+ // Prerequisite. Get size infos
152
+ let minSizesSum = 0;
153
+ let recalculateSizes = false;
154
+ const sizesInfo = [];
155
+ for (let i = 0; i < this.props.children.length; i++) {
156
+ //const size = this.getSectionCurrentSize(i);
157
+ const size = sizes[i].size || 0;
158
+ const minSize = this.getMinSectionSize(i);
159
+ if (minSize > size) {
160
+ recalculateSizes = true;
161
+ }
162
+ minSizesSum += minSize;
163
+ // Sizes data
164
+ sizesInfo.push({
165
+ size,
166
+ minSize,
167
+ spareSize: size - minSize
168
+ });
169
+ }
170
+ // First Part. Check if full screen required
171
+ const layoutSize = this.getRootSize();
172
+ // Second Part. Calculate sections which less than min size.
173
+ if (recalculateSizes && layoutSize >= minSizesSum) {
174
+ const recalculatedSizes = this.calculateSectionSizes(sizesInfo);
175
+ for (let i = 0; i < sizes.length; i++) {
176
+ sizes[i] = recalculatedSizes[i];
177
+ }
178
+ }
179
+ // Check full screen toggle
180
+ const isFullScreen = layoutSize < minSizesSum;
181
+ if (isFullScreen !== this.isFullScreen) {
182
+ this.isFullScreen = isFullScreen;
183
+ this.props.onToggleFullscreen?.(isFullScreen);
184
+ }
185
+ }
186
+ onWindowResize() {
187
+ let { sizes } = this.state;
188
+ // Dynamic section index
189
+ const layoutSize = this.getRootSize();
190
+ if (sizes) {
191
+ // Update sizes after resize
192
+ sizes = this.updateStateSizes(layoutSize, sizes);
193
+ // Apply state
194
+ this.ignoreAnimation = true;
195
+ this.setState({
196
+ sizes: sizes
197
+ });
198
+ }
199
+ this.rootSize = layoutSize;
200
+ }
201
+ /**
202
+ * Method returns indices of visible sections.
203
+ *
204
+ * @param {React.ReactNodeArray} sections Section elements.
205
+ * @returns {number[]} Indices of visible sections.
206
+ */
207
+ static getVisibleSections(sections) {
208
+ const visibleSections = [];
209
+ sections.forEach((child, i) => {
210
+ if (!UISections.isSectionVisible(child)) {
211
+ visibleSections.push(i);
212
+ }
213
+ });
214
+ return visibleSections;
215
+ }
216
+ /**
217
+ * Method checks is passed child section visible or not.
218
+ *
219
+ * @param {React.ReactElement | undefined} node React child node.
220
+ * @returns {boolean} True if section visible.
221
+ */
222
+ static isSectionVisible(node) {
223
+ if (node && node.type === UISection_1.UISection) {
224
+ return !node.props.hidden;
225
+ }
226
+ return false;
227
+ }
228
+ /**
229
+ * Method called when resizing of section started.
230
+ */
231
+ onSplitterResizeStart() {
232
+ const rootDom = this.rootRef.current;
233
+ const resizeSections = [];
234
+ if (rootDom && rootDom.childNodes) {
235
+ rootDom.classList.remove(SECTIONS_ANIMATION_CLASS);
236
+ for (let i = 0; i < rootDom.childNodes.length; i++) {
237
+ const minSectionSize = this.getMinSectionSize(i);
238
+ const siblingMinSectionSize = this.getMinSectionSize(i === 0 ? 1 : 0);
239
+ const sectionDom = rootDom.children[i];
240
+ const maxSize = Math.max(minSectionSize, rootDom[this.domSizeProperty] - siblingMinSectionSize);
241
+ resizeSections.push({
242
+ size: sectionDom[this.domSizeProperty],
243
+ dom: sectionDom,
244
+ maxSize,
245
+ section: this.resizeSections[i]
246
+ ? this.resizeSections[i].section
247
+ : {
248
+ percentage: false
249
+ }
250
+ });
251
+ }
252
+ }
253
+ this.resizeSections = resizeSections;
254
+ }
255
+ /**
256
+ * Method called when resizing of section is happening.
257
+ *
258
+ * @param {number} position Delta position in pixels.
259
+ * @returns {boolean} If resizing was happened - it can return false when splitter meets resizing limitation.
260
+ */
261
+ onSplitterResize(position) {
262
+ const resizeSections = position !== 0 ? this.resizeSections : [];
263
+ let left = 0;
264
+ for (let i = 0; i < resizeSections.length; i++) {
265
+ const minSectionSize = this.getMinSectionSize(i);
266
+ const resizeSection = resizeSections[i];
267
+ let newSize = resizeSection.size + (i === 0 ? position : -position);
268
+ if (minSectionSize === resizeSection.maxSize) {
269
+ // Ignore resize - section is not resizable
270
+ continue;
271
+ }
272
+ // Do not allow size exceed min and max boundaries
273
+ if (newSize < minSectionSize) {
274
+ position = this.correctBoundaryPosition(position, minSectionSize, newSize, i === 0);
275
+ newSize = minSectionSize;
276
+ }
277
+ else if (newSize > resizeSection.maxSize) {
278
+ position = this.correctBoundaryPosition(position, resizeSection.maxSize, newSize, i === 0);
279
+ newSize = resizeSection.maxSize;
280
+ }
281
+ const sectionSize = {
282
+ percentage: false
283
+ };
284
+ const nextSession = resizeSections[i + 1];
285
+ const right = nextSession ? nextSession.size - position : 0;
286
+ if (i > 0) {
287
+ sectionSize.size = newSize;
288
+ sectionSize.start = left;
289
+ resizeSection.dom.style[this.startPositionProperty] = left + 'px';
290
+ }
291
+ else {
292
+ sectionSize.start = 0;
293
+ resizeSection.dom.style[this.startPositionProperty] = '0px';
294
+ }
295
+ sectionSize.end = right;
296
+ resizeSection.dom.style[this.endPositionProperty] = right + 'px';
297
+ resizeSection.section = sectionSize;
298
+ left += newSize;
299
+ }
300
+ return false;
301
+ }
302
+ /**
303
+ * Method returns corrected position based on boundary and size.
304
+ *
305
+ * @param {number} position Delta position in pixels.
306
+ * @param {number} boundary Boundary position.
307
+ * @param {number} size Section size.
308
+ * @param {boolean} positive Direction.
309
+ * @returns {number} Position after correction based on boundary.
310
+ */
311
+ correctBoundaryPosition(position, boundary, size, positive) {
312
+ const diff = boundary - size;
313
+ return position + (positive ? diff : -diff);
314
+ }
315
+ /**
316
+ * Method called when resizing session ended.
317
+ */
318
+ onSplitterResizeEnd() {
319
+ const rootDom = this.rootRef.current;
320
+ if (rootDom && this.isAnimationEnabled()) {
321
+ rootDom.classList.add(SECTIONS_ANIMATION_CLASS);
322
+ }
323
+ const sizes = this.resizeSections.map((resizeSection) => resizeSection.section);
324
+ if (sizes.some((size) => size.end !== undefined || size.start !== undefined || size.size !== undefined)) {
325
+ this.setState({
326
+ sizes
327
+ });
328
+ }
329
+ this.props.onResize?.(sizes);
330
+ }
331
+ /**
332
+ * Method called when splitter with type 'Toggle' was toggled.
333
+ */
334
+ onSplitterToggle() {
335
+ if (this.props.onClose) {
336
+ this.props.onClose();
337
+ }
338
+ }
339
+ /**
340
+ * Method returns visible children sections count.
341
+ *
342
+ * @returns {number} Count of visible children sections.
343
+ */
344
+ getVisibleChildrenCount() {
345
+ return this.props.children.filter((child) => child && UISections.isSectionVisible(child))
346
+ .length;
347
+ }
348
+ /**
349
+ * Method returns size of section in percents.
350
+ *
351
+ * @param {number} index Target section index.
352
+ * @param {number} childrenCount Count of children.
353
+ * @param {boolean} [reverse=false] Reverse calculation(width vs right).
354
+ * @returns {number} Size of section in percents. For example 50% => 0.5.
355
+ */
356
+ getSizePercents(index, childrenCount, reverse = false) {
357
+ const { sizes = [], sizesAsPercents } = this.props;
358
+ let propSize = sizes[index];
359
+ if (propSize === undefined && index === this.state.dynamicSection) {
360
+ // Find available size
361
+ let newSize = 100;
362
+ sizes.every((size) => {
363
+ if (size) {
364
+ newSize -= size;
365
+ }
366
+ });
367
+ propSize = newSize;
368
+ }
369
+ if (propSize && sizesAsPercents) {
370
+ return reverse ? 100 - propSize : propSize;
371
+ }
372
+ return childrenCount > 0 ? 100 / childrenCount : 0;
373
+ }
374
+ /**
375
+ * Method gets section size when section size is not percent based and 'sizes' prop is passed from outside.
376
+ *
377
+ * @param {number} index Section index to look up.
378
+ * @param {number} childrenCount Count of visible children.
379
+ * @returns {React.CSSProperties | undefined} CSS Style object or undefined if no style from 'sizes' prop.
380
+ */
381
+ getSectionSize(index, childrenCount) {
382
+ if (this.props.sizesAsPercents ||
383
+ !this.props.sizes ||
384
+ childrenCount < 2 ||
385
+ (index >= this.props.sizes.length && index >= childrenCount)) {
386
+ return undefined;
387
+ }
388
+ const sectionStyle = {
389
+ [this.sizeProperty]: this.props.sizes[index] ? this.props.sizes[index] + 'px' : this.props.sizes[index]
390
+ };
391
+ if (index === 0) {
392
+ sectionStyle[this.startPositionProperty] = 0;
393
+ }
394
+ if (index === this.props.sizes.length - 1) {
395
+ sectionStyle[this.endPositionProperty] = 0;
396
+ }
397
+ else if (this.props.sizes[index + 1]) {
398
+ sectionStyle[this.endPositionProperty] = this.props.sizes[index + 1] + 'px';
399
+ }
400
+ return sectionStyle;
401
+ }
402
+ /**
403
+ * Gets position style value.
404
+ *
405
+ * @param {number} childrenCount
406
+ * @param {string} value
407
+ * @returns {string}
408
+ */
409
+ getPositionStyleValue(childrenCount, value) {
410
+ return childrenCount === 1 ? '0%' : value;
411
+ }
412
+ /**
413
+ * Method returns style object for passed visible section.
414
+ * Method calculates size of section depending on several points.
415
+ * 1. Section - resized or not.
416
+ * 2. Animation - off or on.
417
+ *
418
+ * @param {number} index Index of section.
419
+ * @returns {SectionStyleCalculation} Object which contains visibility state and styles to apply.
420
+ */
421
+ getVisibleSectionStyle(index) {
422
+ const sectionStyle = {
423
+ visible: true,
424
+ style: {}
425
+ };
426
+ // Use values from state or calculate initial percents
427
+ const childrenCount = this.getVisibleChildrenCount();
428
+ const stateSize = this.state.sizes && this.state.sizes[index];
429
+ if (childrenCount === this.props.children.length && stateSize) {
430
+ sectionStyle.style = {
431
+ ...(stateSize.start !== undefined && { [this.startPositionProperty]: stateSize.start + 'px' }),
432
+ ...(stateSize.end !== undefined && { [this.endPositionProperty]: stateSize.end + 'px' })
433
+ };
434
+ if (stateSize.size !== undefined && (stateSize.start === undefined || stateSize.end === undefined)) {
435
+ // No need to provide size if start and end defined
436
+ sectionStyle.style[this.sizeProperty] = stateSize.size + 'px';
437
+ }
438
+ }
439
+ else {
440
+ const toggleSectionSize = this.getSectionSize(index, childrenCount);
441
+ if (toggleSectionSize) {
442
+ sectionStyle.style = { ...sectionStyle.style, ...toggleSectionSize };
443
+ }
444
+ else {
445
+ const size = this.getSizePercents(index, childrenCount, true);
446
+ sectionStyle.style = {
447
+ [this.startPositionProperty]: this.getPositionStyleValue(childrenCount, `${index * size}%`),
448
+ [this.endPositionProperty]: this.getPositionStyleValue(childrenCount, `${(childrenCount - (index + 1)) * size}%`)
449
+ };
450
+ }
451
+ }
452
+ return sectionStyle;
453
+ }
454
+ /**
455
+ * Method returns style object for passed hidden section.
456
+ * Method calculates size of section depending on several points.
457
+ * 1. Section - resized or not.
458
+ * 2. Animation - off or on.
459
+ *
460
+ * @param {number} index Index of section.
461
+ * @returns {SectionStyleCalculation} Object which contains visibility state and styles to apply.
462
+ */
463
+ getHiddenSectionStyle(index) {
464
+ const sectionStyle = {
465
+ visible: false
466
+ };
467
+ // Hidden section when animation is ON
468
+ let stateSize = this.state.sizes && this.state.sizes[index];
469
+ if (!stateSize &&
470
+ this.props.splitterType === UISplitter_1.UISplitterType.Toggle &&
471
+ this.props.sizes &&
472
+ this.props.sizes[index]) {
473
+ stateSize = {
474
+ size: this.props.sizes[index],
475
+ percentage: false
476
+ };
477
+ }
478
+ let unit;
479
+ let size = 0;
480
+ if (stateSize) {
481
+ unit = 'px';
482
+ if (stateSize.size) {
483
+ size = stateSize.size;
484
+ }
485
+ else if (stateSize?.start !== undefined && stateSize?.end !== undefined) {
486
+ size = this.getRootSize() - stateSize.end - stateSize.start;
487
+ }
488
+ }
489
+ else {
490
+ const childrenCount = this.props.children.length;
491
+ const sectionSize = this.getSectionSize(index, childrenCount);
492
+ if (sectionSize && sectionSize.width) {
493
+ size = parseFloat(sectionSize.width.toString());
494
+ unit = 'px';
495
+ }
496
+ else {
497
+ size = this.getSizePercents(index, childrenCount);
498
+ unit = '%';
499
+ }
500
+ }
501
+ const hiddenPosition = -size + unit;
502
+ sectionStyle.style = {
503
+ [this.endPositionProperty]: index === 0 ? '100%' : hiddenPosition,
504
+ [this.startPositionProperty]: index === 0 ? hiddenPosition : '100%'
505
+ };
506
+ return sectionStyle;
507
+ }
508
+ /**
509
+ * Method returns minimal size for passed section.
510
+ *
511
+ * @param {number} index Index of section.
512
+ * @returns {number} Minimal size of section.
513
+ */
514
+ getMinSectionSize(index) {
515
+ const minSectionSize = this.props.minSectionSize;
516
+ let minSize = 0;
517
+ if (minSectionSize) {
518
+ minSize = Array.isArray(minSectionSize) ? minSectionSize[index] : minSectionSize;
519
+ }
520
+ return minSize;
521
+ }
522
+ /**
523
+ * Method returns class names string depending on props and component state.
524
+ *
525
+ * @param {boolean} fullSizeMode Is full size mode - only ine sction visible.
526
+ * @returns {number} Minimal size of section.
527
+ */
528
+ getClassNames(fullSizeMode) {
529
+ let classNames = ` ${this.props.vertical ? 'sections--vertical' : 'sections--horizontal'}`;
530
+ // Animation
531
+ const sectionsAnimationClass = ` ${SECTIONS_ANIMATION_CLASS}`;
532
+ classNames += `${this.isAnimationEnabled() ? sectionsAnimationClass : ''}`;
533
+ // Full 'screen' mode - only one section visible
534
+ classNames += `${fullSizeMode ? ' sections--full' : ''}`;
535
+ return classNames;
536
+ }
537
+ /**
538
+ * Method returns section's react element based on passed section index.
539
+ *
540
+ * @param {number} index Section index.
541
+ * @param {boolean} isSectionHidden Is section hidden.
542
+ * @returns {React.ReactElement | undefined} Section's react element.
543
+ */
544
+ getSection(index, isSectionHidden) {
545
+ const childNode = this.props.children[index];
546
+ const sectionStyle = UISections.isSectionVisible(childNode)
547
+ ? this.getVisibleSectionStyle(index)
548
+ : this.getHiddenSectionStyle(index);
549
+ if (!sectionStyle) {
550
+ return undefined;
551
+ }
552
+ const splitterType = this.props.splitterType || UISplitter_1.UISplitterType.Resize;
553
+ const splitterLayoutType = this.props.splitterLayoutType || UISplitter_1.UISplitterLayoutType.Standard;
554
+ let isSplitterVisible = this.props.splitter && index > 0;
555
+ const isSingleSection = this.getVisibleChildrenCount() === 1;
556
+ if (isSingleSection && !this.isAnimationEnabled()) {
557
+ isSplitterVisible = false;
558
+ }
559
+ return (react_1.default.createElement("div", { key: index, className: `sections__item${isSplitterVisible ? ' sections__item--' + splitterType : ''}${!sectionStyle.visible ? ' sections__item--hidden' : ''}`, style: sectionStyle.style },
560
+ isSplitterVisible && childNode && (react_1.default.createElement(UISplitter_1.UISplitter, { vertical: this.props.vertical, onResize: this.onSplitterResize.bind(this), onResizeStart: this.onSplitterResizeStart.bind(this), onResizeEnd: this.onSplitterResizeEnd.bind(this), onToggle: this.onSplitterToggle.bind(this), hidden: isSectionHidden || isSingleSection, type: splitterType, title: this.props.splitterTitle, splitterLayoutType: splitterLayoutType })),
561
+ childNode));
562
+ }
563
+ /**
564
+ * Method checks if animation enabled with current state.
565
+ *
566
+ * @returns {boolean} True if animation is enabled.
567
+ */
568
+ isAnimationEnabled() {
569
+ return !this.ignoreAnimation && (this.props.animation === true || this.state.animate);
570
+ }
571
+ /**
572
+ * Method returns index of dynamicly sized section.
573
+ *
574
+ * @returns {number} Index of dynamicly sized section.
575
+ */
576
+ getDynamicSectionIndex() {
577
+ return this.state.dynamicSection !== undefined ? this.state.dynamicSection : 0;
578
+ }
579
+ /**
580
+ * Method converts passed positions to section position object.
581
+ *
582
+ * @param {UISectionSize} section Section size.
583
+ * @returns Position object.
584
+ */
585
+ getSectionPosition(section) {
586
+ return { start: section.start || 0, end: section.end || 0 };
587
+ }
588
+ /**
589
+ * Method calculates spare size for passed section.
590
+ *
591
+ * @param {SizeCalculationInfo} origin Section size.
592
+ * @param {SizeCalculationInfo[]} sizes All section sizes.
593
+ * @returns {number} Spare size.
594
+ */
595
+ getSpareSize(origin, sizes) {
596
+ let increaseSize = 0;
597
+ let target = origin.minSize - origin.size;
598
+ for (const info of sizes) {
599
+ if (info === origin) {
600
+ continue;
601
+ }
602
+ if (info.spareSize > 0) {
603
+ const useSize = Math.min(info.spareSize, target);
604
+ // Update targets
605
+ increaseSize += useSize;
606
+ info.spareSize -= useSize;
607
+ info.size -= useSize;
608
+ target -= useSize;
609
+ }
610
+ if (target <= 0) {
611
+ // Desireable target meet requirement
612
+ break;
613
+ }
614
+ }
615
+ return increaseSize;
616
+ }
617
+ /**
618
+ * Method converts SizeCalculationInfo into UISectionSize before applying sizes to state.
619
+ *
620
+ * @param {SizeCalculationInfo[]} sizes Section sizes.
621
+ * @returns {UISectionSize[]} Section sizes applyable for state.
622
+ */
623
+ calculateSectionSizes(sizes) {
624
+ // Calculate sizes
625
+ for (const section of sizes) {
626
+ if (section.size < section.minSize) {
627
+ const diff = this.getSpareSize(section, sizes);
628
+ if (diff) {
629
+ section.size += diff;
630
+ }
631
+ }
632
+ }
633
+ // Apply sizes to state
634
+ const stateSizes = [];
635
+ for (let i = 0; i < sizes.length; i++) {
636
+ const sectionSize = {
637
+ percentage: false
638
+ };
639
+ const current = sizes[i];
640
+ const next = sizes[i + 1];
641
+ const right = next ? next.size : 0;
642
+ if (i > 0) {
643
+ sectionSize.size = current.size;
644
+ sectionSize.start = undefined;
645
+ }
646
+ else {
647
+ sectionSize.start = 0;
648
+ }
649
+ sectionSize.end = right;
650
+ stateSizes.push(sectionSize);
651
+ }
652
+ return stateSizes;
653
+ }
654
+ /**
655
+ * Method recalculates "start" and "end" position based on size property.
656
+ *
657
+ * @param {UISectionSize[]} sizes Section sizes.
658
+ */
659
+ recalculatePositions(sizes) {
660
+ // Recalculate positions - START
661
+ let start = 0;
662
+ sizes.forEach((section) => {
663
+ section.start = start;
664
+ // Next start
665
+ start += section.size || 0;
666
+ });
667
+ // Recalculate positions - END
668
+ let end = 0;
669
+ for (let i = sizes.length - 1; i >= 0; i--) {
670
+ sizes[i].end = end;
671
+ // Next start
672
+ end += sizes[i].size || 0;
673
+ }
674
+ }
675
+ /**
676
+ * Method returns size of sections container.
677
+ *
678
+ * @returns {UISectionSize[]} Size of sections container.
679
+ */
680
+ getRootSize() {
681
+ const rootDom = this.rootRef.current;
682
+ return rootDom?.getBoundingClientRect()[this.sizeProperty] || 0;
683
+ }
684
+ /**
685
+ * @returns {React.ReactElement}
686
+ */
687
+ render() {
688
+ const sections = [];
689
+ let visibleSections = 0;
690
+ for (let i = 0; i < this.props.children.length; i++) {
691
+ const childNode = this.props.children[i];
692
+ const isSectionHidden = !UISections.isSectionVisible(childNode);
693
+ if (!isSectionHidden) {
694
+ visibleSections++;
695
+ }
696
+ const section = this.getSection(i, isSectionHidden);
697
+ if (section) {
698
+ sections.push(section);
699
+ }
700
+ }
701
+ return (react_1.default.createElement("div", { ref: this.rootRef, className: `sections ${this.getClassNames(visibleSections === 1)}`, style: {
702
+ ...(this.props.height && { height: this.props.height })
703
+ } }, sections));
704
+ }
705
+ }
706
+ exports.UISections = UISections;
707
+ UISections.Section = UISection_1.UISection;
708
708
  //# sourceMappingURL=UISections.js.map