@true-engineering/true-react-common-ui-kit 3.45.1 → 4.0.0-alpha0

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 (122) hide show
  1. package/README.md +0 -40
  2. package/dist/components/CloseButton/CloseButton.d.ts +1 -1
  3. package/dist/components/ControlGroup/ControlGroup.d.ts +10 -0
  4. package/dist/components/ControlGroup/ControlGroup.stories.d.ts +7 -0
  5. package/dist/components/ControlGroup/ControlGroup.styles.d.ts +3 -0
  6. package/dist/components/ControlGroup/index.d.ts +2 -0
  7. package/dist/components/ControlWrapper/ControlWrapper.d.ts +27 -0
  8. package/dist/components/ControlWrapper/ControlWrapper.stories.d.ts +6 -0
  9. package/dist/components/ControlWrapper/ControlWrapper.styles.d.ts +6 -0
  10. package/dist/components/ControlWrapper/index.d.ts +2 -0
  11. package/dist/components/DateInput/DateInput.d.ts +3 -3
  12. package/dist/components/DatePicker/components/DatePickerHeader/DatePickerHeader.styles.d.ts +1 -1
  13. package/dist/components/DatePicker/types.d.ts +1 -1
  14. package/dist/components/FiltersPane/FiltersPane.stories.d.ts +1 -2
  15. package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.d.ts +1 -1
  16. package/dist/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.d.ts +1 -2
  17. package/dist/components/Input/Input.d.ts +5 -52
  18. package/dist/components/Input/Input.stories.d.ts +4 -13
  19. package/dist/components/Input/Input.styles.d.ts +5 -4
  20. package/dist/components/Input/InputBase.d.ts +24 -0
  21. package/dist/components/Input/index.d.ts +1 -0
  22. package/dist/components/Input/types.d.ts +3 -4
  23. package/dist/components/NumberInput/NumberInput.d.ts +3 -3
  24. package/dist/components/PhoneInput/PhoneInput.d.ts +3 -3
  25. package/dist/components/PhoneInput/PhoneInput.stories.d.ts +2 -2
  26. package/dist/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.d.ts +3 -2
  27. package/dist/components/PhoneInput/types.d.ts +2 -0
  28. package/dist/components/SearchInput/SearchInput.d.ts +1 -3
  29. package/dist/components/SearchInput/SearchInput.stories.d.ts +11 -1
  30. package/dist/components/SearchInput/SearchInput.styles.d.ts +1 -1
  31. package/dist/components/Select/Select.d.ts +5 -5
  32. package/dist/components/Select/Select.styles.d.ts +17 -16
  33. package/dist/components/Select/types.d.ts +3 -0
  34. package/dist/components/SmartInput/SmartInput.d.ts +3 -3
  35. package/dist/components/TextArea/TextArea.d.ts +5 -14
  36. package/dist/components/TextArea/TextArea.styles.d.ts +8 -2
  37. package/dist/components/WithPopup/WithPopup.d.ts +3 -10
  38. package/dist/components/WithPopup/WithPopup.styles.d.ts +1 -1
  39. package/dist/components/WithPopup/types.d.ts +0 -3
  40. package/dist/components/WithTooltip/WithTooltip.styles.d.ts +0 -1
  41. package/dist/components/index.d.ts +2 -0
  42. package/dist/theme/common.d.ts +13 -5
  43. package/dist/theme/types.d.ts +4 -2
  44. package/dist/true-react-common-ui-kit.js +1184 -1029
  45. package/dist/true-react-common-ui-kit.js.map +1 -1
  46. package/dist/true-react-common-ui-kit.umd.cjs +1164 -1009
  47. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  48. package/dist/types.d.ts +2 -1
  49. package/package.json +1 -1
  50. package/src/components/Button/Button.stories.tsx +4 -8
  51. package/src/components/CloseButton/CloseButton.tsx +4 -4
  52. package/src/components/ControlGroup/ControlGroup.stories.tsx +40 -0
  53. package/src/components/ControlGroup/ControlGroup.styles.ts +46 -0
  54. package/src/components/ControlGroup/ControlGroup.tsx +55 -0
  55. package/src/components/ControlGroup/index.ts +2 -0
  56. package/src/components/ControlWrapper/ControlWrapper.stories.tsx +45 -0
  57. package/src/components/ControlWrapper/ControlWrapper.styles.ts +185 -0
  58. package/src/components/ControlWrapper/ControlWrapper.tsx +151 -0
  59. package/src/components/ControlWrapper/index.ts +2 -0
  60. package/src/components/DateInput/DateInput.styles.ts +2 -7
  61. package/src/components/DateInput/DateInput.tsx +4 -4
  62. package/src/components/DatePicker/DatePicker.tsx +3 -3
  63. package/src/components/DatePicker/components/DatePickerHeader/DatePickerHeader.styles.ts +7 -41
  64. package/src/components/DatePicker/components/DatePickerHeader/DatePickerHeader.tsx +18 -26
  65. package/src/components/DatePicker/types.ts +1 -1
  66. package/src/components/FileItem/FileItem.stories.tsx +4 -8
  67. package/src/components/FiltersPane/FiltersPane.stories.tsx +0 -4
  68. package/src/components/FiltersPane/components/FilterInterval/FilterInterval.styles.ts +9 -7
  69. package/src/components/FiltersPane/components/FilterInterval/FilterInterval.tsx +1 -8
  70. package/src/components/FiltersPane/components/FilterSelect/FilterSelect.styles.ts +7 -5
  71. package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +7 -9
  72. package/src/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.ts +12 -17
  73. package/src/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.tsx +2 -5
  74. package/src/components/IconButton/IconButton.stories.tsx +5 -5
  75. package/src/components/IncrementInput/IncrementInput.stories.tsx +0 -2
  76. package/src/components/IncrementInput/IncrementInput.styles.ts +9 -9
  77. package/src/components/Input/Input.stories.tsx +17 -25
  78. package/src/components/Input/Input.styles.ts +50 -260
  79. package/src/components/Input/Input.tsx +22 -285
  80. package/src/components/Input/InputBase.tsx +250 -0
  81. package/src/components/Input/index.ts +1 -0
  82. package/src/components/Input/types.ts +3 -32
  83. package/src/components/MultiSelectList/MultiSelectList.styles.ts +7 -5
  84. package/src/components/Notification/Notification.stories.tsx +2 -6
  85. package/src/components/NumberInput/NumberInput.stories.tsx +0 -2
  86. package/src/components/NumberInput/NumberInput.tsx +4 -7
  87. package/src/components/PhoneInput/PhoneInput.stories.tsx +6 -10
  88. package/src/components/PhoneInput/PhoneInput.styles.ts +13 -10
  89. package/src/components/PhoneInput/PhoneInput.tsx +9 -12
  90. package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.styles.ts +6 -4
  91. package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.tsx +6 -6
  92. package/src/components/PhoneInput/types.ts +4 -0
  93. package/src/components/SearchInput/SearchInput.stories.tsx +1 -0
  94. package/src/components/SearchInput/SearchInput.styles.ts +17 -27
  95. package/src/components/SearchInput/SearchInput.tsx +13 -34
  96. package/src/components/Select/CustomSelect.stories.tsx +6 -9
  97. package/src/components/Select/MultiSelect.stories.tsx +4 -12
  98. package/src/components/Select/Select.stories.tsx +3 -11
  99. package/src/components/Select/Select.styles.ts +28 -42
  100. package/src/components/Select/Select.tsx +73 -81
  101. package/src/components/Select/types.ts +5 -0
  102. package/src/components/SmartInput/SmartInput.stories.tsx +0 -1
  103. package/src/components/SmartInput/SmartInput.tsx +4 -4
  104. package/src/components/Status/Status.stories.tsx +3 -7
  105. package/src/components/TextArea/TextArea.stories.tsx +1 -3
  106. package/src/components/TextArea/TextArea.styles.ts +27 -126
  107. package/src/components/TextArea/TextArea.tsx +86 -112
  108. package/src/components/TextButton/TextButton.stories.tsx +4 -8
  109. package/src/components/WithPopup/WithPopup.stories.tsx +0 -1
  110. package/src/components/WithPopup/WithPopup.styles.ts +0 -2
  111. package/src/components/WithPopup/WithPopup.tsx +10 -36
  112. package/src/components/WithPopup/types.ts +0 -7
  113. package/src/components/WithTooltip/WithTooltip.styles.ts +0 -6
  114. package/src/components/WithTooltip/WithTooltip.tsx +2 -7
  115. package/src/components/index.ts +2 -0
  116. package/src/theme/common.ts +15 -6
  117. package/src/theme/types.ts +8 -4
  118. package/src/types.ts +3 -0
  119. package/dist/components/Input/constants.d.ts +0 -1
  120. package/dist/components/WithPopup/helpers.d.ts +0 -2
  121. package/src/components/Input/constants.ts +0 -1
  122. package/src/components/WithPopup/helpers.ts +0 -9
