@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.
Files changed (186) hide show
  1. package/LICENSE +21 -0
  2. package/components/package.json +1 -1
  3. package/dist/FilterProvider.d.ts +3 -3
  4. package/dist/FilterProvider.d.ts.map +1 -1
  5. package/dist/FilterProvider.js +7 -7
  6. package/dist/actions.d.ts +3 -3
  7. package/dist/actions.d.ts.map +1 -1
  8. package/dist/actions.js +1 -1
  9. package/dist/components/filter/FilterOptionHeader.d.ts +4 -4
  10. package/dist/components/filter/FilterOptionHeader.d.ts.map +1 -1
  11. package/dist/components/filter/FilterOptionHeader.js +55 -48
  12. package/dist/components/filter/checkbox/CheckboxFilter.d.ts +16 -6
  13. package/dist/components/filter/checkbox/CheckboxFilter.d.ts.map +1 -1
  14. package/dist/components/filter/checkbox/CheckboxFilter.js +4 -5
  15. package/dist/components/filter/checkbox/CheckboxFilter.style.d.ts +9 -4
  16. package/dist/components/filter/checkbox/CheckboxFilter.style.d.ts.map +1 -1
  17. package/dist/components/filter/checkbox/CheckboxFilter.style.js +21 -19
  18. package/dist/components/filter/checkbox/CheckboxFilterOption.d.ts +8 -7
  19. package/dist/components/filter/checkbox/CheckboxFilterOption.d.ts.map +1 -1
  20. package/dist/components/filter/checkbox/CheckboxFilterOption.js +4 -11
  21. package/dist/components/filter/checkbox/CheckboxFilterOption.style.d.ts +10 -2
  22. package/dist/components/filter/checkbox/CheckboxFilterOption.style.d.ts.map +1 -1
  23. package/dist/components/filter/checkbox/CheckboxFilterOption.style.js +37 -41
  24. package/dist/components/filter/checkbox/CheckboxFilterOptionAll.d.ts +2 -1
  25. package/dist/components/filter/checkbox/CheckboxFilterOptionAll.d.ts.map +1 -1
  26. package/dist/components/filter/checkbox/CheckboxFilterOptionAll.js +7 -8
  27. package/dist/components/filter/checkbox/CheckboxFilterOptions.d.ts +7 -1
  28. package/dist/components/filter/checkbox/CheckboxFilterOptions.d.ts.map +1 -1
  29. package/dist/components/filter/checkbox/CheckboxFilterOptions.js +6 -8
  30. package/dist/components/filter/checkbox/CheckboxFilterProvider.d.ts +9 -5
  31. package/dist/components/filter/checkbox/CheckboxFilterProvider.d.ts.map +1 -1
  32. package/dist/components/filter/checkbox/CheckboxFilterProvider.js +12 -5
  33. package/dist/components/filter/checkbox/context.d.ts +1 -1
  34. package/dist/components/filter/checkbox/context.d.ts.map +1 -1
  35. package/dist/components/filter/checkbox/context.js +0 -1
  36. package/dist/components/filter/checkbox/index.d.ts +1 -1
  37. package/dist/components/filter/checkbox/index.d.ts.map +1 -1
  38. package/dist/components/filter/checkbox/index.js +0 -1
  39. package/dist/components/filter/checkbox/types.d.ts +2 -2
  40. package/dist/components/filter/checkbox/types.d.ts.map +1 -1
  41. package/dist/components/filter/checkbox/types.js +0 -1
  42. package/dist/components/filter/index.js +0 -1
  43. package/dist/components/filter/search/SearchFilter.d.ts +6 -5
  44. package/dist/components/filter/search/SearchFilter.d.ts.map +1 -1
  45. package/dist/components/filter/search/SearchFilter.js +9 -8
  46. package/dist/components/filter/search/index.js +0 -1
  47. package/dist/components/filter/types.d.ts +1 -1
  48. package/dist/components/filter/types.d.ts.map +1 -1
  49. package/dist/components/filter/types.js +0 -1
  50. package/dist/components/index.d.ts +1 -1
  51. package/dist/components/index.d.ts.map +1 -1
  52. package/dist/components/index.js +0 -1
  53. package/dist/components/misc/ClearFilterButton.d.ts +6 -4
  54. package/dist/components/misc/ClearFilterButton.d.ts.map +1 -1
  55. package/dist/components/misc/ClearFilterButton.js +8 -8
  56. package/dist/components/misc/FilterContainer.d.ts +7 -6
  57. package/dist/components/misc/FilterContainer.d.ts.map +1 -1
  58. package/dist/components/misc/FilterContainer.js +13 -14
  59. package/dist/components/misc/SelectionChips.d.ts +5 -4
  60. package/dist/components/misc/SelectionChips.d.ts.map +1 -1
  61. package/dist/components/misc/SelectionChips.js +29 -22
  62. package/dist/components/misc/index.js +0 -1
  63. package/dist/components/panel/FilterPanel.d.ts +7 -3
  64. package/dist/components/panel/FilterPanel.d.ts.map +1 -1
  65. package/dist/components/panel/FilterPanel.js +29 -30
  66. package/dist/components/panel/FilterPanelBar.d.ts +6 -2
  67. package/dist/components/panel/FilterPanelBar.d.ts.map +1 -1
  68. package/dist/components/panel/FilterPanelBar.js +29 -28
  69. package/dist/components/panel/FilterPanelFilters.d.ts +4 -4
  70. package/dist/components/panel/FilterPanelFilters.d.ts.map +1 -1
  71. package/dist/components/panel/FilterPanelFilters.js +4 -4
  72. package/dist/components/panel/FilterPanelProvider.d.ts +12 -12
  73. package/dist/components/panel/FilterPanelProvider.d.ts.map +1 -1
  74. package/dist/components/panel/FilterPanelProvider.js +4 -4
  75. package/dist/components/panel/FilterPanelSelector.d.ts +3 -3
  76. package/dist/components/panel/FilterPanelSelector.d.ts.map +1 -1
  77. package/dist/components/panel/FilterPanelSelector.js +4 -5
  78. package/dist/components/panel/index.js +0 -1
  79. package/dist/context.d.ts +1 -2
  80. package/dist/context.d.ts.map +1 -1
  81. package/dist/context.js +1 -1
  82. package/dist/hooks/index.js +0 -1
  83. package/dist/hooks/useClearFilter.d.ts.map +1 -1
  84. package/dist/hooks/useClearFilter.js +4 -4
  85. package/dist/hooks/useFilter.d.ts +1 -1
  86. package/dist/hooks/useFilter.d.ts.map +1 -1
  87. package/dist/hooks/useFilter.js +0 -1
  88. package/dist/hooks/useFilterData.d.ts +4 -4
  89. package/dist/hooks/useFilterData.d.ts.map +1 -1
  90. package/dist/hooks/useFilterData.js +5 -3
  91. package/dist/hooks/useFilterSelection.d.ts +1 -1
  92. package/dist/hooks/useFilterSelection.d.ts.map +1 -1
  93. package/dist/hooks/useFilterSelection.js +4 -3
  94. package/dist/index.d.ts +1 -1
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +0 -1
  97. package/dist/options/FilterOptionProvider.d.ts +3 -3
  98. package/dist/options/FilterOptionProvider.d.ts.map +1 -1
  99. package/dist/options/FilterOptionProvider.js +2 -3
  100. package/dist/options/actions.d.ts +2 -2
  101. package/dist/options/actions.d.ts.map +1 -1
  102. package/dist/options/actions.js +0 -1
  103. package/dist/options/context.d.ts +1 -2
  104. package/dist/options/context.d.ts.map +1 -1
  105. package/dist/options/context.js +2 -2
  106. package/dist/options/create-options.d.ts +1 -1
  107. package/dist/options/create-options.d.ts.map +1 -1
  108. package/dist/options/create-options.js +3 -2
  109. package/dist/options/index.d.ts +1 -1
  110. package/dist/options/index.d.ts.map +1 -1
  111. package/dist/options/index.js +1 -2
  112. package/dist/options/reducer.d.ts +11 -11
  113. package/dist/options/reducer.d.ts.map +1 -1
  114. package/dist/options/reducer.js +1 -1
  115. package/dist/options/search/filter-option-match.d.ts.map +1 -1
  116. package/dist/options/search/filter-option-match.js +0 -1
  117. package/dist/options/search/filter-option-search.d.ts +1 -4
  118. package/dist/options/search/filter-option-search.d.ts.map +1 -1
  119. package/dist/options/search/filter-option-search.js +3 -2
  120. package/dist/options/search/index.js +0 -1
  121. package/dist/options/search/types.d.ts +2 -2
  122. package/dist/options/search/types.d.ts.map +1 -1
  123. package/dist/options/search/types.js +0 -1
  124. package/dist/options/search/useFilterOptionSearch.d.ts +1 -4
  125. package/dist/options/search/useFilterOptionSearch.d.ts.map +1 -1
  126. package/dist/options/search/useFilterOptionSearch.js +0 -1
  127. package/dist/options/types.d.ts +11 -11
  128. package/dist/options/types.d.ts.map +1 -1
  129. package/dist/options/types.js +0 -1
  130. package/dist/reducers.d.ts +34 -34
  131. package/dist/reducers.d.ts.map +1 -1
  132. package/dist/reducers.js +4 -2
  133. package/dist/types.d.ts +12 -12
  134. package/dist/types.d.ts.map +1 -1
  135. package/dist/types.js +0 -1
  136. package/options/package.json +2 -2
  137. package/package.json +30 -20
  138. package/dist/FilterProvider.js.map +0 -1
  139. package/dist/actions.js.map +0 -1
  140. package/dist/components/filter/FilterOptionHeader.js.map +0 -1
  141. package/dist/components/filter/checkbox/CheckboxFilter.js.map +0 -1
  142. package/dist/components/filter/checkbox/CheckboxFilter.style.js.map +0 -1
  143. package/dist/components/filter/checkbox/CheckboxFilterOption.js.map +0 -1
  144. package/dist/components/filter/checkbox/CheckboxFilterOption.style.js.map +0 -1
  145. package/dist/components/filter/checkbox/CheckboxFilterOptionAll.js.map +0 -1
  146. package/dist/components/filter/checkbox/CheckboxFilterOptions.js.map +0 -1
  147. package/dist/components/filter/checkbox/CheckboxFilterProvider.js.map +0 -1
  148. package/dist/components/filter/checkbox/context.js.map +0 -1
  149. package/dist/components/filter/checkbox/index.js.map +0 -1
  150. package/dist/components/filter/checkbox/types.js.map +0 -1
  151. package/dist/components/filter/index.js.map +0 -1
  152. package/dist/components/filter/search/SearchFilter.js.map +0 -1
  153. package/dist/components/filter/search/index.js.map +0 -1
  154. package/dist/components/filter/types.js.map +0 -1
  155. package/dist/components/index.js.map +0 -1
  156. package/dist/components/misc/ClearFilterButton.js.map +0 -1
  157. package/dist/components/misc/FilterContainer.js.map +0 -1
  158. package/dist/components/misc/SelectionChips.js.map +0 -1
  159. package/dist/components/misc/index.js.map +0 -1
  160. package/dist/components/panel/FilterPanel.js.map +0 -1
  161. package/dist/components/panel/FilterPanelBar.js.map +0 -1
  162. package/dist/components/panel/FilterPanelFilters.js.map +0 -1
  163. package/dist/components/panel/FilterPanelProvider.js.map +0 -1
  164. package/dist/components/panel/FilterPanelSelector.js.map +0 -1
  165. package/dist/components/panel/index.js.map +0 -1
  166. package/dist/context.js.map +0 -1
  167. package/dist/hooks/index.js.map +0 -1
  168. package/dist/hooks/useClearFilter.js.map +0 -1
  169. package/dist/hooks/useFilter.js.map +0 -1
  170. package/dist/hooks/useFilterData.js.map +0 -1
  171. package/dist/hooks/useFilterSelection.js.map +0 -1
  172. package/dist/index.js.map +0 -1
  173. package/dist/options/FilterOptionProvider.js.map +0 -1
  174. package/dist/options/actions.js.map +0 -1
  175. package/dist/options/context.js.map +0 -1
  176. package/dist/options/create-options.js.map +0 -1
  177. package/dist/options/index.js.map +0 -1
  178. package/dist/options/reducer.js.map +0 -1
  179. package/dist/options/search/filter-option-match.js.map +0 -1
  180. package/dist/options/search/filter-option-search.js.map +0 -1
  181. package/dist/options/search/index.js.map +0 -1
  182. package/dist/options/search/types.js.map +0 -1
  183. package/dist/options/search/useFilterOptionSearch.js.map +0 -1
  184. package/dist/options/types.js.map +0 -1
  185. package/dist/reducers.js.map +0 -1
  186. package/dist/types.js.map +0 -1
