@true-engineering/true-react-common-ui-kit 3.17.0 → 3.18.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@true-engineering/true-react-common-ui-kit",
3
- "version": "3.17.0",
3
+ "version": "3.18.0",
4
4
  "description": "True Engineering React UI Kit with theming support",
5
5
  "author": "True Engineering (https://trueengineering.ru)",
6
6
  "keywords": [
@@ -1,4 +1,5 @@
1
1
  import { animations, colors, createThemedStyles, ITweakStyles } from '../../../../theme';
2
+ import { IWithPopupStyles } from '../../../WithPopup';
2
3
  import type { IFilterValueViewStyles } from '../FilterValueView';
3
4
  import { FILTER_HEIGHT } from '../../FiltersPane.styles';
4
5
 
@@ -86,20 +87,9 @@ export const useStyles = createThemedStyles('FilterWrapper', {
86
87
  display: 'flex',
87
88
  minWidth: 0,
88
89
  },
89
-
90
- animationEnd: animations.slideUp['slide-up-exit'],
91
-
92
- animationStart: animations.slideUp['slide-up-enter-active'],
93
-
94
- 'dropdown-initial': { extend: 'animationEnd' },
95
- 'dropdown-open': { extend: 'animationStart' },
96
- 'dropdown-close': { extend: 'animationEnd' },
97
- 'dropdown-unmounted': { extend: 'animationEnd' },
98
90
  });
99
91
 
100
92
  export type IFilterWrapperStyles = ITweakStyles<
101
93
  typeof useStyles,
102
- {
103
- tweakValueView: IFilterValueViewStyles;
104
- }
94
+ { tweakWithPopup: IWithPopupStyles; tweakValueView: IFilterValueViewStyles }
105
95
  >;
