@true-engineering/true-react-common-ui-kit 3.15.3 → 3.16.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 (26) hide show
  1. package/README.md +16 -0
  2. package/dist/components/FiltersPane/FiltersPane.styles.d.ts +2 -0
  3. package/dist/components/FiltersPane/components/Filter/Filter.d.ts +2 -7
  4. package/dist/components/FiltersPane/components/FilterSelect/FilterSelect.d.ts +2 -1
  5. package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.d.ts +2 -3
  6. package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.styles.d.ts +1 -1
  7. package/dist/components/FiltersPane/components/FilterWrapper/helpers.d.ts +1 -0
  8. package/dist/components/NewMoreMenu/NewMoreMenu.d.ts +1 -3
  9. package/dist/components/WithPopup/WithPopup.d.ts +5 -4
  10. package/dist/components/WithPopup/types.d.ts +3 -1
  11. package/dist/true-react-common-ui-kit.js +1078 -1238
  12. package/dist/true-react-common-ui-kit.js.map +1 -1
  13. package/dist/true-react-common-ui-kit.umd.cjs +1077 -1237
  14. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  15. package/package.json +1 -1
  16. package/src/components/FiltersPane/FiltersPane.styles.ts +5 -1
  17. package/src/components/FiltersPane/FiltersPane.tsx +9 -5
  18. package/src/components/FiltersPane/components/Filter/Filter.tsx +53 -142
  19. package/src/components/FiltersPane/components/FilterSelect/FilterSelect.tsx +10 -3
  20. package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.styles.ts +6 -16
  21. package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +72 -114
  22. package/src/components/FiltersPane/components/FilterWrapper/helpers.ts +14 -0
  23. package/src/components/NewMoreMenu/NewMoreMenu.tsx +8 -13
  24. package/src/components/TextArea/TextArea.styles.ts +2 -2
  25. package/src/components/WithPopup/WithPopup.tsx +16 -22
  26. package/src/components/WithPopup/types.ts +4 -1
@@ -12,7 +12,12 @@ import { useStyles, INewMoreMenuStyles } from './NewMoreMenu.styles';
12
12
  export interface INewMoreMenuProps
13
13
  extends Pick<
14
14
  IWithPopupProps,
15
- 'middlewares' | 'shouldHideOnScroll' | 'shouldRenderInBody' | 'canBeFlipped'
15
+ | 'placement'
16
+ | 'middlewares'
17
+ | 'shouldHideOnScroll'
18
+ | 'shouldRenderInBody'
19
+ | 'canBeFlipped'
20
+ | 'onToggle'
16
21
  >,
17
22
  ICommonProps<INewMoreMenuStyles> {
18
23
  items: IListItem[];
@@ -20,8 +25,6 @@ export interface INewMoreMenuProps
20
25
  isDisabled?: boolean;
21
26
  /** @default true */
22
27
  hasDefaultStateBackground?: boolean;
23
- /** @default 'bottom-end' */
24
- placement?: IWithPopupProps['placement'];
25
28
  }
26
29
 
