@true-engineering/true-react-common-ui-kit 3.49.0 → 3.50.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@true-engineering/true-react-common-ui-kit",
3
- "version": "3.49.0",
3
+ "version": "3.50.1",
4
4
  "description": "True Engineering React UI Kit with theming support",
5
5
  "author": "True Engineering (https://trueengineering.ru)",
6
6
  "keywords": [
@@ -1,7 +1,6 @@
1
1
  import { dimensions, ITweakStyles, createThemedStyles, animations } from '../../theme';
2
2
  import { IThemedPreloaderStyles } from '../ThemedPreloader';
3
3
 
4
- const PADDING_X = 12;
5
4
  export const AUTOSIZE_MAX_WIDTH = 480;
6
5
 
7
6
  export const useStyles = createThemedStyles('Input', {
@@ -12,6 +11,9 @@ export const useStyles = createThemedStyles('Input', {
12
11
  },
13
12
 
14
13
  inputWrapper: {
14
+ '--input-padding-x': '12px',
15
+ '--input-with-icons-padding-right': '4px',
16
+
15
17
  display: 'flex',
16
18
  width: '100%',
17
19
  height: dimensions.CONTROL_HEIGHT,
@@ -22,10 +24,15 @@ export const useStyles = createThemedStyles('Input', {
22
24
  position: 'relative',
23
25
  },
24
26
 
27
+ inputWithLabelWrapper: {
28
+ position: 'relative',
29
+ width: '100%',
30
+ },
31
+
25
32
  inputContent: {
26
33
  fontSize: 16,
27
34
  fontFamily: 'inherit',
28
- padding: [0, PADDING_X],
35
+ padding: [0, 'var(--input-padding-x)'],
29
36
  },
30
37
 
31
38
  input: {
@@ -112,8 +119,11 @@ export const useStyles = createThemedStyles('Input', {
112
119
  display: 'none',
113
120
 
114
121
  '&$floating': {
122
+ '--scale-factor': '0.75',
123
+
115
124
  display: 'block',
116
- transform: 'scale(0.75) translateY(-120%)',
125
+ transform: 'scale(var(--scale-factor)) translateY(-120%)',
126
+ maxWidth: 'calc(var(--label-max-width) / var(--scale-factor))',
117
127
  },
118
128
  },
119
129
 
@@ -131,14 +141,19 @@ export const useStyles = createThemedStyles('Input', {
131
141
  },
132
142
 
133
143
  label: {
144
+ '--label-max-width': 'calc(100% - var(--input-padding-x))',
145
+
134
146
  position: 'absolute',
135
147
  pointerEvents: 'none',
136
- left: PADDING_X,
148
+ left: 'var(--input-padding-x)',
137
149
  top: '50%',
150
+ boxSizing: 'border-box',
151
+ maxWidth: 'var(--label-max-width)',
152
+ paddingRight: 'var(--input-padding-x)',
138
153
  transformOrigin: 'top left',
139
154
  transform: 'translateY(-50%)',
140
155
  transition: animations.defaultTransition,
141
- transitionProperty: 'transform, color',
156
+ transitionProperty: ['max-width', 'transform', 'color'],
142
157
  fontSize: 16,
143
158
  },
144
159
 
@@ -147,18 +162,37 @@ export const useStyles = createThemedStyles('Input', {
147
162
  },
148
163
 
149
164
  requiredLabel: {
165
+ '--input-padding-right': 'var(--input-padding-x)',
166
+ '--required-label-size': '6px',
167
+ '--required-label-right': 'calc(var(--input-padding-right) - var(--required-label-size) - 2px)',
168
+
169
+ '&:is($labelWithIcons)': {
170
+ '--input-padding-right': 'var(--input-with-icons-padding-right)',
171
+ },
172
+
150
173
  '&:after': {
151
174
  content: '""',
152
175
  position: 'absolute',
153
- right: -8,
176
+ right: 'var(--required-label-right)',
154
177
  top: 4,
155
178
  transform: 'translate(0, -50%)',
156
- width: 6,
157
- height: 6,
179
+ width: 'var(--required-label-size)',
180
+ height: 'var(--required-label-size)',
158
181
  borderRadius: '50%',
159
182
  },
160
183
  },
161
184
 
185
+ labelWithIcons: {
186
+ extend: 'withIcons',
187
+ },
188
+
189
+ labelText: {
190
+ display: 'block',
191
+ overflow: 'hidden',
192
+ textOverflow: 'ellipsis',
193
+ whiteSpace: 'nowrap',
194
+ },
195
+
162
196
  activeIcon: {
163
197
  cursor: 'pointer',
164
198
  },
@@ -263,7 +297,7 @@ export const useStyles = createThemedStyles('Input', {
263
297
  },
264
298
 
265
299
  withIcons: {
266
- paddingRight: 4,
300
+ paddingRight: 'var(--input-with-icons-padding-right)',
267
301
  },
268
302
 
269
303
  withControls: {},
@@ -210,35 +210,38 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
210
210
  data-value={isAutoSizeable ? value : undefined}
211
211
  {...addDataAttributes(data)}
212
212
  >
213
- {mask === undefined ? (
214
- <input ref={ref ?? inputRef} {...props} />
215
- ) : (
216
- <InputMask
217
- // Баг в типизации react-input-mask
218
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
219
- // @ts-ignore: No overload matches this call
220
- ref={ref ?? inputRef}
221
- mask={mask}
222
- maskPlaceholder={maskPlaceholder}
223
- alwaysShowMask={alwaysShowMask}
224
- beforeMaskedStateChange={beforeMaskedStateChange}
225
- {...props}
226
- />
227
- )}
228
- {hasLabel && (
229
- <span
230
- className={clsx(classes.label, {
231
- [classes.invalidLabel]: isInvalid,
232
- [classes.requiredLabel]: hasRequiredLabel && !isRequired,
233
- [classes.activeLabel]: isLabelActive,
234
- [classes.floating]: hasFloatingLabel,
235
- // Обсуждаемо, сделал так, потому что не хочется создавать новую пропсу, на каждый чих в стилях
236
- [classes.floatingWithoutPadding]: hasFloatingLabel && border === 'bottom',
237
- })}
238
- >
239
- {label}
240
- </span>
241
- )}
213
+ <div className={classes.inputWithLabelWrapper}>
214
+ {mask === undefined ? (
215
+ <input ref={ref ?? inputRef} {...props} />
216
+ ) : (
217
+ <InputMask
218
+ // Баг в типизации react-input-mask
219
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
220
+ // @ts-ignore: No overload matches this call
221
+ ref={ref ?? inputRef}
222
+ mask={mask}
223
+ maskPlaceholder={maskPlaceholder}
224
+ alwaysShowMask={alwaysShowMask}
225
+ beforeMaskedStateChange={beforeMaskedStateChange}
226
+ {...props}
227
+ />
228
+ )}
229
+ {hasLabel && (
230
+ <span
231
+ className={clsx(classes.label, {
232
+ [classes.invalidLabel]: isInvalid,
233
+ [classes.requiredLabel]: hasRequiredLabel && !isRequired,
234
+ [classes.activeLabel]: isLabelActive,
235
+ [classes.floating]: hasFloatingLabel,
236
+ // Обсуждаемо, сделал так, потому что не хочется создавать новую пропсу, на каждый чих в стилях
237
+ [classes.floatingWithoutPadding]: hasFloatingLabel && border === 'bottom',
238
+ [classes.labelWithIcons]: hasControls,
239
+ })}
240
+ >
241
+ <span className={classes.labelText}>{label}</span>
242
+ </span>
243
+ )}
244
+ </div>
242
245
 
243
246
  {shouldShowUnits && (
244
247
  <div
@@ -2,8 +2,6 @@ import { rgba } from '../../helpers';
2
2
  import { colors, createThemedStyles, ITweakStyles } from '../../theme';
3
3
  import { IInputStyles } from '../Input';
4
4
 
5
- const LEFT_PADDING = 44;
6
-
7
5
  export const useStyles = createThemedStyles('SearchInput', {
8
6
  root: {
9
7
  position: 'relative',
@@ -31,7 +29,7 @@ export const inputStyles: IInputStyles = {
31
29
  borderColor: 'transparent',
32
30
  backgroundColor: rgba(colors.BORDER_MAIN, 0.3),
33
31
  borderRadius: 18,
34
- paddingLeft: LEFT_PADDING,
32
+ paddingLeft: 44,
35
33
  transitionProperty: 'background-color, border-color',
36
34
  },
37
35
 
@@ -46,7 +44,7 @@ export const inputStyles: IInputStyles = {
46
44
  },
47
45
 
48
46
  label: {
49
- left: LEFT_PADDING,
47
+ left: 0,
50
48
  fontSize: 14,
51
49
  },
52
50
  };
@@ -12,6 +12,8 @@ export const useStyles = createThemedStyles('Select', {
12
12
  },
13
13
 
14
14
  inputWrapper: {
15
+ '--select-arrow-size': '20px',
16
+
15
17
  width: '100%',
16
18
  cursor: 'text',
17
19
  position: 'relative',
@@ -39,8 +41,8 @@ export const useStyles = createThemedStyles('Select', {
39
41
  position: 'absolute',
40
42
  right: 12,
41
43
  top: 14,
42
- width: 20,
43
- height: 20,
44
+ width: 'var(--select-arrow-size)',
45
+ height: 'var(--select-arrow-size)',
44
46
  cursor: 'pointer',
45
47
  zIndex: 1,
46
48
  transition: animations.defaultTransition,
@@ -83,6 +85,20 @@ const baseInputStyles: IInputStyles = {
83
85
  controls: {
84
86
  paddingRight: 32,
85
87
  },
88
+
89
+ label: {
90
+ '--select-label-max-width': 'calc(100% - var(--input-padding-x) - var(--select-arrow-size))',
91
+
92
+ '&:not($labelWithIcons)': {
93
+ '--label-max-width': 'var(--select-label-max-width)',
94
+ },
95
+ },
96
+
97
+ requiredLabel: {
98
+ '&:not($labelWithIcons)': {
99
+ '--label-max-width': 'calc(var(--select-label-max-width) - var(--required-label-size))',
100
+ },
101
+ },
86
102
  };
87
103
 
88
104
  const readonlyInputBaseStyles: IInputStyles = {
@@ -20,7 +20,6 @@ import { debounce } from 'ts-debounce';
20
20
  import {
21
21
  createFilter,
22
22
  getTestId,
23
- isEmpty,
24
23
  isNotEmpty,
25
24
  isReactNodeNotEmpty,
26
25
  isStringNotEmpty,
@@ -254,12 +253,11 @@ export function Select<Value>(
254
253
  );
255
254
 
256
255
  const getDropdownOffset = () => {
257
- if (isEmpty(input.current) || inputProps.errorPosition === 'top') {
256
+ if (inputProps.errorPosition === 'top') {
258
257
  return 0;
259
258
  }
260
259
 
261
- // Высота элемента inputWrapper у компонента Input
262
- return input.current.parentElement?.offsetHeight ?? 0;
260
+ return inputWrapper.current?.offsetHeight ?? 0;
263
261
  };
264
262
 
265
263
  const closeList = useCallback(() => {
@@ -528,7 +526,7 @@ export function Select<Value>(
528
526
  const popperData = useDropdown({
529
527
  isOpen,
530
528
  onDropdownClose: handleListClose,
531
- referenceElement: input.current?.parentElement ?? inputWrapper.current,
529
+ referenceElement: input.current?.parentElement?.parentElement ?? inputWrapper.current,
532
530
  dropdownElement: list.current,
533
531
  options: dropdownOptions,
534
532
  dependenciesForPositionUpdating: [inputProps.isLoading, filteredOptions.length],
@@ -1,7 +1,5 @@
1
1
  import { ITweakStyles, animations, createThemedStyles, helpers } from '../../theme';
2
2
 
3
- const PADDING_X = 12;
4
-
5
3
  export const useStyles = createThemedStyles('TextArea', {
6
4
  root: {
7
5
  width: '100%',
@@ -11,6 +9,8 @@ export const useStyles = createThemedStyles('TextArea', {
11
9
  },
12
10
 
13
11
  wrapper: {
12
+ '--textarea-padding-x': '12px',
13
+
14
14
  display: 'flex',
15
15
  position: 'relative',
16
16
  width: '100%',
@@ -31,7 +31,7 @@ export const useStyles = createThemedStyles('TextArea', {
31
31
  outlineStyle: 'none',
32
32
  fontFamily: 'inherit',
33
33
  fontSize: 16,
34
- padding: [14, PADDING_X, 8],
34
+ padding: [14, 'var(--textarea-padding-x)', 8],
35
35
  scrollPadding: '14px 0 8px',
36
36
  transition: animations.defaultTransition,
37
37
  transitionProperty: 'background-color',
@@ -89,8 +89,11 @@ export const useStyles = createThemedStyles('TextArea', {
89
89
  display: 'none',
90
90
 
91
91
  '&$floating': {
92
+ '--scale-factor': '0.75',
93
+
92
94
  display: 'block',
93
- transform: 'scale(0.75) translateY(-120%)',
95
+ transform: 'scale(var(--scale-factor)) translateY(-120%)',
96
+ maxWidth: 'calc(var(--label-max-width) / var(--scale-factor))',
94
97
  },
95
98
  },
96
99
 
@@ -111,14 +114,17 @@ export const useStyles = createThemedStyles('TextArea', {
111
114
  disabled: {},
112
115
 
113
116
  label: {
117
+ '--label-max-width': 'calc(100% - 2 * var(--textarea-padding-x))',
118
+
114
119
  position: 'absolute',
115
120
  pointerEvents: 'none',
116
- left: PADDING_X,
117
- top: PADDING_X * 2,
121
+ left: 'var(--textarea-padding-x)',
122
+ top: 24,
123
+ maxWidth: 'var(--label-max-width)',
118
124
  transformOrigin: 'top left',
119
125
  transform: 'translateY(-50%)',
120
126
  transition: animations.defaultTransition,
121
- transitionProperty: 'transform, color',
127
+ transitionProperty: ['max-width', 'transform', 'color'],
122
128
  fontSize: 16,
123
129
  },
124
130
 
@@ -136,19 +142,31 @@ export const useStyles = createThemedStyles('TextArea', {
136
142
  },
137
143
 
138
144
  requiredLabel: {
145
+ '--required-label-size': '6px',
146
+ '--required-label-right': '8px',
147
+
148
+ maxWidth: 'calc(100% - 2 * var(--textarea-padding-x) - var(--required-label-right))',
149
+
139
150
  '&:after': {
140
151
  content: '""',
141
152
  position: 'absolute',
142
- right: -8,
153
+ right: 'calc(-1 * var(--required-label-right))',
143
154
  top: 4,
144
155
  transform: 'translate(0, -50%)',
145
- width: 6,
146
- height: 6,
156
+ width: 'var(--required-label-size)',
157
+ height: 'var(--required-label-size)',
147
158
  borderRadius: '50%',
148
159
  backgroundColor: 'red',
149
160
  },
150
161
  },
151
162
 
163
+ labelText: {
164
+ display: 'block',
165
+ overflow: 'hidden',
166
+ textOverflow: 'ellipsis',
167
+ whiteSpace: 'nowrap',
168
+ },
169
+
152
170
  symbolsCount: {
153
171
  display: 'block',
154
172
  textAlign: 'right',
@@ -154,7 +154,7 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
154
154
  [classes.floating]: hasFloatingLabel,
155
155
  })}
156
156
  >
157
- {label}
157
+ <span className={classes.labelText}>{label}</span>
158
158
  </span>
159
159
  )}
160
160