@dxtmisha/constructor 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +136 -0
  3. package/package.json +124 -0
  4. package/src/classes/CaptionInclude.ts +71 -0
  5. package/src/classes/DescriptionInclude.ts +70 -0
  6. package/src/classes/EnabledInclude.ts +56 -0
  7. package/src/classes/EventClickInclude.ts +138 -0
  8. package/src/classes/LabelHighlightInclude.ts +90 -0
  9. package/src/classes/LabelInclude.ts +171 -0
  10. package/src/classes/LabelNumberInclude.ts +70 -0
  11. package/src/classes/ModelInclude.ts +49 -0
  12. package/src/classes/PrefixInclude.ts +71 -0
  13. package/src/classes/SuffixInclude.ts +71 -0
  14. package/src/classes/field/FieldAttributesInclude.ts +100 -0
  15. package/src/classes/field/FieldChangeInclude.ts +52 -0
  16. package/src/classes/field/FieldCodeInclude.ts +69 -0
  17. package/src/classes/field/FieldElementInclude.ts +97 -0
  18. package/src/classes/field/FieldInputCheckInclude.ts +128 -0
  19. package/src/classes/field/FieldMatchInclude.ts +101 -0
  20. package/src/classes/field/FieldPatternInclude.ts +42 -0
  21. package/src/classes/field/FieldTypeInclude.ts +42 -0
  22. package/src/classes/field/FieldValidationInclude.ts +196 -0
  23. package/src/classes/field/FieldValueInclude.ts +318 -0
  24. package/src/classes/field/FieldVisibilityInclude.ts +21 -0
  25. package/src/constructors/Badge/Badge.ts +73 -0
  26. package/src/constructors/Badge/BadgeDesign.tsx +127 -0
  27. package/src/constructors/Badge/BadgeInclude.ts +78 -0
  28. package/src/constructors/Badge/basicTypes.ts +15 -0
  29. package/src/constructors/Badge/index.ts +5 -0
  30. package/src/constructors/Badge/properties.json +36 -0
  31. package/src/constructors/Badge/props.ts +43 -0
  32. package/src/constructors/Badge/style.scss +83 -0
  33. package/src/constructors/Badge/types.ts +47 -0
  34. package/src/constructors/Bars/Bars.ts +188 -0
  35. package/src/constructors/Bars/BarsAction.ts +57 -0
  36. package/src/constructors/Bars/BarsDesign.tsx +229 -0
  37. package/src/constructors/Bars/BarsInclude.ts +116 -0
  38. package/src/constructors/Bars/basicTypes.ts +40 -0
  39. package/src/constructors/Bars/index.ts +6 -0
  40. package/src/constructors/Bars/properties.json +6 -0
  41. package/src/constructors/Bars/props.ts +63 -0
  42. package/src/constructors/Bars/style.scss +18 -0
  43. package/src/constructors/Bars/types.ts +58 -0
  44. package/src/constructors/Button/Button.ts +88 -0
  45. package/src/constructors/Button/ButtonDesign.tsx +136 -0
  46. package/src/constructors/Button/ButtonInclude.ts +80 -0
  47. package/src/constructors/Button/basicTypes.ts +12 -0
  48. package/src/constructors/Button/index.ts +5 -0
  49. package/src/constructors/Button/properties.json +84 -0
  50. package/src/constructors/Button/props.ts +55 -0
  51. package/src/constructors/Button/style.scss +96 -0
  52. package/src/constructors/Button/types.ts +56 -0
  53. package/src/constructors/Cell/Cell.ts +127 -0
  54. package/src/constructors/Cell/CellDesign.tsx +203 -0
  55. package/src/constructors/Cell/basicTypes.ts +6 -0
  56. package/src/constructors/Cell/index.ts +5 -0
  57. package/src/constructors/Cell/properties.json +52 -0
  58. package/src/constructors/Cell/props.ts +61 -0
  59. package/src/constructors/Cell/style.scss +80 -0
  60. package/src/constructors/Cell/types.ts +68 -0
  61. package/src/constructors/Chip/Chip.ts +33 -0
  62. package/src/constructors/Chip/ChipDesign.tsx +26 -0
  63. package/src/constructors/Chip/basicTypes.ts +0 -0
  64. package/src/constructors/Chip/index.ts +4 -0
  65. package/src/constructors/Chip/properties.json +3 -0
  66. package/src/constructors/Chip/props.ts +44 -0
  67. package/src/constructors/Chip/style.scss +6 -0
  68. package/src/constructors/Chip/types.ts +53 -0
  69. package/src/constructors/Field/Field.ts +147 -0
  70. package/src/constructors/Field/FieldDesign.tsx +372 -0
  71. package/src/constructors/Field/FieldIcons.ts +99 -0
  72. package/src/constructors/Field/FieldInclude.ts +72 -0
  73. package/src/constructors/Field/FieldSize.ts +93 -0
  74. package/src/constructors/Field/basicTypes.ts +90 -0
  75. package/src/constructors/Field/index.ts +5 -0
  76. package/src/constructors/Field/properties.json +86 -0
  77. package/src/constructors/Field/props.ts +88 -0
  78. package/src/constructors/Field/style.scss +556 -0
  79. package/src/constructors/Field/types.ts +78 -0
  80. package/src/constructors/FieldCounter/FieldCounter.ts +75 -0
  81. package/src/constructors/FieldCounter/FieldCounterDesign.tsx +122 -0
  82. package/src/constructors/FieldCounter/FieldCounterInclude.ts +98 -0
  83. package/src/constructors/FieldCounter/basicTypes.ts +25 -0
  84. package/src/constructors/FieldCounter/index.ts +6 -0
  85. package/src/constructors/FieldCounter/properties.json +3 -0
  86. package/src/constructors/FieldCounter/props.ts +32 -0
  87. package/src/constructors/FieldCounter/style.scss +4 -0
  88. package/src/constructors/FieldCounter/types.ts +42 -0
  89. package/src/constructors/FieldLabel/FieldLabel.ts +93 -0
  90. package/src/constructors/FieldLabel/FieldLabelDesign.tsx +156 -0
  91. package/src/constructors/FieldLabel/FieldLabelInclude.ts +91 -0
  92. package/src/constructors/FieldLabel/basicTypes.ts +34 -0
  93. package/src/constructors/FieldLabel/index.ts +6 -0
  94. package/src/constructors/FieldLabel/properties.json +4 -0
  95. package/src/constructors/FieldLabel/props.ts +40 -0
  96. package/src/constructors/FieldLabel/style.scss +10 -0
  97. package/src/constructors/FieldLabel/types.ts +49 -0
  98. package/src/constructors/FieldMessage/FieldMessage.ts +79 -0
  99. package/src/constructors/FieldMessage/FieldMessageDesign.tsx +159 -0
  100. package/src/constructors/FieldMessage/FieldMessageInclude.ts +105 -0
  101. package/src/constructors/FieldMessage/FieldMessageMessage.ts +54 -0
  102. package/src/constructors/FieldMessage/basicTypes.ts +27 -0
  103. package/src/constructors/FieldMessage/index.ts +6 -0
  104. package/src/constructors/FieldMessage/properties.json +9 -0
  105. package/src/constructors/FieldMessage/props.ts +40 -0
  106. package/src/constructors/FieldMessage/style.scss +13 -0
  107. package/src/constructors/FieldMessage/types.ts +49 -0
  108. package/src/constructors/Icon/Icon.ts +105 -0
  109. package/src/constructors/Icon/IconDesign.tsx +157 -0
  110. package/src/constructors/Icon/IconInclude.ts +64 -0
  111. package/src/constructors/Icon/IconLiteInclude.ts +121 -0
  112. package/src/constructors/Icon/IconTrailingInclude.ts +106 -0
  113. package/src/constructors/Icon/basicTypes.ts +50 -0
  114. package/src/constructors/Icon/index.ts +8 -0
  115. package/src/constructors/Icon/properties.json +25 -0
  116. package/src/constructors/Icon/props.ts +54 -0
  117. package/src/constructors/Icon/style.scss +106 -0
  118. package/src/constructors/Icon/types.ts +46 -0
  119. package/src/constructors/Image/Image.ts +184 -0
  120. package/src/constructors/Image/ImageAdaptiveGroup.ts +230 -0
  121. package/src/constructors/Image/ImageAdaptiveItem.ts +295 -0
  122. package/src/constructors/Image/ImageBackground.ts +127 -0
  123. package/src/constructors/Image/ImageCalculation.ts +184 -0
  124. package/src/constructors/Image/ImageCalculationList.ts +61 -0
  125. package/src/constructors/Image/ImageCoordinator.ts +104 -0
  126. package/src/constructors/Image/ImageData.ts +99 -0
  127. package/src/constructors/Image/ImageDesign.tsx +137 -0
  128. package/src/constructors/Image/ImageFile.ts +137 -0
  129. package/src/constructors/Image/ImageInclude.ts +53 -0
  130. package/src/constructors/Image/ImagePdf.ts +44 -0
  131. package/src/constructors/Image/ImagePosition.ts +49 -0
  132. package/src/constructors/Image/ImageType.ts +83 -0
  133. package/src/constructors/Image/basicTypes.ts +70 -0
  134. package/src/constructors/Image/index.ts +5 -0
  135. package/src/constructors/Image/properties.json +17 -0
  136. package/src/constructors/Image/props.ts +66 -0
  137. package/src/constructors/Image/style.scss +77 -0
  138. package/src/constructors/Image/types.ts +49 -0
  139. package/src/constructors/List/List.ts +267 -0
  140. package/src/constructors/List/ListControl.ts +194 -0
  141. package/src/constructors/List/ListDesign.tsx +382 -0
  142. package/src/constructors/List/ListFocus.ts +196 -0
  143. package/src/constructors/List/ListGo.ts +283 -0
  144. package/src/constructors/List/ListSearch.ts +113 -0
  145. package/src/constructors/List/basicTypes.ts +3 -0
  146. package/src/constructors/List/index.ts +5 -0
  147. package/src/constructors/List/properties.json +16 -0
  148. package/src/constructors/List/props.ts +76 -0
  149. package/src/constructors/List/style.scss +36 -0
  150. package/src/constructors/List/types.ts +66 -0
  151. package/src/constructors/ListGroup/ListGroup.ts +53 -0
  152. package/src/constructors/ListGroup/ListGroupDesign.tsx +180 -0
  153. package/src/constructors/ListGroup/ListGroupOpen.ts +56 -0
  154. package/src/constructors/ListGroup/basicTypes.ts +3 -0
  155. package/src/constructors/ListGroup/index.ts +5 -0
  156. package/src/constructors/ListGroup/properties.json +15 -0
  157. package/src/constructors/ListGroup/props.ts +30 -0
  158. package/src/constructors/ListGroup/style.scss +18 -0
  159. package/src/constructors/ListGroup/types.ts +51 -0
  160. package/src/constructors/ListItem/ListItem.ts +115 -0
  161. package/src/constructors/ListItem/ListItemDesign.tsx +196 -0
  162. package/src/constructors/ListItem/basicTypes.ts +3 -0
  163. package/src/constructors/ListItem/index.ts +5 -0
  164. package/src/constructors/ListItem/properties.json +52 -0
  165. package/src/constructors/ListItem/props.ts +78 -0
  166. package/src/constructors/ListItem/style.scss +152 -0
  167. package/src/constructors/ListItem/types.ts +78 -0
  168. package/src/constructors/ListMenu/ListMenu.ts +52 -0
  169. package/src/constructors/ListMenu/ListMenuDesign.tsx +127 -0
  170. package/src/constructors/ListMenu/basicTypes.ts +3 -0
  171. package/src/constructors/ListMenu/index.ts +5 -0
  172. package/src/constructors/ListMenu/properties.json +19 -0
  173. package/src/constructors/ListMenu/props.ts +34 -0
  174. package/src/constructors/ListMenu/style.scss +5 -0
  175. package/src/constructors/ListMenu/types.ts +54 -0
  176. package/src/constructors/Mask/Mask.ts +321 -0
  177. package/src/constructors/Mask/MaskBuffer.ts +89 -0
  178. package/src/constructors/Mask/MaskCharacter.ts +192 -0
  179. package/src/constructors/Mask/MaskCharacterLength.ts +40 -0
  180. package/src/constructors/Mask/MaskData.ts +287 -0
  181. package/src/constructors/Mask/MaskDate.ts +157 -0
  182. package/src/constructors/Mask/MaskDesign.tsx +217 -0
  183. package/src/constructors/Mask/MaskEmit.ts +140 -0
  184. package/src/constructors/Mask/MaskEvent.ts +347 -0
  185. package/src/constructors/Mask/MaskFocus.ts +49 -0
  186. package/src/constructors/Mask/MaskFormat.ts +216 -0
  187. package/src/constructors/Mask/MaskItem.ts +218 -0
  188. package/src/constructors/Mask/MaskMatch.ts +73 -0
  189. package/src/constructors/Mask/MaskPattern.ts +123 -0
  190. package/src/constructors/Mask/MaskRight.ts +43 -0
  191. package/src/constructors/Mask/MaskRubber.ts +156 -0
  192. package/src/constructors/Mask/MaskRubberItem.ts +96 -0
  193. package/src/constructors/Mask/MaskRubberTransition.ts +50 -0
  194. package/src/constructors/Mask/MaskSelection.ts +208 -0
  195. package/src/constructors/Mask/MaskSpecial.ts +179 -0
  196. package/src/constructors/Mask/MaskType.ts +103 -0
  197. package/src/constructors/Mask/MaskValidation.ts +102 -0
  198. package/src/constructors/Mask/MaskValue.ts +225 -0
  199. package/src/constructors/Mask/MaskValueBasic.ts +87 -0
  200. package/src/constructors/Mask/MaskView.ts +169 -0
  201. package/src/constructors/Mask/basicTypes.ts +49 -0
  202. package/src/constructors/Mask/index.ts +5 -0
  203. package/src/constructors/Mask/properties.json +29 -0
  204. package/src/constructors/Mask/props.ts +70 -0
  205. package/src/constructors/Mask/style.scss +104 -0
  206. package/src/constructors/Mask/types.ts +71 -0
  207. package/src/constructors/Menu/Menu.ts +179 -0
  208. package/src/constructors/Menu/MenuDesign.tsx +244 -0
  209. package/src/constructors/Menu/MenuInclude.ts +110 -0
  210. package/src/constructors/Menu/MenuRequest.ts +101 -0
  211. package/src/constructors/Menu/MenuSearch.ts +49 -0
  212. package/src/constructors/Menu/MenuValue.ts +73 -0
  213. package/src/constructors/Menu/MenuWindow.ts +89 -0
  214. package/src/constructors/Menu/basicTypes.ts +41 -0
  215. package/src/constructors/Menu/index.ts +6 -0
  216. package/src/constructors/Menu/properties.json +17 -0
  217. package/src/constructors/Menu/props.ts +79 -0
  218. package/src/constructors/Menu/style.scss +17 -0
  219. package/src/constructors/Menu/types.ts +79 -0
  220. package/src/constructors/MotionTransform/MotionTransform.ts +87 -0
  221. package/src/constructors/MotionTransform/MotionTransformClassesInclude.ts +38 -0
  222. package/src/constructors/MotionTransform/MotionTransformDesign.tsx +242 -0
  223. package/src/constructors/MotionTransform/MotionTransformElement.ts +220 -0
  224. package/src/constructors/MotionTransform/MotionTransformEvent.ts +118 -0
  225. package/src/constructors/MotionTransform/MotionTransformGo.ts +47 -0
  226. package/src/constructors/MotionTransform/MotionTransformInclude.ts +123 -0
  227. package/src/constructors/MotionTransform/MotionTransformSize.ts +97 -0
  228. package/src/constructors/MotionTransform/MotionTransformState.ts +250 -0
  229. package/src/constructors/MotionTransform/basicTypes.ts +121 -0
  230. package/src/constructors/MotionTransform/index.ts +7 -0
  231. package/src/constructors/MotionTransform/properties.json +35 -0
  232. package/src/constructors/MotionTransform/props.ts +50 -0
  233. package/src/constructors/MotionTransform/style.scss +180 -0
  234. package/src/constructors/MotionTransform/types.ts +86 -0
  235. package/src/constructors/Progress/Progress.ts +184 -0
  236. package/src/constructors/Progress/ProgressDesign.tsx +175 -0
  237. package/src/constructors/Progress/ProgressInclude.ts +67 -0
  238. package/src/constructors/Progress/basicTypes.ts +12 -0
  239. package/src/constructors/Progress/index.ts +6 -0
  240. package/src/constructors/Progress/properties.json +47 -0
  241. package/src/constructors/Progress/props.ts +54 -0
  242. package/src/constructors/Progress/style.scss +374 -0
  243. package/src/constructors/Progress/types.ts +43 -0
  244. package/src/constructors/Ripple/Ripple.ts +46 -0
  245. package/src/constructors/Ripple/RippleDesign.tsx +112 -0
  246. package/src/constructors/Ripple/RippleInclude.ts +39 -0
  247. package/src/constructors/Ripple/RippleItem.ts +62 -0
  248. package/src/constructors/Ripple/basicTypes.ts +3 -0
  249. package/src/constructors/Ripple/index.ts +6 -0
  250. package/src/constructors/Ripple/properties.json +9 -0
  251. package/src/constructors/Ripple/props.ts +28 -0
  252. package/src/constructors/Ripple/style.scss +62 -0
  253. package/src/constructors/Ripple/types.ts +41 -0
  254. package/src/constructors/Scrollbar/Scrollbar.ts +66 -0
  255. package/src/constructors/Scrollbar/ScrollbarBorder.ts +243 -0
  256. package/src/constructors/Scrollbar/ScrollbarDesign.tsx +126 -0
  257. package/src/constructors/Scrollbar/ScrollbarInclude.ts +80 -0
  258. package/src/constructors/Scrollbar/basicTypes.ts +42 -0
  259. package/src/constructors/Scrollbar/index.ts +5 -0
  260. package/src/constructors/Scrollbar/properties.json +33 -0
  261. package/src/constructors/Scrollbar/props.ts +37 -0
  262. package/src/constructors/Scrollbar/style.scss +117 -0
  263. package/src/constructors/Scrollbar/types.ts +52 -0
  264. package/src/constructors/Skeleton/Skeleton.ts +86 -0
  265. package/src/constructors/Skeleton/SkeletonDesign.tsx +117 -0
  266. package/src/constructors/Skeleton/SkeletonInclude.ts +61 -0
  267. package/src/constructors/Skeleton/basicTypes.ts +16 -0
  268. package/src/constructors/Skeleton/const.ts +1 -0
  269. package/src/constructors/Skeleton/index.ts +6 -0
  270. package/src/constructors/Skeleton/properties.json +24 -0
  271. package/src/constructors/Skeleton/props.ts +28 -0
  272. package/src/constructors/Skeleton/style.scss +112 -0
  273. package/src/constructors/Skeleton/types.ts +46 -0
  274. package/src/constructors/Window/Window.ts +212 -0
  275. package/src/constructors/Window/WindowClasses.ts +180 -0
  276. package/src/constructors/Window/WindowClassesInclude.ts +39 -0
  277. package/src/constructors/Window/WindowClient.ts +93 -0
  278. package/src/constructors/Window/WindowCoordinates.ts +257 -0
  279. package/src/constructors/Window/WindowDesign.tsx +278 -0
  280. package/src/constructors/Window/WindowElement.ts +84 -0
  281. package/src/constructors/Window/WindowEmit.ts +52 -0
  282. package/src/constructors/Window/WindowEvent.ts +157 -0
  283. package/src/constructors/Window/WindowFlash.ts +70 -0
  284. package/src/constructors/Window/WindowHook.ts +110 -0
  285. package/src/constructors/Window/WindowInclude.ts +134 -0
  286. package/src/constructors/Window/WindowOpen.ts +292 -0
  287. package/src/constructors/Window/WindowOrigin.ts +85 -0
  288. package/src/constructors/Window/WindowPersistent.ts +89 -0
  289. package/src/constructors/Window/WindowPosition.ts +358 -0
  290. package/src/constructors/Window/WindowStatic.ts +102 -0
  291. package/src/constructors/Window/WindowStatus.ts +138 -0
  292. package/src/constructors/Window/WindowStyles.ts +78 -0
  293. package/src/constructors/Window/WindowVerification.ts +287 -0
  294. package/src/constructors/Window/basicTypes.ts +186 -0
  295. package/src/constructors/Window/index.ts +7 -0
  296. package/src/constructors/Window/properties.json +236 -0
  297. package/src/constructors/Window/props.ts +88 -0
  298. package/src/constructors/Window/style.scss +262 -0
  299. package/src/constructors/Window/types.ts +124 -0
  300. package/src/functions/getClassTegAStatic.ts +8 -0
  301. package/src/library.ts +36 -0
  302. package/src/types/captionTypes.ts +15 -0
  303. package/src/types/descriptionTypes.ts +15 -0
  304. package/src/types/enabledTypes.ts +9 -0
  305. package/src/types/eventClickTypes.ts +51 -0
  306. package/src/types/fieldTypes.ts +282 -0
  307. package/src/types/labelTypes.ts +30 -0
  308. package/src/types/modelTypes.ts +23 -0
  309. package/src/types/prefixTypes.ts +15 -0
  310. package/src/types/suffixTypes.ts +15 -0
  311. package/src/vite-env.d.ts +1 -0
