@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.
Files changed (151) hide show
  1. package/README.md +1 -0
  2. package/dist/components/AddButton/AddButton.d.ts +1 -0
  3. package/dist/components/AddButton/AddButton.styles.d.ts +1 -1
  4. package/dist/components/Button/Button.styles.d.ts +1 -1
  5. package/dist/components/Checkbox/Checkbox.styles.d.ts +1 -1
  6. package/dist/components/ControlWrapper/ControlWrapper.d.ts +1 -1
  7. package/dist/components/ControlWrapper/ControlWrapper.styles.d.ts +1 -1
  8. package/dist/components/CssBaseline/CssBaseline.styles.d.ts +1 -1
  9. package/dist/components/DatePicker/components/DatePickerHeader/DatePickerHeader.styles.d.ts +1 -1
  10. package/dist/components/Description/Description.styles.d.ts +1 -1
  11. package/dist/components/FileInput/FileInput.styles.d.ts +1 -1
  12. package/dist/components/FileItem/FileItem.styles.d.ts +1 -1
  13. package/dist/components/FiltersPane/components/FilterInterval/FilterInterval.styles.d.ts +1 -1
  14. package/dist/components/FiltersPane/components/FilterSelect/FilterSelect.styles.d.ts +2 -2
  15. package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.d.ts +2 -2
  16. package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.d.ts +1 -1
  17. package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.styles.d.ts +1 -1
  18. package/dist/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.d.ts +1 -1
  19. package/dist/components/FiltersPane/types.d.ts +2 -1
  20. package/dist/components/FlexibleTable/FlexibleTable.styles.d.ts +1 -1
  21. package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.d.ts +1 -1
  22. package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +1 -3
  23. package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.d.ts +1 -1
  24. package/dist/components/FloatDocActions/components/DocActions/DocActions.styles.d.ts +1 -1
  25. package/dist/components/IconButton/IconButton.styles.d.ts +1 -1
  26. package/dist/components/List/components/ListItem/ListItem.styles.d.ts +1 -1
  27. package/dist/components/Modal/Modal.styles.d.ts +1 -1
  28. package/dist/components/MoreMenu/MoreMenu.styles.d.ts +1 -1
  29. package/dist/components/MultiSelect/MultiSelect.styles.d.ts +1 -1
  30. package/dist/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.styles.d.ts +1 -1
  31. package/dist/components/MultiSelectList/MultiSelectList.styles.d.ts +1 -1
  32. package/dist/components/NewMoreMenu/NewMoreMenu.styles.d.ts +1 -1
  33. package/dist/components/Notification/Notification.styles.d.ts +1 -1
  34. package/dist/components/PhoneInput/PhoneInput.styles.d.ts +1 -1
  35. package/dist/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.styles.d.ts +1 -1
  36. package/dist/components/RadioButton/RadioButton.styles.d.ts +1 -1
  37. package/dist/components/SearchInput/SearchInput.d.ts +1 -1
  38. package/dist/components/Select/Select.styles.d.ts +3 -3
  39. package/dist/components/Select/components/SelectList/SelectList.styles.d.ts +1 -1
  40. package/dist/components/Selector/Selector.styles.d.ts +1 -1
  41. package/dist/components/Status/Status.styles.d.ts +1 -1
  42. package/dist/components/Switch/Switch.d.ts +3 -2
  43. package/dist/components/Switch/Switch.styles.d.ts +3 -2
  44. package/dist/components/Switch/types.d.ts +3 -0
  45. package/dist/components/TextArea/TextArea.styles.d.ts +1 -1
  46. package/dist/components/TextButton/TextButton.styles.d.ts +1 -1
  47. package/dist/components/TextWithInfo/TextWithInfo.styles.d.ts +1 -1
  48. package/dist/components/TextWithTooltip/TextWithTooltip.d.ts +2 -0
  49. package/dist/components/TextWithTooltip/TextWithTooltip.styles.d.ts +1 -1
  50. package/dist/components/ThemedPreloader/ThemedPreloader.styles.d.ts +1 -1
  51. package/dist/components/ThemedPreloader/components/DotsPreloader/DotsPreloader.styles.d.ts +1 -1
  52. package/dist/components/Toaster/Toaster.styles.d.ts +1 -1
  53. package/dist/components/Tooltip/Tooltip.d.ts +3 -0
  54. package/dist/components/Tooltip/Tooltip.styles.d.ts +2 -1
  55. package/dist/components/Tooltip/types.d.ts +3 -0
  56. package/dist/components/WithMessages/WithMessages.styles.d.ts +1 -1
  57. package/dist/components/WithPopup/WithPopup.styles.d.ts +1 -1
  58. package/dist/components/WithTooltip/WithTooltip.d.ts +2 -0
  59. package/dist/helpers/misc.d.ts +2 -0
  60. package/dist/hooks/index.d.ts +1 -0
  61. package/dist/hooks/use-intersection-ref.d.ts +2 -1
  62. package/dist/hooks/use-resize-ref.d.ts +7 -0
  63. package/dist/hooks/use-tweak-styles.d.ts +3 -2
  64. package/dist/theme/Provider.d.ts +2 -12
  65. package/dist/theme/common.d.ts +34 -4
  66. package/dist/theme/helpers.d.ts +3 -16
  67. package/dist/theme/index.d.ts +0 -2
  68. package/dist/theme/types.d.ts +9 -8
  69. package/dist/true-react-common-ui-kit.js +12132 -10
  70. package/dist/true-react-common-ui-kit.js.map +1 -1
  71. package/dist/true-react-common-ui-kit.umd.cjs +2 -10
  72. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  73. package/dist/types.d.ts +3 -3
  74. package/package.json +1 -3
  75. package/src/components/AccountInfo/AccountInfo.tsx +2 -3
  76. package/src/components/AddButton/AddButton.tsx +3 -5
  77. package/src/components/Button/Button.tsx +76 -77
  78. package/src/components/CloseButton/CloseButton.tsx +2 -4
  79. package/src/components/Colors/Colors.stories.tsx +3 -2
  80. package/src/components/ControlWrapper/ControlWrapper.tsx +2 -2
  81. package/src/components/CssBaseline/CssBaseline.styles.ts +2 -0
  82. package/src/components/CssBaseline/CssBaseline.tsx +2 -3
  83. package/src/components/DateInput/DateInput.tsx +59 -61
  84. package/src/components/DatePicker/DatePicker.tsx +259 -262
  85. package/src/components/Description/Description.tsx +2 -3
  86. package/src/components/FileInput/FileInput.tsx +87 -95
  87. package/src/components/FileItem/FileItem.tsx +2 -4
  88. package/src/components/FiltersPane/FiltersPane.stories.tsx +3 -0
  89. package/src/components/FiltersPane/components/FilterInterval/FilterInterval.tsx +2 -3
  90. package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +6 -3
  91. package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +3 -2
  92. package/src/components/FiltersPane/types.ts +2 -0
  93. package/src/components/FlexibleTable/FlexibleTable.styles.ts +1 -0
  94. package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.ts +1 -0
  95. package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +5 -2
  96. package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +9 -7
  97. package/src/components/IconButton/IconButton.tsx +44 -48
  98. package/src/components/Input/Input.tsx +26 -24
  99. package/src/components/Input/InputBase.tsx +183 -187
  100. package/src/components/List/List.tsx +2 -3
  101. package/src/components/List/components/ListItem/ListItem.tsx +2 -4
  102. package/src/components/Modal/Modal.tsx +2 -4
  103. package/src/components/MoreMenu/MoreMenu.tsx +2 -4
  104. package/src/components/MultiSelect/MultiSelect.tsx +2 -4
  105. package/src/components/NewMoreMenu/NewMoreMenu.tsx +2 -4
  106. package/src/components/Notification/Notification.tsx +2 -3
  107. package/src/components/NumberInput/NumberInput.tsx +91 -93
  108. package/src/components/PhoneInput/PhoneInput.tsx +2 -3
  109. package/src/components/SearchInput/SearchInput.tsx +20 -19
  110. package/src/components/Select/Select.tsx +1 -1
  111. package/src/components/Selector/Selector.tsx +4 -6
  112. package/src/components/SmartInput/SmartInput.tsx +85 -87
  113. package/src/components/Status/Status.tsx +5 -4
  114. package/src/components/Switch/Switch.styles.ts +21 -13
  115. package/src/components/Switch/Switch.tsx +11 -6
  116. package/src/components/Switch/types.ts +5 -0
  117. package/src/components/TextArea/TextArea.tsx +128 -130
  118. package/src/components/TextButton/TextButton.tsx +68 -69
  119. package/src/components/TextWithInfo/TextWithInfo.tsx +2 -4
  120. package/src/components/TextWithTooltip/TextWithTooltip.tsx +6 -4
  121. package/src/components/ThemedPreloader/ThemedPreloader.tsx +2 -4
  122. package/src/components/Toaster/Toaster.tsx +2 -4
  123. package/src/components/Tooltip/Tooltip.stories.tsx +10 -0
  124. package/src/components/Tooltip/Tooltip.styles.ts +2 -1
  125. package/src/components/Tooltip/Tooltip.tsx +12 -5
  126. package/src/components/Tooltip/types.ts +5 -0
  127. package/src/components/WithMessages/WithMessages.tsx +41 -40
  128. package/src/components/WithTooltip/WithTooltip.tsx +4 -0
  129. package/src/helpers/misc.ts +6 -0
  130. package/src/hooks/index.ts +1 -0
  131. package/src/hooks/use-intersection-ref.ts +24 -6
  132. package/src/hooks/use-latest-ref.ts +6 -2
  133. package/src/hooks/use-resize-ref.ts +35 -0
  134. package/src/hooks/use-tweak-styles.ts +14 -51
  135. package/src/theme/Provider.tsx +4 -21
  136. package/src/theme/common.ts +33 -36
  137. package/src/theme/helpers.ts +50 -42
  138. package/src/theme/index.ts +0 -2
  139. package/src/theme/types.ts +13 -10
  140. package/src/types.ts +3 -3
  141. package/dist/theme/create-themed-styles.d.ts +0 -2
  142. package/dist/theme/true-jss/ThemedStylesManager.d.ts +0 -18
  143. package/dist/theme/true-jss/TweakStylesManager.d.ts +0 -34
  144. package/dist/theme/true-jss/index.d.ts +0 -2
  145. package/dist/theme/true-jss/jss-context.d.ts +0 -9
  146. package/dist/true-react-common-ui-kit.css +0 -756
  147. package/src/theme/create-themed-styles.ts +0 -78
  148. package/src/theme/true-jss/ThemedStylesManager.ts +0 -93
  149. package/src/theme/true-jss/TweakStylesManager.ts +0 -156
  150. package/src/theme/true-jss/index.ts +0 -2
  151. 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