@@ -1,3 +1,9 @@
1
- export declare const CheckboxFilterOptions: () => JSX.Element;
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":"AAWA,eAAO,MAAM,qBAAqB,QAAO,WAwCxC,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
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-observable';
3
+ import { useObservableRef, useObservableState } from '@equinor/fusion-observable/react';
4
4
  import { useCheckboxFilterOptionContext } from './context';
5
5
  import { CheckboxFilterOption } from './CheckboxFilterOption';
6
- // TODO - make arg!
7
- const sortFn = (a, b) => a.label.localeCompare(b.label);
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,7 @@ 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, Object.assign({}, props), props.name))) }, void 0));
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
- //# sourceMappingURL=CheckboxFilterOptions.js.map
@@ -1,13 +1,17 @@
1
- /// <reference types="react" />
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
- export declare type CheckboxFilterProviderProps<TData extends Record<string, any>, TOption extends CheckboxOption = CheckboxOption> = {
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
- optionBuilder?: FilterOptionBuilder<TData, TOption, string>;
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: import("react").PropsWithChildren<CheckboxFilterProviderProps<TData, TOptions>>) => JSX.Element;
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":";AAIA,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAQ9C,oBAAY,2BAA2B,CACrC,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,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,sBAAsB,mLAKhC,WAmBF,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
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,21 @@ 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 ? data.filter((x) => selection.has(selector(x).key)) : data;
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, optionBuilder, title, initial, children } = props;
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(() => createFilterFn(selectorFn), [selectorFn]);
14
- return (_jsx(FilterOptionProvider, Object.assign({ selector: selectorFn, optionBuilder: optionBuilder, filter: { key: filterKey, title, initial, filterFn } }, { children: children }), void 0));
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
- //# sourceMappingURL=CheckboxFilterProvider.js.map
@@ -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;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,eAAO,MAAM,8BAA8B,8GAG2C,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,3 +1,2 @@
1
1
  import { useFilterOptionContext } from '../../../options';
