@true-engineering/true-react-common-ui-kit 3.41.0 → 3.42.0

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 (101) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +7 -0
  3. package/dist/components/FiltersPane/FiltersPane.stories.d.ts +2 -1
  4. package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.styles.d.ts +1 -1
  5. package/dist/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.d.ts +1 -1
  6. package/dist/components/FiltersPane/types.d.ts +1 -0
  7. package/dist/components/Input/Input.styles.d.ts +1 -1
  8. package/dist/components/SearchInput/SearchInput.stories.d.ts +1 -1
  9. package/dist/components/Select/Select.styles.d.ts +3 -3
  10. package/dist/true-react-common-ui-kit.js +74 -59
  11. package/dist/true-react-common-ui-kit.js.map +1 -1
  12. package/dist/true-react-common-ui-kit.umd.cjs +74 -59
  13. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  14. package/package.json +99 -98
  15. package/src/components/AccountInfo/AccountInfo.stories.tsx +32 -32
  16. package/src/components/AccountInfo/AccountInfo.tsx +80 -80
  17. package/src/components/AddButton/AddButton.stories.tsx +21 -21
  18. package/src/components/AddButton/AddButton.tsx +52 -52
  19. package/src/components/Colors/Colors.stories.tsx +7 -7
  20. package/src/components/DateInput/DateInput.tsx +90 -90
  21. package/src/components/DateInput/constants.ts +2 -2
  22. package/src/components/Description/Description.stories.tsx +27 -27
  23. package/src/components/Description/Description.tsx +61 -61
  24. package/src/components/FiltersPane/FiltersPane.stories.tsx +12 -0
  25. package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +166 -166
  26. package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +210 -210
  27. package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +177 -177
  28. package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.styles.ts +4 -0
  29. package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +20 -2
  30. package/src/components/FiltersPane/types.ts +1 -0
  31. package/src/components/Flag/Flag.stories.tsx +29 -29
  32. package/src/components/Flag/Flag.tsx +26 -26
  33. package/src/components/Flag/augment.d.ts +1 -1
  34. package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.ts +25 -25
  35. package/src/components/Icon/Icon.stories.tsx +86 -86
  36. package/src/components/Icon/complexIcons/augment.d.ts +1 -1
  37. package/src/components/Icon/complexIcons/avatarGreen.svg +57 -57
  38. package/src/components/Icon/complexIcons/index.ts +1 -1
  39. package/src/components/IncrementInput/IncrementInput.tsx +105 -105
  40. package/src/components/Input/types.ts +32 -32
  41. package/src/components/Modal/Modal.stories.tsx +105 -105
  42. package/src/components/MoreMenu/MoreMenu.tsx +93 -93
  43. package/src/components/MultiSelect/MultiSelect.stories.tsx +46 -46
  44. package/src/components/MultiSelect/MultiSelect.tsx +106 -106
  45. package/src/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.tsx +53 -53
  46. package/src/components/Notification/Notification.stories.tsx +55 -55
  47. package/src/components/Notification/Notification.styles.ts +57 -57
  48. package/src/components/Notification/Notification.tsx +77 -77
  49. package/src/components/Notification/types.ts +1 -1
  50. package/src/components/NumberInput/NumberInput.tsx +137 -137
  51. package/src/components/NumberInput/index.ts +1 -1
  52. package/src/components/PhoneInput/PhoneInput.tsx +214 -214
  53. package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.tsx +155 -155
  54. package/src/components/PhoneInput/types.ts +16 -16
  55. package/src/components/RadioButton/RadioButton.stories.tsx +46 -46
  56. package/src/components/RadioButton/RadioButton.tsx +57 -57
  57. package/src/components/ScrollIntoViewIfNeeded/index.ts +1 -1
  58. package/src/components/Select/constants.ts +2 -2
  59. package/src/components/Select/types.ts +1 -1
  60. package/src/components/Selector/Selector.stories.tsx +62 -62
  61. package/src/components/Selector/Selector.tsx +115 -115
  62. package/src/components/Selector/index.ts +2 -2
  63. package/src/components/Selector/types.ts +12 -12
  64. package/src/components/Skeleton/Skeleton.stories.tsx +19 -19
  65. package/src/components/SmartInput/SmartInput.stories.tsx +52 -52
  66. package/src/components/SmartInput/SmartInput.tsx +116 -116
  67. package/src/components/SmartInput/constants.ts +91 -91
  68. package/src/components/SmartInput/helpers.ts +26 -26
  69. package/src/components/SmartInput/types.ts +18 -18
  70. package/src/components/Status/Status.stories.tsx +73 -73
  71. package/src/components/Status/Status.styles.ts +143 -143
  72. package/src/components/Status/Status.tsx +49 -49
  73. package/src/components/Status/constants.ts +11 -11
  74. package/src/components/Status/index.ts +3 -3
  75. package/src/components/Status/types.ts +5 -5
  76. package/src/components/Switch/Switch.stories.tsx +40 -40
  77. package/src/components/Switch/Switch.tsx +75 -75
  78. package/src/components/TextWithInfo/TextWithInfo.stories.tsx +53 -53
  79. package/src/components/TextWithInfo/TextWithInfo.tsx +62 -62
  80. package/src/components/TextWithTooltip/TextWithTooltip.stories.tsx +58 -58
  81. package/src/components/TextWithTooltip/TextWithTooltip.tsx +156 -156
  82. package/src/components/ThemedPreloader/ThemedPreloader.stories.tsx +41 -41
  83. package/src/components/ThemedPreloader/ThemedPreloader.tsx +54 -54
  84. package/src/components/ThemedPreloader/components/DefaultPreloader/index.ts +1 -1
  85. package/src/components/Toaster/Toaster.stories.tsx +30 -30
  86. package/src/components/Tooltip/Tooltip.stories.tsx +19 -19
  87. package/src/components/Tooltip/Tooltip.tsx +35 -35
  88. package/src/components/Tooltip/types.ts +1 -1
  89. package/src/components/WithPopup/WithPopup.styles.ts +45 -45
  90. package/src/components/WithPopup/WithPopup.tsx +184 -184
  91. package/src/components/WithTooltip/WithTooltip.stories.tsx +56 -56
  92. package/src/components/WithTooltip/WithTooltip.styles.ts +7 -7
  93. package/src/components/WithTooltip/WithTooltip.tsx +67 -67
  94. package/src/components/WithTooltip/index.ts +2 -2
  95. package/src/components/index.ts +46 -46
  96. package/src/helpers/popper-helpers.ts +17 -17
  97. package/src/hooks/use-dropdown.ts +84 -84
  98. package/src/hooks/use-is-mounted.ts +15 -15
  99. package/src/theme/helpers.ts +76 -76
  100. package/src/theme/types.ts +158 -158
  101. package/src/vite-env.d.ts +1 -1
