@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
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ChangeEvent,
|
|
3
|
+
CSSProperties,
|
|
3
4
|
FocusEvent,
|
|
4
5
|
FormEvent,
|
|
5
6
|
forwardRef,
|
|
6
7
|
TextareaHTMLAttributes,
|
|
7
8
|
useState,
|
|
8
9
|
} from 'react';
|
|
9
|
-
import { Styles } from 'react-jss';
|
|
10
10
|
import clsx from 'clsx';
|
|
11
11
|
import {
|
|
12
12
|
addDataAttributes,
|
|
@@ -52,144 +52,142 @@ export interface ITextAreaProps
|
|
|
52
52
|
onChange: (value: string, event?: FormEvent<HTMLTextAreaElement>) => void;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const classes = useStyles({ theme: tweakStyles });
|
|
55
|
+
export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(function TextArea(
|
|
56
|
+
{
|
|
57
|
+
value = '',
|
|
58
|
+
placeholder,
|
|
59
|
+
name,
|
|
60
|
+
counterPosition = 'default',
|
|
61
|
+
shouldFocusOnMount,
|
|
62
|
+
hasCounter = true,
|
|
63
|
+
shouldTrimAfterMaxLength,
|
|
64
|
+
isAutoSized = true,
|
|
65
|
+
shouldAlwaysShowPlaceholder,
|
|
66
|
+
isActive,
|
|
67
|
+
maxLength,
|
|
68
|
+
rows,
|
|
69
|
+
data,
|
|
70
|
+
testId,
|
|
71
|
+
tweakStyles,
|
|
72
|
+
onChange,
|
|
73
|
+
onPaste,
|
|
74
|
+
onFocus,
|
|
75
|
+
onBlur,
|
|
76
|
+
// Пропсы WithMessages
|
|
77
|
+
infoMessage,
|
|
78
|
+
errorMessage,
|
|
79
|
+
// Пропсы ControlWrapper
|
|
80
|
+
label,
|
|
81
|
+
isDisabled,
|
|
82
|
+
isInvalid,
|
|
83
|
+
isRequired,
|
|
84
|
+
size,
|
|
85
|
+
groupPlacement,
|
|
86
|
+
...textAreaProps
|
|
87
|
+
},
|
|
88
|
+
ref,
|
|
89
|
+
) {
|
|
90
|
+
const classes = useStyles({ theme: tweakStyles });
|
|
92
91
|
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
const shouldShowCounter = hasCounter && isNotEmpty(maxLength);
|
|
93
|
+
const counterString = `${value.length} / ${maxLength}`;
|
|
95
94
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
const tweakWithMessagesStyles = useTweakStyles({
|
|
96
|
+
tweakStyles,
|
|
97
|
+
className: 'tweakWithMessages',
|
|
98
|
+
currentComponentName: 'TextArea',
|
|
99
|
+
});
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
const tweakControlWrapperStyles = useTweakStyles({
|
|
102
|
+
tweakStyles,
|
|
103
|
+
className: 'tweakControlWrapper',
|
|
104
|
+
currentComponentName: 'TextArea',
|
|
105
|
+
});
|
|
107
106
|
|
|
108
|
-
|
|
107
|
+
const [isFocused, setFocused] = useState(false);
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
const hasFocus = isFocused || isActive;
|
|
110
|
+
const hasValue = isArrayLikeNotEmpty(value);
|
|
111
|
+
const hasLabel = isReactNodeNotEmpty(label);
|
|
112
|
+
const hasPlaceholder =
|
|
113
|
+
(!hasLabel || hasFocus || shouldAlwaysShowPlaceholder) && isStringNotEmpty(placeholder);
|
|
115
114
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
|
|
116
|
+
onChange(event.currentTarget.value, event);
|
|
117
|
+
};
|
|
119
118
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
const handleFocus = (event: FocusEvent<HTMLTextAreaElement>) => {
|
|
120
|
+
setFocused(true);
|
|
121
|
+
onFocus?.(event);
|
|
122
|
+
};
|
|
124
123
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
const handleBlur = (event: FocusEvent<HTMLTextAreaElement>) => {
|
|
125
|
+
setFocused(false);
|
|
126
|
+
onBlur?.(event);
|
|
127
|
+
};
|
|
129
128
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
return (
|
|
130
|
+
<div
|
|
131
|
+
className={clsx(classes.root, isNotEmpty(size) && classes[size])}
|
|
132
|
+
style={{ '--counter-length': counterString.length } as CSSProperties}
|
|
133
|
+
>
|
|
134
|
+
<WithMessages
|
|
135
|
+
errorMessage={errorMessage}
|
|
136
|
+
infoMessage={infoMessage}
|
|
137
|
+
tweakStyles={tweakWithMessagesStyles}
|
|
138
|
+
testId={getTestId(testId, 'wrapper')}
|
|
134
139
|
>
|
|
135
|
-
<
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
+
<ControlWrapper
|
|
141
|
+
label={label}
|
|
142
|
+
tweakStyles={tweakControlWrapperStyles}
|
|
143
|
+
isFocused={hasFocus}
|
|
144
|
+
isDisabled={isDisabled}
|
|
145
|
+
hasValue={hasValue}
|
|
146
|
+
isInvalid={isInvalid}
|
|
147
|
+
isRequired={isRequired}
|
|
148
|
+
groupPlacement={groupPlacement}
|
|
149
|
+
size={size}
|
|
150
|
+
isFullWidth
|
|
140
151
|
>
|
|
141
|
-
<
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
isRequired={isRequired}
|
|
149
|
-
groupPlacement={groupPlacement}
|
|
150
|
-
size={size}
|
|
151
|
-
isFullWidth
|
|
152
|
+
<div
|
|
153
|
+
className={clsx(classes.wrapper, {
|
|
154
|
+
[classes.autoSized]: isAutoSized,
|
|
155
|
+
[classes.withLabel]: hasLabel,
|
|
156
|
+
})}
|
|
157
|
+
// Не менять на addDataAttributes
|
|
158
|
+
{...(isAutoSized && { 'data-value': value })}
|
|
152
159
|
>
|
|
153
|
-
<
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
{
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
{...
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
</span>
|
|
188
|
-
)}
|
|
189
|
-
</div>
|
|
190
|
-
</ControlWrapper>
|
|
191
|
-
</WithMessages>
|
|
192
|
-
</div>
|
|
193
|
-
);
|
|
194
|
-
},
|
|
195
|
-
);
|
|
160
|
+
<textarea
|
|
161
|
+
ref={ref}
|
|
162
|
+
className={classes.textarea}
|
|
163
|
+
value={value}
|
|
164
|
+
disabled={isDisabled}
|
|
165
|
+
placeholder={hasPlaceholder ? placeholder : undefined}
|
|
166
|
+
maxLength={shouldTrimAfterMaxLength ? maxLength : undefined}
|
|
167
|
+
name={name}
|
|
168
|
+
rows={rows}
|
|
169
|
+
onPaste={onPaste}
|
|
170
|
+
onFocus={handleFocus}
|
|
171
|
+
onBlur={handleBlur}
|
|
172
|
+
onChange={handleChange}
|
|
173
|
+
autoFocus={shouldFocusOnMount}
|
|
174
|
+
{...addDataAttributes(data, testId)}
|
|
175
|
+
{...textAreaProps}
|
|
176
|
+
/>
|
|
177
|
+
{shouldShowCounter && (
|
|
178
|
+
<span
|
|
179
|
+
className={clsx(classes.symbolsCount, classes[`counter-${counterPosition}`], {
|
|
180
|
+
[classes.symbolsCountError]: value.length > maxLength,
|
|
181
|
+
[classes.symbolsCountActive]: hasFocus || hasValue,
|
|
182
|
+
})}
|
|
183
|
+
{...addDataAttributes({ counterPosition })}
|
|
184
|
+
>
|
|
185
|
+
{counterString}
|
|
186
|
+
</span>
|
|
187
|
+
)}
|
|
188
|
+
</div>
|
|
189
|
+
</ControlWrapper>
|
|
190
|
+
</WithMessages>
|
|
191
|
+
</div>
|
|
192
|
+
);
|
|
193
|
+
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { forwardRef, ReactNode } 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 } from '../../types';
|
|
7
9
|
import { IIcon, renderIcon } from '../Icon';
|
|
@@ -36,75 +38,72 @@ export interface ITextButtonProps
|
|
|
36
38
|
preloaderType?: IThemedPreloaderProps['type'];
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
export const TextButton = forwardRef<HTMLButtonElement, ITextButtonProps>(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const classes = useStyles({ theme: tweakStyles });
|
|
63
|
-
|
|
64
|
-
const tweakPreloaderStyles = useTweakStyles({
|
|
65
|
-
innerStyles: preloaderStyles,
|
|
66
|
-
tweakStyles,
|
|
67
|
-
className: 'tweakPreloader',
|
|
68
|
-
currentComponentName: 'TextButton',
|
|
69
|
-
});
|
|
41
|
+
export const TextButton = forwardRef<HTMLButtonElement, ITextButtonProps>(function TextButton(
|
|
42
|
+
{
|
|
43
|
+
children,
|
|
44
|
+
icon,
|
|
45
|
+
view = 'primary',
|
|
46
|
+
isDisabled = false,
|
|
47
|
+
isBold = false,
|
|
48
|
+
isLoading = false,
|
|
49
|
+
isActive = false,
|
|
50
|
+
hasCircleUnderIcon = false,
|
|
51
|
+
size = 'l',
|
|
52
|
+
iconPosition = 'left',
|
|
53
|
+
preloaderType = 'dots',
|
|
54
|
+
type = 'button',
|
|
55
|
+
testId,
|
|
56
|
+
tweakStyles,
|
|
57
|
+
data,
|
|
58
|
+
onClick,
|
|
59
|
+
...restProps
|
|
60
|
+
},
|
|
61
|
+
ref,
|
|
62
|
+
) {
|
|
63
|
+
const classes = useStyles({ theme: tweakStyles });
|
|
70
64
|
|
|
71
|
-
|
|
65
|
+
const tweakPreloaderStyles = useTweakStyles({
|
|
66
|
+
innerStyles: preloaderStyles,
|
|
67
|
+
tweakStyles,
|
|
68
|
+
className: 'tweakPreloader',
|
|
69
|
+
currentComponentName: 'TextButton',
|
|
70
|
+
});
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
<button
|
|
75
|
-
ref={ref}
|
|
76
|
-
type={type}
|
|
77
|
-
className={clsx(classes.root, classes[size], classes[view], {
|
|
78
|
-
[classes.bold]: isBold,
|
|
79
|
-
[classes.loading]: isLoading,
|
|
80
|
-
[classes.active]: isActive,
|
|
81
|
-
[classes.disabled]: isDisabled,
|
|
82
|
-
})}
|
|
83
|
-
disabled={hasNoAction}
|
|
84
|
-
onClick={!hasNoAction ? onClick : undefined}
|
|
85
|
-
{...restProps}
|
|
86
|
-
{...addDataTestId(testId)}
|
|
87
|
-
{...addDataAttributes(data)}
|
|
88
|
-
>
|
|
89
|
-
<span className={clsx(classes.content, iconPosition === 'right' && classes.reverseContent)}>
|
|
90
|
-
{isReactNodeNotEmpty(icon) && (
|
|
91
|
-
<span className={clsx(classes.iconContainer, hasCircleUnderIcon && classes.circle)}>
|
|
92
|
-
<span className={classes.icon}>{renderIcon(icon)}</span>
|
|
93
|
-
</span>
|
|
94
|
-
)}
|
|
95
|
-
{children}
|
|
96
|
-
</span>
|
|
72
|
+
const hasNoAction = isDisabled || isLoading;
|
|
97
73
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
74
|
+
return (
|
|
75
|
+
<button
|
|
76
|
+
ref={ref}
|
|
77
|
+
type={type}
|
|
78
|
+
className={clsx(classes.root, classes[size], classes[view], {
|
|
79
|
+
[classes.bold]: isBold,
|
|
80
|
+
[classes.loading]: isLoading,
|
|
81
|
+
[classes.active]: isActive,
|
|
82
|
+
[classes.disabled]: isDisabled,
|
|
83
|
+
})}
|
|
84
|
+
disabled={hasNoAction}
|
|
85
|
+
onClick={!hasNoAction ? onClick : undefined}
|
|
86
|
+
{...restProps}
|
|
87
|
+
{...addDataAttributes(data, testId)}
|
|
88
|
+
>
|
|
89
|
+
<span className={clsx(classes.content, iconPosition === 'right' && classes.reverseContent)}>
|
|
90
|
+
{isReactNodeNotEmpty(icon) && (
|
|
91
|
+
<span className={clsx(classes.iconContainer, hasCircleUnderIcon && classes.circle)}>
|
|
92
|
+
<span className={classes.icon}>{renderIcon(icon)}</span>
|
|
105
93
|
</span>
|
|
106
94
|
)}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
95
|
+
{children}
|
|
96
|
+
</span>
|
|
97
|
+
|
|
98
|
+
{isLoading && (
|
|
99
|
+
<span className={classes.loader}>
|
|
100
|
+
<ThemedPreloader
|
|
101
|
+
type={preloaderType}
|
|
102
|
+
useCurrentColor
|
|
103
|
+
tweakStyles={tweakPreloaderStyles}
|
|
104
|
+
/>
|
|
105
|
+
</span>
|
|
106
|
+
)}
|
|
107
|
+
</button>
|
|
108
|
+
);
|
|
109
|
+
});
|
|
@@ -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 { TextWithTooltip } from '../TextWithTooltip';
|
|
@@ -34,8 +33,7 @@ export const TextWithInfo: FC<ITextWithInfoProps> = ({
|
|
|
34
33
|
return (
|
|
35
34
|
<div
|
|
36
35
|
className={clsx(classes.root, isSelected && classes.selected)}
|
|
37
|
-
{...
|
|
38
|
-
{...addDataAttributes(data)}
|
|
36
|
+
{...addDataAttributes(data, testId)}
|
|
39
37
|
>
|
|
40
38
|
<div className={classes.container}>
|
|
41
39
|
<div className={classes.text} onClick={onClick}>
|
|
@@ -2,8 +2,7 @@ import { CSSProperties, FC, ReactNode, useEffect, useRef, useState } from 'react
|
|
|
2
2
|
import { Portal } from 'react-overlays';
|
|
3
3
|
import usePopper, { Modifier, Placement } from 'react-overlays/usePopper';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
-
import {
|
|
6
|
-
import { addDataAttributes } from '../../helpers';
|
|
5
|
+
import { addDataAttributes } from '@true-engineering/true-react-platform-helpers';
|
|
7
6
|
import { useOnClickOutsideWithRef, useTweakStyles } from '../../hooks';
|
|
8
7
|
import { ICommonProps } from '../../types';
|
|
9
8
|
import { ITooltipProps, Tooltip } from '../Tooltip';
|
|
@@ -21,6 +20,8 @@ export interface ITextWithTooltipProps extends ICommonProps<ITextWithTooltipStyl
|
|
|
21
20
|
/** @default [] */
|
|
22
21
|
tooltipModifiers?: Array<Partial<Modifier<any, any>>>;
|
|
23
22
|
tooltipOffsetOptions?: Record<string, unknown>;
|
|
23
|
+
/** @default 'undefined' */
|
|
24
|
+
tooltipSize?: ITooltipProps['size'];
|
|
24
25
|
/** @default 'hover' */
|
|
25
26
|
mouseEventType?: 'hover' | 'click';
|
|
26
27
|
hoverDelay?: number;
|
|
@@ -39,6 +40,7 @@ export const TextWithTooltip: FC<ITextWithTooltipProps> = ({
|
|
|
39
40
|
tooltipType = 'info',
|
|
40
41
|
tooltipModifiers = [],
|
|
41
42
|
tooltipOffsetOptions,
|
|
43
|
+
tooltipSize,
|
|
42
44
|
isDisabled = false,
|
|
43
45
|
shouldRenderInBody = true,
|
|
44
46
|
mouseEventType = 'hover',
|
|
@@ -128,8 +130,7 @@ export const TextWithTooltip: FC<ITextWithTooltipProps> = ({
|
|
|
128
130
|
mouseEventType === 'click' && shouldShowTooltip && classes.clickable,
|
|
129
131
|
)}
|
|
130
132
|
{...(shouldShowTooltip ? props : undefined)}
|
|
131
|
-
{...
|
|
132
|
-
{...addDataAttributes(data)}
|
|
133
|
+
{...addDataAttributes(data, testId)}
|
|
133
134
|
ref={root}
|
|
134
135
|
>
|
|
135
136
|
{shouldShowTooltip && (
|
|
@@ -144,6 +145,7 @@ export const TextWithTooltip: FC<ITextWithTooltipProps> = ({
|
|
|
144
145
|
view={tooltipView}
|
|
145
146
|
type={tooltipType}
|
|
146
147
|
text={tooltipText}
|
|
148
|
+
size={tooltipSize}
|
|
147
149
|
tweakStyles={tweakTooltipStyles}
|
|
148
150
|
/>
|
|
149
151
|
</div>
|
|
@@ -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 { useTweakStyles } from '../../hooks';
|
|
6
5
|
import { ICommonProps } from '../../types';
|
|
7
6
|
import { SvgPreloader, DotsPreloader } from './components';
|
|
@@ -41,8 +40,7 @@ export const ThemedPreloader: FC<IThemedPreloaderProps> = ({
|
|
|
41
40
|
className={clsx(classes.root, classes[type], {
|
|
42
41
|
[classes.currentColor]: useCurrentColor,
|
|
43
42
|
})}
|
|
44
|
-
{...
|
|
45
|
-
{...addDataAttributes(data)}
|
|
43
|
+
{...addDataAttributes(data, testId)}
|
|
46
44
|
>
|
|
47
45
|
{type === 'dots' ? (
|
|
48
46
|
<DotsPreloader tweakStyles={tweakDotsPreloaderStyles} />
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { FC, ReactNode, useEffect } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
addDataAttributes,
|
|
5
5
|
isEmpty,
|
|
6
6
|
isNotEmpty,
|
|
7
7
|
isReactNodeNotEmpty,
|
|
8
8
|
} from '@true-engineering/true-react-platform-helpers';
|
|
9
|
-
import { addDataAttributes } from '../../helpers';
|
|
10
9
|
import { useTweakStyles } from '../../hooks';
|
|
11
10
|
import { ICommonProps } from '../../types';
|
|
12
11
|
import { Icon } from '../Icon';
|
|
@@ -70,8 +69,7 @@ export const Toaster: FC<IToasterProps> = ({
|
|
|
70
69
|
<div
|
|
71
70
|
className={classes.root}
|
|
72
71
|
onClick={shouldCloseOnClick ? onClose : undefined}
|
|
73
|
-
{...
|
|
74
|
-
{...addDataAttributes(data)}
|
|
72
|
+
{...addDataAttributes(data, testId)}
|
|
75
73
|
>
|
|
76
74
|
<div className={clsx(classes.iconContainer, classes[type])}>
|
|
77
75
|
<Icon type={`status-${type}`} />
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { type Meta } from '@storybook/react';
|
|
2
|
+
import { IExtendableProps } from '../../types';
|
|
2
3
|
import { Tooltip } from './Tooltip';
|
|
3
4
|
|
|
5
|
+
const SIZES = ['micro'] as const;
|
|
6
|
+
|
|
7
|
+
declare module './types' {
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
9
|
+
export interface ITooltipSizes extends IExtendableProps<typeof SIZES> {}
|
|
10
|
+
}
|
|
11
|
+
|
|
4
12
|
const meta: Meta<typeof Tooltip> = {
|
|
5
13
|
title: 'Data Display/Tooltip',
|
|
6
14
|
component: Tooltip,
|
|
@@ -8,11 +16,13 @@ const meta: Meta<typeof Tooltip> = {
|
|
|
8
16
|
text: 'Tooltip Text',
|
|
9
17
|
view: 'tooltip',
|
|
10
18
|
type: 'info',
|
|
19
|
+
size: undefined,
|
|
11
20
|
},
|
|
12
21
|
argTypes: {
|
|
13
22
|
text: { control: 'text' },
|
|
14
23
|
view: { control: 'inline-radio', options: ['tooltip', 'hint'] },
|
|
15
24
|
type: { control: 'inline-radio', options: ['info', 'error'] },
|
|
25
|
+
size: { options: [undefined, ...SIZES], control: 'inline-radio' },
|
|
16
26
|
},
|
|
17
27
|
};
|
|
18
28
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { rgba } from '../../helpers';
|
|
2
2
|
import { colors, createThemedStyles, dimensions, ITweakStyles } from '../../theme';
|
|
3
|
+
import { ITooltipSizes } from './types';
|
|
3
4
|
|
|
4
5
|
export const useStyles = createThemedStyles('Tooltip', {
|
|
5
6
|
root: {
|
|
@@ -48,4 +49,4 @@ export const useStyles = createThemedStyles('Tooltip', {
|
|
|
48
49
|
},
|
|
49
50
|
});
|
|
50
51
|
|
|
51
|
-
export type ITooltipStyles = ITweakStyles<typeof useStyles>;
|
|
52
|
+
export type ITooltipStyles = ITweakStyles<typeof useStyles, ITooltipSizes>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import {
|
|
4
|
-
import { addDataAttributes } from '../../helpers';
|
|
3
|
+
import { addDataAttributes, isNotEmpty } from '@true-engineering/true-react-platform-helpers';
|
|
5
4
|
import { ICommonProps } from '../../types';
|
|
5
|
+
import { ITooltipSize } from './types';
|
|
6
6
|
import { useStyles, ITooltipStyles } from './Tooltip.styles';
|
|
7
7
|
|
|
8
8
|
export interface ITooltipProps extends ICommonProps<ITooltipStyles> {
|
|
@@ -11,12 +11,15 @@ export interface ITooltipProps extends ICommonProps<ITooltipStyles> {
|
|
|
11
11
|
view?: 'tooltip' | 'hint' | 'custom';
|
|
12
12
|
/** @default 'info' */
|
|
13
13
|
type?: 'info' | 'error';
|
|
14
|
+
/** @default 'undefined' */
|
|
15
|
+
size?: ITooltipSize;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export const Tooltip: FC<ITooltipProps> = ({
|
|
17
19
|
text,
|
|
18
20
|
view = 'tooltip',
|
|
19
21
|
type = 'info',
|
|
22
|
+
size,
|
|
20
23
|
data,
|
|
21
24
|
testId,
|
|
22
25
|
tweakStyles,
|
|
@@ -25,9 +28,13 @@ export const Tooltip: FC<ITooltipProps> = ({
|
|
|
25
28
|
|
|
26
29
|
return (
|
|
27
30
|
<div
|
|
28
|
-
className={clsx(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
className={clsx(
|
|
32
|
+
classes.root,
|
|
33
|
+
classes[view],
|
|
34
|
+
classes[type],
|
|
35
|
+
isNotEmpty(size) && classes[size],
|
|
36
|
+
)}
|
|
37
|
+
{...addDataAttributes(data, testId)}
|
|
31
38
|
>
|
|
32
39
|
{text}
|
|
33
40
|
</div>
|