- value = '',
59
- placeholder,
60
- name,
61
- counterPosition = 'default',
62
- shouldFocusOnMount,
63
- hasCounter = true,
64
- shouldTrimAfterMaxLength,
65
- isAutoSized = true,
66
- shouldAlwaysShowPlaceholder,
67
- isActive,
68
- maxLength,
69
- rows,
70
- data,
71
- testId,
72
- tweakStyles,
73
- onChange,
74
- onPaste,
75
- onFocus,
76
- onBlur,
77
- // Пропсы WithMessages
78
- infoMessage,
79
- errorMessage,
80
- // Пропсы ControlWrapper
81
- label,
82
- isDisabled,
83
- isInvalid,
84
- isRequired,
85
- size,
86
- groupPlacement,
87
- ...textAreaProps
88
- },
89
- ref,
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
- const shouldShowCounter = hasCounter && isNotEmpty(maxLength);
94
- const counterString = `${value.length} / ${maxLength}`;
92
+ const shouldShowCounter = hasCounter && isNotEmpty(maxLength);
93
+ const counterString = `${value.length} / ${maxLength}`;
95
94
 
96
- const tweakWithMessagesStyles = useTweakStyles({
97
- tweakStyles,
98
- className: 'tweakWithMessages',
99
- currentComponentName: 'TextArea',
100
- });
95
+ const tweakWithMessagesStyles = useTweakStyles({
96
+ tweakStyles,
97
+ className: 'tweakWithMessages',
98
+ currentComponentName: 'TextArea',
99
+ });
101
100
 