@@ -0,0 +1,358 @@
1
+ import { getElement, isDomRuntime } from '@dxtmisha/functional'
2
+
3
+ import { WindowClient } from './WindowClient'
4
+ import { WindowElement } from './WindowElement'
5
+ import { WindowCoordinates } from './WindowCoordinates'
6
+
7
+ import type { WindowProps } from './props'
8
+
9
+ /**
10
+ * A class for working with position.
11
+ *
12
+ * Класс для работы с позицией.
13
+ */
14
+ export class WindowPosition {
15
+ protected x: number = 0
16
+ protected y: number = 0
17
+
18
+ /**
19
+ * Constructor
20
+ * @param props input data/ входные данные
21
+ * @param client object for working with mouse pointer coordinates/ объект для работы с координатами указателя мыши
22
+ * @param element an object of the class for working with elements/ объект класса для работы с элементами
23
+ * @param coordinates object for working with coordinates/ объект для работы с координатами
24
+ */
25
+
26
+ constructor(
27
+ protected readonly props: WindowProps,
28
+ protected readonly client: WindowClient,
29
+ protected readonly element: WindowElement,
30
+ protected readonly coordinates: WindowCoordinates
31
+ ) {
32
+ }
33
+
34
+ /**
35
+ * Checks if the alignment type is above the element.
36
+ *
37
+ * Проверяет, является ли тип выравнивания над элементом.
38
+ */
39
+ isOver(): boolean {
40
+ return this.props.axis === 'on'
41
+ }
42
+
43
+ /**
44
+ * Returns the X position.
45
+ *
46
+ * Возвращает позицию X.
47
+ */
48
+ getX(): number {
49
+ return this.x
50
+ }
51
+
52
+ /**
53
+ * Returns the Y position.
54
+ *
55
+ * Возвращает позицию Y.
56
+ */
57
+ getY(): number {
58
+ return this.y
59
+ }
60
+
61
+ /**
62
+ * Returns the X position for styles.
63
+ *
64
+ * Возвращает позицию X для стилей.
65
+ */
66
+ getStyleX(): string {
67
+ return `${this.x}px`
68
+ }
69
+
70
+ /**
71
+ * Returns the Y position for styles.
72
+ *
73
+ * Возвращает позицию Y для стилей.
74
+ */
75
+ getStyleY(): string {
76
+ return `${this.y}px`
77
+ }
78
+
79
+ /**
80
+ * Update of the element's position coordinates.
81
+ *
82
+ * Обновление координаты положения элемента.
83
+ */
84
+ update(): boolean {
85
+ if (this.coordinates.update()) {
86
+ this.setX()
87
+ this.setY()
88
+
89
+ return true
90
+ }
91
+
92
+ return false
93
+ }
94
+
95
+ /**
96
+ * Updates the scroll position if an element is selected.
97
+ *
98
+ * Обновляет место скрола, если выбран элемент.
99
+ */
100
+ updateScroll(): void {
101
+ const elementBodyContext = this.element.getBodyContext()
102
+
103
+ if (
104
+ this.isOver()
105
+ && this.props.overElement
106
+ && elementBodyContext
107
+ && elementBodyContext.scrollHeight > elementBodyContext.offsetHeight
108
+ ) {
109
+ const rect = getElement(this.props.overElement)?.getBoundingClientRect()
110
+ const rectBody = this.element.getBody()?.getBoundingClientRect()
111
+ const rectBodyContext = elementBodyContext?.getBoundingClientRect()
112
+ const rectControl = this.element.getControl()?.getBoundingClientRect()
113
+
114
+ if (
115
+ elementBodyContext
116
+ && rect
117
+ && rectBody
118
+ && rectBodyContext
119
+ ) {
120
+ const center = rect.height / 2
121
+ const shift = rect.top - rectBodyContext.top
122
+
123
+ if (
124
+ rectControl
125
+ && this.coordinates.getMaxHeight() === rectBody.height
126
+ ) {
127
+ if (rectControl.top + center < rectBody.top) {
128
+ elementBodyContext.scrollTop += shift
129
+ return
130
+ }
131
+
132
+ if (rectControl.bottom - center > rectBody.bottom) {
133
+ elementBodyContext.scrollTop += shift - rectBodyContext.height + rect.height
134
+ return
135
+ }
136
+
137
+ elementBodyContext.scrollTop += shift - (rectControl.top - rectBodyContext.top) - (rectControl.height / 2) + center
138
+ return
139
+ }
140
+
141
+ elementBodyContext.scrollTop += shift - (rectBodyContext.height / 2) + center
142
+ }
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Updates the scroll display status of the element.
148
+ *
149
+ * Обновляет статус отображения скролла у элемента.
150
+ */
151
+ updateBody(): void {
152
+ if (isDomRuntime()) {
153
+ const body = document.body
154
+ const value = body.offsetHeight > window.innerHeight ? 'scroll' : 'none'
155
+
156
+ if (body.dataset.scroll !== value) {
157
+ body.dataset.scroll = value
158
+ }
159
+ }
160
+ }
161
+
162
+ /**
163
+ * Returns the axis alignment values.
164
+ *
165
+ * Возвращает значения оси выравнивания.
166
+ */
167
+ protected getAxis(): WindowProps['axis'] {
168
+ return this.isOver() ? 'y' : (this.props?.axis ?? 'y')
169
+ }
170
+
171
+ /**
172
+ * Returns the margins from the control element.
173
+ *
174
+ * Возвращает отступы от элемента управления.
175
+ * @param axis the axis of alignment of the element/ ось выравнивания элемента
176
+ */
177
+ protected getIndent(axis: string): number {
178
+ return this.getAxis() === axis ? (this.props.indent ?? 4) : 0
179
+ }
180
+
181
+ /**
182
+ * Calculation of the position for window alignment.
183
+ *
184
+ * Вычисление места положения для выравнивания окна.
185
+ * @param rectTop high control coordinates/ высокие координаты контрола
186
+ * @param rectBottom lower control coordinates/ нижние координаты контрола
187
+ */
188
+ protected getOverHeight(
189
+ rectTop: number,
190
+ rectBottom: number
191
+ ) {
192
+ const over = (rectBottom - rectTop) / 2
193
+
194
+ if (this.props.overElement) {
195
+ const rect = getElement(this.props.overElement)?.getBoundingClientRect()
196
+ const rectBody = this.element.getBody()?.getBoundingClientRect()
197
+
198
+ if (rect && rectBody) {
199
+ const top = rect.top - rectBody.top
200
+ const height = rect.height / 2
201
+
202
+ return rectBottom - top - height - over
203
+ }
204
+ }
205
+
206
+ const height = this.coordinates.getHeight() / 2
207
+
208
+ return rectBottom - over - height
209
+ }
210
+
211
+ /**
212
+ * Changes in position along the X coordinate.
213
+ *
214
+ * Изменения положения по координате X.
215
+ */
216
+ protected setX(): this {
217
+ const element = this.element.getMain()
218
+
219
+ if (element) {
220
+ const indent = this.getIndent('x')
221
+ const rectRight = this.props.contextmenu ? this.client.getX() : this.coordinates.getRight() + indent
222
+ const rectLeft = this.props.contextmenu ? this.client.getX() : this.coordinates.getLeft() - indent
223
+ const argumentValues: number[] = []
224
+
225
+ if (this.getAxis() === 'x') {
226
+ argumentValues.push(rectRight, rectLeft)
227
+ } else {
228
+ argumentValues.push(rectLeft, rectRight)
229
+ }
230
+
231
+ this.x = this.calculationInner(
232
+ argumentValues[0] as number,
233
+ argumentValues[1] as number,
234
+ element.offsetWidth,
235
+ window.innerWidth,
236
+ this.coordinates.getWidth()
237
+ )
238
+ }
239
+
240
+ return this
241
+ }
242
+
243
+ /**
244
+ * Changes in position along the Y coordinate.
245
+ *
246
+ * Изменения положения по координате Y.
247
+ */
248
+ protected setY(): this {
249
+ const element = this.element.getMain()
250
+
251
+ if (element) {
252
+ const indent = this.getIndent('y')
253
+ const rectTop = this.props.contextmenu ? this.client.getY() : this.coordinates.getTop() - indent
254
+ const rectBottom = this.props.contextmenu ? this.client.getY() : this.coordinates.getBottom() + indent
255
+ const argumentValues: number[] = []
256
+
257
+ if (this.isOver()) {
258
+ this.y = this.calculationOver(
259
+ this.getOverHeight(rectTop, rectBottom),
260
+ rectTop,
261
+ rectBottom,
262
+ element.offsetHeight,
263
+ window.innerHeight
264
+ )
265
+
266
+ return this
267
+ } else if (this.getAxis() !== 'x') {
268
+ argumentValues.push(rectBottom, rectTop)
269
+ } else {
270
+ argumentValues.push(rectTop, rectBottom)
271
+ }
272
+
273
+ this.y = this.calculationInner(
274
+ argumentValues[0] as number,
275
+ argumentValues[1] as number,
276
+ element.offsetHeight,
277
+ window.innerHeight,
278
+ this.coordinates.getHeight()
279
+ )
280
+ }
281
+
282
+ return this
283
+ }
284
+
285
+ /**
286
+ * Calculation of the element's position.
287
+ *
288
+ * Вычисление положения элемента.
289
+ * @param inValue initial values/ начальные значения
290
+ * @param outValue final values/ конечные значения
291
+ * @param length length of the object/ длина объекта
292
+ * @param innerLength length of the indentation/ длина отступа
293
+ * @param maxSize maximum length/ максимальная длина
294
+ */
295
+ protected calculationInner(
296
+ inValue: number,
297
+ outValue: number,
298
+ length: number,
299
+ innerLength: number,
300
+ maxSize: number
301
+ ): number {
302
+ const padding = this.coordinates.getPadding()
303
+
304
+ if (inValue + length <= innerLength - padding) {
305
+ return inValue
306
+ }
307
+
308
+ if (outValue - length > padding) {
309
+ return outValue - length
310
+ }
311
+
312
+ return (innerLength / 2) - (maxSize / 2)
313
+ }
314
+
315
+ /**
316
+ * Calculation of the element's position.
317
+ *
318
+ * Вычисление положения над элемента.
319
+ * @param value initial values/ начальные значения
320
+ * @param top high control coordinates/ высокие координаты контрола
321
+ * @param bottom lower control coordinates/ нижние координаты контрола
322
+ * @param length length of the object/ длина объекта
323
+ * @param innerLength length of the indentation/ длина отступа
324
+ */
325
+ protected calculationOver(
326
+ value: number,
327
+ top: number,
328
+ bottom: number,
329
+ length: number,
330
+ innerLength: number
331
+ ): number {
332
+ const padding = this.coordinates.getPadding()
333
+
334
+ if (bottom < padding) {
335
+ return bottom
336
+ }
337
+
338
+ if (top > innerLength - padding) {
339
+ const data = top - length - padding
340
+
341
+ if (data < padding) {
342
+ return padding
343
+ }
344
+
345
+ return data
346
+ }
347
+
348
+ if (value < padding) {
349
+ return padding
350
+ }
351
+
352
+ if (value + length <= innerLength - padding) {
353
+ return value
354
+ }
355
+
356
+ return innerLength - length - padding
357
+ }
358
+ }
@@ -0,0 +1,102 @@
1
+ import { ref, type ToRefs, watch } from 'vue'
2
+ import { EventItem, setRef } from '@dxtmisha/functional'
3
+
4
+ import { WindowElement } from './WindowElement'
5
+
6
+ import type { WindowProps } from './props'
7
+
8
+ /**
9
+ * Class for working with a static window.
10
+ *
11
+ * Класс для работы со статичным окном.
12
+ */
13
+ export class WindowStatic {
14
+ protected event?: EventItem<Window, Event>
15
+
16
+ readonly item = ref<boolean>(false)
17
+
18
+ /**
19
+ * Constructor
20
+ * @param props input data/ входные данные
21
+ * @param refs input data in the form of reactive elements/ входные данные в виде реактивных элементов
22
+ * @param element an object of the class for working with elements/ объект класса для работы с элементами
23
+ */
24
+ constructor(
25
+ protected readonly props: WindowProps,
26
+ refs: ToRefs<WindowProps>,
27
+ protected readonly element: WindowElement
28
+ ) {
29
+ watch([refs.staticMode], this.make, { immediate: true })
30
+ }
31
+
32
+ /**
33
+ * Checks if the static mode is enabled.
34
+ *
35
+ * Проверяет, включен ли режим статичности.
36
+ */
37
+ isStaticMod(): boolean {
38
+ return Boolean(this.props.staticMode)
39
+ }
40
+
41
+ /**
42
+ * Starts the status tracking event.
43
+ *
44
+ * Стартует событие слежения за статусами.
45
+ */
46
+ start(): void {
47
+ if (!this.event) {
48
+ this.event = new EventItem(window, ['resize'], this.listener)
49
+ }
50
+
51
+ this.event.start()
52
+ }
53
+
54
+ /**
55
+ * Restores the data to its previous state.
56
+ *
57
+ * Восстанавливает данные в прежнее состояние.
58
+ */
59
+ stop(): void {
60
+ if (this.event) {
61
+ this.event.stop()
62
+ this.event = undefined
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Checks if the static window is active.
68
+ *
69
+ * Проверяет, активно ли статичное окно.
70
+ */
71
+ protected isStatic(): boolean {
72
+ const element = this.element.getMain()
73
+
74
+ return Boolean(
75
+ element
76
+ && getComputedStyle(element).content === '"--STATIC--"'
77
+ )
78
+ }
79
+
80
+ /**
81
+ * The function called when an event is triggered.
82
+ *
83
+ * Вызываемая функция при срабатывании события.
84
+ */
85
+ protected readonly listener = (): void => {
86
+ setRef(this.item, this.isStatic())
87
+ }
88
+
89
+ /**
90
+ * Performs status check and activates events when turned on.
91
+ *
92
+ * Выполняет проверку статуса и активизирует события при включении.
93
+ */
94
+ protected readonly make = (): void => {
95
+ if (this.isStaticMod()) {
96
+ this.start()
97
+ requestAnimationFrame(this.listener)
98
+ } else {
99
+ this.stop()
100
+ }
101
+ }
102
+ }
@@ -0,0 +1,138 @@
1
+ import { ref } from 'vue'
2
+
3
+ import { WindowElement } from './WindowElement'
4
+
5
+ import { WindowStatusItem } from './basicTypes'
6
+
7
+ /**
8
+ * A class that changes the status of the current component. This is needed for
9
+ * working with animation and behavior of the element when opening/closing.
10
+ *
11
+ * Класс, отвечающий за изменение статуса текущего компонента. Это нужно для работы
12
+ * с анимацией и поведением элемента при открытии/закрытии.
13
+ */
14
+ export class WindowStatus {
15
+ readonly item = ref<WindowStatusItem>(WindowStatusItem.close)
16
+
17
+ /**
18
+ * Constructor
19
+ * @param element an object of the class for working with elements/ объект класса для работы с элементами
20
+ */
21
+ constructor(
22
+ protected readonly element: WindowElement
23
+ ) {
24
+ }
25
+
26
+ /**
27
+ * Checks if the current status is closed (hide).
28
+ *
29
+ * Проверяет, является ли текущий статус закрытым (hide).
30
+ */
31
+ isHide(): boolean {
32
+ return this.item.value === WindowStatusItem.hide
33
+ }
34
+
35
+ /**
36
+ * Checks if the current status is open (open/flash).
37
+ *
38
+ * Проверяет, является ли текущий статус открытым (open/flash).
39
+ */
40
+ isOpen(): boolean {
41
+ return this.item.value === WindowStatusItem.open || this.item.value === WindowStatusItem.flash
42
+ }
43
+
44
+ /**
45
+ * Change the current status.
46
+ *
47
+ * Изменить текущий статус.
48
+ * @param value value/ значение
49
+ */
50
+ set(value: WindowStatusItem): this {
51
+ this.item.value = value
52
+ this.update()
53
+
54
+ return this
55
+ }
56
+
57
+ /**
58
+ * Translates status to display.
59
+ *
60
+ * Переводит статус в display.
61
+ */
62
+ toDisplay(): this {
63
+ this.set(WindowStatusItem.display)
64
+ return this
65
+ }
66
+
67
+ /**
68
+ * Translates status to preparation.
69
+ *
70
+ * Переводит статус в preparation.
71
+ */
72
+ toPreparation(): this {
73
+ this.set(WindowStatusItem.preparation)
74
+ return this
75
+ }
76
+
77
+ /**
78
+ * Translates status to flash.
79
+ *
80
+ * Переводит статус в flash.
81
+ */
82
+ toFlash(): this {
83
+ this.set(WindowStatusItem.flash)
84
+ return this
85
+ }
86
+
87
+ /**
88
+ * Translates status to open.
89
+ *
90
+ * Переводит статус в open.
91
+ */
92
+ toOpen(): this {
93
+ this.set(WindowStatusItem.open)
94
+ return this
95
+ }
96
+
97
+ /**
98
+ * Translates status to hide.
99
+ *
100
+ * Переводит статус в hide.
101
+ */
102
+ toHide(): this {
103
+ this.set(WindowStatusItem.hide)
104
+ return this
105
+ }
106
+
107
+ /**
108
+ * Translates status to close.
109
+ *
110
+ * Переводит статус в close.
111
+ */
112
+ toClose(): this {
113
+ this.set(WindowStatusItem.close)
114
+ return this
115
+ }
116
+
117
+ /**
118
+ * Updates the data-status attribute on the main element and teleport element.
119
+ *
120
+ * Обновляет атрибут data-status на основном элементе и элементе телепорта.
121
+ */
122
+ update(): void {
123
+ const element = this.element.getMain()
124
+
125
+ if (element) {
126
+ const teleportElement = element.parentElement
127
+
128
+ element.dataset.status = this.item.value
129
+
130
+ if (
131
+ teleportElement
132
+ && teleportElement.dataset.windowTeleport
133
+ ) {
134
+ teleportElement.dataset.status = this.item.value
135
+ }
136
+ }
137
+ }
138
+ }
@@ -0,0 +1,78 @@
1
+ import { watch } from 'vue'
2
+
3
+ import { WindowElement } from './WindowElement'
4
+ import { WindowCoordinates } from './WindowCoordinates'
5
+ import { WindowPosition } from './WindowPosition'
6
+ import { WindowOrigin } from './WindowOrigin'
7
+
8
+ /**
9
+ * Style management class.
10
+ *
11
+ * Класс управления стилями.
12
+ */
13
+ export class WindowStyles {
14
+ /**
15
+ * Constructor
16
+ * @param element an object of the class for working with elements/ объект класса для работы с элементами
17
+ * @param coordinates object for working with coordinates/ объект для работы с координатами
18
+ * @param position object for working with the position of the element/ объект для работы с положением элемента
19
+ * @param origin the object for work is in the initial position upon opening/ объект для работы в начальной позиции при открытии
20
+ * @param className class name/ название класса
21
+ */
22
+ constructor(
23
+ protected readonly element: WindowElement,
24
+ protected readonly coordinates: WindowCoordinates,
25
+ protected readonly position: WindowPosition,
26
+ protected readonly origin: WindowOrigin,
27
+ protected readonly className: string
28
+ ) {
29
+ watch(this.element.element, () => this.update())
30
+ }
31
+
32
+ /**
33
+ * Data update.
34
+ *
35
+ * Обновление данных.
36
+ */
37
+ update(): void {
38
+ const element = this.element.getMain()
39
+
40
+ if (element) {
41
+ element.style.setProperty(`--${this.className}-sys-inset-x`, this.position.getStyleX())
42
+ element.style.setProperty(`--${this.className}-sys-inset-y`, this.position.getStyleY())
43
+ element.style.setProperty(`--${this.className}-origin-x`, this.origin.getStyleX())
44
+ element.style.setProperty(`--${this.className}-origin-y`, this.origin.getStyleY())
45
+ element.style.setProperty(`--${this.className}-sys-control-width`, `${this.coordinates.getControlWidth()}px`)
46
+ element.style.setProperty(`--${this.className}-sys-control-height`, `${this.coordinates.getControlHeight()}px`)
47
+ element.style.setProperty(`--${this.className}-sys-location`, this.coordinates.getLocation())
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Updates the window type (menu or modal).
53
+ *
54
+ * Обновляет тип окна (меню или модальное).
55
+ * @param isMenu whether the window is a menu/ является ли окно меню
56
+ */
57
+ updateType(isMenu: boolean): void {
58
+ const element = this.element.getMain()
59
+
60
+ if (
61
+ element && (
62
+ (isMenu && (element.dataset.windowMenu !== 'menu'))
63
+ || (!isMenu && (element.dataset.windowMenu === 'menu'))
64
+ )
65
+ ) {
66
+ const teleportElement = element.parentElement
67
+
68
+ element.dataset.windowMenu = isMenu ? 'menu' : 'modal'
69
+
70
+ if (
71
+ teleportElement
72
+ && teleportElement.dataset.windowTeleport
73
+ ) {
74
+ teleportElement.dataset.windowMenu = element.dataset.windowMenu
75
+ }
76
+ }
77
+ }
78
+ }