@true-engineering/true-react-common-ui-kit 4.0.0-alpha28 → 4.0.0-alpha29

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": "4.0.0-alpha28",
3
+ "version": "4.0.0-alpha29",
4
4
  "description": "True Engineering React UI Kit with theming support",
5
5
  "author": "True Engineering (https://trueengineering.ru)",
6
6
  "keywords": [
@@ -33,6 +33,11 @@ export const useStyles = createThemedStyles('FiltersPaneSearch', {
33
33
  },
34
34
  },
35
35
 
36
+ hasValue: {
37
+ backgroundColor: colors.CLASSIC_WHITE,
38
+ borderColor: colors.BORDER_MAIN,
39
+ },
40
+
36
41
  selectWrapper: {
37
42
  position: 'relative',
38
43
  display: 'flex',
@@ -4,6 +4,8 @@ import {
4
4
  addDataAttributes,
5
5
  addDataTestId,
6
6
  getTestId,
7
+ isArrayLikeNotEmpty,
8
+ isArrayNotEmpty,
7
9
  isNotEmpty,
8
10
  } from '@true-engineering/true-react-platform-helpers';
9
11
  import { useOnClickOutside, useTweakStyles } from '../../../../hooks';
@@ -99,6 +101,7 @@ export function FiltersPaneSearch<Value>({
99
101
  className={clsx(classes.root, {
100
102
  [classes.focused]: isInputFocused,
101
103
  [classes.disabled]: isDisabled,
104
+ [classes.hasValue]: isArrayLikeNotEmpty(value),
102
105
  })}
103
106
  ref={refRoot}
104
107
  {...addDataAttributes(data, testId)}
@@ -117,7 +120,7 @@ export function FiltersPaneSearch<Value>({
117
120
 
118
121
  <div className={classes.selectWrapper}>
119
122
  {/* Select block */}
120
- {fields.length > 0 && (
123
+ {isArrayNotEmpty(fields) && (
121
124
  <div
122
125
  className={classes.selectBlock}
123
126
  onClick={!isDisabled ? () => setIsOpen(!isOpen) : undefined}
@@ -116,13 +116,14 @@ export const WithPopup: FC<IWithPopupProps> = ({
116
116
  const classes = useStyles({ theme: tweakStyles });
117
117
 
118
118
  const [isOpen, setIsOpen] = useState(false);
119
+ const isActive = isOpen && !isDisabled;
119
120
 
120
121
  const arrowRef = useRef<SVGSVGElement>(null);
121
122
 
122
- const handleToggle = (isActive: boolean, event?: IWithPopupToggleEvent) => {
123
+ const handleToggle = (next: boolean, event?: IWithPopupToggleEvent) => {
123
124
  event?.stopPropagation();
124
- onToggle?.(isActive, event);
125
- setIsOpen(isActive);
125
+ onToggle?.(next, event);
126
+ setIsOpen(next);
126
127
  };
127
128
 
128
129
  const handleClose = (event?: IWithPopupToggleEvent) => {
@@ -130,7 +131,7 @@ export const WithPopup: FC<IWithPopupProps> = ({
130
131
  };
131
132
 
132
133
  const { refs, floatingStyles, context } = useFloating({
133
- open: isOpen && !isDisabled,
134
+ open: isActive,
134
135
  middleware: [
135
136
  offset(popupOffset),
136
137
  canBeFlipped && flip({ fallbackAxisSideDirection: 'start' }),
@@ -177,7 +178,7 @@ export const WithPopup: FC<IWithPopupProps> = ({
177
178
  const triggerElement = applyAction(trigger, {
178
179
  referenceProps: !isTriggerWrapped ? referenceProps : undefined,
179
180
  triggerProps: {
180
- isActive: isOpen,
181
+ isActive,
181
182
  isDisabled,
182
183
  ...(!isTriggerWrapped && { data, testId, ...referenceProps }),
183
184
  },
@@ -190,7 +191,7 @@ export const WithPopup: FC<IWithPopupProps> = ({
190
191
  className={clsx(classes.trigger, {
191
192
  [classes.clickable]: eventType === 'click',
192
193
  [classes.disabled]: isDisabled,
193
- [classes.active]: isOpen,
194
+ [classes.active]: isActive,
194
195
  })}
195
196
  {...referenceProps}
196
197
  {...addDataAttributes(data, testId)}