@true-engineering/true-react-common-ui-kit 3.0.0-alpha.11 → 3.0.0-alpha.13
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/LICENSE +201 -201
- package/dist/components/Flag/augment.d.ts +1 -1
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.d.ts +1 -1
- package/dist/components/Icon/complexIcons/augment.d.ts +1 -1
- package/dist/true-react-common-ui-kit.js +67 -61
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +67 -61
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/dist/vite-env.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/AddButton/AddButton.stories.tsx +21 -21
- package/src/components/Colors/Colors.stories.tsx +7 -7
- package/src/components/DateInput/constants.ts +2 -2
- package/src/components/Flag/augment.d.ts +1 -1
- package/src/components/FlexibleTable/FlexibleTable.tsx +4 -3
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.ts +4 -0
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +7 -6
- package/src/components/Icon/complexIcons/augment.d.ts +1 -1
- package/src/components/Icon/complexIcons/avatarGreen.svg +57 -57
- package/src/components/Icon/complexIcons/index.ts +1 -1
- package/src/components/MoreMenu/MoreMenu.stories.tsx +46 -46
- package/src/components/NumberInput/index.ts +1 -1
- package/src/components/PhoneInput/types.ts +16 -16
- package/src/components/ScrollIntoViewIfNeeded/index.ts +1 -1
- package/src/components/Select/constants.ts +2 -2
- package/src/components/Select/types.ts +1 -1
- package/src/components/TextWithTooltip/TextWithTooltip.stories.tsx +58 -58
- package/src/components/ThemedPreloader/components/DefaultPreloader/index.ts +1 -1
- package/src/components/Tooltip/types.ts +1 -1
- package/src/helpers/popper-helpers.ts +17 -17
- package/src/hooks/use-is-mounted.ts +15 -15
- package/src/vite-env.d.ts +1 -1
package/dist/vite-env.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
1
|
+
/// <reference types="vite/client" />
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { ComponentStory } from '@storybook/react';
|
|
2
|
-
import { AddButton } from './AddButton';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
title: 'AddButton',
|
|
6
|
-
component: AddButton,
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const Template: ComponentStory<typeof AddButton> = (args) => (
|
|
10
|
-
<AddButton {...args} onClick={console.log} />
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
export const Default = Template.bind({});
|
|
14
|
-
|
|
15
|
-
Default.args = {
|
|
16
|
-
text: 'Добавить билет',
|
|
17
|
-
isDisabled: false,
|
|
18
|
-
isFullWidth: false,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
Default.parameters = { controls: { exclude: ['onClick'] } };
|
|
1
|
+
import { ComponentStory } from '@storybook/react';
|
|
2
|
+
import { AddButton } from './AddButton';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'AddButton',
|
|
6
|
+
component: AddButton,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const Template: ComponentStory<typeof AddButton> = (args) => (
|
|
10
|
+
<AddButton {...args} onClick={console.log} />
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export const Default = Template.bind({});
|
|
14
|
+
|
|
15
|
+
Default.args = {
|
|
16
|
+
text: 'Добавить билет',
|
|
17
|
+
isDisabled: false,
|
|
18
|
+
isFullWidth: false,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
Default.parameters = { controls: { exclude: ['onClick'] } };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Colors } from './Colors';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'Colors',
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const Default = (): JSX.Element => <Colors />;
|
|
1
|
+
import { Colors } from './Colors';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Colors',
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const Default = (): JSX.Element => <Colors />;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const EMPTY_DATE_INPUT_VALUE = '__.__.____';
|
|
2
|
-
export const EMPTY_DATE_RANGE_INPUT_VALUE = `${EMPTY_DATE_INPUT_VALUE} - ${EMPTY_DATE_INPUT_VALUE}`;
|
|
1
|
+
export const EMPTY_DATE_INPUT_VALUE = '__.__.____';
|
|
2
|
+
export const EMPTY_DATE_RANGE_INPUT_VALUE = `${EMPTY_DATE_INPUT_VALUE} - ${EMPTY_DATE_INPUT_VALUE}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
declare module 'country-flag-icons/react/3x2';
|
|
1
|
+
declare module 'country-flag-icons/react/3x2';
|
|
@@ -65,6 +65,7 @@ export function FlexibleTable<Values extends Record<string, any>>({
|
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
const [isHorizontallyScrolled, setIsHorizontallyScrolled] = useState(false);
|
|
68
|
+
const [hasScrollBar, setHasScrollBar] = useState(false);
|
|
68
69
|
|
|
69
70
|
const observer = useRef<IntersectionObserver>();
|
|
70
71
|
const scrollRef = useRef<HTMLDivElement>(null);
|
|
@@ -107,12 +108,13 @@ export function FlexibleTable<Values extends Record<string, any>>({
|
|
|
107
108
|
if (scrollContainer === null || !isHorizontallyScrollable || !isFirstColumnSticky) {
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
111
|
+
setHasScrollBar(hasHorizontalScrollBar(scrollContainer));
|
|
110
112
|
const scrollHandler = (e: Event) => {
|
|
111
113
|
setIsHorizontallyScrolled((e.target as HTMLDivElement).scrollLeft > 0);
|
|
112
114
|
};
|
|
113
115
|
scrollContainer.addEventListener('scroll', scrollHandler);
|
|
114
116
|
return () => scrollContainer.removeEventListener('scroll', scrollHandler);
|
|
115
|
-
}, [
|
|
117
|
+
}, [ref]);
|
|
116
118
|
|
|
117
119
|
return (
|
|
118
120
|
<div
|
|
@@ -120,8 +122,7 @@ export function FlexibleTable<Values extends Record<string, any>>({
|
|
|
120
122
|
className={clsx({ [classes.scroll]: isHorizontallyScrollable })}
|
|
121
123
|
{...addDataAttributes({
|
|
122
124
|
scrolled: isHorizontallyScrolled ? true : undefined,
|
|
123
|
-
scrollable:
|
|
124
|
-
isHorizontallyScrollable && hasHorizontalScrollBar(ref.current) ? true : undefined,
|
|
125
|
+
scrollable: isHorizontallyScrollable && hasScrollBar ? true : undefined,
|
|
125
126
|
})}
|
|
126
127
|
>
|
|
127
128
|
<table className={classes.root} {...addDataTestId(testId)} {...addDataAttributes(data)}>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactNode, useState, memo } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
+
import { isNotEmpty } from '@true-engineering/true-react-platform-helpers';
|
|
3
4
|
import { addDataAttributes } from '../../../../helpers';
|
|
4
5
|
import { useTweakStyles } from '../../../../hooks';
|
|
5
6
|
import { ICommonProps, IDataAttributes } from '../../../../types';
|
|
@@ -81,7 +82,7 @@ function FlexibleTableRowInner<Values extends Record<string, any>>({
|
|
|
81
82
|
onRowClick?.(item[uniqueField]);
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
if (expandableRowComponent
|
|
85
|
+
if (isNotEmpty(expandableRowComponent)) {
|
|
85
86
|
const newNestedComponent = expandableRowComponent(item, true, closeNestedComponent);
|
|
86
87
|
|
|
87
88
|
if (!nestedComponent.isOpen && newNestedComponent !== null) {
|
|
@@ -101,11 +102,11 @@ function FlexibleTableRowInner<Values extends Record<string, any>>({
|
|
|
101
102
|
return (
|
|
102
103
|
<>
|
|
103
104
|
<tr
|
|
104
|
-
className={clsx(
|
|
105
|
-
classes.
|
|
106
|
-
|
|
107
|
-
(onRowClick
|
|
108
|
-
)}
|
|
105
|
+
className={clsx(classes.root, {
|
|
106
|
+
[classes.active]: isActive,
|
|
107
|
+
[classes.editable]: isNotEmpty(onRowClick) || isNotEmpty(onRowHover),
|
|
108
|
+
[classes.clickable]: isNotEmpty(onRowClick) || isNotEmpty(expandableRowComponent),
|
|
109
|
+
})}
|
|
109
110
|
onMouseEnter={(e) => {
|
|
110
111
|
if (uniqueField !== undefined && onRowHover !== undefined) {
|
|
111
112
|
e.stopPropagation();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
declare module '*.svg?raw';
|
|
1
|
+
declare module '*.svg?raw';
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
<svg
|
|
2
|
-
width="100%"
|
|
3
|
-
height="100%"
|
|
4
|
-
viewBox="0 0 32 32"
|
|
5
|
-
fill="none"
|
|
6
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
-
>
|
|
8
|
-
<circle opacity="0.5" cx="16" cy="16" r="16" fill="#DDE3ED" />
|
|
9
|
-
<mask
|
|
10
|
-
id="mask0_0_12744"
|
|
11
|
-
style="mask-type: 'alpha';"
|
|
12
|
-
maskUnits="userSpaceOnUse"
|
|
13
|
-
x="0"
|
|
14
|
-
y="0"
|
|
15
|
-
width="32"
|
|
16
|
-
height="32"
|
|
17
|
-
>
|
|
18
|
-
<circle cx="16" cy="16" r="16" fill="white" />
|
|
19
|
-
</mask>
|
|
20
|
-
<g mask="url(#mask0_0_12744)">
|
|
21
|
-
<circle cx="16" cy="29" r="13" fill="url(#paint0_linear_0_12744)" />
|
|
22
|
-
<mask
|
|
23
|
-
id="mask1_0_12744"
|
|
24
|
-
style="mask-type: 'alpha';"
|
|
25
|
-
maskUnits="userSpaceOnUse"
|
|
26
|
-
x="3"
|
|
27
|
-
y="16"
|
|
28
|
-
width="26"
|
|
29
|
-
height="26"
|
|
30
|
-
>
|
|
31
|
-
<circle cx="16" cy="29" r="13" fill="white" />
|
|
32
|
-
</mask>
|
|
33
|
-
<g mask="url(#mask1_0_12744)">
|
|
34
|
-
<ellipse
|
|
35
|
-
cx="16"
|
|
36
|
-
cy="17.5"
|
|
37
|
-
rx="6"
|
|
38
|
-
ry="7.5"
|
|
39
|
-
fill="#505F79"
|
|
40
|
-
fill-opacity="0.204983"
|
|
41
|
-
/>
|
|
42
|
-
</g>
|
|
43
|
-
</g>
|
|
44
|
-
<ellipse cx="16" cy="13" rx="6" ry="7" fill="white" />
|
|
45
|
-
<defs>
|
|
46
|
-
<linearGradient
|
|
47
|
-
id="paint0_linear_0_12744"
|
|
48
|
-
x1="13.347"
|
|
49
|
-
y1="46.279"
|
|
50
|
-
x2="33.5318"
|
|
51
|
-
y2="30.8088"
|
|
52
|
-
gradientUnits="userSpaceOnUse"
|
|
53
|
-
>
|
|
54
|
-
<stop stop-color="#ABD229" />
|
|
55
|
-
<stop offset="1" stop-color="#9CD03F" />
|
|
56
|
-
</linearGradient>
|
|
57
|
-
</defs>
|
|
1
|
+
<svg
|
|
2
|
+
width="100%"
|
|
3
|
+
height="100%"
|
|
4
|
+
viewBox="0 0 32 32"
|
|
5
|
+
fill="none"
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
>
|
|
8
|
+
<circle opacity="0.5" cx="16" cy="16" r="16" fill="#DDE3ED" />
|
|
9
|
+
<mask
|
|
10
|
+
id="mask0_0_12744"
|
|
11
|
+
style="mask-type: 'alpha';"
|
|
12
|
+
maskUnits="userSpaceOnUse"
|
|
13
|
+
x="0"
|
|
14
|
+
y="0"
|
|
15
|
+
width="32"
|
|
16
|
+
height="32"
|
|
17
|
+
>
|
|
18
|
+
<circle cx="16" cy="16" r="16" fill="white" />
|
|
19
|
+
</mask>
|
|
20
|
+
<g mask="url(#mask0_0_12744)">
|
|
21
|
+
<circle cx="16" cy="29" r="13" fill="url(#paint0_linear_0_12744)" />
|
|
22
|
+
<mask
|
|
23
|
+
id="mask1_0_12744"
|
|
24
|
+
style="mask-type: 'alpha';"
|
|
25
|
+
maskUnits="userSpaceOnUse"
|
|
26
|
+
x="3"
|
|
27
|
+
y="16"
|
|
28
|
+
width="26"
|
|
29
|
+
height="26"
|
|
30
|
+
>
|
|
31
|
+
<circle cx="16" cy="29" r="13" fill="white" />
|
|
32
|
+
</mask>
|
|
33
|
+
<g mask="url(#mask1_0_12744)">
|
|
34
|
+
<ellipse
|
|
35
|
+
cx="16"
|
|
36
|
+
cy="17.5"
|
|
37
|
+
rx="6"
|
|
38
|
+
ry="7.5"
|
|
39
|
+
fill="#505F79"
|
|
40
|
+
fill-opacity="0.204983"
|
|
41
|
+
/>
|
|
42
|
+
</g>
|
|
43
|
+
</g>
|
|
44
|
+
<ellipse cx="16" cy="13" rx="6" ry="7" fill="white" />
|
|
45
|
+
<defs>
|
|
46
|
+
<linearGradient
|
|
47
|
+
id="paint0_linear_0_12744"
|
|
48
|
+
x1="13.347"
|
|
49
|
+
y1="46.279"
|
|
50
|
+
x2="33.5318"
|
|
51
|
+
y2="30.8088"
|
|
52
|
+
gradientUnits="userSpaceOnUse"
|
|
53
|
+
>
|
|
54
|
+
<stop stop-color="#ABD229" />
|
|
55
|
+
<stop offset="1" stop-color="#9CD03F" />
|
|
56
|
+
</linearGradient>
|
|
57
|
+
</defs>
|
|
58
58
|
</svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './icons';
|
|
1
|
+
export * from './icons';
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { ComponentStory } from '@storybook/react';
|
|
2
|
-
import { colors } from '../../theme';
|
|
3
|
-
import { MoreMenu } from './MoreMenu';
|
|
4
|
-
|
|
5
|
-
const menuItems = [
|
|
6
|
-
{ item: 'Печатать билет', onClick: console.log },
|
|
7
|
-
{ item: 'Выписать', onClick: console.log },
|
|
8
|
-
{ item: 'Аннулировать', onClick: console.log, shouldDrawSpacerBelow: true },
|
|
9
|
-
{
|
|
10
|
-
item: (() => <div style={{ color: colors.RED_ACTIVE }}>Удалить</div>)(),
|
|
11
|
-
onClick: console.log,
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
item: (() => <div style={{ color: colors.RED_ACTIVE }}>Удалить</div>)(),
|
|
15
|
-
onClick: console.log,
|
|
16
|
-
},
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
export default {
|
|
20
|
-
title: 'MoreMenu',
|
|
21
|
-
component: MoreMenu,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const Template: ComponentStory<typeof MoreMenu> = (args) => (
|
|
25
|
-
<div
|
|
26
|
-
style={{
|
|
27
|
-
display: 'flex',
|
|
28
|
-
alignItems: 'center',
|
|
29
|
-
justifyContent: 'center',
|
|
30
|
-
width: 600,
|
|
31
|
-
height: 400,
|
|
32
|
-
}}
|
|
33
|
-
>
|
|
34
|
-
<div style={{ display: 'flex', gap: 10, alignItems: 'center' }}>
|
|
35
|
-
<div style={{ flexShrink: 0 }}>Test subject</div>
|
|
36
|
-
<MoreMenu {...args} items={menuItems} />
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
export const Default = Template.bind({});
|
|
42
|
-
|
|
43
|
-
Default.args = {
|
|
44
|
-
isDisabled: false,
|
|
45
|
-
hasDefaultStateBackground: true,
|
|
46
|
-
};
|
|
1
|
+
import { ComponentStory } from '@storybook/react';
|
|
2
|
+
import { colors } from '../../theme';
|
|
3
|
+
import { MoreMenu } from './MoreMenu';
|
|
4
|
+
|
|
5
|
+
const menuItems = [
|
|
6
|
+
{ item: 'Печатать билет', onClick: console.log },
|
|
7
|
+
{ item: 'Выписать', onClick: console.log },
|
|
8
|
+
{ item: 'Аннулировать', onClick: console.log, shouldDrawSpacerBelow: true },
|
|
9
|
+
{
|
|
10
|
+
item: (() => <div style={{ color: colors.RED_ACTIVE }}>Удалить</div>)(),
|
|
11
|
+
onClick: console.log,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
item: (() => <div style={{ color: colors.RED_ACTIVE }}>Удалить</div>)(),
|
|
15
|
+
onClick: console.log,
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
title: 'MoreMenu',
|
|
21
|
+
component: MoreMenu,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const Template: ComponentStory<typeof MoreMenu> = (args) => (
|
|
25
|
+
<div
|
|
26
|
+
style={{
|
|
27
|
+
display: 'flex',
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
justifyContent: 'center',
|
|
30
|
+
width: 600,
|
|
31
|
+
height: 400,
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
<div style={{ display: 'flex', gap: 10, alignItems: 'center' }}>
|
|
35
|
+
<div style={{ flexShrink: 0 }}>Test subject</div>
|
|
36
|
+
<MoreMenu {...args} items={menuItems} />
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export const Default = Template.bind({});
|
|
42
|
+
|
|
43
|
+
Default.args = {
|
|
44
|
+
isDisabled: false,
|
|
45
|
+
hasDefaultStateBackground: true,
|
|
46
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './NumberInput';
|
|
1
|
+
export * from './NumberInput';
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export interface IPhoneInfo {
|
|
2
|
-
countryEn: string;
|
|
3
|
-
countryRu: string;
|
|
4
|
-
countryCode: string;
|
|
5
|
-
dialCode: string;
|
|
6
|
-
phoneMask?: string;
|
|
7
|
-
dialCodePriority?: number;
|
|
8
|
-
areaCodes?: string[];
|
|
9
|
-
fullCodes: string[];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface IPhoneValue {
|
|
13
|
-
phoneNumber?: string;
|
|
14
|
-
dialCode?: string;
|
|
15
|
-
countryCode?: string;
|
|
16
|
-
}
|
|
1
|
+
export interface IPhoneInfo {
|
|
2
|
+
countryEn: string;
|
|
3
|
+
countryRu: string;
|
|
4
|
+
countryCode: string;
|
|
5
|
+
dialCode: string;
|
|
6
|
+
phoneMask?: string;
|
|
7
|
+
dialCodePriority?: number;
|
|
8
|
+
areaCodes?: string[];
|
|
9
|
+
fullCodes: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IPhoneValue {
|
|
13
|
+
phoneNumber?: string;
|
|
14
|
+
dialCode?: string;
|
|
15
|
+
countryCode?: string;
|
|
16
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './ScrollIntoViewIfNeeded';
|
|
1
|
+
export * from './ScrollIntoViewIfNeeded';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const DEFAULT_OPTION_INDEX = -2;
|
|
2
|
-
export const ALL_OPTION_INDEX = -1;
|
|
1
|
+
export const DEFAULT_OPTION_INDEX = -2;
|
|
2
|
+
export const ALL_OPTION_INDEX = -1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type IMultipleSelectValue<Value> = Array<NonNullable<Value>>;
|
|
1
|
+
export type IMultipleSelectValue<Value> = Array<NonNullable<Value>>;
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { ComponentStory } from '@storybook/react';
|
|
2
|
-
import { TextWithTooltip } from './TextWithTooltip';
|
|
3
|
-
|
|
4
|
-
const positions = [
|
|
5
|
-
'top',
|
|
6
|
-
'bottom',
|
|
7
|
-
'right',
|
|
8
|
-
'left',
|
|
9
|
-
'top-start',
|
|
10
|
-
'top-end',
|
|
11
|
-
'bottom-start',
|
|
12
|
-
'bottom-end',
|
|
13
|
-
'right-start',
|
|
14
|
-
'right-end',
|
|
15
|
-
'left-start',
|
|
16
|
-
'left-end',
|
|
17
|
-
'auto',
|
|
18
|
-
'auto-start',
|
|
19
|
-
'auto-end',
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
export default {
|
|
23
|
-
title: 'TextWithTooltip',
|
|
24
|
-
component: TextWithTooltip,
|
|
25
|
-
argTypes: {
|
|
26
|
-
tooltipPosition: { control: 'select', options: positions },
|
|
27
|
-
tooltipView: { control: 'inline-radio', options: ['tooltip', 'hint'] },
|
|
28
|
-
tooltipType: { control: 'inline-radio', options: ['info', 'error'] },
|
|
29
|
-
mouseEventType: { control: 'inline-radio', options: ['hover', 'click'] },
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const Template: ComponentStory<typeof TextWithTooltip> = (args) => (
|
|
34
|
-
<div
|
|
35
|
-
style={{
|
|
36
|
-
display: 'flex',
|
|
37
|
-
alignItems: 'center',
|
|
38
|
-
justifyContent: 'center',
|
|
39
|
-
width: 600,
|
|
40
|
-
height: 400,
|
|
41
|
-
}}
|
|
42
|
-
>
|
|
43
|
-
<TextWithTooltip {...args} />
|
|
44
|
-
</div>
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
export const Default = Template.bind({});
|
|
48
|
-
|
|
49
|
-
Default.args = {
|
|
50
|
-
children: 'Наведи на меня - появится тултип',
|
|
51
|
-
tooltipText: 'Текст тултипа',
|
|
52
|
-
tooltipPosition: 'top',
|
|
53
|
-
tooltipView: 'tooltip',
|
|
54
|
-
tooltipType: 'info',
|
|
55
|
-
isDisabled: false,
|
|
56
|
-
mouseEventType: 'hover',
|
|
57
|
-
shouldRenderInBody: true,
|
|
58
|
-
};
|
|
1
|
+
import { ComponentStory } from '@storybook/react';
|
|
2
|
+
import { TextWithTooltip } from './TextWithTooltip';
|
|
3
|
+
|
|
4
|
+
const positions = [
|
|
5
|
+
'top',
|
|
6
|
+
'bottom',
|
|
7
|
+
'right',
|
|
8
|
+
'left',
|
|
9
|
+
'top-start',
|
|
10
|
+
'top-end',
|
|
11
|
+
'bottom-start',
|
|
12
|
+
'bottom-end',
|
|
13
|
+
'right-start',
|
|
14
|
+
'right-end',
|
|
15
|
+
'left-start',
|
|
16
|
+
'left-end',
|
|
17
|
+
'auto',
|
|
18
|
+
'auto-start',
|
|
19
|
+
'auto-end',
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
title: 'TextWithTooltip',
|
|
24
|
+
component: TextWithTooltip,
|
|
25
|
+
argTypes: {
|
|
26
|
+
tooltipPosition: { control: 'select', options: positions },
|
|
27
|
+
tooltipView: { control: 'inline-radio', options: ['tooltip', 'hint'] },
|
|
28
|
+
tooltipType: { control: 'inline-radio', options: ['info', 'error'] },
|
|
29
|
+
mouseEventType: { control: 'inline-radio', options: ['hover', 'click'] },
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const Template: ComponentStory<typeof TextWithTooltip> = (args) => (
|
|
34
|
+
<div
|
|
35
|
+
style={{
|
|
36
|
+
display: 'flex',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
justifyContent: 'center',
|
|
39
|
+
width: 600,
|
|
40
|
+
height: 400,
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<TextWithTooltip {...args} />
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export const Default = Template.bind({});
|
|
48
|
+
|
|
49
|
+
Default.args = {
|
|
50
|
+
children: 'Наведи на меня - появится тултип',
|
|
51
|
+
tooltipText: 'Текст тултипа',
|
|
52
|
+
tooltipPosition: 'top',
|
|
53
|
+
tooltipView: 'tooltip',
|
|
54
|
+
tooltipType: 'info',
|
|
55
|
+
isDisabled: false,
|
|
56
|
+
mouseEventType: 'hover',
|
|
57
|
+
shouldRenderInBody: true,
|
|
58
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './DefaultPreloader';
|
|
1
|
+
export * from './DefaultPreloader';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type ITooltipType = 'info' | 'warning';
|
|
1
|
+
export type ITooltipType = 'info' | 'warning';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Modifier } from 'react-overlays/usePopper';
|
|
2
|
-
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
-
export const minWidthModifier: Partial<Modifier<any, any>> = {
|
|
5
|
-
name: 'minWidth',
|
|
6
|
-
enabled: true,
|
|
7
|
-
phase: 'beforeWrite',
|
|
8
|
-
requires: ['computeStyles'],
|
|
9
|
-
fn: ({ state }) => {
|
|
10
|
-
state.styles.popper.minWidth = `${state.rects.reference.width}px`;
|
|
11
|
-
},
|
|
12
|
-
effect: ({ state }) => {
|
|
13
|
-
state.elements.popper.style.minWidth = `${
|
|
14
|
-
(state.elements.reference as HTMLElement).offsetWidth
|
|
15
|
-
}px`;
|
|
16
|
-
},
|
|
17
|
-
};
|
|
1
|
+
import { Modifier } from 'react-overlays/usePopper';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
+
export const minWidthModifier: Partial<Modifier<any, any>> = {
|
|
5
|
+
name: 'minWidth',
|
|
6
|
+
enabled: true,
|
|
7
|
+
phase: 'beforeWrite',
|
|
8
|
+
requires: ['computeStyles'],
|
|
9
|
+
fn: ({ state }) => {
|
|
10
|
+
state.styles.popper.minWidth = `${state.rects.reference.width}px`;
|
|
11
|
+
},
|
|
12
|
+
effect: ({ state }) => {
|
|
13
|
+
state.elements.popper.style.minWidth = `${
|
|
14
|
+
(state.elements.reference as HTMLElement).offsetWidth
|
|
15
|
+
}px`;
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
export const useIsMounted = (): (() => boolean) => {
|
|
4
|
-
const isMounted = useRef(false);
|
|
5
|
-
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
isMounted.current = true;
|
|
8
|
-
|
|
9
|
-
return () => {
|
|
10
|
-
isMounted.current = false;
|
|
11
|
-
};
|
|
12
|
-
}, []);
|
|
13
|
-
|
|
14
|
-
return useCallback(() => isMounted.current, []);
|
|
15
|
-
};
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
export const useIsMounted = (): (() => boolean) => {
|
|
4
|
+
const isMounted = useRef(false);
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
isMounted.current = true;
|
|
8
|
+
|
|
9
|
+
return () => {
|
|
10
|
+
isMounted.current = false;
|
|
11
|
+
};
|
|
12
|
+
}, []);
|
|
13
|
+
|
|
14
|
+
return useCallback(() => isMounted.current, []);
|
|
15
|
+
};
|
package/src/vite-env.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
1
|
+
/// <reference types="vite/client" />
|