@velumweb/ui-kit 1.0.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 (267) hide show
  1. package/.storybook/main.ts +14 -0
  2. package/.storybook/manager.ts +32 -0
  3. package/.storybook/preview.ts +14 -0
  4. package/dist/Button/Button.d.ts +32 -0
  5. package/dist/Button/Button.stories.d.ts +15 -0
  6. package/dist/Button/index.d.ts +1 -0
  7. package/dist/Container/Box.d.ts +33 -0
  8. package/dist/Container/index.d.ts +1 -0
  9. package/dist/Input/Input.d.ts +38 -0
  10. package/dist/Input/Input.stories.d.ts +14 -0
  11. package/dist/Input/index.d.ts +1 -0
  12. package/dist/Modal/Modal.d.ts +29 -0
  13. package/dist/Modal/Modal.stories.d.ts +13 -0
  14. package/dist/Modal/index.d.ts +1 -0
  15. package/dist/Toggle/Toggle.d.ts +18 -0
  16. package/dist/Toggle/Toggle.stories.d.ts +13 -0
  17. package/dist/Toggle/index.d.ts +1 -0
  18. package/dist/assets/svg-lib/3-dots-horizontal-svgrepo-com.svg +5 -0
  19. package/dist/assets/svg-lib/about-empty-page-svgrepo-com.svg +5 -0
  20. package/dist/assets/svg-lib/alert-square.svg +26 -0
  21. package/dist/assets/svg-lib/arrow-bottom-svgrepo-com.svg +9 -0
  22. package/dist/assets/svg-lib/arrow-left-svgrepo-com.svg +5 -0
  23. package/dist/assets/svg-lib/arrow-right-svgrepo-com.svg +5 -0
  24. package/dist/assets/svg-lib/arrow-top-svgrepo-com.svg +9 -0
  25. package/dist/assets/svg-lib/checkmark-svgrepo-com.svg +5 -0
  26. package/dist/assets/svg-lib/clock-svgrepo-com.svg +5 -0
  27. package/dist/assets/svg-lib/cross-svgrepo-com.svg +12 -0
  28. package/dist/assets/svg-lib/download-svgrepo-com.svg +5 -0
  29. package/dist/assets/svg-lib/edit-pen-svgrepo-com.svg +5 -0
  30. package/dist/assets/svg-lib/favorite-svgrepo-com.svg +5 -0
  31. package/dist/assets/svg-lib/forbiden-svgrepo-com.svg +9 -0
  32. package/dist/assets/svg-lib/input-svgrepo-com.svg +5 -0
  33. package/dist/assets/svg-lib/link-svgrepo-com.svg +5 -0
  34. package/dist/assets/svg-lib/messages-alert-svgrepo-com.svg +6 -0
  35. package/dist/assets/svg-lib/messages-svgrepo-com.svg +5 -0
  36. package/dist/assets/svg-lib/mic-off-svgrepo-com.svg +6 -0
  37. package/dist/assets/svg-lib/mic-svgrepo-com.svg +5 -0
  38. package/dist/assets/svg-lib/music-svgrepo-com.svg +6 -0
  39. package/dist/assets/svg-lib/next-long-arrow-right-svgrepo-com.svg +5 -0
  40. package/dist/assets/svg-lib/notification-alert-svgrepo-com.svg +6 -0
  41. package/dist/assets/svg-lib/notification-svgrepo-com.svg +5 -0
  42. package/dist/assets/svg-lib/notifications-off-svgrepo-com.svg +6 -0
  43. package/dist/assets/svg-lib/party-simple-colored-svgrepo-com.svg +11 -0
  44. package/dist/assets/svg-lib/pattern-circles-svgrepo-com.svg +5 -0
  45. package/dist/assets/svg-lib/play-button-simple-svgrepo-com.svg +5 -0
  46. package/dist/assets/svg-lib/plus-outlined-svgrepo-com.svg +5 -0
  47. package/dist/assets/svg-lib/previous-long-arrow-left-svgrepo-com.svg +5 -0
  48. package/dist/assets/svg-lib/queue-listing-cards-svgrepo-com.svg +6 -0
  49. package/dist/assets/svg-lib/queue-remove-svgrepo-com.svg +5 -0
  50. package/dist/assets/svg-lib/recent-svgrepo-com.svg +5 -0
  51. package/dist/assets/svg-lib/remove-svgrepo-com.svg +5 -0
  52. package/dist/assets/svg-lib/repeat-svgrepo-com.svg +5 -0
  53. package/dist/assets/svg-lib/schedule-add-svgrepo-com.svg +5 -0
  54. package/dist/assets/svg-lib/schedule-alert-svgrepo-com.svg +6 -0
  55. package/dist/assets/svg-lib/schedule-remove-svgrepo-com.svg +6 -0
  56. package/dist/assets/svg-lib/schedule-svgrepo-com.svg +5 -0
  57. package/dist/assets/svg-lib/search-svgrepo-com.svg +5 -0
  58. package/dist/assets/svg-lib/session-abandon-svgrepo-com.svg +5 -0
  59. package/dist/assets/svg-lib/session-join-svgrepo-com.svg +5 -0
  60. package/dist/assets/svg-lib/session-leave-svgrepo-com.svg +5 -0
  61. package/dist/assets/svg-lib/settings-svgrepo-com.svg +5 -0
  62. package/dist/assets/svg-lib/share-svgrepo-com.svg +5 -0
  63. package/dist/assets/svg-lib/sound-off-svgrepo-com.svg +6 -0
  64. package/dist/assets/svg-lib/sound-svgrepo-com.svg +5 -0
  65. package/dist/assets/svg-lib/spectacles-svgrepo-com.svg +5 -0
  66. package/dist/assets/svg-lib/star-svgrepo-com.svg +5 -0
  67. package/dist/assets/svg-lib/user-avatar-with-alert-svgrepo-com.svg +6 -0
  68. package/dist/assets/svg-lib/user-banned-svgrepo-com.svg +6 -0
  69. package/dist/assets/svg-lib/user-svgrepo-com.svg +5 -0
  70. package/dist/assets/svglist.png +0 -0
  71. package/dist/index.d.ts +5 -0
  72. package/dist/index.es.d.ts +2 -0
  73. package/dist/index.es.js +569 -0
  74. package/dist/index.umd.js +6 -0
  75. package/dist/ui-kit.css +1 -0
  76. package/docs/Button/Button.d.ts +32 -0
  77. package/docs/Button/Button.stories.d.ts +15 -0
  78. package/docs/Button/index.d.ts +1 -0
  79. package/docs/CNAME +1 -0
  80. package/docs/Container/Box.d.ts +33 -0
  81. package/docs/Container/index.d.ts +1 -0
  82. package/docs/Input/Input.d.ts +38 -0
  83. package/docs/Input/Input.stories.d.ts +14 -0
  84. package/docs/Input/index.d.ts +1 -0
  85. package/docs/Modal/Modal.d.ts +29 -0
  86. package/docs/Modal/Modal.stories.d.ts +13 -0
  87. package/docs/Modal/index.d.ts +1 -0
  88. package/docs/Toggle/Toggle.d.ts +18 -0
  89. package/docs/Toggle/Toggle.stories.d.ts +13 -0
  90. package/docs/Toggle/index.d.ts +1 -0
  91. package/docs/assets/Button-CfaZpHIg.css +1 -0
  92. package/docs/assets/Button-DBH2W8EG.js +1 -0
  93. package/docs/assets/Button.stories-uPwy2cWr.js +34 -0
  94. package/docs/assets/Input-D117xj27.js +1 -0
  95. package/docs/assets/Input-RjFZkyU_.css +1 -0
  96. package/docs/assets/Input.stories-Ck4AyV-4.js +21 -0
  97. package/docs/assets/Modal-CWKTs3Ep.css +1 -0
  98. package/docs/assets/Modal.stories-3HMpRqSx.js +7 -0
  99. package/docs/assets/Toggle-BmcBtVup.css +1 -0
  100. package/docs/assets/Toggle-DiHagfS3.js +1 -0
  101. package/docs/assets/Toggle.stories-d01loxLD.js +9 -0
  102. package/docs/assets/iframe-D7bwIom8.js +1062 -0
  103. package/docs/assets/jsx-runtime-u17CrQMm.js +1 -0
  104. package/docs/assets/preload-helper-PPVm8Dsz.js +1 -0
  105. package/docs/assets/react-18-CW3OMC0n.js +9 -0
  106. package/docs/assets/svg-lib/3-dots-horizontal-svgrepo-com.svg +5 -0
  107. package/docs/assets/svg-lib/about-empty-page-svgrepo-com.svg +5 -0
  108. package/docs/assets/svg-lib/alert-square.svg +26 -0
  109. package/docs/assets/svg-lib/arrow-bottom-svgrepo-com.svg +9 -0
  110. package/docs/assets/svg-lib/arrow-left-svgrepo-com.svg +5 -0
  111. package/docs/assets/svg-lib/arrow-right-svgrepo-com.svg +5 -0
  112. package/docs/assets/svg-lib/arrow-top-svgrepo-com.svg +9 -0
  113. package/docs/assets/svg-lib/checkmark-svgrepo-com.svg +5 -0
  114. package/docs/assets/svg-lib/clock-svgrepo-com.svg +5 -0
  115. package/docs/assets/svg-lib/cross-svgrepo-com.svg +12 -0
  116. package/docs/assets/svg-lib/download-svgrepo-com.svg +5 -0
  117. package/docs/assets/svg-lib/edit-pen-svgrepo-com.svg +5 -0
  118. package/docs/assets/svg-lib/favorite-svgrepo-com.svg +5 -0
  119. package/docs/assets/svg-lib/forbiden-svgrepo-com.svg +9 -0
  120. package/docs/assets/svg-lib/input-svgrepo-com.svg +5 -0
  121. package/docs/assets/svg-lib/link-svgrepo-com.svg +5 -0
  122. package/docs/assets/svg-lib/messages-alert-svgrepo-com.svg +6 -0
  123. package/docs/assets/svg-lib/messages-svgrepo-com.svg +5 -0
  124. package/docs/assets/svg-lib/mic-off-svgrepo-com.svg +6 -0
  125. package/docs/assets/svg-lib/mic-svgrepo-com.svg +5 -0
  126. package/docs/assets/svg-lib/music-svgrepo-com.svg +6 -0
  127. package/docs/assets/svg-lib/next-long-arrow-right-svgrepo-com.svg +5 -0
  128. package/docs/assets/svg-lib/notification-alert-svgrepo-com.svg +6 -0
  129. package/docs/assets/svg-lib/notification-svgrepo-com.svg +5 -0
  130. package/docs/assets/svg-lib/notifications-off-svgrepo-com.svg +6 -0
  131. package/docs/assets/svg-lib/party-simple-colored-svgrepo-com.svg +11 -0
  132. package/docs/assets/svg-lib/pattern-circles-svgrepo-com.svg +5 -0
  133. package/docs/assets/svg-lib/play-button-simple-svgrepo-com.svg +5 -0
  134. package/docs/assets/svg-lib/plus-outlined-svgrepo-com.svg +5 -0
  135. package/docs/assets/svg-lib/previous-long-arrow-left-svgrepo-com.svg +5 -0
  136. package/docs/assets/svg-lib/queue-listing-cards-svgrepo-com.svg +6 -0
  137. package/docs/assets/svg-lib/queue-remove-svgrepo-com.svg +5 -0
  138. package/docs/assets/svg-lib/recent-svgrepo-com.svg +5 -0
  139. package/docs/assets/svg-lib/remove-svgrepo-com.svg +5 -0
  140. package/docs/assets/svg-lib/repeat-svgrepo-com.svg +5 -0
  141. package/docs/assets/svg-lib/schedule-add-svgrepo-com.svg +5 -0
  142. package/docs/assets/svg-lib/schedule-alert-svgrepo-com.svg +6 -0
  143. package/docs/assets/svg-lib/schedule-remove-svgrepo-com.svg +6 -0
  144. package/docs/assets/svg-lib/schedule-svgrepo-com.svg +5 -0
  145. package/docs/assets/svg-lib/search-svgrepo-com.svg +5 -0
  146. package/docs/assets/svg-lib/session-abandon-svgrepo-com.svg +5 -0
  147. package/docs/assets/svg-lib/session-join-svgrepo-com.svg +5 -0
  148. package/docs/assets/svg-lib/session-leave-svgrepo-com.svg +5 -0
  149. package/docs/assets/svg-lib/settings-svgrepo-com.svg +5 -0
  150. package/docs/assets/svg-lib/share-svgrepo-com.svg +5 -0
  151. package/docs/assets/svg-lib/sound-off-svgrepo-com.svg +6 -0
  152. package/docs/assets/svg-lib/sound-svgrepo-com.svg +5 -0
  153. package/docs/assets/svg-lib/spectacles-svgrepo-com.svg +5 -0
  154. package/docs/assets/svg-lib/star-svgrepo-com.svg +5 -0
  155. package/docs/assets/svg-lib/user-avatar-with-alert-svgrepo-com.svg +6 -0
  156. package/docs/assets/svg-lib/user-banned-svgrepo-com.svg +6 -0
  157. package/docs/assets/svg-lib/user-svgrepo-com.svg +5 -0
  158. package/docs/assets/svglist.png +0 -0
  159. package/docs/favicon-wrapper.svg +46 -0
  160. package/docs/favicon.svg +1 -0
  161. package/docs/iframe.html +686 -0
  162. package/docs/index.d.ts +5 -0
  163. package/docs/index.html +137 -0
  164. package/docs/index.json +1 -0
  165. package/docs/makeColors.ts +37 -0
  166. package/docs/notes.txt +11 -0
  167. package/docs/nunito-sans-bold-italic.woff2 +0 -0
  168. package/docs/nunito-sans-bold.woff2 +0 -0
  169. package/docs/nunito-sans-italic.woff2 +0 -0
  170. package/docs/nunito-sans-regular.woff2 +0 -0
  171. package/docs/project.json +1 -0
  172. package/docs/sb-addons/storybook-1/manager-bundle.js +3 -0
  173. package/docs/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +628 -0
  174. package/docs/sb-common-assets/favicon-wrapper.svg +46 -0
  175. package/docs/sb-common-assets/favicon.svg +1 -0
  176. package/docs/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
  177. package/docs/sb-common-assets/nunito-sans-bold.woff2 +0 -0
  178. package/docs/sb-common-assets/nunito-sans-italic.woff2 +0 -0
  179. package/docs/sb-common-assets/nunito-sans-regular.woff2 +0 -0
  180. package/docs/sb-manager/globals-runtime.js +75597 -0
  181. package/docs/sb-manager/globals.js +24 -0
  182. package/docs/sb-manager/manager-stores.js +23 -0
  183. package/docs/sb-manager/runtime.js +19698 -0
  184. package/docs/style_setter.js +19 -0
  185. package/docs/vite-inject-mocker-entry.js +2 -0
  186. package/index.html +7 -0
  187. package/package.json +37 -0
  188. package/public/assets/svg-lib/3-dots-horizontal-svgrepo-com.svg +5 -0
  189. package/public/assets/svg-lib/about-empty-page-svgrepo-com.svg +5 -0
  190. package/public/assets/svg-lib/alert-square.svg +26 -0
  191. package/public/assets/svg-lib/arrow-bottom-svgrepo-com.svg +9 -0
  192. package/public/assets/svg-lib/arrow-left-svgrepo-com.svg +5 -0
  193. package/public/assets/svg-lib/arrow-right-svgrepo-com.svg +5 -0
  194. package/public/assets/svg-lib/arrow-top-svgrepo-com.svg +9 -0
  195. package/public/assets/svg-lib/checkmark-svgrepo-com.svg +5 -0
  196. package/public/assets/svg-lib/clock-svgrepo-com.svg +5 -0
  197. package/public/assets/svg-lib/cross-svgrepo-com.svg +12 -0
  198. package/public/assets/svg-lib/download-svgrepo-com.svg +5 -0
  199. package/public/assets/svg-lib/edit-pen-svgrepo-com.svg +5 -0
  200. package/public/assets/svg-lib/favorite-svgrepo-com.svg +5 -0
  201. package/public/assets/svg-lib/forbiden-svgrepo-com.svg +9 -0
  202. package/public/assets/svg-lib/input-svgrepo-com.svg +5 -0
  203. package/public/assets/svg-lib/link-svgrepo-com.svg +5 -0
  204. package/public/assets/svg-lib/messages-alert-svgrepo-com.svg +6 -0
  205. package/public/assets/svg-lib/messages-svgrepo-com.svg +5 -0
  206. package/public/assets/svg-lib/mic-off-svgrepo-com.svg +6 -0
  207. package/public/assets/svg-lib/mic-svgrepo-com.svg +5 -0
  208. package/public/assets/svg-lib/music-svgrepo-com.svg +6 -0
  209. package/public/assets/svg-lib/next-long-arrow-right-svgrepo-com.svg +5 -0
  210. package/public/assets/svg-lib/notification-alert-svgrepo-com.svg +6 -0
  211. package/public/assets/svg-lib/notification-svgrepo-com.svg +5 -0
  212. package/public/assets/svg-lib/notifications-off-svgrepo-com.svg +6 -0
  213. package/public/assets/svg-lib/party-simple-colored-svgrepo-com.svg +11 -0
  214. package/public/assets/svg-lib/pattern-circles-svgrepo-com.svg +5 -0
  215. package/public/assets/svg-lib/play-button-simple-svgrepo-com.svg +5 -0
  216. package/public/assets/svg-lib/plus-outlined-svgrepo-com.svg +5 -0
  217. package/public/assets/svg-lib/previous-long-arrow-left-svgrepo-com.svg +5 -0
  218. package/public/assets/svg-lib/queue-listing-cards-svgrepo-com.svg +6 -0
  219. package/public/assets/svg-lib/queue-remove-svgrepo-com.svg +5 -0
  220. package/public/assets/svg-lib/recent-svgrepo-com.svg +5 -0
  221. package/public/assets/svg-lib/remove-svgrepo-com.svg +5 -0
  222. package/public/assets/svg-lib/repeat-svgrepo-com.svg +5 -0
  223. package/public/assets/svg-lib/schedule-add-svgrepo-com.svg +5 -0
  224. package/public/assets/svg-lib/schedule-alert-svgrepo-com.svg +6 -0
  225. package/public/assets/svg-lib/schedule-remove-svgrepo-com.svg +6 -0
  226. package/public/assets/svg-lib/schedule-svgrepo-com.svg +5 -0
  227. package/public/assets/svg-lib/search-svgrepo-com.svg +5 -0
  228. package/public/assets/svg-lib/session-abandon-svgrepo-com.svg +5 -0
  229. package/public/assets/svg-lib/session-join-svgrepo-com.svg +5 -0
  230. package/public/assets/svg-lib/session-leave-svgrepo-com.svg +5 -0
  231. package/public/assets/svg-lib/settings-svgrepo-com.svg +5 -0
  232. package/public/assets/svg-lib/share-svgrepo-com.svg +5 -0
  233. package/public/assets/svg-lib/sound-off-svgrepo-com.svg +6 -0
  234. package/public/assets/svg-lib/sound-svgrepo-com.svg +5 -0
  235. package/public/assets/svg-lib/spectacles-svgrepo-com.svg +5 -0
  236. package/public/assets/svg-lib/star-svgrepo-com.svg +5 -0
  237. package/public/assets/svg-lib/user-avatar-with-alert-svgrepo-com.svg +6 -0
  238. package/public/assets/svg-lib/user-banned-svgrepo-com.svg +6 -0
  239. package/public/assets/svg-lib/user-svgrepo-com.svg +5 -0
  240. package/public/assets/svglist.png +0 -0
  241. package/readme.md +9 -0
  242. package/src/components/Button/Button.stories.ts +64 -0
  243. package/src/components/Button/Button.tsx +99 -0
  244. package/src/components/Button/button.scss +147 -0
  245. package/src/components/Button/index.ts +1 -0
  246. package/src/components/Container/Box.tsx +83 -0
  247. package/src/components/Container/box.scss +41 -0
  248. package/src/components/Container/index.ts +1 -0
  249. package/src/components/Input/Input.stories.ts +49 -0
  250. package/src/components/Input/Input.tsx +172 -0
  251. package/src/components/Input/index.ts +1 -0
  252. package/src/components/Input/input.scss +69 -0
  253. package/src/components/Modal/Modal.stories.ts +33 -0
  254. package/src/components/Modal/Modal.tsx +125 -0
  255. package/src/components/Modal/index.ts +1 -0
  256. package/src/components/Modal/modal.scss +54 -0
  257. package/src/components/Toggle/Toggle.stories.ts +35 -0
  258. package/src/components/Toggle/Toggle.tsx +60 -0
  259. package/src/components/Toggle/index.ts +1 -0
  260. package/src/components/Toggle/toggle.scss +97 -0
  261. package/src/components/index.ts +5 -0
  262. package/src/main.scss +46 -0
  263. package/tsconfig.json +15 -0
  264. package/utils/makeColors.ts +37 -0
  265. package/utils/notes.txt +11 -0
  266. package/utils/style_setter.js +19 -0
  267. package/vite.config.ts +32 -0