102
- const tweakControlWrapperStyles = useTweakStyles({
103
- tweakStyles,
104
- className: 'tweakControlWrapper',
105
- currentComponentName: 'TextArea',
106
- });
101
+ const tweakControlWrapperStyles = useTweakStyles({
102
+ tweakStyles,
103
+ className: 'tweakControlWrapper',
104
+ currentComponentName: 'TextArea',
105
+ });
107
106
 
108
- const [isFocused, setFocused] = useState(false);
107
+ const [isFocused, setFocused] = useState(false);
109
108
 
110
- const hasFocus = isFocused || isActive;
111
- const hasValue = isArrayLikeNotEmpty(value);
112
- const hasLabel = isReactNodeNotEmpty(label);
113
- const hasPlaceholder =
114
- (!hasLabel || hasFocus || shouldAlwaysShowPlaceholder) && isStringNotEmpty(placeholder);
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
- const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
117
- onChange(event.currentTarget.value, event);
118
- };
115
+ const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
116
+ onChange(event.currentTarget.value, event);
117
+ };
119
118
 
120
- const handleFocus = (event: FocusEvent<HTMLTextAreaElement>) => {
121
- setFocused(true);
122
- onFocus?.(event);
123
- };
119
+ const handleFocus = (event: FocusEvent<HTMLTextAreaElement>) => {
120
+ setFocused(true);
121
+ onFocus?.(event);
122
+ };
124
123
 
