@equinor/fusion-react-filter 2.1.0-filter.8 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 -6
- package/dist/FilterProvider.js.map +1 -1
- package/dist/actions.d.ts +3 -3
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +1 -0
- package/dist/actions.js.map +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 -47
- package/dist/components/filter/FilterOptionHeader.js.map +1 -1
- 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 -4
- package/dist/components/filter/checkbox/CheckboxFilter.js.map +1 -1
- 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 -18
- package/dist/components/filter/checkbox/CheckboxFilter.style.js.map +1 -1
- 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 -10
- package/dist/components/filter/checkbox/CheckboxFilterOption.js.map +1 -1
- 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 -40
- package/dist/components/filter/checkbox/CheckboxFilterOption.style.js.map +1 -1
- 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 -7
- package/dist/components/filter/checkbox/CheckboxFilterOptionAll.js.map +1 -1
- 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 -7
- package/dist/components/filter/checkbox/CheckboxFilterOptions.js.map +1 -1
- 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 -4
- package/dist/components/filter/checkbox/CheckboxFilterProvider.js.map +1 -1
- 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.map +1 -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.map +1 -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/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 -7
- package/dist/components/filter/search/SearchFilter.js.map +1 -1
- package/dist/components/filter/types.d.ts +1 -1
- package/dist/components/filter/types.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js.map +1 -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 -7
- package/dist/components/misc/ClearFilterButton.js.map +1 -1
- 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 -13
- package/dist/components/misc/FilterContainer.js.map +1 -1
- 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 -21
- package/dist/components/misc/SelectionChips.js.map +1 -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 -29
- package/dist/components/panel/FilterPanel.js.map +1 -1
- 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 -27
- package/dist/components/panel/FilterPanelBar.js.map +1 -1
- 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 -3
- package/dist/components/panel/FilterPanelFilters.js.map +1 -1
- 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 -3
- package/dist/components/panel/FilterPanelProvider.js.map +1 -1
- 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 -4
- package/dist/components/panel/FilterPanelSelector.js.map +1 -1
- package/dist/context.d.ts +1 -2
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -0
- package/dist/context.js.map +1 -1
- package/dist/hooks/useClearFilter.d.ts.map +1 -1
- package/dist/hooks/useClearFilter.js +4 -3
- package/dist/hooks/useClearFilter.js.map +1 -1
- package/dist/hooks/useFilter.d.ts +1 -1
- package/dist/hooks/useFilter.d.ts.map +1 -1
- package/dist/hooks/useFilter.js.map +1 -1
- package/dist/hooks/useFilterData.d.ts +4 -4
- package/dist/hooks/useFilterData.d.ts.map +1 -1
- package/dist/hooks/useFilterData.js +5 -2
- package/dist/hooks/useFilterData.js.map +1 -1
- package/dist/hooks/useFilterSelection.d.ts +1 -1
- package/dist/hooks/useFilterSelection.d.ts.map +1 -1
- package/dist/hooks/useFilterSelection.js +4 -2
- package/dist/hooks/useFilterSelection.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/options/FilterOptionProvider.d.ts +3 -3
- package/dist/options/FilterOptionProvider.d.ts.map +1 -1
- package/dist/options/FilterOptionProvider.js +2 -2
- package/dist/options/FilterOptionProvider.js.map +1 -1
- package/dist/options/actions.d.ts +2 -2
- package/dist/options/actions.d.ts.map +1 -1
- package/dist/options/actions.js.map +1 -1
- package/dist/options/context.d.ts +1 -2
- package/dist/options/context.d.ts.map +1 -1
- package/dist/options/context.js +2 -1
- package/dist/options/context.js.map +1 -1
- 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 -1
- package/dist/options/create-options.js.map +1 -1
- package/dist/options/index.d.ts +1 -1
- package/dist/options/index.d.ts.map +1 -1
- package/dist/options/index.js +1 -1
- package/dist/options/index.js.map +1 -1
- package/dist/options/reducer.d.ts +11 -11
- package/dist/options/reducer.d.ts.map +1 -1
- package/dist/options/reducer.js +1 -0
- package/dist/options/reducer.js.map +1 -1
- package/dist/options/search/filter-option-match.d.ts.map +1 -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 -1
- package/dist/options/search/filter-option-search.js.map +1 -1
- package/dist/options/search/types.d.ts +2 -2
- package/dist/options/search/types.d.ts.map +1 -1
- package/dist/options/search/useFilterOptionSearch.d.ts +1 -4
- package/dist/options/search/useFilterOptionSearch.d.ts.map +1 -1
- package/dist/options/types.d.ts +11 -11
- package/dist/options/types.d.ts.map +1 -1
- package/dist/reducers.d.ts +34 -34
- package/dist/reducers.d.ts.map +1 -1
- package/dist/reducers.js +4 -1
- package/dist/reducers.js.map +1 -1
- package/dist/types.d.ts +12 -12
- package/dist/types.d.ts.map +1 -1
- package/options/package.json +2 -2
- package/package.json +30 -20
|
@@ -1,41 +1,38 @@
|
|
|
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;
|
|
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
|
+
};
|
|
41
38
|
//# sourceMappingURL=CheckboxFilterOption.style.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxFilterOption.style.js","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterOption.style.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CheckboxFilterOption.style.js","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterOption.style.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC,GAAG,CAA0C;;;;;;;;;;0BAUlC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI;;;MAGrE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAClB,SAAS;QACT;;;KAGD;;MAEC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CACd,KAAK;QACL;;KAED;GACF;IACD,OAAO,EAAE,MAAM,CAAC,IAAI,CAAA;aACT,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK;mBAC7B,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU;iBAC1C,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ;mBACpC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU;mBACxC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU;;gBAE3C,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK;GAC9C;CACF,CAAC"}
|
|
@@ -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,24 @@
|
|
|
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
24
|
//# sourceMappingURL=CheckboxFilterOptionAll.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxFilterOptionAll.js","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterOptionAll.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CheckboxFilterOptionAll.js","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterOptionAll.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,WAAW,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAiB,EAAE;IACxD,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,8BAA8B,EAAE,CAAC;IAChF,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,kBAAkB,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC9D,MAAM,aAAa,GAAG,gBAAgB,CAAC,qBAAqB,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/F,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,kBAAkB,CAAC,UAAU,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC;IAE9E,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CACxD,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACb,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC;QACzB,GAAG,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC;QACnC,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAC5B,CAAC;IAEF,MAAM,OAAO,GAAG,YAAY,EAAE,IAAI,KAAK,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC;IACrE,MAAM,aAAa,GAAG,OAAO,CAAC,YAAY,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9D,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,EAAE,QAAQ,EAAwC,EAAE,EAAE;QACrD,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC,EACD,CAAC,YAAY,EAAE,aAAa,CAAC,CAC9B,CAAC;IAEF,OAAO,CACL,KAAC,oBAAoB,IACnB,IAAI,EAAC,KAAK,EACV,KAAK,EAAC,KAAK,EACX,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,UAAU,EACjB,cAAc,EAAE,cAAc,GAC9B,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
type CheckboxFilterOptionsProps = {
|
|
3
|
+
readonly sortFn?: <T extends {
|
|
4
|
+
label: string;
|
|
5
|
+
}>(a: T, b: T) => number;
|
|
6
|
+
};
|
|
7
|
+
export declare const CheckboxFilterOptions: ({ sortFn }: CheckboxFilterOptionsProps) => ReactElement;
|
|
2
8
|
export default CheckboxFilterOptions;
|
|
3
9
|
//# sourceMappingURL=CheckboxFilterOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxFilterOptions.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterOptions.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CheckboxFilterOptions.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterOptions.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,OAAO,CAAC;AAUvD,KAAK,0BAA0B,GAAG;IAChC,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;AAEF,eAAO,MAAM,qBAAqB,GAAI,YAAY,0BAA0B,KAAG,YAyC9E,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { useObservableRef, useObservableState } from '@equinor/fusion-react
|
|
3
|
+
import { useObservableRef, useObservableState } from '@equinor/fusion-observable/react';
|
|
4
4
|
import { useCheckboxFilterOptionContext } from './context';
|
|
5
5
|
import { CheckboxFilterOption } from './CheckboxFilterOption';
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
export const CheckboxFilterOptions = () => {
|
|
6
|
+
const defaultSortFn = (a, b) => a.label.localeCompare(b.label);
|
|
7
|
+
export const CheckboxFilterOptions = ({ sortFn }) => {
|
|
9
8
|
const context = useCheckboxFilterOptionContext();
|
|
10
|
-
const data = useObservableState(context.options$);
|
|
9
|
+
const { value: data } = useObservableState(context.options$);
|
|
11
10
|
const selectionRef = useObservableRef(context.selection$);
|
|
12
11
|
const onOptionChange = useCallback((item) => {
|
|
13
12
|
const selection = new Set(selectionRef.current || []);
|
|
@@ -30,8 +29,8 @@ export const CheckboxFilterOptions = () => {
|
|
|
30
29
|
inactive: !value.count,
|
|
31
30
|
hide: value.hide,
|
|
32
31
|
}))
|
|
33
|
-
.sort(sortFn);
|
|
34
|
-
return (_jsx(_Fragment, { children: itemProps.map((props) => (_jsx(CheckboxFilterOption,
|
|
32
|
+
.sort(sortFn ?? defaultSortFn);
|
|
33
|
+
return (_jsx(_Fragment, { children: itemProps.map((props) => (_jsx(CheckboxFilterOption, { ...props }, props.name))) }));
|
|
35
34
|
};
|
|
36
35
|
export default CheckboxFilterOptions;
|
|
37
36
|
//# sourceMappingURL=CheckboxFilterOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxFilterOptions.js","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterOptions.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CheckboxFilterOptions.js","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterOptions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,WAAW,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAExF,OAAO,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAkC,MAAM,wBAAwB,CAAC;AAE9F,MAAM,aAAa,GAAG,CAA8B,CAAI,EAAE,CAAI,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAMlG,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EAAE,MAAM,EAA8B,EAAgB,EAAE;IAC5F,MAAM,OAAO,GAAG,8BAA8B,EAAE,CAAC;IACjD,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7D,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAE1D,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,IAA0C,EAAE,EAAE;QAC7C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QACtD,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAChC,IAAI,QAAQ,EAAE,CAAC;YACb,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;QACD,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC/D,CAAC,EACD,CAAC,OAAO,EAAE,YAAY,CAAC,CACxB,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;SACzC,GAAG,CACF,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CACf,CAAC;QACC,cAAc;QACd,IAAI,EAAE,GAAG;QACT,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ;QACzB,KAAK,EACH,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,MAAM,KAAK,CAAC,UAAU,EAAE;QACzF,QAAQ,EAAE,CAAC,KAAK,CAAC,KAAK;QACtB,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAA8B,CAClC;SACA,IAAI,CAAC,MAAM,IAAI,aAAa,CAAC,CAAC;IACjC,OAAO,CACL,4BACG,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACxB,KAAC,oBAAoB,OAAsB,KAAK,IAArB,KAAK,CAAC,IAAI,CAAe,CACrD,CAAC,GACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import { FilterOptionBuilder, FilterOptionSelector } from '../../../options/types';
|
|
1
|
+
import { type ReactElement, type PropsWithChildren } from 'react';
|
|
2
|
+
import type { FilterOptionBuilder, FilterOptionSelector } from '../../../options/types';
|
|
3
3
|
import type { CheckboxOption } from './types';
|
|
4
|
-
|
|
4
|
+
import type { FilterFn } from '../../../types';
|
|
5
|
+
export type CheckboxFilterProviderProps<TData extends Record<string, any>, TOption extends CheckboxOption = CheckboxOption> = {
|
|
5
6
|
filterKey: string;
|
|
6
7
|
title?: string;
|
|
7
|
-
|
|
8
|
+
filter?: {
|
|
9
|
+
filterFn: FilterFn<TData, Set<string>>;
|
|
10
|
+
optionFn: FilterOptionBuilder<TData, TOption, string>;
|
|
11
|
+
};
|
|
8
12
|
selector?: Extract<keyof TData, string> | string | FilterOptionSelector<TData>;
|
|
9
13
|
initial?: Set<string>;
|
|
10
14
|
};
|
|
11
|
-
export declare const CheckboxFilterProvider: <TData extends Record<string, any>, TOptions extends CheckboxOption = CheckboxOption>(props:
|
|
15
|
+
export declare const CheckboxFilterProvider: <TData extends Record<string, any>, TOptions extends CheckboxOption = CheckboxOption>(props: PropsWithChildren<CheckboxFilterProviderProps<TData, TOptions>>) => ReactElement;
|
|
12
16
|
export default CheckboxFilterProviderProps;
|
|
13
17
|
//# sourceMappingURL=CheckboxFilterProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxFilterProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterProvider.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"CheckboxFilterProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAI3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAExF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAU/C,MAAM,MAAM,2BAA2B,CAErC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,OAAO,SAAS,cAAc,GAAG,cAAc,IAC7C;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE;QACP,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QACvC,QAAQ,EAAE,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;KACvD,CAAC;IACF,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,sBAAsB,EAAE,CAEnC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,QAAQ,SAAS,cAAc,GAAG,cAAc,EAEhD,KAAK,EAAE,iBAAiB,CAAC,2BAA2B,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,KACnE,YA8BJ,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
|
|
@@ -3,14 +3,22 @@ import { useMemo } from 'react';
|
|
|
3
3
|
import { FilterOptionProvider } from '../../../options/FilterOptionProvider';
|
|
4
4
|
import { propertySelector } from '../../../options/create-options';
|
|
5
5
|
const createFilterFn = (selector) => (data, selection) => {
|
|
6
|
-
return selection.size
|
|
6
|
+
return selection.size
|
|
7
|
+
? data.filter((x) => selection.has(selector(x).key))
|
|
8
|
+
: data;
|
|
7
9
|
};
|
|
8
10
|
export const CheckboxFilterProvider = (props) => {
|
|
9
|
-
const { filterKey, selector = filterKey,
|
|
11
|
+
const { filterKey, selector = filterKey, title, initial, filter, children } = props;
|
|
10
12
|
const selectorFn = useMemo(() => typeof selector === 'function'
|
|
11
13
|
? selector
|
|
12
14
|
: propertySelector(selector || selector), [selector]);
|
|
13
|
-
const filterFn = useMemo(() =>
|
|
14
|
-
|
|
15
|
+
const filterFn = useMemo(() => {
|
|
16
|
+
if (filter?.filterFn)
|
|
17
|
+
return filter.filterFn;
|
|
18
|
+
if (!selectorFn)
|
|
19
|
+
throw Error('Could not create filter. Please provide either filterFn or filterSelector.');
|
|
20
|
+
return createFilterFn(selectorFn);
|
|
21
|
+
}, [selectorFn, filter?.filterFn]);
|
|
22
|
+
return (_jsx(FilterOptionProvider, { selector: selectorFn, optionBuilder: filter?.optionFn, filter: { key: filterKey, title, initial, filterFn }, children: children }));
|
|
15
23
|
};
|
|
16
24
|
//# sourceMappingURL=CheckboxFilterProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxFilterProvider.js","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CheckboxFilterProvider.js","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/CheckboxFilterProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA6C,OAAO,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMnE,MAAM,cAAc,GAClB,CAAyD,QAAqC,EAAE,EAAE,CAClG,CAAC,IAAa,EAAE,SAAsB,EAAE,EAAE;IACxC,OAAO,SAAS,CAAC,IAAI;QACnB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAwB,CAAC,CAAC;QACzE,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAC;AAiBJ,MAAM,CAAC,MAAM,sBAAsB,GAMf,CAKlB,KAAsE,EACxD,EAAE;IAChB,MAAM,EAAE,SAAS,EAAE,QAAQ,GAAG,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACpF,MAAM,UAAU,GAAG,OAAO,CACxB,GAAG,EAAE,CACH,OAAO,QAAQ,KAAK,UAAU;QAC5B,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,gBAAgB,CAAC,QAAQ,IAAK,QAAyC,CAAC,EAC9E,CAAC,QAAQ,CAAC,CACX,CAAC;IACF,MAAM,QAAQ,GAAG,OAAO,CAA+B,GAAG,EAAE;QAC1D,IAAI,MAAM,EAAE,QAAQ;YAAE,OAAO,MAAM,CAAC,QAAQ,CAAC;QAC7C,IAAI,CAAC,UAAU;YACb,MAAM,KAAK,CAAC,4EAA4E,CAAC,CAAC;QAC5F,OAAO,cAAc,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACnC,OAAO,CACL,KAAC,oBAAoB,IACnB,QAAQ,EAAE,UAAU,EACpB,aAAa,EAAE,MAAM,EAAE,QAAQ,EAC/B,MAAM,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAEnD,QAAQ,GACY,CACxB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FilterOptionContext } from '../../../options';
|
|
1
|
+
import { type FilterOptionContext } from '../../../options';
|
|
2
2
|
import type { CheckboxOption } from './types';
|
|
3
3
|
export declare const useCheckboxFilterOptionContext: <TOption extends CheckboxOption = CheckboxOption, TValue = string>() => FilterOptionContext<TOption, TValue>;
|
|
4
4
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,eAAO,MAAM,8BAA8B,GACzC,OAAO,SAAS,cAAc,GAAG,cAAc,EAC/C,MAAM,GAAG,MAAM,OACZ,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAA8C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAA4B,MAAM,kBAAkB,CAAC;AAGpF,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAGJ,EAAE,CAAC,sBAAsB,EAAmB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { CheckboxFilter, CheckboxFilterProps, default } from './CheckboxFilter';
|
|
1
|
+
export { CheckboxFilter, type CheckboxFilterProps, default } from './CheckboxFilter';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA4B,OAAO,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/checkbox/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import { type TextFieldProps } from '@equinor/eds-core-react';
|
|
2
3
|
import type { FilterFn } from '../../../types';
|
|
3
|
-
export
|
|
4
|
+
export type SearchFilterProps<TData> = Omit<TextFieldProps, 'onInput' | 'ref' | 'id'> & {
|
|
4
5
|
/** identifier for filter */
|
|
5
|
-
filterKey: string;
|
|
6
|
+
readonly filterKey: string;
|
|
6
7
|
/** function for filtering by provided query */
|
|
7
|
-
filterFn?: FilterFn<TData, string>;
|
|
8
|
+
readonly filterFn?: FilterFn<TData, string>;
|
|
8
9
|
};
|
|
9
10
|
/**
|
|
10
11
|
* Simple text filter
|
|
@@ -12,6 +13,6 @@ export declare type SearchFilterProps<TData> = Omit<TextInputProps, 'onInput' |
|
|
|
12
13
|
* __NOTE__ if not `filterFn` provided, default will be created, this filter is brute and
|
|
13
14
|
* `JSON.stringify` provided data object, this might not be optimal for heavy data sets.
|
|
14
15
|
*/
|
|
15
|
-
export declare const SearchFilter: <TData>(props: SearchFilterProps<TData>) =>
|
|
16
|
+
export declare const SearchFilter: <TData>(props: SearchFilterProps<TData>) => ReactElement;
|
|
16
17
|
export default SearchFilter;
|
|
17
18
|
//# sourceMappingURL=SearchFilter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchFilter.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/search/SearchFilter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SearchFilter.d.ts","sourceRoot":"","sources":["../../../../src/components/filter/search/SearchFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAKlB,MAAM,OAAO,CAAC;AAIf,OAAO,EAAa,KAAK,cAAc,EAAQ,MAAM,yBAAyB,CAAC;AAI/E,OAAO,KAAK,EAAU,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAavD,MAAM,MAAM,iBAAiB,CAAC,KAAK,IAAI,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,KAAK,GAAG,IAAI,CAAC,GAAG;IACtF,4BAA4B;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,EAAG,OAAO,iBAAiB,CAAC,KAAK,CAAC,KAAG,YAgDtE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useMemo, useRef } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { useCallback, useMemo, useRef, } from 'react';
|
|
3
|
+
import { useObservableSelector } from '@equinor/fusion-observable/react';
|
|
4
|
+
import { TextField, Icon } from '@equinor/eds-core-react';
|
|
5
5
|
import { useFilter, useFilterSelection } from '../../../hooks';
|
|
6
|
+
import { search } from '@equinor/eds-icons';
|
|
7
|
+
Icon.add({ search });
|
|
6
8
|
const defaultMatcher = (data, query) => {
|
|
7
9
|
/** early escape, no filter */
|
|
8
10
|
if (!query)
|
|
9
11
|
return data;
|
|
10
12
|
const matcher = new RegExp(query, 'i');
|
|
11
|
-
return data.filter((x) => !!JSON.stringify(Object.values(x)).match(matcher));
|
|
13
|
+
return data.filter((x) => !!JSON.stringify(Object.values(x ?? {})).match(matcher));
|
|
12
14
|
};
|
|
13
15
|
/**
|
|
14
16
|
* Simple text filter
|
|
@@ -32,16 +34,16 @@ export const SearchFilter = (props) => {
|
|
|
32
34
|
setSelection(e.currentTarget.value);
|
|
33
35
|
}, [setSelection]);
|
|
34
36
|
/** subscribe to changes in the filter selection */
|
|
35
|
-
|
|
37
|
+
useObservableSelector(
|
|
36
38
|
/** create an observable selection for filter */
|
|
37
39
|
useFilterSelection(props.filterKey),
|
|
38
40
|
/** update value of text input when selection changes */
|
|
39
41
|
useCallback((query) => {
|
|
40
42
|
if (inputRef.current) {
|
|
41
|
-
inputRef.current.value = query || '';
|
|
43
|
+
inputRef.current.value = query ? Array.from(query)[0] || '' : '';
|
|
42
44
|
}
|
|
43
45
|
}, []));
|
|
44
|
-
return _jsx(
|
|
46
|
+
return (_jsx(TextField, { id: filterKey, ref: inputRef, onInput: onInput, type: "search", inputIcon: _jsx(Icon, { name: "search" }), ...args }));
|
|
45
47
|
};
|
|
46
48
|
export default SearchFilter;
|
|
47
49
|
//# sourceMappingURL=SearchFilter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchFilter.js","sourceRoot":"","sources":["../../../../src/components/filter/search/SearchFilter.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"SearchFilter.js","sourceRoot":"","sources":["../../../../src/components/filter/search/SearchFilter.tsx"],"names":[],"mappings":";AAAA,OAAO,EAIL,WAAW,EACX,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAuB,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/E,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAI/D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AAErB,MAAM,cAAc,GAAG,CAAS,IAAa,EAAE,KAAa,EAAW,EAAE;IACvE,8BAA8B;IAC9B,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACvC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AACrF,CAAC,CAAC;AASF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAS,KAA+B,EAAgB,EAAE;IACpF,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAE/C,2BAA2B;IAC3B,MAAM,MAAM,GAAG,OAAO,CACpB,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,EAAE,SAAS;QACd,QAAQ,EAAE,QAAQ,IAAI,cAAc;KACrC,CAAC,EACF,CAAC,SAAS,EAAE,QAAQ,CAAC,CACtB,CAAC;IAEF,4CAA4C;IAC5C,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAEvC,2CAA2C;IAC3C,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAEhD,uDAAuD;IACvD,MAAM,OAAO,GAAG,WAAW,CACzB,CAAC,CAA8B,EAAE,EAAE;QACjC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC,EACD,CAAC,YAAY,CAAC,CACf,CAAC;IAEF,mDAAmD;IACnD,qBAAqB;IACnB,iDAAiD;IACjD,kBAAkB,CAAS,KAAK,CAAC,SAAS,CAAC;IAC3C,wDAAwD;IACxD,WAAW,CAAC,CAAC,KAAmB,EAAE,EAAE;QAClC,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACrB,QAAQ,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CACP,CAAC;IAEF,OAAO,CACL,KAAC,SAAS,IACR,EAAE,EAAE,SAAS,EACb,GAAG,EAAE,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,KAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,GAAG,KAC5B,IAA0D,GAC/D,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/filter/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/filter/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { FilterComponent, CheckboxFilter, FilterOptionHeader, SearchFilter } from './filter';
|
|
2
2
|
export { ClearFilterButton, FilterContainer, SelectionChips } from './misc';
|
|
3
|
-
export { FilterPanel } from './panel';
|
|
3
|
+
export { FilterPanel, FilterPanelProps } from './panel';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAoB,MAAM,SAAS,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { type ReactElement, type ForwardedRef, type PropsWithChildren } from 'react';
|
|
2
|
+
import { type ButtonProps } from '@equinor/eds-core-react';
|
|
3
|
+
export type ClearFilterButtonProps = PropsWithChildren<Omit<ButtonProps, 'onClick'> & {
|
|
4
|
+
ref?: ForwardedRef<HTMLButtonElement>;
|
|
5
|
+
}>;
|
|
3
6
|
/**
|
|
4
7
|
* Component for resetting filter values.
|
|
5
8
|
* uses the `useClearFilter` hook
|
|
6
|
-
* inherits `ButtonProps` from `@equinor/fusion-react-button`
|
|
7
9
|
*/
|
|
8
|
-
export declare const ClearFilterButton: (props: ClearFilterButtonProps) =>
|
|
10
|
+
export declare const ClearFilterButton: (props: ClearFilterButtonProps) => ReactElement;
|
|
9
11
|
export default ClearFilterButton;
|
|
10
12
|
//# sourceMappingURL=ClearFilterButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClearFilterButton.d.ts","sourceRoot":"","sources":["../../../src/components/misc/ClearFilterButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ClearFilterButton.d.ts","sourceRoot":"","sources":["../../../src/components/misc/ClearFilterButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAIlG,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAInE,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CACpD,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAA;CAAE,CACzE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,KAAG,YA0BjE,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { useForwardRef } from '@equinor/fusion-react-utils';
|
|
4
|
-
import {
|
|
5
|
-
import { Button } from '@equinor/
|
|
4
|
+
import { useObservableSubscription } from '@equinor/fusion-observable/react';
|
|
5
|
+
import { Button } from '@equinor/eds-core-react';
|
|
6
6
|
import { useClearFilter } from '../../hooks/useClearFilter';
|
|
7
7
|
/**
|
|
8
8
|
* Component for resetting filter values.
|
|
9
9
|
* uses the `useClearFilter` hook
|
|
10
|
-
* inherits `ButtonProps` from `@equinor/fusion-react-button`
|
|
11
10
|
*/
|
|
12
11
|
export const ClearFilterButton = (props) => {
|
|
13
|
-
const {
|
|
12
|
+
const { children, ...args } = props;
|
|
14
13
|
const { clear, changed$ } = useClearFilter();
|
|
15
14
|
const ref = useForwardRef(props.ref);
|
|
16
15
|
/** Subscribe to changes and toggle `disable` of button */
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
useObservableSubscription(changed$, useCallback((changed) => {
|
|
17
|
+
if (ref.current) {
|
|
18
|
+
ref.current.disabled = !Object.keys(changed).length;
|
|
19
|
+
}
|
|
19
20
|
}, [ref]));
|
|
20
21
|
/** Reset filters on click */
|
|
21
22
|
const onClick = useCallback(() => clear(), [clear]);
|
|
22
|
-
return _jsx(Button,
|
|
23
|
+
return (_jsx(Button, { variant: "ghost", ...args, ref, onClick, children: children ?? 'Clear Filter' }));
|
|
23
24
|
};
|
|
24
25
|
export default ClearFilterButton;
|
|
25
26
|
//# sourceMappingURL=ClearFilterButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClearFilterButton.js","sourceRoot":"","sources":["../../../src/components/misc/ClearFilterButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"ClearFilterButton.js","sourceRoot":"","sources":["../../../src/components/misc/ClearFilterButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAgE,MAAM,OAAO,CAAC;AAElG,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAoB,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAM5D;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAA6B,EAAgB,EAAE;IAC/E,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACpC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,cAAc,EAAE,CAAC;IAC7C,MAAM,GAAG,GAAG,aAAa,CAAoB,KAAK,CAAC,GAAG,CAAC,CAAC;IAExD,0DAA0D;IAC1D,yBAAyB,CACvB,QAAQ,EACR,WAAW,CACT,CAAC,OAAgC,EAAE,EAAE;QACnC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAChB,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;QACtD,CAAC;IACH,CAAC,EACD,CAAC,GAAG,CAAC,CACN,CACF,CAAC;IAEF,6BAA6B;IAC7B,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEpD,OAAO,CACL,KAAC,MAAM,IAAC,OAAO,EAAC,OAAO,EAAO,GAAG,IAAI,EAAE,GAAG,EAAE,OAAO,YAChD,QAAQ,IAAI,cAAc,GACpB,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { ReactElement, PropsWithChildren, HTMLAttributes } from 'react';
|
|
2
|
+
import { tokens } from '@equinor/eds-tokens';
|
|
3
|
+
type SpacingKey = keyof typeof tokens.spacings.comfortable;
|
|
4
|
+
type StyleProps = {
|
|
5
|
+
readonly spacing?: SpacingKey;
|
|
5
6
|
};
|
|
6
|
-
export
|
|
7
|
+
export type FilterContainerProps = HTMLAttributes<HTMLDivElement> & StyleProps;
|
|
7
8
|
/**
|
|
8
9
|
* Components for displaying filters
|
|
9
10
|
*/
|
|
10
|
-
export declare const FilterContainer: (props:
|
|
11
|
+
export declare const FilterContainer: (props: PropsWithChildren<FilterContainerProps>) => ReactElement;
|
|
11
12
|
export default FilterContainer;
|
|
12
13
|
//# sourceMappingURL=FilterContainer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterContainer.d.ts","sourceRoot":"","sources":["../../../src/components/misc/FilterContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"FilterContainer.d.ts","sourceRoot":"","sources":["../../../src/components/misc/FilterContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE7E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,KAAK,UAAU,GAAG,MAAM,OAAO,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC;AAa3D,KAAK,UAAU,GAAG;IAChB,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG,UAAU,CAAC;AAE/E;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,iBAAiB,CAAC,oBAAoB,CAAC,KAAG,YAOhF,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { tokens } from '@equinor/eds-tokens';
|
|
4
|
+
const Styled = {
|
|
5
|
+
Root: styled.div `
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
flex: auto;
|
|
8
|
+
gap: ${({ $spacing }) => tokens.spacings.comfortable[$spacing || 'medium']};
|
|
9
|
+
& > * {
|
|
10
|
+
flex: 1;
|
|
11
|
+
}
|
|
12
|
+
`,
|
|
13
|
+
};
|
|
13
14
|
/**
|
|
14
15
|
* Components for displaying filters
|
|
15
16
|
*/
|
|
16
17
|
export const FilterContainer = (props) => {
|
|
17
18
|
const { children, className, spacing, ...args } = props;
|
|
18
|
-
|
|
19
|
-
return (_jsx("div", Object.assign({ className: clsx(styles.root, className) }, args, { children: children }), void 0));
|
|
19
|
+
return (_jsx(Styled.Root, { className: className, "$spacing": spacing, ...args, children: children }));
|
|
20
20
|
};
|
|
21
21
|
export default FilterContainer;
|
|
22
22
|
//# sourceMappingURL=FilterContainer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterContainer.js","sourceRoot":"","sources":["../../../src/components/misc/FilterContainer.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"FilterContainer.js","sourceRoot":"","sources":["../../../src/components/misc/FilterContainer.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7C,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,MAAM,CAAC,GAAG,CAA2B;;;WAGlC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,IAAI,QAAQ,CAAC;;;;GAI3E;CACF,CAAC;AAQF;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAA8C,EAAgB,EAAE;IAC9F,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACxD,OAAO,CACL,KAAC,MAAM,CAAC,IAAI,IAAC,SAAS,EAAE,SAAS,cAAY,OAAO,KAAM,IAAI,YAC3D,QAAQ,GACG,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|