@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Equinor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/components/package.json
CHANGED
package/dist/FilterProvider.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { type PropsWithChildren, type ReactElement } from 'react';
|
|
2
2
|
import type { Filter } from './types';
|
|
3
|
-
export
|
|
3
|
+
export type FilterProviderProps<TSelections extends Record<string, unknown>, TData> = {
|
|
4
4
|
data: TData[];
|
|
5
5
|
initialSelection?: TSelections;
|
|
6
6
|
initialFilters?: Record<string, Filter<TData, TSelections>>;
|
|
7
7
|
};
|
|
8
|
-
export declare const FilterProvider: <TSelections extends Record<string, any>, TData extends Record<string, any> = Record<string, any>>(props:
|
|
8
|
+
export declare const FilterProvider: <TSelections extends Record<string, any>, TData extends Record<string, any> = Record<string, any>>(props: PropsWithChildren<FilterProviderProps<TSelections, TData>>) => ReactElement;
|
|
9
9
|
export default FilterProvider;
|
|
10
10
|
//# sourceMappingURL=FilterProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterProvider.d.ts","sourceRoot":"","sources":["../src/FilterProvider.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"FilterProvider.d.ts","sourceRoot":"","sources":["../src/FilterProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAIlB,MAAM,OAAO,CAAC;AAYf,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,SAAS,CAAC;AAErD,MAAM,MAAM,mBAAmB,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,IAAI;IACpF,IAAI,EAAE,KAAK,EAAE,CAAC;IACd,gBAAgB,CAAC,EAAE,WAAW,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;CAC7D,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,CAE3B,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAEvC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAEvD,KAAK,EAAE,iBAAiB,CAAC,mBAAmB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,KAC9D,YA4CJ,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
package/dist/FilterProvider.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useLayoutEffect, useState } from 'react';
|
|
2
|
+
import { useLayoutEffect, useMemo, useState, } from 'react';
|
|
3
3
|
import { BehaviorSubject } from 'rxjs';
|
|
4
|
-
import { useObservable,
|
|
4
|
+
import { useObservable, useObservableSubscription } from '@equinor/fusion-observable/react';
|
|
5
5
|
import { createSelectionReducer, createDataReducer, createFilterReducer } from './reducers';
|
|
6
6
|
import { Provider } from './context';
|
|
7
7
|
import { actions } from './actions';
|
|
@@ -12,19 +12,19 @@ export const FilterProvider = (props) => {
|
|
|
12
12
|
const source$ = useObservable(createDataReducer(data), data);
|
|
13
13
|
const selection$ = useObservable(createSelectionReducer(initialSelection), initialSelection);
|
|
14
14
|
const filter$ = useObservable(createFilterReducer({}), initialFilters);
|
|
15
|
+
const filterData$ = useMemo(() => filterData(source$, filter$, selection$), [source$, filter$, selection$]);
|
|
15
16
|
const [data$] = useState(new BehaviorSubject(data));
|
|
16
|
-
|
|
17
|
-
const context = {
|
|
17
|
+
useObservableSubscription(filterData$, data$);
|
|
18
|
+
const context = useMemo(() => ({
|
|
18
19
|
source$,
|
|
19
20
|
filter$,
|
|
20
21
|
selection$,
|
|
21
22
|
data$,
|
|
22
23
|
/** type issues, might fix later */
|
|
23
|
-
};
|
|
24
|
+
}), [source$, filter$, selection$, data$]);
|
|
24
25
|
useLayoutEffect(() => {
|
|
25
26
|
source$.next(actions.source.update(data));
|
|
26
27
|
}, [source$, data]);
|
|
27
|
-
return _jsx(Provider,
|
|
28
|
+
return _jsx(Provider, { value: context, children: children });
|
|
28
29
|
};
|
|
29
30
|
export default FilterProvider;
|
|
30
|
-
//# sourceMappingURL=FilterProvider.js.map
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ActionType } from 'typesafe-actions';
|
|
1
|
+
import { type ActionType } from 'typesafe-actions';
|
|
2
2
|
import type { Filter } from './types';
|
|
3
|
-
export
|
|
3
|
+
export type SelectionValues<TValue = unknown> = Record<string, TValue>;
|
|
4
4
|
export declare const filter: {
|
|
5
5
|
add: import("typesafe-actions").PayloadActionCreator<"@FILTER/FILTERS_ADD", Filter<any, any>>;
|
|
6
6
|
remove: import("typesafe-actions").PayloadActionCreator<"@FILTER/FILTERS_REMOVE", string>;
|
|
@@ -29,6 +29,6 @@ export declare const actions: {
|
|
|
29
29
|
update: import("typesafe-actions").PayloadActionCreator<"@FILTER/SOURCE_UPDATE", unknown>;
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
|
-
export
|
|
32
|
+
export type Actions = ActionType<typeof actions>;
|
|
33
33
|
export default actions;
|
|
34
34
|
//# sourceMappingURL=actions.d.ts.map
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,MAAM,eAAe,CAAC,MAAM,GAAG,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEvE,eAAO,MAAM,MAAM;;;CAIlB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;CAKrB,CAAC;AAEF,eAAO,MAAM,MAAM;;CAElB,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;;;;;;;;;CAInB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAEjD,eAAe,OAAO,CAAC"}
|
package/dist/actions.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createAction } from 'typesafe-actions';
|
|
2
2
|
export const filter = {
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: we need any here to avoid type errors
|
|
3
4
|
add: createAction('@FILTER/FILTERS_ADD')(),
|
|
4
5
|
remove: createAction('@FILTER/FILTERS_REMOVE')(),
|
|
5
6
|
};
|
|
@@ -18,4 +19,3 @@ export const actions = {
|
|
|
18
19
|
source,
|
|
19
20
|
};
|
|
20
21
|
export default actions;
|
|
21
|
-
//# sourceMappingURL=actions.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
type FilterHeaderProps = {
|
|
3
|
+
readonly title: string;
|
|
3
4
|
};
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const FilterOptionHeader: (props: FilterHeaderProps) => JSX.Element;
|
|
5
|
+
export declare const FilterOptionHeader: (props: FilterHeaderProps) => ReactElement;
|
|
6
6
|
export default FilterOptionHeader;
|
|
7
7
|
//# sourceMappingURL=FilterOptionHeader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterOptionHeader.d.ts","sourceRoot":"","sources":["../../../src/components/filter/FilterOptionHeader.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FilterOptionHeader.d.ts","sourceRoot":"","sources":["../../../src/components/filter/FilterOptionHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,YAAY,EAAqC,MAAM,OAAO,CAAC;AAY7F,KAAK,iBAAiB,GAAG;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AA2CF,eAAO,MAAM,kBAAkB,GAAI,OAAO,iBAAiB,KAAG,YAuD7D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,55 +1,59 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useObservableState, useSelector } from '@equinor/fusion-react-observable';
|
|
3
|
-
import { Icon } from '@equinor/fusion-react-icon';
|
|
4
|
-
import { TextInput } from '@equinor/fusion-react-textinput';
|
|
5
|
-
import { useFilterOptionContext, useFilterOptionSearch } from '../../options';
|
|
6
|
-
import { clsx, createStyles, makeStyles } from '@equinor/fusion-react-styles';
|
|
7
2
|
import { useLayoutEffect, useRef, useState } from 'react';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
3
|
+
import { useObservableState, useObservableSelector } from '@equinor/fusion-observable/react';
|
|
4
|
+
import { TextField, Icon } from '@equinor/eds-core-react';
|
|
5
|
+
import { useFilterOptionContext, useFilterOptionSearch } from '../../options';
|
|
6
|
+
import { search, chevron_right } from '@equinor/eds-icons';
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { tokens } from '@equinor/eds-tokens';
|
|
9
|
+
Icon.add({ search, chevron_right });
|
|
10
|
+
const Styled = {
|
|
11
|
+
Root: styled.div `
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
`,
|
|
15
|
+
Header: styled.header `
|
|
16
|
+
color: ${tokens.typography.table.cell_header.color};
|
|
17
|
+
font-family: ${tokens.typography.table.cell_header.fontFamily};
|
|
18
|
+
font-size: ${tokens.typography.table.cell_header.fontSize};
|
|
19
|
+
font-weight: ${tokens.typography.table.cell_header.fontWeight};
|
|
20
|
+
line-height: ${tokens.typography.table.cell_header.lineHeight};
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
${({ $showSearch }) => $showSearch && 'display: none;'}
|
|
23
|
+
`,
|
|
24
|
+
Counter: styled.span `
|
|
25
|
+
display: ${({ $noCount }) => ($noCount ? 'none' : 'inline-flex')};
|
|
26
|
+
gap: 1px;
|
|
27
|
+
color: ${tokens.typography.input.helper.color};
|
|
28
|
+
font-family: ${tokens.typography.input.helper.fontFamily};
|
|
29
|
+
font-size: ${tokens.typography.input.helper.fontSize};
|
|
30
|
+
font-weight: ${tokens.typography.input.helper.fontWeight};
|
|
31
|
+
letter-spacing: ${tokens.typography.input.helper.letterSpacing};
|
|
32
|
+
line-height: ${tokens.typography.input.helper.lineHeight};
|
|
33
|
+
margin-left: ${tokens.spacings.comfortable.small};
|
|
34
|
+
`,
|
|
35
|
+
IconBtn: styled(Icon) `
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
margin-left: auto;
|
|
38
|
+
`,
|
|
39
|
+
SearchField: styled(TextField) `
|
|
40
|
+
margin-top: 4px;
|
|
41
|
+
flex: ${({ $showSearch }) => ($showSearch ? '1 1 auto' : 'none')};
|
|
42
|
+
${({ $showSearch }) => !$showSearch &&
|
|
43
|
+
`
|
|
44
|
+
max-width: 0;
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
`}
|
|
47
|
+
`,
|
|
48
|
+
};
|
|
44
49
|
export const FilterOptionHeader = (props) => {
|
|
45
50
|
const { title } = props;
|
|
46
51
|
const [showSearch, setShowSearch] = useState(false);
|
|
47
52
|
const { setQuery, query$ } = useFilterOptionSearch();
|
|
48
53
|
const searchRef = useRef(null);
|
|
49
54
|
const { options$, selection$ } = useFilterOptionContext();
|
|
50
|
-
const optionCount = Object.keys(useObservableState(options$) || {}).length;
|
|
51
|
-
const selectedCount = useObservableState(
|
|
52
|
-
const styles = useStyles();
|
|
55
|
+
const optionCount = Object.keys(useObservableState(options$).value || {}).length;
|
|
56
|
+
const { value: selectedCount } = useObservableState(useObservableSelector(selection$, (x) => (x ?? new Set()).size > 0));
|
|
53
57
|
const onIconClick = () => {
|
|
54
58
|
if (showSearch) {
|
|
55
59
|
setQuery('');
|
|
@@ -60,10 +64,13 @@ export const FilterOptionHeader = (props) => {
|
|
|
60
64
|
setShowSearch(!showSearch);
|
|
61
65
|
};
|
|
62
66
|
useLayoutEffect(() => {
|
|
63
|
-
const subscription = query$.subscribe((x) =>
|
|
67
|
+
const subscription = query$.subscribe((x) => {
|
|
68
|
+
if (searchRef.current) {
|
|
69
|
+
searchRef.current.value = x;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
64
72
|
return () => subscription.unsubscribe();
|
|
65
|
-
}, [
|
|
66
|
-
return (_jsxs(
|
|
73
|
+
}, [query$]);
|
|
74
|
+
return (_jsxs(Styled.Root, { children: [_jsx(Styled.SearchField, { id: title, ref: searchRef, "$showSearch": showSearch, type: "search", placeholder: title, onInput: (e) => setQuery(e.currentTarget.value), inputIcon: _jsx(Icon, { name: "search", size: 16 }, "thumbs") }), _jsxs(Styled.Header, { "$showSearch": showSearch, children: [_jsx("span", { children: title }), _jsxs(Styled.Counter, { "$noCount": !selectedCount, children: [_jsx("span", { children: "(" }), _jsx("span", { children: selectedCount }), _jsx("span", { children: "/" }), _jsx("span", { children: optionCount }), _jsx("span", { children: ")" })] })] }), _jsx(Styled.IconBtn, { name: showSearch ? 'chevron_right' : 'search', size: 16, onClick: onIconClick })] }));
|
|
67
75
|
};
|
|
68
76
|
export default FilterOptionHeader;
|
|
69
|
-
//# sourceMappingURL=FilterOptionHeader.js.map
|
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { FilterOptionBuilder, FilterOptionSelector } from '../../../options';
|
|
2
3
|
import type { FilterComponent } from '../types';
|
|
3
|
-
|
|
4
|
+
import type { CheckboxOption } from './types';
|
|
5
|
+
import type { FilterFn } from '../../../types';
|
|
6
|
+
export type CheckboxFilterProps<TData extends Record<string, any> = Record<string, any>> = FilterComponent & {
|
|
4
7
|
/** either name of property of data type or a function that selects value */
|
|
5
|
-
selector?: Extract<keyof TData, string> | string | FilterOptionSelector<TData>;
|
|
8
|
+
readonly selector?: Extract<keyof TData, string> | string | FilterOptionSelector<TData>;
|
|
6
9
|
/** show option for selecting all */
|
|
7
|
-
enableAll?: boolean;
|
|
10
|
+
readonly enableAll?: boolean;
|
|
8
11
|
/** initial selection */
|
|
9
|
-
initial?: Set<string>;
|
|
12
|
+
readonly initial?: Set<string>;
|
|
13
|
+
readonly filter?: {
|
|
14
|
+
filterFn: FilterFn<TData, Set<string>>;
|
|
15
|
+
optionFn: FilterOptionBuilder<TData, CheckboxOption, string>;
|
|
16
|
+
};
|
|
17
|
+
readonly sortFn?: <T extends {
|
|
18
|
+
label: string;
|
|
19
|
+
}>(a: T, b: T) => number;
|
|
10
20
|
};
|
|
11
21
|
/**
|
|
12
22
|
* Component for displaying multi-select filter with checkboxes
|
|
13
23
|
*/
|
|
14
|
-
export declare const CheckboxFilter: (props: CheckboxFilterProps) =>
|
|
24
|
+
export declare const CheckboxFilter: <TData extends Record<string, any> = Record<string, any>>(props: CheckboxFilterProps<TData>) => ReactElement;
|
|
15
25
|
export default CheckboxFilter;
|
|
16
26
|
//# sourceMappingURL=CheckboxFilter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxFilter.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"CheckboxFilter.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAElF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAQhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C,MAAM,MAAM,mBAAmB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IACrF,eAAe,GAAG;IAChB,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,KAAK,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IACxF,oCAAoC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,wBAAwB;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAI/B,QAAQ,CAAC,MAAM,CAAC,EAAE;QAChB,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QACvC,QAAQ,EAAE,mBAAmB,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;KAC9D,CAAC;IACF,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;CACvE,CAAC;AAEJ;;GAEG;AAEH,eAAO,MAAM,cAAc,GAAI,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACpF,OAAO,mBAAmB,CAAC,KAAK,CAAC,KAChC,YAaF,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -3,14 +3,13 @@ import { FilterOptionHeader } from '../FilterOptionHeader';
|
|
|
3
3
|
import { CheckboxFilterProvider } from './CheckboxFilterProvider';
|
|
4
4
|
import CheckboxFilterOptions from './CheckboxFilterOptions';
|
|
5
5
|
import CheckboxFilterOptionAll from './CheckboxFilterOptionAll';
|
|
6
|
-
import
|
|
6
|
+
import { Styled } from './CheckboxFilter.style';
|
|
7
7
|
/**
|
|
8
8
|
* Component for displaying multi-select filter with checkboxes
|
|
9
9
|
*/
|
|
10
|
+
// biome-ignore lint/suspicious/noExplicitAny: we need any here to avoid type errors
|
|
10
11
|
export const CheckboxFilter = (props) => {
|
|
11
|
-
const { enableAll, ...args } = props;
|
|
12
|
-
|
|
13
|
-
return (_jsx(CheckboxFilterProvider, Object.assign({}, args, { children: _jsxs("div", Object.assign({ className: styles.root }, { children: [_jsx(FilterOptionHeader, { title: args.title }, void 0), _jsxs("div", Object.assign({ className: styles.items }, { children: [enableAll && _jsx(CheckboxFilterOptionAll, {}, void 0), _jsx(CheckboxFilterOptions, {}, void 0)] }), void 0)] }), void 0) }), void 0));
|
|
12
|
+
const { enableAll, sortFn, ...args } = props;
|
|
13
|
+
return (_jsx(CheckboxFilterProvider, { ...args, children: _jsxs(Styled.Root, { children: [_jsx(FilterOptionHeader, { title: args.title }), _jsxs(Styled.Items, { "$layout": "column", children: [enableAll && _jsx(CheckboxFilterOptionAll, {}), _jsx(CheckboxFilterOptions, { sortFn: sortFn })] })] }) }));
|
|
14
14
|
};
|
|
15
15
|
export default CheckboxFilter;
|
|
16
|
-
//# sourceMappingURL=CheckboxFilter.js.map
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export declare const Styled: {
|
|
2
|
+
Root: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
|
|
3
|
+
Items: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$layout"> & {
|
|
4
|
+
$layout: "column" | "row";
|
|
5
|
+
}, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$layout"> & {
|
|
6
|
+
$layout: "column" | "row";
|
|
7
|
+
}, never>>> & string;
|
|
8
|
+
Title: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>>> & string;
|
|
9
|
+
};
|
|
5
10
|
//# sourceMappingURL=CheckboxFilter.style.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxFilter.style.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilter.style.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CheckboxFilter.style.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilter.style.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM;;;iBAMY,QAAQ,GAAG,KAAK;;iBAAhB,QAAQ,GAAG,KAAK;;;CAY9C,CAAC"}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { tokens } from '@equinor/eds-tokens';
|
|
3
|
+
export const Styled = {
|
|
4
|
+
Root: styled.div `
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-flow: column;
|
|
7
|
+
min-width: 150px;
|
|
8
|
+
`,
|
|
9
|
+
Items: styled.div `
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-flow: ${({ $layout }) => $layout};
|
|
12
|
+
overflow-y: auto;
|
|
13
|
+
`,
|
|
14
|
+
Title: styled.span `
|
|
15
|
+
color: ${tokens.typography.heading.h3.color};
|
|
16
|
+
font-family: ${tokens.typography.heading.h3.fontFamily};
|
|
17
|
+
font-size: ${tokens.typography.heading.h3.fontSize};
|
|
18
|
+
font-weight: ${tokens.typography.heading.h3.fontWeight};
|
|
19
|
+
line-height: ${tokens.typography.heading.h3.lineHeight};
|
|
20
|
+
`,
|
|
21
|
+
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { type ReactElement, type HTMLAttributes } from 'react';
|
|
1
2
|
import type { CheckboxOption } from './types';
|
|
2
|
-
export
|
|
3
|
-
name: string;
|
|
4
|
-
checked?: boolean;
|
|
5
|
-
indeterminate?: boolean;
|
|
6
|
-
count: string | number;
|
|
7
|
-
onOptionChange: (item: {
|
|
3
|
+
export type CheckboxFilterOptionProps = Partial<HTMLAttributes<HTMLDivElement>> & Omit<CheckboxOption, 'totalCount'> & {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly checked?: boolean;
|
|
6
|
+
readonly indeterminate?: boolean;
|
|
7
|
+
readonly count: string | number;
|
|
8
|
+
readonly onOptionChange: (item: {
|
|
8
9
|
name: string;
|
|
9
10
|
selected?: boolean;
|
|
10
11
|
}) => void;
|
|
11
12
|
};
|
|
12
|
-
export declare const CheckboxFilterOption: (props: CheckboxFilterOptionProps) =>
|
|
13
|
+
export declare const CheckboxFilterOption: (props: CheckboxFilterOptionProps) => ReactElement;
|
|
13
14
|
export default CheckboxFilterOption;
|
|
14
15
|
//# sourceMappingURL=CheckboxFilterOption.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxFilterOption.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterOption.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CheckboxFilterOption.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterOption.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,YAAY,EAAE,KAAK,cAAc,EAAkB,MAAM,OAAO,CAAC;AAK5F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,GAC7E,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,GAAG;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;CAC/E,CAAC;AAEJ,eAAO,MAAM,oBAAoB,GAAI,OAAO,yBAAyB,KAAG,YA+BvE,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { useStyles } from './CheckboxFilterOption.style';
|
|
3
|
+
import { Checkbox } from '@equinor/eds-core-react';
|
|
4
|
+
import { Styled } from './CheckboxFilterOption.style';
|
|
6
5
|
export const CheckboxFilterOption = (props) => {
|
|
7
6
|
const { name, label, count, checked, indeterminate, inactive, hide, onOptionChange, className, ...args } = props;
|
|
8
|
-
const onCheckboxClick = useCallback((e) => e.stopPropagation(), []);
|
|
9
7
|
const onCheckboxInput = useCallback(({ currentTarget: { name, checked } }) => {
|
|
10
|
-
return onOptionChange({ name, selected:
|
|
8
|
+
return onOptionChange({ name, selected: checked });
|
|
11
9
|
}, [onOptionChange]);
|
|
12
|
-
|
|
13
|
-
e.currentTarget.firstChild.click();
|
|
14
|
-
}, []);
|
|
15
|
-
const styles = useStyles();
|
|
16
|
-
return (_jsxs("div", Object.assign({}, args, { className: clsx(className, styles.root, inactive && styles.inactive, hide && styles.hide), onClick: onClick }, { children: [_jsx(Checkbox, { className: styles.checkbox, name: name, checked: checked, onInput: onCheckboxInput, onClick: onCheckboxClick, indeterminate: indeterminate }, void 0), _jsx("span", Object.assign({ className: styles.label }, { children: label }), void 0), _jsx("span", Object.assign({ className: styles.counter }, { children: count }), void 0)] }), void 0));
|
|
10
|
+
return (_jsxs(Styled.Root, { ...args, className: className, "$inactive": inactive, "$hide": hide, children: [_jsx(Checkbox, { name: name, checked: checked, onChange: onCheckboxInput, indeterminate: indeterminate, label: label }), _jsx(Styled.Counter, { children: count })] }));
|
|
17
11
|
};
|
|
18
12
|
export default CheckboxFilterOption;
|
|
19
|
-
//# sourceMappingURL=CheckboxFilterOption.js.map
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
1
|
+
export declare const Styled: {
|
|
2
|
+
Root: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$inactive" | "$hide"> & {
|
|
3
|
+
$inactive?: boolean;
|
|
4
|
+
$hide?: boolean;
|
|
5
|
+
}, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$inactive" | "$hide"> & {
|
|
6
|
+
$inactive?: boolean;
|
|
7
|
+
$hide?: boolean;
|
|
8
|
+
}, never>>> & string;
|
|
9
|
+
Counter: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>>> & string;
|
|
10
|
+
};
|
|
3
11
|
//# sourceMappingURL=CheckboxFilterOption.style.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxFilterOption.style.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterOption.style.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CheckboxFilterOption.style.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterOption.style.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM;;oBACc,OAAO;gBAAU,OAAO;;oBAAxB,OAAO;gBAAU,OAAO;;;CAmCxD,CAAC"}
|
|
@@ -1,41 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
inactive
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
}), { name: 'fusion-filter-checkbox-option' });
|
|
40
|
-
export default useStyles;
|
|
41
|
-
//# sourceMappingURL=CheckboxFilterOption.style.js.map
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { tokens } from '@equinor/eds-tokens';
|
|
3
|
+
export const Styled = {
|
|
4
|
+
Root: styled.div `
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
background-color: transparent;
|
|
10
|
+
will-change: background-color;
|
|
11
|
+
transition: 125ms background-color ease-out;
|
|
12
|
+
|
|
13
|
+
&:hover {
|
|
14
|
+
background-color: ${tokens.colors.interactive.primary__hover_alt.rgba};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
${({ $inactive }) => $inactive &&
|
|
18
|
+
`
|
|
19
|
+
filter: grayscale(100%);
|
|
20
|
+
opacity: 0.5;
|
|
21
|
+
`}
|
|
22
|
+
|
|
23
|
+
${({ $hide }) => $hide &&
|
|
24
|
+
`
|
|
25
|
+
display: none;
|
|
26
|
+
`}
|
|
27
|
+
`,
|
|
28
|
+
Counter: styled.span `
|
|
29
|
+
color: ${tokens.typography.input.label.color};
|
|
30
|
+
font-family: ${tokens.typography.input.label.fontFamily};
|
|
31
|
+
font-size: ${tokens.typography.input.label.fontSize};
|
|
32
|
+
font-weight: ${tokens.typography.input.label.fontWeight};
|
|
33
|
+
line-height: ${tokens.typography.input.label.lineHeight};
|
|
34
|
+
white-space: nowrap;
|
|
35
|
+
margin: 0 ${tokens.spacings.comfortable.small};
|
|
36
|
+
`,
|
|
37
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
export declare const CheckboxFilterOptionAll: () => ReactElement;
|
|
2
3
|
export default CheckboxFilterOptionAll;
|
|
3
4
|
//# sourceMappingURL=CheckboxFilterOptionAll.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxFilterOptionAll.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterOptionAll.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CheckboxFilterOptionAll.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterOptionAll.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,OAAO,CAAC;AAWvD,eAAO,MAAM,uBAAuB,QAAO,YAmC1C,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { useObservableRef, useObservableState,
|
|
3
|
+
import { useObservableRef, useObservableState, useObservableSelector, } from '@equinor/fusion-observable/react';
|
|
4
4
|
import { useCheckboxFilterOptionContext } from './context';
|
|
5
5
|
import CheckboxFilterOption from './CheckboxFilterOption';
|
|
6
6
|
export const CheckboxFilterOptionAll = () => {
|
|
7
7
|
const { options$, selection$, setSelection } = useCheckboxFilterOptionContext();
|
|
8
|
-
const options = useObservableState(options$) || {};
|
|
9
|
-
const optionKeysRef = useObservableRef(
|
|
10
|
-
const selectedKeys = useObservableState(selection$) || new Set([]);
|
|
8
|
+
const { value: options } = useObservableState(options$) || {};
|
|
9
|
+
const optionKeysRef = useObservableRef(useObservableSelector(options$, (x) => Object.keys(x)));
|
|
10
|
+
const { value: selectedKeys } = useObservableState(selection$) || new Set([]);
|
|
11
11
|
const { totalCount } = Object.values(options || {}).reduce((acc, value) => {
|
|
12
12
|
acc.count += value.count;
|
|
13
13
|
acc.totalCount += value.totalCount;
|
|
14
14
|
return acc;
|
|
15
15
|
}, { count: 0, totalCount: 0 });
|
|
16
|
-
const checked = selectedKeys
|
|
17
|
-
const indeterminate = Boolean(selectedKeys
|
|
16
|
+
const checked = selectedKeys?.size === optionKeysRef.current?.length;
|
|
17
|
+
const indeterminate = Boolean(selectedKeys?.size && !checked);
|
|
18
18
|
const onOptionChange = useCallback(({ selected }) => {
|
|
19
19
|
setSelection(selected ? new Set(optionKeysRef.current) : new Set([]));
|
|
20
20
|
}, [setSelection, optionKeysRef]);
|
|
21
|
-
return (_jsx(CheckboxFilterOption, { name: "all", label: "
|
|
21
|
+
return (_jsx(CheckboxFilterOption, { name: "all", label: "All", indeterminate: indeterminate, checked: checked, count: totalCount, onOptionChange: onOptionChange }));
|
|
22
22
|
};
|
|
23
23
|
export default CheckboxFilterOptionAll;
|
|
24
|
-
//# sourceMappingURL=CheckboxFilterOptionAll.js.map
|