@planningcenter/tapestry 4.8.1-qa-1359.0 → 4.9.0-rc.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/dist/components/DataTable/CollectionEditorsLazy.d.ts +3 -1
- package/dist/components/DataTable/CollectionEditorsLazy.d.ts.map +1 -1
- package/dist/components/DataTable/CollectionEditorsLazy.js +7 -33
- package/dist/components/DataTable/CollectionEditorsLazy.js.map +1 -1
- package/dist/components/DataTable/CollectionEditorsShared.d.ts +2 -2
- package/dist/components/DataTable/CollectionEditorsShared.d.ts.map +1 -1
- package/dist/components/DataTable/CollectionEditorsShared.js.map +1 -1
- package/dist/components/DataTable/FilterContext.d.ts +0 -1
- package/dist/components/DataTable/FilterContext.d.ts.map +1 -1
- package/dist/components/DataTable/FilterContext.js +13 -10
- package/dist/components/DataTable/FilterContext.js.map +1 -1
- package/dist/components/DataTable/FilterTypes.d.ts +20 -8
- package/dist/components/DataTable/FilterTypes.d.ts.map +1 -1
- package/dist/components/DataTable/FilterTypes.js.map +1 -1
- package/dist/components/DataTable/SearchableFilters.js +2 -2
- package/dist/components/DataTable/SearchableFilters.js.map +1 -1
- package/dist/components/DataTable/collectionFilter.d.ts.map +1 -1
- package/dist/components/DataTable/collectionFilter.js +5 -3
- package/dist/components/DataTable/collectionFilter.js.map +1 -1
- package/dist/components/DataTable/scopedFilter.d.ts +6 -10
- package/dist/components/DataTable/scopedFilter.d.ts.map +1 -1
- package/dist/components/DataTable/scopedFilter.js +77 -41
- package/dist/components/DataTable/scopedFilter.js.map +1 -1
- package/dist/components/DataTable/useLazyOptions.d.ts +7 -0
- package/dist/components/DataTable/useLazyOptions.d.ts.map +1 -0
- package/dist/components/DataTable/useLazyOptions.js +37 -0
- package/dist/components/DataTable/useLazyOptions.js.map +1 -0
- package/dist/components/button/Button.d.ts +1 -1
- package/dist/components/button/Button.js +1 -1
- package/dist/components/button/Button.js.map +1 -1
- package/dist/components/button/DropdownButton.d.ts +1 -1
- package/dist/components/button/DropdownButton.js +1 -1
- package/dist/components/button/DropdownButton.js.map +1 -1
- package/dist/components/button/DropdownIconButton.d.ts +1 -1
- package/dist/components/button/DropdownIconButton.js +1 -1
- package/dist/components/button/DropdownIconButton.js.map +1 -1
- package/dist/components/button/IconButton.d.ts +1 -1
- package/dist/components/button/IconButton.js +1 -1
- package/dist/components/button/IconButton.js.map +1 -1
- package/dist/components/button/PageHeaderActionsDropdownButton.d.ts +1 -1
- package/dist/components/button/PageHeaderActionsDropdownButton.js +1 -1
- package/dist/components/button/PageHeaderActionsDropdownButton.js.map +1 -1
- package/dist/components/button-group/ButtonGroup.d.ts +1 -1
- package/dist/components/button-group/ButtonGroup.js +1 -1
- package/dist/components/button-group/ButtonGroup.js.map +1 -1
- package/dist/components/checkbox/Checkbox.d.ts +1 -1
- package/dist/components/checkbox/Checkbox.js +1 -1
- package/dist/components/checkbox/Checkbox.js.map +1 -1
- package/dist/components/checkbox-group/CheckboxGroup.d.ts +1 -1
- package/dist/components/checkbox-group/CheckboxGroup.js +1 -1
- package/dist/components/checkbox-group/CheckboxGroup.js.map +1 -1
- package/dist/components/combo-box/ComboBox.d.ts +3 -3
- package/dist/components/combo-box/ComboBox.js +3 -3
- package/dist/components/combo-box/ComboBox.js.map +1 -1
- package/dist/components/currency-input/CurrencyInput.d.ts +1 -1
- package/dist/components/currency-input/CurrencyInput.js +1 -1
- package/dist/components/currency-input/CurrencyInput.js.map +1 -1
- package/dist/components/date-picker/DatePicker.d.ts +1 -1
- package/dist/components/date-picker/DatePicker.js +1 -1
- package/dist/components/date-picker/DatePicker.js.map +1 -1
- package/dist/components/dropdown/Dropdown.d.ts +3 -1
- package/dist/components/dropdown/Dropdown.d.ts.map +1 -1
- package/dist/components/dropdown/Dropdown.js +2 -2
- package/dist/components/dropdown/Dropdown.js.map +1 -1
- package/dist/components/flex/Flex.d.ts +1 -1
- package/dist/components/flex/Flex.js +1 -1
- package/dist/components/flex/Flex.js.map +1 -1
- package/dist/components/input/Input.d.ts +1 -1
- package/dist/components/input/Input.js +1 -1
- package/dist/components/input/Input.js.map +1 -1
- package/dist/components/link/IconLink.d.ts +1 -1
- package/dist/components/link/IconLink.js +1 -1
- package/dist/components/link/IconLink.js.map +1 -1
- package/dist/components/link/Link.d.ts +1 -1
- package/dist/components/link/Link.js +1 -1
- package/dist/components/link/Link.js.map +1 -1
- package/dist/components/modal/ModalBody.d.ts +1 -1
- package/dist/components/modal/ModalBody.js +1 -1
- package/dist/components/modal/ModalBody.js.map +1 -1
- package/dist/components/modal/ModalFooter.d.ts +1 -1
- package/dist/components/modal/ModalFooter.js +1 -1
- package/dist/components/modal/ModalFooter.js.map +1 -1
- package/dist/components/modal/ModalHeader.d.ts +1 -1
- package/dist/components/modal/ModalHeader.js +1 -1
- package/dist/components/modal/ModalHeader.js.map +1 -1
- package/dist/components/number-stepper/NumberStepper.d.ts +1 -1
- package/dist/components/number-stepper/NumberStepper.js +1 -1
- package/dist/components/number-stepper/NumberStepper.js.map +1 -1
- package/dist/components/page-header/PageHeader.d.ts +1 -1
- package/dist/components/page-header/PageHeader.js +1 -1
- package/dist/components/page-header/PageHeader.js.map +1 -1
- package/dist/components/pane/Pane.d.ts +1 -1
- package/dist/components/pane/Pane.js +2 -2
- package/dist/components/pane/Pane.js.map +1 -1
- package/dist/components/pane/PaneBody.d.ts +1 -1
- package/dist/components/pane/PaneBody.js +1 -1
- package/dist/components/pane/PaneBody.js.map +1 -1
- package/dist/components/pane/PaneContext.d.ts +0 -2
- package/dist/components/pane/PaneContext.d.ts.map +1 -1
- package/dist/components/pane/PaneContext.js.map +1 -1
- package/dist/components/pane/PaneDivider.d.ts +1 -1
- package/dist/components/pane/PaneDivider.js +1 -1
- package/dist/components/pane/PaneDivider.js.map +1 -1
- package/dist/components/pane/PaneFooter.d.ts +1 -1
- package/dist/components/pane/PaneFooter.js +1 -1
- package/dist/components/pane/PaneFooter.js.map +1 -1
- package/dist/components/pane/PaneHeader.d.ts +5 -12
- package/dist/components/pane/PaneHeader.d.ts.map +1 -1
- package/dist/components/pane/PaneHeader.js +6 -13
- package/dist/components/pane/PaneHeader.js.map +1 -1
- package/dist/components/pane/PaneHeaderActions.d.ts +1 -1
- package/dist/components/pane/PaneHeaderActions.js +1 -1
- package/dist/components/pane/PaneHeaderActions.js.map +1 -1
- package/dist/components/popover/Popover.d.ts +6 -2
- package/dist/components/popover/Popover.d.ts.map +1 -1
- package/dist/components/popover/Popover.js +18 -4
- package/dist/components/popover/Popover.js.map +1 -1
- package/dist/components/radio/Radio.d.ts +1 -1
- package/dist/components/radio/Radio.js +1 -1
- package/dist/components/radio/Radio.js.map +1 -1
- package/dist/components/radio-group/RadioGroup.d.ts +1 -1
- package/dist/components/radio-group/RadioGroup.js +1 -1
- package/dist/components/radio-group/RadioGroup.js.map +1 -1
- package/dist/components/search-input/SearchInput.d.ts +1 -1
- package/dist/components/search-input/SearchInput.js +1 -1
- package/dist/components/search-input/SearchInput.js.map +1 -1
- package/dist/components/select/Select.d.ts +1 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/select/Select.js.map +1 -1
- package/dist/components/sidenav/Sidenav.d.ts +1 -1
- package/dist/components/sidenav/Sidenav.js +1 -1
- package/dist/components/sidenav/Sidenav.js.map +1 -1
- package/dist/components/sidenav/SidenavItem.d.ts +1 -1
- package/dist/components/sidenav/SidenavItem.js +1 -1
- package/dist/components/sidenav/SidenavItem.js.map +1 -1
- package/dist/components/sidenav/SidenavSection.d.ts +1 -1
- package/dist/components/sidenav/SidenavSection.js +1 -1
- package/dist/components/sidenav/SidenavSection.js.map +1 -1
- package/dist/components/text-area/TextArea.d.ts +1 -1
- package/dist/components/text-area/TextArea.js +1 -1
- package/dist/components/text-area/TextArea.js.map +1 -1
- package/dist/components/time-field/TimeField.d.ts +1 -1
- package/dist/components/time-field/TimeField.js +1 -1
- package/dist/components/time-field/TimeField.js.map +1 -1
- package/dist/components/toggle-switch/ToggleSwitch.d.ts +1 -1
- package/dist/components/toggle-switch/ToggleSwitch.js +1 -1
- package/dist/components/toggle-switch/ToggleSwitch.js.map +1 -1
- package/dist/reactRender.css +1243 -1308
- package/dist/reactRender.css.map +1 -1
- package/dist/reactRenderLegacy.css +1243 -1308
- package/dist/reactRenderLegacy.css.map +1 -1
- package/dist/unstable.css +0 -65
- package/dist/unstable.css.map +1 -1
- package/package.json +5 -5
- package/dist/components/internal/helper-shelf/HelperShelf.d.ts +0 -26
- package/dist/components/internal/helper-shelf/HelperShelf.d.ts.map +0 -1
- package/dist/components/internal/helper-shelf/HelperShelf.js +0 -37
- package/dist/components/internal/helper-shelf/HelperShelf.js.map +0 -1
- package/dist/components/internal/helper-shelf/index.d.ts +0 -4
- package/dist/components/internal/helper-shelf/index.d.ts.map +0 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { CollectionFilterEditorProps } from "./CollectionEditorsShared";
|
|
3
|
-
export declare function CollectionFilterEditorLazy({ config, onChange, operator, value, filter, label, }: CollectionFilterEditorProps): React.JSX.Element;
|
|
3
|
+
export declare function CollectionFilterEditorLazy({ config, onChange, operator, value, filter, label, scope, }: CollectionFilterEditorProps): React.JSX.Element;
|
|
4
|
+
export declare function Loading(): React.JSX.Element;
|
|
5
|
+
export declare function LoadError(): React.JSX.Element;
|
|
4
6
|
//# sourceMappingURL=CollectionEditorsLazy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionEditorsLazy.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/CollectionEditorsLazy.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAgD,MAAM,OAAO,CAAA;AAEpE,OAAO,KAAK,EACV,2BAA2B,
|
|
1
|
+
{"version":3,"file":"CollectionEditorsLazy.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/CollectionEditorsLazy.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAgD,MAAM,OAAO,CAAA;AAEpE,OAAO,KAAK,EACV,2BAA2B,EAG5B,MAAM,2BAA2B,CAAA;AAsBlC,wBAAgB,0BAA0B,CAAC,EACzC,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,MAAM,EACN,KAAK,EACL,KAAK,GACN,EAAE,2BAA2B,qBA4C7B;AA+FD,wBAAgB,OAAO,sBAEtB;AAED,wBAAgB,SAAS,sBAMxB"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { ComboBoxItem } from '../combo-box/ComboBox.js';
|
|
2
2
|
import { useDebouncedValue } from '../../utilities/useDebouncedValue.js';
|
|
3
|
-
import React__default, {
|
|
3
|
+
import React__default, { useCallback, useState, useEffect } from 'react';
|
|
4
4
|
import { CollectionEditorCombobox } from './CollectionEditorsShared.js';
|
|
5
5
|
import { CollectionEditorCheckboxes, CollectionEditorRadios, CollectionEditorSelect } from './CollectionEditorsStatic.js';
|
|
6
|
+
import { useLazyOptions } from './useLazyOptions.js';
|
|
6
7
|
import { isEmptyValue } from './utils.js';
|
|
7
8
|
|
|
8
9
|
const DEBOUNCE_MS = 300;
|
|
9
|
-
function CollectionFilterEditorLazy({ config, onChange, operator, value, filter, label, }) {
|
|
10
|
+
function CollectionFilterEditorLazy({ config, onChange, operator, value, filter, label, scope, }) {
|
|
10
11
|
const { display, multiple } = config;
|
|
11
|
-
const
|
|
12
|
+
const loadOptions = config.options;
|
|
13
|
+
const options = useCallback((query) => loadOptions(query, scope), [loadOptions, scope]);
|
|
12
14
|
const [query, setQuery] = useState();
|
|
13
15
|
const debouncedQuery = useDebouncedValue(query, DEBOUNCE_MS);
|
|
14
|
-
const
|
|
16
|
+
const { error, loading, options: resolvedOptions, } = useLazyOptions(options, debouncedQuery);
|
|
15
17
|
const onCommit = useCallback((newValue) => {
|
|
16
18
|
const newLabel = findLabelFromOptions(resolvedOptions, newValue, {
|
|
17
19
|
label,
|
|
@@ -19,34 +21,6 @@ function CollectionFilterEditorLazy({ config, onChange, operator, value, filter,
|
|
|
19
21
|
});
|
|
20
22
|
return onChange({ label: newLabel, value: newValue }, { complete: !isEmptyValue(newValue) });
|
|
21
23
|
}, [resolvedOptions, onChange, value, label]);
|
|
22
|
-
const [loading, setLoading] = useState(true);
|
|
23
|
-
const [error, setError] = useState(null);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
let active = true;
|
|
26
|
-
async function fetchOptions() {
|
|
27
|
-
try {
|
|
28
|
-
const resolved = await options(debouncedQuery);
|
|
29
|
-
if (!active)
|
|
30
|
-
return;
|
|
31
|
-
setResolvedOptions(resolved);
|
|
32
|
-
setError(null);
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
if (!active)
|
|
36
|
-
return;
|
|
37
|
-
setResolvedOptions([]);
|
|
38
|
-
setError(e);
|
|
39
|
-
}
|
|
40
|
-
finally {
|
|
41
|
-
if (active)
|
|
42
|
-
setLoading(false);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
fetchOptions();
|
|
46
|
-
return () => {
|
|
47
|
-
active = false;
|
|
48
|
-
};
|
|
49
|
-
}, [options, debouncedQuery]);
|
|
50
24
|
const Editor = getLazyEditor({ display, multiple });
|
|
51
25
|
return (React__default.createElement(Editor, { error: error, loading: loading, query: query, setQuery: setQuery, value: value, onCommit: onCommit, options: resolvedOptions, multiple: multiple, operator: operator, filterLabel: filter.label, filterName: filter.name }));
|
|
52
26
|
}
|
|
@@ -127,5 +101,5 @@ function normalizeValueToArray(value) {
|
|
|
127
101
|
return Array.isArray(value) ? value : [value];
|
|
128
102
|
}
|
|
129
103
|
|
|
130
|
-
export { CollectionFilterEditorLazy };
|
|
104
|
+
export { CollectionFilterEditorLazy, LoadError, Loading };
|
|
131
105
|
//# sourceMappingURL=CollectionEditorsLazy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionEditorsLazy.js","sources":["../../../src/components/DataTable/CollectionEditorsLazy.tsx"],"sourcesContent":["import { ComboBoxItem } from \"@components/combo-box\"\nimport { useDebouncedValue } from \"@utilities/useDebouncedValue\"\nimport React, { Key, useCallback, useEffect, useState } from \"react\"\n\nimport type {\n CollectionFilterEditorProps,\n CollectionFilterValue,\n} from \"./CollectionEditorsShared\"\nimport { CollectionEditorCombobox } from \"./CollectionEditorsShared\"\nimport {\n CollectionEditorCheckboxes,\n CollectionEditorRadios,\n CollectionEditorSelect,\n CollectionEditorStaticProps,\n} from \"./CollectionEditorsStatic\"\nimport { CollectionOption } from \"./collectionFilter\"\nimport type { ActiveFilterLabel } from \"./FilterTypes\"\nimport { isEmptyValue } from \"./utils\"\n\ntype CollectionEditorLazyProps = CollectionEditorStaticProps & {\n error: unknown\n loading: boolean\n query: string | undefined\n setQuery: (query: string | undefined) => void\n}\n\nconst DEBOUNCE_MS = 300\n\nexport function CollectionFilterEditorLazy({\n config,\n onChange,\n operator,\n value,\n filter,\n label,\n}: CollectionFilterEditorProps) {\n const { display, multiple } = config\n const options = config.options as\n | ((query?: string) => Promise<CollectionOption[]>)\n | ((query?: string) => CollectionOption[])\n const [query, setQuery] = useState<string | undefined>()\n const debouncedQuery = useDebouncedValue(query, DEBOUNCE_MS)\n const [resolvedOptions, setResolvedOptions] = useState<CollectionOption[]>([])\n const onCommit = useCallback(\n (newValue: CollectionFilterValue) => {\n const newLabel = findLabelFromOptions(resolvedOptions, newValue, {\n label,\n value,\n })\n return onChange(\n { label: newLabel, value: newValue },\n { complete: !isEmptyValue(newValue) }\n )\n },\n [resolvedOptions, onChange, value, label]\n )\n const [loading, setLoading] = useState<boolean>(true)\n const [error, setError] = useState<unknown>(null)\n\n useEffect(() => {\n let active = true\n async function fetchOptions() {\n try {\n const resolved = await options(debouncedQuery)\n if (!active) return\n setResolvedOptions(resolved)\n setError(null)\n } catch (e) {\n if (!active) return\n setResolvedOptions([])\n setError(e)\n } finally {\n if (active) setLoading(false)\n }\n }\n fetchOptions()\n return () => {\n active = false\n }\n }, [options, debouncedQuery])\n\n const Editor = getLazyEditor({ display, multiple })\n\n return (\n <Editor\n error={error}\n loading={loading}\n query={query}\n setQuery={setQuery}\n value={value}\n onCommit={onCommit}\n options={resolvedOptions}\n multiple={multiple}\n operator={operator}\n filterLabel={filter.label}\n filterName={filter.name}\n />\n )\n}\n\nfunction getLazyEditor({\n display,\n multiple,\n}: {\n display: string\n multiple: boolean\n}) {\n if (display === \"combobox\") return CollectionEditorComboboxLazy\n if (multiple) return CollectionEditorCheckboxesLazy\n if (display === \"checkboxes\") return CollectionEditorRadiosLazy // TODO: This looks like it might be a mistake, should it be CollectionEditorCheckboxes? or at least allow for `radios` as an option?\n return CollectionEditorSelectLazy\n}\n\nfunction CollectionEditorCheckboxesLazy({\n error,\n loading,\n ...props\n}: CollectionEditorLazyProps) {\n if (loading) return <Loading />\n if (error) return <LoadError />\n return <CollectionEditorCheckboxes {...props} />\n}\n\nfunction CollectionEditorRadiosLazy({\n error,\n loading,\n ...props\n}: CollectionEditorLazyProps) {\n if (loading) return <Loading />\n if (error) return <LoadError />\n return <CollectionEditorRadios {...props} />\n}\n\nfunction CollectionEditorSelectLazy({\n error,\n loading,\n ...props\n}: CollectionEditorLazyProps) {\n if (loading) return <Loading />\n if (error) return <LoadError />\n return <CollectionEditorSelect {...props} />\n}\n\nfunction CollectionEditorComboboxLazy({\n error,\n onCommit,\n options,\n query,\n loading,\n setQuery,\n ...props\n}: CollectionEditorLazyProps) {\n const [loadingState, setLoadingState] = useState<\n \"loading\" | \"filtering\" | \"idle\"\n >(loading ? \"loading\" : \"idle\")\n useEffect(() => {\n if (!loading) {\n setLoadingState(\"idle\")\n }\n }, [loading])\n\n return (\n <CollectionEditorCombobox\n {...props}\n loadingState={error ? \"error\" : loadingState}\n inputValue={query}\n onInputChange={(q: string) => {\n setLoadingState(\"filtering\")\n setQuery(q)\n }}\n onChange={(value: Key | Key[] | null) => {\n if (value === null) return\n\n const resolvedValue = Array.isArray(value)\n ? value.map(String)\n : String(value)\n onCommit(resolvedValue)\n }}\n items={options}\n renderEmptyState={error ? <LoadError /> : \"No results\"}\n >\n {(o) => {\n const option = o as CollectionOption\n return (\n <ComboBoxItem key={option.value} id={option.value}>\n {option.label}\n </ComboBoxItem>\n )\n }}\n </CollectionEditorCombobox>\n )\n}\n\nfunction Loading() {\n return <div style={{ color: \"hotpink\", fontWeight: \"bold\" }}>Loading...</div>\n}\n\nfunction LoadError() {\n return (\n <div style={{ color: \"hotpink\", fontWeight: \"bold\" }}>\n Failed to load options\n </div>\n )\n}\n\nfunction findLabelFromOptions(\n options: CollectionOption[],\n value: CollectionFilterValue,\n previous: { label?: ActiveFilterLabel; value: CollectionFilterValue }\n) {\n const previousLabelByValue = buildPreviousLabelByValue(previous)\n const labelFor = (v: string) =>\n options.find((option) => option.value === v)?.label ??\n previousLabelByValue.get(v)\n\n return Array.isArray(value)\n ? value.map(labelFor).filter((label) => label !== undefined)\n : labelFor(value)\n}\n\nfunction buildPreviousLabelByValue(previous: {\n label?: ActiveFilterLabel\n value: CollectionFilterValue\n}): Map<string, string | undefined> {\n const previousValues = normalizeValueToArray(previous.value)\n const previousLabels = normalizeValueToArray(previous.label)\n return new Map(previousValues.map((v, index) => [v, previousLabels[index]]))\n}\n\nfunction normalizeValueToArray(value: string | string[] | undefined): string[] {\n if (value === undefined) return []\n return Array.isArray(value) ? value : [value]\n}\n"],"names":["React"],"mappings":";;;;;;;AA0BA,MAAM,WAAW,GAAG,GAAG;AAEjB,SAAU,0BAA0B,CAAC,EACzC,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,MAAM,EACN,KAAK,GACuB,EAAA;AAC5B,IAAA,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM;AACpC,IAAA,MAAM,OAAO,GAAG,MAAM,CAAC,OAEqB;IAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAsB;IACxD,MAAM,cAAc,GAAG,iBAAiB,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5D,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAA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,KAAK,KAAK,KAAK,SAAS;AAC3D,UAAE,QAAQ,CAAC,KAAK,CAAC;AACrB;AAEA,SAAS,yBAAyB,CAAC,QAGlC,EAAA;IACC,MAAM,cAAc,GAAG,qBAAqB,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC5D,MAAM,cAAc,GAAG,qBAAqB,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC5D,OAAO,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC9E;AAEA,SAAS,qBAAqB,CAAC,KAAoC,EAAA;IACjE,IAAI,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,EAAE;AAClC,IAAA,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC;AAC/C;;;;"}
|
|
1
|
+
{"version":3,"file":"CollectionEditorsLazy.js","sources":["../../../src/components/DataTable/CollectionEditorsLazy.tsx"],"sourcesContent":["import { ComboBoxItem } from \"@components/combo-box\"\nimport { useDebouncedValue } from \"@utilities/useDebouncedValue\"\nimport React, { Key, useCallback, useEffect, useState } from \"react\"\n\nimport type {\n CollectionFilterEditorProps,\n CollectionFilterValue,\n CollectionOptionsLazy,\n} from \"./CollectionEditorsShared\"\nimport { CollectionEditorCombobox } from \"./CollectionEditorsShared\"\nimport {\n CollectionEditorCheckboxes,\n CollectionEditorRadios,\n CollectionEditorSelect,\n CollectionEditorStaticProps,\n} from \"./CollectionEditorsStatic\"\nimport { CollectionOption } from \"./collectionFilter\"\nimport type { ActiveFilterLabel } from \"./FilterTypes\"\nimport { useLazyOptions } from \"./useLazyOptions\"\nimport { isEmptyValue } from \"./utils\"\n\ntype CollectionEditorLazyProps = CollectionEditorStaticProps & {\n error: unknown\n loading: boolean\n query: string | undefined\n setQuery: (query: string | undefined) => void\n}\n\nconst DEBOUNCE_MS = 300\n\nexport function CollectionFilterEditorLazy({\n config,\n onChange,\n operator,\n value,\n filter,\n label,\n scope,\n}: CollectionFilterEditorProps) {\n const { display, multiple } = config\n const loadOptions = config.options as CollectionOptionsLazy\n const options = useCallback(\n (query?: string) => loadOptions(query, scope),\n [loadOptions, scope]\n )\n const [query, setQuery] = useState<string | undefined>()\n const debouncedQuery = useDebouncedValue(query, DEBOUNCE_MS)\n const {\n error,\n loading,\n options: resolvedOptions,\n } = useLazyOptions(options, debouncedQuery)\n const onCommit = useCallback(\n (newValue: CollectionFilterValue) => {\n const newLabel = findLabelFromOptions(resolvedOptions, newValue, {\n label,\n value,\n })\n return onChange(\n { label: newLabel, value: newValue },\n { complete: !isEmptyValue(newValue) }\n )\n },\n [resolvedOptions, onChange, value, label]\n )\n const Editor = getLazyEditor({ display, multiple })\n\n return (\n <Editor\n error={error}\n loading={loading}\n query={query}\n setQuery={setQuery}\n value={value}\n onCommit={onCommit}\n options={resolvedOptions}\n multiple={multiple}\n operator={operator}\n filterLabel={filter.label}\n filterName={filter.name}\n />\n )\n}\n\nfunction getLazyEditor({\n display,\n multiple,\n}: {\n display: string\n multiple: boolean\n}) {\n if (display === \"combobox\") return CollectionEditorComboboxLazy\n if (multiple) return CollectionEditorCheckboxesLazy\n if (display === \"checkboxes\") return CollectionEditorRadiosLazy // TODO: This looks like it might be a mistake, should it be CollectionEditorCheckboxes? or at least allow for `radios` as an option?\n return CollectionEditorSelectLazy\n}\n\nfunction CollectionEditorCheckboxesLazy({\n error,\n loading,\n ...props\n}: CollectionEditorLazyProps) {\n if (loading) return <Loading />\n if (error) return <LoadError />\n return <CollectionEditorCheckboxes {...props} />\n}\n\nfunction CollectionEditorRadiosLazy({\n error,\n loading,\n ...props\n}: CollectionEditorLazyProps) {\n if (loading) return <Loading />\n if (error) return <LoadError />\n return <CollectionEditorRadios {...props} />\n}\n\nfunction CollectionEditorSelectLazy({\n error,\n loading,\n ...props\n}: CollectionEditorLazyProps) {\n if (loading) return <Loading />\n if (error) return <LoadError />\n return <CollectionEditorSelect {...props} />\n}\n\nfunction CollectionEditorComboboxLazy({\n error,\n onCommit,\n options,\n query,\n loading,\n setQuery,\n ...props\n}: CollectionEditorLazyProps) {\n const [loadingState, setLoadingState] = useState<\n \"loading\" | \"filtering\" | \"idle\"\n >(loading ? \"loading\" : \"idle\")\n useEffect(() => {\n if (!loading) {\n setLoadingState(\"idle\")\n }\n }, [loading])\n\n return (\n <CollectionEditorCombobox\n {...props}\n loadingState={error ? \"error\" : loadingState}\n inputValue={query}\n onInputChange={(q: string) => {\n setLoadingState(\"filtering\")\n setQuery(q)\n }}\n onChange={(value: Key | Key[] | null) => {\n if (value === null) return\n\n const resolvedValue = Array.isArray(value)\n ? value.map(String)\n : String(value)\n onCommit(resolvedValue)\n }}\n items={options}\n renderEmptyState={error ? <LoadError /> : \"No results\"}\n >\n {(o) => {\n const option = o as CollectionOption\n return (\n <ComboBoxItem key={option.value} id={option.value}>\n {option.label}\n </ComboBoxItem>\n )\n }}\n </CollectionEditorCombobox>\n )\n}\n\nexport function Loading() {\n return <div style={{ color: \"hotpink\", fontWeight: \"bold\" }}>Loading...</div>\n}\n\nexport function LoadError() {\n return (\n <div style={{ color: \"hotpink\", fontWeight: \"bold\" }}>\n Failed to load options\n </div>\n )\n}\n\nfunction findLabelFromOptions(\n options: CollectionOption[],\n value: CollectionFilterValue,\n previous: { label?: ActiveFilterLabel; value: CollectionFilterValue }\n) {\n const previousLabelByValue = buildPreviousLabelByValue(previous)\n const labelFor = (v: string) =>\n options.find((option) => option.value === v)?.label ??\n previousLabelByValue.get(v)\n\n return Array.isArray(value)\n ? value.map(labelFor).filter((label) => label !== undefined)\n : labelFor(value)\n}\n\nfunction buildPreviousLabelByValue(previous: {\n label?: ActiveFilterLabel\n value: CollectionFilterValue\n}): Map<string, string | undefined> {\n const previousValues = normalizeValueToArray(previous.value)\n const previousLabels = normalizeValueToArray(previous.label)\n return new Map(previousValues.map((v, index) => [v, previousLabels[index]]))\n}\n\nfunction normalizeValueToArray(value: string | string[] | undefined): string[] {\n if (value === undefined) return []\n return Array.isArray(value) ? value : [value]\n}\n"],"names":["React"],"mappings":";;;;;;;;AA4BA,MAAM,WAAW,GAAG,GAAG;SAEP,0BAA0B,CAAC,EACzC,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,MAAM,EACN,KAAK,EACL,KAAK,GACuB,EAAA;AAC5B,IAAA,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM;AACpC,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,OAAgC;IAC3D,MAAM,OAAO,GAAG,WAAW,CACzB,CAAC,KAAc,KAAK,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,EAC7C,CAAC,WAAW,EAAE,KAAK,CAAC,CACrB;IACD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAsB;IACxD,MAAM,cAAc,GAAG,iBAAiB,CAAC,KAAK,EAAE,WAAW,CAAC;AAC5D,IAAA,MAAM,EACJ,KAAK,EACL,OAAO,EACP,OAAO,EAAE,eAAe,GACzB,GAAG,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC;AAC3C,IAAA,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,QAA+B,KAAI;AAClC,QAAA,MAAM,QAAQ,GAAG,oBAAoB,CAAC,eAAe,EAAE,QAAQ,EAAE;YAC/D,KAAK;YACL,KAAK;AACN,SAAA,CAAC;QACF,OAAO,QAAQ,CACb,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EACpC,EAAE,QAAQ,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CACtC;IACH,CAAC,EACD,CAAC,eAAe,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,CAC1C;IACD,MAAM,MAAM,GAAG,aAAa,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IAEnD,QACEA,c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EA,SAAS,yBAAyB,CAAC,QAGlC,EAAA;IACC,MAAM,cAAc,GAAG,qBAAqB,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC5D,MAAM,cAAc,GAAG,qBAAqB,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC5D,OAAO,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC9E;AAEA,SAAS,qBAAqB,CAAC,KAAoC,EAAA;IACjE,IAAI,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,EAAE;AAClC,IAAA,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC;AAC/C;;;;"}
|
|
@@ -5,7 +5,7 @@ import { CollectionOption } from "./collectionFilter";
|
|
|
5
5
|
import type { ActiveFilterLabel, FilterChange } from "./FilterTypes";
|
|
6
6
|
/** A single option's `value`, or the selected `value`s when `multiple`. */
|
|
7
7
|
export type CollectionFilterValue = string | string[];
|
|
8
|
-
type CollectionOptionsLazy = (q: string | undefined) => Promise<CollectionOption[]> | CollectionOption[];
|
|
8
|
+
export type CollectionOptionsLazy = (q: string | undefined, scope?: string) => Promise<CollectionOption[]> | CollectionOption[];
|
|
9
9
|
export type CollectionOptions = CollectionOption[] | CollectionOptionsLazy;
|
|
10
10
|
export type CollectionEditorProps = {
|
|
11
11
|
multiple: boolean;
|
|
@@ -29,9 +29,9 @@ export type CollectionFilterEditorProps = {
|
|
|
29
29
|
operator: {
|
|
30
30
|
label: string;
|
|
31
31
|
};
|
|
32
|
+
scope?: string;
|
|
32
33
|
value: CollectionFilterValue;
|
|
33
34
|
};
|
|
34
35
|
export declare function orderByOptions(options: CollectionOption[], selected: Set<string>): string[];
|
|
35
36
|
export declare function CollectionEditorCombobox({ value, multiple, operator, ...props }: CollectionEditorProps & Partial<ComboBoxElementProps> & Pick<ComboBoxElementProps, "children">): React.JSX.Element;
|
|
36
|
-
export {};
|
|
37
37
|
//# sourceMappingURL=CollectionEditorsShared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionEditorsShared.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/CollectionEditorsShared.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEpE,2EAA2E;AAC3E,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;AAErD,
|
|
1
|
+
{"version":3,"file":"CollectionEditorsShared.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/CollectionEditorsShared.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEpE,2EAA2E;AAC3E,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;AAErD,MAAM,MAAM,qBAAqB,GAAG,CAClC,CAAC,EAAE,MAAM,GAAG,SAAS,EACrB,KAAK,CAAC,EAAE,MAAM,KACX,OAAO,CAAC,gBAAgB,EAAE,CAAC,GAAG,gBAAgB,EAAE,CAAA;AACrD,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,EAAE,GAAG,qBAAqB,CAAA;AAE1E,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC3B,KAAK,EAAE,qBAAqB,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE;QACN,OAAO,EAAE,iBAAiB,CAAA;QAC1B,QAAQ,EAAE,OAAO,CAAA;QACjB,OAAO,EAAE,iBAAiB,CAAA;KAC3B,CAAA;IACD,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;IACD,KAAK,EAAE,iBAAiB,CAAA;IACxB,QAAQ,EAAE,YAAY,CAAA;IACtB,QAAQ,EAAE;QACR,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,qBAAqB,CAAA;CAC7B,CAAA;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,gBAAgB,EAAE,EAC3B,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,YAGtB;AAED,wBAAgB,wBAAwB,CAAC,EACvC,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,qBAAqB,GACtB,OAAO,CAAC,oBAAoB,CAAC,GAC7B,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC,qBAYvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionEditorsShared.js","sources":["../../../src/components/DataTable/CollectionEditorsShared.tsx"],"sourcesContent":["import { ComboBox, type ComboBoxElementProps } from \"@components/combo-box\"\nimport React from \"react\"\n\nimport type { CollectionDisplay } from \"./collectionFilter\"\nimport { CollectionOption } from \"./collectionFilter\"\nimport type { ActiveFilterLabel, FilterChange } from \"./FilterTypes\"\n\n/** A single option's `value`, or the selected `value`s when `multiple`. */\nexport type CollectionFilterValue = string | string[]\n\
|
|
1
|
+
{"version":3,"file":"CollectionEditorsShared.js","sources":["../../../src/components/DataTable/CollectionEditorsShared.tsx"],"sourcesContent":["import { ComboBox, type ComboBoxElementProps } from \"@components/combo-box\"\nimport React from \"react\"\n\nimport type { CollectionDisplay } from \"./collectionFilter\"\nimport { CollectionOption } from \"./collectionFilter\"\nimport type { ActiveFilterLabel, FilterChange } from \"./FilterTypes\"\n\n/** A single option's `value`, or the selected `value`s when `multiple`. */\nexport type CollectionFilterValue = string | string[]\n\nexport type CollectionOptionsLazy = (\n q: string | undefined,\n scope?: string\n) => Promise<CollectionOption[]> | CollectionOption[]\nexport type CollectionOptions = CollectionOption[] | CollectionOptionsLazy\n\nexport type CollectionEditorProps = {\n multiple: boolean\n operator: { label: string }\n value: CollectionFilterValue\n}\n\nexport type CollectionFilterEditorProps = {\n config: {\n display: CollectionDisplay\n multiple: boolean\n options: CollectionOptions\n }\n filter: {\n label: string\n name: string\n }\n label: ActiveFilterLabel\n onChange: FilterChange\n operator: {\n label: string\n }\n scope?: string\n value: CollectionFilterValue\n}\n\nexport function orderByOptions(\n options: CollectionOption[],\n selected: Set<string>\n) {\n return options.filter((o) => selected.has(o.value)).map((o) => o.value)\n}\n\nexport function CollectionEditorCombobox({\n value,\n multiple,\n operator,\n ...props\n}: CollectionEditorProps &\n Partial<ComboBoxElementProps> &\n Pick<ComboBoxElementProps, \"children\">) {\n return (\n <ComboBox\n // eslint-disable-next-line jsx-a11y/no-autofocus -- the editor only ever renders inside a chip popover that just opened, per ARIA dialog practices\n autoFocus\n hideLabel\n label={operator.label}\n selectionMode={multiple ? \"multiple\" : \"single\"}\n value={value}\n {...props}\n />\n )\n}\n"],"names":["React"],"mappings":";;;AAyCM,SAAU,cAAc,CAC5B,OAA2B,EAC3B,QAAqB,EAAA;AAErB,IAAA,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;AACzE;AAEM,SAAU,wBAAwB,CAAC,EACvC,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,GAAG,KAAK,EAG8B,EAAA;IACtC,QACEA,6BAAC;;;;AAEC,QAAA,SAAS,EAAA,IAAA,EACT,SAAS,EAAA,IAAA,EACT,KAAK,EAAE,QAAQ,CAAC,KAAK,EACrB,aAAa,EAAE,QAAQ,GAAG,UAAU,GAAG,QAAQ,EAC/C,KAAK,EAAE,KAAK,EAAA,GACR,KAAK,EAAA,CACT;AAEN;;;;"}
|
|
@@ -12,7 +12,6 @@ export declare const FilterContext: React.Context<{
|
|
|
12
12
|
/** Restores focus after an action (e.g. clearing filters). */
|
|
13
13
|
restoreFilterFocus: () => void;
|
|
14
14
|
}>;
|
|
15
|
-
export declare function findScopedOption(filter: FilterNodeItem, scope: string | undefined): FilterNodeItem | undefined;
|
|
16
15
|
export declare function FiltersProvider({ activeFilters, filters, children, }: {
|
|
17
16
|
activeFilters?: ActiveFilter[];
|
|
18
17
|
children: React.ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterContext.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/FilterContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAA;AAEd,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,QAAQ,EACT,MAAM,eAAe,CAAA;AAQtB,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,aAAa,CAAC,EAAE,cAAc,CAAA;CAC/B,CAAA;AACD,eAAO,MAAM,aAAa;wBACJ,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC;8BAC5B,CACxB,YAAY,EAAE,YAAY,KACvB,2BAA2B,GAAG,SAAS;iBAC/B,cAAc,EAAE;wBACT,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO;IAC7C,8DAA8D;wBAC1C,MAAM,IAAI;EAO9B,CAAA;
|
|
1
|
+
{"version":3,"file":"FilterContext.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/FilterContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAA;AAEd,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,QAAQ,EACT,MAAM,eAAe,CAAA;AAQtB,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,aAAa,CAAC,EAAE,cAAc,CAAA;CAC/B,CAAA;AACD,eAAO,MAAM,aAAa;wBACJ,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC;8BAC5B,CACxB,YAAY,EAAE,YAAY,KACvB,2BAA2B,GAAG,SAAS;iBAC/B,cAAc,EAAE;wBACT,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO;IAC7C,8DAA8D;wBAC1C,MAAM,IAAI;EAO9B,CAAA;AAoBF,wBAAgB,eAAe,CAAC,EAC9B,aAAkB,EAClB,OAAO,EACP,QAAQ,GACT,EAAE;IACD,aAAa,CAAC,EAAE,YAAY,EAAE,CAAA;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,OAAO,EAAE,UAAU,EAAE,CAAA;CACtB,qBAUA;AAqDD,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,YAAY,GACzB,2BAA2B,CAQ7B;AAED,wBAAgB,qBAAqB,uCAEpC;AAED,wBAAgB,qBAAqB,UAlHT,IAAI,CAoH/B;AAED,wBAAgB,4BAA4B,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAExE"}
|
|
@@ -13,17 +13,17 @@ const FilterContext = createContext({
|
|
|
13
13
|
function flattenFilters(nodes) {
|
|
14
14
|
return nodes.flatMap((node) => node.children ? flattenFilters(node.children) : node);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function findScopeFilter(filter, scope) {
|
|
17
17
|
if (scope === undefined || !isScopedFilter(filter))
|
|
18
18
|
return undefined;
|
|
19
|
-
|
|
19
|
+
const isLazy = filter.options.length === 0;
|
|
20
|
+
if (!isLazy && !filter.options.some(({ value }) => value === scope))
|
|
21
|
+
return undefined;
|
|
22
|
+
return filter.scopeFilter;
|
|
20
23
|
}
|
|
21
24
|
function findOperator(filter, operatorName) {
|
|
22
25
|
return filter.operators.find((operator) => operator.name === operatorName);
|
|
23
26
|
}
|
|
24
|
-
function defaultOperator(filter) {
|
|
25
|
-
return filter.operators[0];
|
|
26
|
-
}
|
|
27
27
|
function FiltersProvider({ activeFilters = [], filters, children, }) {
|
|
28
28
|
return (React__default.createElement(PendingFilterProvider, null,
|
|
29
29
|
React__default.createElement(SearchableFiltersProvider, { filters: filters },
|
|
@@ -43,10 +43,13 @@ function FilterContextProvider({ activeFilters, filters, children, }) {
|
|
|
43
43
|
const relatedFilter = findFilter(activeFilter);
|
|
44
44
|
if (!relatedFilter)
|
|
45
45
|
return { operator: undefined, relatedFilter };
|
|
46
|
-
const
|
|
47
|
-
const isScopeUnrecognized =
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
const scopeFilter = findScopeFilter(relatedFilter, activeFilter.scope);
|
|
47
|
+
const isScopeUnrecognized = isScopedFilter(relatedFilter) &&
|
|
48
|
+
activeFilter.scope !== undefined &&
|
|
49
|
+
!scopeFilter;
|
|
50
|
+
const operator = isScopeUnrecognized
|
|
51
|
+
? undefined
|
|
52
|
+
: findOperator(scopeFilter ?? relatedFilter, activeFilter.operator);
|
|
50
53
|
return { operator, relatedFilter };
|
|
51
54
|
},
|
|
52
55
|
flatFilters,
|
|
@@ -73,5 +76,5 @@ function useHasFilterInstancesChecker() {
|
|
|
73
76
|
return useContext(FilterContext).hasFilterInstances;
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
export { FilterContext, FiltersProvider,
|
|
79
|
+
export { FilterContext, FiltersProvider, useAddFilterButtonRef, useHasFilterInstancesChecker, useRelatedFilterOperator, useRestoreFilterFocus };
|
|
77
80
|
//# sourceMappingURL=FilterContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterContext.js","sources":["../../../src/components/DataTable/FilterContext.tsx"],"sourcesContent":["import React, {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n} from \"react\"\n\nimport type {\n ActiveFilter,\n FilterNode,\n FilterNodeItem,\n Operator,\n} from \"./FilterTypes\"\nimport { isScopedFilter } from \"./FilterTypes\"\nimport {\n PendingFilterProvider,\n usePendingFilters,\n} from \"./PendingFilterContext\"\nimport { SearchableFiltersProvider } from \"./SearchableFilters\"\n\nexport type RelatedFilterOperatorResult = {\n operator?: Operator\n relatedFilter?: FilterNodeItem\n}\nexport const FilterContext = createContext<{\n addFilterButtonRef: React.RefObject<HTMLButtonElement>\n findActiveFilterOperator: (\n activeFilter: ActiveFilter\n ) => RelatedFilterOperatorResult | undefined\n flatFilters: FilterNodeItem[]\n hasFilterInstances: (name: string) => boolean\n /** Restores focus after an action (e.g. clearing filters). */\n restoreFilterFocus: () => void\n}>({\n addFilterButtonRef: { current: null },\n findActiveFilterOperator: () => undefined,\n flatFilters: [],\n hasFilterInstances: () => false,\n restoreFilterFocus: () => {},\n})\n\nfunction flattenFilters(nodes: FilterNode[]): FilterNodeItem[] {\n return nodes.flatMap((node) =>\n node.children ? flattenFilters(node.children) : node\n )\n}\n\
|
|
1
|
+
{"version":3,"file":"FilterContext.js","sources":["../../../src/components/DataTable/FilterContext.tsx"],"sourcesContent":["import React, {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n} from \"react\"\n\nimport type {\n ActiveFilter,\n FilterNode,\n FilterNodeItem,\n Operator,\n} from \"./FilterTypes\"\nimport { isScopedFilter } from \"./FilterTypes\"\nimport {\n PendingFilterProvider,\n usePendingFilters,\n} from \"./PendingFilterContext\"\nimport { SearchableFiltersProvider } from \"./SearchableFilters\"\n\nexport type RelatedFilterOperatorResult = {\n operator?: Operator\n relatedFilter?: FilterNodeItem\n}\nexport const FilterContext = createContext<{\n addFilterButtonRef: React.RefObject<HTMLButtonElement>\n findActiveFilterOperator: (\n activeFilter: ActiveFilter\n ) => RelatedFilterOperatorResult | undefined\n flatFilters: FilterNodeItem[]\n hasFilterInstances: (name: string) => boolean\n /** Restores focus after an action (e.g. clearing filters). */\n restoreFilterFocus: () => void\n}>({\n addFilterButtonRef: { current: null },\n findActiveFilterOperator: () => undefined,\n flatFilters: [],\n hasFilterInstances: () => false,\n restoreFilterFocus: () => {},\n})\n\nfunction flattenFilters(nodes: FilterNode[]): FilterNodeItem[] {\n return nodes.flatMap((node) =>\n node.children ? flattenFilters(node.children) : node\n )\n}\n\nfunction findScopeFilter(filter: FilterNodeItem, scope: string | undefined) {\n if (scope === undefined || !isScopedFilter(filter)) return undefined\n const isLazy = filter.options.length === 0\n if (!isLazy && !filter.options.some(({ value }) => value === scope))\n return undefined\n return filter.scopeFilter\n}\n\nfunction findOperator(filter: FilterNodeItem, operatorName: string) {\n return filter.operators.find((operator) => operator.name === operatorName)\n}\n\nexport function FiltersProvider({\n activeFilters = [],\n filters,\n children,\n}: {\n activeFilters?: ActiveFilter[]\n children: React.ReactNode\n filters: FilterNode[]\n}) {\n return (\n <PendingFilterProvider>\n <SearchableFiltersProvider filters={filters}>\n <FilterContextProvider activeFilters={activeFilters} filters={filters}>\n {children}\n </FilterContextProvider>\n </SearchableFiltersProvider>\n </PendingFilterProvider>\n )\n}\n\nfunction FilterContextProvider({\n activeFilters,\n filters,\n children,\n}: {\n activeFilters: ActiveFilter[]\n children: React.ReactNode\n filters: FilterNode[]\n}) {\n const { pendingFilters } = usePendingFilters()\n const flatFilters = useMemo(() => flattenFilters(filters), [filters])\n const findFilter = useCallback(\n (activeFilter: ActiveFilter) =>\n flatFilters.find((f) => f.name === activeFilter.name),\n [flatFilters]\n )\n const addFilterButtonRef = useRef<HTMLButtonElement>(null!)\n const restoreFilterFocus = useCallback(() => {\n addFilterButtonRef.current?.focus()\n }, [])\n const value = useMemo(\n () => ({\n addFilterButtonRef,\n findActiveFilterOperator: (activeFilter: ActiveFilter) => {\n const relatedFilter = findFilter(activeFilter)\n if (!relatedFilter) return { operator: undefined, relatedFilter }\n\n const scopeFilter = findScopeFilter(relatedFilter, activeFilter.scope)\n const isScopeUnrecognized =\n isScopedFilter(relatedFilter) &&\n activeFilter.scope !== undefined &&\n !scopeFilter\n\n const operator = isScopeUnrecognized\n ? undefined\n : findOperator(scopeFilter ?? relatedFilter, activeFilter.operator)\n return { operator, relatedFilter }\n },\n flatFilters,\n hasFilterInstances: (name: string) =>\n activeFilters.some((f) => f.name === name) ||\n pendingFilters.some((f) => f.name === name),\n restoreFilterFocus,\n }),\n [activeFilters, findFilter, flatFilters, pendingFilters, restoreFilterFocus]\n )\n return (\n <FilterContext.Provider value={value}>{children}</FilterContext.Provider>\n )\n}\n\nexport function useRelatedFilterOperator(\n activeFilter: ActiveFilter\n): RelatedFilterOperatorResult {\n const context = React.useContext(FilterContext)\n return (\n context.findActiveFilterOperator(activeFilter) || {\n operator: undefined,\n relatedFilter: undefined,\n }\n )\n}\n\nexport function useAddFilterButtonRef() {\n return React.useContext(FilterContext).addFilterButtonRef\n}\n\nexport function useRestoreFilterFocus() {\n return React.useContext(FilterContext).restoreFilterFocus\n}\n\nexport function useHasFilterInstancesChecker(): (name: string) => boolean {\n return useContext(FilterContext).hasFilterInstances\n}\n"],"names":["React"],"mappings":";;;;;AAyBO,MAAM,aAAa,GAAG,aAAa,CASvC;AACD,IAAA,kBAAkB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;AACrC,IAAA,wBAAwB,EAAE,MAAM,SAAS;AACzC,IAAA,WAAW,EAAE,EAAE;AACf,IAAA,kBAAkB,EAAE,MAAM,KAAK;AAC/B,IAAA,kBAAkB,EAAE,MAAK,EAAE,CAAC;AAC7B,CA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AC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;QAC7C,kBAAkB;AACnB,KAAA,CAAC,EACF,CAAC,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,CAAC,CAC7E;AACD,IAAA,QACEA,cAAA,CAAA,aAAA,CAAC,aAAa,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,EAAG,QAAQ,CAA0B;AAE7E;AAEM,SAAU,wBAAwB,CACtC,YAA0B,EAAA;IAE1B,MAAM,OAAO,GAAGA,cAAK,CAAC,UAAU,CAAC,aAAa,CAAC;AAC/C,IAAA,QACE,OAAO,CAAC,wBAAwB,CAAC,YAAY,CAAC,IAAI;AAChD,QAAA,QAAQ,EAAE,SAAS;AACnB,QAAA,aAAa,EAAE,SAAS;AACzB,KAAA;AAEL;SAEgB,qBAAqB,GAAA;IACnC,OAAOA,cAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,kBAAkB;AAC3D;SAEgB,qBAAqB,GAAA;IACnC,OAAOA,cAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,kBAAkB;AAC3D;SAEgB,4BAA4B,GAAA;AAC1C,IAAA,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC,kBAAkB;AACrD;;;;"}
|
|
@@ -29,17 +29,24 @@ export interface FilterNodeItem extends FilterNodeBase {
|
|
|
29
29
|
name: string;
|
|
30
30
|
operators: Operator[];
|
|
31
31
|
}
|
|
32
|
+
/** One of a scoped filter's scopes. Its `value` is stored as the active filter's `scope`. */
|
|
33
|
+
export type ScopeOption = {
|
|
34
|
+
keywords?: string[];
|
|
35
|
+
label: string;
|
|
36
|
+
value: string;
|
|
37
|
+
};
|
|
32
38
|
/**
|
|
33
|
-
* A filter
|
|
34
|
-
*
|
|
35
|
-
* `operator` and `value`, while this one still labels the chip.
|
|
39
|
+
* A filter applied within one of several scopes, chosen by an active filter's
|
|
40
|
+
* `scope` (see `scopedFilter`). Every scope shares `scopeFilter`, which
|
|
41
|
+
* supplies the `operator` and `value`, while this one still labels the chip.
|
|
36
42
|
*
|
|
37
43
|
* Distinct from a group's `children`: those render side by side in the menu,
|
|
38
44
|
* while these are alternatives the user picks between one at a time.
|
|
39
45
|
*/
|
|
40
46
|
export interface FilterNodeScoped extends FilterNodeItem {
|
|
41
|
-
/** The
|
|
42
|
-
options:
|
|
47
|
+
/** The scopes to pick from. Empty when they load lazily in the editor. */
|
|
48
|
+
options: ScopeOption[];
|
|
49
|
+
scopeFilter: FilterNodeItem;
|
|
43
50
|
}
|
|
44
51
|
/** Whether a filter delegates to scoped options. */
|
|
45
52
|
export declare function isScopedFilter(filter: FilterNodeItem): filter is FilterNodeScoped;
|
|
@@ -84,11 +91,16 @@ export interface ActiveFilter<T = unknown> {
|
|
|
84
91
|
/** The operator used by the applied filter. Corresponds to the name of the operator in the filter configuration. */
|
|
85
92
|
operator: string;
|
|
86
93
|
/**
|
|
87
|
-
* For scoped filters only: which of the parent's
|
|
88
|
-
* `operator` and `value` then belong to
|
|
89
|
-
*
|
|
94
|
+
* For scoped filters only: which of the parent's scopes is selected. The
|
|
95
|
+
* `operator` and `value` then belong to the parent's `scopeFilter`, so both
|
|
96
|
+
* are resolved against it.
|
|
90
97
|
*/
|
|
91
98
|
scope?: string;
|
|
99
|
+
/**
|
|
100
|
+
* For scoped filters with lazy scopes only: the selected scope's label, so
|
|
101
|
+
* the chip renders without loading the scopes.
|
|
102
|
+
*/
|
|
103
|
+
scopeLabel?: string;
|
|
92
104
|
/**
|
|
93
105
|
* The value of the applied filter. Can be of any type depending on the filter configuration.
|
|
94
106
|
* TODO: Add more specific typing based on the operator and input type.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterTypes.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/FilterTypes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAElE,MA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C;IAAE,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,CAAA;AAE3C,MAAM,MAAM,gBAAgB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI,IAAI,CAC/D,cAAc,EACd,4BAA4B,GAAG,WAAW,CAC3C,GACC,iBAAiB,CAAC,IAAI,CAAC,CAAA;AAEzB,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAA;AAEzE;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,CACzB,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,EAC9B,KAAK,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,KAC3B,IAAI,CAAA;AAET,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;AAE7D,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACvC,qEAAqE;IACrE,KAAK,CAAC,EAAE,iBAAiB,CAAA;IACzB,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAA;IACZ,qHAAqH;IACrH,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,KAAK,EAAE,CAAC,CAAA;CACT;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterTypes.js","sources":["../../../src/components/DataTable/FilterTypes.tsx"],"sourcesContent":["import type { ActiveFilterInstance } from \"./ActiveFilterInstance\"\n\nexport interface FilterNodeBase {\n /** Extra search terms beyond the label. */\n keywords?: string[]\n}\n\nexport interface InputType {\n type: string\n}\n\nexport interface Operator {\n inputType: InputType\n label: string\n name: string\n}\n\nexport interface FilterNodeItem extends FilterNodeBase {\n /** Whether multiple instances of this filter can be active simultaneously. */\n allowMultiple?: boolean\n children?: never\n /** Binds this filter to one active filter's operator and value. Supplied by the filter factories. */\n createActiveFilterInstance: (\n activeFilter: ActiveFilter,\n operator: Operator\n ) => ActiveFilterInstance\n /** Not rendered in the menu. Carried through as data for the change handler. */\n description?: string\n /** Display name in the filter menu. */\n label: string\n /**\n * Stable id. Keys the active filter this config produces. Must be unique\n * across the whole filter tree — it's applied as the item's `id`, and\n * duplicates break the menu.\n */\n name: string\n operators: Operator[]\n}\n\n/**\n * A filter
|
|
1
|
+
{"version":3,"file":"FilterTypes.js","sources":["../../../src/components/DataTable/FilterTypes.tsx"],"sourcesContent":["import type { ActiveFilterInstance } from \"./ActiveFilterInstance\"\n\nexport interface FilterNodeBase {\n /** Extra search terms beyond the label. */\n keywords?: string[]\n}\n\nexport interface InputType {\n type: string\n}\n\nexport interface Operator {\n inputType: InputType\n label: string\n name: string\n}\n\nexport interface FilterNodeItem extends FilterNodeBase {\n /** Whether multiple instances of this filter can be active simultaneously. */\n allowMultiple?: boolean\n children?: never\n /** Binds this filter to one active filter's operator and value. Supplied by the filter factories. */\n createActiveFilterInstance: (\n activeFilter: ActiveFilter,\n operator: Operator\n ) => ActiveFilterInstance\n /** Not rendered in the menu. Carried through as data for the change handler. */\n description?: string\n /** Display name in the filter menu. */\n label: string\n /**\n * Stable id. Keys the active filter this config produces. Must be unique\n * across the whole filter tree — it's applied as the item's `id`, and\n * duplicates break the menu.\n */\n name: string\n operators: Operator[]\n}\n\n/** One of a scoped filter's scopes. Its `value` is stored as the active filter's `scope`. */\nexport type ScopeOption = {\n keywords?: string[]\n label: string\n value: string\n}\n\n/**\n * A filter applied within one of several scopes, chosen by an active filter's\n * `scope` (see `scopedFilter`). Every scope shares `scopeFilter`, which\n * supplies the `operator` and `value`, while this one still labels the chip.\n *\n * Distinct from a group's `children`: those render side by side in the menu,\n * while these are alternatives the user picks between one at a time.\n */\nexport interface FilterNodeScoped extends FilterNodeItem {\n /** The scopes to pick from. Empty when they load lazily in the editor. */\n options: ScopeOption[]\n scopeFilter: FilterNodeItem\n}\n\n/** Whether a filter delegates to scoped options. */\nexport function isScopedFilter(\n filter: FilterNodeItem\n): filter is FilterNodeScoped {\n return Array.isArray((filter as FilterNodeScoped).options)\n}\n\nexport interface FilterNodeGroup extends FilterNodeBase {\n /** Filters and nested groups, in display order. */\n children: FilterNode[]\n description?: never\n keywords?: string[]\n /** Section header, or submenu trigger label. */\n label: string\n /** Opens children in a submenu instead of an inline section. */\n renderChildrenInSubmenu?: boolean\n}\n\nexport type FilterNode = FilterNodeItem | FilterNodeGroup\n\n/** Narrow a factory's operator set by name. `includes` keeps only the named operators, in the order given; `excludes` drops them. */\nexport type OperatorSelection<Name extends string = string> =\n | { excludes?: never; includes?: Name[] }\n | { excludes?: Name[]; includes?: never }\n\nexport type FilterItemConfig<Name extends string = string> = Omit<\n FilterNodeItem,\n \"createActiveFilterInstance\" | \"operators\"\n> &\n OperatorSelection<Name>\n\nexport type UpdateActiveFilter = (updates: Partial<ActiveFilter>) => void\n\n/**\n * How an editor reports a change, along with whether the filter can now be\n * applied. Editors know this; callers would otherwise have to infer it from\n * the shape of the update.\n *\n * `complete` defaults to true, so an editor reporting a finished value says\n * nothing extra — only partial states need flagging.\n */\nexport type FilterChange = (\n updates: Partial<ActiveFilter>,\n state?: { complete?: boolean }\n) => void\n\nexport type ActiveFilterLabel = string | string[] | undefined\n\nexport interface ActiveFilter<T = unknown> {\n /** The human-readable label for the applied filter, if available. */\n label?: ActiveFilterLabel\n /** The HTML name of the applied filter. Connects to the name of the filter. */\n name: string\n /** The operator used by the applied filter. Corresponds to the name of the operator in the filter configuration. */\n operator: string\n /**\n * For scoped filters only: which of the parent's scopes is selected. The\n * `operator` and `value` then belong to the parent's `scopeFilter`, so both\n * are resolved against it.\n */\n scope?: string\n /**\n * For scoped filters with lazy scopes only: the selected scope's label, so\n * the chip renders without loading the scopes.\n */\n scopeLabel?: string\n /**\n * The value of the applied filter. Can be of any type depending on the filter configuration.\n * TODO: Add more specific typing based on the operator and input type.\n */\n value: T\n}\n\nexport type AddPendingFilterFn = (filter: ActiveFilter) => void\n"],"names":[],"mappings":"AA4DA;AACM,SAAU,cAAc,CAC5B,MAAsB,EAAA;IAEtB,OAAO,KAAK,CAAC,OAAO,CAAE,MAA2B,CAAC,OAAO,CAAC;AAC5D;;;;"}
|
|
@@ -30,8 +30,8 @@ function SearchableFiltersProvider({ children, filters, }) {
|
|
|
30
30
|
grouping: optionGrouping,
|
|
31
31
|
label: option.label,
|
|
32
32
|
name: filter.name,
|
|
33
|
-
operator: getDefaultOperatorName(
|
|
34
|
-
scope: option.
|
|
33
|
+
operator: getDefaultOperatorName(filter.scopeFilter),
|
|
34
|
+
scope: option.value,
|
|
35
35
|
searchable: optionSearchable,
|
|
36
36
|
});
|
|
37
37
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchableFilters.js","sources":["../../../src/components/DataTable/SearchableFilters.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from \"react\"\n\nimport { FilterNode, isScopedFilter } from \"./FilterTypes\"\nimport { getDefaultOperatorName } from \"./utils\"\n\nexport function useSearchableFilters(): SearchableSimpleFilterItem[] {\n return useContext(SearchableFiltersContext)\n}\n\nexport type SearchableSimpleFilterItem = {\n allowMultiple?: boolean\n grouping: string[]\n label: string\n name: string\n operator: string\n /** For a scoped filter's option: the scope to pre-select on the pending filter. */\n scope?: string\n searchable: string\n}\n\nconst SearchableFiltersContext = createContext<SearchableSimpleFilterItem[]>([])\n\nexport function SearchableFiltersProvider({\n children,\n filters,\n}: {\n children: React.ReactNode\n filters: FilterNode[]\n}) {\n const searchableSimpleFilterItems = useMemo(() => {\n const result: SearchableSimpleFilterItem[] = []\n\n function addFilterItem(\n filter: FilterNode,\n grouping: string[] = [],\n collectedKeywords: string[] = []\n ) {\n const keywords = [...collectedKeywords, ...(filter.keywords || [])]\n if (filter.children) {\n return filter.children.forEach((child) =>\n addFilterItem(child, [...grouping, filter.label], keywords)\n )\n }\n\n if (isScopedFilter(filter)) {\n return filter.options.forEach((option) => {\n const optionGrouping = [...grouping, filter.label]\n const optionKeywords = [...keywords, ...(option.keywords || [])]\n const optionSearchable = dedup([\n ...optionGrouping,\n option.label,\n ...optionKeywords,\n ])\n .join(\" \")\n .toLowerCase()\n result.push({\n allowMultiple: filter.allowMultiple,\n grouping: optionGrouping,\n label: option.label,\n name: filter.name,\n operator: getDefaultOperatorName(
|
|
1
|
+
{"version":3,"file":"SearchableFilters.js","sources":["../../../src/components/DataTable/SearchableFilters.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from \"react\"\n\nimport { FilterNode, isScopedFilter } from \"./FilterTypes\"\nimport { getDefaultOperatorName } from \"./utils\"\n\nexport function useSearchableFilters(): SearchableSimpleFilterItem[] {\n return useContext(SearchableFiltersContext)\n}\n\nexport type SearchableSimpleFilterItem = {\n allowMultiple?: boolean\n grouping: string[]\n label: string\n name: string\n operator: string\n /** For a scoped filter's option: the scope to pre-select on the pending filter. */\n scope?: string\n searchable: string\n}\n\nconst SearchableFiltersContext = createContext<SearchableSimpleFilterItem[]>([])\n\nexport function SearchableFiltersProvider({\n children,\n filters,\n}: {\n children: React.ReactNode\n filters: FilterNode[]\n}) {\n const searchableSimpleFilterItems = useMemo(() => {\n const result: SearchableSimpleFilterItem[] = []\n\n function addFilterItem(\n filter: FilterNode,\n grouping: string[] = [],\n collectedKeywords: string[] = []\n ) {\n const keywords = [...collectedKeywords, ...(filter.keywords || [])]\n if (filter.children) {\n return filter.children.forEach((child) =>\n addFilterItem(child, [...grouping, filter.label], keywords)\n )\n }\n\n if (isScopedFilter(filter)) {\n return filter.options.forEach((option) => {\n const optionGrouping = [...grouping, filter.label]\n const optionKeywords = [...keywords, ...(option.keywords || [])]\n const optionSearchable = dedup([\n ...optionGrouping,\n option.label,\n ...optionKeywords,\n ])\n .join(\" \")\n .toLowerCase()\n result.push({\n allowMultiple: filter.allowMultiple,\n grouping: optionGrouping,\n label: option.label,\n name: filter.name,\n operator: getDefaultOperatorName(filter.scopeFilter),\n scope: option.value,\n searchable: optionSearchable,\n })\n })\n }\n\n const searchable = dedup([...grouping, filter.label, ...keywords])\n .join(\" \")\n .toLowerCase()\n result.push({\n allowMultiple: filter.allowMultiple,\n grouping,\n label: filter.label,\n name: filter.name,\n operator: getDefaultOperatorName(filter),\n searchable,\n })\n }\n\n filters.forEach((filter) => addFilterItem(filter))\n return result\n }, [filters])\n\n return (\n <SearchableFiltersContext.Provider value={searchableSimpleFilterItems}>\n {children}\n </SearchableFiltersContext.Provider>\n )\n}\n\nfunction dedup(items: string[]): string[] {\n return Array.from(new Set(items))\n}\n"],"names":["React"],"mappings":";;;;SAKgB,oBAAoB,GAAA;AAClC,IAAA,OAAO,UAAU,CAAC,wBAAwB,CAAC;AAC7C;AAaA,MAAM,wBAAwB,GAAG,aAAa,CAA+B,EAAE,CAAC;SAEhE,yBAAyB,CAAC,EACxC,QAAQ,EACR,OAAO,GAIR,EAAA;AACC,IAAA,MAAM,2BAA2B,GAAG,OAAO,CAAC,MAAK;QAC/C,MAAM,MAAM,GAAiC,EAAE;QAE/C,SAAS,aAAa,CACpB,MAAkB,EAClB,WAAqB,EAAE,EACvB,oBAA8B,EAAE,EAAA;AAEhC,YAAA,MAAM,QAAQ,GAAG,CAAC,GAAG,iBAAiB,EAAE,IAAI,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;AACnE,YAAA,IAAI,MAAM,CAAC,QAAQ,EAAE;gBACnB,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAK,KACnC,aAAa,CAAC,KAAK,EAAE,CAAC,GAAG,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,CAC5D;YACH;AAEA,YAAA,IAAI,cAAc,CAAC,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E,CACrE,CAAA;AAEL,wBAAgB,gBAAgB,CAAC,EAC/B,OAAkB,EAClB,QAAQ,EACR,QAAQ,EACR,QAAgB,EAChB,OAAO,EACP,GAAG,MAAM,EACV,EAAE,sBAAsB,GAAG,cAAc,CAezC"}
|
|
@@ -18,17 +18,19 @@ const COLLECTION_OPERATORS = [COLLECTION_IS, COLLECTION_NOT];
|
|
|
18
18
|
function collectionFilter({ display = "select", excludes, includes, multiple = false, options, ...config }) {
|
|
19
19
|
const filter = {
|
|
20
20
|
...config,
|
|
21
|
-
createActiveFilterInstance: (activeFilter, operator) => new CollectionActiveFilter(filter, operator, activeFilter.value, activeFilter.label, { display, multiple, options }),
|
|
21
|
+
createActiveFilterInstance: (activeFilter, operator) => new CollectionActiveFilter(filter, operator, activeFilter.value, activeFilter.label, activeFilter.scope, { display, multiple, options }),
|
|
22
22
|
operators: resolveOperators(COLLECTION_OPERATORS, { excludes, includes }),
|
|
23
23
|
};
|
|
24
24
|
return filter;
|
|
25
25
|
}
|
|
26
26
|
class CollectionActiveFilter extends ActiveFilterInstance {
|
|
27
27
|
label;
|
|
28
|
+
scope;
|
|
28
29
|
config;
|
|
29
|
-
constructor(filter, operator, value, label, config) {
|
|
30
|
+
constructor(filter, operator, value, label, scope, config) {
|
|
30
31
|
super(filter, operator, value);
|
|
31
32
|
this.label = label;
|
|
33
|
+
this.scope = scope;
|
|
32
34
|
this.config = config;
|
|
33
35
|
this.label = label;
|
|
34
36
|
}
|
|
@@ -47,7 +49,7 @@ class CollectionActiveFilter extends ActiveFilterInstance {
|
|
|
47
49
|
const Editor = hasLazyOptions
|
|
48
50
|
? CollectionFilterEditorLazy
|
|
49
51
|
: CollectionFilterEditorStatic;
|
|
50
|
-
return (React__default.createElement(Editor, { config: this.config, onChange: onChange, operator: this.operator, value: this.value, label: this.label, filter: this.filter }));
|
|
52
|
+
return (React__default.createElement(Editor, { config: this.config, onChange: onChange, operator: this.operator, value: this.value, label: this.label, filter: this.filter, scope: this.scope }));
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectionFilter.js","sources":["../../../src/components/DataTable/collectionFilter.tsx"],"sourcesContent":["import React from \"react\"\n\nimport { ActiveFilterInstance } from \"./ActiveFilterInstance\"\nimport { CollectionFilterEditorLazy } from \"./CollectionEditorsLazy\"\nimport type {\n CollectionFilterValue,\n CollectionOptions,\n} from \"./CollectionEditorsShared\"\nimport { CollectionFilterEditorStatic } from \"./CollectionEditorsStatic\"\nimport type {\n ActiveFilterLabel,\n FilterChange,\n FilterItemConfig,\n FilterNodeItem,\n Operator,\n} from \"./FilterTypes\"\nimport { resolveOperators } from \"./resolveOperators\"\n\n// A type alias (not an interface) so it satisfies `Select`'s `data-*` index signature.\nexport type CollectionOption = {\n label: string\n value: string\n}\n\nexport type CollectionDisplay = \"checkboxes\" | \"combobox\" | \"select\"\n\nexport const COLLECTION_IS = {\n inputType: { type: \"collection\" },\n label: \"is\",\n name: \"eq\",\n} as const satisfies Operator\nexport const COLLECTION_NOT = {\n inputType: { type: \"collection\" },\n label: \"is not\",\n name: \"not\",\n} as const satisfies Operator\n\nconst COLLECTION_OPERATORS = [COLLECTION_IS, COLLECTION_NOT]\n\nexport type CollectionOperatorName =\n (typeof COLLECTION_OPERATORS)[number][\"name\"]\n\nexport type CollectionFilterConfig =\n FilterItemConfig<CollectionOperatorName> & {\n options: CollectionOptions\n } & (\n | { display?: CollectionDisplay; multiple?: false }\n | { display?: Exclude<CollectionDisplay, \"select\">; multiple: true }\n )\n\nexport function collectionFilter({\n display = \"select\",\n excludes,\n includes,\n multiple = false,\n options,\n ...config\n}: CollectionFilterConfig): FilterNodeItem {\n const filter: FilterNodeItem = {\n ...config,\n createActiveFilterInstance: (activeFilter, operator) =>\n new CollectionActiveFilter(\n filter,\n operator,\n activeFilter.value as CollectionFilterValue,\n activeFilter.label,\n { display, multiple, options }\n ),\n operators: resolveOperators(COLLECTION_OPERATORS, { excludes, includes }),\n }\n return filter\n}\n\nclass CollectionActiveFilter extends ActiveFilterInstance<CollectionFilterValue> {\n constructor(\n filter: FilterNodeItem,\n operator: FilterNodeItem[\"operators\"][number],\n value: CollectionFilterValue,\n private readonly label: ActiveFilterLabel,\n private readonly config: {\n display: CollectionDisplay\n multiple: boolean\n options: CollectionOptions\n }\n ) {\n super(filter, operator, value)\n this.label = label\n }\n\n formatValue() {\n if (this.label) return Array.isArray(this.label) ? this.label : [this.label]\n const values = Array.isArray(this.value) ? this.value : [this.value]\n if (typeof this.config.options === \"function\") return [\"\"]\n return values\n .map(\n (value) =>\n (this.config.options as CollectionOption[]).find(\n (option) => option.value === value\n )?.label ?? value\n )\n .join(\", \")\n }\n\n renderEditor(onChange: FilterChange) {\n const hasLazyOptions = typeof this.config.options === \"function\"\n const Editor = hasLazyOptions\n ? CollectionFilterEditorLazy\n : CollectionFilterEditorStatic\n\n return (\n <Editor\n config={this.config}\n onChange={onChange}\n operator={this.operator}\n value={this.value}\n label={this.label}\n filter={this.filter}\n />\n )\n }\n}\n"],"names":["React"],"mappings":";;;;;;AA0BO,MAAM,aAAa,GAAG;AAC3B,IAAA,SAAS,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE;AACjC,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,IAAI,EAAE,IAAI;;AAEL,MAAM,cAAc,GAAG;AAC5B,IAAA,SAAS,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE;AACjC,IAAA,KAAK,EAAE,QAAQ;AACf,IAAA,IAAI,EAAE,KAAK;;AAGb,MAAM,oBAAoB,GAAG,CAAC,aAAa,EAAE,cAAc,CAAC;AAatD,SAAU,gBAAgB,CAAC,EAC/B,OAAO,GAAG,QAAQ,EAClB,QAAQ,EACR,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,OAAO,EACP,GAAG,MAAM,EACc,EAAA;AACvB,IAAA,MAAM,MAAM,GAAmB;AAC7B,QAAA,GAAG,MAAM;AACT,QAAA,0BAA0B,EAAE,CAAC,YAAY,EAAE,QAAQ,KACjD,IAAI,sBAAsB,CACxB,MAAM,EACN,QAAQ,EACR,YAAY,CAAC,KAA8B,EAC3C,YAAY,CAAC,KAAK,EAClB,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAC/B;QACH,SAAS,EAAE,gBAAgB,CAAC,oBAAoB,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;KAC1E;AACD,IAAA,OAAO,MAAM;AACf;AAEA,MAAM,sBAAuB,SAAQ,oBAA2C,CAAA;AAK3D,IAAA,KAAA;AACA,IAAA,MAAA;
|
|
1
|
+
{"version":3,"file":"collectionFilter.js","sources":["../../../src/components/DataTable/collectionFilter.tsx"],"sourcesContent":["import React from \"react\"\n\nimport { ActiveFilterInstance } from \"./ActiveFilterInstance\"\nimport { CollectionFilterEditorLazy } from \"./CollectionEditorsLazy\"\nimport type {\n CollectionFilterValue,\n CollectionOptions,\n} from \"./CollectionEditorsShared\"\nimport { CollectionFilterEditorStatic } from \"./CollectionEditorsStatic\"\nimport type {\n ActiveFilterLabel,\n FilterChange,\n FilterItemConfig,\n FilterNodeItem,\n Operator,\n} from \"./FilterTypes\"\nimport { resolveOperators } from \"./resolveOperators\"\n\n// A type alias (not an interface) so it satisfies `Select`'s `data-*` index signature.\nexport type CollectionOption = {\n label: string\n value: string\n}\n\nexport type CollectionDisplay = \"checkboxes\" | \"combobox\" | \"select\"\n\nexport const COLLECTION_IS = {\n inputType: { type: \"collection\" },\n label: \"is\",\n name: \"eq\",\n} as const satisfies Operator\nexport const COLLECTION_NOT = {\n inputType: { type: \"collection\" },\n label: \"is not\",\n name: \"not\",\n} as const satisfies Operator\n\nconst COLLECTION_OPERATORS = [COLLECTION_IS, COLLECTION_NOT]\n\nexport type CollectionOperatorName =\n (typeof COLLECTION_OPERATORS)[number][\"name\"]\n\nexport type CollectionFilterConfig =\n FilterItemConfig<CollectionOperatorName> & {\n options: CollectionOptions\n } & (\n | { display?: CollectionDisplay; multiple?: false }\n | { display?: Exclude<CollectionDisplay, \"select\">; multiple: true }\n )\n\nexport function collectionFilter({\n display = \"select\",\n excludes,\n includes,\n multiple = false,\n options,\n ...config\n}: CollectionFilterConfig): FilterNodeItem {\n const filter: FilterNodeItem = {\n ...config,\n createActiveFilterInstance: (activeFilter, operator) =>\n new CollectionActiveFilter(\n filter,\n operator,\n activeFilter.value as CollectionFilterValue,\n activeFilter.label,\n activeFilter.scope,\n { display, multiple, options }\n ),\n operators: resolveOperators(COLLECTION_OPERATORS, { excludes, includes }),\n }\n return filter\n}\n\nclass CollectionActiveFilter extends ActiveFilterInstance<CollectionFilterValue> {\n constructor(\n filter: FilterNodeItem,\n operator: FilterNodeItem[\"operators\"][number],\n value: CollectionFilterValue,\n private readonly label: ActiveFilterLabel,\n private readonly scope: string | undefined,\n private readonly config: {\n display: CollectionDisplay\n multiple: boolean\n options: CollectionOptions\n }\n ) {\n super(filter, operator, value)\n this.label = label\n }\n\n formatValue() {\n if (this.label) return Array.isArray(this.label) ? this.label : [this.label]\n const values = Array.isArray(this.value) ? this.value : [this.value]\n if (typeof this.config.options === \"function\") return [\"\"]\n return values\n .map(\n (value) =>\n (this.config.options as CollectionOption[]).find(\n (option) => option.value === value\n )?.label ?? value\n )\n .join(\", \")\n }\n\n renderEditor(onChange: FilterChange) {\n const hasLazyOptions = typeof this.config.options === \"function\"\n const Editor = hasLazyOptions\n ? CollectionFilterEditorLazy\n : CollectionFilterEditorStatic\n\n return (\n <Editor\n config={this.config}\n onChange={onChange}\n operator={this.operator}\n value={this.value}\n label={this.label}\n filter={this.filter}\n scope={this.scope}\n />\n )\n }\n}\n"],"names":["React"],"mappings":";;;;;;AA0BO,MAAM,aAAa,GAAG;AAC3B,IAAA,SAAS,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE;AACjC,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,IAAI,EAAE,IAAI;;AAEL,MAAM,cAAc,GAAG;AAC5B,IAAA,SAAS,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,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;QAC5E,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;AACpE,QAAA,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,KAAK,UAAU;YAAE,OAAO,CAAC,EAAE,CAAC;AAC1D,QAAA,OAAO;AACJ,aAAA,GAAG,CACF,CAAC,KAAK,KACH,IAAI,CAAC,MAAM,CAAC,OAA8B,CAAC,IAAI,CAC9C,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,KAAK,KAAK,CACnC,EAAE,KAAK,IAAI,KAAK;aAEpB,IAAI,CAAC,IAAI,CAAC;IACf;AAEA,IAAA,YAAY,CAAC,QAAsB,EAAA;QACjC,MAAM,cAAc,GAAG,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,KAAK,UAAU;QAChE,MAAM,MAAM,GAAG;AACb,cAAE;cACA,4BAA4B;QAEhC,QACEA,6BAAC,MAAM,EAAA,EACL,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,KAAK,EAAE,IAAI,CAAC,KAAK,EAAA,CACjB;IAEN;AACD;;;;"}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import type { FilterItemConfig, FilterNodeItem, FilterNodeScoped } from "./FilterTypes";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* identifier and its `label` is the scope's entry in the dropdown, so there's
|
|
5
|
-
* no separate option wrapper to keep in sync. Names need only be unique within
|
|
6
|
-
* this list — they're resolved here, not in the table's flat filter registry.
|
|
7
|
-
*/
|
|
8
|
-
export type ScopedFilterOptions = FilterNodeItem[];
|
|
1
|
+
import type { FilterItemConfig, FilterNodeItem, FilterNodeScoped, ScopeOption } from "./FilterTypes";
|
|
2
|
+
export type ScopedFilterOptions = ScopeOption[];
|
|
3
|
+
export type ScopedFilterOptionsLoader = () => Promise<ScopedFilterOptions> | ScopedFilterOptions;
|
|
9
4
|
export type ScopedFilterConfig = Omit<FilterItemConfig, "excludes" | "includes"> & {
|
|
10
|
-
|
|
5
|
+
filter: FilterNodeItem;
|
|
6
|
+
options: ScopedFilterOptions | ScopedFilterOptionsLoader;
|
|
11
7
|
};
|
|
12
|
-
export declare function scopedFilter({ options, ...config }: ScopedFilterConfig): FilterNodeScoped;
|
|
8
|
+
export declare function scopedFilter({ filter: scopeFilter, options, ...config }: ScopedFilterConfig): FilterNodeScoped;
|
|
13
9
|
//# sourceMappingURL=scopedFilter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scopedFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/scopedFilter.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,gBAAgB,EAChB,cAAc,EACd,gBAAgB,
|
|
1
|
+
{"version":3,"file":"scopedFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/scopedFilter.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAEhB,WAAW,EACZ,MAAM,eAAe,CAAA;AAWtB,MAAM,MAAM,mBAAmB,GAAG,WAAW,EAAE,CAAA;AAE/C,MAAM,MAAM,yBAAyB,GAAG,MACpC,OAAO,CAAC,mBAAmB,CAAC,GAC5B,mBAAmB,CAAA;AAEvB,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,gBAAgB,EAChB,UAAU,GAAG,UAAU,CACxB,GAAG;IACF,MAAM,EAAE,cAAc,CAAA;IACtB,OAAO,EAAE,mBAAmB,GAAG,yBAAyB,CAAA;CACzD,CAAA;AAED,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EAAE,WAAW,EACnB,OAAO,EACP,GAAG,MAAM,EACV,EAAE,kBAAkB,GAAG,gBAAgB,CAWvC"}
|