Skip to content

Commit

Permalink
Add core and integrate it into filters
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwardBrunton committed Nov 18, 2024
1 parent c6cc6bd commit 6967472
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 157 deletions.
3 changes: 2 additions & 1 deletion packages/filter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/workspace-filter",
"version": "4.0.5",
"version": "4.0.6",
"type": "module",
"sideEffects": false,
"license": "MIT",
Expand Down Expand Up @@ -30,6 +30,7 @@
"@equinor/eds-icons": "^0.18.0",
"@equinor/eds-tokens": "^0.9.0",
"@tanstack/react-query": "^5.32.0",
"@equinor/workspace-core": "workspace:^",
"react-error-boundary": "^4.0.13",
"react-sortablejs": "^6.1.4",
"react-virtual": "^2.10.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Button, Icon, Search } from '@equinor/eds-core-react';
import { useMemo, useState } from 'react';
import { useMemo, useRef, useState } from 'react';
import { FilterClearIcon } from '../../icons';
import { FilterGroup, FilterValueType } from '../../types';

import { useClickOutside } from '@equinor/workspace-core';
import { Case, Switch } from '../../utils/Switch';
import { StyledSearchButton, StyledFilterHeaderGroup, StyledTitle, StyledWrapper } from './expandedFilterGroup.styles';
import { VirtualContainer } from '../virtualContainer/VirtualContainer';
Expand All @@ -21,6 +21,12 @@ export const ExpandedFilterGroup = ({ filterGroup, isFetching }: FilterGroupeCom
const [filterSearchValue, setFilterSearchValue] = useState('');
const [searchActive, setSearchActive] = useState(false);

const ref = useRef<HTMLDivElement>(null);
useClickOutside(ref, () => {
setSearchActive(false);
setFilterSearchValue('');
});

function handleOnChange(event: React.ChangeEvent<HTMLInputElement>) {
const { value } = event.target;
setFilterSearchValue(value);
Expand Down Expand Up @@ -50,16 +56,12 @@ export const ExpandedFilterGroup = ({ filterGroup, isFetching }: FilterGroupeCom
}

return (
<StyledWrapper>
<StyledWrapper ref={ref}>
<StyledFilterHeaderGroup isActive={hasAnyActiveFilters}>
<Switch>
<Case when={searchActive}>
<Search
autoFocus={searchActive}
onBlur={() => {
setSearchActive(false);
setFilterSearchValue('');
}}
aria-label="in filter group"
id="search-normal"
placeholder="Search"
Expand Down
2 changes: 1 addition & 1 deletion packages/power-bi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/workspace-powerbi",
"version": "3.0.8",
"version": "3.0.9",
"type": "module",
"sideEffects": false,
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/power-bi/src/lib/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, Icon, Search } from '@equinor/eds-core-react';
import { useState } from 'react';
import styled from 'styled-components';
import useClickOutside from '@equinor/workspace-core';
import { useClickOutside } from '@equinor/workspace-core';
import { FilterClearIcon } from '../../icons';
import { FilterController } from '../Filter/Filter';
import { Case, Switch } from '../switch/Switch';
Expand Down
30 changes: 0 additions & 30 deletions packages/power-bi/src/lib/hooks/useClickOutside.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/workspace-fusion/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/workspace-fusion",
"version": "9.0.18",
"version": "9.0.19",
"type": "module",
"sideEffects": false,
"license": "MIT",
Expand Down
129 changes: 13 additions & 116 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6967472

Please sign in to comment.