@@ -1,184 +1,184 @@
1
- import { FC, useState } from 'react';
2
- import clsx from 'clsx';
3
- import {
4
- addDataTestId,
5
- applyAction,
6
- stopPropagation,
7
- addDataAttributes,
8
- } from '@true-engineering/true-react-platform-helpers';
9
- import {
10
- autoUpdate,
11
- useFloating,
12
- useClick,
13
- useDismiss,
14
- useHover,
15
- useInteractions,
16
- Placement,
17
- Middleware,
18
- FloatingPortal,
19
- offset,
20
- flip,
21
- useTransitionStatus,
22
- OffsetOptions,
23
- UseHoverProps,
24
- safePolygon,
25
- useFocus,
26
- } from '@floating-ui/react';
27
- import { ICommonProps, IRenderNode } from '../../types';
28
- import { DEFAULT_OFFSET } from './constants';
29
- import {
30
- IPopupEventType,
31
- IReferenceProps,
32
- IWithPopupChildrenProps,
33
- IWithPopupToggleEvent,
34
- IWithPopupTriggerProps,
35
- } from './types';
36
- import { useStyles, IWithPopupStyles } from './WithPopup.styles';
37
-
38
- export interface IWithPopupProps extends ICommonProps<IWithPopupStyles> {
39
- trigger: IRenderNode<IWithPopupTriggerProps>;
40
- children: IRenderNode<IWithPopupChildrenProps>;
41
- middlewares?: Middleware[];
42
- /** @default eventType === 'click' ? 'bottom-end' : 'top' */
43
- placement?: Placement;
44
- /** @default 'click' */
45
- eventType?: IPopupEventType;
46
- /** @default 0 */
47
- hoverDelay?: UseHoverProps['delay'];
48
- /** @default 6 */
49
- popupOffset?: OffsetOptions;
50
- /** @default true */
51
- shouldStopPropagation?: boolean;
52
- /** @default false */
53
- shouldHideOnScroll?: boolean;
54
- /** @default true */
55
- shouldRenderInBody?: boolean;
56
- /** Должен ли WithPopup рендерить свой div-wrapper в качестве триггера
57
- * @default true, if eventType === hover */
58
- isTriggerWrapped?: boolean;
59
- /** @default true */
60
- canBeFlipped?: boolean;
61
- /** @default false */
62
- isDisabled?: boolean;
63
- onToggle?: (isActive: boolean, event?: IWithPopupToggleEvent) => void;
64
- }
65
-
66
- export const WithPopup: FC<IWithPopupProps> = ({
67
- trigger,
68
- children,
69
- middlewares = [],
70
- eventType = 'click',
71
- placement = eventType === 'click' ? 'bottom-end' : 'top',
72
- hoverDelay = 0,
73
- popupOffset = DEFAULT_OFFSET,
74
- shouldStopPropagation = true,
75
- shouldHideOnScroll = false,
76
- shouldRenderInBody = true,
77
- canBeFlipped = true,
78
- isTriggerWrapped = eventType === 'hover',
79
- isDisabled = false,
80
- tweakStyles,
81
- data,
82
- testId,
83
- onToggle,
84
- }) => {
85
- const classes = useStyles({ theme: tweakStyles });
86
-
87
- const [isOpen, setIsOpen] = useState(false);
88
-
89
- const handleToggle = (isActive: boolean, event?: IWithPopupToggleEvent) => {
90
- event?.stopPropagation();
91
- if (!isDisabled) {
92
- onToggle?.(isActive, event);
93
- setIsOpen(isActive);
94
- }
95
- };
96
-
97
- const handleClose = (event?: IWithPopupToggleEvent) => {
98
- handleToggle(false, event);
99
- };
100
-
101
- const { refs, floatingStyles, context } = useFloating({
102
- open: isOpen,
103
- middleware: [
104
- offset(popupOffset),
105
- canBeFlipped && flip({ fallbackAxisSideDirection: 'start' }),
106
- ...middlewares,
107
- ],
108
- whileElementsMounted: autoUpdate,
109
- placement,
110
- onOpenChange: handleToggle,
111
- });
112
-
113
- const hover = useHover(context, {
114
- enabled: eventType === 'hover',
115
- delay: typeof hoverDelay === 'number' ? { open: hoverDelay, close: 0 } : hoverDelay,
116
- handleClose: safePolygon(),
117
- });
118
-
119
- const focus = useFocus(context, { enabled: eventType === 'hover' });
120
-
121
- const click = useClick(context, { enabled: eventType === 'click' });
122
-
123
- const dismiss = useDismiss(context, {
124
- enabled: eventType === 'click',
125
- ancestorScroll: shouldHideOnScroll,
126
- });
127
-
128
- const { getFloatingProps, getReferenceProps } = useInteractions([hover, click, focus, dismiss]);
129
-
130
- const { isMounted, status } = useTransitionStatus(context, { duration: { close: 500 } });
131
-
132
- const referenceProps: IReferenceProps = getReferenceProps({
133
- ref: refs.setReference,
134
- ...(shouldStopPropagation && {
135
- onClick: stopPropagation,
136
- }),
137
- });
138
-
139
- const triggerElement = applyAction(trigger, {
140
- referenceProps: !isTriggerWrapped ? referenceProps : undefined,
141
- triggerProps: {
142
- isActive: isOpen,
143
- isDisabled,
144
- ...(!isTriggerWrapped && { data, testId, ...referenceProps }),
145
- },
146
- });
147
-
148
- return (
149
- <>
150
- {isTriggerWrapped ? (
151
- <div
152
- className={clsx(classes.trigger, {
153
- [classes.clickable]: eventType === 'click',
154
- [classes.disabled]: isDisabled,
155
- [classes.active]: isOpen,
156
- })}
157
- {...referenceProps}
158
- {...addDataTestId(testId)}
159
- {...addDataAttributes(data)}
160
- >
161
- {triggerElement}
162
- </div>
163
- ) : (
164
- triggerElement
165
- )}
166
- {isMounted && (
167
- <FloatingPortal
168
- root={!shouldRenderInBody ? (refs.reference.current as HTMLDivElement) : undefined}
169
- >
170
- <div
171
- style={floatingStyles}
172
- className={classes.popup}
173
- ref={refs.setFloating}
174
- {...getFloatingProps()}
175
- >
176
- <div className={classes[`dropdown-${status}`]}>
177
- {applyAction(children, { onClose: handleClose })}
178
- </div>
179
- </div>
180
- </FloatingPortal>
181
- )}
182
- </>
183
- );
184
- };
1
+ import { FC, useState } from 'react';
2
+ import clsx from 'clsx';
3
+ import {
4
+ addDataTestId,
5
+ applyAction,
6
+ stopPropagation,
7
+ addDataAttributes,
8
+ } from '@true-engineering/true-react-platform-helpers';
9
+ import {
10
+ autoUpdate,
11
+ useFloating,
12
+ useClick,
13
+ useDismiss,
14
+ useHover,
15
+ useInteractions,
16
+ Placement,
17
+ Middleware,
18
+ FloatingPortal,
19
+ offset,
20
+ flip,
21
+ useTransitionStatus,
22
+ OffsetOptions,
23
+ UseHoverProps,
24
+ safePolygon,
25
+ useFocus,
26
+ } from '@floating-ui/react';
27
+ import { ICommonProps, IRenderNode } from '../../types';
28
+ import { DEFAULT_OFFSET } from './constants';
29
+ import {
30
+ IPopupEventType,
31
+ IReferenceProps,
32
+ IWithPopupChildrenProps,
33
+ IWithPopupToggleEvent,
34
+ IWithPopupTriggerProps,
35
+ } from './types';
36
+ import { useStyles, IWithPopupStyles } from './WithPopup.styles';
37
+
38
+ export interface IWithPopupProps extends ICommonProps<IWithPopupStyles> {
39
+ trigger: IRenderNode<IWithPopupTriggerProps>;
40
+ children: IRenderNode<IWithPopupChildrenProps>;
41
+ middlewares?: Middleware[];
42
+ /** @default eventType === 'click' ? 'bottom-end' : 'top' */
43
+ placement?: Placement;
44
+ /** @default 'click' */
45
+ eventType?: IPopupEventType;
46
+ /** @default 0 */
47
+ hoverDelay?: UseHoverProps['delay'];
48
+ /** @default 6 */
49
+ popupOffset?: OffsetOptions;
50
+ /** @default true */
51
+ shouldStopPropagation?: boolean;
52
+ /** @default false */
53
+ shouldHideOnScroll?: boolean;
54
+ /** @default true */
55
+ shouldRenderInBody?: boolean;
56
+ /** Должен ли WithPopup рендерить свой div-wrapper в качестве триггера
57
+ * @default true, if eventType === hover */
58
+ isTriggerWrapped?: boolean;
59
+ /** @default true */
60
+ canBeFlipped?: boolean;
61
+ /** @default false */
62
+ isDisabled?: boolean;
63
+ onToggle?: (isActive: boolean, event?: IWithPopupToggleEvent) => void;
64
+ }
65
+
66
+ export const WithPopup: FC<IWithPopupProps> = ({
67
+ trigger,
68
+ children,
69
+ middlewares = [],
70
+ eventType = 'click',
71
+ placement = eventType === 'click' ? 'bottom-end' : 'top',
72
+ hoverDelay = 0,
73
+ popupOffset = DEFAULT_OFFSET,
74
+ shouldStopPropagation = true,
75
+ shouldHideOnScroll = false,
76
+ shouldRenderInBody = true,
77
+ canBeFlipped = true,
78
+ isTriggerWrapped = eventType === 'hover',
79
+ isDisabled = false,
80
+ tweakStyles,
81
+ data,
82
+ testId,
83
+ onToggle,
84
+ }) => {
85
+ const classes = useStyles({ theme: tweakStyles });
86
+
87
+ const [isOpen, setIsOpen] = useState(false);
88
+
89
+ const handleToggle = (isActive: boolean, event?: IWithPopupToggleEvent) => {
90
+ event?.stopPropagation();
91
+ if (!isDisabled) {
92
+ onToggle?.(isActive, event);
93
+ setIsOpen(isActive);
94
+ }
95
+ };
96
+
97
+ const handleClose = (event?: IWithPopupToggleEvent) => {
98
+ handleToggle(false, event);
99
+ };
100
+
101
+ const { refs, floatingStyles, context } = useFloating({
102
+ open: isOpen,
103
+ middleware: [
104
+ offset(popupOffset),
105
+ canBeFlipped && flip({ fallbackAxisSideDirection: 'start' }),
106
+ ...middlewares,
107
+ ],
108
+ whileElementsMounted: autoUpdate,
109
+ placement,
110
+ onOpenChange: handleToggle,
111
+ });
112
+
113
+ const hover = useHover(context, {
114
+ enabled: eventType === 'hover',
115
+ delay: typeof hoverDelay === 'number' ? { open: hoverDelay, close: 0 } : hoverDelay,
116
+ handleClose: safePolygon(),
117
+ });
118
+
119
+ const focus = useFocus(context, { enabled: eventType === 'hover' });
120
+
121
+ const click = useClick(context, { enabled: eventType === 'click' });
122
+
123
+ const dismiss = useDismiss(context, {
124
+ enabled: eventType === 'click',
125
+ ancestorScroll: shouldHideOnScroll,
126
+ });
127
+
128
+ const { getFloatingProps, getReferenceProps } = useInteractions([hover, click, focus, dismiss]);
129
+
130
+ const { isMounted, status } = useTransitionStatus(context, { duration: { close: 500 } });
131
+
132
+ const referenceProps: IReferenceProps = getReferenceProps({
133
+ ref: refs.setReference,
134
+ ...(shouldStopPropagation && {
135
+ onClick: stopPropagation,
136
+ }),
137
+ });
138
+
139
+ const triggerElement = applyAction(trigger, {
140
+ referenceProps: !isTriggerWrapped ? referenceProps : undefined,
141
+ triggerProps: {
142
+ isActive: isOpen,
143
+ isDisabled,
144
+ ...(!isTriggerWrapped && { data, testId, ...referenceProps }),
145
+ },
146
+ });
147
+
148
+ return (
149
+ <>
150
+ {isTriggerWrapped ? (
151
+ <div
152
+ className={clsx(classes.trigger, {
153
+ [classes.clickable]: eventType === 'click',
154
+ [classes.disabled]: isDisabled,
155
+ [classes.active]: isOpen,
156
+ })}
157
+ {...referenceProps}
158
+ {...addDataTestId(testId)}
159
+ {...addDataAttributes(data)}
160
+ >
161
+ {triggerElement}
162
+ </div>
163
+ ) : (
164
+ triggerElement
165
+ )}
166
+ {isMounted && (
167
+ <FloatingPortal
168
+ root={!shouldRenderInBody ? (refs.reference.current as HTMLDivElement) : undefined}
169
+ >
170
+ <div
171
+ style={floatingStyles}
172
+ className={classes.popup}
173
+ ref={refs.setFloating}
174
+ {...getFloatingProps()}
175
+ >
176
+ <div className={classes[`dropdown-${status}`]}>
177
+ {applyAction(children, { onClose: handleClose })}
178
+ </div>
179
+ </div>
180
+ </FloatingPortal>
181
+ )}
182
+ </>
183
+ );
184
+ };
@@ -1,56 +1,56 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
- import { WithTooltip } from './WithTooltip';
3
-
4
- const positions = [
5
- 'top',
6
- 'bottom',
7
- 'right',
8
- 'left',
9
- 'top-start',
10
- 'top-end',
11
- 'bottom-start',
12
- 'bottom-end',
13
- 'right-start',
14
- 'right-end',
15
- 'left-start',
16
- 'left-end',
17
- ];
18
-
19
- const meta: Meta<typeof WithTooltip> = {
20
- title: 'Data Display/WithTooltip',
21
- component: WithTooltip,
22
- argTypes: {
23
- placement: { control: 'select', options: positions },
24
- tooltipView: { control: 'inline-radio', options: ['tooltip', 'hint'] },
25
- tooltipType: { control: 'inline-radio', options: ['info', 'error'] },
26
- eventType: { control: 'inline-radio', options: ['hover', 'click'] },
27
- },
28
- };
29
- export default meta;
30
- type IStory = StoryObj<typeof WithTooltip>;
31
-
32
- export const Default: IStory = {
33
- args: {
34
- children: 'Наведи на меня - появится тултип',
35
- tooltipText: 'Текст тултипа',
36
- placement: 'top',
37
- tooltipView: 'tooltip',
38
- tooltipType: 'info',
39
- eventType: 'hover',
40
- isDisabled: false,
41
- shouldRenderInBody: true,
42
- },
43
- render: (args) => (
44
- <div
45
- style={{
46
- display: 'flex',
47
- alignItems: 'center',
48
- justifyContent: 'center',
49
- width: 600,
50
- height: 400,
51
- }}
52
- >
53
- <WithTooltip {...args} />
54
- </div>
55
- ),
56
- };
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { WithTooltip } from './WithTooltip';
3
+
4
+ const positions = [
5
+ 'top',
6
+ 'bottom',
7
+ 'right',
8
+ 'left',
9
+ 'top-start',
10
+ 'top-end',
11
+ 'bottom-start',
12
+ 'bottom-end',
13
+ 'right-start',
14
+ 'right-end',
15
+ 'left-start',
16
+ 'left-end',
17
+ ];
18
+
19
+ const meta: Meta<typeof WithTooltip> = {
20
+ title: 'Data Display/WithTooltip',
21
+ component: WithTooltip,
22
+ argTypes: {
23
+ placement: { control: 'select', options: positions },
24
+ tooltipView: { control: 'inline-radio', options: ['tooltip', 'hint'] },
25
+ tooltipType: { control: 'inline-radio', options: ['info', 'error'] },
26
+ eventType: { control: 'inline-radio', options: ['hover', 'click'] },
27
+ },
28
+ };
29
+ export default meta;
30
+ type IStory = StoryObj<typeof WithTooltip>;
31
+
32
+ export const Default: IStory = {
33
+ args: {
34
+ children: 'Наведи на меня - появится тултип',
35
+ tooltipText: 'Текст тултипа',
36
+ placement: 'top',
37
+ tooltipView: 'tooltip',
38
+ tooltipType: 'info',
39
+ eventType: 'hover',
40
+ isDisabled: false,
41
+ shouldRenderInBody: true,
42
+ },
43
+ render: (args) => (
44
+ <div
45
+ style={{
46
+ display: 'flex',
47
+ alignItems: 'center',
48
+ justifyContent: 'center',
49
+ width: 600,
50
+ height: 400,
51
+ }}
52
+ >
53
+ <WithTooltip {...args} />
54
+ </div>
55
+ ),
56
+ };
@@ -1,7 +1,7 @@
1
- import { ITooltipStyles } from '../Tooltip';
2
- import { IWithPopupStyles } from '../WithPopup';
3
-
4
- export interface IWithTooltipStyles {
5
- tweakWithPopup?: IWithPopupStyles;
6
- tweakTooltip?: ITooltipStyles;
7
- }
1
+ import { ITooltipStyles } from '../Tooltip';
2
+ import { IWithPopupStyles } from '../WithPopup';
3
+
4
+ export interface IWithTooltipStyles {
5
+ tweakWithPopup?: IWithPopupStyles;
6
+ tweakTooltip?: ITooltipStyles;
7
+ }
@@ -1,67 +1,67 @@
1
- import { FC } from 'react';
2
- import { getTestId, isReactNodeNotEmpty } from '@true-engineering/true-react-platform-helpers';
3
- import { useTweakStyles } from '../../hooks';
4
- import { ICommonProps } from '../../types';
5
- import { ITooltipProps, Tooltip } from '../Tooltip';
6
- import { IWithPopupProps, WithPopup } from '../WithPopup';
7
- import { IWithTooltipStyles } from './WithTooltip.styles';
8
-
9
- export interface IWithTooltipProps
10
- extends Omit<
11
- IWithPopupProps,
12
- 'trigger' | 'children' | 'placement' | 'eventType' | 'isTriggerWrapped' | 'tweakStyles'
13
- >,
14
- ICommonProps<IWithTooltipStyles> {
15
- children: IWithPopupProps['trigger'];
16
- /** @default 'hover' */
17
- eventType?: IWithPopupProps['eventType'];
18
- /** @default 'top' */
19
- placement?: IWithPopupProps['placement'];
20
- tooltipText?: ITooltipProps['text'];
21
- /** @default 'tooltip' */
22
- tooltipView?: ITooltipProps['view'];
23
- /** @default 'info' */
24
- tooltipType?: ITooltipProps['type'];
25
- }
26
-
27
- export const WithTooltip: FC<IWithTooltipProps> = ({
28
- children,
29
- eventType = 'hover',
30
- placement = 'top',
31
- tooltipText,
32
- tooltipView = 'tooltip',
33
- tooltipType = 'info',
34
- isDisabled = false,
35
- tweakStyles,
36
- ...restProps
37
- }) => {
38
- const tweakWithPopupStyles = useTweakStyles({
39
- tweakStyles,
40
- className: 'tweakWithPopup',
41
- });
42
-
43
- const tweakTooltipStyles = useTweakStyles({
44
- tweakStyles,
45
- className: 'tweakTooltip',
46
- });
47
-
48
- return (
49
- <WithPopup
50
- trigger={children}
51
- placement={placement}
52
- eventType={eventType}
53
- isTriggerWrapped
54
- isDisabled={isDisabled || !isReactNodeNotEmpty(tooltipText)}
55
- tweakStyles={tweakWithPopupStyles}
56
- {...restProps}
57
- >
58
- <Tooltip
59
- view={tooltipView}
60
- type={tooltipType}
61
- text={tooltipText}
62
- tweakStyles={tweakTooltipStyles}
63
- testId={getTestId(restProps.testId, 'tooltip')}
64
- />
65
- </WithPopup>
66
- );
67
- };
1
+ import { FC } from 'react';
2
+ import { getTestId, isReactNodeNotEmpty } from '@true-engineering/true-react-platform-helpers';
3
+ import { useTweakStyles } from '../../hooks';
4
+ import { ICommonProps } from '../../types';
5
+ import { ITooltipProps, Tooltip } from '../Tooltip';
6
+ import { IWithPopupProps, WithPopup } from '../WithPopup';
7
+ import { IWithTooltipStyles } from './WithTooltip.styles';
8
+
9
+ export interface IWithTooltipProps
10
+ extends Omit<
11
+ IWithPopupProps,
12
+ 'trigger' | 'children' | 'placement' | 'eventType' | 'isTriggerWrapped' | 'tweakStyles'
13
+ >,
14
+ ICommonProps<IWithTooltipStyles> {
15
+ children: IWithPopupProps['trigger'];
16
+ /** @default 'hover' */
17
+ eventType?: IWithPopupProps['eventType'];
18
+ /** @default 'top' */
19
+ placement?: IWithPopupProps['placement'];
20
+ tooltipText?: ITooltipProps['text'];
21
+ /** @default 'tooltip' */
22
+ tooltipView?: ITooltipProps['view'];
23
+ /** @default 'info' */
24
+ tooltipType?: ITooltipProps['type'];
25
+ }
26
+
27
+ export const WithTooltip: FC<IWithTooltipProps> = ({
28
+ children,
29
+ eventType = 'hover',
30
+ placement = 'top',
31
+ tooltipText,
32
+ tooltipView = 'tooltip',
33
+ tooltipType = 'info',
34
+ isDisabled = false,
35
+ tweakStyles,
36
+ ...restProps
37
+ }) => {
38
+ const tweakWithPopupStyles = useTweakStyles({
39
+ tweakStyles,
40
+ className: 'tweakWithPopup',
41
+ });
42
+
43
+ const tweakTooltipStyles = useTweakStyles({
44
+ tweakStyles,
45
+ className: 'tweakTooltip',
46
+ });
47
+
48
+ return (
49
+ <WithPopup
50
+ trigger={children}
51
+ placement={placement}
52
+ eventType={eventType}
53
+ isTriggerWrapped
54
+ isDisabled={isDisabled || !isReactNodeNotEmpty(tooltipText)}
55
+ tweakStyles={tweakWithPopupStyles}
56
+ {...restProps}
57
+ >
58
+ <Tooltip
59
+ view={tooltipView}
60
+ type={tooltipType}
61
+ text={tooltipText}
62
+ tweakStyles={tweakTooltipStyles}
63
+ testId={getTestId(restProps.testId, 'tooltip')}
64
+ />
65
+ </WithPopup>
66
+ );
67
+ };
@@ -1,2 +1,2 @@
1
- export * from './WithTooltip';
2
- export type { IWithTooltipStyles } from './WithTooltip.styles';
1
+ export * from './WithTooltip';
2
+ export type { IWithTooltipStyles } from './WithTooltip.styles';