@planningcenter/tapestry 4.8.1-rc.0 → 4.9.1-qa-1346.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.
Files changed (36) hide show
  1. package/dist/components/DataTable/CollectionEditorsLazy.d.ts +4 -0
  2. package/dist/components/DataTable/CollectionEditorsLazy.d.ts.map +1 -0
  3. package/dist/components/DataTable/CollectionEditorsLazy.js +131 -0
  4. package/dist/components/DataTable/CollectionEditorsLazy.js.map +1 -0
  5. package/dist/components/DataTable/CollectionEditorsShared.d.ts +6 -2
  6. package/dist/components/DataTable/CollectionEditorsShared.d.ts.map +1 -1
  7. package/dist/components/DataTable/CollectionEditorsShared.js.map +1 -1
  8. package/dist/components/DataTable/CollectionEditorsStatic.d.ts.map +1 -1
  9. package/dist/components/DataTable/CollectionEditorsStatic.js +3 -2
  10. package/dist/components/DataTable/CollectionEditorsStatic.js.map +1 -1
  11. package/dist/components/DataTable/FilterTypes.d.ts +3 -0
  12. package/dist/components/DataTable/FilterTypes.d.ts.map +1 -1
  13. package/dist/components/DataTable/FilterTypes.js.map +1 -1
  14. package/dist/components/DataTable/collectionFilter.d.ts +2 -1
  15. package/dist/components/DataTable/collectionFilter.d.ts.map +1 -1
  16. package/dist/components/DataTable/collectionFilter.js +16 -5
  17. package/dist/components/DataTable/collectionFilter.js.map +1 -1
  18. package/dist/components/DataTable/numberFilter.d.ts.map +1 -1
  19. package/dist/components/DataTable/numberFilter.js +49 -31
  20. package/dist/components/DataTable/numberFilter.js.map +1 -1
  21. package/dist/components/DataTable/textFilter.js +14 -2
  22. package/dist/components/DataTable/textFilter.js.map +1 -1
  23. package/dist/components/dropdown/Dropdown.d.ts.map +1 -1
  24. package/dist/components/dropdown/Dropdown.js +28 -1
  25. package/dist/components/dropdown/Dropdown.js.map +1 -1
  26. package/dist/reactRender.css +656 -656
  27. package/dist/reactRender.css.map +1 -1
  28. package/dist/reactRenderLegacy.css +656 -656
  29. package/dist/reactRenderLegacy.css.map +1 -1
  30. package/dist/unstable.css +213 -213
  31. package/dist/unstable.css.map +1 -1
  32. package/dist/utilities/useDebouncedValue.d.ts +2 -0
  33. package/dist/utilities/useDebouncedValue.d.ts.map +1 -0
  34. package/dist/utilities/useDebouncedValue.js +13 -0
  35. package/dist/utilities/useDebouncedValue.js.map +1 -0
  36. package/package.json +5 -5
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { CollectionFilterEditorProps } from "./CollectionEditorsShared";
3
+ export declare function CollectionFilterEditorLazy({ config, onChange, operator, value, filter, label, }: CollectionFilterEditorProps): React.JSX.Element;
4
+ //# sourceMappingURL=CollectionEditorsLazy.d.ts.map
@@ -0,0 +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,EAE5B,MAAM,2BAA2B,CAAA;AAqBlC,wBAAgB,0BAA0B,CAAC,EACzC,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,MAAM,EACN,KAAK,GACN,EAAE,2BAA2B,qBA+D7B"}
@@ -0,0 +1,131 @@
1
+ import { ComboBoxItem } from '../combo-box/ComboBox.js';
2
+ import { useDebouncedValue } from '../../utilities/useDebouncedValue.js';
3
+ import React__default, { useState, useCallback, useEffect } from 'react';
4
+ import { CollectionEditorCombobox } from './CollectionEditorsShared.js';
5
+ import { CollectionEditorCheckboxes, CollectionEditorRadios, CollectionEditorSelect } from './CollectionEditorsStatic.js';
6
+ import { isEmptyValue } from './utils.js';
7
+
8
+ const DEBOUNCE_MS = 300;
9
+ function CollectionFilterEditorLazy({ config, onChange, operator, value, filter, label, }) {
10
+ const { display, multiple } = config;
11
+ const options = config.options;
12
+ const [query, setQuery] = useState();
13
+ const debouncedQuery = useDebouncedValue(query, DEBOUNCE_MS);
14
+ const [resolvedOptions, setResolvedOptions] = useState([]);
15
+ const onCommit = useCallback((newValue) => {
16
+ const newLabel = findLabelFromOptions(resolvedOptions, newValue, {
17
+ label,
18
+ value,
19
+ });
20
+ return onChange({ label: newLabel, value: newValue }, { complete: !isEmptyValue(newValue) });
21
+ }, [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
+ const Editor = getLazyEditor({ display, multiple });
51
+ 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
+ }
53
+ function getLazyEditor({ display, multiple, }) {
54
+ if (display === "combobox")
55
+ return CollectionEditorComboboxLazy;
56
+ if (multiple)
57
+ return CollectionEditorCheckboxesLazy;
58
+ if (display === "checkboxes")
59
+ return CollectionEditorRadiosLazy; // TODO: This looks like it might be a mistake, should it be CollectionEditorCheckboxes? or at least allow for `radios` as an option?
60
+ return CollectionEditorSelectLazy;
61
+ }
62
+ function CollectionEditorCheckboxesLazy({ error, loading, ...props }) {
63
+ if (loading)
64
+ return React__default.createElement(Loading, null);
65
+ if (error)
66
+ return React__default.createElement(LoadError, null);
67
+ return React__default.createElement(CollectionEditorCheckboxes, { ...props });
68
+ }
69
+ function CollectionEditorRadiosLazy({ error, loading, ...props }) {
70
+ if (loading)
71
+ return React__default.createElement(Loading, null);
72
+ if (error)
73
+ return React__default.createElement(LoadError, null);
74
+ return React__default.createElement(CollectionEditorRadios, { ...props });
75
+ }
76
+ function CollectionEditorSelectLazy({ error, loading, ...props }) {
77
+ if (loading)
78
+ return React__default.createElement(Loading, null);
79
+ if (error)
80
+ return React__default.createElement(LoadError, null);
81
+ return React__default.createElement(CollectionEditorSelect, { ...props });
82
+ }
83
+ function CollectionEditorComboboxLazy({ error, onCommit, options, query, loading, setQuery, ...props }) {
84
+ const [loadingState, setLoadingState] = useState(loading ? "loading" : "idle");
85
+ useEffect(() => {
86
+ if (!loading) {
87
+ setLoadingState("idle");
88
+ }
89
+ }, [loading]);
90
+ return (React__default.createElement(CollectionEditorCombobox, { ...props, loadingState: error ? "error" : loadingState, inputValue: query, onInputChange: (q) => {
91
+ setLoadingState("filtering");
92
+ setQuery(q);
93
+ }, onChange: (value) => {
94
+ if (value === null)
95
+ return;
96
+ const resolvedValue = Array.isArray(value)
97
+ ? value.map(String)
98
+ : String(value);
99
+ onCommit(resolvedValue);
100
+ }, items: options, renderEmptyState: error ? React__default.createElement(LoadError, null) : "No results" }, (o) => {
101
+ const option = o;
102
+ return (React__default.createElement(ComboBoxItem, { key: option.value, id: option.value }, option.label));
103
+ }));
104
+ }
105
+ function Loading() {
106
+ return React__default.createElement("div", { style: { color: "hotpink", fontWeight: "bold" } }, "Loading...");
107
+ }
108
+ function LoadError() {
109
+ return (React__default.createElement("div", { style: { color: "hotpink", fontWeight: "bold" } }, "Failed to load options"));
110
+ }
111
+ function findLabelFromOptions(options, value, previous) {
112
+ const previousLabelByValue = buildPreviousLabelByValue(previous);
113
+ const labelFor = (v) => options.find((option) => option.value === v)?.label ??
114
+ previousLabelByValue.get(v);
115
+ return Array.isArray(value)
116
+ ? value.map(labelFor).filter((label) => label !== undefined)
117
+ : labelFor(value);
118
+ }
119
+ function buildPreviousLabelByValue(previous) {
120
+ const previousValues = normalizeValueToArray(previous.value);
121
+ const previousLabels = normalizeValueToArray(previous.label);
122
+ return new Map(previousValues.map((v, index) => [v, previousLabels[index]]));
123
+ }
124
+ function normalizeValueToArray(value) {
125
+ if (value === undefined)
126
+ return [];
127
+ return Array.isArray(value) ? value : [value];
128
+ }
129
+
130
+ export { CollectionFilterEditorLazy };
131
+ //# sourceMappingURL=CollectionEditorsLazy.js.map
@@ -0,0 +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,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AQ,CAAC;IAChE,MAAM,QAAQ,GAAG,CAAC,CAAS,KACzB,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,KAAK,CAAC,CAAC,EAAE,KAAK;AACnD,QAAA,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC;AAE7B,IAAA,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK;AACxB,UAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,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;;;;"}
@@ -2,9 +2,11 @@ import { type ComboBoxElementProps } from "../combo-box";
2
2
  import React from "react";
3
3
  import type { CollectionDisplay } from "./collectionFilter";
4
4
  import { CollectionOption } from "./collectionFilter";
5
- import type { FilterChange } from "./FilterTypes";
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[];
9
+ export type CollectionOptions = CollectionOption[] | CollectionOptionsLazy;
8
10
  export type CollectionEditorProps = {
9
11
  multiple: boolean;
10
12
  operator: {
@@ -16,12 +18,13 @@ export type CollectionFilterEditorProps = {
16
18
  config: {
17
19
  display: CollectionDisplay;
18
20
  multiple: boolean;
19
- options: CollectionOption[];
21
+ options: CollectionOptions;
20
22
  };
21
23
  filter: {
22
24
  label: string;
23
25
  name: string;
24
26
  };
27
+ label: ActiveFilterLabel;
25
28
  onChange: FilterChange;
26
29
  operator: {
27
30
  label: string;
@@ -30,4 +33,5 @@ export type CollectionFilterEditorProps = {
30
33
  };
31
34
  export declare function orderByOptions(options: CollectionOption[], selected: Set<string>): string[];
32
35
  export declare function CollectionEditorCombobox({ value, multiple, operator, ...props }: CollectionEditorProps & Partial<ComboBoxElementProps> & Pick<ComboBoxElementProps, "children">): React.JSX.Element;
36
+ export {};
33
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,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,2EAA2E;AAC3E,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;AAErD,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,gBAAgB,EAAE,CAAA;KAC5B,CAAA;IACD,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;IACD,QAAQ,EAAE,YAAY,CAAA;IACtB,QAAQ,EAAE;QACR,KAAK,EAAE,MAAM,CAAA;KACd,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
+ {"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,KAAK,qBAAqB,GAAG,CAC3B,CAAC,EAAE,MAAM,GAAG,SAAS,KAClB,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,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 { 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 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: CollectionOption[]\n }\n filter: {\n label: string\n name: string\n }\n onChange: FilterChange\n operator: {\n label: string\n }\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":";;;AAiCM,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;;;;"}
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\ntype CollectionOptionsLazy = (\n q: string | undefined\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 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":";;;AAuCM,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;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"CollectionEditorsStatic.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/CollectionEditorsStatic.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAc,MAAM,OAAO,CAAA;AAElC,OAAO,EAEL,qBAAqB,EACrB,2BAA2B,EAC3B,qBAAqB,EAEtB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGrD,MAAM,MAAM,2BAA2B,GAAG,qBAAqB,GAAG;IAChE,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAA;IAChD,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAC5B,CAAA;AAED,wBAAgB,4BAA4B,CAAC,EAC3C,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,MAAM,GACP,EAAE,2BAA2B,qBAmB7B;AAeD,wBAAgB,0BAA0B,CAAC,EACzC,WAAW,EACX,QAAQ,EACR,OAAO,EACP,KAAK,GACN,EAAE,2BAA2B,qBAuB7B;AAED,wBAAgB,sBAAsB,CAAC,EACrC,WAAW,EACX,UAAU,EACV,QAAQ,EACR,OAAO,EACP,KAAK,GACN,EAAE,2BAA2B,qBAqB7B;AAED,wBAAgB,sBAAsB,CAAC,EACrC,KAAK,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,GACT,EAAE,2BAA2B,qBAc7B"}
1
+ {"version":3,"file":"CollectionEditorsStatic.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/CollectionEditorsStatic.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAc,MAAM,OAAO,CAAA;AAElC,OAAO,EAEL,qBAAqB,EACrB,2BAA2B,EAC3B,qBAAqB,EAEtB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGrD,MAAM,MAAM,2BAA2B,GAAG,qBAAqB,GAAG;IAChE,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAA;IAChD,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAC5B,CAAA;AAED,wBAAgB,4BAA4B,CAAC,EAC3C,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,MAAM,GACP,EAAE,2BAA2B,qBAoB7B;AAeD,wBAAgB,0BAA0B,CAAC,EACzC,WAAW,EACX,QAAQ,EACR,OAAO,EACP,KAAK,GACN,EAAE,2BAA2B,qBAuB7B;AAED,wBAAgB,sBAAsB,CAAC,EACrC,WAAW,EACX,UAAU,EACV,QAAQ,EACR,OAAO,EACP,KAAK,GACN,EAAE,2BAA2B,qBAqB7B;AAED,wBAAgB,sBAAsB,CAAC,EACrC,KAAK,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,GACT,EAAE,2BAA2B,qBAc7B"}
@@ -9,8 +9,9 @@ import { CollectionEditorCombobox, orderByOptions } from './CollectionEditorsSha
9
9
  import { isEmptyValue } from './utils.js';
10
10
 
11
11
  function CollectionFilterEditorStatic({ config, onChange, operator, value, filter, }) {
12
- const { display, multiple, options } = config;
13
- const onCommit = (value) => onChange({ value }, { complete: !isEmptyValue(value) });
12
+ const { display, multiple } = config;
13
+ const options = config.options;
14
+ const onCommit = (value) => onChange({ label: undefined, value }, { complete: !isEmptyValue(value) });
14
15
  const Editor = getStaticEditor({ display, multiple });
15
16
  return (React__default.createElement(Editor, { value: value, onCommit: onCommit, options: options, multiple: multiple, operator: operator, filterLabel: filter.label, filterName: filter.name }));
16
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CollectionEditorsStatic.js","sources":["../../../src/components/DataTable/CollectionEditorsStatic.tsx"],"sourcesContent":["import { Checkbox } from \"@components/checkbox\"\nimport { CheckboxGroup } from \"@components/checkbox-group\"\nimport { ComboBoxItem } from \"@components/combo-box\"\nimport { Radio } from \"@components/radio\"\nimport { RadioGroup } from \"@components/radio-group\"\nimport { Select } from \"@components/select\"\nimport React, { Key } from \"react\"\n\nimport {\n CollectionEditorCombobox,\n CollectionEditorProps,\n CollectionFilterEditorProps,\n CollectionFilterValue,\n orderByOptions,\n} from \"./CollectionEditorsShared\"\nimport { CollectionOption } from \"./collectionFilter\"\nimport { isEmptyValue } from \"./utils\"\n\nexport type CollectionEditorStaticProps = CollectionEditorProps & {\n filterLabel: string\n filterName: string\n onCommit: (value: CollectionFilterValue) => void\n options: CollectionOption[]\n}\n\nexport function CollectionFilterEditorStatic({\n config,\n onChange,\n operator,\n value,\n filter,\n}: CollectionFilterEditorProps) {\n const { display, multiple, options } = config\n\n const onCommit = (value: CollectionFilterValue) =>\n onChange({ value }, { complete: !isEmptyValue(value) })\n\n const Editor = getStaticEditor({ display, multiple })\n\n return (\n <Editor\n value={value}\n onCommit={onCommit}\n options={options}\n multiple={multiple}\n operator={operator}\n filterLabel={filter.label}\n filterName={filter.name}\n />\n )\n}\n\nfunction getStaticEditor({\n display,\n multiple,\n}: {\n display: string\n multiple: boolean\n}) {\n if (display === \"combobox\") return CollectionEditorComboboxStatic\n if (multiple) return CollectionEditorCheckboxes\n if (display === \"checkboxes\") return CollectionEditorRadios // TODO: This looks like it might be a mistake, should it be CollectionEditorCheckboxes? or at least allow for `radios` as an option?\n return CollectionEditorSelect\n}\n\nexport function CollectionEditorCheckboxes({\n filterLabel,\n onCommit,\n options,\n value,\n}: CollectionEditorStaticProps) {\n const selected = Array.isArray(value) ? value : [value]\n const toggle = (optionValue: string, checked: boolean) => {\n const next = new Set(selected)\n if (checked) next.add(optionValue)\n else next.delete(optionValue)\n onCommit(orderByOptions(options, next))\n }\n\n return (\n <CheckboxGroup label={filterLabel}>\n {options.map((option, index) => (\n <Checkbox\n key={option.value}\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={index === 0}\n checked={selected.includes(option.value)}\n label={option.label}\n onChange={(e) => toggle(option.value, e.target.checked)}\n />\n ))}\n </CheckboxGroup>\n )\n}\n\nexport function CollectionEditorRadios({\n filterLabel,\n filterName,\n onCommit,\n options,\n value,\n}: CollectionEditorStaticProps) {\n const selected = Array.isArray(value) ? value[0] : value\n const focusIndex = Math.max(\n 0,\n options.findIndex((option) => option.value === selected)\n )\n return (\n <RadioGroup label={filterLabel}>\n {options.map((option, index) => (\n <Radio\n key={option.value}\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={index === focusIndex}\n checked={selected === option.value}\n label={option.label}\n name={filterName}\n onChange={() => onCommit(option.value)}\n />\n ))}\n </RadioGroup>\n )\n}\n\nexport function CollectionEditorSelect({\n value,\n operator,\n options,\n onCommit,\n}: CollectionEditorStaticProps) {\n const selected = Array.isArray(value) ? value[0] : value\n\n return (\n <Select\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 options={options}\n value={selected}\n onChange={(e) => onCommit(e.target.value)}\n />\n )\n}\n\nfunction CollectionEditorComboboxStatic({\n onCommit,\n options,\n filterLabel,\n filterName,\n ...props\n}: CollectionEditorStaticProps) {\n return (\n <CollectionEditorCombobox\n {...props}\n onChange={(value: Key | Key[] | null) => {\n if (value === null) return\n\n const resolvedValue = Array.isArray(value)\n ? orderByOptions(options, new Set(value.map(String)))\n : String(value)\n\n onCommit(resolvedValue)\n }}\n >\n {options.map((option) => (\n <ComboBoxItem key={option.value} id={option.value}>\n {option.label}\n </ComboBoxItem>\n ))}\n </CollectionEditorCombobox>\n )\n}\n"],"names":["React"],"mappings":";;;;;;;;;;AAyBM,SAAU,4BAA4B,CAAC,EAC3C,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,MAAM,GACsB,EAAA;IAC5B,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM;IAE7C,MAAM,QAAQ,GAAG,CAAC,KAA4B,KAC5C,QAAQ,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;IAEzD,MAAM,MAAM,GAAG,eAAe,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAErD,IAAA,QACEA,cAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EACL,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,MAAM,CAAC,KAAK,EACzB,UAAU,EAAE,MAAM,CAAC,IAAI,EAAA,CACvB;AAEN;AAEA,SAAS,eAAe,CAAC,EACvB,OAAO,EACP,QAAQ,GAIT,EAAA;IACC,IAAI,OAAO,KAAK,UAAU;AAAE,QAAA,OAAO,8BAA8B;AACjE,IAAA,IAAI,QAAQ;AAAE,QAAA,OAAO,0BAA0B;IAC/C,IAAI,OAAO,KAAK,YAAY;QAAE,OAAO,sBAAsB,CAAA;AAC3D,IAAA,OAAO,sBAAsB;AAC/B;AAEM,SAAU,0BAA0B,CAAC,EACzC,WAAW,EACX,QAAQ,EACR,OAAO,EACP,KAAK,GACuB,EAAA;AAC5B,IAAA,MAAM,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,CAAC,OAAO,CAAC,KAAK;AACvC,kBAAE,cAAc,CAAC,OAAO,EAAE,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACpD,kBAAE,MAAM,CAAC,KAAK,CAAC;YAEjB,QAAQ,CAAC,aAAa,CAAC;AACzB,QAAA,CAAC,EAAA,EAEA,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,MAClBA,cAAA,CAAA,aAAA,CAAC,YAAY,EAAA,EAAC,GAAG,EAAE,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,EAAA,EAC9C,MAAM,CAAC,KAAK,CACA,CAChB,CAAC,CACuB;AAE/B;;;;"}
1
+ {"version":3,"file":"CollectionEditorsStatic.js","sources":["../../../src/components/DataTable/CollectionEditorsStatic.tsx"],"sourcesContent":["import { Checkbox } from \"@components/checkbox\"\nimport { CheckboxGroup } from \"@components/checkbox-group\"\nimport { ComboBoxItem } from \"@components/combo-box\"\nimport { Radio } from \"@components/radio\"\nimport { RadioGroup } from \"@components/radio-group\"\nimport { Select } from \"@components/select\"\nimport React, { Key } from \"react\"\n\nimport {\n CollectionEditorCombobox,\n CollectionEditorProps,\n CollectionFilterEditorProps,\n CollectionFilterValue,\n orderByOptions,\n} from \"./CollectionEditorsShared\"\nimport { CollectionOption } from \"./collectionFilter\"\nimport { isEmptyValue } from \"./utils\"\n\nexport type CollectionEditorStaticProps = CollectionEditorProps & {\n filterLabel: string\n filterName: string\n onCommit: (value: CollectionFilterValue) => void\n options: CollectionOption[]\n}\n\nexport function CollectionFilterEditorStatic({\n config,\n onChange,\n operator,\n value,\n filter,\n}: CollectionFilterEditorProps) {\n const { display, multiple } = config\n const options = config.options as CollectionOption[]\n\n const onCommit = (value: CollectionFilterValue) =>\n onChange({ label: undefined, value }, { complete: !isEmptyValue(value) })\n\n const Editor = getStaticEditor({ display, multiple })\n\n return (\n <Editor\n value={value}\n onCommit={onCommit}\n options={options}\n multiple={multiple}\n operator={operator}\n filterLabel={filter.label}\n filterName={filter.name}\n />\n )\n}\n\nfunction getStaticEditor({\n display,\n multiple,\n}: {\n display: string\n multiple: boolean\n}) {\n if (display === \"combobox\") return CollectionEditorComboboxStatic\n if (multiple) return CollectionEditorCheckboxes\n if (display === \"checkboxes\") return CollectionEditorRadios // TODO: This looks like it might be a mistake, should it be CollectionEditorCheckboxes? or at least allow for `radios` as an option?\n return CollectionEditorSelect\n}\n\nexport function CollectionEditorCheckboxes({\n filterLabel,\n onCommit,\n options,\n value,\n}: CollectionEditorStaticProps) {\n const selected = Array.isArray(value) ? value : [value]\n const toggle = (optionValue: string, checked: boolean) => {\n const next = new Set(selected)\n if (checked) next.add(optionValue)\n else next.delete(optionValue)\n onCommit(orderByOptions(options, next))\n }\n\n return (\n <CheckboxGroup label={filterLabel}>\n {options.map((option, index) => (\n <Checkbox\n key={option.value}\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={index === 0}\n checked={selected.includes(option.value)}\n label={option.label}\n onChange={(e) => toggle(option.value, e.target.checked)}\n />\n ))}\n </CheckboxGroup>\n )\n}\n\nexport function CollectionEditorRadios({\n filterLabel,\n filterName,\n onCommit,\n options,\n value,\n}: CollectionEditorStaticProps) {\n const selected = Array.isArray(value) ? value[0] : value\n const focusIndex = Math.max(\n 0,\n options.findIndex((option) => option.value === selected)\n )\n return (\n <RadioGroup label={filterLabel}>\n {options.map((option, index) => (\n <Radio\n key={option.value}\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={index === focusIndex}\n checked={selected === option.value}\n label={option.label}\n name={filterName}\n onChange={() => onCommit(option.value)}\n />\n ))}\n </RadioGroup>\n )\n}\n\nexport function CollectionEditorSelect({\n value,\n operator,\n options,\n onCommit,\n}: CollectionEditorStaticProps) {\n const selected = Array.isArray(value) ? value[0] : value\n\n return (\n <Select\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 options={options}\n value={selected}\n onChange={(e) => onCommit(e.target.value)}\n />\n )\n}\n\nfunction CollectionEditorComboboxStatic({\n onCommit,\n options,\n filterLabel,\n filterName,\n ...props\n}: CollectionEditorStaticProps) {\n return (\n <CollectionEditorCombobox\n {...props}\n onChange={(value: Key | Key[] | null) => {\n if (value === null) return\n\n const resolvedValue = Array.isArray(value)\n ? orderByOptions(options, new Set(value.map(String)))\n : String(value)\n\n onCommit(resolvedValue)\n }}\n >\n {options.map((option) => (\n <ComboBoxItem key={option.value} id={option.value}>\n {option.label}\n </ComboBoxItem>\n ))}\n </CollectionEditorCombobox>\n )\n}\n"],"names":["React"],"mappings":";;;;;;;;;;AAyBM,SAAU,4BAA4B,CAAC,EAC3C,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,MAAM,GACsB,EAAA;AAC5B,IAAA,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM;AACpC,IAAA,MAAM,OAAO,GAAG,MAAM,CAAC,OAA6B;IAEpD,MAAM,QAAQ,GAAG,CAAC,KAA4B,KAC5C,QAAQ,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;IAE3E,MAAM,MAAM,GAAG,eAAe,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAErD,IAAA,QACEA,cAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EACL,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,MAAM,CAAC,KAAK,EACzB,UAAU,EAAE,MAAM,CAAC,IAAI,EAAA,CACvB;AAE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AAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAA,CACzC;AAEN;AAEA,SAAS,8BAA8B,CAAC,EACtC,QAAQ,EACR,OAAO,EACP,WAAW,EACX,UAAU,EACV,GAAG,KAAK,EACoB,EAAA;IAC5B,QACEA,cAAA,CAAA,aAAA,CAAC,wBAAwB,EAAA,EAAA,GACnB,KAAK,EACT,QAAQ,EAAE,CAAC,KAAyB,KAAI;YACtC,IAAI,KAAK,KAAK,IAAI;gBAAE;AAEpB,YAAA,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK;AACvC,kBAAE,cAAc,CAAC,OAAO,EAAE,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACpD,kBAAE,MAAM,CAAC,KAAK,CAAC;YAEjB,QAAQ,CAAC,aAAa,CAAC;AACzB,QAAA,CAAC,EAAA,EAEA,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,MAClBA,cAAA,CAAA,aAAA,CAAC,YAAY,EAAA,EAAC,GAAG,EAAE,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,EAAA,EAC9C,MAAM,CAAC,KAAK,CACA,CAChB,CAAC,CACuB;AAE/B;;;;"}
@@ -75,7 +75,10 @@ export type UpdateActiveFilter = (updates: Partial<ActiveFilter>) => void;
75
75
  export type FilterChange = (updates: Partial<ActiveFilter>, state?: {
76
76
  complete?: boolean;
77
77
  }) => void;
78
+ export type ActiveFilterLabel = string | string[] | undefined;
78
79
  export interface ActiveFilter<T = unknown> {
80
+ /** The human-readable label for the applied filter, if available. */
81
+ label?: ActiveFilterLabel;
79
82
  /** The HTML name of the applied filter. Connects to the name of the filter. */
80
83
  name: string;
81
84
  /** The operator used by the applied filter. Corresponds to the name of the operator in the filter configuration. */
@@ -1 +1 @@
1
- {"version":3,"file":"FilterTypes.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/Filter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M,iBAAiB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IACtD;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAA;CAAE,GACvC;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,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 that delegates to one of several other filters, chosen by an active\n * filter's `scope` (see `scopedFilter`). The scoped filter supplies the\n * `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 filters a `scope` selects from, keyed by their own `name`. */\n options: 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 interface ActiveFilter<T = unknown> {\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 options is selected. The\n * `operator` and `value` then belong to that option's filter rather than to\n * the parent, so both are resolved against the scoped filter.\n */\n scope?: 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":"AAoDA;AACM,SAAU,cAAc,CAC5B,MAAsB,EAAA;IAEtB,OAAO,KAAK,CAAC,OAAO,CAAE,MAA2B,CAAC,OAAO,CAAC;AAC5D;;;;"}
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 that delegates to one of several other filters, chosen by an active\n * filter's `scope` (see `scopedFilter`). The scoped filter supplies the\n * `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 filters a `scope` selects from, keyed by their own `name`. */\n options: 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 options is selected. The\n * `operator` and `value` then belong to that option's filter rather than to\n * the parent, so both are resolved against the scoped filter.\n */\n scope?: 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":"AAoDA;AACM,SAAU,cAAc,CAC5B,MAAsB,EAAA;IAEtB,OAAO,KAAK,CAAC,OAAO,CAAE,MAA2B,CAAC,OAAO,CAAC;AAC5D;;;;"}
@@ -1,3 +1,4 @@
1
+ import type { CollectionOptions } from "./CollectionEditorsShared";
1
2
  import type { FilterItemConfig, FilterNodeItem } from "./FilterTypes";
2
3
  export type CollectionOption = {
3
4
  label: string;
@@ -33,7 +34,7 @@ declare const COLLECTION_OPERATORS: ({
33
34
  })[];
34
35
  export type CollectionOperatorName = (typeof COLLECTION_OPERATORS)[number]["name"];
35
36
  export type CollectionFilterConfig = FilterItemConfig<CollectionOperatorName> & {
36
- options: CollectionOption[];
37
+ options: CollectionOptions;
37
38
  } & ({
38
39
  display?: CollectionDisplay;
39
40
  multiple?: false;
@@ -1 +1 @@
1
- {"version":3,"file":"collectionFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/collectionFilter.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,gBAAgB,EAChB,cAAc,EAEf,MAAM,eAAe,CAAA;AAItB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEpE,eAAO,MAAM,aAAa;;;;;;CAIG,CAAA;AAC7B,eAAO,MAAM,cAA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,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/C,MAAM,MAAM,sBAAsB,GAChC,gBAAgB,CAAC,sBAAsB,CAAC,GAAG;IACzC,OAAO,EAAE,iBAAiB,CAAA;CAC3B,GAAG,CACE;IAAE,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,GACjD;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IAAC,QAAQ,EAAE,IAAI,CAAA;CAAE,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,CAczC"}
@@ -1,5 +1,6 @@
1
1
  import React__default from 'react';
2
2
  import { ActiveFilterInstance } from './ActiveFilterInstance.js';
3
+ import { CollectionFilterEditorLazy } from './CollectionEditorsLazy.js';
3
4
  import { CollectionFilterEditorStatic } from './CollectionEditorsStatic.js';
4
5
  import { resolveOperators } from './resolveOperators.js';
5
6
 
@@ -17,26 +18,36 @@ const COLLECTION_OPERATORS = [COLLECTION_IS, COLLECTION_NOT];
17
18
  function collectionFilter({ display = "select", excludes, includes, multiple = false, options, ...config }) {
18
19
  const filter = {
19
20
  ...config,
20
- createActiveFilterInstance: (activeFilter, operator) => new CollectionActiveFilter(filter, operator, activeFilter.value, { display, multiple, options }),
21
+ createActiveFilterInstance: (activeFilter, operator) => new CollectionActiveFilter(filter, operator, activeFilter.value, activeFilter.label, { display, multiple, options }),
21
22
  operators: resolveOperators(COLLECTION_OPERATORS, { excludes, includes }),
22
23
  };
23
24
  return filter;
24
25
  }
25
26
  class CollectionActiveFilter extends ActiveFilterInstance {
27
+ label;
26
28
  config;
27
- constructor(filter, operator, value, config) {
29
+ constructor(filter, operator, value, label, config) {
28
30
  super(filter, operator, value);
31
+ this.label = label;
29
32
  this.config = config;
33
+ this.label = label;
30
34
  }
31
35
  formatValue() {
36
+ if (this.label)
37
+ return Array.isArray(this.label) ? this.label : [this.label];
32
38
  const values = Array.isArray(this.value) ? this.value : [this.value];
39
+ if (typeof this.config.options === "function")
40
+ return [""];
33
41
  return values
34
- .map((value) => this.config.options.find((option) => option.value === value)?.label ??
35
- value)
42
+ .map((value) => this.config.options.find((option) => option.value === value)?.label ?? value)
36
43
  .join(", ");
37
44
  }
38
45
  renderEditor(onChange) {
39
- return (React__default.createElement(CollectionFilterEditorStatic, { config: this.config, onChange: onChange, operator: this.operator, value: this.value, filter: this.filter }));
46
+ const hasLazyOptions = typeof this.config.options === "function";
47
+ const Editor = hasLazyOptions
48
+ ? CollectionFilterEditorLazy
49
+ : CollectionFilterEditorStatic;
50
+ return (React__default.createElement(Editor, { config: this.config, onChange: onChange, operator: this.operator, value: this.value, label: this.label, filter: this.filter }));
40
51
  }
41
52
  }
42
53
 
@@ -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 type { CollectionFilterValue } from \"./CollectionEditorsShared\"\nimport { CollectionFilterEditorStatic } from \"./CollectionEditorsStatic\"\nimport type {\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: CollectionOption[]\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 { 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 config: {\n display: CollectionDisplay\n multiple: boolean\n options: CollectionOption[]\n }\n ) {\n super(filter, operator, value)\n }\n\n formatValue() {\n const values = Array.isArray(this.value) ? this.value : [this.value]\n return values\n .map(\n (value) =>\n this.config.options.find((option) => option.value === value)?.label ??\n value\n )\n .join(\", \")\n }\n\n renderEditor(onChange: FilterChange) {\n return (\n <CollectionFilterEditorStatic\n config={this.config}\n onChange={onChange}\n operator={this.operator}\n value={this.value}\n filter={this.filter}\n />\n )\n }\n}\n"],"names":["React"],"mappings":";;;;;AAqBO,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,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4B,EAAA,EAC3B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,MAAM,EAAE,IAAI,CAAC,MAAM,EAAA,CACnB;IAEN;AACD;;;;"}
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,E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,GAAG,MAAM,EACV,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,cAAc,CAYvD"}
1
+ {"version":3,"file":"numberFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/numberFilter.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,gBAAgB,EAChB,cAAc,EAEf,MAAM,eAAe,CAAA;AAGtB,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAEzD,eAAO,MAAM,GAAG;;;;;;CAIa,CAAA;AAC7B,eAAO,MAAM,GAAG;;;;;;CAIa,CAAA;AAC7B,eAAO,MAAM,YAAY;;;;;;CAII,CAAA;AAE7B,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;IAA2B,CAAA;AAEjD,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AAE1E,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,cAAc,CAYvD"}
@@ -1,9 +1,8 @@
1
1
  import { Flex } from '../flex/Flex.js';
2
2
  import { NumberStepper } from '../number-stepper/NumberStepper.js';
3
- import React__default, { useState } from 'react';
3
+ import React__default, { useRef } from 'react';
4
4
  import { ActiveFilterInstance } from './ActiveFilterInstance.js';
5
5
  import { resolveOperators } from './resolveOperators.js';
6
- import { isEmptyValue } from './utils.js';
7
6
 
8
7
  const GTE = {
9
8
  inputType: { type: "number" },
@@ -31,43 +30,62 @@ function numberFilter({ excludes, includes, ...config }) {
31
30
  }
32
31
  class NumberActiveFilter extends ActiveFilterInstance {
33
32
  formatValue() {
34
- if (this.value === undefined)
35
- return "";
36
- return Array.isArray(this.value)
37
- ? this.value.join(" and ")
38
- : String(this.value);
33
+ return [this.value]
34
+ .flat()
35
+ .filter((value) => value !== undefined)
36
+ .join(" and ");
39
37
  }
40
38
  renderEditor(onChange) {
41
- const { label } = this.operator;
42
- const onCommit = (value) => onChange({ value }, { complete: !isEmptyValue(value) });
43
- if (this.operator.inputType.type === "number-range") {
44
- const range = Array.isArray(this.value)
45
- ? this.value
46
- : [this.value, this.value];
47
- return (React__default.createElement(NumberRangeEditor, { label: label, value: range, onCommit: onCommit }));
48
- }
49
- const single = Array.isArray(this.value) ? this.value[0] : this.value;
50
- return React__default.createElement(NumberEditor, { label: label, value: single, onCommit: onCommit });
39
+ const { inputType, label, name } = this.operator;
40
+ const [start, end] = [this.value].flat();
41
+ const { initialValues, labels, toValue } = inputType.type === "number-range"
42
+ ? {
43
+ initialValues: [start, end],
44
+ labels: [`${label} from`, `${label} to`],
45
+ toValue: (committed) => committed,
46
+ }
47
+ : {
48
+ initialValues: [start],
49
+ labels: [label],
50
+ toValue: (committed) => committed[0],
51
+ };
52
+ return (React__default.createElement(NumberEditor, { key: name, labels: labels, values: initialValues, onCommit: (committed) => onChange({ value: toValue(committed) }, { complete: committed.every((value) => value !== undefined) }) }));
51
53
  }
52
54
  }
53
- function NumberEditor({ label, onCommit, value: initialValue, }) {
54
- const [value, setValue] = useState(initialValue);
55
- return (React__default.createElement(NumberStepper
56
- // eslint-disable-next-line jsx-a11y/no-autofocus -- the editor only ever renders inside a chip popover that just opened, per ARIA dialog practices
57
- , {
58
- // eslint-disable-next-line jsx-a11y/no-autofocus -- the editor only ever renders inside a chip popover that just opened, per ARIA dialog practices
59
- autoFocus: true, hideLabel: true, label: label, value: value, onChange: setValue, onBlur: () => onCommit(value) }));
60
- }
61
- function NumberRangeEditor({ label, onCommit, value: initialValue, }) {
62
- const [[start, end], setRange] = useState(initialValue);
63
- return (React__default.createElement(Flex, { gap: 1 },
55
+ // React Aria parses typed text in its own blur and Enter handlers, after ours,
56
+ // so parsed values go in a ref and commit from the wrapper's blur (which
57
+ // bubbles after parsing) or Enter's keyup.
58
+ function NumberEditor({ labels, onCommit, values: initialValues, }) {
59
+ const values = useRef(initialValues);
60
+ const lastCommitted = useRef(initialValues);
61
+ const shouldCommitOnKeyUp = useRef(false);
62
+ const commit = () => {
63
+ lastCommitted.current = values.current;
64
+ onCommit(values.current);
65
+ };
66
+ const changed = () => values.current.some((value, index) => value !== lastCommitted.current[index]);
67
+ return (React__default.createElement(Flex, { gap: 1, onBlur: () => {
68
+ if (changed())
69
+ commit();
70
+ } }, labels.map((label, index) => (React__default.createElement(React__default.Fragment, { key: label },
71
+ index > 0 && React__default.createElement("span", null, "and"),
64
72
  React__default.createElement(NumberStepper
65
73
  // eslint-disable-next-line jsx-a11y/no-autofocus -- the editor only ever renders inside a chip popover that just opened, per ARIA dialog practices
66
74
  , {
67
75
  // eslint-disable-next-line jsx-a11y/no-autofocus -- the editor only ever renders inside a chip popover that just opened, per ARIA dialog practices
68
- autoFocus: true, hideLabel: true, label: `${label} from`, value: start, onChange: (value) => setRange([value, end]), onBlur: () => onCommit([start, end]) }),
69
- React__default.createElement("span", null, "and"),
70
- React__default.createElement(NumberStepper, { hideLabel: true, label: `${label} to`, value: end, onChange: (value) => setRange([start, value]), onBlur: () => onCommit([start, end]) })));
76
+ autoFocus: index === 0, defaultValue: initialValues[index], hideLabel: true, label: label, onChange: (value) => {
77
+ const next = [...values.current];
78
+ next[index] = Number.isNaN(value) ? undefined : value;
79
+ values.current = next;
80
+ }, onKeyDown: (e) => {
81
+ shouldCommitOnKeyUp.current =
82
+ e.key === "Enter" && !e.nativeEvent.isComposing;
83
+ }, onKeyUp: (e) => {
84
+ if (e.key !== "Enter" || !shouldCommitOnKeyUp.current)
85
+ return;
86
+ shouldCommitOnKeyUp.current = false;
87
+ commit();
88
+ } }))))));
71
89
  }
72
90
 
73
91
  export { GTE, LTE, NUMBER_RANGE, numberFilter };