@equinor/fusion-react-filter 2.1.0-filter.8 → 2.1.1
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/LICENSE +21 -0
- package/components/package.json +1 -1
- package/dist/FilterProvider.d.ts +3 -3
- package/dist/FilterProvider.d.ts.map +1 -1
- package/dist/FilterProvider.js +7 -7
- package/dist/actions.d.ts +3 -3
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +1 -1
- package/dist/components/filter/FilterOptionHeader.d.ts +4 -4
- package/dist/components/filter/FilterOptionHeader.d.ts.map +1 -1
- package/dist/components/filter/FilterOptionHeader.js +55 -48
- package/dist/components/filter/checkbox/CheckboxFilter.d.ts +16 -6
- package/dist/components/filter/checkbox/CheckboxFilter.d.ts.map +1 -1
- package/dist/components/filter/checkbox/CheckboxFilter.js +4 -5
- package/dist/components/filter/checkbox/CheckboxFilter.style.d.ts +9 -4
- package/dist/components/filter/checkbox/CheckboxFilter.style.d.ts.map +1 -1
- package/dist/components/filter/checkbox/CheckboxFilter.style.js +21 -19
- package/dist/components/filter/checkbox/CheckboxFilterOption.d.ts +8 -7
- package/dist/components/filter/checkbox/CheckboxFilterOption.d.ts.map +1 -1
- package/dist/components/filter/checkbox/CheckboxFilterOption.js +4 -11
- package/dist/components/filter/checkbox/CheckboxFilterOption.style.d.ts +10 -2
- package/dist/components/filter/checkbox/CheckboxFilterOption.style.d.ts.map +1 -1
- package/dist/components/filter/checkbox/CheckboxFilterOption.style.js +37 -41
- package/dist/components/filter/checkbox/CheckboxFilterOptionAll.d.ts +2 -1
- package/dist/components/filter/checkbox/CheckboxFilterOptionAll.d.ts.map +1 -1
- package/dist/components/filter/checkbox/CheckboxFilterOptionAll.js +7 -8
- package/dist/components/filter/checkbox/CheckboxFilterOptions.d.ts +7 -1
- package/dist/components/filter/checkbox/CheckboxFilterOptions.d.ts.map +1 -1
- package/dist/components/filter/checkbox/CheckboxFilterOptions.js +6 -8
- package/dist/components/filter/checkbox/CheckboxFilterProvider.d.ts +9 -5
- package/dist/components/filter/checkbox/CheckboxFilterProvider.d.ts.map +1 -1
- package/dist/components/filter/checkbox/CheckboxFilterProvider.js +12 -5
- package/dist/components/filter/checkbox/context.d.ts +1 -1
- package/dist/components/filter/checkbox/context.d.ts.map +1 -1
- package/dist/components/filter/checkbox/context.js +0 -1
- package/dist/components/filter/checkbox/index.d.ts +1 -1
- package/dist/components/filter/checkbox/index.d.ts.map +1 -1
- package/dist/components/filter/checkbox/index.js +0 -1
- package/dist/components/filter/checkbox/types.d.ts +2 -2
- package/dist/components/filter/checkbox/types.d.ts.map +1 -1
- package/dist/components/filter/checkbox/types.js +0 -1
- package/dist/components/filter/index.js +0 -1
- package/dist/components/filter/search/SearchFilter.d.ts +6 -5
- package/dist/components/filter/search/SearchFilter.d.ts.map +1 -1
- package/dist/components/filter/search/SearchFilter.js +9 -8
- package/dist/components/filter/search/index.js +0 -1
- package/dist/components/filter/types.d.ts +1 -1
- package/dist/components/filter/types.d.ts.map +1 -1
- package/dist/components/filter/types.js +0 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +0 -1
- package/dist/components/misc/ClearFilterButton.d.ts +6 -4
- package/dist/components/misc/ClearFilterButton.d.ts.map +1 -1
- package/dist/components/misc/ClearFilterButton.js +8 -8
- package/dist/components/misc/FilterContainer.d.ts +7 -6
- package/dist/components/misc/FilterContainer.d.ts.map +1 -1
- package/dist/components/misc/FilterContainer.js +13 -14
- package/dist/components/misc/SelectionChips.d.ts +5 -4
- package/dist/components/misc/SelectionChips.d.ts.map +1 -1
- package/dist/components/misc/SelectionChips.js +29 -22
- package/dist/components/misc/index.js +0 -1
- package/dist/components/panel/FilterPanel.d.ts +7 -3
- package/dist/components/panel/FilterPanel.d.ts.map +1 -1
- package/dist/components/panel/FilterPanel.js +29 -30
- package/dist/components/panel/FilterPanelBar.d.ts +6 -2
- package/dist/components/panel/FilterPanelBar.d.ts.map +1 -1
- package/dist/components/panel/FilterPanelBar.js +29 -28
- package/dist/components/panel/FilterPanelFilters.d.ts +4 -4
- package/dist/components/panel/FilterPanelFilters.d.ts.map +1 -1
- package/dist/components/panel/FilterPanelFilters.js +4 -4
- package/dist/components/panel/FilterPanelProvider.d.ts +12 -12
- package/dist/components/panel/FilterPanelProvider.d.ts.map +1 -1
- package/dist/components/panel/FilterPanelProvider.js +4 -4
- package/dist/components/panel/FilterPanelSelector.d.ts +3 -3
- package/dist/components/panel/FilterPanelSelector.d.ts.map +1 -1
- package/dist/components/panel/FilterPanelSelector.js +4 -5
- package/dist/components/panel/index.js +0 -1
- package/dist/context.d.ts +1 -2
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/hooks/index.js +0 -1
- package/dist/hooks/useClearFilter.d.ts.map +1 -1
- package/dist/hooks/useClearFilter.js +4 -4
- package/dist/hooks/useFilter.d.ts +1 -1
- package/dist/hooks/useFilter.d.ts.map +1 -1
- package/dist/hooks/useFilter.js +0 -1
- package/dist/hooks/useFilterData.d.ts +4 -4
- package/dist/hooks/useFilterData.d.ts.map +1 -1
- package/dist/hooks/useFilterData.js +5 -3
- package/dist/hooks/useFilterSelection.d.ts +1 -1
- package/dist/hooks/useFilterSelection.d.ts.map +1 -1
- package/dist/hooks/useFilterSelection.js +4 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/options/FilterOptionProvider.d.ts +3 -3
- package/dist/options/FilterOptionProvider.d.ts.map +1 -1
- package/dist/options/FilterOptionProvider.js +2 -3
- package/dist/options/actions.d.ts +2 -2
- package/dist/options/actions.d.ts.map +1 -1
- package/dist/options/actions.js +0 -1
- package/dist/options/context.d.ts +1 -2
- package/dist/options/context.d.ts.map +1 -1
- package/dist/options/context.js +2 -2
- package/dist/options/create-options.d.ts +1 -1
- package/dist/options/create-options.d.ts.map +1 -1
- package/dist/options/create-options.js +3 -2
- package/dist/options/index.d.ts +1 -1
- package/dist/options/index.d.ts.map +1 -1
- package/dist/options/index.js +1 -2
- package/dist/options/reducer.d.ts +11 -11
- package/dist/options/reducer.d.ts.map +1 -1
- package/dist/options/reducer.js +1 -1
- package/dist/options/search/filter-option-match.d.ts.map +1 -1
- package/dist/options/search/filter-option-match.js +0 -1
- package/dist/options/search/filter-option-search.d.ts +1 -4
- package/dist/options/search/filter-option-search.d.ts.map +1 -1
- package/dist/options/search/filter-option-search.js +3 -2
- package/dist/options/search/index.js +0 -1
- package/dist/options/search/types.d.ts +2 -2
- package/dist/options/search/types.d.ts.map +1 -1
- package/dist/options/search/types.js +0 -1
- package/dist/options/search/useFilterOptionSearch.d.ts +1 -4
- package/dist/options/search/useFilterOptionSearch.d.ts.map +1 -1
- package/dist/options/search/useFilterOptionSearch.js +0 -1
- package/dist/options/types.d.ts +11 -11
- package/dist/options/types.d.ts.map +1 -1
- package/dist/options/types.js +0 -1
- package/dist/reducers.d.ts +34 -34
- package/dist/reducers.d.ts.map +1 -1
- package/dist/reducers.js +4 -2
- package/dist/types.d.ts +12 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/options/package.json +2 -2
- package/package.json +30 -20
- package/dist/FilterProvider.js.map +0 -1
- package/dist/actions.js.map +0 -1
- package/dist/components/filter/FilterOptionHeader.js.map +0 -1
- package/dist/components/filter/checkbox/CheckboxFilter.js.map +0 -1
- package/dist/components/filter/checkbox/CheckboxFilter.style.js.map +0 -1
- package/dist/components/filter/checkbox/CheckboxFilterOption.js.map +0 -1
- package/dist/components/filter/checkbox/CheckboxFilterOption.style.js.map +0 -1
- package/dist/components/filter/checkbox/CheckboxFilterOptionAll.js.map +0 -1
- package/dist/components/filter/checkbox/CheckboxFilterOptions.js.map +0 -1
- package/dist/components/filter/checkbox/CheckboxFilterProvider.js.map +0 -1
- package/dist/components/filter/checkbox/context.js.map +0 -1
- package/dist/components/filter/checkbox/index.js.map +0 -1
- package/dist/components/filter/checkbox/types.js.map +0 -1
- package/dist/components/filter/index.js.map +0 -1
- package/dist/components/filter/search/SearchFilter.js.map +0 -1
- package/dist/components/filter/search/index.js.map +0 -1
- package/dist/components/filter/types.js.map +0 -1
- package/dist/components/index.js.map +0 -1
- package/dist/components/misc/ClearFilterButton.js.map +0 -1
- package/dist/components/misc/FilterContainer.js.map +0 -1
- package/dist/components/misc/SelectionChips.js.map +0 -1
- package/dist/components/misc/index.js.map +0 -1
- package/dist/components/panel/FilterPanel.js.map +0 -1
- package/dist/components/panel/FilterPanelBar.js.map +0 -1
- package/dist/components/panel/FilterPanelFilters.js.map +0 -1
- package/dist/components/panel/FilterPanelProvider.js.map +0 -1
- package/dist/components/panel/FilterPanelSelector.js.map +0 -1
- package/dist/components/panel/index.js.map +0 -1
- package/dist/context.js.map +0 -1
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/useClearFilter.js.map +0 -1
- package/dist/hooks/useFilter.js.map +0 -1
- package/dist/hooks/useFilterData.js.map +0 -1
- package/dist/hooks/useFilterSelection.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/options/FilterOptionProvider.js.map +0 -1
- package/dist/options/actions.js.map +0 -1
- package/dist/options/context.js.map +0 -1
- package/dist/options/create-options.js.map +0 -1
- package/dist/options/index.js.map +0 -1
- package/dist/options/reducer.js.map +0 -1
- package/dist/options/search/filter-option-match.js.map +0 -1
- package/dist/options/search/filter-option-search.js.map +0 -1
- package/dist/options/search/index.js.map +0 -1
- package/dist/options/search/types.js.map +0 -1
- package/dist/options/search/useFilterOptionSearch.js.map +0 -1
- package/dist/options/types.js.map +0 -1
- package/dist/reducers.js.map +0 -1
- package/dist/types.js.map +0 -1
|
@@ -1,44 +1,43 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Children } from 'react';
|
|
3
|
-
import { FilterPanelProvider, FilterPanelConsumer } from './FilterPanelProvider';
|
|
3
|
+
import { FilterPanelProvider, FilterPanelConsumer, } from './FilterPanelProvider';
|
|
4
4
|
import { FilterPanelFilters } from './FilterPanelFilters';
|
|
5
5
|
import { FilterPanelBar } from './FilterPanelBar';
|
|
6
6
|
import { SelectionChips } from '../misc';
|
|
7
7
|
import FilterPanelSelector from './FilterPanelSelector';
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
8
|
+
import styled from 'styled-components';
|
|
9
|
+
import { tokens } from '@equinor/eds-tokens';
|
|
10
|
+
const Styled = {
|
|
11
|
+
Root: styled.div `
|
|
12
|
+
--filter-panel-spacing: ${tokens.spacings.comfortable.medium};
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-flow: column;
|
|
15
|
+
gap: var(--filter-panel-spacing);
|
|
16
|
+
padding: var(--filter-panel-spacing);
|
|
17
|
+
border: 1px solid ${tokens.colors.interactive.disabled__border.rgba};
|
|
18
|
+
border-radius: 0.5rem;
|
|
19
|
+
& > * {
|
|
20
|
+
padding: 0 var(--filter-panel-spacing);
|
|
21
|
+
margin: 0 calc(var(--filter-panel-spacing) * -1);
|
|
22
|
+
}
|
|
23
|
+
`,
|
|
24
|
+
Filters: styled.div `
|
|
25
|
+
overflow-x: auto;
|
|
26
|
+
overflow-y: hidden;
|
|
27
|
+
display: flex;
|
|
28
|
+
padding-bottom: calc(var(--filter-panel-spacing));
|
|
29
|
+
margin-bottom: calc(var(--filter-panel-spacing) * -1);
|
|
30
|
+
background-color: ${tokens.colors.ui.background__light.rgba};
|
|
31
|
+
`,
|
|
32
|
+
};
|
|
32
33
|
/**
|
|
33
34
|
* Base component for displaying filter components and controllers
|
|
34
35
|
*/
|
|
35
36
|
export const FilterPanel = (props) => {
|
|
36
|
-
const { showFilters, className, classes, children, showSelection, ...args } = props;
|
|
37
|
+
const { showFilters, className, classes, children, showSelection, searchFn, ...args } = props;
|
|
37
38
|
const filters = Children.toArray(children).filter((x) => !!x.props.filterKey);
|
|
38
39
|
const initialSelectedFilters = props.selectedFilters || filters.map((x) => x.props.filterKey);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return (_jsx(FilterPanelProvider, Object.assign({}, { filters, initialSelectedFilters, showFilters }, { children: _jsxs("div", Object.assign({}, args, { className: clsx(styles.root, classes?.root, className) }, { children: [props.showBar && _jsx(FilterPanelBar, {}, void 0), _jsx(FilterPanelFilters, { FilterSelector: props.showSelector ? FilterPanelSelector : undefined, className: clsx(styles.filters, classes?.filters) }, void 0), _jsx(FilterPanelConsumer, { children: (context) => showSelection && !context?.showFilters && _jsx(SelectionChips, { chips: { variant: 'outlined' } }, void 0) }, void 0)] }), void 0) }), void 0));
|
|
40
|
+
return (_jsx(FilterPanelProvider, { filters, initialSelectedFilters, showFilters, children: _jsxs(Styled.Root, { ...args, className: [classes?.root, className].filter(Boolean).join(' ') || undefined, children: [props.showBar && _jsx(FilterPanelBar, { searchFn: searchFn }), _jsx(Styled.Filters, { children: _jsx(FilterPanelFilters, { FilterSelector: props.showSelector ? FilterPanelSelector : undefined, className: classes?.filters }) }), _jsx(FilterPanelConsumer, { children: (context) => showSelection &&
|
|
41
|
+
!context?.showFilters && _jsx(SelectionChips, { chips: { variant: 'outlined' } }) })] }) }));
|
|
42
42
|
};
|
|
43
43
|
export default FilterPanel;
|
|
44
|
-
//# sourceMappingURL=FilterPanel.js.map
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { HTMLAttributes, ReactElement } from 'react';
|
|
2
|
+
import type { FilterFn } from '../../types';
|
|
3
|
+
type FilterPanelBarProps<TData> = HTMLAttributes<HTMLDivElement> & {
|
|
4
|
+
readonly searchFn?: FilterFn<TData, string>;
|
|
5
|
+
};
|
|
6
|
+
export declare const FilterPanelBar: <TData>(props: FilterPanelBarProps<TData>) => ReactElement;
|
|
3
7
|
export default FilterPanelBar;
|
|
4
8
|
//# sourceMappingURL=FilterPanelBar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterPanelBar.d.ts","sourceRoot":"","sources":["../../../src/components/panel/FilterPanelBar.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FilterPanelBar.d.ts","sourceRoot":"","sources":["../../../src/components/panel/FilterPanelBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAO1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AA8B5C,KAAK,mBAAmB,CAAC,KAAK,IAAI,cAAc,CAAC,cAAc,CAAC,GAAG;IACjE,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CAC7C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,EAAG,OAAO,mBAAmB,CAAC,KAAK,CAAC,KAAG,YA0B1E,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import Button from '@equinor/
|
|
3
|
-
import {
|
|
2
|
+
import { Button, Icon } from '@equinor/eds-core-react';
|
|
3
|
+
import { chevron_up, chevron_down, refresh } from '@equinor/eds-icons';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { tokens } from '@equinor/eds-tokens';
|
|
4
6
|
import { SearchFilter } from '../filter';
|
|
5
7
|
import { ClearFilterButton } from '../misc';
|
|
6
8
|
import { useFilterPanelContext } from './FilterPanelProvider';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
Icon.add({ chevron_down, chevron_up, refresh });
|
|
10
|
+
const Styled = {
|
|
11
|
+
Root: styled.div `
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-wrap: wrap;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: ${tokens.spacings.comfortable.medium};
|
|
16
|
+
`,
|
|
17
|
+
Actions: styled.div `
|
|
18
|
+
margin-left: auto;
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
gap: ${tokens.spacings.comfortable.medium};
|
|
22
|
+
`,
|
|
23
|
+
ResetBtn: styled(ClearFilterButton) `
|
|
24
|
+
&[disabled] {
|
|
25
|
+
display: none;
|
|
26
|
+
}
|
|
27
|
+
`,
|
|
28
|
+
SearchWrapper: styled.div `
|
|
29
|
+
--textinput-dense-size: 36px;
|
|
30
|
+
`,
|
|
31
|
+
};
|
|
29
32
|
export const FilterPanelBar = (props) => {
|
|
30
|
-
const { className, ...args } = props;
|
|
33
|
+
const { className, searchFn, ...args } = props;
|
|
31
34
|
const { showFilters, setShowFilters } = useFilterPanelContext();
|
|
32
|
-
|
|
33
|
-
return (_jsxs("div", Object.assign({}, args, { className: clsx(className, styles.root) }, { children: [_jsx(SearchFilter, { filterKey: "global", label: "Search all", className: styles.searchInput, dense: true }, void 0), _jsxs("div", Object.assign({ className: styles.actions }, { children: [_jsx(ClearFilterButton, { className: styles.resetBtn, label: "Reset Filters", icon: "refresh", variant: "ghost" }, void 0), _jsx(Button, { icon: showFilters ? 'chevron_up' : 'chevron_down', label: showFilters ? 'Hide filters' : 'Show filters', onClick: () => setShowFilters(!showFilters), variant: "outlined", trailingIcon: true }, void 0)] }), void 0)] }), void 0));
|
|
35
|
+
return (_jsxs(Styled.Root, { ...args, className: className, children: [_jsx(Styled.SearchWrapper, { children: _jsx(SearchFilter, { filterKey: "global", label: "Search all", filterFn: searchFn }) }), _jsxs(Styled.Actions, { children: [_jsxs(Styled.ResetBtn, { variant: "ghost", children: ["Reset Filters", _jsx(Icon, { name: "refresh" })] }), _jsxs(Button, { icon: showFilters ? 'chevron_up' : 'chevron_down', onClick: () => setShowFilters(!showFilters), variant: "outlined", trailingIcon: true, children: [showFilters ? 'Hide filters' : 'Show filters', _jsx(Icon, { name: showFilters ? 'chevron_up' : 'chevron_down' })] })] })] }));
|
|
34
36
|
};
|
|
35
37
|
export default FilterPanelBar;
|
|
36
|
-
//# sourceMappingURL=FilterPanelBar.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
FilterSelector?:
|
|
1
|
+
import { type HTMLAttributes, type ReactElement, type FC } from 'react';
|
|
2
|
+
type FilterPanelFiltersProps = HTMLAttributes<HTMLDivElement> & {
|
|
3
|
+
readonly FilterSelector?: FC;
|
|
4
4
|
};
|
|
5
|
-
export declare const FilterPanelFilters: (props: FilterPanelFiltersProps) =>
|
|
5
|
+
export declare const FilterPanelFilters: (props: FilterPanelFiltersProps) => ReactElement;
|
|
6
6
|
export default FilterPanelFilters;
|
|
7
7
|
//# sourceMappingURL=FilterPanelFilters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterPanelFilters.d.ts","sourceRoot":"","sources":["../../../src/components/panel/FilterPanelFilters.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FilterPanelFilters.d.ts","sourceRoot":"","sources":["../../../src/components/panel/FilterPanelFilters.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AASjF,KAAK,uBAAuB,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IAC9D,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,OAAO,uBAAuB,KAAG,YAuBnE,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
-
import { useObservableState } from '@equinor/fusion-react
|
|
3
|
+
import { useObservableState } from '@equinor/fusion-observable/react';
|
|
4
4
|
import { useFilterPanelContext } from './FilterPanelProvider';
|
|
5
|
+
import { EdsProvider } from '@equinor/eds-core-react';
|
|
5
6
|
import { map } from 'rxjs/operators';
|
|
6
7
|
import { FilterContainer } from '../misc';
|
|
7
8
|
export const FilterPanelFilters = (props) => {
|
|
8
9
|
const { FilterSelector, ...args } = props;
|
|
9
10
|
const { filters$, showFilters } = useFilterPanelContext();
|
|
10
|
-
const filters = useObservableState(useMemo(() => filters$.pipe(map(({ filters, selectedFilters }) => filters.filter((filter) => selectedFilters.has(filter.props.filterKey)))), [filters$]));
|
|
11
|
-
return (_jsxs("div",
|
|
11
|
+
const { value: filters } = useObservableState(useMemo(() => filters$.pipe(map(({ filters, selectedFilters }) => filters.filter((filter) => selectedFilters.has(filter.props.filterKey)))), [filters$]));
|
|
12
|
+
return (_jsx(EdsProvider, { density: "compact", children: _jsxs("div", { ...args, style: { display: showFilters ? '' : 'none' }, children: [FilterSelector && _jsx(FilterSelector, {}), _jsx(FilterContainer, { children: filters })] }) }));
|
|
12
13
|
};
|
|
13
14
|
export default FilterPanelFilters;
|
|
14
|
-
//# sourceMappingURL=FilterPanelFilters.js.map
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { FilterComponent } from '../filter';
|
|
4
|
-
import FilterPanelSelector from './FilterPanelSelector';
|
|
5
|
-
import { ActionType } from 'typesafe-actions';
|
|
6
|
-
export
|
|
7
|
-
filters$:
|
|
1
|
+
import { type ReactElement, type PropsWithChildren } from 'react';
|
|
2
|
+
import type { FlowSubject } from '@equinor/fusion-observable';
|
|
3
|
+
import type { FilterComponent } from '../filter';
|
|
4
|
+
import type FilterPanelSelector from './FilterPanelSelector';
|
|
5
|
+
import { type ActionType } from 'typesafe-actions';
|
|
6
|
+
export type FilterPanelProviderContext = {
|
|
7
|
+
filters$: FlowSubject<State, Actions>;
|
|
8
8
|
showFilters?: boolean;
|
|
9
9
|
setShowFilters: (show: boolean) => void;
|
|
10
10
|
};
|
|
11
|
-
declare const Consumer:
|
|
11
|
+
declare const Consumer: any;
|
|
12
12
|
export { Consumer as FilterPanelConsumer };
|
|
13
13
|
export declare const useFilterPanelContext: () => FilterPanelProviderContext;
|
|
14
14
|
export declare const actions: {
|
|
15
15
|
add: import("typesafe-actions").PayloadActionCreator<"@FILTER_PANEL/FILTER_SELECTION_ADD", string>;
|
|
16
16
|
remove: import("typesafe-actions").PayloadActionCreator<"@FILTER_PANEL/FILTER_SELECTION_REMOVE", string>;
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
type Actions = ActionType<typeof actions>;
|
|
19
|
+
type State = {
|
|
20
20
|
selectedFilters: Set<string>;
|
|
21
21
|
filters: ReactElement<FilterComponent>[];
|
|
22
22
|
};
|
|
23
23
|
export declare const initialState: State;
|
|
24
|
-
|
|
24
|
+
type FilterPanelProviderProps = PropsWithChildren<{
|
|
25
25
|
filters: ReactElement<FilterComponent>[];
|
|
26
26
|
FilterSelector?: typeof FilterPanelSelector;
|
|
27
27
|
initialSelectedFilters?: string[];
|
|
28
28
|
showFilters?: boolean;
|
|
29
29
|
}>;
|
|
30
|
-
export declare const FilterPanelProvider: (props: FilterPanelProviderProps) =>
|
|
30
|
+
export declare const FilterPanelProvider: (props: FilterPanelProviderProps) => ReactElement;
|
|
31
31
|
export default FilterPanelProvider;
|
|
32
32
|
//# sourceMappingURL=FilterPanelProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterPanelProvider.d.ts","sourceRoot":"","sources":["../../../src/components/panel/FilterPanelProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"FilterPanelProvider.d.ts","sourceRoot":"","sources":["../../../src/components/panel/FilterPanelProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,iBAAiB,EAIvB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,mBAAmB,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAA+B,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEhF,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,EAAE,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACtC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC;AAIF,QAAA,MAAkB,QAAQ,KAAgD,CAAC;AAE3E,OAAO,EAAE,QAAQ,IAAI,mBAAmB,EAAE,CAAC;AAE3C,eAAO,MAAM,qBAAqB,QAAO,0BACU,CAAC;AAEpD,eAAO,MAAM,OAAO;;;CAGnB,CAAC;AAEF,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,KAAK,KAAK,GAAG;IACX,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,EAAE,CAAC;CAC1C,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAG1B,CAAC;AAYF,KAAK,wBAAwB,GAAG,iBAAiB,CAAC;IAChD,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,EAAE,CAAC;IACzC,cAAc,CAAC,EAAE,OAAO,mBAAmB,CAAC;IAC5C,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC,CAAC;AAEH,eAAO,MAAM,mBAAmB,GAAI,OAAO,wBAAwB,KAAG,YASrE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { createContext, useContext, useState, } from 'react';
|
|
3
|
+
import { useObservable } from '@equinor/fusion-observable/react';
|
|
4
4
|
import { createAction, createReducer } from 'typesafe-actions';
|
|
5
5
|
const context = createContext(null);
|
|
6
|
+
// biome-ignore lint/suspicious/noExplicitAny: React context Provider/Consumer types require any for generic usage
|
|
6
7
|
const { Provider, Consumer } = context;
|
|
7
8
|
export { Consumer as FilterPanelConsumer };
|
|
8
9
|
export const useFilterPanelContext = () => useContext(context);
|
|
@@ -29,7 +30,6 @@ export const FilterPanelProvider = (props) => {
|
|
|
29
30
|
filters: props.filters,
|
|
30
31
|
});
|
|
31
32
|
const [showFilters, setShowFilters] = useState(props.showFilters);
|
|
32
|
-
return _jsx(Provider,
|
|
33
|
+
return _jsx(Provider, { value: { filters$, showFilters, setShowFilters }, children: props.children });
|
|
33
34
|
};
|
|
34
35
|
export default FilterPanelProvider;
|
|
35
|
-
//# sourceMappingURL=FilterPanelProvider.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
export type FilterPanelSelectorProps = {
|
|
3
3
|
title?: string;
|
|
4
4
|
};
|
|
5
|
-
export declare const FilterPanelSelector: () =>
|
|
5
|
+
export declare const FilterPanelSelector: () => ReactElement;
|
|
6
6
|
export default FilterPanelSelector;
|
|
7
7
|
//# sourceMappingURL=FilterPanelSelector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterPanelSelector.d.ts","sourceRoot":"","sources":["../../../src/components/panel/FilterPanelSelector.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"FilterPanelSelector.d.ts","sourceRoot":"","sources":["../../../src/components/panel/FilterPanelSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAOvE,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAO,YA2BtC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { Checkbox } from '@equinor/
|
|
3
|
+
import { Checkbox } from '@equinor/eds-core-react';
|
|
4
4
|
import { initialState, useFilterPanelContext, actions } from './FilterPanelProvider';
|
|
5
|
-
import { useObservableState } from '@equinor/fusion-react
|
|
5
|
+
import { useObservableState } from '@equinor/fusion-observable/react';
|
|
6
6
|
export const FilterPanelSelector = () => {
|
|
7
7
|
const { filters$ } = useFilterPanelContext();
|
|
8
|
-
const { filters, selectedFilters } = useObservableState(filters$) || initialState;
|
|
8
|
+
const { filters, selectedFilters } = useObservableState(filters$).value || initialState;
|
|
9
9
|
const onInput = useCallback((e) => {
|
|
10
10
|
const key = e.currentTarget.value;
|
|
11
11
|
const selected = e.currentTarget.checked;
|
|
12
12
|
filters$.next(selected ? actions.remove(key) : actions.add(key));
|
|
13
13
|
}, [filters$]);
|
|
14
|
-
return (_jsx("div", { children: filters.map(({ props: { filterKey, title } }) => (_jsx(Checkbox, { value: filterKey, label: title, checked: selectedFilters.has(filterKey), onInput: onInput }, filterKey))) }
|
|
14
|
+
return (_jsx("div", { children: filters.map(({ props: { filterKey, title } }) => (_jsx(Checkbox, { value: filterKey, label: title, checked: selectedFilters.has(filterKey), onInput: onInput }, filterKey))) }));
|
|
15
15
|
};
|
|
16
16
|
export default FilterPanelSelector;
|
|
17
|
-
//# sourceMappingURL=FilterPanelSelector.js.map
|
package/dist/context.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { FilterContext } from './types';
|
|
3
2
|
export declare const useFilterContext: <TSelection = any, TData extends Record<string, any> = Record<string, any>>() => FilterContext<TSelection, TData>;
|
|
4
|
-
export declare const Provider:
|
|
3
|
+
export declare const Provider: any, Consumer: any;
|
|
5
4
|
export default useFilterContext;
|
|
6
5
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,eAAO,MAAM,gBAAgB,GAE3B,UAAU,GAAG,GAAG,EAEhB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OACpD,aAAa,CAAC,UAAU,EAAE,KAAK,CAA4D,CAAC;AAGjG,eAAO,MAAQ,QAAQ,OAAE,QAAQ,KAAgD,CAAC;AAElF,eAAe,gBAAgB,CAAC"}
|
package/dist/context.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext, useContext } from 'react';
|
|
2
2
|
const context = createContext({});
|
|
3
3
|
export const useFilterContext = () => useContext(context);
|
|
4
|
+
// biome-ignore lint/suspicious/noExplicitAny: React context Provider/Consumer types require any for generic usage
|
|
4
5
|
export const { Provider, Consumer } = context;
|
|
5
6
|
export default useFilterContext;
|
|
6
|
-
//# sourceMappingURL=context.js.map
|
package/dist/hooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClearFilter.d.ts","sourceRoot":"","sources":["../../src/hooks/useClearFilter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAUvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"useClearFilter.d.ts","sourceRoot":"","sources":["../../src/hooks/useClearFilter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAUvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,eAAO,MAAM,gBAAgB,GAAI,UAAU,GAAG,GAAG,EAC/C,SAAS,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC3C,YAAY,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,KACjD,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAWvC,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO;IAChC,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,UAAU,CAElB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACpB,CAAC;CAmCH,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -2,14 +2,15 @@ import { useCallback, useMemo } from 'react';
|
|
|
2
2
|
import { combineLatest } from 'rxjs';
|
|
3
3
|
import { map, distinctUntilChanged, filter, withLatestFrom } from 'rxjs/operators';
|
|
4
4
|
import { isActionOf } from 'typesafe-actions';
|
|
5
|
-
import {
|
|
5
|
+
import { useObservableFlow } from '@equinor/fusion-observable/react';
|
|
6
6
|
import { useFilterContext } from '../context';
|
|
7
7
|
import { actions } from '../actions';
|
|
8
|
+
// biome-ignore lint/suspicious/noExplicitAny: TSelection defaults to any to allow untyped usage
|
|
8
9
|
export const selectionChanges = (filter$, selection$) => {
|
|
9
10
|
return combineLatest([selection$, filter$]).pipe(map(([selections, filters]) => {
|
|
10
11
|
return Object.values(filters).reduce((acc, filter) => {
|
|
11
12
|
const selection = selections[filter.key];
|
|
12
|
-
const changed = filter.hasChanged
|
|
13
|
+
const changed = filter.hasChanged?.(selection, filter.initial);
|
|
13
14
|
return changed ? Object.assign(acc, { [filter.key]: selection }) : acc;
|
|
14
15
|
}, {});
|
|
15
16
|
}), distinctUntilChanged());
|
|
@@ -23,8 +24,7 @@ export const useClearFilter = () => {
|
|
|
23
24
|
return Object.assign(acc, { [filter.key]: filter.initial });
|
|
24
25
|
}, {}))), [filter$]);
|
|
25
26
|
const changed$ = useMemo(() => selectionChanges(filter$, selection$), [filter$, selection$]);
|
|
26
|
-
|
|
27
|
+
useObservableFlow(selection$, useCallback((action$) => action$.pipe(filter(isActionOf(actions.selection.clear)), withLatestFrom(initial$), map(([_, initial]) => actions.selection.set(initial))), [initial$]));
|
|
27
28
|
return { clear, changed$ };
|
|
28
29
|
};
|
|
29
30
|
export default useClearFilter;
|
|
30
|
-
//# sourceMappingURL=useClearFilter.js.map
|
|
@@ -3,5 +3,5 @@ import type { Filter } from '../types';
|
|
|
3
3
|
* Hook for attaching a filter to the current context
|
|
4
4
|
* Must be used within {@link FilterProvider}
|
|
5
5
|
*/
|
|
6
|
-
export declare const useFilter: <TData, TSelection>(filter: Filter<TData, TSelection>) => (value: TSelection) => void;
|
|
6
|
+
export declare const useFilter: <TData, TSelection>(filter: Filter<TData, TSelection>) => ((value: TSelection) => void);
|
|
7
7
|
//# sourceMappingURL=useFilter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFilter.d.ts","sourceRoot":"","sources":["../../src/hooks/useFilter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC;;;GAGG;AACH,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"useFilter.d.ts","sourceRoot":"","sources":["../../src/hooks/useFilter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,EAAE,UAAU,EACzC,QAAQ,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,KAChC,CAAC,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAsB9B,CAAC"}
|
package/dist/hooks/useFilter.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Observable } from 'rxjs';
|
|
2
2
|
import type { Filter } from '../types';
|
|
3
|
-
|
|
3
|
+
type useFilterDataArgs = {
|
|
4
4
|
/** array of filter keys of filters that will not be included in the data filtration */
|
|
5
5
|
exclude?: string[];
|
|
6
6
|
};
|
|
7
|
-
export declare const filterSelection: (filter$: Observable<Record<string, Filter>>, exclude?: string[]
|
|
8
|
-
export declare const filterData: <TInn extends Record<string, any>, TOut extends Record<string, any> = TInn>(source$: Observable<TInn[]>, filter$: Observable<Record<string, Filter<TInn
|
|
9
|
-
export declare const useFilterData: <TData extends Record<string, any>>(args?: useFilterDataArgs
|
|
7
|
+
export declare const filterSelection: (filter$: Observable<Record<string, Filter>>, exclude?: string[]) => Observable<Record<string, Filter>>;
|
|
8
|
+
export declare const filterData: <TInn extends Record<string, any>, TOut extends Record<string, any> = TInn>(source$: Observable<TInn[]>, filter$: Observable<Record<string, Filter<TInn>>>, selection$: Observable<Record<string, any>>) => Observable<TOut[]>;
|
|
9
|
+
export declare const useFilterData: <TData extends Record<string, any>>(args?: useFilterDataArgs) => Observable<TData[]>;
|
|
10
10
|
export default useFilterData;
|
|
11
11
|
//# sourceMappingURL=useFilterData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFilterData.d.ts","sourceRoot":"","sources":["../../src/hooks/useFilterData.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,
|
|
1
|
+
{"version":3,"file":"useFilterData.d.ts","sourceRoot":"","sources":["../../src/hooks/useFilterData.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,KAAK,iBAAiB,GAAG;IACvB,uFAAuF;IACvF,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,SAAS,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC3C,UAAU,MAAM,EAAE,KACjB,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBnC,CAAC;AAEF,eAAO,MAAM,UAAU,GAErB,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAEhC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,EAEvC,SAAS,UAAU,CAAC,IAAI,EAAE,CAAC,EAC3B,SAAS,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAEjD,YAAY,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAC1C,UAAU,CAAC,IAAI,EAAE,CAanB,CAAC;AAGF,eAAO,MAAM,aAAa,GAAI,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7D,OAAO,iBAAiB,KACvB,UAAU,CAAC,KAAK,EAAE,CAYpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -6,7 +6,7 @@ export const filterSelection = (filter$, exclude) => {
|
|
|
6
6
|
return filter$.pipe(
|
|
7
7
|
/** create a selection of filters base on provided args */
|
|
8
8
|
map((x) => Object.entries(x)
|
|
9
|
-
.filter(([key]) => !exclude
|
|
9
|
+
.filter(([key]) => !exclude?.includes(key))
|
|
10
10
|
.reduce((acc, [key, filter]) => Object.assign(acc, { [key]: filter }), {})),
|
|
11
11
|
/** only update filters when filter function changes */
|
|
12
12
|
distinctUntilChanged((a, b) => {
|
|
@@ -17,7 +17,9 @@ export const filterSelection = (filter$, exclude) => {
|
|
|
17
17
|
return !filterA.find((x) => filterB.find((y) => x.filterFn !== y.filterFn));
|
|
18
18
|
}));
|
|
19
19
|
};
|
|
20
|
-
export const filterData = (source$, filter$,
|
|
20
|
+
export const filterData = (source$, filter$,
|
|
21
|
+
// biome-ignore lint/suspicious/noExplicitAny: selection values are unknown at this level
|
|
22
|
+
selection$) => {
|
|
21
23
|
return combineLatest([selection$, source$, filter$]).pipe(switchMap(([selections, source, filters]) => {
|
|
22
24
|
/** loop threw all provided filters */
|
|
23
25
|
return from(Object.values(filters)).pipe(reduce((acc, filter) => {
|
|
@@ -27,6 +29,7 @@ export const filterData = (source$, filter$, selection$) => {
|
|
|
27
29
|
}, source));
|
|
28
30
|
}));
|
|
29
31
|
};
|
|
32
|
+
// biome-ignore lint/suspicious/noExplicitAny: TData is a generic record type
|
|
30
33
|
export const useFilterData = (args) => {
|
|
31
34
|
const { exclude } = args || {};
|
|
32
35
|
const { source$, filter$, selection$ } = useFilterContext();
|
|
@@ -36,4 +39,3 @@ export const useFilterData = (args) => {
|
|
|
36
39
|
return useMemo(() => filterData(source$, selectedFilter$, selection$), [source$, selectedFilter$, selection$]);
|
|
37
40
|
};
|
|
38
41
|
export default useFilterData;
|
|
39
|
-
//# sourceMappingURL=useFilterData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFilterSelection.d.ts","sourceRoot":"","sources":["../../src/hooks/useFilterSelection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useFilterSelection.d.ts","sourceRoot":"","sources":["../../src/hooks/useFilterSelection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAI7D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,EAAE,WAAW,MAAM,KAAG,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAK1F,CAAC;AAEJ,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useObservableSelector } from '@equinor/fusion-observable/react';
|
|
2
2
|
import { useFilterContext } from '../context';
|
|
3
3
|
/**
|
|
4
4
|
* Use the filter selection from filter provider context
|
|
5
5
|
* @param filterKey {string} the key that the filter was registered on
|
|
6
6
|
* @returns {Observable<TSelection>}
|
|
7
7
|
*/
|
|
8
|
-
export const useFilterSelection = (filterKey) =>
|
|
8
|
+
export const useFilterSelection = (filterKey) => useObservableSelector(
|
|
9
|
+
// biome-ignore lint/suspicious/noExplicitAny: selection$ is a generic observable, any is required for the key lookup
|
|
10
|
+
useFilterContext().selection$, filterKey);
|
|
9
11
|
export default useFilterSelection;
|
|
10
|
-
//# sourceMappingURL=useFilterSelection.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export * from './hooks';
|
|
|
3
3
|
export * from './types';
|
|
4
4
|
/** Common Components */
|
|
5
5
|
export { FilterProvider, FilterProviderProps } from './FilterProvider';
|
|
6
|
-
export { CheckboxFilter, FilterPanel } from './components';
|
|
6
|
+
export { CheckboxFilter, FilterPanel, FilterPanelProps } from './components';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/E,cAAc,SAAS,CAAC;AAExB,cAAc,SAAS,CAAC;AAExB,wBAAwB;AAExB,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/E,cAAc,SAAS,CAAC;AAExB,cAAc,SAAS,CAAC;AAExB,wBAAwB;AAExB,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { type PropsWithChildren, type ReactElement } from 'react';
|
|
2
2
|
import type { Filter } from '../types';
|
|
3
3
|
import type { FilterOption, FilterOptionBuilder, FilterOptionSelector } from './types';
|
|
4
|
-
export
|
|
4
|
+
export type FilterComponentProviderProps<TData, TOption extends FilterOption, TValue> = {
|
|
5
5
|
filter: Filter<TData, Set<TValue>>;
|
|
6
6
|
optionBuilder?: FilterOptionBuilder<TData, TOption, TValue>;
|
|
7
7
|
selector?: Extract<keyof TData, string> | string | FilterOptionSelector<TData>;
|
|
8
8
|
initial?: Set<TValue>;
|
|
9
9
|
};
|
|
10
|
-
export declare const FilterOptionProvider: <TData extends Record<string, any>, TOption extends FilterOption, TValue>(props:
|
|
10
|
+
export declare const FilterOptionProvider: <TData extends Record<string, any>, TOption extends FilterOption, TValue>(props: PropsWithChildren<FilterComponentProviderProps<TData, TOption, TValue>>) => ReactElement;
|
|
11
11
|
export default FilterOptionProvider;
|
|
12
12
|
//# sourceMappingURL=FilterOptionProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterOptionProvider.d.ts","sourceRoot":"","sources":["../../src/options/FilterOptionProvider.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"FilterOptionProvider.d.ts","sourceRoot":"","sources":["../../src/options/FilterOptionProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,YAAY,EAAsB,MAAM,OAAO,CAAC;AAQtF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAOvC,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAIvF,MAAM,MAAM,4BAA4B,CAAC,KAAK,EAAE,OAAO,SAAS,YAAY,EAAE,MAAM,IAAI;IACtF,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACnC,aAAa,CAAC,EAAE,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,KAAK,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC/E,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,CAEjC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,OAAO,SAAS,YAAY,EAC5B,MAAM,EAEN,KAAK,EAAE,iBAAiB,CAAC,4BAA4B,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,KAC3E,YAwDJ,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useMemo } from 'react';
|
|
3
3
|
import { combineLatest, of } from 'rxjs';
|
|
4
4
|
import { switchMap, map } from 'rxjs/operators';
|
|
5
|
-
import { useObservable } from '@equinor/fusion-react
|
|
5
|
+
import { useObservable } from '@equinor/fusion-observable/react';
|
|
6
6
|
import { useFilterData, useFilterSelection, useFilter, useFilterContext } from '../hooks';
|
|
7
7
|
import { Provider } from './context';
|
|
8
8
|
import { actions } from './actions';
|
|
@@ -48,7 +48,6 @@ export const FilterOptionProvider = (props) => {
|
|
|
48
48
|
selection$,
|
|
49
49
|
setSelection,
|
|
50
50
|
};
|
|
51
|
-
return _jsx(Provider,
|
|
51
|
+
return _jsx(Provider, { value: value, children: props.children });
|
|
52
52
|
};
|
|
53
53
|
export default FilterOptionProvider;
|
|
54
|
-
//# sourceMappingURL=FilterOptionProvider.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ActionType } from 'typesafe-actions';
|
|
1
|
+
import { type ActionType } from 'typesafe-actions';
|
|
2
2
|
import type { FilterOption } from './types';
|
|
3
3
|
export declare const actions: {
|
|
4
4
|
set: import("typesafe-actions").PayloadActionCreator<"@FILTER_OPTIONS/SELECTION_SET", Record<string, FilterOption>>;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type Actions = ActionType<typeof actions>;
|
|
7
7
|
export default actions;
|
|
8
8
|
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/options/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/options/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,OAAO;;CAEnB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAEjD,eAAe,OAAO,CAAC"}
|
package/dist/options/actions.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { FilterOption, FilterOptionContext } from './types';
|
|
3
|
-
export declare const Provider:
|
|
2
|
+
export declare const Provider: any, Consumer: any;
|
|
4
3
|
export declare const useFilterOptionContext: <TOption extends FilterOption = FilterOption, TValue = string>() => FilterOptionContext<TOption, TValue>;
|
|
5
4
|
export default useFilterOptionContext;
|
|
6
5
|
//# sourceMappingURL=context.d.ts.map
|