@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.
- package/.storybook/main.ts +14 -0
- package/.storybook/manager.ts +32 -0
- package/.storybook/preview.ts +14 -0
- package/dist/Button/Button.d.ts +32 -0
- package/dist/Button/Button.stories.d.ts +15 -0
- package/dist/Button/index.d.ts +1 -0
- package/dist/Container/Box.d.ts +33 -0
- package/dist/Container/index.d.ts +1 -0
- package/dist/Input/Input.d.ts +38 -0
- package/dist/Input/Input.stories.d.ts +14 -0
- package/dist/Input/index.d.ts +1 -0
- package/dist/Modal/Modal.d.ts +29 -0
- package/dist/Modal/Modal.stories.d.ts +13 -0
- package/dist/Modal/index.d.ts +1 -0
- package/dist/Toggle/Toggle.d.ts +18 -0
- package/dist/Toggle/Toggle.stories.d.ts +13 -0
- package/dist/Toggle/index.d.ts +1 -0
- package/dist/assets/svg-lib/3-dots-horizontal-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/about-empty-page-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/alert-square.svg +26 -0
- package/dist/assets/svg-lib/arrow-bottom-svgrepo-com.svg +9 -0
- package/dist/assets/svg-lib/arrow-left-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/arrow-right-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/arrow-top-svgrepo-com.svg +9 -0
- package/dist/assets/svg-lib/checkmark-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/clock-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/cross-svgrepo-com.svg +12 -0
- package/dist/assets/svg-lib/download-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/edit-pen-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/favorite-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/forbiden-svgrepo-com.svg +9 -0
- package/dist/assets/svg-lib/input-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/link-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/messages-alert-svgrepo-com.svg +6 -0
- package/dist/assets/svg-lib/messages-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/mic-off-svgrepo-com.svg +6 -0
- package/dist/assets/svg-lib/mic-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/music-svgrepo-com.svg +6 -0
- package/dist/assets/svg-lib/next-long-arrow-right-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/notification-alert-svgrepo-com.svg +6 -0
- package/dist/assets/svg-lib/notification-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/notifications-off-svgrepo-com.svg +6 -0
- package/dist/assets/svg-lib/party-simple-colored-svgrepo-com.svg +11 -0
- package/dist/assets/svg-lib/pattern-circles-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/play-button-simple-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/plus-outlined-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/previous-long-arrow-left-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/queue-listing-cards-svgrepo-com.svg +6 -0
- package/dist/assets/svg-lib/queue-remove-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/recent-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/remove-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/repeat-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/schedule-add-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/schedule-alert-svgrepo-com.svg +6 -0
- package/dist/assets/svg-lib/schedule-remove-svgrepo-com.svg +6 -0
- package/dist/assets/svg-lib/schedule-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/search-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/session-abandon-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/session-join-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/session-leave-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/settings-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/share-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/sound-off-svgrepo-com.svg +6 -0
- package/dist/assets/svg-lib/sound-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/spectacles-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/star-svgrepo-com.svg +5 -0
- package/dist/assets/svg-lib/user-avatar-with-alert-svgrepo-com.svg +6 -0
- package/dist/assets/svg-lib/user-banned-svgrepo-com.svg +6 -0
- package/dist/assets/svg-lib/user-svgrepo-com.svg +5 -0
- package/dist/assets/svglist.png +0 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.es.d.ts +2 -0
- package/dist/index.es.js +569 -0
- package/dist/index.umd.js +6 -0
- package/dist/ui-kit.css +1 -0
- package/docs/Button/Button.d.ts +32 -0
- package/docs/Button/Button.stories.d.ts +15 -0
- package/docs/Button/index.d.ts +1 -0
- package/docs/CNAME +1 -0
- package/docs/Container/Box.d.ts +33 -0
- package/docs/Container/index.d.ts +1 -0
- package/docs/Input/Input.d.ts +38 -0
- package/docs/Input/Input.stories.d.ts +14 -0
- package/docs/Input/index.d.ts +1 -0
- package/docs/Modal/Modal.d.ts +29 -0
- package/docs/Modal/Modal.stories.d.ts +13 -0
- package/docs/Modal/index.d.ts +1 -0
- package/docs/Toggle/Toggle.d.ts +18 -0
- package/docs/Toggle/Toggle.stories.d.ts +13 -0
- package/docs/Toggle/index.d.ts +1 -0
- package/docs/assets/Button-CfaZpHIg.css +1 -0
- package/docs/assets/Button-DBH2W8EG.js +1 -0
- package/docs/assets/Button.stories-uPwy2cWr.js +34 -0
- package/docs/assets/Input-D117xj27.js +1 -0
- package/docs/assets/Input-RjFZkyU_.css +1 -0
- package/docs/assets/Input.stories-Ck4AyV-4.js +21 -0
- package/docs/assets/Modal-CWKTs3Ep.css +1 -0
- package/docs/assets/Modal.stories-3HMpRqSx.js +7 -0
- package/docs/assets/Toggle-BmcBtVup.css +1 -0
- package/docs/assets/Toggle-DiHagfS3.js +1 -0
- package/docs/assets/Toggle.stories-d01loxLD.js +9 -0
- package/docs/assets/iframe-D7bwIom8.js +1062 -0
- package/docs/assets/jsx-runtime-u17CrQMm.js +1 -0
- package/docs/assets/preload-helper-PPVm8Dsz.js +1 -0
- package/docs/assets/react-18-CW3OMC0n.js +9 -0
- package/docs/assets/svg-lib/3-dots-horizontal-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/about-empty-page-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/alert-square.svg +26 -0
- package/docs/assets/svg-lib/arrow-bottom-svgrepo-com.svg +9 -0
- package/docs/assets/svg-lib/arrow-left-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/arrow-right-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/arrow-top-svgrepo-com.svg +9 -0
- package/docs/assets/svg-lib/checkmark-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/clock-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/cross-svgrepo-com.svg +12 -0
- package/docs/assets/svg-lib/download-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/edit-pen-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/favorite-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/forbiden-svgrepo-com.svg +9 -0
- package/docs/assets/svg-lib/input-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/link-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/messages-alert-svgrepo-com.svg +6 -0
- package/docs/assets/svg-lib/messages-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/mic-off-svgrepo-com.svg +6 -0
- package/docs/assets/svg-lib/mic-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/music-svgrepo-com.svg +6 -0
- package/docs/assets/svg-lib/next-long-arrow-right-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/notification-alert-svgrepo-com.svg +6 -0
- package/docs/assets/svg-lib/notification-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/notifications-off-svgrepo-com.svg +6 -0
- package/docs/assets/svg-lib/party-simple-colored-svgrepo-com.svg +11 -0
- package/docs/assets/svg-lib/pattern-circles-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/play-button-simple-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/plus-outlined-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/previous-long-arrow-left-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/queue-listing-cards-svgrepo-com.svg +6 -0
- package/docs/assets/svg-lib/queue-remove-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/recent-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/remove-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/repeat-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/schedule-add-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/schedule-alert-svgrepo-com.svg +6 -0
- package/docs/assets/svg-lib/schedule-remove-svgrepo-com.svg +6 -0
- package/docs/assets/svg-lib/schedule-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/search-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/session-abandon-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/session-join-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/session-leave-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/settings-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/share-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/sound-off-svgrepo-com.svg +6 -0
- package/docs/assets/svg-lib/sound-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/spectacles-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/star-svgrepo-com.svg +5 -0
- package/docs/assets/svg-lib/user-avatar-with-alert-svgrepo-com.svg +6 -0
- package/docs/assets/svg-lib/user-banned-svgrepo-com.svg +6 -0
- package/docs/assets/svg-lib/user-svgrepo-com.svg +5 -0
- package/docs/assets/svglist.png +0 -0
- package/docs/favicon-wrapper.svg +46 -0
- package/docs/favicon.svg +1 -0
- package/docs/iframe.html +686 -0
- package/docs/index.d.ts +5 -0
- package/docs/index.html +137 -0
- package/docs/index.json +1 -0
- package/docs/makeColors.ts +37 -0
- package/docs/notes.txt +11 -0
- package/docs/nunito-sans-bold-italic.woff2 +0 -0
- package/docs/nunito-sans-bold.woff2 +0 -0
- package/docs/nunito-sans-italic.woff2 +0 -0
- package/docs/nunito-sans-regular.woff2 +0 -0
- package/docs/project.json +1 -0
- package/docs/sb-addons/storybook-1/manager-bundle.js +3 -0
- package/docs/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +628 -0
- package/docs/sb-common-assets/favicon-wrapper.svg +46 -0
- package/docs/sb-common-assets/favicon.svg +1 -0
- package/docs/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/docs/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/docs/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/docs/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/docs/sb-manager/globals-runtime.js +75597 -0
- package/docs/sb-manager/globals.js +24 -0
- package/docs/sb-manager/manager-stores.js +23 -0
- package/docs/sb-manager/runtime.js +19698 -0
- package/docs/style_setter.js +19 -0
- package/docs/vite-inject-mocker-entry.js +2 -0
- package/index.html +7 -0
- package/package.json +37 -0
- package/public/assets/svg-lib/3-dots-horizontal-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/about-empty-page-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/alert-square.svg +26 -0
- package/public/assets/svg-lib/arrow-bottom-svgrepo-com.svg +9 -0
- package/public/assets/svg-lib/arrow-left-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/arrow-right-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/arrow-top-svgrepo-com.svg +9 -0
- package/public/assets/svg-lib/checkmark-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/clock-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/cross-svgrepo-com.svg +12 -0
- package/public/assets/svg-lib/download-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/edit-pen-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/favorite-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/forbiden-svgrepo-com.svg +9 -0
- package/public/assets/svg-lib/input-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/link-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/messages-alert-svgrepo-com.svg +6 -0
- package/public/assets/svg-lib/messages-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/mic-off-svgrepo-com.svg +6 -0
- package/public/assets/svg-lib/mic-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/music-svgrepo-com.svg +6 -0
- package/public/assets/svg-lib/next-long-arrow-right-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/notification-alert-svgrepo-com.svg +6 -0
- package/public/assets/svg-lib/notification-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/notifications-off-svgrepo-com.svg +6 -0
- package/public/assets/svg-lib/party-simple-colored-svgrepo-com.svg +11 -0
- package/public/assets/svg-lib/pattern-circles-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/play-button-simple-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/plus-outlined-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/previous-long-arrow-left-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/queue-listing-cards-svgrepo-com.svg +6 -0
- package/public/assets/svg-lib/queue-remove-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/recent-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/remove-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/repeat-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/schedule-add-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/schedule-alert-svgrepo-com.svg +6 -0
- package/public/assets/svg-lib/schedule-remove-svgrepo-com.svg +6 -0
- package/public/assets/svg-lib/schedule-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/search-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/session-abandon-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/session-join-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/session-leave-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/settings-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/share-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/sound-off-svgrepo-com.svg +6 -0
- package/public/assets/svg-lib/sound-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/spectacles-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/star-svgrepo-com.svg +5 -0
- package/public/assets/svg-lib/user-avatar-with-alert-svgrepo-com.svg +6 -0
- package/public/assets/svg-lib/user-banned-svgrepo-com.svg +6 -0
- package/public/assets/svg-lib/user-svgrepo-com.svg +5 -0
- package/public/assets/svglist.png +0 -0
- package/readme.md +9 -0
- package/src/components/Button/Button.stories.ts +64 -0
- package/src/components/Button/Button.tsx +99 -0
- package/src/components/Button/button.scss +147 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Container/Box.tsx +83 -0
- package/src/components/Container/box.scss +41 -0
- package/src/components/Container/index.ts +1 -0
- package/src/components/Input/Input.stories.ts +49 -0
- package/src/components/Input/Input.tsx +172 -0
- package/src/components/Input/index.ts +1 -0
- package/src/components/Input/input.scss +69 -0
- package/src/components/Modal/Modal.stories.ts +33 -0
- package/src/components/Modal/Modal.tsx +125 -0
- package/src/components/Modal/index.ts +1 -0
- package/src/components/Modal/modal.scss +54 -0
- package/src/components/Toggle/Toggle.stories.ts +35 -0
- package/src/components/Toggle/Toggle.tsx +60 -0
- package/src/components/Toggle/index.ts +1 -0
- package/src/components/Toggle/toggle.scss +97 -0
- package/src/components/index.ts +5 -0
- package/src/main.scss +46 -0
- package/tsconfig.json +15 -0
- package/utils/makeColors.ts +37 -0
- package/utils/notes.txt +11 -0
- package/utils/style_setter.js +19 -0
- 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
|
+
}
|