@true-engineering/true-react-common-ui-kit 3.40.0 → 3.41.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/README.md +9 -1
- package/dist/components/SmartInput/SmartInput.d.ts +8 -6
- package/dist/components/SmartInput/constants.d.ts +4 -6
- package/dist/components/SmartInput/helpers.d.ts +2 -4
- package/dist/components/SmartInput/types.d.ts +5 -0
- package/dist/true-react-common-ui-kit.js +1081 -940
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +1081 -940
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +98 -98
- package/src/components/MoreMenu/MoreMenu.tsx +93 -93
- package/src/components/SmartInput/SmartInput.stories.tsx +52 -51
- package/src/components/SmartInput/SmartInput.tsx +116 -134
- package/src/components/SmartInput/constants.ts +91 -84
- package/src/components/SmartInput/helpers.ts +26 -13
- package/src/components/SmartInput/types.ts +18 -11
- package/src/components/TextWithTooltip/TextWithTooltip.tsx +156 -156
- package/src/components/WithPopup/WithPopup.styles.ts +45 -45
- package/src/components/WithPopup/WithPopup.tsx +184 -184
- package/src/components/WithTooltip/WithTooltip.stories.tsx +56 -56
- package/src/components/WithTooltip/WithTooltip.styles.ts +7 -7
- package/src/components/WithTooltip/WithTooltip.tsx +67 -67
- package/src/components/WithTooltip/index.ts +2 -2
- package/src/components/index.ts +46 -46
- package/src/theme/types.ts +158 -158
package/package.json
CHANGED
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@true-engineering/true-react-common-ui-kit",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "True Engineering React UI Kit with theming support",
|
|
5
|
-
"author": "True Engineering (https://trueengineering.ru)",
|
|
6
|
-
"keywords": [
|
|
7
|
-
"TE",
|
|
8
|
-
"True Engineering",
|
|
9
|
-
"UI Kit with theming support",
|
|
10
|
-
"UI Kit"
|
|
11
|
-
],
|
|
12
|
-
"homepage": "",
|
|
13
|
-
"license": "Apache-2.0",
|
|
14
|
-
"type": "module",
|
|
15
|
-
"types": "dist/index.d.ts",
|
|
16
|
-
"main": "dist/true-react-common-ui-kit.umd.cjs",
|
|
17
|
-
"module": "./dist/true-react-common-ui-kit.js",
|
|
18
|
-
"directories": {
|
|
19
|
-
"lib": "src"
|
|
20
|
-
},
|
|
21
|
-
"publishConfig": {
|
|
22
|
-
"access": "public"
|
|
23
|
-
},
|
|
24
|
-
"files": [
|
|
25
|
-
"src",
|
|
26
|
-
"dist"
|
|
27
|
-
],
|
|
28
|
-
"exports": {
|
|
29
|
-
".": {
|
|
30
|
-
"require": "./dist/true-react-common-ui-kit.umd.cjs",
|
|
31
|
-
"import": "./dist/true-react-common-ui-kit.js"
|
|
32
|
-
},
|
|
33
|
-
"./dist/style.css": "./dist/style.css",
|
|
34
|
-
"./src": "./src/index.ts"
|
|
35
|
-
},
|
|
36
|
-
"scripts": {
|
|
37
|
-
"build": "tsc && vite build",
|
|
38
|
-
"lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
|
|
39
|
-
"format": "prettier --write \"**/*.{js,jsx,css,json,ts,tsx}\"",
|
|
40
|
-
"format:check": "prettier --check \"**/*.{js,jsx,css,json,ts,tsx}\"",
|
|
41
|
-
"full-check": "yarn format:check && yarn lint",
|
|
42
|
-
"types-check": "tsc --noEmit"
|
|
43
|
-
},
|
|
44
|
-
"dependencies": {
|
|
45
|
-
"@floating-ui/react": "0.26.12",
|
|
46
|
-
"@true-engineering/true-react-platform-helpers": "0.4.4",
|
|
47
|
-
"clsx": "1.2.1",
|
|
48
|
-
"country-flag-icons": "1.5.5",
|
|
49
|
-
"date-fns": "2.29.3",
|
|
50
|
-
"filesize": "10.1.1",
|
|
51
|
-
"hex-to-rgba": "2.0.1",
|
|
52
|
-
"jss": "10.10.0",
|
|
53
|
-
"lodash-es": "4.17.21",
|
|
54
|
-
"react": "18.2.0",
|
|
55
|
-
"react-datepicker": "4.25.0",
|
|
56
|
-
"react-dom": "18.2.0",
|
|
57
|
-
"react-input-mask": "3.0.0-alpha.2",
|
|
58
|
-
"react-jss": "10.10.0",
|
|
59
|
-
"react-overlays": "5.2.1",
|
|
60
|
-
"react-remove-scroll": "2.5.6",
|
|
61
|
-
"react-transition-group": "4.4.5",
|
|
62
|
-
"scroll-into-view-if-needed": "3.0.6",
|
|
63
|
-
"ts-debounce": "4.0.0"
|
|
64
|
-
},
|
|
65
|
-
"devDependencies": {
|
|
66
|
-
"@babel/core": "7.20.12",
|
|
67
|
-
"@storybook/addon-essentials": "7.6.17",
|
|
68
|
-
"@storybook/blocks": "7.6.17",
|
|
69
|
-
"@storybook/react": "7.6.17",
|
|
70
|
-
"@storybook/react-vite": "7.6.17",
|
|
71
|
-
"@storybook/test": "7.6.17",
|
|
72
|
-
"@swc/core": "^1.3.30",
|
|
73
|
-
"@trivago/prettier-plugin-sort-imports": "4.3.0",
|
|
74
|
-
"@types/lodash-es": "4.17.11",
|
|
75
|
-
"@types/react": "18.2.79",
|
|
76
|
-
"@types/react-datepicker": "4.19.4",
|
|
77
|
-
"@types/react-dom": "18.2.25",
|
|
78
|
-
"@types/react-input-mask": "3.0.2",
|
|
79
|
-
"@types/react-transition-group": "4.4.10",
|
|
80
|
-
"@typescript-eslint/eslint-plugin": "5.48.2",
|
|
81
|
-
"@typescript-eslint/parser": "5.48.2",
|
|
82
|
-
"@vitejs/plugin-react": "3.0.0",
|
|
83
|
-
"eslint": "8.36.0",
|
|
84
|
-
"eslint-config-prettier": "8.7.0",
|
|
85
|
-
"eslint-plugin-import": "2.29.0",
|
|
86
|
-
"eslint-plugin-react": "7.32.2",
|
|
87
|
-
"eslint-plugin-react-hooks": "4.6.0",
|
|
88
|
-
"prettier": "2.8.3",
|
|
89
|
-
"rollup-plugin-swc3": "0.3.0",
|
|
90
|
-
"typescript": "4.9.3",
|
|
91
|
-
"unplugin-swc": "1.3.2",
|
|
92
|
-
"vite": "4.0.0",
|
|
93
|
-
"vite-plugin-dts": "3.7.3"
|
|
94
|
-
},
|
|
95
|
-
"resolutions": {
|
|
96
|
-
"strip-ansi": "6.0.1"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@true-engineering/true-react-common-ui-kit",
|
|
3
|
+
"version": "3.41.0",
|
|
4
|
+
"description": "True Engineering React UI Kit with theming support",
|
|
5
|
+
"author": "True Engineering (https://trueengineering.ru)",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"TE",
|
|
8
|
+
"True Engineering",
|
|
9
|
+
"UI Kit with theming support",
|
|
10
|
+
"UI Kit"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "",
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"types": "dist/index.d.ts",
|
|
16
|
+
"main": "dist/true-react-common-ui-kit.umd.cjs",
|
|
17
|
+
"module": "./dist/true-react-common-ui-kit.js",
|
|
18
|
+
"directories": {
|
|
19
|
+
"lib": "src"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"src",
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"require": "./dist/true-react-common-ui-kit.umd.cjs",
|
|
31
|
+
"import": "./dist/true-react-common-ui-kit.js"
|
|
32
|
+
},
|
|
33
|
+
"./dist/style.css": "./dist/style.css",
|
|
34
|
+
"./src": "./src/index.ts"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc && vite build",
|
|
38
|
+
"lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
|
|
39
|
+
"format": "prettier --write \"**/*.{js,jsx,css,json,ts,tsx}\"",
|
|
40
|
+
"format:check": "prettier --check \"**/*.{js,jsx,css,json,ts,tsx}\"",
|
|
41
|
+
"full-check": "yarn format:check && yarn lint",
|
|
42
|
+
"types-check": "tsc --noEmit"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@floating-ui/react": "0.26.12",
|
|
46
|
+
"@true-engineering/true-react-platform-helpers": "0.4.4",
|
|
47
|
+
"clsx": "1.2.1",
|
|
48
|
+
"country-flag-icons": "1.5.5",
|
|
49
|
+
"date-fns": "2.29.3",
|
|
50
|
+
"filesize": "10.1.1",
|
|
51
|
+
"hex-to-rgba": "2.0.1",
|
|
52
|
+
"jss": "10.10.0",
|
|
53
|
+
"lodash-es": "4.17.21",
|
|
54
|
+
"react": "18.2.0",
|
|
55
|
+
"react-datepicker": "4.25.0",
|
|
56
|
+
"react-dom": "18.2.0",
|
|
57
|
+
"react-input-mask": "3.0.0-alpha.2",
|
|
58
|
+
"react-jss": "10.10.0",
|
|
59
|
+
"react-overlays": "5.2.1",
|
|
60
|
+
"react-remove-scroll": "2.5.6",
|
|
61
|
+
"react-transition-group": "4.4.5",
|
|
62
|
+
"scroll-into-view-if-needed": "3.0.6",
|
|
63
|
+
"ts-debounce": "4.0.0"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@babel/core": "7.20.12",
|
|
67
|
+
"@storybook/addon-essentials": "7.6.17",
|
|
68
|
+
"@storybook/blocks": "7.6.17",
|
|
69
|
+
"@storybook/react": "7.6.17",
|
|
70
|
+
"@storybook/react-vite": "7.6.17",
|
|
71
|
+
"@storybook/test": "7.6.17",
|
|
72
|
+
"@swc/core": "^1.3.30",
|
|
73
|
+
"@trivago/prettier-plugin-sort-imports": "4.3.0",
|
|
74
|
+
"@types/lodash-es": "4.17.11",
|
|
75
|
+
"@types/react": "18.2.79",
|
|
76
|
+
"@types/react-datepicker": "4.19.4",
|
|
77
|
+
"@types/react-dom": "18.2.25",
|
|
78
|
+
"@types/react-input-mask": "3.0.2",
|
|
79
|
+
"@types/react-transition-group": "4.4.10",
|
|
80
|
+
"@typescript-eslint/eslint-plugin": "5.48.2",
|
|
81
|
+
"@typescript-eslint/parser": "5.48.2",
|
|
82
|
+
"@vitejs/plugin-react": "3.0.0",
|
|
83
|
+
"eslint": "8.36.0",
|
|
84
|
+
"eslint-config-prettier": "8.7.0",
|
|
85
|
+
"eslint-plugin-import": "2.29.0",
|
|
86
|
+
"eslint-plugin-react": "7.32.2",
|
|
87
|
+
"eslint-plugin-react-hooks": "4.6.0",
|
|
88
|
+
"prettier": "2.8.3",
|
|
89
|
+
"rollup-plugin-swc3": "0.3.0",
|
|
90
|
+
"typescript": "4.9.3",
|
|
91
|
+
"unplugin-swc": "1.3.2",
|
|
92
|
+
"vite": "4.0.0",
|
|
93
|
+
"vite-plugin-dts": "3.7.3"
|
|
94
|
+
},
|
|
95
|
+
"resolutions": {
|
|
96
|
+
"strip-ansi": "6.0.1"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import { FC, MouseEvent, useRef, useState } from 'react';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import { addDataTestId, getTestId } from '@true-engineering/true-react-platform-helpers';
|
|
4
|
-
import { addDataAttributes } from '../../helpers';
|
|
5
|
-
import { useTweakStyles, useOnClickOutsideWithRef } from '../../hooks';
|
|
6
|
-
import { ICommonProps } from '../../types';
|
|
7
|
-
import { Icon } from '../Icon';
|
|
8
|
-
import { IListItem, List } from '../List';
|
|
9
|
-
import { useStyles, IMoreMenuStyles } from './MoreMenu.styles';
|
|
10
|
-
|
|
11
|
-
export interface IMoreMenuProps extends ICommonProps<IMoreMenuStyles> {
|
|
12
|
-
items: IListItem[];
|
|
13
|
-
/** @default false */
|
|
14
|
-
isDisabled?: boolean;
|
|
15
|
-
/** @default true */
|
|
16
|
-
hasDefaultStateBackground?: boolean;
|
|
17
|
-
onMenuOpen?: () => void;
|
|
18
|
-
onMenuClose?: () => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** @deprecated Используйте {@link import('../NewMoreMenu').NewMoreMenu NewMoreMenu} */
|
|
22
|
-
export const MoreMenu: FC<IMoreMenuProps> = ({
|
|
23
|
-
items,
|
|
24
|
-
isDisabled = false,
|
|
25
|
-
hasDefaultStateBackground = true,
|
|
26
|
-
data,
|
|
27
|
-
testId,
|
|
28
|
-
tweakStyles,
|
|
29
|
-
onMenuOpen,
|
|
30
|
-
onMenuClose,
|
|
31
|
-
}) => {
|
|
32
|
-
const classes = useStyles({ theme: tweakStyles });
|
|
33
|
-
|
|
34
|
-
const tweakListStyles = useTweakStyles({
|
|
35
|
-
tweakStyles,
|
|
36
|
-
className: 'tweakList',
|
|
37
|
-
currentComponentName: 'MoreMenu',
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const [isMenuShown, setIsMenuShown] = useState(false);
|
|
41
|
-
const list = useRef<HTMLDivElement>(null);
|
|
42
|
-
const button = useRef<HTMLButtonElement>(null);
|
|
43
|
-
|
|
44
|
-
const isButtonDisabled = isDisabled || items.length === 0;
|
|
45
|
-
|
|
46
|
-
const toggleMenu = (event: MouseEvent) => {
|
|
47
|
-
const isShown = !isMenuShown;
|
|
48
|
-
event.stopPropagation();
|
|
49
|
-
setIsMenuShown(isShown);
|
|
50
|
-
if (isShown) {
|
|
51
|
-
onMenuOpen?.();
|
|
52
|
-
} else {
|
|
53
|
-
onMenuClose?.();
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const handleCloseMenu = () => {
|
|
58
|
-
setIsMenuShown(false);
|
|
59
|
-
onMenuClose?.();
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
useOnClickOutsideWithRef(list, handleCloseMenu, button);
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<div className={classes.root}>
|
|
66
|
-
<button
|
|
67
|
-
ref={button}
|
|
68
|
-
className={clsx(classes.button, {
|
|
69
|
-
[classes.hasCircle]: hasDefaultStateBackground,
|
|
70
|
-
[classes.disabled]: isButtonDisabled,
|
|
71
|
-
[classes.active]: isMenuShown,
|
|
72
|
-
})}
|
|
73
|
-
onClick={!isButtonDisabled ? toggleMenu : undefined}
|
|
74
|
-
{...addDataTestId(testId)}
|
|
75
|
-
{...addDataAttributes(data)}
|
|
76
|
-
>
|
|
77
|
-
<div className={classes.icon}>
|
|
78
|
-
<Icon type="menu" />
|
|
79
|
-
</div>
|
|
80
|
-
</button>
|
|
81
|
-
{isMenuShown && !isButtonDisabled && (
|
|
82
|
-
<div className={classes.menu} ref={list}>
|
|
83
|
-
<List
|
|
84
|
-
items={items}
|
|
85
|
-
testId={getTestId(testId, 'list')}
|
|
86
|
-
tweakStyles={tweakListStyles}
|
|
87
|
-
onClick={handleCloseMenu}
|
|
88
|
-
/>
|
|
89
|
-
</div>
|
|
90
|
-
)}
|
|
91
|
-
</div>
|
|
92
|
-
);
|
|
93
|
-
};
|
|
1
|
+
import { FC, MouseEvent, useRef, useState } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { addDataTestId, getTestId } from '@true-engineering/true-react-platform-helpers';
|
|
4
|
+
import { addDataAttributes } from '../../helpers';
|
|
5
|
+
import { useTweakStyles, useOnClickOutsideWithRef } from '../../hooks';
|
|
6
|
+
import { ICommonProps } from '../../types';
|
|
7
|
+
import { Icon } from '../Icon';
|
|
8
|
+
import { IListItem, List } from '../List';
|
|
9
|
+
import { useStyles, IMoreMenuStyles } from './MoreMenu.styles';
|
|
10
|
+
|
|
11
|
+
export interface IMoreMenuProps extends ICommonProps<IMoreMenuStyles> {
|
|
12
|
+
items: IListItem[];
|
|
13
|
+
/** @default false */
|
|
14
|
+
isDisabled?: boolean;
|
|
15
|
+
/** @default true */
|
|
16
|
+
hasDefaultStateBackground?: boolean;
|
|
17
|
+
onMenuOpen?: () => void;
|
|
18
|
+
onMenuClose?: () => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** @deprecated Используйте {@link import('../NewMoreMenu').NewMoreMenu NewMoreMenu} */
|
|
22
|
+
export const MoreMenu: FC<IMoreMenuProps> = ({
|
|
23
|
+
items,
|
|
24
|
+
isDisabled = false,
|
|
25
|
+
hasDefaultStateBackground = true,
|
|
26
|
+
data,
|
|
27
|
+
testId,
|
|
28
|
+
tweakStyles,
|
|
29
|
+
onMenuOpen,
|
|
30
|
+
onMenuClose,
|
|
31
|
+
}) => {
|
|
32
|
+
const classes = useStyles({ theme: tweakStyles });
|
|
33
|
+
|
|
34
|
+
const tweakListStyles = useTweakStyles({
|
|
35
|
+
tweakStyles,
|
|
36
|
+
className: 'tweakList',
|
|
37
|
+
currentComponentName: 'MoreMenu',
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const [isMenuShown, setIsMenuShown] = useState(false);
|
|
41
|
+
const list = useRef<HTMLDivElement>(null);
|
|
42
|
+
const button = useRef<HTMLButtonElement>(null);
|
|
43
|
+
|
|
44
|
+
const isButtonDisabled = isDisabled || items.length === 0;
|
|
45
|
+
|
|
46
|
+
const toggleMenu = (event: MouseEvent) => {
|
|
47
|
+
const isShown = !isMenuShown;
|
|
48
|
+
event.stopPropagation();
|
|
49
|
+
setIsMenuShown(isShown);
|
|
50
|
+
if (isShown) {
|
|
51
|
+
onMenuOpen?.();
|
|
52
|
+
} else {
|
|
53
|
+
onMenuClose?.();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const handleCloseMenu = () => {
|
|
58
|
+
setIsMenuShown(false);
|
|
59
|
+
onMenuClose?.();
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
useOnClickOutsideWithRef(list, handleCloseMenu, button);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div className={classes.root}>
|
|
66
|
+
<button
|
|
67
|
+
ref={button}
|
|
68
|
+
className={clsx(classes.button, {
|
|
69
|
+
[classes.hasCircle]: hasDefaultStateBackground,
|
|
70
|
+
[classes.disabled]: isButtonDisabled,
|
|
71
|
+
[classes.active]: isMenuShown,
|
|
72
|
+
})}
|
|
73
|
+
onClick={!isButtonDisabled ? toggleMenu : undefined}
|
|
74
|
+
{...addDataTestId(testId)}
|
|
75
|
+
{...addDataAttributes(data)}
|
|
76
|
+
>
|
|
77
|
+
<div className={classes.icon}>
|
|
78
|
+
<Icon type="menu" />
|
|
79
|
+
</div>
|
|
80
|
+
</button>
|
|
81
|
+
{isMenuShown && !isButtonDisabled && (
|
|
82
|
+
<div className={classes.menu} ref={list}>
|
|
83
|
+
<List
|
|
84
|
+
items={items}
|
|
85
|
+
testId={getTestId(testId, 'list')}
|
|
86
|
+
tweakStyles={tweakListStyles}
|
|
87
|
+
onClick={handleCloseMenu}
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
@@ -1,51 +1,52 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { ComponentStory } from '@storybook/react';
|
|
3
|
-
import { IInputProps } from '../Input';
|
|
4
|
-
import { SmartInput } from './SmartInput';
|
|
5
|
-
import { ISmartType } from './types';
|
|
6
|
-
|
|
7
|
-
const types: Array<IInputProps['type']> = ['text', 'password', 'email', 'number'];
|
|
8
|
-
const smartTypes: ISmartType[] = ['default', 'agencyName', 'surname', 'name', 'email'];
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
title: 'Inputs/SmartInput',
|
|
12
|
-
component: SmartInput,
|
|
13
|
-
argTypes: {
|
|
14
|
-
type: { control: 'inline-radio', options: types },
|
|
15
|
-
smartType: { control: 'inline-radio', options: smartTypes },
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const Template: ComponentStory<typeof SmartInput> = (args) => {
|
|
20
|
-
const [value, setValue] = useState('');
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div>
|
|
24
|
-
<div>Фичи умного инпута:</div>
|
|
25
|
-
<ul>
|
|
26
|
-
<li>Переключение раскладки при вводе</li>
|
|
27
|
-
<li>Транслитерация при копировании текста на русском</li>
|
|
28
|
-
<li>
|
|
29
|
-
Запрет ввода определённых символов для разных видов полей, например, только буквы, пробелы
|
|
30
|
-
и дефис для фамилий и т.д.
|
|
31
|
-
</li>
|
|
32
|
-
<li>Фильтрация скопированного значения на предмет запрещённых символов</li>
|
|
33
|
-
<li>Трансформация значения в UPPERCASE</li>
|
|
34
|
-
</ul>
|
|
35
|
-
|
|
36
|
-
<SmartInput {...args} value={value} onChange={
|
|
37
|
-
</div>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const Default = Template.bind({});
|
|
42
|
-
|
|
43
|
-
Default.args = {
|
|
44
|
-
label: 'Label',
|
|
45
|
-
placeholder: 'Placeholder',
|
|
46
|
-
type: 'text',
|
|
47
|
-
smartType: 'default',
|
|
48
|
-
isUpperCase: false,
|
|
49
|
-
isDisabled: false,
|
|
50
|
-
|
|
51
|
-
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { ComponentStory } from '@storybook/react';
|
|
3
|
+
import { IInputProps } from '../Input';
|
|
4
|
+
import { SmartInput } from './SmartInput';
|
|
5
|
+
import { ISmartType } from './types';
|
|
6
|
+
|
|
7
|
+
const types: Array<IInputProps['type']> = ['text', 'password', 'email', 'number'];
|
|
8
|
+
const smartTypes: ISmartType[] = ['default', 'agencyName', 'surname', 'name', 'email'];
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
title: 'Inputs/SmartInput',
|
|
12
|
+
component: SmartInput,
|
|
13
|
+
argTypes: {
|
|
14
|
+
type: { control: 'inline-radio', options: types },
|
|
15
|
+
smartType: { control: 'inline-radio', options: smartTypes },
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const Template: ComponentStory<typeof SmartInput> = (args) => {
|
|
20
|
+
const [value, setValue] = useState('');
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div>
|
|
24
|
+
<div>Фичи умного инпута:</div>
|
|
25
|
+
<ul>
|
|
26
|
+
<li>Переключение раскладки при вводе</li>
|
|
27
|
+
<li>Транслитерация при копировании текста на русском</li>
|
|
28
|
+
<li>
|
|
29
|
+
Запрет ввода определённых символов для разных видов полей, например, только буквы, пробелы
|
|
30
|
+
и дефис для фамилий и т.д.
|
|
31
|
+
</li>
|
|
32
|
+
<li>Фильтрация скопированного значения на предмет запрещённых символов</li>
|
|
33
|
+
<li>Трансформация значения в UPPERCASE</li>
|
|
34
|
+
</ul>
|
|
35
|
+
|
|
36
|
+
<SmartInput {...args} value={value} onChange={setValue} />
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Default = Template.bind({});
|
|
42
|
+
|
|
43
|
+
Default.args = {
|
|
44
|
+
label: 'Label',
|
|
45
|
+
placeholder: 'Placeholder',
|
|
46
|
+
type: 'text',
|
|
47
|
+
smartType: 'default',
|
|
48
|
+
isUpperCase: false,
|
|
49
|
+
isDisabled: false,
|
|
50
|
+
isTransliterationEnabled: true,
|
|
51
|
+
hasFloatingLabel: true,
|
|
52
|
+
};
|