@@ -34,6 +34,12 @@ export function FilterWrapper<Values, Key extends keyof Values>({
34
34
  }: IFilterWrapperProps<Values, Key>): JSX.Element {
35
35
  const classes = useStyles({ theme: tweakStyles });
36
36
 
37
+ const tweakWithPopupStyles = useTweakStyles({
38
+ tweakStyles,
39
+ className: 'tweakWithPopup',
40
+ currentComponentName: 'FilterWrapper',
41
+ });
42
+
37
43
  const tweakFilterValueViewStyles = useTweakStyles({
38
44
  tweakStyles,
39
45
  className: 'tweakValueView',
@@ -68,6 +74,7 @@ export function FilterWrapper<Values, Key extends keyof Values>({
68
74
  placement="bottom-start"
69
75
  canBeFlipped
70
76
  isDisabled={isBoolean || isDisabled}
77
+ tweakStyles={tweakWithPopupStyles}
71
78
  trigger={({ isActive }) => (
72
79
  <div
73
80
  className={clsx(classes.root, {
@@ -107,18 +114,16 @@ export function FilterWrapper<Values, Key extends keyof Values>({
107
114
  </div>
108
115
  )}
109
116
  >
110
- {({ onClose, status }) => (
111
- <div className={classes[`dropdown-${status}`]}>
112
- <Filter
113
- value={value}
114
- filter={filter}
115
- localeKey={localeKey}
116
- locale={locale}
117
- onClose={onClose}
118
- onChange={onChange}
119
- testId={testId}
120
- />
121
- </div>
117
+ {({ onClose }) => (
118
+ <Filter
119
+ value={value}
120
+ filter={filter}
121
+ localeKey={localeKey}
122
+ locale={locale}
123
+ onClose={onClose}
124
+ onChange={onChange}
125
+ testId={testId}
126
+ />
122
127
  )}
123
128
  </WithPopup>
124
129
  );
@@ -217,7 +217,8 @@ export function FlexibleTable<Row extends ITableRow>({
217
217
  maxWidth: itemConfig?.maxWidth,
218
218
  textAlign: itemConfig?.titleAlign ?? 'left',
219
219
  }}
220
- onClick={() => onHeadClick?.(key)}
220
+ onClick={isNotEmpty(onHeadClick) ? () => onHeadClick(key) : undefined}
221
+ {...addDataAttributes({ id: itemConfig?.shouldRenderDataId ? key : undefined })}
221
222
  >
222
223
  {isNotEmpty(TitleComponent) ? (
223
224
  <TitleComponent value={headerContent?.[key]} />
@@ -16,6 +16,27 @@ export const useStyles = createThemedStyles('WithPopup', {
16
16
  popup: {
17
17
  zIndex: 5,
18
18
  },
19
+
20
+ animationEnd: {},
21
+
22
+ animationStart: {},
23
+
24
+ 'dropdown-initial': {
25
+ extend: 'animationEnd',
26
+ },
27
+
28
+ 'dropdown-open': {
29
+ extend: 'animationStart',
30
+ },
31
+
32
+ 'dropdown-close': {
33
+ visibility: 'hidden',
34
+ extend: 'animationEnd',
35
+ },
36
+
37
+ 'dropdown-unmounted': {
38
+ extend: 'animationEnd',
39
+ },
19
40
  });
20
41
 
21
42
  export type IWithPopupStyles = ITweakStyles<typeof useStyles>;
@@ -20,12 +20,12 @@ import {
20
20
  import { addDataAttributes } from '../../helpers';
21
21
  import { ICommonProps } from '../../types';
22
22
  import { DEFAULT_OFFSET } from './constants';
23
- import { IPopupEventType, ITransitionStatus } from './types';
23
+ import { IPopupEventType } from './types';
24
24
  import { useStyles, IWithPopupStyles } from './WithPopup.styles';
25
25
 
26
26
  export interface IWithPopupProps extends ICommonProps<IWithPopupStyles> {
27
27
  trigger: ReactNode | FC<{ isActive: boolean }>;
28
- children: ReactNode | FC<{ status: ITransitionStatus; onClose: () => void }>;
28
+ children: ReactNode | FC<{ onClose: () => void }>;
29
29
  middlewares?: Middleware[];
30
30
  /** @default eventType === 'click' ? 'bottom-end' : 'top' */
31
31
  placement?: Placement;
@@ -87,7 +87,10 @@ export const WithPopup: FC<IWithPopupProps> = ({
87
87
  onOpenChange: handleToggle,
88
88
  });
89
89
 
90
- const hover = useHover(context, { enabled: eventType === 'hover', delay: hoverDelay });
90
+ const hover = useHover(context, {
91
+ enabled: eventType === 'hover',
92
+ delay: typeof hoverDelay === 'number' ? { open: hoverDelay, close: 0 } : hoverDelay,
93
+ });
91
94
  const click = useClick(context, { enabled: eventType === 'click', toggle: false });
92
95
  const dismiss = useDismiss(context, {
93
96
  enabled: eventType === 'click',
@@ -96,7 +99,7 @@ export const WithPopup: FC<IWithPopupProps> = ({
96
99
 
97
100
  const { getFloatingProps } = useInteractions([hover, click, dismiss]);
98
101
 
99
- const { isMounted, status } = useTransitionStatus(context);
102
+ const { isMounted, status } = useTransitionStatus(context, { duration: { close: 500 } });
100
103
 
101
104
  return (
102
105
  <div
@@ -123,7 +126,9 @@ export const WithPopup: FC<IWithPopupProps> = ({
123
126
  ref={refs.setFloating}
124
127
  {...getFloatingProps()}
125
128
  >
126
- {isFunction(children) ? children({ status, onClose: handleClose }) : children}
129
+ <div className={classes[`dropdown-${status}`]}>
130
+ {isFunction(children) ? children({ onClose: handleClose }) : children}
131
+ </div>
127
132
  </div>
128
133
  </FloatingPortal>
129
134
  )}
@@ -1,6 +1,3 @@
1
- import type { useTransitionStatus } from '@floating-ui/react';
2
1
  import type { POPUP_EVENT_TYPES } from './constants';
3
2
 
4
3
  export type IPopupEventType = (typeof POPUP_EVENT_TYPES)[number];
5
-
6
- export type ITransitionStatus = ReturnType<typeof useTransitionStatus>['status'];
@@ -114,6 +114,7 @@ export const helpers = {
114
114
  },
115
115
  } satisfies IUiKitHelpers;
116
116
 
117
+ export const SLIDE_UP_ANIMATION_DURATION = 150;
117
118
  const SLIDE_UP_POSITION_START = 15;
118
119
  const SLIDE_UP_POSITION_END = 0;
119
120
 
@@ -129,7 +130,7 @@ export const animations = {
129
130
  'slide-up-enter-active': {
130
131
  opacity: 1,
131
132
  transform: `translateY(${SLIDE_UP_POSITION_END}px)`,
132
- transition: '150ms ease-in-out',
133
+ transition: `${SLIDE_UP_ANIMATION_DURATION}ms ease-in-out`,
133
134
  transitionProperty: 'opacity, transform',
134
135
  },
135
136
 
@@ -141,7 +142,7 @@ export const animations = {
141
142
  'slide-up-exit': {
142
143
  opacity: 0,
143
144
  transform: `translateY(${SLIDE_UP_POSITION_START}px)`,
144
- transition: '150ms ease-in-out',
145
+ transition: `${SLIDE_UP_ANIMATION_DURATION}ms ease-in-out`,
145
146
  transitionProperty: 'opacity, transform',
146
147
  },
147
148
  },