27
30
  export const NewMoreMenu: FC<INewMoreMenuProps> = ({
@@ -30,12 +33,8 @@ export const NewMoreMenu: FC<INewMoreMenuProps> = ({
30
33
  hasDefaultStateBackground = true,
31
34
  data,
32
35
  testId,
33
- placement,
34
- middlewares,
35
- shouldHideOnScroll,
36
- shouldRenderInBody,
37
- canBeFlipped,
38
36
  tweakStyles,
37
+ ...props
39
38
  }) => {
40
39
  const classes = useStyles({ theme: tweakStyles });
41
40
 
@@ -55,13 +54,9 @@ export const NewMoreMenu: FC<INewMoreMenuProps> = ({
55
54
 
56
55
  return (
57
56
  <WithPopup
58
- placement={placement}
59
- middlewares={middlewares}
60
- shouldHideOnScroll={shouldHideOnScroll}
61
- shouldRenderInBody={shouldRenderInBody}
62
- canBeFlipped={canBeFlipped}
63
57
  isDisabled={isButtonDisabled}
64
58
  tweakStyles={tweakWithPopupStyles}
59
+ {...props}
65
60
  trigger={({ isActive }) => (
66
61
  <button
67
62
  className={clsx(classes.button, {
@@ -32,7 +32,7 @@ export const useStyles = createThemedStyles('TextArea', {
32
32
  fontFamily: 'inherit',
33
33
  fontSize: 16,
34
34
  padding: [14, PADDING_X, 8],
35
- scrollPadding: [14, 0, 8],
35
+ scrollPadding: '14px 0 8px',
36
36
  transition: animations.defaultTransition,
37
37
  transitionProperty: 'background-color',
38
38
  border: 'none',
@@ -79,7 +79,7 @@ export const useStyles = createThemedStyles('TextArea', {
79
79
  withFloatingLabel: {
80
80
  '& $textarea, &::after': {
81
81
  paddingTop: 24,
82
- scrollPaddingTop: 24,
82
+ scrollPaddingTop: '24px',
83
83
  },
84
84
  },
85
85
 
@@ -1,4 +1,4 @@
1
- import { FC, ReactNode, useState, MouseEvent, useMemo } from 'react';
1
+ import { FC, ReactNode, useState, MouseEvent } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import { addDataTestId, isFunction } from '@true-engineering/true-react-platform-helpers';
4
4
  import {
@@ -13,16 +13,19 @@ import {
13
13
  FloatingPortal,
14
14
  offset,
15
15
  flip,
16
+ useTransitionStatus,
17
+ OffsetOptions,
18
+ UseHoverProps,
16
19
  } from '@floating-ui/react';
17
20
  import { addDataAttributes } from '../../helpers';
18
21
  import { ICommonProps } from '../../types';
19
22
  import { DEFAULT_OFFSET } from './constants';
20
- import { IPopupEventType } from './types';
23
+ import { IPopupEventType, ITransitionStatus } from './types';
21
24
  import { useStyles, IWithPopupStyles } from './WithPopup.styles';
22
25
 
23
26
  export interface IWithPopupProps extends ICommonProps<IWithPopupStyles> {
24
27
  trigger: ReactNode | FC<{ isActive: boolean }>;
25
- children: ReactNode | FC<{ onClose: () => void }>;
28
+ children: ReactNode | FC<{ status: ITransitionStatus; onClose: () => void }>;
26
29
  middlewares?: Middleware[];
27
30
  /** @default eventType === 'click' ? 'bottom-end' : 'top' */
28
31
  placement?: Placement;
@@ -33,9 +36,9 @@ export interface IWithPopupProps extends ICommonProps<IWithPopupStyles> {
33
36
  /** @default 'click' */
34
37
  eventType?: IPopupEventType;
35
38
  /** @default 0 */
36
- hoverDelay?: number;
39
+ hoverDelay?: UseHoverProps['delay'];
37
40
  /** @default 6 */
38
- popupOffset?: number;
41
+ popupOffset?: OffsetOptions;
39
42
  /** @default false */
40
43
  canBeFlipped?: boolean;
41
44
  /** @default false */
@@ -46,7 +49,7 @@ export interface IWithPopupProps extends ICommonProps<IWithPopupStyles> {
46
49
  export const WithPopup: FC<IWithPopupProps> = ({
47
50
  trigger,
48
51
  children,
49
- middlewares: initialMiddlewares,
52
+ middlewares = [],
50
53
  eventType = 'click',
51
54
  placement = eventType === 'click' ? 'bottom-end' : 'top',
52
55
  shouldHideOnScroll = false,
@@ -64,14 +67,6 @@ export const WithPopup: FC<IWithPopupProps> = ({
64
67
 
65
68
  const [isOpen, setIsOpen] = useState(false);
66
69
 
67
- const Trigger = trigger;
68
- const Popup = children;
69
-
70
- const middleware = useMemo(
71
- () => [offset(popupOffset), ...(canBeFlipped ? [flip()] : []), ...(initialMiddlewares ?? [])],
72
- [popupOffset, canBeFlipped, initialMiddlewares],
73
- );
74
-
75
70
  const handleToggle = (isActive: boolean, event?: MouseEvent | Event) => {
76
71
  event?.stopPropagation();
77
72
  if (!isDisabled) {
@@ -86,16 +81,13 @@ export const WithPopup: FC<IWithPopupProps> = ({
86
81
 
87
82
  const { refs, floatingStyles, context } = useFloating({
88
83
  open: isOpen,
89
- middleware,
84
+ middleware: [offset(popupOffset), ...(canBeFlipped ? [flip()] : []), ...middlewares],
90
85
  whileElementsMounted: autoUpdate,
91
86
  placement,
92
87
  onOpenChange: handleToggle,
93
88
  });
94
89
 
95
- const hover = useHover(context, {
96
- enabled: eventType === 'hover',
97
- delay: { open: hoverDelay },
98
- });
90
+ const hover = useHover(context, { enabled: eventType === 'hover', delay: hoverDelay });
99
91
  const click = useClick(context, { enabled: eventType === 'click', toggle: false });
100
92
  const dismiss = useDismiss(context, {
101
93
  enabled: eventType === 'click',
@@ -104,6 +96,8 @@ export const WithPopup: FC<IWithPopupProps> = ({
104
96
 
105
97
  const { getFloatingProps } = useInteractions([hover, click, dismiss]);
106
98
 
99
+ const { isMounted, status } = useTransitionStatus(context);
100
+
107
101
  return (
108
102
  <div
109
103
  ref={refs.setReference}
@@ -116,10 +110,10 @@ export const WithPopup: FC<IWithPopupProps> = ({
116
110
  onClick={eventType === 'click' ? (e) => handleToggle(!isOpen, e) : undefined}
117
111
  {...addDataTestId(testId, 'trigger')}
118
112
  >
119
- {isFunction(Trigger) ? <Trigger isActive={isOpen} /> : Trigger}
113
+ {isFunction(trigger) ? trigger({ isActive: isOpen }) : trigger}
120
114
  </div>
121
115
 
122
- {isOpen && (
116
+ {isMounted && (
123
117
  <FloatingPortal
124
118
  root={!shouldRenderInBody ? (refs.reference.current as HTMLDivElement) : undefined}
125
119
  >
@@ -129,7 +123,7 @@ export const WithPopup: FC<IWithPopupProps> = ({
129
123
  ref={refs.setFloating}
130
124
  {...getFloatingProps()}
131
125
  >
132
- {isFunction(Popup) ? <Popup onClose={handleClose} /> : Popup}
126
+ {isFunction(children) ? children({ status, onClose: handleClose }) : children}
133
127
  </div>
134
128
  </FloatingPortal>
135
129
  )}
@@ -1,3 +1,6 @@
1
- import { POPUP_EVENT_TYPES } from './constants';
1
+ import type { useTransitionStatus } from '@floating-ui/react';
2
+ import type { POPUP_EVENT_TYPES } from './constants';
2
3
 
3
4
  export type IPopupEventType = (typeof POPUP_EVENT_TYPES)[number];
5
+
6
+ export type ITransitionStatus = ReturnType<typeof useTransitionStatus>['status'];