125
- const handleBlur = (event: FocusEvent<HTMLTextAreaElement>) => {
126
- setFocused(false);
127
- onBlur?.(event);
128
- };
124
+ const handleBlur = (event: FocusEvent<HTMLTextAreaElement>) => {
125
+ setFocused(false);
126
+ onBlur?.(event);
127
+ };
129
128
 
130
- return (
131
- <div
132
- className={clsx(classes.root, isNotEmpty(size) && classes[size])}
133
- style={{ '--counter-length': counterString.length } as Styles}
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
- <WithMessages
136
- errorMessage={errorMessage}
137
- infoMessage={infoMessage}
138
- tweakStyles={tweakWithMessagesStyles}
139
- testId={getTestId(testId, 'wrapper')}
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
- <ControlWrapper
142
- label={label}
143
- tweakStyles={tweakControlWrapperStyles}
144
- isFocused={hasFocus}
145
- isDisabled={isDisabled}
146
- hasValue={hasValue}
147
- isInvalid={isInvalid}
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
- <div
154
- className={clsx(classes.wrapper, {
155
- [classes.autoSized]: isAutoSized,
156
- [classes.withLabel]: hasLabel,
157
- })}
158
- // Не менять на addDataAttributes
159
- {...(isAutoSized && { 'data-value': value })}
160
- >
161
- <textarea
162
- ref={ref}
163
- className={classes.textarea}
164
- value={value}
165
- disabled={isDisabled}
166
- placeholder={hasPlaceholder ? placeholder : undefined}
167
- maxLength={shouldTrimAfterMaxLength ? maxLength : undefined}
168
- name={name}
169
- rows={rows}
170
- onPaste={onPaste}
171
- onFocus={handleFocus}
172
- onBlur={handleBlur}
173
- onChange={handleChange}
174
- autoFocus={shouldFocusOnMount}
175
- {...addDataAttributes(data, testId)}
176
- {...textAreaProps}
177
- />
178
- {shouldShowCounter && (
179
- <span
180
- className={clsx(classes.symbolsCount, classes[`counter-${counterPosition}`], {
181
- [classes.symbolsCountError]: value.length > maxLength,
182
- [classes.symbolsCountActive]: hasFocus || hasValue,
183
- })}
184
- {...addDataAttributes({ counterPosition })}
185
- >
186
- {counterString}
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 { addDataTestId, isReactNodeNotEmpty } from '@true-engineering/true-react-platform-helpers';
4
- import { addDataAttributes } from '../../helpers';
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
- children,
43
- icon,
44
- view = 'primary',
45
- isDisabled = false,
46
- isBold = false,
47
- isLoading = false,
48
- isActive = false,
49
- hasCircleUnderIcon = false,
50
- size = 'l',
51
- iconPosition = 'left',
52
- preloaderType = 'dots',
53
- type = 'button',
54
- testId,
55
- tweakStyles,
56
- data,
57
- onClick,
58
- ...restProps
59
- },
60
- ref,
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
- const hasNoAction = isDisabled || isLoading;
65
+ const tweakPreloaderStyles = useTweakStyles({
66
+ innerStyles: preloaderStyles,
67
+ tweakStyles,
68
+ className: 'tweakPreloader',
69
+ currentComponentName: 'TextButton',
70
+ });
72
71
 
73
- return (
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
- {isLoading && (
99
- <span className={classes.loader}>
100
- <ThemedPreloader
101
- type={preloaderType}
102
- useCurrentColor
103
- tweakStyles={tweakPreloaderStyles}
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
- </button>
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 { addDataTestId } from '@true-engineering/true-react-platform-helpers';
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
- {...addDataTestId(testId)}
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 { addDataTestId } from '@true-engineering/true-react-platform-helpers';
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
- {...addDataTestId(testId)}
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 { addDataTestId } from '@true-engineering/true-react-platform-helpers';
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
- {...addDataTestId(testId)}
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
- addDataTestId,
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
- {...addDataTestId(testId)}
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 { addDataTestId } from '@true-engineering/true-react-platform-helpers';
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(classes.root, classes[view], classes[type])}
29
- {...addDataTestId(testId)}
30
- {...addDataAttributes(data)}
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>
@@ -1 +1,6 @@
1
1
  export type ITooltipType = 'info' | 'warning';
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
4
+ export interface ITooltipSizes {}
5
+
6
+ export type ITooltipSize = keyof ITooltipSizes;