@true-engineering/true-react-common-ui-kit 4.0.0-alpha54 → 4.0.0-alpha61
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 +1 -0
- package/dist/components/AddButton/AddButton.d.ts +1 -0
- package/dist/components/AddButton/AddButton.styles.d.ts +1 -1
- package/dist/components/Button/Button.styles.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.styles.d.ts +1 -1
- package/dist/components/ControlWrapper/ControlWrapper.d.ts +1 -1
- package/dist/components/ControlWrapper/ControlWrapper.styles.d.ts +1 -1
- package/dist/components/CssBaseline/CssBaseline.styles.d.ts +1 -1
- package/dist/components/DatePicker/components/DatePickerHeader/DatePickerHeader.styles.d.ts +1 -1
- package/dist/components/Description/Description.styles.d.ts +1 -1
- package/dist/components/FileInput/FileInput.styles.d.ts +1 -1
- package/dist/components/FileItem/FileItem.styles.d.ts +1 -1
- package/dist/components/FiltersPane/components/FilterInterval/FilterInterval.styles.d.ts +1 -1
- package/dist/components/FiltersPane/components/FilterSelect/FilterSelect.styles.d.ts +2 -2
- package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.d.ts +2 -2
- package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.d.ts +1 -1
- package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.styles.d.ts +1 -1
- package/dist/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.d.ts +1 -1
- package/dist/components/FiltersPane/types.d.ts +2 -1
- package/dist/components/FlexibleTable/FlexibleTable.styles.d.ts +1 -1
- package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.d.ts +1 -1
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +1 -3
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.d.ts +1 -1
- package/dist/components/FloatDocActions/components/DocActions/DocActions.styles.d.ts +1 -1
- package/dist/components/IconButton/IconButton.styles.d.ts +1 -1
- package/dist/components/List/components/ListItem/ListItem.styles.d.ts +1 -1
- package/dist/components/Modal/Modal.styles.d.ts +1 -1
- package/dist/components/MoreMenu/MoreMenu.styles.d.ts +1 -1
- package/dist/components/MultiSelect/MultiSelect.styles.d.ts +1 -1
- package/dist/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.styles.d.ts +1 -1
- package/dist/components/MultiSelectList/MultiSelectList.styles.d.ts +1 -1
- package/dist/components/NewMoreMenu/NewMoreMenu.styles.d.ts +1 -1
- package/dist/components/Notification/Notification.styles.d.ts +1 -1
- package/dist/components/PhoneInput/PhoneInput.styles.d.ts +1 -1
- package/dist/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.styles.d.ts +1 -1
- package/dist/components/RadioButton/RadioButton.styles.d.ts +1 -1
- package/dist/components/SearchInput/SearchInput.d.ts +1 -1
- package/dist/components/Select/Select.styles.d.ts +3 -3
- package/dist/components/Select/components/SelectList/SelectList.styles.d.ts +1 -1
- package/dist/components/Selector/Selector.styles.d.ts +1 -1
- package/dist/components/Status/Status.styles.d.ts +1 -1
- package/dist/components/Switch/Switch.d.ts +3 -2
- package/dist/components/Switch/Switch.styles.d.ts +3 -2
- package/dist/components/Switch/types.d.ts +3 -0
- package/dist/components/TextArea/TextArea.styles.d.ts +1 -1
- package/dist/components/TextButton/TextButton.styles.d.ts +1 -1
- package/dist/components/TextWithInfo/TextWithInfo.styles.d.ts +1 -1
- package/dist/components/TextWithTooltip/TextWithTooltip.d.ts +2 -0
- package/dist/components/TextWithTooltip/TextWithTooltip.styles.d.ts +1 -1
- package/dist/components/ThemedPreloader/ThemedPreloader.styles.d.ts +1 -1
- package/dist/components/ThemedPreloader/components/DotsPreloader/DotsPreloader.styles.d.ts +1 -1
- package/dist/components/Toaster/Toaster.styles.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +3 -0
- package/dist/components/Tooltip/Tooltip.styles.d.ts +2 -1
- package/dist/components/Tooltip/types.d.ts +3 -0
- package/dist/components/WithMessages/WithMessages.styles.d.ts +1 -1
- package/dist/components/WithPopup/WithPopup.styles.d.ts +1 -1
- package/dist/components/WithTooltip/WithTooltip.d.ts +2 -0
- package/dist/helpers/misc.d.ts +2 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/use-intersection-ref.d.ts +2 -1
- package/dist/hooks/use-resize-ref.d.ts +7 -0
- package/dist/hooks/use-tweak-styles.d.ts +3 -2
- package/dist/theme/Provider.d.ts +2 -12
- package/dist/theme/common.d.ts +34 -4
- package/dist/theme/helpers.d.ts +3 -16
- package/dist/theme/index.d.ts +0 -2
- package/dist/theme/types.d.ts +9 -8
- package/dist/true-react-common-ui-kit.js +12132 -10
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +2 -10
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/dist/types.d.ts +3 -3
- package/package.json +1 -3
- package/src/components/AccountInfo/AccountInfo.tsx +2 -3
- package/src/components/AddButton/AddButton.tsx +3 -5
- package/src/components/Button/Button.tsx +76 -77
- package/src/components/CloseButton/CloseButton.tsx +2 -4
- package/src/components/Colors/Colors.stories.tsx +3 -2
- package/src/components/ControlWrapper/ControlWrapper.tsx +2 -2
- package/src/components/CssBaseline/CssBaseline.styles.ts +2 -0
- package/src/components/CssBaseline/CssBaseline.tsx +2 -3
- package/src/components/DateInput/DateInput.tsx +59 -61
- package/src/components/DatePicker/DatePicker.tsx +259 -262
- package/src/components/Description/Description.tsx +2 -3
- package/src/components/FileInput/FileInput.tsx +87 -95
- package/src/components/FileItem/FileItem.tsx +2 -4
- package/src/components/FiltersPane/FiltersPane.stories.tsx +3 -0
- package/src/components/FiltersPane/components/FilterInterval/FilterInterval.tsx +2 -3
- package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +6 -3
- package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +3 -2
- package/src/components/FiltersPane/types.ts +2 -0
- package/src/components/FlexibleTable/FlexibleTable.styles.ts +1 -0
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.ts +1 -0
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +5 -2
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +9 -7
- package/src/components/IconButton/IconButton.tsx +44 -48
- package/src/components/Input/Input.tsx +26 -24
- package/src/components/Input/InputBase.tsx +183 -187
- package/src/components/List/List.tsx +2 -3
- package/src/components/List/components/ListItem/ListItem.tsx +2 -4
- package/src/components/Modal/Modal.tsx +2 -4
- package/src/components/MoreMenu/MoreMenu.tsx +2 -4
- package/src/components/MultiSelect/MultiSelect.tsx +2 -4
- package/src/components/NewMoreMenu/NewMoreMenu.tsx +2 -4
- package/src/components/Notification/Notification.tsx +2 -3
- package/src/components/NumberInput/NumberInput.tsx +91 -93
- package/src/components/PhoneInput/PhoneInput.tsx +2 -3
- package/src/components/SearchInput/SearchInput.tsx +20 -19
- package/src/components/Select/Select.tsx +1 -1
- package/src/components/Selector/Selector.tsx +4 -6
- package/src/components/SmartInput/SmartInput.tsx +85 -87
- package/src/components/Status/Status.tsx +5 -4
- package/src/components/Switch/Switch.styles.ts +21 -13
- package/src/components/Switch/Switch.tsx +11 -6
- package/src/components/Switch/types.ts +5 -0
- package/src/components/TextArea/TextArea.tsx +128 -130
- package/src/components/TextButton/TextButton.tsx +68 -69
- package/src/components/TextWithInfo/TextWithInfo.tsx +2 -4
- package/src/components/TextWithTooltip/TextWithTooltip.tsx +6 -4
- package/src/components/ThemedPreloader/ThemedPreloader.tsx +2 -4
- package/src/components/Toaster/Toaster.tsx +2 -4
- package/src/components/Tooltip/Tooltip.stories.tsx +10 -0
- package/src/components/Tooltip/Tooltip.styles.ts +2 -1
- package/src/components/Tooltip/Tooltip.tsx +12 -5
- package/src/components/Tooltip/types.ts +5 -0
- package/src/components/WithMessages/WithMessages.tsx +41 -40
- package/src/components/WithTooltip/WithTooltip.tsx +4 -0
- package/src/helpers/misc.ts +6 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-intersection-ref.ts +24 -6
- package/src/hooks/use-latest-ref.ts +6 -2
- package/src/hooks/use-resize-ref.ts +35 -0
- package/src/hooks/use-tweak-styles.ts +14 -51
- package/src/theme/Provider.tsx +4 -21
- package/src/theme/common.ts +33 -36
- package/src/theme/helpers.ts +50 -42
- package/src/theme/index.ts +0 -2
- package/src/theme/types.ts +13 -10
- package/src/types.ts +3 -3
- package/dist/theme/create-themed-styles.d.ts +0 -2
- package/dist/theme/true-jss/ThemedStylesManager.d.ts +0 -18
- package/dist/theme/true-jss/TweakStylesManager.d.ts +0 -34
- package/dist/theme/true-jss/index.d.ts +0 -2
- package/dist/theme/true-jss/jss-context.d.ts +0 -9
- package/dist/true-react-common-ui-kit.css +0 -756
- package/src/theme/create-themed-styles.ts +0 -78
- package/src/theme/true-jss/ThemedStylesManager.ts +0 -93
- package/src/theme/true-jss/TweakStylesManager.ts +0 -156
- package/src/theme/true-jss/index.ts +0 -2
- package/src/theme/true-jss/jss-context.tsx +0 -34
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FocusEventHandler, KeyboardEvent, KeyboardEventHandler, MouseEvent, MouseEventHandler, PointerEventHandler, ReactNode } from 'react';
|
|
2
2
|
import { Modifier, Placement } from 'react-overlays/usePopper';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { IMaybeArray } from '@true-engineering/true-react-platform-helpers';
|
|
4
|
+
import { IStyle } from './theme';
|
|
5
5
|
export interface ITestIdProps {
|
|
6
6
|
testId?: string;
|
|
7
7
|
}
|
|
@@ -45,7 +45,7 @@ export interface IDomElementInteractions<T> {
|
|
|
45
45
|
onPointerUp?: PointerEventHandler<T>;
|
|
46
46
|
}
|
|
47
47
|
export type IRenderNode<T> = ReactNode | ((props: T) => ReactNode);
|
|
48
|
-
export type IExtendableProps<T extends string | readonly string[]> = Record<T extends ReadonlyArray<infer P> ? P : T,
|
|
48
|
+
export type IExtendableProps<T extends string | readonly string[]> = Record<T extends ReadonlyArray<infer P> ? P : T, IStyle>;
|
|
49
49
|
export type IDefaultExtendableProps = IExtendableProps<'custom'>;
|
|
50
50
|
export type IWithPrefix<T, P extends string> = {
|
|
51
51
|
[K in keyof T as `${P}${K & string}`]: T[K];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@true-engineering/true-react-common-ui-kit",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-alpha61",
|
|
4
4
|
"description": "True Engineering React UI Kit with theming support",
|
|
5
5
|
"author": "True Engineering (https://trueengineering.ru)",
|
|
6
6
|
"keywords": [
|
|
@@ -55,7 +55,6 @@
|
|
|
55
55
|
"filesize": "10.1.1",
|
|
56
56
|
"hex-to-rgba": "2.0.1",
|
|
57
57
|
"jss": "10.10.0",
|
|
58
|
-
"lodash-es": "4.17.21",
|
|
59
58
|
"react": "^18.2.0",
|
|
60
59
|
"react-datepicker": "8.4.0",
|
|
61
60
|
"react-dom": "^18.2.0",
|
|
@@ -72,7 +71,6 @@
|
|
|
72
71
|
"@storybook/react": "9.1.10",
|
|
73
72
|
"@swc/core": "1.3.30",
|
|
74
73
|
"@trivago/prettier-plugin-sort-imports": "4.3.0",
|
|
75
|
-
"@types/lodash-es": "4.17.11",
|
|
76
74
|
"@types/node": "24.7.2",
|
|
77
75
|
"@types/react": "18.2.79",
|
|
78
76
|
"@types/react-dom": "18.2.25",
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { FC, ReactNode, useRef, useState, MouseEvent } from 'react';
|
|
2
2
|
import { CSSTransition } from 'react-transition-group';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import {
|
|
5
|
-
import { addDataAttributes } from '../../helpers';
|
|
4
|
+
import { addDataAttributes } from '@true-engineering/true-react-platform-helpers';
|
|
6
5
|
import { useOnClickOutsideWithRef, useTweakStyles } from '../../hooks';
|
|
7
6
|
import { ICommonProps } from '../../types';
|
|
8
7
|
import { Icon } from '../Icon';
|
|
@@ -46,7 +45,7 @@ export const AccountInfo: FC<IAccountInfoProps> = ({
|
|
|
46
45
|
useOnClickOutsideWithRef(dropdownRef, () => setIsMenuOpen(false), nameRef);
|
|
47
46
|
|
|
48
47
|
return (
|
|
49
|
-
<div className={classes.root} {...
|
|
48
|
+
<div className={classes.root} {...addDataAttributes(data, testId)}>
|
|
50
49
|
{avatar ?? (
|
|
51
50
|
<div className={classes.avatarIcon}>
|
|
52
51
|
<Icon type="avatar" />
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import {
|
|
4
|
-
import { addDataAttributes } from '../../helpers';
|
|
3
|
+
import { addDataAttributes } from '@true-engineering/true-react-platform-helpers';
|
|
5
4
|
import { ICommonProps } from '../../types';
|
|
6
5
|
import { Icon } from '../Icon';
|
|
7
6
|
import { useStyles, IAddButtonStyles } from './AddButton.styles';
|
|
@@ -17,7 +16,7 @@ export interface IAddButtonProps extends ICommonProps<IAddButtonStyles> {
|
|
|
17
16
|
onClick?: () => void | Promise<void>;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
/** @deprecated Весьма сомнительный компонент */
|
|
21
20
|
export const AddButton: FC<IAddButtonProps> = ({
|
|
22
21
|
text,
|
|
23
22
|
type = 'button',
|
|
@@ -40,8 +39,7 @@ export const AddButton: FC<IAddButtonProps> = ({
|
|
|
40
39
|
)}
|
|
41
40
|
onClick={!isDisabled ? onClick : undefined}
|
|
42
41
|
disabled={isDisabled}
|
|
43
|
-
{...
|
|
44
|
-
{...addDataAttributes(data)}
|
|
42
|
+
{...addDataAttributes(data, testId)}
|
|
45
43
|
>
|
|
46
44
|
<div className={classes.icon}>
|
|
47
45
|
<Icon type="plus" />
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ReactNode, ButtonHTMLAttributes, MouseEvent, forwardRef } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
addDataAttributes,
|
|
5
|
+
isReactNodeNotEmpty,
|
|
6
|
+
} from '@true-engineering/true-react-platform-helpers';
|
|
5
7
|
import { useTweakStyles } from '../../hooks';
|
|
6
8
|
import { ICommonProps, IDomElementInteractions } from '../../types';
|
|
7
9
|
import { renderIcon, IIcon } from '../Icon';
|
|
@@ -46,84 +48,81 @@ export interface IButtonProps
|
|
|
46
48
|
onMouseDown?: (event: MouseEvent<HTMLButtonElement>) => void | Promise<void>;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
export const Button = forwardRef<HTMLButtonElement, IButtonProps>(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const classes = useStyles({ theme: tweakStyles });
|
|
51
|
+
export const Button = forwardRef<HTMLButtonElement, IButtonProps>(function Button(
|
|
52
|
+
{
|
|
53
|
+
type = 'button',
|
|
54
|
+
children,
|
|
55
|
+
size = 'l',
|
|
56
|
+
view = 'primary',
|
|
57
|
+
isFullWidth = false,
|
|
58
|
+
isInline = false,
|
|
59
|
+
isDisabled = false,
|
|
60
|
+
isActive = false,
|
|
61
|
+
isLoading = false,
|
|
62
|
+
shouldSkipTabNavigation = false,
|
|
63
|
+
data,
|
|
64
|
+
testId,
|
|
65
|
+
tweakStyles,
|
|
66
|
+
icon,
|
|
67
|
+
iconPosition = 'left',
|
|
68
|
+
preloaderType = 'dots',
|
|
69
|
+
...interactions
|
|
70
|
+
},
|
|
71
|
+
ref,
|
|
72
|
+
) {
|
|
73
|
+
const classes = useStyles({ theme: tweakStyles });
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
const tweakPreloaderStyles = useTweakStyles({
|
|
76
|
+
innerStyles: getPreloaderStyles(size),
|
|
77
|
+
tweakStyles,
|
|
78
|
+
className: 'tweakPreloader',
|
|
79
|
+
currentComponentName: 'Button',
|
|
80
|
+
});
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
const hasIcon = isReactNodeNotEmpty(icon);
|
|
83
|
+
const hasChildren = isReactNodeNotEmpty(children);
|
|
84
|
+
const hasNoAction = isDisabled || isLoading;
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
86
|
+
return (
|
|
87
|
+
<button
|
|
88
|
+
ref={ref}
|
|
89
|
+
type={type}
|
|
90
|
+
className={clsx(classes.root, classes[size], classes[view], {
|
|
91
|
+
[classes.disabled]: isDisabled,
|
|
92
|
+
[classes.fullWidth]: isFullWidth,
|
|
93
|
+
[classes.inline]: isInline,
|
|
94
|
+
[classes.active]: isActive,
|
|
95
|
+
[classes.loading]: isLoading,
|
|
96
|
+
[classes.onlyIcon]: hasIcon && !hasChildren,
|
|
97
|
+
})}
|
|
98
|
+
tabIndex={shouldSkipTabNavigation ? -1 : undefined}
|
|
99
|
+
disabled={hasNoAction}
|
|
100
|
+
{...interactions}
|
|
101
|
+
{...addDataAttributes(data, testId)}
|
|
102
|
+
>
|
|
103
|
+
<span
|
|
104
|
+
className={clsx(classes.content, {
|
|
105
|
+
[classes.iconFromRight]: hasChildren && hasIcon && iconPosition === 'right',
|
|
106
|
+
[classes.iconFromLeft]: hasChildren && hasIcon && iconPosition === 'left',
|
|
96
107
|
})}
|
|
97
|
-
tabIndex={shouldSkipTabNavigation ? -1 : undefined}
|
|
98
|
-
disabled={hasNoAction}
|
|
99
|
-
{...interactions}
|
|
100
|
-
{...addDataTestId(testId)}
|
|
101
|
-
{...addDataAttributes(data)}
|
|
102
108
|
>
|
|
103
|
-
|
|
104
|
-
className={
|
|
105
|
-
[classes.iconFromRight]: hasChildren && hasIcon && iconPosition === 'right',
|
|
106
|
-
[classes.iconFromLeft]: hasChildren && hasIcon && iconPosition === 'left',
|
|
107
|
-
})}
|
|
108
|
-
>
|
|
109
|
-
{hasIcon && (
|
|
110
|
-
<span className={classes.icon}>{isReactNodeNotEmpty(icon) && renderIcon(icon)}</span>
|
|
111
|
-
)}
|
|
112
|
-
{hasChildren && (
|
|
113
|
-
<span className={clsx(classes.children, hasIcon && classes.withIcon)}>{children}</span>
|
|
114
|
-
)}
|
|
115
|
-
</span>
|
|
116
|
-
|
|
117
|
-
{isLoading && (
|
|
118
|
-
<span className={classes.loader}>
|
|
119
|
-
<ThemedPreloader
|
|
120
|
-
type={preloaderType}
|
|
121
|
-
useCurrentColor
|
|
122
|
-
tweakStyles={tweakPreloaderStyles}
|
|
123
|
-
/>
|
|
124
|
-
</span>
|
|
109
|
+
{hasIcon && (
|
|
110
|
+
<span className={classes.icon}>{isReactNodeNotEmpty(icon) && renderIcon(icon)}</span>
|
|
125
111
|
)}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
112
|
+
{hasChildren && (
|
|
113
|
+
<span className={clsx(classes.children, hasIcon && classes.withIcon)}>{children}</span>
|
|
114
|
+
)}
|
|
115
|
+
</span>
|
|
116
|
+
|
|
117
|
+
{isLoading && (
|
|
118
|
+
<span className={classes.loader}>
|
|
119
|
+
<ThemedPreloader
|
|
120
|
+
type={preloaderType}
|
|
121
|
+
useCurrentColor
|
|
122
|
+
tweakStyles={tweakPreloaderStyles}
|
|
123
|
+
/>
|
|
124
|
+
</span>
|
|
125
|
+
)}
|
|
126
|
+
</button>
|
|
127
|
+
);
|
|
128
|
+
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { addDataAttributes } from '../../helpers';
|
|
2
|
+
import { addDataAttributes } from '@true-engineering/true-react-platform-helpers';
|
|
4
3
|
import { ICommonProps } from '../../types';
|
|
5
4
|
import { Icon } from '../Icon';
|
|
6
5
|
import { ICloseButtonStyles, useStyles } from './CloseButton.styles';
|
|
@@ -26,8 +25,7 @@ export const CloseButton: FC<ICloseButtonProps> = ({
|
|
|
26
25
|
type="button"
|
|
27
26
|
className={classes.root}
|
|
28
27
|
onClick={onClose}
|
|
29
|
-
{...
|
|
30
|
-
{...addDataAttributes(data)}
|
|
28
|
+
{...addDataAttributes(data, testId)}
|
|
31
29
|
>
|
|
32
30
|
<Icon type={icon} />
|
|
33
31
|
</button>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import { createUseStyles } from 'react-jss';
|
|
2
3
|
import { type Meta } from '@storybook/react';
|
|
3
|
-
import {
|
|
4
|
+
import { useTheme } from '../../theme';
|
|
4
5
|
|
|
5
|
-
const useStyles =
|
|
6
|
+
const useStyles = createUseStyles({
|
|
6
7
|
root: {
|
|
7
8
|
display: 'flex',
|
|
8
9
|
flexWrap: 'wrap',
|
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
addDataAttributes,
|
|
6
6
|
addDataTestId,
|
|
7
7
|
getArray,
|
|
8
|
+
IMaybeArray,
|
|
8
9
|
isArrayNotEmpty,
|
|
9
10
|
isNotEmpty,
|
|
10
11
|
isReactNodeNotEmpty,
|
|
11
12
|
} from '@true-engineering/true-react-platform-helpers';
|
|
12
13
|
import { useTweakStyles } from '../../hooks';
|
|
13
|
-
import { IMaybeArray } from '../../theme';
|
|
14
14
|
import { IClickHandlerEvent, ICommonProps } from '../../types';
|
|
15
15
|
import { IIcon, renderIcon } from '../Icon';
|
|
16
16
|
import { ThemedPreloader } from '../ThemedPreloader';
|
|
@@ -89,7 +89,7 @@ export const ControlWrapper: FC<IControlWrapperProps> = ({
|
|
|
89
89
|
(node: HTMLDivElement | null) => {
|
|
90
90
|
setStartControlsWidth(node?.clientWidth);
|
|
91
91
|
},
|
|
92
|
-
// eslint-disable-next-line
|
|
92
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
93
|
[startIcon, size],
|
|
94
94
|
);
|
|
95
95
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { addDataAttributes } from '../../helpers';
|
|
2
|
+
import { addDataAttributes } from '@true-engineering/true-react-platform-helpers';
|
|
4
3
|
import { ICommonProps } from '../../types';
|
|
5
4
|
import { useStyles, ICssBaselineStyles } from './CssBaseline.styles';
|
|
6
5
|
|
|
@@ -9,5 +8,5 @@ export type ICssBaselineProps = ICommonProps<ICssBaselineStyles>;
|
|
|
9
8
|
export const CssBaseline: FC<ICssBaselineProps> = ({ data, testId, tweakStyles }) => {
|
|
10
9
|
const classes = useStyles({ theme: tweakStyles });
|
|
11
10
|
|
|
12
|
-
return <div className={classes.root} {...
|
|
11
|
+
return <div className={classes.root} {...addDataAttributes(data, testId)} />;
|
|
13
12
|
};
|
|
@@ -22,68 +22,66 @@ export interface IDateInputProps
|
|
|
22
22
|
onChange?: (event: IChangeInputEvent, value: string) => void;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export const DateInput = forwardRef<HTMLInputElement, IDateInputProps>(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const classes = useStyles({ theme: tweakStyles });
|
|
25
|
+
export const DateInput = forwardRef<HTMLInputElement, IDateInputProps>(function DateInput(
|
|
26
|
+
{
|
|
27
|
+
date,
|
|
28
|
+
startDate = '',
|
|
29
|
+
endDate = '',
|
|
30
|
+
mask,
|
|
31
|
+
className,
|
|
32
|
+
placeholder,
|
|
33
|
+
data,
|
|
34
|
+
isRange = false,
|
|
35
|
+
tweakStyles,
|
|
36
|
+
onClick,
|
|
37
|
+
onChange,
|
|
38
|
+
...inputProps
|
|
39
|
+
},
|
|
40
|
+
ref,
|
|
41
|
+
) {
|
|
42
|
+
const classes = useStyles({ theme: tweakStyles });
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
const tweakInputStyles = useTweakStyles({
|
|
45
|
+
tweakStyles,
|
|
46
|
+
className: 'tweakInput',
|
|
47
|
+
currentComponentName: 'DateInput',
|
|
48
|
+
});
|
|
50
49
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
const beforeMaskedStateChange: IInputProps['beforeMaskedStateChange'] = ({ nextState }) => {
|
|
51
|
+
// Если в инпуте отсутствует введенное значение, то выставляем
|
|
52
|
+
// пустую строку для корректной работы react-datepicker
|
|
53
|
+
if (
|
|
54
|
+
nextState.value === EMPTY_DATE_INPUT_VALUE ||
|
|
55
|
+
nextState.value === EMPTY_DATE_RANGE_INPUT_VALUE
|
|
56
|
+
) {
|
|
57
|
+
return { value: '', selection: { start: 0, end: 0 } };
|
|
58
|
+
}
|
|
59
|
+
return nextState;
|
|
60
|
+
};
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
const handleChange: IInputProps['onChange'] = (value, event) => {
|
|
63
|
+
// Событие click срабатывает только при нажатии на кнопку очистки
|
|
64
|
+
if (event.type === 'click') {
|
|
65
|
+
// react-datepicker ожидает пустую строку в event.target.value
|
|
66
|
+
(event as ChangeEvent<HTMLInputElement>).target.value = '';
|
|
67
|
+
}
|
|
68
|
+
onChange?.(event, value);
|
|
69
|
+
};
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
);
|
|
71
|
+
return (
|
|
72
|
+
<div className={clsx(classes.root, className)} {...addDataAttributes(data)} onClick={onClick}>
|
|
73
|
+
<Input
|
|
74
|
+
{...inputProps}
|
|
75
|
+
ref={ref}
|
|
76
|
+
value={isRange ? `${startDate}${endDate}` : date}
|
|
77
|
+
mask={mask ?? (isRange ? '99.99.9999 - 99.99.9999' : '99.99.9999')}
|
|
78
|
+
placeholder={
|
|
79
|
+
placeholder ?? (isRange ? EMPTY_DATE_RANGE_INPUT_VALUE : EMPTY_DATE_INPUT_VALUE)
|
|
80
|
+
}
|
|
81
|
+
tweakStyles={tweakInputStyles}
|
|
82
|
+
onChange={handleChange}
|
|
83
|
+
beforeMaskedStateChange={beforeMaskedStateChange}
|
|
84
|
+
/>
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
87
|
+
});
|