@@ -0,0 +1,172 @@
1
+ import React, {useState, useId} from 'react';
2
+ import { Button } from "../Button";
3
+ import './input.scss';
4
+
5
+ /**
6
+ * Компонент поля для ввода текста
7
+ * - тип (текст, цифры, пароль)
8
+ * - это поисковая строка (значок лупы)
9
+ * - валидация
10
+ */
11
+
12
+ export interface InputProps {
13
+ /** Значение */
14
+ value?: string | number;
15
+
16
+ /** Текстовое поле \ цифровое \ пароль \ textarea */
17
+ type?: 'text' | 'number' | 'password' | 'email' | 'date' | 'tel' | 'time' | 'textarea';
18
+
19
+ /** Углы прямые / Закругленные / Круглые */
20
+ corners?: 'square' | 'standard' | 'round';
21
+
22
+ /** Доступность поля */
23
+ disabled?: boolean,
24
+
25
+ /** Текст над полем */
26
+ label?: string;
27
+
28
+ /** Текст под полем */
29
+ bottomText?: string;
30
+
31
+ /** Плейсхолдер */
32
+ placeholder?: string;
33
+
34
+ /** Живой поиск */
35
+ live?: boolean;
36
+
37
+ /** Событие при изменении */
38
+ onChange?: (value?: string | number) => void;
39
+
40
+ /** Это поиск */
41
+ isSearch?: boolean;
42
+
43
+ /** Валидация */
44
+ mask?: RegExp;
45
+
46
+ /** Ошибки валидации */
47
+ errorText: string;
48
+
49
+ /** Ширина в px */
50
+ width?: number;
51
+
52
+ /** Дополнительные классы */
53
+ cls?: string;
54
+ }
55
+
56
+ /** Элемент кнопки */
57
+ export const Input = ({
58
+ value='',
59
+ type='text',
60
+ corners='standard',
61
+ disabled=false,
62
+ label='',
63
+ bottomText='',
64
+ placeholder='',
65
+ errorText='',
66
+ live=false,
67
+ isSearch=false,
68
+ mask,
69
+ width,
70
+ onChange,
71
+ cls,
72
+ ...props
73
+ }: InputProps) => {
74
+ const [internalValue, setInternalValue] = useState<string | number>(value);
75
+ const [error, setError] = useState<string>('');
76
+ const inputId = useId();
77
+
78
+ const handleChange = (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
79
+ let val: string | number = e.target.value;
80
+
81
+ if (type === 'number') {
82
+ val = val.toString().replace(/\D/g, '');
83
+ }
84
+
85
+ if (mask && !mask.test(val.toString())) {
86
+ setError(errorText || 'Некорректное значение'); // TODO нормальные текстовки
87
+ } else {
88
+ setError('');
89
+ }
90
+
91
+ setInternalValue(val);
92
+
93
+ if (live && onChange) {
94
+ onChange(val);
95
+ }
96
+ };
97
+
98
+ const clearInput = () => {
99
+ setInternalValue('');
100
+ }
101
+
102
+ const handleBlur = (e: FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => {
103
+ if (!live && onChange) {
104
+ onChange(internalValue);
105
+ }
106
+ };
107
+
108
+ const inputProps = {
109
+ value: internalValue,
110
+ placeholder,
111
+ onChange: handleChange,
112
+ onBlur: handleBlur,
113
+ className: [
114
+ 'kit-input',
115
+ `kit-input--${corners}`,
116
+ disabled ? 'kit-input--disabled' : '',
117
+ error ? 'kit-input--error' : '',
118
+ cls
119
+ ].join(' ').trim()
120
+ };
121
+
122
+ return (
123
+ <div className="kit-input--wrapper">
124
+ { label && <div className='w5rem'>
125
+ <label
126
+ for={ inputId }
127
+ className="kit-input--label kit-input-secondary-text"
128
+ >
129
+ { label }
130
+ </label>
131
+ </div> }
132
+ <div
133
+ className="kit-input--container"
134
+ style={{ 'width': width ? `${width}px` : 'auto' }}
135
+ >
136
+ { type === 'textarea' ? (
137
+ <textarea
138
+ id={ inputId }
139
+ { ...inputProps }
140
+ />
141
+ ) : (
142
+ <input
143
+ { ...inputProps }
144
+ type={ type }
145
+ id={ inputId }
146
+ />
147
+ )}
148
+
149
+ <div className='kit-input--icon-container'>
150
+ { internalValue && <Button
151
+ type='transparent'
152
+ iconPath='svg-lib/input-svgrepo-com.svg'
153
+ size='small'
154
+ onClick={clearInput}
155
+ cls='kit-input--icon'
156
+ /> }
157
+ { isSearch && <Button
158
+ type='transparent'
159
+ iconPath='svg-lib/search-svgrepo-com.svg'
160
+ size='small'
161
+ staticIcon={live}
162
+ onClick={() => onChange && onChange(internalValue)}
163
+ cls='kit-input--icon'
164
+ /> }
165
+ </div>
166
+ </div>
167
+
168
+ { !error && bottomText && <div className="kit-input-bottomtext kit-input-secondary-text">{bottomText}</div> }
169
+ { error && <div className="kit-input-errortext kit-input-secondary-text">{error}</div> }
170
+ </div>
171
+ );
172
+ };
@@ -0,0 +1 @@
1
+ export * from "./Input";
@@ -0,0 +1,69 @@
1
+ @import '../../main.scss';
2
+
3
+ .kit-input--container {
4
+ display: flex;
5
+ line-height: 30px;
6
+ align-items: center;
7
+ position: relative;
8
+ }
9
+
10
+ .kit-input {
11
+ width: 100%;
12
+ height: 36px;
13
+ line-height: 30px;
14
+ padding: 0 .6rem;
15
+ border: 1px solid var(--primary-btn-color);
16
+ outline: none;
17
+ background-color: #efefef;
18
+ color: var(--text-color);
19
+ transition: .3s ease;
20
+ &.kit-input--disabled {
21
+ opacity: 0.5;
22
+ pointer-events: none;
23
+ user-select: none;
24
+ }
25
+ }
26
+ .kit-input--error {
27
+ border: 1px solid var(--error-color);
28
+ }
29
+
30
+ .kit-input--standard {
31
+ border-radius: var(--corners-standard);
32
+ }
33
+ .kit-input--round {
34
+ border-radius: var(--corners-round);
35
+ }
36
+ .kit-input--square {
37
+ border-radius: var(--corners-square);
38
+ }
39
+
40
+ .kit-input-secondary-text {
41
+ font-size: 12px;
42
+ line-height: 24px;
43
+ margin-left: .8rem;
44
+ }
45
+
46
+ .kit-input::placeholder, .kit-input-bottomtext {
47
+ color: var(--text-color-secondary);
48
+ }
49
+ .kit-input-errortext {
50
+ color: var(--error-color);
51
+ }
52
+ .kit-input--label {
53
+ color: var(--text-color);
54
+ }
55
+
56
+ .kit-input:focus, .kit-input:hover {
57
+ outline: none;
58
+ }
59
+
60
+ .kit-input--icon-container {
61
+ position: absolute;
62
+ right: .4rem;
63
+ fill: none;
64
+ display: flex;
65
+ }
66
+
67
+ .kit-input--icon {
68
+ padding: 4px;
69
+ }
@@ -0,0 +1,33 @@
1
+ import type { StoryObj } from '@storybook/react-vite';
2
+ import { Modal } from './Modal';
3
+
4
+ const meta = {
5
+ title: 'Modal',
6
+ component: Modal,
7
+ parameters: {
8
+ layout: 'centered'
9
+ },
10
+ tags: ['autodocs'],
11
+ decorators: [
12
+ (Story) => {
13
+ const script = document.createElement('script')
14
+ script.src = '/style_setter.js'
15
+ script.type = 'module'
16
+ document.head.appendChild(script)
17
+
18
+ return Story()
19
+ },
20
+ ],
21
+ }
22
+
23
+ export default meta;
24
+ type Story = StoryObj<typeof meta>;
25
+
26
+ export const ModalWindow: Story = {
27
+ args: {
28
+ width: 400,
29
+ isOpen: true,
30
+ children: 'This is modal window! You can close it.'
31
+ }
32
+ };
33
+
@@ -0,0 +1,125 @@
1
+ import React, { ReactNode, useEffect, useRef, useState } from 'react';
2
+ import { Box, Button } from "../index";
3
+ import './modal.scss';
4
+
5
+ /**
6
+ * Компонент модальное окно
7
+ * - размеры
8
+ * - углы
9
+ * - тип непрозрачности фона
10
+ */
11
+
12
+
13
+ export interface ModalProps {
14
+ /** Ширина */
15
+ width?: number | 'auto';
16
+
17
+ /** Углы прямые / Закругленные / Круглые */
18
+ corners?: 'square' | 'standard' | 'round';
19
+
20
+ /** Тип непрозрачности фона */
21
+ background?: 'blackout' | 'blur';
22
+
23
+ /** Содержимое контейнера **/
24
+ children: ReactNode | string;
25
+
26
+ /** Дополнительные классы */
27
+ cls?: string;
28
+
29
+ /** Операции при закрытии */
30
+ onClose: () => void;
31
+
32
+ /** Окно открыто */
33
+ isOpen?: boolean;
34
+
35
+ /** Title */
36
+ title?: string; // TODO
37
+
38
+ /** Кнопка закрытия в углу */
39
+ closeButton?: boolean;
40
+ }
41
+
42
+ /** Элемент модалки */
43
+ export const Modal = ({
44
+ width = 'auto',
45
+ corners = 'standard',
46
+ background = 'blackout',
47
+ isOpen = false,
48
+ closeButton = true,
49
+ title = '',
50
+ cls = '',
51
+ children,
52
+ onClose,
53
+ ...props
54
+ }: ModalProps) => {
55
+ const overlayRef = useRef<HTMLDivElement | null>(null);
56
+ const [showModal, setShowModal] = useState(isOpen);
57
+
58
+ function handleClose(): void {
59
+ setShowModal(false);
60
+ onClose && onClose();
61
+ }
62
+
63
+ /** только для демонстрации в userbook */
64
+ useEffect(() => {
65
+ setShowModal(isOpen);
66
+ }, [isOpen]);
67
+
68
+ useEffect(() => {
69
+ if (!showModal) return;
70
+
71
+ function handleKeyDown(e) {
72
+ if (e.key === 'Escape') handleClose();
73
+ }
74
+
75
+ // закрытие по Esc
76
+ document.addEventListener('keydown', handleKeyDown);
77
+
78
+ // блокировка скролла фона
79
+ const original = document.body.style.overflow;
80
+ document.body.style.overflow = 'hidden';
81
+
82
+ return () => {
83
+ document.body.style.overflow = original;
84
+ document.removeEventListener('keydown', handleKeyDown);
85
+ }
86
+ }, [showModal, handleClose]);
87
+
88
+ return(
89
+ <>
90
+ {showModal ? <div
91
+ className='kit-modal--overlay'
92
+ onClick={(e) => {
93
+ if (e.target === overlayRef.current) handleClose()
94
+ }}
95
+ ref={overlayRef}
96
+ >
97
+ <div
98
+ className={[
99
+ 'kit-modal',
100
+ `kit-modal--${corners}`,
101
+ `kit-modal--bg-${background}`,
102
+ cls
103
+ ].join(' ')}
104
+ style={{width: !isNaN(width as number) ? `${width}px` : 'fit-content'}}
105
+ {...props}>
106
+ <Box padding={[8, 16]} direction='column'>
107
+ <Box justify='end' margin={[0, -16]}>
108
+ <Button
109
+ type='transparent'
110
+ size='large'
111
+ onClick={handleClose}
112
+ iconPath='svg-lib/cross-svgrepo-com.svg'
113
+ cls='kit-modal-close'
114
+ />
115
+ </Box>
116
+ <Box justify='start'>
117
+ {children}
118
+ </Box>
119
+ { /** (необязательные) кнопки управления окном */}
120
+ </Box>
121
+ </div>
122
+ </div> : <></>}
123
+ </>
124
+ )
125
+ };
@@ -0,0 +1 @@
1
+ export * from './Modal'
@@ -0,0 +1,54 @@
1
+ @import '../../main.scss';
2
+
3
+ .kit-modal--overlay {
4
+ position: fixed;
5
+ top: 0;
6
+ left: 0;
7
+ inset: 0;
8
+ width: 100%;
9
+ height: 100%;
10
+ background: rgba(0,0,0,0.8);
11
+ z-index: 9999;
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+ animation: fadeInOverlay 0.2s ease-out;
16
+ }
17
+
18
+ .kit-modal {
19
+ background-color: var(--bg-color);
20
+ position: relative;
21
+ max-width: 420px; // TODO убрать?
22
+ width: 100%; // TODO убрать?
23
+ min-height: 200px;
24
+ box-shadow: 0 10px 30px rgba(0,0,0,0.15);
25
+ animation: fadeInModal 0.2s ease-out;
26
+ & > div {
27
+ width: auto;
28
+ }
29
+ }
30
+
31
+ .kit-modal-close {
32
+ margin: -4px -16px 0 0;
33
+ }
34
+
35
+ // border-radius
36
+ .kit-modal--standard {
37
+ border-radius: var(--corners-standard);
38
+ }
39
+ .kit-modal--round {
40
+ border-radius: var(--corners-round);
41
+ }
42
+ .kit-modal--square {
43
+ border-radius: var(--corners-square);
44
+ }
45
+
46
+ // animations
47
+ @keyframes fadeInOverlay {
48
+ from { opacity: 0; }
49
+ to { opacity: 1; }
50
+ }
51
+ @keyframes fadeInModal {
52
+ from { opacity: 0; transform: scale(0.95); }
53
+ to { opacity: 1; transform: scale(1); }
54
+ }
@@ -0,0 +1,35 @@
1
+ import type { StoryObj } from '@storybook/react-vite';
2
+ import { Toggle } from './Toggle';
3
+
4
+ const meta = {
5
+ title: 'Example Toggle',
6
+ component: Toggle,
7
+ parameters: {
8
+ layout: 'centered'
9
+ },
10
+ tags: ['autodocs'],
11
+ decorators: [
12
+ (Story) => {
13
+ const script = document.createElement('script')
14
+ script.src = '/style_setter.js'
15
+ script.type = 'module'
16
+ document.head.appendChild(script)
17
+
18
+ return Story()
19
+ },
20
+ ],
21
+ }
22
+
23
+ export default meta;
24
+ type Story = StoryObj<typeof meta>;
25
+
26
+ export const CustomToggle: Story = {
27
+ args: {
28
+ text: 'subscribe',
29
+ size: 'medium',
30
+ disabled: false,
31
+ cls: '',
32
+ onClick: () => console.log('CustomToggle')
33
+ },
34
+ };
35
+
@@ -0,0 +1,60 @@
1
+ import React, { useId } from 'react';
2
+ import './toggle.scss';
3
+
4
+ /**
5
+ * Компонент переключателя
6
+ */
7
+
8
+ export interface ToggleProps {
9
+ /** Маленькая / Средняя / Большая */
10
+ size?: 'small' | 'medium' | 'large';
11
+
12
+ /** Доступность переключателя */
13
+ disabled?: boolean,
14
+
15
+ /** Текст переключателя */
16
+ text?: string;
17
+
18
+ /** Событие при нажатии */
19
+ onClick?: (e?: MouseEvent) => void;
20
+
21
+ /** Дополнительные классы */
22
+ cls?: string;
23
+ }
24
+
25
+ /** Элемент кнопки */
26
+ export const Toggle: React.FC<ToggleProps> = ({
27
+ size = 'medium',
28
+ disabled = false,
29
+ cls = '',
30
+ text = '',
31
+ onClick,
32
+ ...props
33
+ }) => {
34
+ const toggleId = useId();
35
+
36
+ return (
37
+ <label
38
+ htmlFor={toggleId}
39
+ className={[
40
+ 'kit-toggle',
41
+ disabled ? 'kit-toggle--disabled' : '',
42
+ `kit-toggle--${size}`,
43
+ cls
44
+ ].join(' ')}
45
+ >
46
+ <input
47
+ id={toggleId}
48
+ type="checkbox"
49
+ className="kit-toggle--input"
50
+ disabled={disabled}
51
+ defaultChecked={false}
52
+ onChange={(e) => onClick?.(e.target.checked)}
53
+ />
54
+
55
+ <span className="kit-toggle--slider" aria-hidden="true" />
56
+
57
+ {text && <span className="kit-toggle--label">{text}</span>}
58
+ </label>
59
+ );
60
+ };
@@ -0,0 +1 @@
1
+ export * from "./Toggle";
@@ -0,0 +1,97 @@
1
+ @import '../../main.scss';
2
+
3
+ .kit-toggle {
4
+ display: inline-flex;
5
+ align-items: center;
6
+ gap: 12px;
7
+ cursor: pointer;
8
+ user-select: none;
9
+ font-family: system-ui, sans-serif;
10
+ }
11
+
12
+ .kit-toggle--input {
13
+ position: absolute;
14
+ opacity: 0;
15
+ pointer-events: none;
16
+ }
17
+
18
+ .kit-toggle--slider {
19
+ position: relative;
20
+ border-radius: 999px;
21
+ transition: background 0.25s ease;
22
+ background: #d1d5db;
23
+ }
24
+ .kit-toggle--slider::before {
25
+ content: "";
26
+ position: absolute;
27
+ top: 3px;
28
+ left: 3px;
29
+ border-radius: 50%;
30
+ transition: transform 0.25s ease, box-shadow 0.25s ease;
31
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
32
+ background: white;
33
+ }
34
+
35
+ .kit-toggle--input:checked + .kit-toggle--slider {
36
+ background: var(--primary-btn-color);
37
+ }
38
+ .kit-toggle--input:checked + .kit-toggle--slider::before {
39
+ transform: translateX(20px);
40
+ }
41
+ .kit-toggle--input:focus-visible + .kit-toggle--slider {
42
+ outline: 2px solid var(--primary-btn-color);
43
+ outline-offset: 2px;
44
+ }
45
+
46
+ .kit-toggle--disabled {
47
+ opacity: 0.5;
48
+ pointer-events: none;
49
+ user-select: none;
50
+ }
51
+ .kit-toggle--disabled .kit-toggle--slider {
52
+ background: #9ca3af;
53
+ }
54
+
55
+ .kit-toggle--label {
56
+ color: var(--text-color);
57
+ }
58
+
59
+ .kit-toggle--small {
60
+ & > .kit-toggle--slider {
61
+ width: 38px;
62
+ height: 18px;
63
+ &::before {
64
+ width: 12px;
65
+ height: 12px;
66
+ }
67
+ }
68
+ & > .kit-toggle--label {
69
+ font-size: 14px;
70
+ }
71
+ }
72
+ .kit-toggle--medium {
73
+ & > .kit-toggle--slider {
74
+ width: 42px;
75
+ height: 22px;
76
+ &::before {
77
+ width: 16px;
78
+ height: 16px;
79
+ }
80
+ }
81
+ & > .kit-toggle--label {
82
+ font-size: 16px;
83
+ }
84
+ }
85
+ .kit-toggle--large {
86
+ & > .kit-toggle--slider {
87
+ width: 46px;
88
+ height: 26px;
89
+ &::before {
90
+ width: 20px;
91
+ height: 20px;
92
+ }
93
+ }
94
+ & > .kit-toggle--label {
95
+ font-size: 18px;
96
+ }
97
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./Button";
2
+ export * from "./Container";
3
+ export * from "./Modal";
4
+ export * from "./Input";
5
+ export * from "./Toggle";