@dxtmisha/constructor 0.23.0 → 0.30.1

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 (343) hide show
  1. package/package.json +36 -6
  2. package/src/classes/AriaStaticInclude.ts +269 -0
  3. package/src/classes/DescriptionInclude.ts +19 -2
  4. package/src/classes/EnabledInclude.ts +11 -0
  5. package/src/classes/EventClickInclude.ts +2 -2
  6. package/src/classes/LabelHighlightInclude.ts +35 -0
  7. package/src/classes/LabelInclude.ts +40 -5
  8. package/src/classes/ModelInclude.ts +50 -1
  9. package/src/classes/ModelValueInclude.ts +73 -0
  10. package/src/classes/TabIndexInclude.ts +260 -0
  11. package/src/classes/TextInclude.ts +102 -0
  12. package/src/classes/TouchEventInclude.ts +284 -0
  13. package/src/classes/field/FieldArrowInclude.ts +189 -0
  14. package/src/classes/field/FieldAttributesInclude.ts +87 -28
  15. package/src/classes/field/FieldChangeInclude.ts +1 -1
  16. package/src/classes/field/FieldElementInclude.ts +1 -1
  17. package/src/classes/field/FieldEventInclude.ts +253 -0
  18. package/src/classes/field/FieldInputModeInclude.ts +48 -0
  19. package/src/classes/field/FieldMatchInclude.ts +9 -3
  20. package/src/classes/field/FieldTypeInclude.ts +11 -6
  21. package/src/classes/field/FieldValidationInclude.ts +1 -4
  22. package/src/classes/field/FieldValueInclude.ts +10 -0
  23. package/src/constructors/Accordion/Accordion.ts +68 -0
  24. package/src/constructors/Accordion/AccordionDesign.tsx +192 -0
  25. package/src/constructors/Accordion/basicTypes.ts +0 -0
  26. package/src/constructors/Accordion/index.ts +5 -0
  27. package/src/constructors/Accordion/properties.json +16 -0
  28. package/src/constructors/Accordion/props.ts +55 -0
  29. package/src/constructors/Accordion/style.scss +12 -0
  30. package/src/constructors/Accordion/types.ts +63 -0
  31. package/src/constructors/ActionSheet/ActionSheet.ts +78 -0
  32. package/src/constructors/ActionSheet/ActionSheetDesign.tsx +125 -0
  33. package/src/constructors/ActionSheet/basicTypes.ts +0 -0
  34. package/src/constructors/ActionSheet/index.ts +5 -0
  35. package/src/constructors/ActionSheet/properties.json +14 -0
  36. package/src/constructors/ActionSheet/props.ts +44 -0
  37. package/src/constructors/ActionSheet/style.scss +25 -0
  38. package/src/constructors/ActionSheet/types.ts +54 -0
  39. package/src/constructors/Actions/Actions.ts +60 -0
  40. package/src/constructors/Actions/ActionsDesign.tsx +212 -0
  41. package/src/constructors/Actions/ActionsInclude.ts +109 -0
  42. package/src/constructors/Actions/basicTypes.ts +40 -0
  43. package/src/constructors/Actions/index.ts +6 -0
  44. package/src/constructors/Actions/properties.json +63 -0
  45. package/src/constructors/Actions/props.ts +42 -0
  46. package/src/constructors/Actions/style.scss +11 -0
  47. package/src/constructors/Actions/types.ts +52 -0
  48. package/src/constructors/Anchor/Anchor.ts +113 -0
  49. package/src/constructors/Anchor/AnchorDesign.tsx +242 -0
  50. package/src/constructors/Anchor/AnchorEvent.ts +76 -0
  51. package/src/constructors/Anchor/AnchorHref.ts +54 -0
  52. package/src/constructors/Anchor/AnchorIcon.ts +54 -0
  53. package/src/constructors/Anchor/AnchorTo.ts +46 -0
  54. package/src/constructors/Anchor/basicTypes.ts +9 -0
  55. package/src/constructors/Anchor/index.ts +5 -0
  56. package/src/constructors/Anchor/properties.json +3 -0
  57. package/src/constructors/Anchor/props.ts +54 -0
  58. package/src/constructors/Anchor/style.scss +10 -0
  59. package/src/constructors/Anchor/types.ts +47 -0
  60. package/src/constructors/Arrow/Arrow.ts +134 -0
  61. package/src/constructors/Arrow/ArrowDesign.tsx +226 -0
  62. package/src/constructors/Arrow/ArrowElement.ts +139 -0
  63. package/src/constructors/Arrow/ArrowElementTarget.ts +72 -0
  64. package/src/constructors/Arrow/ArrowEvent.ts +126 -0
  65. package/src/constructors/Arrow/ArrowInclude.ts +85 -0
  66. package/src/constructors/Arrow/ArrowParent.ts +100 -0
  67. package/src/constructors/Arrow/ArrowPosition.ts +231 -0
  68. package/src/constructors/Arrow/basicTypes.ts +50 -0
  69. package/src/constructors/Arrow/index.ts +6 -0
  70. package/src/constructors/Arrow/properties.json +23 -0
  71. package/src/constructors/Arrow/props.ts +31 -0
  72. package/src/constructors/Arrow/style.scss +133 -0
  73. package/src/constructors/Arrow/types.ts +54 -0
  74. package/src/constructors/Badge/BadgeDesign.tsx +4 -1
  75. package/src/constructors/Badge/properties.json +36 -36
  76. package/src/constructors/Badge/props.ts +3 -1
  77. package/src/constructors/Badge/types.ts +3 -3
  78. package/src/constructors/Bars/Bars.ts +10 -4
  79. package/src/constructors/Bars/BarsDesign.tsx +17 -11
  80. package/src/constructors/Bars/BarsInclude.ts +5 -2
  81. package/src/constructors/Bars/properties.json +6 -6
  82. package/src/constructors/Bars/props.ts +3 -1
  83. package/src/constructors/Bars/style.scss +4 -0
  84. package/src/constructors/Bars/types.ts +3 -3
  85. package/src/constructors/Block/Block.ts +105 -0
  86. package/src/constructors/Block/BlockDesign.tsx +219 -0
  87. package/src/constructors/Block/basicTypes.ts +0 -0
  88. package/src/constructors/Block/index.ts +5 -0
  89. package/src/constructors/Block/properties.json +10 -0
  90. package/src/constructors/Block/props.ts +46 -0
  91. package/src/constructors/Block/style.scss +11 -0
  92. package/src/constructors/Block/types.ts +64 -0
  93. package/src/constructors/Button/Button.ts +26 -2
  94. package/src/constructors/Button/ButtonDesign.tsx +11 -6
  95. package/src/constructors/Button/ButtonInclude.ts +8 -5
  96. package/src/constructors/Button/index.ts +1 -0
  97. package/src/constructors/Button/properties.json +84 -84
  98. package/src/constructors/Button/props.ts +5 -1
  99. package/src/constructors/Button/style.scss +1 -1
  100. package/src/constructors/Button/types.ts +2 -2
  101. package/src/constructors/Cell/Cell.ts +23 -6
  102. package/src/constructors/Cell/CellDesign.tsx +53 -22
  103. package/src/constructors/Cell/basicTypes.ts +33 -0
  104. package/src/constructors/Cell/properties.json +52 -52
  105. package/src/constructors/Cell/props.ts +16 -13
  106. package/src/constructors/Cell/style.scss +1 -1
  107. package/src/constructors/Cell/types.ts +3 -3
  108. package/src/constructors/Chip/ChipDesign.tsx +5 -5
  109. package/src/constructors/Chip/ChipInclude.ts +83 -0
  110. package/src/constructors/Chip/basicTypes.ts +12 -0
  111. package/src/constructors/Chip/index.ts +2 -0
  112. package/src/constructors/Chip/properties.json +3 -3
  113. package/src/constructors/Chip/types.ts +5 -5
  114. package/src/constructors/ChipGroup/ChipGroup.ts +74 -0
  115. package/src/constructors/ChipGroup/ChipGroupDesign.tsx +162 -0
  116. package/src/constructors/ChipGroup/basicTypes.ts +6 -0
  117. package/src/constructors/ChipGroup/index.ts +5 -0
  118. package/src/constructors/ChipGroup/properties.json +3 -0
  119. package/src/constructors/ChipGroup/props.ts +50 -0
  120. package/src/constructors/ChipGroup/style.scss +6 -0
  121. package/src/constructors/ChipGroup/types.ts +47 -0
  122. package/src/constructors/Dialog/Dialog.ts +145 -0
  123. package/src/constructors/Dialog/DialogDesign.tsx +135 -0
  124. package/src/constructors/Dialog/basicTypes.ts +0 -0
  125. package/src/constructors/Dialog/index.ts +5 -0
  126. package/src/constructors/Dialog/properties.json +23 -0
  127. package/src/constructors/Dialog/props.ts +76 -0
  128. package/src/constructors/Dialog/style.scss +18 -0
  129. package/src/constructors/Dialog/types.ts +67 -0
  130. package/src/constructors/Field/Field.ts +58 -19
  131. package/src/constructors/Field/FieldDesign.tsx +35 -17
  132. package/src/constructors/Field/FieldInclude.ts +141 -11
  133. package/src/constructors/Field/basicTypes.ts +35 -19
  134. package/src/constructors/Field/properties.json +92 -86
  135. package/src/constructors/Field/props.ts +6 -3
  136. package/src/constructors/Field/style.scss +36 -20
  137. package/src/constructors/Field/types.ts +13 -13
  138. package/src/constructors/FieldCounter/FieldCounterDesign.tsx +1 -0
  139. package/src/constructors/FieldCounter/FieldCounterInclude.ts +3 -1
  140. package/src/constructors/FieldCounter/basicTypes.ts +1 -0
  141. package/src/constructors/FieldCounter/properties.json +3 -3
  142. package/src/constructors/FieldCounter/props.ts +5 -2
  143. package/src/constructors/FieldCounter/types.ts +1 -1
  144. package/src/constructors/FieldLabel/FieldLabelDesign.tsx +6 -2
  145. package/src/constructors/FieldLabel/FieldLabelInclude.ts +13 -4
  146. package/src/constructors/FieldLabel/properties.json +4 -4
  147. package/src/constructors/FieldLabel/props.ts +2 -2
  148. package/src/constructors/FieldLabel/types.ts +2 -2
  149. package/src/constructors/FieldMessage/FieldMessage.ts +19 -0
  150. package/src/constructors/FieldMessage/FieldMessageDesign.tsx +36 -4
  151. package/src/constructors/FieldMessage/FieldMessageInclude.ts +11 -1
  152. package/src/constructors/FieldMessage/basicTypes.ts +15 -1
  153. package/src/constructors/FieldMessage/properties.json +10 -9
  154. package/src/constructors/FieldMessage/props.ts +4 -0
  155. package/src/constructors/FieldMessage/style.scss +16 -1
  156. package/src/constructors/FieldMessage/types.ts +4 -2
  157. package/src/constructors/Icon/Icon.ts +37 -2
  158. package/src/constructors/Icon/IconDesign.tsx +46 -39
  159. package/src/constructors/Icon/properties.json +25 -25
  160. package/src/constructors/Icon/props.ts +22 -16
  161. package/src/constructors/Icon/types.ts +1 -1
  162. package/src/constructors/Image/Image.ts +68 -10
  163. package/src/constructors/Image/ImageBackground.ts +15 -2
  164. package/src/constructors/Image/ImageCoordinator.ts +4 -2
  165. package/src/constructors/Image/ImageData.ts +4 -0
  166. package/src/constructors/Image/ImageDesign.tsx +81 -15
  167. package/src/constructors/Image/ImageFile.ts +2 -13
  168. package/src/constructors/Image/ImageImg.ts +218 -0
  169. package/src/constructors/Image/ImagePdf.ts +2 -2
  170. package/src/constructors/Image/basicTypes.ts +5 -0
  171. package/src/constructors/Image/properties.json +17 -17
  172. package/src/constructors/Image/props.ts +34 -7
  173. package/src/constructors/Image/style.scss +42 -0
  174. package/src/constructors/Image/types.ts +1 -1
  175. package/src/constructors/Input/Input.ts +146 -0
  176. package/src/constructors/Input/InputDesign.tsx +174 -0
  177. package/src/constructors/Input/InputPassword.ts +54 -0
  178. package/src/constructors/Input/basicTypes.ts +3 -0
  179. package/src/constructors/Input/index.ts +5 -0
  180. package/src/constructors/Input/properties.json +2 -0
  181. package/src/constructors/Input/props.ts +53 -0
  182. package/src/constructors/Input/style.scss +5 -0
  183. package/src/constructors/Input/types.ts +48 -0
  184. package/src/constructors/List/List.ts +36 -11
  185. package/src/constructors/List/ListControl.ts +2 -2
  186. package/src/constructors/List/ListDesign.tsx +59 -38
  187. package/src/constructors/List/ListGo.ts +5 -3
  188. package/src/constructors/List/properties.json +16 -16
  189. package/src/constructors/List/props.ts +7 -0
  190. package/src/constructors/List/style.scss +14 -0
  191. package/src/constructors/List/types.ts +9 -9
  192. package/src/constructors/ListGroup/ListGroupDesign.tsx +8 -3
  193. package/src/constructors/ListGroup/basicTypes.ts +7 -0
  194. package/src/constructors/ListGroup/properties.json +15 -15
  195. package/src/constructors/ListGroup/props.ts +4 -4
  196. package/src/constructors/ListGroup/types.ts +2 -1
  197. package/src/constructors/ListItem/ListItem.ts +67 -7
  198. package/src/constructors/ListItem/ListItemDesign.tsx +13 -10
  199. package/src/constructors/ListItem/properties.json +52 -52
  200. package/src/constructors/ListItem/props.ts +24 -15
  201. package/src/constructors/ListItem/types.ts +12 -12
  202. package/src/constructors/ListMenu/ListMenu.ts +2 -1
  203. package/src/constructors/ListMenu/ListMenuDesign.tsx +3 -3
  204. package/src/constructors/ListMenu/properties.json +19 -19
  205. package/src/constructors/ListMenu/types.ts +3 -3
  206. package/src/constructors/Mask/MaskDesign.tsx +33 -28
  207. package/src/constructors/Mask/MaskEvent.ts +41 -2
  208. package/src/constructors/Mask/MaskInclude.ts +147 -0
  209. package/src/constructors/Mask/basicTypes.ts +19 -1
  210. package/src/constructors/Mask/properties.json +30 -29
  211. package/src/constructors/Mask/props.ts +1 -1
  212. package/src/constructors/Mask/style.scss +2 -4
  213. package/src/constructors/Mask/types.ts +4 -4
  214. package/src/constructors/Menu/Menu.ts +17 -5
  215. package/src/constructors/Menu/MenuDesign.tsx +11 -11
  216. package/src/constructors/Menu/MenuGo.ts +72 -0
  217. package/src/constructors/Menu/MenuInclude.ts +20 -10
  218. package/src/constructors/Menu/MenuSearch.ts +20 -1
  219. package/src/constructors/Menu/MenuValue.ts +7 -3
  220. package/src/constructors/Menu/MenuWindow.ts +2 -1
  221. package/src/constructors/Menu/basicTypes.ts +21 -4
  222. package/src/constructors/Menu/properties.json +17 -17
  223. package/src/constructors/Menu/props.ts +15 -3
  224. package/src/constructors/Menu/types.ts +6 -16
  225. package/src/constructors/Modal/Modal.ts +53 -0
  226. package/src/constructors/Modal/ModalAbstract.ts +74 -0
  227. package/src/constructors/Modal/ModalDesign.tsx +63 -0
  228. package/src/constructors/Modal/ModalDesignAbstract.tsx +226 -0
  229. package/src/constructors/Modal/basicTypes.ts +0 -0
  230. package/src/constructors/Modal/index.ts +5 -0
  231. package/src/constructors/Modal/properties.json +17 -0
  232. package/src/constructors/Modal/props.ts +45 -0
  233. package/src/constructors/Modal/style.scss +20 -0
  234. package/src/constructors/Modal/types.ts +62 -0
  235. package/src/constructors/MotionTransform/MotionTransform.ts +65 -8
  236. package/src/constructors/MotionTransform/MotionTransformDesign.tsx +55 -21
  237. package/src/constructors/MotionTransform/MotionTransformElement.ts +7 -2
  238. package/src/constructors/MotionTransform/MotionTransformInclude.ts +2 -1
  239. package/src/constructors/MotionTransform/MotionTransformState.ts +5 -0
  240. package/src/constructors/MotionTransform/basicTypes.ts +18 -2
  241. package/src/constructors/MotionTransform/properties.json +35 -35
  242. package/src/constructors/MotionTransform/props.ts +13 -7
  243. package/src/constructors/MotionTransform/style.scss +24 -2
  244. package/src/constructors/MotionTransform/types.ts +7 -7
  245. package/src/constructors/Progress/Progress.ts +12 -2
  246. package/src/constructors/Progress/ProgressDesign.tsx +75 -53
  247. package/src/constructors/Progress/ProgressInclude.ts +13 -1
  248. package/src/constructors/Progress/properties.json +47 -47
  249. package/src/constructors/Progress/props.ts +5 -1
  250. package/src/constructors/Progress/style.scss +2 -2
  251. package/src/constructors/Progress/types.ts +4 -4
  252. package/src/constructors/Ripple/Ripple.ts +1 -1
  253. package/src/constructors/Ripple/RippleDesign.tsx +7 -4
  254. package/src/constructors/Ripple/RippleItem.ts +1 -1
  255. package/src/constructors/Ripple/style.scss +4 -0
  256. package/src/constructors/Ripple/types.ts +2 -2
  257. package/src/constructors/Scrollbar/Scrollbar.ts +3 -3
  258. package/src/constructors/Scrollbar/ScrollbarDesign.tsx +1 -1
  259. package/src/constructors/Scrollbar/properties.json +33 -33
  260. package/src/constructors/Scrollbar/types.ts +1 -1
  261. package/src/constructors/Section/Section.ts +33 -0
  262. package/src/constructors/Section/SectionDesign.tsx +127 -0
  263. package/src/constructors/Section/basicTypes.ts +0 -0
  264. package/src/constructors/Section/index.ts +5 -0
  265. package/src/constructors/Section/properties.json +2 -0
  266. package/src/constructors/Section/props.ts +29 -0
  267. package/src/constructors/Section/style.scss +5 -0
  268. package/src/constructors/Section/types.ts +47 -0
  269. package/src/constructors/Select/Select.ts +172 -0
  270. package/src/constructors/Select/SelectDesign.tsx +288 -0
  271. package/src/constructors/Select/SelectFilter.ts +43 -0
  272. package/src/constructors/Select/SelectInput.ts +68 -0
  273. package/src/constructors/Select/basicTypes.ts +0 -0
  274. package/src/constructors/Select/index.ts +5 -0
  275. package/src/constructors/Select/properties.json +3 -0
  276. package/src/constructors/Select/props.ts +63 -0
  277. package/src/constructors/Select/style.scss +5 -0
  278. package/src/constructors/Select/types.ts +53 -0
  279. package/src/constructors/SelectValue/SelectValue.ts +95 -0
  280. package/src/constructors/SelectValue/SelectValueDesign.tsx +198 -0
  281. package/src/constructors/SelectValue/SelectValueInclude.ts +92 -0
  282. package/src/constructors/SelectValue/basicTypes.ts +17 -0
  283. package/src/constructors/SelectValue/index.ts +6 -0
  284. package/src/constructors/SelectValue/properties.json +7 -0
  285. package/src/constructors/SelectValue/props.ts +48 -0
  286. package/src/constructors/SelectValue/style.scss +14 -0
  287. package/src/constructors/SelectValue/types.ts +47 -0
  288. package/src/constructors/Skeleton/Skeleton.ts +1 -3
  289. package/src/constructors/Skeleton/SkeletonDesign.tsx +7 -1
  290. package/src/constructors/Skeleton/SkeletonInclude.ts +5 -0
  291. package/src/constructors/Skeleton/properties.json +24 -24
  292. package/src/constructors/Skeleton/types.ts +1 -1
  293. package/src/constructors/TextareaAutosize/TextareaAutosize.ts +41 -0
  294. package/src/constructors/TextareaAutosize/TextareaAutosizeDesign.tsx +147 -0
  295. package/src/constructors/TextareaAutosize/TextareaAutosizeResize.ts +109 -0
  296. package/src/constructors/TextareaAutosize/TextareaAutosizeValue.ts +69 -0
  297. package/src/constructors/TextareaAutosize/basicTypes.ts +0 -0
  298. package/src/constructors/TextareaAutosize/index.ts +5 -0
  299. package/src/constructors/TextareaAutosize/properties.json +6 -0
  300. package/src/constructors/TextareaAutosize/props.ts +34 -0
  301. package/src/constructors/TextareaAutosize/style.scss +31 -0
  302. package/src/constructors/TextareaAutosize/types.ts +50 -0
  303. package/src/constructors/Tooltip/Tooltip.ts +138 -0
  304. package/src/constructors/Tooltip/TooltipClasses.ts +90 -0
  305. package/src/constructors/Tooltip/TooltipDesign.tsx +198 -0
  306. package/src/constructors/Tooltip/TooltipEvent.ts +103 -0
  307. package/src/constructors/Tooltip/TooltipInclude.ts +114 -0
  308. package/src/constructors/Tooltip/TooltipOpen.ts +128 -0
  309. package/src/constructors/Tooltip/TooltipPosition.ts +92 -0
  310. package/src/constructors/Tooltip/TooltipStatus.ts +97 -0
  311. package/src/constructors/Tooltip/TooltipStyle.ts +123 -0
  312. package/src/constructors/Tooltip/basicTypes.ts +39 -0
  313. package/src/constructors/Tooltip/index.ts +6 -0
  314. package/src/constructors/Tooltip/properties.json +14 -0
  315. package/src/constructors/Tooltip/props.ts +49 -0
  316. package/src/constructors/Tooltip/style.scss +43 -0
  317. package/src/constructors/Tooltip/types.ts +58 -0
  318. package/src/constructors/Window/Window.ts +52 -16
  319. package/src/constructors/Window/WindowClasses.ts +33 -0
  320. package/src/constructors/Window/WindowClient.ts +39 -0
  321. package/src/constructors/Window/WindowDesign.tsx +31 -14
  322. package/src/constructors/Window/WindowEsc.ts +114 -0
  323. package/src/constructors/Window/WindowHidden.ts +120 -0
  324. package/src/constructors/Window/WindowInclude.ts +2 -2
  325. package/src/constructors/Window/WindowOpen.ts +10 -1
  326. package/src/constructors/Window/WindowOrigin.ts +5 -1
  327. package/src/constructors/Window/WindowStatic.ts +3 -1
  328. package/src/constructors/Window/WindowVerification.ts +8 -5
  329. package/src/constructors/Window/basicTypes.ts +26 -16
  330. package/src/constructors/Window/properties.json +239 -236
  331. package/src/constructors/Window/props.ts +10 -1
  332. package/src/constructors/Window/style.scss +11 -0
  333. package/src/constructors/Window/types.ts +2 -2
  334. package/src/functions/{getClassTegAStatic.ts → getClassTagAStatic.ts} +1 -1
  335. package/src/library.ts +13 -1
  336. package/src/types/ariaTypes.ts +366 -0
  337. package/src/types/descriptionTypes.ts +8 -0
  338. package/src/types/fieldTypes.ts +120 -16
  339. package/src/types/labelTypes.ts +39 -0
  340. package/src/types/modelTypes.ts +16 -0
  341. package/src/types/roleTypes.ts +88 -0
  342. package/src/types/textTypes.ts +33 -0
  343. package/src/types/touchEventTypes.ts +43 -0
