@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,69 @@
1
+ import type { FieldAllProps } from '../../types/fieldTypes'
2
+
3
+ /**
4
+ * Class for processing standard error text
5
+ *
6
+ * Класс для обработки стандартного текста ошибки
7
+ */
8
+ export class FieldCodeInclude {
9
+ /**
10
+ * Constructor
11
+ * @param props input data/ входные данные
12
+ */
13
+ constructor(
14
+ protected readonly props: FieldAllProps
15
+ ) {
16
+ }
17
+
18
+ /**
19
+ * Returns error text
20
+ *
21
+ * Возвращает текст ошибки
22
+ * @param state object with validity state/ объект с данными валидности
23
+ */
24
+ get(state?: ValidityState): string | undefined {
25
+ const validationCode = this.props.validationCode
26
+
27
+ if (
28
+ state
29
+ && validationCode
30
+ && !state.valid
31
+ ) {
32
+ if (typeof validationCode === 'string') {
33
+ return validationCode
34
+ } else {
35
+ const index = this.getIndex(state)
36
+
37
+ if (
38
+ index
39
+ && index in validationCode
40
+ ) {
41
+ return validationCode[index]
42
+ }
43
+ }
44
+ }
45
+
46
+ return undefined
47
+ }
48
+
49
+ /**
50
+ * Returns error key (first matched)
51
+ *
52
+ * Возвращает ключ ошибки (первый найденный)
53
+ * @param state object with validity state/ объект с данными валидности
54
+ */
55
+ protected getIndex(state: ValidityState): keyof ValidityState | undefined {
56
+ const data = Object.entries(state) as ([keyof ValidityState, boolean])[]
57
+
58
+ for (const [code, value] of data) {
59
+ if (
60
+ code !== 'valid'
61
+ && value
62
+ ) {
63
+ return code
64
+ }
65
+ }
66
+
67
+ return undefined
68
+ }
69
+ }
@@ -0,0 +1,97 @@
1
+ import type { Ref } from 'vue'
2
+ import type { FieldAllProps, FieldElementInput } from '../../types/fieldTypes'
3
+
4
+ /**
5
+ * Class for working with input elements.
6
+ *
7
+ * Класс для работы с элементами ввода.
8
+ */
9
+ export class FieldElementInclude {
10
+ /**
11
+ * Constructor
12
+ * @param props input data/ входные данные
13
+ * @param element input element/ элемент ввода
14
+ */
15
+
16
+ constructor(
17
+ protected readonly props: FieldAllProps,
18
+ protected readonly element: Ref<FieldElementInput>
19
+ ) {
20
+ }
21
+
22
+ /**
23
+ * Returns the input element.
24
+ *
25
+ * Возвращает элемент ввода.
26
+ */
27
+ get(): HTMLInputElement | undefined {
28
+ const element = this.element.value
29
+
30
+ if (element) {
31
+ if ('input' in element) {
32
+ return element.input
33
+ }
34
+
35
+ return element as HTMLInputElement
36
+ }
37
+
38
+ return undefined
39
+ }
40
+
41
+ /**
42
+ * Returns a reference to the input element.
43
+ *
44
+ * Возвращает ссылку на элемент ввода.
45
+ */
46
+ getElement(): Ref<FieldElementInput> {
47
+ return this.element
48
+ }
49
+
50
+ /**
51
+ * Search for an element by its name inside a group or by selector.
52
+ *
53
+ * Поиск элемента по его названию внутри группы или по селектору.
54
+ * @param nameSelectors element name or selector /<br>название элемента или селектор
55
+ */
56
+ findByName(nameSelectors: string | HTMLInputElement): HTMLInputElement | undefined {
57
+ if (nameSelectors instanceof Element) {
58
+ return nameSelectors
59
+ }
60
+
61
+ const form = this.get()?.form
62
+
63
+ if (form) {
64
+ const item = form.querySelector<HTMLInputElement>(`[name="${nameSelectors}"]`)
65
+
66
+ if (item) {
67
+ return item
68
+ }
69
+ }
70
+
71
+ const globalItem = document.querySelector<HTMLInputElement>(nameSelectors)
72
+
73
+ if (globalItem) {
74
+ return globalItem
75
+ }
76
+
77
+ return undefined
78
+ }
79
+
80
+ /**
81
+ * Clear all values to the original ones.
82
+ *
83
+ * Очисти все значения до оригинальных.
84
+ */
85
+ clear(): this {
86
+ const element = this.element.value
87
+
88
+ if (
89
+ element
90
+ && 'clear' in element
91
+ ) {
92
+ element.clear?.()
93
+ }
94
+
95
+ return this
96
+ }
97
+ }
@@ -0,0 +1,128 @@
1
+ import {
2
+ anyToString,
3
+ createElement,
4
+ executeFunction,
5
+ isFilled,
6
+ isString
7
+ } from '@dxtmisha/functional'
8
+
9
+ import type { FieldCodeInclude } from './FieldCodeInclude'
10
+
11
+ import type {
12
+ FieldElementDom,
13
+ FieldPatternElement,
14
+ FieldPatternItemOrFunction,
15
+ FieldValidationItem
16
+ } from '../../types/fieldTypes'
17
+
18
+ /**
19
+ * The class creates hidden input and runs native validation for pattern
20
+ *
21
+ * Класс создаёт скрытый input и выполняет нативную валидацию по паттерну
22
+ */
23
+ export class FieldInputCheckInclude<Value = any> {
24
+ /** Hidden input element for native validation/ Скрытый input для нативной валидации */
25
+ readonly input: HTMLInputElement | undefined
26
+
27
+ /**
28
+ * Constructor
29
+ * @param pattern property for verification/ свойство для проверки
30
+ * @param group group name/ название группы
31
+ * @param code object for error codes/ объект для работы с кодами ошибок
32
+ */
33
+ constructor(
34
+ readonly pattern: FieldPatternItemOrFunction,
35
+ readonly group: string = FieldInputCheckInclude.getGroupDefault(),
36
+ protected readonly code?: FieldCodeInclude
37
+ ) {
38
+ this.input = createElement<HTMLInputElement>(
39
+ undefined,
40
+ 'input',
41
+ this.getAttributes()
42
+ )
43
+ }
44
+
45
+ /**
46
+ * Runs validation and returns result
47
+ *
48
+ * Выполняет проверку и возвращает результат
49
+ */
50
+ check(value: Value): FieldValidationItem {
51
+ const input = this.input
52
+
53
+ if (input) {
54
+ if (
55
+ input.type === 'checkbox'
56
+ || input.type === 'radio'
57
+ ) {
58
+ input.checked = Boolean(value)
59
+ } else {
60
+ input.value = anyToString(value)
61
+ }
62
+
63
+ return this.checkByInput(input)
64
+ }
65
+
66
+ return {
67
+ group: this.group,
68
+ status: true,
69
+ value
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Runs validation by input and returns result
75
+ *
76
+ * Выполняет проверку по инпуту и возвращает результат
77
+ * @param input input element/ элемент инпута
78
+ */
79
+ checkByInput(
80
+ input: FieldElementDom
81
+ ): FieldValidationItem {
82
+ return {
83
+ group: this.group,
84
+ input,
85
+ status: input.checkValidity(),
86
+ validationMessage: input.validationMessage,
87
+ validity: input.validity,
88
+ validityMessage: this.code?.get(input.validity),
89
+ required: input.required,
90
+ pattern: this.pattern,
91
+ value: input.value
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Returns attributes for internal input
97
+ *
98
+ * Возвращает атрибуты для внутреннего инпута
99
+ */
100
+ protected getAttributes(): FieldPatternElement {
101
+ const pattern = this.pattern
102
+
103
+ if (isFilled(pattern)) {
104
+ const attributes: FieldPatternElement = executeFunction(pattern)
105
+
106
+ if (isFilled(attributes)) {
107
+ if (isString(attributes)) {
108
+ return { pattern: attributes }
109
+ }
110
+
111
+ return attributes
112
+ }
113
+ }
114
+
115
+ return {}
116
+ }
117
+
118
+ /**
119
+ * Returns the default group name
120
+ *
121
+ * Возвращает название группы по умолчанию
122
+ */
123
+ static getGroupDefault(): string {
124
+ return 'check'
125
+ }
126
+ }
127
+
128
+ export type FieldInputCheckListInclude = Record<string, FieldInputCheckInclude>
@@ -0,0 +1,101 @@
1
+ import { anyToString, isObject, Translate } from '@dxtmisha/functional'
2
+
3
+ import { FieldElementInclude } from './FieldElementInclude'
4
+ import { FieldValueInclude } from './FieldValueInclude'
5
+ import { FieldInputCheckInclude } from './FieldInputCheckInclude'
6
+
7
+ import type { FieldAllProps, FieldValidationItem } from '../../types/fieldTypes'
8
+
9
+ /**
10
+ * Class for checking input value matching with another element
11
+ *
12
+ * Класс для проверки совпадения вводимого значения с другим элементом
13
+ */
14
+ export class FieldMatchInclude {
15
+ /**
16
+ * Constructor
17
+ * @param props input data/ входные данные
18
+ * @param element object for working with input element/ объект для работы с элементом ввода
19
+ * @param value object for working with value/ объект для работы со значениями
20
+ */
21
+ constructor(
22
+ protected readonly props: FieldAllProps,
23
+ protected readonly element: FieldElementInclude,
24
+ protected readonly value: FieldValueInclude
25
+ ) {
26
+ }
27
+
28
+ /**
29
+ * Checks whether matching verification is enabled
30
+ *
31
+ * Проверяет, включена ли проверка совпадения
32
+ */
33
+ is(): boolean {
34
+ return Boolean(this.props.match)
35
+ }
36
+
37
+ /**
38
+ * Returns selector used to find external element
39
+ *
40
+ * Возвращает селектор для поиска внешнего элемента
41
+ */
42
+ getSelectors() {
43
+ if (this.is()) {
44
+ if (isObject(this.props.match)) {
45
+ return this.props.match.name
46
+ }
47
+
48
+ return this.props.match
49
+ }
50
+
51
+ return undefined
52
+ }
53
+
54
+ /**
55
+ * Returns validation error text
56
+ *
57
+ * Возвращает текст ошибки валидации
58
+ */
59
+ getValidationMessage(): string {
60
+ if (this.is()) {
61
+ if (
62
+ isObject(this.props.match)
63
+ && this.props.match?.validationMessage
64
+ ) {
65
+ return this.props.match.validationMessage
66
+ }
67
+
68
+ return Translate.getSync('Your entries must match.')
69
+ }
70
+
71
+ return ''
72
+ }
73
+
74
+ /**
75
+ * Checks value against external element
76
+ *
77
+ * Проверяет совпадение значения с внешним элементом
78
+ */
79
+ check(): FieldValidationItem | undefined {
80
+ const selectors = this.getSelectors()
81
+
82
+ if (selectors) {
83
+ const input = this.element.findByName(selectors)
84
+
85
+ if (
86
+ input
87
+ && anyToString(input.value) !== this.value.string.value
88
+ ) {
89
+ return {
90
+ group: FieldInputCheckInclude.getGroupDefault(),
91
+ status: false,
92
+ input: this.element.get(),
93
+ validationMessage: this.getValidationMessage(),
94
+ value: this.value.item.value
95
+ }
96
+ }
97
+ }
98
+
99
+ return undefined
100
+ }
101
+ }
@@ -0,0 +1,42 @@
1
+ import { computed } from 'vue'
2
+
3
+ import { FieldTypeInclude } from './FieldTypeInclude'
4
+
5
+ import type { FieldAllProps } from '../../types/fieldTypes'
6
+
7
+ const PATTERNS: Record<string, string> = {
8
+ email: '[\\S]+@[\\S]{2,}\\.[\\w]{2,}',
9
+ password: '[0-9a-zA-Z\\-!@#$%^&*]+'
10
+ }
11
+
12
+ /**
13
+ * Class for working with checks by regular expressions.
14
+ *
15
+ * Класс для работы с проверкой по регулярным выражениям.
16
+ */
17
+ export class FieldPatternInclude {
18
+ /**
19
+ * Constructor
20
+ * @param props input data/ входные данные
21
+ * @param type object for working with input type/ объект для работы с типом ввода
22
+ */
23
+
24
+ constructor(
25
+ protected readonly props: FieldAllProps,
26
+ protected readonly type?: FieldTypeInclude
27
+ ) {
28
+ }
29
+
30
+ /** Returns regular expressions/ Возвращает регулярные выражения */
31
+ readonly item = computed<string | undefined>(() => {
32
+ if (this.props.pattern) {
33
+ return this.props.pattern
34
+ }
35
+
36
+ if (this.type) {
37
+ return PATTERNS?.[this.type.item.value]
38
+ }
39
+
40
+ return undefined
41
+ })
42
+ }
@@ -0,0 +1,42 @@
1
+ import { computed } from 'vue'
2
+
3
+ import { FieldVisibilityInclude } from './FieldVisibilityInclude'
4
+
5
+ import type { FieldAllProps } from '../../types/fieldTypes'
6
+
7
+ /**
8
+ * Class for working with the input type.
9
+ *
10
+ * Класс для работы с типом ввода.
11
+ */
12
+ export class FieldTypeInclude {
13
+ /**
14
+ * Constructor
15
+ * @param props input data/ входные данные
16
+ * @param visibility object for working with visualization/ объект для работы с визуализацией
17
+ */
18
+
19
+ constructor(
20
+ protected readonly props: FieldAllProps,
21
+ protected readonly visibility?: FieldVisibilityInclude
22
+ ) {
23
+ }
24
+
25
+ /** Returns the input type/ Возвращает тип ввода */
26
+ readonly item = computed<string>(() => {
27
+ if (this.props.arrow) {
28
+ return 'number'
29
+ }
30
+
31
+ const type = this.props.type
32
+
33
+ if (
34
+ type === 'password'
35
+ && this.visibility?.item.value
36
+ ) {
37
+ return 'text'
38
+ }
39
+
40
+ return type ?? 'text'
41
+ })
42
+ }
@@ -0,0 +1,196 @@
1
+ import { computed, ref } from 'vue'
2
+
3
+ import { FieldInputCheckInclude } from './FieldInputCheckInclude'
4
+
5
+ import type { FieldElementInclude } from './FieldElementInclude'
6
+ import type { FieldAttributesInclude } from './FieldAttributesInclude'
7
+ import type { FieldChangeInclude } from './FieldChangeInclude'
8
+ import type { FieldValueInclude } from './FieldValueInclude'
9
+ import type { FieldCodeInclude } from './FieldCodeInclude'
10
+ import type { FieldMatchInclude } from './FieldMatchInclude'
11
+
12
+ import type { FieldAllProps, FieldValidationItem } from '../../types/fieldTypes'
13
+
14
+ /**
15
+ * Class for working with validity
16
+ *
17
+ * Класс для работы с валидностью
18
+ */
19
+ export class InputValidation {
20
+ /** Internal validation state/ Внутреннее состояние валидации */
21
+ protected readonly validation = ref<FieldValidationItem>()
22
+
23
+ /**
24
+ * Constructor
25
+ * @param props input data/ входные данные
26
+ * @param element object for working with input element/ объект для работы с элементом ввода
27
+ * @param attributes object for working with input attributes/ объект для работы с атрибутами ввода
28
+ * @param value object for value work/ объект для работы со значениями
29
+ * @param change object for change state/ объект для состояния изменения
30
+ * @param code object for error codes/ объект для работы с кодами ошибок
31
+ * @param match object for match checking/ объект для проверки совпадений
32
+ */
33
+ constructor(
34
+ protected readonly props: FieldAllProps,
35
+ protected readonly element: FieldElementInclude,
36
+ protected readonly attributes: FieldAttributesInclude,
37
+ protected readonly value: FieldValueInclude,
38
+ protected readonly change?: FieldChangeInclude,
39
+ protected readonly code?: FieldCodeInclude,
40
+ protected readonly match?: FieldMatchInclude
41
+ ) {
42
+ }
43
+
44
+ /** Hidden input element for native validation/ Скрытый input для нативной валидации */
45
+ protected readonly input = computed<FieldInputCheckInclude>(
46
+ () => new FieldInputCheckInclude(
47
+ this.attributes.listForCheck.value,
48
+ undefined,
49
+ this.code
50
+ )
51
+ )
52
+
53
+ /** Returns error data/ Возвращает данные об ошибке */
54
+ readonly item = computed<FieldValidationItem>(() => {
55
+ const global = this.checkGlobal()
56
+
57
+ if (global) {
58
+ return global
59
+ }
60
+
61
+ const check = this.checkItem() ?? this.match?.check()
62
+
63
+ if (check) {
64
+ return check
65
+ }
66
+
67
+ return this.getValidationItemNone()
68
+ })
69
+
70
+ /** Returns error string/ Возвращает строку об ошибке */
71
+ readonly message = computed<string>(() => {
72
+ if (this.props.validationMessage) {
73
+ return this.props.validationMessage
74
+ }
75
+
76
+ if (
77
+ !this.change
78
+ || this.change.is()
79
+ ) {
80
+ const data = this.item.value
81
+
82
+ return data.validityMessage
83
+ ?? data.validationMessage
84
+ ?? ''
85
+ }
86
+
87
+ return ''
88
+ })
89
+
90
+ /**
91
+ * Checks if there is an error
92
+ *
93
+ * Проверяет, есть ли ошибка
94
+ */
95
+ isError(): boolean {
96
+ return !this.item.value?.status
97
+ }
98
+
99
+ /**
100
+ * Checks whether the element has constraints and satisfies them
101
+ *
102
+ * Проверяет, имеет ли элемент ограничения и удовлетворяет ли им
103
+ */
104
+ readonly checkValidity = (): boolean => {
105
+ return !this.isError()
106
+ }
107
+
108
+ /**
109
+ * Changes the validity data
110
+ *
111
+ * Изменяет данные о валидности
112
+ * @param validation values for validity/ значения для валидности
113
+ */
114
+ set(validation: Record<string, any> | FieldValidationItem): this {
115
+ if (
116
+ 'status' in validation
117
+ && 'validationMessage' in validation
118
+ && 'value' in validation
119
+ ) {
120
+ this.validation.value = validation as FieldValidationItem
121
+ } else if (
122
+ 'target' in validation
123
+ && (
124
+ validation.target instanceof HTMLInputElement
125
+ || validation.target instanceof HTMLTextAreaElement
126
+ )
127
+ && Number(validation.target.minLength) > -1
128
+ ) {
129
+ this.validation.value = this.input.value.checkByInput(validation.target)
130
+ } else {
131
+ this.validation.value = undefined
132
+ }
133
+
134
+ return this
135
+ }
136
+
137
+ /**
138
+ * Returns an empty validation item
139
+ *
140
+ * Возвращает пустой элемент валидации
141
+ */
142
+ protected getValidationItemNone(): FieldValidationItem {
143
+ return {
144
+ group: FieldInputCheckInclude.getGroupDefault(),
145
+ status: true,
146
+ value: undefined
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Check for global data
152
+ *
153
+ * Проверка для глобальных данных
154
+ */
155
+ protected checkGlobal(): FieldValidationItem | undefined {
156
+ if (this.props.validationMessage) {
157
+ return {
158
+ group: FieldInputCheckInclude.getGroupDefault(),
159
+ status: false,
160
+ validationMessage: this.props.validationMessage,
161
+ value: this.value.item.value
162
+ }
163
+ }
164
+
165
+ return this.validation.value ?? undefined
166
+ }
167
+
168
+ /**
169
+ * Check for selected data
170
+ *
171
+ * Проверка для выбранных данных
172
+ */
173
+ protected checkItem(): FieldValidationItem | undefined {
174
+ const values = this.value.getToArray()
175
+
176
+ for (const value of values) {
177
+ const check = this.checkByInput(value)
178
+
179
+ if (!check.status) {
180
+ return check
181
+ }
182
+ }
183
+
184
+ return undefined
185
+ }
186
+
187
+ /**
188
+ * Checks the value using hidden input element
189
+ * @param value value to check/ значение для проверки
190
+ *
191
+ * Проверяет значение с помощью скрытого input
192
+ */
193
+ protected checkByInput(value: any): FieldValidationItem {
194
+ return this.input.value.check(value)
195
+ }
196
+ }