2
2
  export const useCheckboxFilterOptionContext = () => useFilterOptionContext();
3
- //# sourceMappingURL=context.js.map
@@ -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,2 +1 @@
1
1
  export { CheckboxFilter, default } from './CheckboxFilter';
2
- //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
- import { FilterOption } from '../../../options';
2
- export declare type CheckboxOption = FilterOption & {
1
+ import type { FilterOption } from '../../../options';
2
+ export type CheckboxOption = FilterOption & {
3
3
  label: string;
4
4
  count: number;
5
5
  totalCount: number;
@@ -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;AAEhD,oBAAY,cAAc,GAAG,YAAY,GAAG;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,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,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -2,4 +2,3 @@ export { CheckboxFilter } from './checkbox';
2
2
  export { SearchFilter } from './search';
3
3
  export { FilterOptionHeader } from './FilterOptionHeader';
4
4
  export * from './types';
5
- //# sourceMappingURL=index.js.map
@@ -1,10 +1,11 @@
1
- import { TextInputProps } from '@equinor/fusion-react-textinput';
1
+ import { type ReactElement } from 'react';
2
+ import { type TextFieldProps } from '@equinor/eds-core-react';
2
3
  import type { FilterFn } from '../../../types';
3
- export declare type SearchFilterProps<TData> = Omit<TextInputProps, 'onInput' | 'ref'> & {
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>) => JSX.Element;
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":"AAIA,OAAO,EAAyC,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAIxG,OAAO,KAAK,EAAU,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AASvD,oBAAY,iBAAiB,CAAC,KAAK,IAAI,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,KAAK,CAAC,GAAG;IAC/E,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,8CAA8C,WAuCtE,CAAC;AAEF,eAAe,YAAY,CAAC"}
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 { useSubscription } from '@equinor/fusion-react-observable';
4
- import { TextInput } from '@equinor/fusion-react-textinput';
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,15 @@ export const SearchFilter = (props) => {
32
34
  setSelection(e.currentTarget.value);
33
35
  }, [setSelection]);
34
36
  /** subscribe to changes in the filter selection */
35
- useSubscription(
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(TextInput, Object.assign({ ref: inputRef, onInput: onInput, type: "search", variant: "outlined", icon: "search" }, args), void 0);
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
- //# sourceMappingURL=SearchFilter.js.map
@@ -1,2 +1 @@
1
1
  export { SearchFilter } from './SearchFilter';
2
- //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- export declare type FilterComponent = {
1
+ export type FilterComponent = {
2
2
  /** unique key for filter */
3
3
  filterKey: string;
4
4
  /** title for filter */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/filter/types.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe,GAAG;IAC5B,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC"}
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,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -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,4 +1,3 @@
1
1
  export { CheckboxFilter, FilterOptionHeader, SearchFilter } from './filter';
2
2
  export { ClearFilterButton, FilterContainer, SelectionChips } from './misc';
3
3
  export { FilterPanel } from './panel';
4
- //# sourceMappingURL=index.js.map
@@ -1,10 +1,12 @@
1
- import { ButtonProps } from '@equinor/fusion-react-button';
2
- export declare type ClearFilterButtonProps = Omit<ButtonProps, 'onClick'>;
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) => JSX.Element;
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":"AAIA,OAAO,EAAU,WAAW,EAA2B,MAAM,8BAA8B,CAAC;AAI5F,oBAAY,sBAAsB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,UAAW,sBAAsB,KAAG,WAoBjE,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
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,25 @@
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 { useSubscription } from '@equinor/fusion-react-observable';
5
- import { Button } from '@equinor/fusion-react-button';
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 { label = 'Clear Filter', ...args } = props;
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
- useSubscription(changed$, useCallback((changed) => {
18
- ref.current && (ref.current.disabled = !Object.keys(changed).length);
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, Object.assign({ variant: "ghost" }, { ...args, ref, onClick, label }), void 0);
23
+ return (_jsx(Button, { variant: "ghost", ...args, ref, onClick, children: children ?? 'Clear Filter' }));
23
24
  };
24
25
  export default ClearFilterButton;
25
- //# sourceMappingURL=ClearFilterButton.js.map
@@ -1,12 +1,13 @@
1
- import { theme } from '@equinor/fusion-react-styles';
2
- import React from 'react';
3
- declare type StyleProps = {
4
- spacing?: keyof typeof theme.spacing.comfortable;
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 declare type FilterContainerProps = JSX.IntrinsicElements['div'] & StyleProps;
7
+ export type FilterContainerProps = HTMLAttributes<HTMLDivElement> & StyleProps;
7
8
  /**
8
9
  * Components for displaying filters
9
10
  */
10
- export declare const FilterContainer: (props: React.PropsWithChildren<FilterContainerProps>) => JSX.Element;
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,EAAkC,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,KAAK,MAAM,OAAO,CAAC;AAiB1B,aAAK,UAAU,GAAG;IAChB,OAAO,CAAC,EAAE,MAAM,OAAO,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;CAClD,CAAC;AAEF,oBAAY,oBAAoB,GAAG,GAAG,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,eAAe,UAAW,MAAM,iBAAiB,CAAC,oBAAoB,CAAC,KAAG,WAQtF,CAAC;AAEF,eAAe,eAAe,CAAC"}
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,21 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { clsx, createStyles, makeStyles } from '@equinor/fusion-react-styles';
3
- const useStyles = makeStyles((theme) => createStyles({
4
- root: ({ spacing }) => ({
5
- display: 'inline-flex',
6
- flex: 'auto',
7
- gap: theme.spacing.comfortable[spacing || 'medium'].getVariable('padding'),
8
- '&>*': {
9
- flex: 1,
10
- },
11
- }),
12
- }), { name: 'fusion-filter-container' });
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
- const styles = useStyles({ spacing });
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
- //# sourceMappingURL=FilterContainer.js.map
@@ -1,6 +1,7 @@
1
- import { ChipProps } from '@equinor/fusion-react-chip';
2
- export declare type SelectionChipsProps = JSX.IntrinsicElements['div'] & {
3
- chips: Omit<ChipProps, 'removable' | 'onRemove' | 'value' | 'children'>;
1
+ import { type HTMLAttributes, type ReactElement } from 'react';
2
+ import { type ChipElementProps } from '@equinor/fusion-wc-chip';
3
+ export type SelectionChipsProps = HTMLAttributes<HTMLDivElement> & {
4
+ readonly chips: Pick<ChipElementProps, 'variant'>;
4
5
  };
5
- export declare const SelectionChips: (props: SelectionChipsProps) => JSX.Element;
6
+ export declare const SelectionChips: (props: SelectionChipsProps) => ReactElement;
6
7
  //# sourceMappingURL=SelectionChips.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionChips.d.ts","sourceRoot":"","sources":["../../../src/components/misc/SelectionChips.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAQ,SAAS,EAAyB,MAAM,4BAA4B,CAAC;AA0CpF,oBAAY,mBAAmB,GAAG,GAAG,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG;IAC/D,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,WAAW,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC,CAAC;CACzE,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,mBAAmB,KAAG,WAgD3D,CAAC"}
1
+ {"version":3,"file":"SelectionChips.d.ts","sourceRoot":"","sources":["../../../src/components/misc/SelectionChips.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EAKlB,MAAM,OAAO,CAAC;AAIf,OAAa,EAAoB,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AA0CxF,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IACjE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;CACnD,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,KAAG,YAsD3D,CAAC"}
@@ -1,14 +1,16 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { createElement as _createElement } from "react";
3
- import { useCallback, useMemo, useState } from 'react';
2
+ import { useEffect, useMemo, useRef, useState, } from 'react';
4
3
  import { combineLatest, of } from 'rxjs';
5
4
  import { switchMap } from 'rxjs/operators';
6
- import { useSubscription } from '@equinor/fusion-react-observable';
7
- import { Chip } from '@equinor/fusion-react-chip';
5
+ import { useObservableSubscription } from '@equinor/fusion-observable/react';
6
+ import Chip from '@equinor/fusion-wc-chip';
8
7
  import { useFilterContext } from '../../hooks';
9
8
  import { actions } from '../../actions';
10
- import { clsx, createStyles, makeStyles } from '@equinor/fusion-react-styles';
9
+ import styled from 'styled-components';
10
+ import { tokens } from '@equinor/eds-tokens';
11
+ Chip;
11
12
  /** method for extracting selection to array */
13
+ // biome-ignore lint/suspicious/noExplicitAny: selection can be any type from the filter context
12
14
  const formatSelection = (selection) => {
13
15
  switch (true) {
14
16
  case selection === undefined:
@@ -24,20 +26,21 @@ const formatSelection = (selection) => {
24
26
  return [];
25
27
  }
26
28
  };
27
- const useStyles = makeStyles((theme) => createStyles({
28
- root: {
29
- display: 'flex',
30
- gap: theme.spacing.comfortable.small.getVariable('padding'),
31
- },
32
- chip: {
33
- marginRight: theme.spacing.comfortable.small.getVariable('padding'),
34
- },
35
- }), { name: 'fusion-filter-selection-chips' });
29
+ const Styled = {
30
+ Root: styled.div `
31
+ display: flex;
32
+ gap: ${tokens.spacings.comfortable.small};
33
+ `,
34
+ Chip: styled.span `
35
+ margin-right: ${tokens.spacings.comfortable.small};
36
+ `,
37
+ };
36
38
  export const SelectionChips = (props) => {
37
39
  const { chips, className, ...args } = props;
38
40
  const { filter$, selection$ } = useFilterContext();
39
41
  const [items, setItems] = useState([]);
40
- useSubscription(useMemo(() =>
42
+ const ref = useRef(null);
43
+ useObservableSubscription(useMemo(() =>
41
44
  /** Observe filter and selection changes */
42
45
  combineLatest([filter$, selection$]).pipe(switchMap(([filters, selections]) => {
43
46
  const items = Object.values(filters)
@@ -51,12 +54,16 @@ export const SelectionChips = (props) => {
51
54
  .filter((x) => !!x.title && !!x.selection.length);
52
55
  return of(items);
53
56
  })), [filter$, selection$]), setItems);
54
- const onRemove = useCallback((e) => {
55
- selection$.next(actions.selection.remove(String(e.currentTarget.value)));
57
+ useEffect(() => {
58
+ const el = ref.current;
59
+ if (el) {
60
+ const handler = (e) => {
61
+ const value = e.target.value;
62
+ selection$.next(actions.selection.remove(String(value)));
63
+ };
64
+ el.addEventListener('remove', handler);
65
+ return () => el.removeEventListener('remove', handler);
66
+ }
56
67
  }, [selection$]);
57
- const styles = useStyles();
58
- return (_jsx("div", Object.assign({}, args, { className: clsx(styles.root, className) }, { children: items?.map((x) => (_createElement(Chip, { ...chips, key: x.key, value: x.key, onRemove: onRemove, removable: true },
59
- _jsxs("span", { children: [x.title, " "] }, void 0),
60
- _jsx("span", Object.assign({ slot: "graphic", className: styles.chip }, { children: x.selection.length }), void 0)))) }), void 0));
68
+ return (_jsx(Styled.Root, { ...args, className: className, ref: ref, children: items?.map((x) => (_jsxs("fwc-chip", { value: x.key, removable: true, variant: chips.variant, children: [_jsxs("span", { children: [x.title, " "] }), _jsx(Styled.Chip, { slot: "graphic", children: x.selection.length })] }, x.key))) }));
61
69
  };
62
- //# sourceMappingURL=SelectionChips.js.map
@@ -1,4 +1,3 @@
1
1
  export { ClearFilterButton } from './ClearFilterButton';
2
2
  export { FilterContainer } from './FilterContainer';
3
3
  export { SelectionChips } from './SelectionChips';
4
- //# sourceMappingURL=index.js.map
@@ -1,10 +1,12 @@
1
- declare type StyleClasses = {
1
+ import { type PropsWithChildren, type HTMLAttributes, type ReactElement } from 'react';
2
+ import type { FilterFn } from '../../types';
3
+ type StyleClasses = {
2
4
  /** filter panel */
3
5
  root: string;
4
6
  /** filter container */
5
7
  filters: string;
6
8
  };
7
- export declare type FilterPanelProps = JSX.IntrinsicElements['div'] & {
9
+ export type FilterPanelProps<TData> = HTMLAttributes<HTMLDivElement> & {
8
10
  /** Show filter bar */
9
11
  showBar?: boolean;
10
12
  /** Show selector for filters */
@@ -20,10 +22,12 @@ export declare type FilterPanelProps = JSX.IntrinsicElements['div'] & {
20
22
  selectedFilters?: string[];
21
23
  /** style classes */
22
24
  classes?: Partial<StyleClasses>;
25
+ /** method to use for search bar */
26
+ searchFn?: FilterFn<TData, string>;
23
27
  };
24
28
  /**
25
29
  * Base component for displaying filter components and controllers
26
30
  */
27
- export declare const FilterPanel: (props: React.PropsWithChildren<FilterPanelProps>) => JSX.Element;
31
+ export declare const FilterPanel: <TData>(props: PropsWithChildren<FilterPanelProps<TData>>) => ReactElement;
28
32
  export default FilterPanel;
29
33
  //# sourceMappingURL=FilterPanel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FilterPanel.d.ts","sourceRoot":"","sources":["../../../src/components/panel/FilterPanel.tsx"],"names":[],"mappings":"AAqCA,aAAK,YAAY,GAAG;IAClB,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,gBAAgB,GAAG,GAAG,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG;IAC5D,sBAAsB;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,gCAAgC;IAChC,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,8BAA8B;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,gDAAgD;IAChD,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B,oBAAoB;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,UAAW,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,KAAG,WAoB9E,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"FilterPanel.d.ts","sourceRoot":"","sources":["../../../src/components/panel/FilterPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAajG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AA0B5C,KAAK,YAAY,GAAG;IAClB,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,KAAK,IAAI,cAAc,CAAC,cAAc,CAAC,GAAG;IACrE,sBAAsB;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,gCAAgC;IAChC,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,8BAA8B;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,gDAAgD;IAChD,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B,oBAAoB;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAEhC,mCAAmC;IACnC,QAAQ,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,CAAC,KAAK,EAC9B,KAAK,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,KAC9C,YA4BJ,CAAC;AAEF,eAAe,WAAW,CAAC"}