@@ -78,6 +78,10 @@ export class ImageData {
78
78
  case ImageTypeValue.image:
79
79
  case ImageTypeValue.file:
80
80
  try {
81
+ if (this.props.lazy) {
82
+ return this.props.value
83
+ }
84
+
81
85
  return await ImageFile.createImage(image)
82
86
  } catch {
83
87
  console.error('ImageData.initImage: ', image)
@@ -1,4 +1,4 @@
1
- import { h, type VNode } from 'vue'
1
+ import { computed, h, type VNode } from 'vue'
2
2
  import {
3
3
  type ConstrOptions,
4
4
  type ConstrStyles,
@@ -43,11 +43,13 @@ export class ImageDesign<
43
43
  * @param name class name/ название класса
44
44
  * @param props properties/ свойства
45
45
  * @param options list of additional parameters/ список дополнительных параметров
46
+ * @param ItemConstructor image item class/ класс элемента изображения
46
47
  */
47
48
  constructor(
48
49
  name: string,
49
50
  props: Readonly<P>,
50
- options?: ConstrOptions<COMP, ImageEmits, P>
51
+ options?: ConstrOptions<COMP, ImageEmits, P>,
52
+ ItemConstructor: typeof Image = Image
51
53
  ) {
52
54
  super(
53
55
  name,
@@ -55,7 +57,7 @@ export class ImageDesign<
55
57
  options
56
58
  )
57
59
 
58
- this.item = new Image(
60
+ this.item = new ItemConstructor(
59
61
  this.props,
60
62
  this.element,
61
63
  this.getName(),
@@ -107,29 +109,93 @@ export class ImageDesign<
107
109
  * Метод для рендеринга.
108
110
  */
109
111
  protected initRender(): VNode {
112
+ if (this.item.img.isPicture.value) {
113
+ return this.renderPicture()
114
+ }
115
+
116
+ if (this.item.img.is.value) {
117
+ return this.renderImg()
118
+ }
119
+
110
120
  return h(
111
121
  'span',
112
- {
113
- ...this.getAttrs(),
114
- ref: this.element,
115
- class: this.classes?.value.main,
116
- style: this.styles?.value,
117
- translate: 'no'
118
- },
122
+ this.propsMain.value,
119
123
  this.renderValue()
120
124
  )
121
125
  }
122
126
 
127
+ /**
128
+ * Properties for the image tag.
129
+ *
130
+ * Свойства для тега image.
131
+ */
132
+ readonly propsImage = computed<any>(() => ({
133
+ ...this.getAttrs(),
134
+ ref: this.element,
135
+ key: 'image',
136
+ class: this.classes?.value.main
137
+ }))
138
+
139
+ /**
140
+ * Main properties.
141
+ *
142
+ * Основные свойства.
143
+ */
144
+ readonly propsMain = computed<any>(() => ({
145
+ ...this.propsImage.value,
146
+ ...this.item.binds.value,
147
+ style: this.styles?.value
148
+ }))
149
+
150
+ /**
151
+ * Rendering the picture tag.
152
+ *
153
+ * Рендеринг тега picture.
154
+ */
155
+ readonly renderPicture = (): VNode => {
156
+ const list = this.item.img.picture.value
157
+ const children: any[] = []
158
+
159
+ if (list) {
160
+ list.forEach(
161
+ item => children.push(h('source', item))
162
+ )
163
+ }
164
+
165
+ children.push(this.renderImgItem())
166
+
167
+ return h('picture', this.propsImage.value, children)
168
+ }
169
+
170
+ /**
171
+ * Rendering the img tag.
172
+ *
173
+ * Рендеринг тега img.
174
+ */
175
+ readonly renderImg = (): VNode => {
176
+ return h('span', this.propsImage.value, this.renderImgItem())
177
+ }
178
+
179
+ /**
180
+ * Rendering the img item.
181
+ *
182
+ * Рендеринг элемента img.
183
+ */
184
+ readonly renderImgItem = (): VNode => {
185
+ return h('img', this.item.img.binds.value)
186
+ }
187
+
123
188
  /**
124
189
  * Rendering the value for the component.
125
190
  *
126
191
  * Рендеринг значения для компонента.
127
192
  */
128
- readonly renderValue = (): string | VNode[] | undefined => {
129
- if (
130
- this.item.type.item.value === ImageTypeValue.pdf
131
- ) {
132
- return [h('object', { data: this.item.data.image.value })]
193
+ readonly renderValue = (): string | VNode | undefined => {
194
+ if (this.item.type.item.value === ImageTypeValue.pdf) {
195
+ return h(
196
+ 'object',
197
+ this.item.valueBinds.value
198
+ )
133
199
  }
134
200
 
135
201
  return this.item.text.value
@@ -1,5 +1,5 @@
1
1
  import type { ImageItem } from './basicTypes'
2
- import { isDomRuntime } from '@dxtmisha/functional'
2
+ import { isDomRuntime, resizeImageByMax } from '@dxtmisha/functional'
3
3
 
4
4
  /**
5
5
  * Maximum size allowed without conversion.
@@ -118,18 +118,7 @@ export class ImageFile {
118
118
  || image.naturalWidth > maxSize
119
119
  )
120
120
  ) {
121
- const is = image.naturalWidth >= image.naturalHeight
122
- const canvas = document.createElement('canvas')?.getContext('2d')
123
-
124
- if (canvas) {
125
- canvas.canvas.width = is ? maxSize : (image.naturalWidth / image.naturalHeight * maxSize)
126
- canvas.canvas.height = is ? (image.naturalHeight / image.naturalWidth * maxSize) : maxSize
127
- canvas.drawImage(image, 0, 0, canvas.canvas.width, canvas.canvas.height)
128
-
129
- return canvas.canvas.toDataURL()
130
- } else {
131
- return ''
132
- }
121
+ return resizeImageByMax(image, maxSize) ?? ''
133
122
  } else {
134
123
  return image.src
135
124
  }
@@ -0,0 +1,218 @@
1
+ import { computed, type Ref, ref, toRefs, type WatchHandle, watch } from 'vue'
2
+ import { type ConstrBind, forEach, isArray, isNumber, useLazyItemByMarginRef } from '@dxtmisha/functional'
3
+
4
+ import { ImageType } from './ImageType'
5
+ import { ImagePosition } from './ImagePosition'
6
+ import { ImageBackground } from './ImageBackground'
7
+
8
+ import { type ImageAttrs, type ImagePictureList, ImageTypeValue } from './basicTypes'
9
+ import type { ImageProps } from './props'
10
+
11
+ /**
12
+ * A class for working with the img tag.
13
+ *
14
+ * Класс для работы с тегом img.
15
+ */
16
+ export class ImageImg {
17
+ protected lazyInit = ref<boolean>(false)
18
+ protected lazyStatus?: WatchHandle
19
+
20
+ constructor(
21
+ protected readonly props: ImageProps,
22
+ protected readonly element: Ref<HTMLElement | undefined>,
23
+ protected readonly type: ImageType,
24
+ protected readonly position: ImagePosition,
25
+ protected readonly background: ImageBackground
26
+ ) {
27
+ const {
28
+ lazy,
29
+ preloadOffset
30
+ } = toRefs(props)
31
+
32
+ watch(
33
+ [lazy, preloadOffset, element],
34
+ () => {
35
+ if (
36
+ this.props.lazy
37
+ && this.element.value
38
+ ) {
39
+ this.makeLazy()
40
+ } else {
41
+ this.lazyInit.value = false
42
+ this.lazyStatus?.stop()
43
+ this.lazyStatus = undefined
44
+ }
45
+ },
46
+ { immediate: true }
47
+ )
48
+ }
49
+
50
+ /**
51
+ * Determines whether to use the img tag/ Определяет, использовать ли тег img
52
+ */
53
+ readonly is = computed<boolean>(() => {
54
+ return Boolean(this.props.tagImg)
55
+ && this.isType()
56
+ })
57
+
58
+ /**
59
+ * Determines whether lazy loading is enabled/ Определяет, включена ли ленивя загрузка
60
+ */
61
+ readonly isLazy = computed<boolean>(() => {
62
+ return Boolean(this.props.lazy) && !this.lazyInit.value
63
+ })
64
+
65
+ /**
66
+ * Determines whether to use the picture tag/ Определяет, использовать ли тег picture
67
+ */
68
+ readonly isPicture = computed(() => this.is.value && Boolean(this.props.picture))
69
+
70
+ /**
71
+ * Calculates all properties for binding to the element/
72
+ * Вычисляет все свойства для привязки к элементу
73
+ */
74
+ readonly binds = computed<ConstrBind<ImageAttrs>>(
75
+ () => {
76
+ const attrs: ConstrBind<any> = {
77
+ key: 'img'
78
+ }
79
+
80
+ if (this.is.value) {
81
+ attrs.src = this.background.imageSrc.value
82
+ attrs.alt = this.props.alt ?? ''
83
+ attrs.width = '100%'
84
+ attrs.height = '100%'
85
+ attrs.style = this.styles.value
86
+
87
+ if (this.props.lazy) {
88
+ attrs.loading = this.isLazy.value ? 'lazy' : 'auto'
89
+ }
90
+
91
+ if (this.props.srcset) {
92
+ attrs.srcset = this.getSrcset()
93
+ }
94
+ }
95
+
96
+ return attrs
97
+ }
98
+ )
99
+
100
+ /**
101
+ * Calculates the picture sources for different resolutions/
102
+ * Вычисляет источники picture для разных разрешений
103
+ */
104
+ readonly picture = computed<ImagePictureList | undefined>(() => {
105
+ if (!this.props.picture) {
106
+ return undefined
107
+ }
108
+
109
+ if (isArray(this.props.picture)) {
110
+ return this.props.picture
111
+ }
112
+
113
+ return forEach(
114
+ this.props.picture,
115
+ (value, media) => {
116
+ return {
117
+ key: media,
118
+ srcset: value,
119
+ media: `(width >= ${media})`
120
+ }
121
+ }
122
+ ) as ImagePictureList
123
+ })
124
+
125
+ /**
126
+ * Calculates styles for binding to the element.
127
+ *
128
+ * Вычисляет стили для привязки к элементу.
129
+ */
130
+ readonly styles = computed<Record<string, any>>(() => {
131
+ const styles: any = {
132
+ 'object-position': `${this.position.x.value} ${this.position.y.value}`,
133
+ '--sys-transform-originX': this.position.x.value,
134
+ '--sys-transform-originY': this.position.y.value
135
+ }
136
+
137
+ if (this.isSize()) {
138
+ styles['--sys-transform-scale'] = this.getSize()
139
+ }
140
+
141
+ return styles
142
+ })
143
+
144
+ /**
145
+ * Checks if the type is file or image.
146
+ *
147
+ * Проверяет, является ли тип файлом или изображением.
148
+ */
149
+ protected isType(): boolean {
150
+ const type = this.type.item.value
151
+ return type === ImageTypeValue.file || type === ImageTypeValue.image
152
+ }
153
+
154
+ /**
155
+ * Checks if the size is contained or cover.
156
+ *
157
+ * Проверяет, является ли размер contain или cover.
158
+ */
159
+ protected isSize(): boolean {
160
+ const size = this.background.size.value
161
+
162
+ return Boolean(size && size.match('[% ]'))
163
+ }
164
+
165
+ /**
166
+ * Returns the value for the transform scale.
167
+ *
168
+ * Возвращает значение для свойства transform scale.
169
+ */
170
+ protected getSize() {
171
+ return this.background.size.value
172
+ ?.replace('auto', '')
173
+ ?.trim()
174
+ }
175
+
176
+ /**
177
+ * Returns the srcset attribute value.
178
+ *
179
+ * Возвращает значение атрибута srcset.
180
+ */
181
+ protected getSrcset(): string | undefined {
182
+ if (!this.props.srcset) {
183
+ return undefined
184
+ }
185
+
186
+ if (typeof this.props.srcset === 'string') {
187
+ return this.props.srcset
188
+ }
189
+
190
+ return Object.entries(this.props.srcset)
191
+ .map(([key, value]) => `${value} ${this.toSrcsetKey(key)}`)
192
+ .join(', ')
193
+ }
194
+
195
+ /**
196
+ * Converts the srcset key to a string.
197
+ *
198
+ * Преобразует ключ srcset в строку.
199
+ * @param key key/ ключ
200
+ */
201
+ protected toSrcsetKey(key: string | number): string {
202
+ return isNumber(key) ? `${key}w` : String(key)
203
+ }
204
+
205
+ /**
206
+ * Initializes lazy loading.
207
+ *
208
+ * Инициализирует ленивую загрузку.
209
+ */
210
+ protected makeLazy(): void {
211
+ const lazyStatus = useLazyItemByMarginRef(this.element, `${this.props.preloadOffset} 0px`)
212
+ .lazyItemStatus
213
+
214
+ this.lazyStatus = watch(lazyStatus, () => {
215
+ this.lazyInit.value = lazyStatus.value
216
+ }, { immediate: true })
217
+ }
218
+ }
@@ -1,4 +1,4 @@
1
- import { isString } from '@dxtmisha/functional'
1
+ import { isDomRuntime, isString } from '@dxtmisha/functional'
2
2
 
3
3
  import { ImageFile } from './ImageFile'
4
4
 
@@ -21,7 +21,7 @@ export class ImagePdf {
21
21
  return Boolean(file.match(/\.pdf$/i))
22
22
  }
23
23
 
24
- return Boolean(file.type.match(/\/pdf$/i))
24
+ return isDomRuntime() && Boolean(file.type.match(/\/pdf$/i))
25
25
  }
26
26
 
27
27
  /**
@@ -19,6 +19,7 @@ export enum ImageTypeValue {
19
19
  }
20
20
 
21
21
  export type ImageElement = HTMLElement | undefined
22
+ export type ImageAttrs = Record<keyof HTMLImageElement, any>
22
23
 
23
24
  export type ImageCoordinatorItem
24
25
  = [number]
@@ -32,6 +33,10 @@ export type ImageSize<T = number> = {
32
33
  height: T
33
34
  }
34
35
 
36
+ export type ImagePictureItem = Record<keyof HTMLSourceElement & 'key', any>
37
+ export type ImagePictureList = ImagePictureItem[]
38
+ export type ImagePicture = Record<string, string> | ImagePictureList
39
+
35
40
  /**
36
41
  * Parameters for the uploaded image or the one available by a direct link.
37
42
  *
@@ -1,17 +1,17 @@
1
- {
2
- "color": {
3
- "_type": "var"
4
- },
5
- "color-opacity": {
6
- "_type": "var"
7
- },
8
- "~turn": {},
9
- "~disabled": {},
10
- "~hide": {},
11
- "~adaptive": {},
12
- "~size": {
13
- "~auto": {},
14
- "~contain": {},
15
- "~cover": {}
16
- }
17
- }
1
+ {
2
+ "color": {
3
+ "_type": "var"
4
+ },
5
+ "color-opacity": {
6
+ "_type": "var"
7
+ },
8
+ "~turn": {},
9
+ "~disabled": {},
10
+ "~hide": {},
11
+ "~adaptive": {},
12
+ "~size": {
13
+ "~auto": {},
14
+ "~contain": {},
15
+ "~cover": {}
16
+ }
17
+ }
@@ -1,10 +1,12 @@
1
+ import type { ImagePicture } from './basicTypes'
2
+
1
3
  interface ImagePropsToken {
2
- // :type [!] System label / Системная метка
3
- turn?: boolean
4
- disabled?: boolean
5
- hide?: boolean
6
- adaptive?: boolean
7
- size?: 'auto' | 'contain' | 'cover'
4
+ // :type [!] System label / Системная метка
5
+ turn?: boolean
6
+ disabled?: boolean
7
+ hide?: boolean
8
+ adaptive?: boolean
9
+ size?: 'auto' | 'contain' | 'cover'
8
10
  // :type [!] System label / Системная метка
9
11
  }
10
12
 
@@ -42,6 +44,30 @@ export interface ImagePropsBasic {
42
44
  x?: string | number
43
45
  /** Y position/ Позиция по оси Y */
44
46
  y?: string | number
47
+
48
+ /**
49
+ * Use <img> tag instead of background image/
50
+ * Использовать тег <img> вместо фонового изображения
51
+ */
52
+ tagImg?: boolean
53
+ /**
54
+ * Image source set for different resolutions/
55
+ * Набор источников изображения для разных разрешений
56
+ */
57
+ srcset?: string | Record<string, string>
58
+ /**
59
+ * Picture sources for different resolutions using <picture> tag/
60
+ * Источники для разных разрешений с использованием тега <picture>
61
+ */
62
+ picture?: ImagePicture
63
+ /** Alt text/ Текст alt */
64
+ alt?: string
65
+ /** Lazy loading/ Ленивя загрузка */
66
+ lazy?: boolean
67
+ /** Preload offset/ Смещение для предзагрузки */
68
+ preloadOffset?: string
69
+ /** Image fetch priority (low, high, auto)/ Приоритет загрузки изображения (low, high, auto) */
70
+ fetchPriority?: HTMLImageElement['fetchPriority']
45
71
  }
46
72
 
47
73
  /**
@@ -59,8 +85,9 @@ export interface ImageProps extends ImagePropsBasic, ImagePropsToken {
59
85
  */
60
86
  export const defaultsImage = {
61
87
  adaptiveGroup: 'basic',
88
+ preloadOffset: '1024px',
62
89
  ...{
63
- // :default [!] System label / Системная метка
90
+ // :default [!] System label / Системная метка
64
91
  // :default [!] System label / Системная метка
65
92
  }
66
93
  }
@@ -1,6 +1,10 @@
1
1
  @use "@dxtmisha/styles/properties" as ui;
2
2
 
3
3
  @mixin mixinImage {
4
+ @include ui.initByCustom('img.width', 100%);
5
+ @include ui.initByCustom('img.height', 100%);
6
+ @include ui.initByCustom('img.object.fit', cover);
7
+
4
8
  direction: ltr;
5
9
  @include ui.flexCenter;
6
10
  @include ui.absolute;
@@ -15,6 +19,29 @@
15
19
  transition-duration: ui.v('d.sys.transitionDuration.standard');
16
20
  transform: none;
17
21
 
22
+ @include ui.mediaPrefersReducedMotion {
23
+ transition-duration: 0ms;
24
+ }
25
+
26
+ img {
27
+ position: relative;
28
+ top: 50%;
29
+ left: 50%;
30
+ margin: auto;
31
+
32
+ width: ui.v('??img.width');
33
+ height: ui.v('??img.height');
34
+ min-width: 100%;
35
+ min-height: 100%;
36
+
37
+ object-fit: ui.v('??img.object.fit');
38
+
39
+ --sys-transform-translateX: -50%;
40
+ --sys-transform-translateY: -50%;
41
+ @include ui.transformInit();
42
+ transform-origin: var(--sys-transform-originX) var(--sys-transform-originY);
43
+ }
44
+
18
45
  &--type {
19
46
  &--public {
20
47
  -webkit-mask-position: center;
@@ -49,7 +76,22 @@
49
76
  }
50
77
  }
51
78
 
79
+ &--size {
80
+ &--auto {
81
+ @include ui.initByCustom('img.object.fit', none);
82
+ }
83
+
84
+ &--contain {
85
+ @include ui.initByCustom('img.object.fit', contain);
86
+ }
87
+
88
+ &--cover {
89
+ @include ui.initByCustom('img.object.fit', cover);
90
+ }
91
+ }
92
+
52
93
  &--adaptive {
94
+ @include ui.initByCustom('img.height', auto);
53
95
  background-size: 100%;
54
96
  }
55
97
 
@@ -44,6 +44,6 @@ export interface ImageSlots {
44
44
  */
45
45
  export type ImageClasses = {
46
46
  main: ConstrClass
47
- // :classes [!] System label / Системная метка
47
+ // :classes [!] System label / Системная метка
48
48
  // :classes [!] System label / Системная метка
49
49
  }