@@ -1,6 +1,7 @@
1
- import { FC, useRef, useState } from 'react';
1
+ import { FC, useState } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import {
4
+ addDataTestId,
4
5
  applyAction,
5
6
  stopPropagation,
6
7
  addDataAttributes,
@@ -22,14 +23,10 @@ import {
22
23
  UseHoverProps,
23
24
  safePolygon,
24
25
  useFocus,
25
- FloatingArrow,
26
- arrow,
27
26
  } from '@floating-ui/react';
28
- import { ICommonProps, IDataAttributes, IRenderNode } from '../../types';
27
+ import { ICommonProps, IRenderNode } from '../../types';
29
28
  import { DEFAULT_OFFSET } from './constants';
30
- import { minWidthRelativeToTrigger } from './helpers';
31
29
  import {
32
- IPopupArrowProps,
33
30
  IPopupEventType,
34
31
  IReferenceProps,
35
32
  IWithPopupChildrenProps,
@@ -50,9 +47,7 @@ export interface IWithPopupProps extends ICommonProps<IWithPopupStyles> {
50
47
  hoverDelay?: UseHoverProps['delay'];
51
48
  /** @default 6 */
52
49
  popupOffset?: OffsetOptions;
53
- arrowProps?: IPopupArrowProps;
54
- popupData?: IDataAttributes;
55
- /** @default true, if eventType === click */
50
+ /** @default true */
56
51
  shouldStopPropagation?: boolean;
57
52
  /** @default false */
58
53
  shouldHideOnScroll?: boolean;
@@ -65,11 +60,6 @@ export interface IWithPopupProps extends ICommonProps<IWithPopupStyles> {
65
60
  canBeFlipped?: boolean;
66
61
  /** @default false */
67
62
  isDisabled?: boolean;
68
- /** @default false */
69
- shouldShowArrow?: boolean;
70
- /** Должна ли минимальная ширина попапа быть равна ширине триггера
71
- * @default false */
72
- isMinWidthSameAsTrigger?: boolean;
73
63
  onToggle?: (isActive: boolean, event?: IWithPopupToggleEvent) => void;
74
64
  }
75
65
 
@@ -81,16 +71,12 @@ export const WithPopup: FC<IWithPopupProps> = ({
81
71
  placement = eventType === 'click' ? 'bottom-end' : 'top',
82
72
  hoverDelay = 0,
83
73
  popupOffset = DEFAULT_OFFSET,
84
- arrowProps,
85
- popupData,
86
- shouldStopPropagation = eventType === 'click',
74
+ shouldStopPropagation = true,
87
75
  shouldHideOnScroll = false,
88
76
  shouldRenderInBody = true,
89
77
  canBeFlipped = true,
90
78
  isTriggerWrapped = eventType === 'hover',
91
79
  isDisabled = false,
92
- shouldShowArrow = false,
93
- isMinWidthSameAsTrigger = false,
94
80
  tweakStyles,
95
81
  data,
96
82
  testId,
@@ -100,8 +86,6 @@ export const WithPopup: FC<IWithPopupProps> = ({
100
86
 
101
87
  const [isOpen, setIsOpen] = useState(false);
102
88
 
103
- const arrowRef = useRef<SVGSVGElement>(null);
104
-
105
89
  const handleToggle = (isActive: boolean, event?: IWithPopupToggleEvent) => {
106
90
  event?.stopPropagation();
107
91
  if (!isDisabled) {
@@ -119,9 +103,7 @@ export const WithPopup: FC<IWithPopupProps> = ({
119
103
  middleware: [
120
104
  offset(popupOffset),
121
105
  canBeFlipped && flip({ fallbackAxisSideDirection: 'start' }),
122
- isMinWidthSameAsTrigger && minWidthRelativeToTrigger,
123
106
  ...middlewares,
124
- shouldShowArrow && arrow({ element: arrowRef }),
125
107
  ],
126
108
  whileElementsMounted: autoUpdate,
127
109
  placement,
@@ -173,7 +155,8 @@ export const WithPopup: FC<IWithPopupProps> = ({
173
155
  [classes.active]: isOpen,
174
156
  })}
175
157
  {...referenceProps}
176
- {...addDataAttributes(data, testId)}
158
+ {...addDataTestId(testId)}
159
+ {...addDataAttributes(data)}
177
160
  >
178
161
  {triggerElement}
179
162
  </div>
@@ -182,25 +165,16 @@ export const WithPopup: FC<IWithPopupProps> = ({
182
165
  )}
183
166
  {isMounted && (
184
167
  <FloatingPortal
185
- root={shouldRenderInBody ? document.body : (refs.reference.current as HTMLElement)}
168
+ root={!shouldRenderInBody ? (refs.reference.current as HTMLDivElement) : undefined}
186
169
  >
187
170
  <div
188
- ref={refs.setFloating}
189
171
  style={floatingStyles}
190
172
  className={classes.popup}
173
+ ref={refs.setFloating}
191
174
  {...getFloatingProps()}
192
- {...addDataAttributes(popupData)}
193
175
  >
194
176
  <div className={classes[`dropdown-${status}`]}>
195
- {shouldShowArrow && (
196
- <FloatingArrow
197
- {...arrowProps}
198
- ref={arrowRef}
199
- context={context}
200
- className={classes.arrow}
201
- />
202
- )}
203
- {applyAction(children, { floatingContext: context, onClose: handleClose })}
177
+ {applyAction(children, { onClose: handleClose })}
204
178
  </div>
205
179
  </div>
206
180
  </FloatingPortal>
@@ -1,5 +1,4 @@
1
1
  import type { MouseEvent, KeyboardEvent } from 'react';
2
- import type { FloatingArrowProps, UseFloatingReturn } from '@floating-ui/react';
3
2
  import type { IDataAttributesProps, IDomElementInteractions } from '../../types';
4
3
  import type { POPUP_EVENT_TYPES } from './constants';
5
4
 
@@ -22,11 +21,5 @@ export interface IWithPopupTriggerProps {
22
21
  }
23
22
 
24
23
  export interface IWithPopupChildrenProps {
25
- floatingContext: UseFloatingReturn['context'];
26
24
  onClose: (event?: IWithPopupToggleEvent) => void;
27
25
  }
28
-
29
- export type IPopupArrowProps = Pick<
30
- FloatingArrowProps,
31
- 'width' | 'height' | 'tipRadius' | 'staticOffset' | 'd' | 'stroke' | 'strokeWidth'
32
- >;
@@ -1,12 +1,6 @@
1
1
  import { ITooltipStyles } from '../Tooltip';
2
2
  import { IWithPopupStyles } from '../WithPopup';
3
3
 
4
- export const withPopupStyles: IWithPopupStyles = {
5
- popup: {
6
- zIndex: 9999,
7
- },
8
- };
9
-
10
4
  export interface IWithTooltipStyles {
11
5
  tweakWithPopup?: IWithPopupStyles;
12
6
  tweakTooltip?: ITooltipStyles;
@@ -4,7 +4,7 @@ import { useTweakStyles } from '../../hooks';
4
4
  import { ICommonProps } from '../../types';
5
5
  import { ITooltipProps, Tooltip } from '../Tooltip';
6
6
  import { IWithPopupProps, WithPopup } from '../WithPopup';
7
- import { IWithTooltipStyles, withPopupStyles } from './WithTooltip.styles';
7
+ import { IWithTooltipStyles } from './WithTooltip.styles';
8
8
 
9
9
  export interface IWithTooltipProps
10
10
  extends Omit<
@@ -32,21 +32,17 @@ export const WithTooltip: FC<IWithTooltipProps> = ({
32
32
  tooltipView = 'tooltip',
33
33
  tooltipType = 'info',
34
34
  isDisabled = false,
35
- popupData,
36
35
  tweakStyles,
37
36
  ...restProps
38
37
  }) => {
39
38
  const tweakWithPopupStyles = useTweakStyles({
40
- innerStyles: withPopupStyles,
41
39
  tweakStyles,
42
40
  className: 'tweakWithPopup',
43
- currentComponentName: 'WithTooltip',
44
41
  });
45
42
 
46
43
  const tweakTooltipStyles = useTweakStyles({
47
44
  tweakStyles,
48
45
  className: 'tweakTooltip',
49
- currentComponentName: 'WithTooltip',
50
46
  });
51
47
 
52
48
  return (
@@ -54,9 +50,8 @@ export const WithTooltip: FC<IWithTooltipProps> = ({
54
50
  trigger={children}
55
51
  placement={placement}
56
52
  eventType={eventType}
57
- popupData={{ ...popupData, tooltipView }}
58
- isDisabled={isDisabled || !isReactNodeNotEmpty(tooltipText)}
59
53
  isTriggerWrapped
54
+ isDisabled={isDisabled || !isReactNodeNotEmpty(tooltipText)}
60
55
  tweakStyles={tweakWithPopupStyles}
61
56
  {...restProps}
62
57
  >
@@ -44,3 +44,5 @@ export * from './Tooltip';
44
44
  export * from './NewMoreMenu';
45
45
  export * from './WithPopup';
46
46
  export * from './WithTooltip';
47
+ export * from './ControlGroup';
48
+ export * from './ControlWrapper';
@@ -33,7 +33,19 @@ export const dimensions = {
33
33
  BORDER_RADIUS_STD: 8,
34
34
  BORDER_RADIUS_SMALL: 6,
35
35
  BORDER_RADIUS_EXTRA_SMALL: 4,
36
- CONTROL_HEIGHT: 48,
36
+
37
+ CONTROL: {
38
+ HEIGHT: 48,
39
+ PADDING: 16,
40
+ ICON_SIZE: 24,
41
+ ICON_INNER_SIZE: 24,
42
+ ICON_GAP: 8,
43
+ },
44
+
45
+ Z_INDEX: {
46
+ CONTROL_INVALID: 1,
47
+ CONTROL_FOCUS: 2,
48
+ },
37
49
  } as const;
38
50
 
39
51
  export const helpers = {
@@ -79,12 +91,9 @@ export const helpers = {
79
91
 
80
92
  // Chromium
81
93
  '@supports selector(::-webkit-scrollbar)': {
82
- '--webkit-scrollbar-width': '10px',
83
- '--webkit-scrollbar-height': '10px',
84
-
85
94
  '&::-webkit-scrollbar': {
86
- width: 'var(--webkit-scrollbar-width)',
87
- height: 'var(--webkit-scrollbar-height)',
95
+ height: 10,
96
+ width: 10,
88
97
 
89
98
  '&-thumb': {
90
99
  width: 6,
@@ -8,12 +8,16 @@ import type {
8
8
  ICloseButtonStyles,
9
9
  ICommonIcon,
10
10
  IComplexIcon,
11
+ IControlGroupStyles,
12
+ IControlWrapperStyles,
11
13
  ICssBaselineStyles,
12
14
  IDateInputStyles,
13
15
  IDatePickerHeaderStyles,
14
16
  IDatePickerStyles,
15
17
  IDescriptionStyles,
16
18
  IDotsPreloaderStyles,
19
+ IFileInputStyles,
20
+ IFileItemStyles,
17
21
  IFilterIntervalStyles,
18
22
  IFilterSelectStyles,
19
23
  IFiltersPaneSearchStyles,
@@ -37,6 +41,7 @@ import type {
37
41
  IMultiSelectInputStyles,
38
42
  IMultiSelectListStyles,
39
43
  IMultiSelectStyles,
44
+ INewMoreMenuStyles,
40
45
  INotificationStyles,
41
46
  IPhoneInputCountryListStyles,
42
47
  IPhoneInputStyles,
@@ -59,9 +64,6 @@ import type {
59
64
  IToasterStyles,
60
65
  ITooltipStyles,
61
66
  IWithPopupStyles,
62
- INewMoreMenuStyles,
63
- IFileInputStyles,
64
- IFileItemStyles,
65
67
  IWithTooltipStyles,
66
68
  } from '../components';
67
69
 
@@ -136,6 +138,8 @@ export interface IComponentStyles {
136
138
  Toaster: IToasterStyles;
137
139
  WithPopup: IWithPopupStyles;
138
140
  NewMoreMenu: INewMoreMenuStyles;
141
+ ControlGroup: IControlGroupStyles;
142
+ ControlWrapper: IControlWrapperStyles;
139
143
  WithTooltip: IWithTooltipStyles;
140
144
  }
141
145
 
@@ -152,7 +156,7 @@ export interface IUiKitTheme {
152
156
  preloaders?: Partial<Record<IPreloaderSvgType, string>>; // TODO: заменить string
153
157
  animations?: IUiKitAnimations;
154
158
  colors?: Record<string, string>;
155
- dimensions?: Record<string, number>;
159
+ dimensions?: Record<string, number | Record<string, number>>;
156
160
  boxShadows?: Record<string, JssValue>;
157
161
  helpers?: IUiKitHelpers;
158
162
  }
package/src/types.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import {
2
2
  FocusEventHandler,
3
+ type KeyboardEvent,
3
4
  KeyboardEventHandler,
5
+ MouseEvent,
4
6
  MouseEventHandler,
5
7
  PointerEventHandler,
6
8
  ReactNode,
@@ -39,6 +41,7 @@ export interface IDropdownWithPopperOptions {
39
41
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
42
  flipOptions?: Record<string, any>; // только с shouldUsePopper
41
43
  }
44
+ export type IClickHandlerEvent = MouseEvent | KeyboardEvent;
42
45
 
43
46
  export interface IDomElementInteractions<T> {
44
47
  onBlur?: FocusEventHandler<T>;
@@ -1 +0,0 @@
1
- export declare const DEFAULT_SIZE = 6;
@@ -1,2 +0,0 @@
1
- import { Middleware } from '@floating-ui/react';
2
- export declare const minWidthRelativeToTrigger: Middleware;
@@ -1 +0,0 @@
1
- export const DEFAULT_SIZE = 6;
@@ -1,9 +0,0 @@
1
- import { Middleware, size } from '@floating-ui/react';
2
-
3
- export const minWidthRelativeToTrigger: Middleware = size({
4
- apply({ rects, elements }) {
5
- Object.assign(elements.floating.style, {
6
- minWidth: `${rects.reference.width}px`,
7
- });
8
- },
9
- });