@navikt/ds-react 8.5.2 → 8.7.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/cjs/data/drag-and-drop/item/DataDragAndDropItem.d.ts +27 -0
- package/cjs/data/drag-and-drop/item/DataDragAndDropItem.js +91 -0
- package/cjs/data/drag-and-drop/item/DataDragAndDropItem.js.map +1 -0
- package/cjs/data/drag-and-drop/root/DataDragAndDrop.context.d.ts +5 -0
- package/cjs/data/drag-and-drop/root/DataDragAndDrop.context.js +6 -0
- package/cjs/data/drag-and-drop/root/DataDragAndDrop.context.js.map +1 -0
- package/cjs/data/drag-and-drop/root/DataDragAndDropRoot.d.ts +24 -0
- package/cjs/data/drag-and-drop/root/DataDragAndDropRoot.js +111 -0
- package/cjs/data/drag-and-drop/root/DataDragAndDropRoot.js.map +1 -0
- package/cjs/data/table/helpers/table-keyboard.d.ts +1 -0
- package/cjs/data/table/helpers/table-keyboard.js +5 -3
- package/cjs/data/table/helpers/table-keyboard.js.map +1 -1
- package/cjs/data/table/root/DataTableRoot.context.d.ts +8 -0
- package/cjs/data/table/root/DataTableRoot.context.js +11 -0
- package/cjs/data/table/root/DataTableRoot.context.js.map +1 -0
- package/cjs/data/table/root/DataTableRoot.js +5 -3
- package/cjs/data/table/root/DataTableRoot.js.map +1 -1
- package/cjs/data/table/th/DataTableTh.d.ts +18 -2
- package/cjs/data/table/th/DataTableTh.js +45 -20
- package/cjs/data/table/th/DataTableTh.js.map +1 -1
- package/cjs/data/table/tr/DataTableTr.js +9 -2
- package/cjs/data/table/tr/DataTableTr.js.map +1 -1
- package/cjs/data/token-filter/AutoSuggest.d.ts +6 -2
- package/cjs/data/token-filter/AutoSuggest.js +46 -14
- package/cjs/data/token-filter/AutoSuggest.js.map +1 -1
- package/cjs/data/token-filter/AutoSuggest.types.d.ts +0 -1
- package/cjs/data/token-filter/TokenFilter.d.ts +10 -5
- package/cjs/data/token-filter/TokenFilter.js +110 -48
- package/cjs/data/token-filter/TokenFilter.js.map +1 -1
- package/cjs/data/token-filter/TokenFilter.types.d.ts +51 -35
- package/cjs/data/token-filter/helpers/generate-autocomplete-options.d.ts +3 -6
- package/cjs/data/token-filter/helpers/generate-autocomplete-options.js +24 -37
- package/cjs/data/token-filter/helpers/generate-autocomplete-options.js.map +1 -1
- package/cjs/data/token-filter/helpers/operators.d.ts +6 -6
- package/cjs/data/token-filter/helpers/operators.js +3 -4
- package/cjs/data/token-filter/helpers/operators.js.map +1 -1
- package/cjs/data/token-filter/helpers/parse-query-text.d.ts +2 -20
- package/cjs/data/token-filter/helpers/parse-query-text.js +1 -1
- package/cjs/data/token-filter/helpers/parse-query-text.js.map +1 -1
- package/cjs/data/token-filter/helpers/query-builder.d.ts +2 -2
- package/cjs/data/token-filter/helpers/query-builder.js.map +1 -1
- package/cjs/date/Date.Dialog.d.ts +5 -1
- package/cjs/date/Date.Dialog.js +6 -2
- package/cjs/date/Date.Dialog.js.map +1 -1
- package/cjs/date/datepicker/DatePicker.js +3 -2
- package/cjs/date/datepicker/DatePicker.js.map +1 -1
- package/cjs/date/datepicker/hooks/useDatepicker.js +5 -2
- package/cjs/date/datepicker/hooks/useDatepicker.js.map +1 -1
- package/cjs/date/datepicker/hooks/useRangeDatepicker.js +3 -1
- package/cjs/date/datepicker/hooks/useRangeDatepicker.js.map +1 -1
- package/cjs/date/datepicker/parts/DatePicker.Months.d.ts +2 -1
- package/cjs/date/datepicker/parts/DatePicker.Months.js +3 -3
- package/cjs/date/datepicker/parts/DatePicker.Months.js.map +1 -1
- package/cjs/date/datepicker/parts/DatePicker.RDP.d.ts +5 -1
- package/cjs/date/datepicker/parts/DatePicker.RDP.js +2 -2
- package/cjs/date/datepicker/parts/DatePicker.RDP.js.map +1 -1
- package/cjs/date/monthpicker/MonthPicker.js +3 -2
- package/cjs/date/monthpicker/MonthPicker.js.map +1 -1
- package/cjs/date/monthpicker/hooks/useMonthPicker.js +3 -1
- package/cjs/date/monthpicker/hooks/useMonthPicker.js.map +1 -1
- package/cjs/date/monthpicker/parts/MonthPicker.Caption.d.ts +4 -1
- package/cjs/date/monthpicker/parts/MonthPicker.Caption.js +3 -2
- package/cjs/date/monthpicker/parts/MonthPicker.Caption.js.map +1 -1
- package/cjs/dropdown/Toggle.js +5 -12
- package/cjs/dropdown/Toggle.js.map +1 -1
- package/cjs/form/combobox/Input/Input.js +1 -1
- package/cjs/form/combobox/Input/Input.js.map +1 -1
- package/cjs/inline-message/root/InlineMessage.js +2 -2
- package/cjs/inline-message/root/InlineMessage.js.map +1 -1
- package/cjs/provider/Provider.d.ts +2 -2
- package/cjs/toggle-group/useToggleGroup.js +5 -3
- package/cjs/toggle-group/useToggleGroup.js.map +1 -1
- package/cjs/tooltip/Tooltip.js +1 -3
- package/cjs/tooltip/Tooltip.js.map +1 -1
- package/cjs/utils/components/HighlightText/HighlightText.d.ts +8 -0
- package/cjs/utils/components/HighlightText/HighlightText.js +27 -0
- package/cjs/utils/components/HighlightText/HighlightText.js.map +1 -0
- package/cjs/utils/components/Listbox/group/ListboxGroup.d.ts +7 -0
- package/cjs/utils/components/Listbox/group/ListboxGroup.js +15 -0
- package/cjs/utils/components/Listbox/group/ListboxGroup.js.map +1 -0
- package/cjs/utils/components/Listbox/input-slot/ListboxInputSlot.d.ts +7 -0
- package/cjs/utils/components/Listbox/input-slot/ListboxInputSlot.js +15 -0
- package/cjs/utils/components/Listbox/input-slot/ListboxInputSlot.js.map +1 -0
- package/cjs/utils/components/Listbox/item/ListboxItem.d.ts +24 -0
- package/cjs/utils/components/Listbox/item/ListboxItem.js +33 -0
- package/cjs/utils/components/Listbox/item/ListboxItem.js.map +1 -0
- package/cjs/utils/components/Listbox/list/ListboxList.d.ts +8 -0
- package/cjs/utils/components/Listbox/list/ListboxList.js +32 -0
- package/cjs/utils/components/Listbox/list/ListboxList.js.map +1 -0
- package/cjs/utils/components/Listbox/root/ListboxRoot.d.ts +20 -0
- package/cjs/utils/components/Listbox/root/ListboxRoot.js +84 -0
- package/cjs/utils/components/Listbox/root/ListboxRoot.js.map +1 -0
- package/cjs/utils/components/Listbox/root/domHelpers.d.ts +3 -0
- package/cjs/utils/components/Listbox/root/domHelpers.js +53 -0
- package/cjs/utils/components/Listbox/root/domHelpers.js.map +1 -0
- package/cjs/utils/components/focus-boundary/FocusBoundary.js +9 -64
- package/cjs/utils/components/focus-boundary/FocusBoundary.js.map +1 -1
- package/cjs/utils/helpers/focus.d.ts +14 -0
- package/cjs/utils/helpers/focus.js +63 -0
- package/cjs/utils/helpers/focus.js.map +1 -0
- package/cjs/utils/hooks/useDeferredValue.d.ts +1 -0
- package/cjs/utils/hooks/useDeferredValue.js +14 -0
- package/cjs/utils/hooks/useDeferredValue.js.map +1 -0
- package/esm/data/drag-and-drop/item/DataDragAndDropItem.d.ts +27 -0
- package/esm/data/drag-and-drop/item/DataDragAndDropItem.js +55 -0
- package/esm/data/drag-and-drop/item/DataDragAndDropItem.js.map +1 -0
- package/esm/data/drag-and-drop/root/DataDragAndDrop.context.d.ts +5 -0
- package/esm/data/drag-and-drop/root/DataDragAndDrop.context.js +3 -0
- package/esm/data/drag-and-drop/root/DataDragAndDrop.context.js.map +1 -0
- package/esm/data/drag-and-drop/root/DataDragAndDropRoot.d.ts +24 -0
- package/esm/data/drag-and-drop/root/DataDragAndDropRoot.js +71 -0
- package/esm/data/drag-and-drop/root/DataDragAndDropRoot.js.map +1 -0
- package/esm/data/table/helpers/table-keyboard.d.ts +1 -0
- package/esm/data/table/helpers/table-keyboard.js +5 -3
- package/esm/data/table/helpers/table-keyboard.js.map +1 -1
- package/esm/data/table/root/DataTableRoot.context.d.ts +8 -0
- package/esm/data/table/root/DataTableRoot.context.js +7 -0
- package/esm/data/table/root/DataTableRoot.context.js.map +1 -0
- package/esm/data/table/root/DataTableRoot.js +5 -3
- package/esm/data/table/root/DataTableRoot.js.map +1 -1
- package/esm/data/table/th/DataTableTh.d.ts +18 -2
- package/esm/data/table/th/DataTableTh.js +46 -21
- package/esm/data/table/th/DataTableTh.js.map +1 -1
- package/esm/data/table/tr/DataTableTr.js +9 -2
- package/esm/data/table/tr/DataTableTr.js.map +1 -1
- package/esm/data/token-filter/AutoSuggest.d.ts +6 -2
- package/esm/data/token-filter/AutoSuggest.js +45 -16
- package/esm/data/token-filter/AutoSuggest.js.map +1 -1
- package/esm/data/token-filter/AutoSuggest.types.d.ts +0 -1
- package/esm/data/token-filter/TokenFilter.d.ts +10 -5
- package/esm/data/token-filter/TokenFilter.js +110 -48
- package/esm/data/token-filter/TokenFilter.js.map +1 -1
- package/esm/data/token-filter/TokenFilter.types.d.ts +51 -35
- package/esm/data/token-filter/helpers/generate-autocomplete-options.d.ts +3 -6
- package/esm/data/token-filter/helpers/generate-autocomplete-options.js +24 -37
- package/esm/data/token-filter/helpers/generate-autocomplete-options.js.map +1 -1
- package/esm/data/token-filter/helpers/operators.d.ts +6 -6
- package/esm/data/token-filter/helpers/operators.js +3 -4
- package/esm/data/token-filter/helpers/operators.js.map +1 -1
- package/esm/data/token-filter/helpers/parse-query-text.d.ts +2 -20
- package/esm/data/token-filter/helpers/parse-query-text.js +1 -1
- package/esm/data/token-filter/helpers/parse-query-text.js.map +1 -1
- package/esm/data/token-filter/helpers/query-builder.d.ts +2 -2
- package/esm/data/token-filter/helpers/query-builder.js.map +1 -1
- package/esm/date/Date.Dialog.d.ts +5 -1
- package/esm/date/Date.Dialog.js +6 -2
- package/esm/date/Date.Dialog.js.map +1 -1
- package/esm/date/datepicker/DatePicker.js +3 -2
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/datepicker/hooks/useDatepicker.js +5 -2
- package/esm/date/datepicker/hooks/useDatepicker.js.map +1 -1
- package/esm/date/datepicker/hooks/useRangeDatepicker.js +3 -1
- package/esm/date/datepicker/hooks/useRangeDatepicker.js.map +1 -1
- package/esm/date/datepicker/parts/DatePicker.Months.d.ts +2 -1
- package/esm/date/datepicker/parts/DatePicker.Months.js +3 -3
- package/esm/date/datepicker/parts/DatePicker.Months.js.map +1 -1
- package/esm/date/datepicker/parts/DatePicker.RDP.d.ts +5 -1
- package/esm/date/datepicker/parts/DatePicker.RDP.js +2 -2
- package/esm/date/datepicker/parts/DatePicker.RDP.js.map +1 -1
- package/esm/date/monthpicker/MonthPicker.js +3 -2
- package/esm/date/monthpicker/MonthPicker.js.map +1 -1
- package/esm/date/monthpicker/hooks/useMonthPicker.js +3 -1
- package/esm/date/monthpicker/hooks/useMonthPicker.js.map +1 -1
- package/esm/date/monthpicker/parts/MonthPicker.Caption.d.ts +4 -1
- package/esm/date/monthpicker/parts/MonthPicker.Caption.js +3 -2
- package/esm/date/monthpicker/parts/MonthPicker.Caption.js.map +1 -1
- package/esm/dropdown/Toggle.js +5 -12
- package/esm/dropdown/Toggle.js.map +1 -1
- package/esm/form/combobox/Input/Input.js +1 -1
- package/esm/form/combobox/Input/Input.js.map +1 -1
- package/esm/inline-message/root/InlineMessage.js +3 -3
- package/esm/inline-message/root/InlineMessage.js.map +1 -1
- package/esm/provider/Provider.d.ts +2 -2
- package/esm/toggle-group/useToggleGroup.js +6 -4
- package/esm/toggle-group/useToggleGroup.js.map +1 -1
- package/esm/tooltip/Tooltip.js +1 -3
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/utils/components/HighlightText/HighlightText.d.ts +8 -0
- package/esm/utils/components/HighlightText/HighlightText.js +21 -0
- package/esm/utils/components/HighlightText/HighlightText.js.map +1 -0
- package/esm/utils/components/Listbox/group/ListboxGroup.d.ts +7 -0
- package/esm/utils/components/Listbox/group/ListboxGroup.js +10 -0
- package/esm/utils/components/Listbox/group/ListboxGroup.js.map +1 -0
- package/esm/utils/components/Listbox/input-slot/ListboxInputSlot.d.ts +7 -0
- package/esm/utils/components/Listbox/input-slot/ListboxInputSlot.js +9 -0
- package/esm/utils/components/Listbox/input-slot/ListboxInputSlot.js.map +1 -0
- package/esm/utils/components/Listbox/item/ListboxItem.d.ts +24 -0
- package/esm/utils/components/Listbox/item/ListboxItem.js +27 -0
- package/esm/utils/components/Listbox/item/ListboxItem.js.map +1 -0
- package/esm/utils/components/Listbox/list/ListboxList.d.ts +8 -0
- package/esm/utils/components/Listbox/list/ListboxList.js +27 -0
- package/esm/utils/components/Listbox/list/ListboxList.js.map +1 -0
- package/esm/utils/components/Listbox/root/ListboxRoot.d.ts +20 -0
- package/esm/utils/components/Listbox/root/ListboxRoot.js +79 -0
- package/esm/utils/components/Listbox/root/ListboxRoot.js.map +1 -0
- package/esm/utils/components/Listbox/root/domHelpers.d.ts +3 -0
- package/esm/utils/components/Listbox/root/domHelpers.js +50 -0
- package/esm/utils/components/Listbox/root/domHelpers.js.map +1 -0
- package/esm/utils/components/focus-boundary/FocusBoundary.js +8 -63
- package/esm/utils/components/focus-boundary/FocusBoundary.js.map +1 -1
- package/esm/utils/helpers/focus.d.ts +14 -0
- package/esm/utils/helpers/focus.js +60 -0
- package/esm/utils/helpers/focus.js.map +1 -0
- package/esm/utils/hooks/useDeferredValue.d.ts +1 -0
- package/esm/utils/hooks/useDeferredValue.js +7 -0
- package/esm/utils/hooks/useDeferredValue.js.map +1 -0
- package/package.json +7 -7
- package/src/data/drag-and-drop/item/DataDragAndDropItem.tsx +101 -0
- package/src/data/drag-and-drop/root/DataDragAndDrop.context.tsx +9 -0
- package/src/data/drag-and-drop/root/DataDragAndDropRoot.tsx +98 -0
- package/src/data/table/helpers/table-keyboard.ts +7 -3
- package/src/data/table/root/DataTableRoot.context.ts +13 -0
- package/src/data/table/root/DataTableRoot.tsx +16 -13
- package/src/data/table/th/DataTableTh.tsx +110 -54
- package/src/data/table/tr/DataTableTr.tsx +13 -2
- package/src/data/token-filter/AutoSuggest.tsx +142 -35
- package/src/data/token-filter/AutoSuggest.types.ts +0 -1
- package/src/data/token-filter/TokenFilter.tsx +179 -81
- package/src/data/token-filter/TokenFilter.types.ts +70 -44
- package/src/data/token-filter/helpers/generate-autocomplete-options.test.ts +97 -157
- package/src/data/token-filter/helpers/generate-autocomplete-options.ts +56 -53
- package/src/data/token-filter/helpers/operators.test.ts +29 -29
- package/src/data/token-filter/helpers/operators.ts +16 -16
- package/src/data/token-filter/helpers/parse-query-text.test.ts +37 -35
- package/src/data/token-filter/helpers/parse-query-text.ts +7 -26
- package/src/data/token-filter/helpers/query-builder.ts +2 -2
- package/src/date/Date.Dialog.tsx +15 -0
- package/src/date/datepicker/DatePicker.tsx +3 -0
- package/src/date/datepicker/hooks/useDatepicker.tsx +7 -2
- package/src/date/datepicker/hooks/useRangeDatepicker.tsx +5 -1
- package/src/date/datepicker/parts/DatePicker.Months.tsx +9 -1
- package/src/date/datepicker/parts/DatePicker.RDP.tsx +7 -1
- package/src/date/monthpicker/MonthPicker.tsx +3 -1
- package/src/date/monthpicker/hooks/useMonthPicker.tsx +5 -1
- package/src/date/monthpicker/parts/MonthPicker.Caption.tsx +20 -2
- package/src/dropdown/Toggle.tsx +6 -12
- package/src/form/combobox/Input/Input.tsx +2 -2
- package/src/inline-message/root/InlineMessage.tsx +5 -5
- package/src/provider/Provider.tsx +2 -2
- package/src/toggle-group/useToggleGroup.ts +6 -5
- package/src/tooltip/Tooltip.tsx +1 -3
- package/src/utils/components/HighlightText/HighlightText.tsx +34 -0
- package/src/utils/components/Listbox/group/ListboxGroup.tsx +26 -0
- package/src/utils/components/Listbox/input-slot/ListboxInputSlot.tsx +22 -0
- package/src/utils/components/Listbox/item/ListboxItem.tsx +57 -0
- package/src/utils/components/Listbox/list/ListboxList.tsx +38 -0
- package/src/utils/components/Listbox/root/ListboxRoot.tsx +104 -0
- package/src/utils/components/Listbox/root/domHelpers.ts +59 -0
- package/src/utils/components/focus-boundary/FocusBoundary.tsx +8 -78
- package/src/utils/helpers/focus.ts +75 -0
- package/src/utils/hooks/useDeferredValue.ts +12 -0
- package/cjs/data/table/th/DataTableThSortHandle.d.ts +0 -6
- package/cjs/data/table/th/DataTableThSortHandle.js +0 -82
- package/cjs/data/table/th/DataTableThSortHandle.js.map +0 -1
- package/esm/data/table/th/DataTableThSortHandle.d.ts +0 -6
- package/esm/data/table/th/DataTableThSortHandle.js +0 -47
- package/esm/data/table/th/DataTableThSortHandle.js.map +0 -1
- package/src/data/table/th/DataTableThSortHandle.tsx +0 -67
|
@@ -1,51 +1,53 @@
|
|
|
1
1
|
import { describe, expect, test } from "vitest";
|
|
2
2
|
import type { AutoCompleteOption } from "../AutoSuggest.types";
|
|
3
3
|
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
ExternalOption,
|
|
5
|
+
ExternalPropertyDefinition,
|
|
6
|
+
InternalParsedTextState,
|
|
7
|
+
InternalPropertyDefinition,
|
|
8
|
+
InternalPropertyOption,
|
|
8
9
|
} from "../TokenFilter.types";
|
|
9
10
|
import { generateAutoCompleteOptions } from "./generate-autocomplete-options";
|
|
10
|
-
import type { ParsedText } from "./parse-query-text";
|
|
11
11
|
|
|
12
|
-
const properties:
|
|
12
|
+
const properties: ExternalPropertyDefinition[] = [
|
|
13
13
|
{
|
|
14
|
-
|
|
14
|
+
groupLabel: "Status values",
|
|
15
15
|
group: "Metadata",
|
|
16
16
|
key: "status",
|
|
17
|
-
|
|
17
|
+
label: "Status",
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
|
-
|
|
20
|
+
groupLabel: "Region values",
|
|
21
21
|
group: "Location",
|
|
22
22
|
key: "region",
|
|
23
|
-
|
|
23
|
+
label: "Region",
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
|
-
|
|
26
|
+
groupLabel: "Type values",
|
|
27
27
|
group: "",
|
|
28
28
|
key: "type",
|
|
29
|
-
|
|
29
|
+
label: "Type",
|
|
30
30
|
},
|
|
31
31
|
];
|
|
32
32
|
|
|
33
|
-
const parsedProperties:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
const parsedProperties: InternalPropertyDefinition[] = properties.map(
|
|
34
|
+
(prop) => ({
|
|
35
|
+
key: prop.key,
|
|
36
|
+
label: prop.label,
|
|
37
|
+
groupLabel: prop.groupLabel ?? "",
|
|
38
|
+
group: prop.group ?? "",
|
|
39
|
+
externalProperty: prop,
|
|
40
|
+
operators: prop.operators ?? [],
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const statusOptions: ExternalOption[] = [
|
|
43
45
|
{ propertyKey: "status", value: "active", label: "Active" },
|
|
44
46
|
{ propertyKey: "status", value: "pending", label: "Pending" },
|
|
45
47
|
{ propertyKey: "status", value: "inactive", label: "Inactive" },
|
|
46
48
|
];
|
|
47
49
|
|
|
48
|
-
const regionOptions:
|
|
50
|
+
const regionOptions: ExternalOption[] = [
|
|
49
51
|
{
|
|
50
52
|
propertyKey: "region",
|
|
51
53
|
value: "us-east-1",
|
|
@@ -60,25 +62,22 @@ const regionOptions: QueryFilteringOption[] = [
|
|
|
60
62
|
},
|
|
61
63
|
];
|
|
62
64
|
|
|
63
|
-
const allOptions:
|
|
65
|
+
const allOptions: ExternalOption[] = [...statusOptions, ...regionOptions];
|
|
64
66
|
|
|
65
|
-
const parsedOptions:
|
|
66
|
-
const property = parsedProperties.find(
|
|
67
|
-
(p) => p.propertyKey === option.propertyKey,
|
|
68
|
-
);
|
|
67
|
+
const parsedOptions: InternalPropertyOption[] = allOptions.map((option) => {
|
|
68
|
+
const property = parsedProperties.find((p) => p.key === option.propertyKey);
|
|
69
69
|
return {
|
|
70
70
|
property: property || null,
|
|
71
71
|
value: option.value,
|
|
72
72
|
label: option.label || String(option.value),
|
|
73
73
|
tags: option.tags || [],
|
|
74
|
-
filteringTags: option.filteringTags || [],
|
|
75
74
|
};
|
|
76
75
|
});
|
|
77
76
|
|
|
78
77
|
describe("generateAutoCompleteOptions v2", () => {
|
|
79
78
|
describe("free-text step", () => {
|
|
80
79
|
test("empty value: should return all properties", () => {
|
|
81
|
-
const queryState:
|
|
80
|
+
const queryState: InternalParsedTextState = {
|
|
82
81
|
step: "free-text",
|
|
83
82
|
value: "",
|
|
84
83
|
};
|
|
@@ -103,7 +102,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
103
102
|
});
|
|
104
103
|
|
|
105
104
|
test("non-empty value: should return filtered properties and values", () => {
|
|
106
|
-
const queryState:
|
|
105
|
+
const queryState: InternalParsedTextState = {
|
|
107
106
|
step: "free-text",
|
|
108
107
|
value: "statu",
|
|
109
108
|
};
|
|
@@ -125,7 +124,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
125
124
|
});
|
|
126
125
|
|
|
127
126
|
test("non-empty value with operator '!:': should skip property suggestions", () => {
|
|
128
|
-
const queryState:
|
|
127
|
+
const queryState: InternalParsedTextState = {
|
|
129
128
|
step: "free-text",
|
|
130
129
|
value: "test",
|
|
131
130
|
operator: "!:",
|
|
@@ -145,7 +144,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
145
144
|
});
|
|
146
145
|
|
|
147
146
|
test("non-empty value: case-insensitive filtering", () => {
|
|
148
|
-
const queryState:
|
|
147
|
+
const queryState: InternalParsedTextState = {
|
|
149
148
|
step: "free-text",
|
|
150
149
|
value: "STATU",
|
|
151
150
|
};
|
|
@@ -167,7 +166,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
167
166
|
});
|
|
168
167
|
|
|
169
168
|
test("non-empty value: should match tags", () => {
|
|
170
|
-
const queryState:
|
|
169
|
+
const queryState: InternalParsedTextState = {
|
|
171
170
|
step: "free-text",
|
|
172
171
|
value: "europe",
|
|
173
172
|
};
|
|
@@ -184,12 +183,12 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
184
183
|
expect(valueGroup).toBeDefined();
|
|
185
184
|
expect(valueGroup?.options).toHaveLength(1);
|
|
186
185
|
expect((valueGroup?.options[0] as AutoCompleteOption).label).toBe(
|
|
187
|
-
"
|
|
186
|
+
"Region = eu-west-1",
|
|
188
187
|
);
|
|
189
188
|
});
|
|
190
189
|
|
|
191
190
|
test("non-empty value: whitespace-aware matching", () => {
|
|
192
|
-
const queryState:
|
|
191
|
+
const queryState: InternalParsedTextState = {
|
|
193
192
|
step: "free-text",
|
|
194
193
|
value: "us east",
|
|
195
194
|
};
|
|
@@ -206,7 +205,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
206
205
|
expect(valueGroup).toBeDefined();
|
|
207
206
|
expect(valueGroup?.options).toHaveLength(1);
|
|
208
207
|
expect((valueGroup?.options[0] as AutoCompleteOption).label).toBe(
|
|
209
|
-
"
|
|
208
|
+
"Region = us-east-1",
|
|
210
209
|
);
|
|
211
210
|
});
|
|
212
211
|
});
|
|
@@ -215,7 +214,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
215
214
|
const statusProperty = parsedProperties[0];
|
|
216
215
|
|
|
217
216
|
test("empty value: should return all values for selected property", () => {
|
|
218
|
-
const queryState:
|
|
217
|
+
const queryState: InternalParsedTextState = {
|
|
219
218
|
step: "property",
|
|
220
219
|
property: statusProperty,
|
|
221
220
|
operator: "=",
|
|
@@ -235,7 +234,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
235
234
|
});
|
|
236
235
|
|
|
237
236
|
test("non-empty value: should return filtered values", () => {
|
|
238
|
-
const queryState:
|
|
237
|
+
const queryState: InternalParsedTextState = {
|
|
239
238
|
step: "property",
|
|
240
239
|
property: statusProperty,
|
|
241
240
|
operator: "=",
|
|
@@ -252,12 +251,12 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
252
251
|
expect(result.options).toHaveLength(1);
|
|
253
252
|
expect(result.options[0].options).toHaveLength(2);
|
|
254
253
|
const labels = result.options[0].options.map((o) => o.label);
|
|
255
|
-
expect(labels).toContain("
|
|
256
|
-
expect(labels).toContain("
|
|
254
|
+
expect(labels).toContain("Status = active");
|
|
255
|
+
expect(labels).toContain("Status = inactive");
|
|
257
256
|
});
|
|
258
257
|
|
|
259
258
|
test("should use specified operator in value suggestions", () => {
|
|
260
|
-
const queryState:
|
|
259
|
+
const queryState: InternalParsedTextState = {
|
|
261
260
|
step: "property",
|
|
262
261
|
property: statusProperty,
|
|
263
262
|
operator: "!=",
|
|
@@ -280,7 +279,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
280
279
|
const statusProperty = parsedProperties[0];
|
|
281
280
|
|
|
282
281
|
test("empty prefix: should return all operators", () => {
|
|
283
|
-
const queryState:
|
|
282
|
+
const queryState: InternalParsedTextState = {
|
|
284
283
|
step: "operator",
|
|
285
284
|
property: statusProperty,
|
|
286
285
|
operatorPrefix: "",
|
|
@@ -298,7 +297,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
298
297
|
});
|
|
299
298
|
|
|
300
299
|
test("operator prefix '!': should filter operators starting with '!'", () => {
|
|
301
|
-
const queryState:
|
|
300
|
+
const queryState: InternalParsedTextState = {
|
|
302
301
|
step: "operator",
|
|
303
302
|
property: statusProperty,
|
|
304
303
|
operatorPrefix: "!",
|
|
@@ -320,7 +319,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
320
319
|
});
|
|
321
320
|
|
|
322
321
|
test("operator prefix '>=': should filter to single operator", () => {
|
|
323
|
-
const queryState:
|
|
322
|
+
const queryState: InternalParsedTextState = {
|
|
324
323
|
step: "operator",
|
|
325
324
|
property: statusProperty,
|
|
326
325
|
operatorPrefix: ">=",
|
|
@@ -340,7 +339,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
340
339
|
});
|
|
341
340
|
|
|
342
341
|
test("invalid prefix: should return empty suggestions", () => {
|
|
343
|
-
const queryState:
|
|
342
|
+
const queryState: InternalParsedTextState = {
|
|
344
343
|
step: "operator",
|
|
345
344
|
property: statusProperty,
|
|
346
345
|
operatorPrefix: "invalid",
|
|
@@ -359,7 +358,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
359
358
|
|
|
360
359
|
describe("operator filtering by description", () => {
|
|
361
360
|
test("should filter operators by description text", () => {
|
|
362
|
-
const queryState:
|
|
361
|
+
const queryState: InternalParsedTextState = {
|
|
363
362
|
step: "operator",
|
|
364
363
|
property: parsedProperties[0],
|
|
365
364
|
operatorPrefix: "",
|
|
@@ -380,7 +379,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
380
379
|
|
|
381
380
|
describe("empty groups filtering", () => {
|
|
382
381
|
test("should not return empty option groups", () => {
|
|
383
|
-
const queryState:
|
|
382
|
+
const queryState: InternalParsedTextState = {
|
|
384
383
|
step: "free-text",
|
|
385
384
|
value: "nonexistent",
|
|
386
385
|
};
|
|
@@ -399,7 +398,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
399
398
|
|
|
400
399
|
describe("value suggestions use correct operator", () => {
|
|
401
400
|
test("free-text step uses '=' operator for all values", () => {
|
|
402
|
-
const queryState:
|
|
401
|
+
const queryState: InternalParsedTextState = {
|
|
403
402
|
step: "free-text",
|
|
404
403
|
value: "active",
|
|
405
404
|
};
|
|
@@ -420,7 +419,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
420
419
|
});
|
|
421
420
|
|
|
422
421
|
test("property step uses selected operator", () => {
|
|
423
|
-
const queryState:
|
|
422
|
+
const queryState: InternalParsedTextState = {
|
|
424
423
|
step: "property",
|
|
425
424
|
property: parsedProperties[0],
|
|
426
425
|
operator: "!:",
|
|
@@ -441,20 +440,20 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
441
440
|
|
|
442
441
|
describe("custom operators configuration", () => {
|
|
443
442
|
test("property with string-format operators should filter to only those operators", () => {
|
|
444
|
-
const propertyWithCustomOps:
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
443
|
+
const propertyWithCustomOps: InternalPropertyDefinition = {
|
|
444
|
+
key: "custom",
|
|
445
|
+
label: "Custom",
|
|
446
|
+
groupLabel: "Custom values",
|
|
447
|
+
group: "Custom",
|
|
449
448
|
operators: ["=", "!="],
|
|
450
449
|
externalProperty: {
|
|
451
450
|
key: "custom",
|
|
452
|
-
|
|
451
|
+
label: "Custom",
|
|
453
452
|
operators: ["=", "!="],
|
|
454
453
|
},
|
|
455
454
|
};
|
|
456
455
|
|
|
457
|
-
const queryState:
|
|
456
|
+
const queryState: InternalParsedTextState = {
|
|
458
457
|
step: "operator",
|
|
459
458
|
property: propertyWithCustomOps,
|
|
460
459
|
operatorPrefix: "",
|
|
@@ -474,26 +473,26 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
474
473
|
});
|
|
475
474
|
|
|
476
475
|
test("property with object-format operators should extract operator strings", () => {
|
|
477
|
-
const propertyWithObjectOps:
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
476
|
+
const propertyWithObjectOps: InternalPropertyDefinition = {
|
|
477
|
+
key: "custom2",
|
|
478
|
+
label: "Custom2",
|
|
479
|
+
groupLabel: "Custom2 values",
|
|
480
|
+
group: "Custom",
|
|
482
481
|
operators: [
|
|
483
|
-
{ operator: ":",
|
|
484
|
-
{ operator: "!:",
|
|
482
|
+
{ operator: ":", type: "single" },
|
|
483
|
+
{ operator: "!:", type: "single" },
|
|
485
484
|
],
|
|
486
485
|
externalProperty: {
|
|
487
486
|
key: "custom2",
|
|
488
|
-
|
|
487
|
+
label: "Custom2",
|
|
489
488
|
operators: [
|
|
490
|
-
{ operator: ":",
|
|
491
|
-
{ operator: "!:",
|
|
489
|
+
{ operator: ":", type: "single" },
|
|
490
|
+
{ operator: "!:", type: "single" },
|
|
492
491
|
],
|
|
493
492
|
},
|
|
494
493
|
};
|
|
495
494
|
|
|
496
|
-
const queryState:
|
|
495
|
+
const queryState: InternalParsedTextState = {
|
|
497
496
|
step: "operator",
|
|
498
497
|
property: propertyWithObjectOps,
|
|
499
498
|
operatorPrefix: "",
|
|
@@ -513,28 +512,28 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
513
512
|
});
|
|
514
513
|
|
|
515
514
|
test("property with mixed operator formats should normalize and filter", () => {
|
|
516
|
-
const propertyWithMixedOps:
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
515
|
+
const propertyWithMixedOps: InternalPropertyDefinition = {
|
|
516
|
+
key: "mixed",
|
|
517
|
+
label: "Mixed",
|
|
518
|
+
groupLabel: "Mixed values",
|
|
519
|
+
group: "Custom",
|
|
521
520
|
operators: [
|
|
522
521
|
"=",
|
|
523
|
-
{ operator: "!=",
|
|
522
|
+
{ operator: "!=", type: "single" },
|
|
524
523
|
"invalid-operator",
|
|
525
524
|
],
|
|
526
525
|
externalProperty: {
|
|
527
526
|
key: "mixed",
|
|
528
|
-
|
|
527
|
+
label: "Mixed",
|
|
529
528
|
operators: [
|
|
530
529
|
"=",
|
|
531
|
-
{ operator: "!=",
|
|
530
|
+
{ operator: "!=", type: "single" },
|
|
532
531
|
"invalid-operator",
|
|
533
532
|
],
|
|
534
533
|
},
|
|
535
534
|
};
|
|
536
535
|
|
|
537
|
-
const queryState:
|
|
536
|
+
const queryState: InternalParsedTextState = {
|
|
538
537
|
step: "operator",
|
|
539
538
|
property: propertyWithMixedOps,
|
|
540
539
|
operatorPrefix: "",
|
|
@@ -556,7 +555,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
556
555
|
|
|
557
556
|
describe("edge case: operator without value", () => {
|
|
558
557
|
test("should return empty options when operator is present but value is empty", () => {
|
|
559
|
-
const queryState:
|
|
558
|
+
const queryState: InternalParsedTextState = {
|
|
560
559
|
step: "free-text",
|
|
561
560
|
value: "",
|
|
562
561
|
operator: "!=",
|
|
@@ -573,7 +572,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
573
572
|
});
|
|
574
573
|
|
|
575
574
|
test("should return empty options when operator-start input has no value", () => {
|
|
576
|
-
const queryState:
|
|
575
|
+
const queryState: InternalParsedTextState = {
|
|
577
576
|
step: "free-text",
|
|
578
577
|
value: "",
|
|
579
578
|
operator: ":",
|
|
@@ -594,7 +593,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
594
593
|
test("scoped to property should only show values from that property", () => {
|
|
595
594
|
const statusProperty = parsedProperties[0];
|
|
596
595
|
|
|
597
|
-
const queryState:
|
|
596
|
+
const queryState: InternalParsedTextState = {
|
|
598
597
|
step: "property",
|
|
599
598
|
property: statusProperty,
|
|
600
599
|
operator: "=",
|
|
@@ -616,7 +615,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
616
615
|
});
|
|
617
616
|
|
|
618
617
|
test("non-scoped (free-text) with empty value should show all properties", () => {
|
|
619
|
-
const queryState:
|
|
618
|
+
const queryState: InternalParsedTextState = {
|
|
620
619
|
step: "free-text",
|
|
621
620
|
value: "",
|
|
622
621
|
};
|
|
@@ -636,7 +635,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
636
635
|
test("scoped property search should not include property labels in search fields", () => {
|
|
637
636
|
const statusProperty = parsedProperties[0];
|
|
638
637
|
|
|
639
|
-
const queryState:
|
|
638
|
+
const queryState: InternalParsedTextState = {
|
|
640
639
|
step: "property",
|
|
641
640
|
property: statusProperty,
|
|
642
641
|
operator: "=",
|
|
@@ -653,7 +652,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
653
652
|
});
|
|
654
653
|
|
|
655
654
|
test("non-scoped search should include property labels in search", () => {
|
|
656
|
-
const queryState:
|
|
655
|
+
const queryState: InternalParsedTextState = {
|
|
657
656
|
step: "free-text",
|
|
658
657
|
value: "region",
|
|
659
658
|
};
|
|
@@ -671,88 +670,30 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
671
670
|
});
|
|
672
671
|
});
|
|
673
672
|
|
|
674
|
-
describe("filtering tags and metadata", () => {
|
|
675
|
-
test("should match filteringTags in search", () => {
|
|
676
|
-
const optionsWithFilteringTags: ParsedOption[] = [
|
|
677
|
-
{
|
|
678
|
-
property: parsedProperties[1],
|
|
679
|
-
value: "special-region",
|
|
680
|
-
label: "Special Region",
|
|
681
|
-
tags: [],
|
|
682
|
-
filteringTags: ["premium", "exclusive"],
|
|
683
|
-
},
|
|
684
|
-
];
|
|
685
|
-
|
|
686
|
-
const queryState: ParsedText = {
|
|
687
|
-
step: "free-text",
|
|
688
|
-
value: "premium",
|
|
689
|
-
};
|
|
690
|
-
|
|
691
|
-
const result = generateAutoCompleteOptions(
|
|
692
|
-
queryState,
|
|
693
|
-
parsedProperties,
|
|
694
|
-
optionsWithFilteringTags,
|
|
695
|
-
);
|
|
696
|
-
|
|
697
|
-
const regionGroup = result.options.find(
|
|
698
|
-
(g) => g.label === "Region values",
|
|
699
|
-
);
|
|
700
|
-
expect(regionGroup?.options).toHaveLength(1);
|
|
701
|
-
expect((regionGroup?.options[0] as AutoCompleteOption).label).toBe(
|
|
702
|
-
"Special Region",
|
|
703
|
-
);
|
|
704
|
-
});
|
|
705
|
-
|
|
706
|
-
test("should preserve tags and filteringTags in suggestions", () => {
|
|
707
|
-
const queryState: ParsedText = {
|
|
708
|
-
step: "free-text",
|
|
709
|
-
value: "region",
|
|
710
|
-
};
|
|
711
|
-
|
|
712
|
-
const result = generateAutoCompleteOptions(
|
|
713
|
-
queryState,
|
|
714
|
-
parsedProperties,
|
|
715
|
-
parsedOptions,
|
|
716
|
-
);
|
|
717
|
-
|
|
718
|
-
const regionGroup = result.options.find(
|
|
719
|
-
(g) => g.label === "Region values",
|
|
720
|
-
);
|
|
721
|
-
const usEastOption = regionGroup?.options.find(
|
|
722
|
-
(o) => (o as AutoCompleteOption).label === "US East",
|
|
723
|
-
) as AutoCompleteOption;
|
|
724
|
-
|
|
725
|
-
expect(usEastOption).toBeDefined();
|
|
726
|
-
expect(usEastOption.tags).toContain("north america");
|
|
727
|
-
expect(usEastOption.tags).toContain("usa");
|
|
728
|
-
});
|
|
729
|
-
});
|
|
730
|
-
|
|
731
673
|
describe("properties with no groupValuesLabel", () => {
|
|
732
674
|
test("should default to 'Values' when groupValuesLabel is empty", () => {
|
|
733
|
-
const propertyWithoutGroupLabel:
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
675
|
+
const propertyWithoutGroupLabel: InternalPropertyDefinition = {
|
|
676
|
+
key: "nogroup",
|
|
677
|
+
label: "NoGroup",
|
|
678
|
+
groupLabel: "",
|
|
679
|
+
group: "Custom",
|
|
738
680
|
operators: [],
|
|
739
681
|
externalProperty: {
|
|
740
682
|
key: "nogroup",
|
|
741
|
-
|
|
683
|
+
label: "NoGroup",
|
|
742
684
|
},
|
|
743
685
|
};
|
|
744
686
|
|
|
745
|
-
const optionsForProperty:
|
|
687
|
+
const optionsForProperty: InternalPropertyOption[] = [
|
|
746
688
|
{
|
|
747
689
|
property: propertyWithoutGroupLabel,
|
|
748
690
|
value: "val1",
|
|
749
691
|
label: "Value 1",
|
|
750
692
|
tags: [],
|
|
751
|
-
filteringTags: [],
|
|
752
693
|
},
|
|
753
694
|
];
|
|
754
695
|
|
|
755
|
-
const queryState:
|
|
696
|
+
const queryState: InternalParsedTextState = {
|
|
756
697
|
step: "property",
|
|
757
698
|
property: propertyWithoutGroupLabel,
|
|
758
699
|
operator: "=",
|
|
@@ -771,18 +712,17 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
771
712
|
|
|
772
713
|
describe("null or missing property references", () => {
|
|
773
714
|
test("should skip options with null property reference", () => {
|
|
774
|
-
const optionsWithNull:
|
|
715
|
+
const optionsWithNull: InternalPropertyOption[] = [
|
|
775
716
|
{
|
|
776
717
|
property: null,
|
|
777
718
|
value: "orphaned",
|
|
778
719
|
label: "Orphaned Value",
|
|
779
720
|
tags: [],
|
|
780
|
-
filteringTags: [],
|
|
781
721
|
},
|
|
782
722
|
...parsedOptions,
|
|
783
723
|
];
|
|
784
724
|
|
|
785
|
-
const queryState:
|
|
725
|
+
const queryState: InternalParsedTextState = {
|
|
786
726
|
step: "free-text",
|
|
787
727
|
value: "orphaned",
|
|
788
728
|
};
|
|
@@ -800,7 +740,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
800
740
|
});
|
|
801
741
|
|
|
802
742
|
test("should skip properties with no data", () => {
|
|
803
|
-
const queryState:
|
|
743
|
+
const queryState: InternalParsedTextState = {
|
|
804
744
|
step: "free-text",
|
|
805
745
|
value: "",
|
|
806
746
|
};
|
|
@@ -813,7 +753,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
813
753
|
|
|
814
754
|
describe("operator prefix filtering", () => {
|
|
815
755
|
test("prefix ':' should match ':' and '!:' operators", () => {
|
|
816
|
-
const queryState:
|
|
756
|
+
const queryState: InternalParsedTextState = {
|
|
817
757
|
step: "operator",
|
|
818
758
|
property: parsedProperties[0],
|
|
819
759
|
operatorPrefix: ":",
|
|
@@ -833,7 +773,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
833
773
|
});
|
|
834
774
|
|
|
835
775
|
test("prefix '>' should match '>', '>=', '!>' operators", () => {
|
|
836
|
-
const queryState:
|
|
776
|
+
const queryState: InternalParsedTextState = {
|
|
837
777
|
step: "operator",
|
|
838
778
|
property: parsedProperties[0],
|
|
839
779
|
operatorPrefix: ">",
|
|
@@ -856,7 +796,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
856
796
|
|
|
857
797
|
describe("buildQueryString integration", () => {
|
|
858
798
|
test("query string should contain property, operator, and value", () => {
|
|
859
|
-
const queryState:
|
|
799
|
+
const queryState: InternalParsedTextState = {
|
|
860
800
|
step: "property",
|
|
861
801
|
property: parsedProperties[0],
|
|
862
802
|
operator: "=",
|
|
@@ -878,7 +818,7 @@ describe("generateAutoCompleteOptions v2", () => {
|
|
|
878
818
|
});
|
|
879
819
|
|
|
880
820
|
test("operator-step value should only contain property and operator", () => {
|
|
881
|
-
const queryState:
|
|
821
|
+
const queryState: InternalParsedTextState = {
|
|
882
822
|
step: "operator",
|
|
883
823
|
property: parsedProperties[0],
|
|
884
824
|
operatorPrefix: "=",
|