@navikt/ds-react 8.5.1 → 8.6.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 (102) hide show
  1. package/cjs/data/table/root/DataTableRoot.d.ts +27 -0
  2. package/cjs/data/table/root/DataTableRoot.js +8 -2
  3. package/cjs/data/table/root/DataTableRoot.js.map +1 -1
  4. package/cjs/data/table/td/DataTableTd.d.ts +5 -4
  5. package/cjs/data/table/td/DataTableTd.js +2 -2
  6. package/cjs/data/table/td/DataTableTd.js.map +1 -1
  7. package/cjs/data/token-filter/AutoSuggest.d.ts +2 -14
  8. package/cjs/data/token-filter/AutoSuggest.js +13 -89
  9. package/cjs/data/token-filter/AutoSuggest.js.map +1 -1
  10. package/cjs/data/token-filter/AutoSuggest.types.d.ts +11 -0
  11. package/cjs/data/token-filter/AutoSuggest.types.js +3 -0
  12. package/cjs/data/token-filter/AutoSuggest.types.js.map +1 -0
  13. package/cjs/data/token-filter/TokenFilter.d.ts +5 -0
  14. package/cjs/data/token-filter/TokenFilter.js +20 -10
  15. package/cjs/data/token-filter/TokenFilter.js.map +1 -1
  16. package/cjs/data/token-filter/TokenFilter.types.d.ts +8 -4
  17. package/cjs/data/token-filter/helpers/generate-autocomplete-options.d.ts +13 -61
  18. package/cjs/data/token-filter/helpers/generate-autocomplete-options.js +152 -135
  19. package/cjs/data/token-filter/helpers/generate-autocomplete-options.js.map +1 -1
  20. package/cjs/data/token-filter/helpers/grouping.d.ts +28 -0
  21. package/cjs/data/token-filter/helpers/grouping.js +61 -0
  22. package/cjs/data/token-filter/helpers/grouping.js.map +1 -0
  23. package/cjs/data/token-filter/helpers/operators.d.ts +22 -0
  24. package/cjs/data/token-filter/helpers/operators.js +66 -0
  25. package/cjs/data/token-filter/helpers/operators.js.map +1 -0
  26. package/cjs/data/token-filter/helpers/parse-query-text.d.ts +1 -7
  27. package/cjs/data/token-filter/helpers/parse-query-text.js +5 -50
  28. package/cjs/data/token-filter/helpers/parse-query-text.js.map +1 -1
  29. package/cjs/data/token-filter/helpers/query-builder.d.ts +20 -0
  30. package/cjs/data/token-filter/helpers/query-builder.js +38 -0
  31. package/cjs/data/token-filter/helpers/query-builder.js.map +1 -0
  32. package/cjs/data/token-filter/helpers/text-matching.d.ts +16 -0
  33. package/cjs/data/token-filter/helpers/text-matching.js +47 -0
  34. package/cjs/data/token-filter/helpers/text-matching.js.map +1 -0
  35. package/cjs/form/combobox/Input/InputController.js +1 -1
  36. package/cjs/form/combobox/Input/InputController.js.map +1 -1
  37. package/cjs/form/file-upload/dropzone/FileUploadDropzone.js +1 -1
  38. package/cjs/form/file-upload/dropzone/FileUploadDropzone.js.map +1 -1
  39. package/cjs/toggle-group/useToggleGroup.js +5 -3
  40. package/cjs/toggle-group/useToggleGroup.js.map +1 -1
  41. package/esm/data/table/root/DataTableRoot.d.ts +27 -0
  42. package/esm/data/table/root/DataTableRoot.js +8 -2
  43. package/esm/data/table/root/DataTableRoot.js.map +1 -1
  44. package/esm/data/table/td/DataTableTd.d.ts +5 -4
  45. package/esm/data/table/td/DataTableTd.js +2 -2
  46. package/esm/data/table/td/DataTableTd.js.map +1 -1
  47. package/esm/data/token-filter/AutoSuggest.d.ts +2 -14
  48. package/esm/data/token-filter/AutoSuggest.js +14 -90
  49. package/esm/data/token-filter/AutoSuggest.js.map +1 -1
  50. package/esm/data/token-filter/AutoSuggest.types.d.ts +11 -0
  51. package/esm/data/token-filter/AutoSuggest.types.js +2 -0
  52. package/esm/data/token-filter/AutoSuggest.types.js.map +1 -0
  53. package/esm/data/token-filter/TokenFilter.d.ts +5 -0
  54. package/esm/data/token-filter/TokenFilter.js +20 -10
  55. package/esm/data/token-filter/TokenFilter.js.map +1 -1
  56. package/esm/data/token-filter/TokenFilter.types.d.ts +8 -4
  57. package/esm/data/token-filter/helpers/generate-autocomplete-options.d.ts +13 -61
  58. package/esm/data/token-filter/helpers/generate-autocomplete-options.js +152 -135
  59. package/esm/data/token-filter/helpers/generate-autocomplete-options.js.map +1 -1
  60. package/esm/data/token-filter/helpers/grouping.d.ts +28 -0
  61. package/esm/data/token-filter/helpers/grouping.js +59 -0
  62. package/esm/data/token-filter/helpers/grouping.js.map +1 -0
  63. package/esm/data/token-filter/helpers/operators.d.ts +22 -0
  64. package/esm/data/token-filter/helpers/operators.js +60 -0
  65. package/esm/data/token-filter/helpers/operators.js.map +1 -0
  66. package/esm/data/token-filter/helpers/parse-query-text.d.ts +1 -7
  67. package/esm/data/token-filter/helpers/parse-query-text.js +2 -45
  68. package/esm/data/token-filter/helpers/parse-query-text.js.map +1 -1
  69. package/esm/data/token-filter/helpers/query-builder.d.ts +20 -0
  70. package/esm/data/token-filter/helpers/query-builder.js +34 -0
  71. package/esm/data/token-filter/helpers/query-builder.js.map +1 -0
  72. package/esm/data/token-filter/helpers/text-matching.d.ts +16 -0
  73. package/esm/data/token-filter/helpers/text-matching.js +45 -0
  74. package/esm/data/token-filter/helpers/text-matching.js.map +1 -0
  75. package/esm/form/combobox/Input/InputController.js +1 -1
  76. package/esm/form/combobox/Input/InputController.js.map +1 -1
  77. package/esm/form/file-upload/dropzone/FileUploadDropzone.js +1 -1
  78. package/esm/form/file-upload/dropzone/FileUploadDropzone.js.map +1 -1
  79. package/esm/toggle-group/useToggleGroup.js +6 -4
  80. package/esm/toggle-group/useToggleGroup.js.map +1 -1
  81. package/package.json +3 -3
  82. package/src/data/table/root/DataTableRoot.tsx +30 -1
  83. package/src/data/table/td/DataTableTd.tsx +13 -6
  84. package/src/data/token-filter/AutoSuggest.tsx +33 -163
  85. package/src/data/token-filter/AutoSuggest.types.ts +13 -0
  86. package/src/data/token-filter/TokenFilter.tsx +21 -13
  87. package/src/data/token-filter/TokenFilter.types.ts +8 -4
  88. package/src/data/token-filter/helpers/generate-autocomplete-options.test.ts +836 -0
  89. package/src/data/token-filter/helpers/generate-autocomplete-options.ts +241 -186
  90. package/src/data/token-filter/helpers/grouping.test.ts +206 -0
  91. package/src/data/token-filter/helpers/grouping.ts +73 -0
  92. package/src/data/token-filter/helpers/operators.test.ts +281 -0
  93. package/src/data/token-filter/helpers/operators.ts +91 -0
  94. package/src/data/token-filter/helpers/parse-query-text.test.ts +4 -213
  95. package/src/data/token-filter/helpers/parse-query-text.ts +7 -69
  96. package/src/data/token-filter/helpers/query-builder.test.ts +126 -0
  97. package/src/data/token-filter/helpers/query-builder.ts +41 -0
  98. package/src/data/token-filter/helpers/text-matching.test.ts +125 -0
  99. package/src/data/token-filter/helpers/text-matching.ts +58 -0
  100. package/src/form/combobox/Input/InputController.tsx +0 -1
  101. package/src/form/file-upload/dropzone/FileUploadDropzone.tsx +0 -1
  102. package/src/toggle-group/useToggleGroup.ts +6 -5
@@ -1 +1 @@
1
- {"version":3,"file":"TokenFilter.js","sourceRoot":"","sources":["../../../src/data/token-filter/TokenFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAQzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAU5D,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CACnC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,EAAE,GAAG,EAAE,EAAE;IACnE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAC5C,IAAI,CACL,CAAC;IAEF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAC;IACzD,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,mBAAmB,CACjD,mBAAmB,EACnB,gBAAgB,CACjB,CAAC;IAEF,MAAM,UAAU,GAAG,cAAc,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AAG,EAAe,CAAC;IAE3C,KAAK,MAAM,QAAQ,IAAI,mBAAmB,EAAE,CAAC;QAC3C,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE;YAC5B,WAAW,EAAE,QAAQ,CAAC,GAAG;YACzB,aAAa,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,aAAa,mCAAI,EAAE;YAC5C,gBAAgB,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,gBAAgB,mCAAI,EAAE;YAClD,aAAa,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK;YAC9B,SAAS,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,SAAS,mCAAI,EAAE;YACpC,wDAAwD;YACxD,gBAAgB,EAAE,QAAQ;SAC3B,CAAC,CAAC;IACL,CAAC;IAED,MAAM,eAAe,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;;QAAC,OAAA,CAAC;YACxD,QAAQ,EAAE,MAAA,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,mCAAI,IAAI;YACrD,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,KAAK,EAAE,MAAA,MAAA,MAAM,CAAC,KAAK,mCAAI,MAAM,CAAC,KAAK,mCAAI,EAAE;YACzC,IAAI,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,EAAE;SACxB,CAAC,CAAA;KAAA,CAAC,CAAC;IAEJ,OAAO,EAAE,UAAU,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;AAC7E,CAAC"}
@@ -14,7 +14,6 @@ type QueryFilteringOption = {
14
14
  value: any;
15
15
  label?: string;
16
16
  tags?: string[];
17
- filteringTags?: string[];
18
17
  disabled?: boolean;
19
18
  };
20
19
  type QueryFilteringOptions = QueryFilteringOption[];
@@ -22,11 +21,16 @@ type QueryFilteringOptionGroup = {
22
21
  label: string;
23
22
  options: QueryFilteringOptions;
24
23
  };
24
+ type QueryFilteringScopedOperator = string | {
25
+ operator: string;
26
+ tokenType: "single" | "multiple";
27
+ };
25
28
  type QueryFilteringProperty = {
26
29
  key: string;
27
30
  propertyLabel: string;
28
- groupValuesLabel: string;
29
- group: string;
31
+ groupValuesLabel?: string;
32
+ group?: string;
33
+ operators?: QueryFilteringScopedOperator[];
30
34
  };
31
35
  type QueryFilteringProperties = QueryFilteringProperty[];
32
36
  type ParsedProperty = {
@@ -34,6 +38,7 @@ type ParsedProperty = {
34
38
  propertyLabel: string;
35
39
  groupValuesLabel: string;
36
40
  propertyGroup: string;
41
+ operators: QueryFilteringScopedOperator[];
37
42
  externalProperty: QueryFilteringProperty;
38
43
  };
39
44
  type ParsedOption = {
@@ -41,6 +46,5 @@ type ParsedOption = {
41
46
  value: any;
42
47
  label: string;
43
48
  tags: string[];
44
- filteringTags: string[];
45
49
  };
46
50
  export type { QueryFilterOperator, QueryFilterQuery, QueryFilteringOptions, QueryFilteringProperty, QueryFilterOperation, QueryFilteringProperties, ParsedProperty, ParsedOption, QueryFilteringOption, QueryFilteringOptionGroup, };
@@ -1,70 +1,22 @@
1
+ import type { AutoCompleteOption, OptionGroup } from "../AutoSuggest.types.js";
1
2
  import type { ParsedOption, ParsedProperty } from "../TokenFilter.types.js";
2
3
  import { type ParsedText } from "./parse-query-text.js";
3
- interface OptionGroup<T> {
4
- label: string;
5
- options: T[];
6
- }
7
- interface AutoCompleteOption {
8
- value: string;
9
- label: string;
10
- tags?: string[];
11
- filteringTags?: string[];
12
- description?: string;
13
- }
14
4
  /**
15
- * Grouping option for autocomplete suggestions structures:
16
- *
17
- * Step: "free-text" + empty value:
18
- * - Group: "Properties" with all properties.
19
- *
20
- * Step: "free-text" with non-empty value:
21
- * - Group: "Properties". All properties including the filter text in label or description or tags. String match.
22
- * - Group: "Values". All "property = value" combinations where either the property label or value label or description or tags include the filter text. String match.
23
- * - - Ignore all other operators than "=" for value suggestions.
24
- *
25
- * Step: "property" + empty value:
26
- * - Group: "Operators". All operators valid for the selected property.
27
- *
28
- * Step: "property" + non-empty value:
29
- * - Group: "Operators". All operators valid for the selected property with string match. Only relevant for multi letter operators like "!="
30
- *
31
- * Step: "operator" + empty value:
32
- * - Group: "<Property> values". All values valid for the selected property and operator. String match on value label, description and tags.
5
+ * Generates "options" to be used as autosuggest-ottion based on the current query state.
33
6
  *
34
- * Step: "operator" + non-empty value:
35
- * - Group: "<Property> values". All values valid for the selected property and operator with string match. String match on value label, description and tags.
7
+ * The query parser recognizes three states:
8
+ * - "property": User has selected/matched a property and operator ("Status = active")
9
+ * - "operator": User has matched a property but is typing the operator ("Status" or "Status !")
10
+ * - "free-text": User is typing freely without a property match (e.g., "act" or "!: test")
36
11
  *
37
- *
38
- * TODO:
39
- * - Handle custom groups
40
- * - Multi vs single-select: Allow operators for each options where user can define type to be enum: { operator: "=", tokenType: "enum" }. Enum-type options allow selecting multiple values, i.e state = ("active", "pending"))
41
- */
42
- /**
43
- * TODO: Update based on instructions above.
12
+ * @returns
13
+ * - value: The canonical query string representation for the current state.
14
+ * Used by the UI to determine cursor position and input replacement.
15
+ * - options: Grouped suggestions to display (properties, operators, or values).
44
16
  */
45
- declare function generateAutoCompleteOptions(queryState: ParsedText, filteringProperties?: ParsedProperty[], filteringOptions?: ParsedOption[]): {
46
- value: string;
47
- options: {
48
- label: string;
49
- options: {
50
- value: string;
51
- label: string;
52
- tags: string[];
53
- filteringTags: string[];
54
- }[];
55
- }[];
56
- } | {
57
- value: string;
58
- options: (OptionGroup<ParsedProperty> | {
59
- options: {
60
- value: string;
61
- label: string;
62
- description: string;
63
- }[];
64
- label: string;
65
- })[];
66
- } | {
17
+ type AutoCompleteResult = {
67
18
  value: string;
68
- options: (OptionGroup<ParsedProperty> | OptionGroup<AutoCompleteOption>)[];
19
+ options: OptionGroup<AutoCompleteOption>[];
69
20
  };
21
+ declare function generateAutoCompleteOptions(queryState: ParsedText, filteringProperties?: ParsedProperty[], filteringOptions?: ParsedOption[]): AutoCompleteResult;
70
22
  export { generateAutoCompleteOptions };
@@ -1,123 +1,170 @@
1
- import { QUERY_OPERATORS } from "./parse-query-text.js";
2
- function buildQueryString(propertyLabel, operator, value) {
3
- const parts = [propertyLabel, operator, value].filter(Boolean);
4
- return parts.join(" ");
5
- }
6
- /* TODO: i18n */
7
- const OPERATOR_LABELS = {
8
- ":": "contains",
9
- "!:": "does not contain",
10
- "=": "is",
11
- "!=": "is not",
12
- "^": "starts with",
13
- "!^": "does not start with",
14
- ">=": "is greater than or equal to",
15
- "<=": "is less than or equal to",
16
- ">": "is greater than",
17
- "<": "is less than",
18
- };
19
- /**
20
- * Grouping option for autocomplete suggestions structures:
21
- *
22
- * Step: "free-text" + empty value:
23
- * - Group: "Properties" with all properties.
24
- *
25
- * Step: "free-text" with non-empty value:
26
- * - Group: "Properties". All properties including the filter text in label or description or tags. String match.
27
- * - Group: "Values". All "property = value" combinations where either the property label or value label or description or tags include the filter text. String match.
28
- * - - Ignore all other operators than "=" for value suggestions.
29
- *
30
- * Step: "property" + empty value:
31
- * - Group: "Operators". All operators valid for the selected property.
32
- *
33
- * Step: "property" + non-empty value:
34
- * - Group: "Operators". All operators valid for the selected property with string match. Only relevant for multi letter operators like "!="
35
- *
36
- * Step: "operator" + empty value:
37
- * - Group: "<Property> values". All values valid for the selected property and operator. String match on value label, description and tags.
38
- *
39
- * Step: "operator" + non-empty value:
40
- * - Group: "<Property> values". All values valid for the selected property and operator with string match. String match on value label, description and tags.
41
- *
42
- *
43
- * TODO:
44
- * - Handle custom groups
45
- * - Multi vs single-select: Allow operators for each options where user can define type to be enum: { operator: "=", tokenType: "enum" }. Enum-type options allow selecting multiple values, i.e state = ("active", "pending"))
46
- */
47
- /**
48
- * TODO: Update based on instructions above.
49
- */
1
+ import { createGroups } from "./grouping.js";
2
+ import { QUERY_OPERATORS } from "./operators.js";
3
+ import { OPERATOR_LABELS, buildQueryString } from "./query-builder.js";
4
+ import { matchesFilterText } from "./text-matching.js";
50
5
  function generateAutoCompleteOptions(queryState, filteringProperties = [], filteringOptions = []) {
6
+ var _a;
7
+ /* State: Property and operator are matched, suggest values */
51
8
  if (queryState.step === "property") {
52
- if (!queryState.property) {
9
+ const filterText = queryState.value || "";
10
+ return {
11
+ value: queryState.value,
12
+ options: createValueSuggestions(filteringOptions, queryState.operator, filterText, queryState.property),
13
+ };
14
+ }
15
+ /* State: Property matched, but operator is incomplete */
16
+ if (queryState.step === "operator") {
17
+ const operators = filterOperatorsByPrefix(getValidOperatorsForProperty(queryState.property), queryState.operatorPrefix);
18
+ const partialQuery = buildQueryString(queryState.property.propertyLabel, queryState.operatorPrefix, "");
19
+ /**
20
+ * Edge case: User typed an invalid operator prefix that doesn't match any operators.
21
+ * This can happen when typing characters that don't start any valid operator.
22
+ * Return empty suggestions gracefully - the UI will show "no results".
23
+ */
24
+ if (operators.length === 0) {
53
25
  return {
54
- value: queryState.value,
26
+ value: partialQuery,
55
27
  options: [],
56
28
  };
57
29
  }
58
- const { propertyLabel, groupValuesLabel } = queryState.property;
59
- const options = filteringOptions.filter((o) => o.property === queryState.property);
60
30
  return {
61
- value: queryState.value,
62
- options: [
63
- {
64
- label: groupValuesLabel,
65
- options: options.map(({ label, value, tags, filteringTags }) => ({
66
- value: buildQueryString(propertyLabel, queryState.operator, value),
67
- label,
68
- tags,
69
- filteringTags,
70
- })),
71
- },
72
- ],
31
+ value: partialQuery,
32
+ options: generateOperatorSuggestions(queryState.property, queryState.operatorPrefix),
73
33
  };
74
34
  }
75
- if (queryState.step === "operator") {
35
+ /*
36
+ * Edge case: Input starts with operator but has no value yet (user typed just "!=")
37
+ * Wait for value before showing suggestions
38
+ */
39
+ if (!queryState.value && queryState.operator) {
76
40
  return {
77
- value: buildQueryString(queryState.property.propertyLabel, queryState.operatorPrefix, ""),
78
- options: [
79
- ...generatePropertySuggestions(filteringProperties),
80
- {
81
- options: QUERY_OPERATORS.map((value) => {
82
- var _a;
83
- return ({
84
- value: buildQueryString(queryState.property.propertyLabel, value, ""),
85
- label: buildQueryString(queryState.property.propertyLabel, value, ""),
86
- description: (_a = OPERATOR_LABELS[value]) !== null && _a !== void 0 ? _a : "",
87
- });
88
- }),
89
- /* TODO: i18n */
90
- label: "Operator",
91
- },
92
- ],
41
+ value: "",
42
+ options: [],
93
43
  };
94
44
  }
95
- const needsValueSuggestions = !!queryState.value;
96
- const needsPropertySuggestions = !(queryState.step === "free-text" && queryState.operator === "!:");
45
+ /* Empty input: Show all properties */
46
+ if (!queryState.value) {
47
+ return {
48
+ value: "",
49
+ options: generatePropertySuggestions(filteringProperties),
50
+ };
51
+ }
52
+ /*
53
+ * Free-text search: Show matching values across all properties
54
+ * Use the detected operator if input started with one (e.g., "!= test"), otherwise default to "="
55
+ */
97
56
  return {
98
57
  value: queryState.value,
99
58
  options: [
100
- ...(needsPropertySuggestions
101
- ? generatePropertySuggestions(filteringProperties)
102
- : []),
103
- ...(needsValueSuggestions
104
- ? generateAllValueSuggestions(filteringOptions)
105
- : []),
59
+ ...generatePropertySuggestions(filteringProperties, queryState.value),
60
+ ...createValueSuggestions(filteringOptions, (_a = queryState.operator) !== null && _a !== void 0 ? _a : "=", queryState.value),
106
61
  ],
107
62
  };
108
63
  }
109
- function createAutoCompleteOption(propertyLabel, operator, value, label, tags, filteringTags) {
110
- return {
111
- value: buildQueryString(propertyLabel, operator, value),
112
- label: buildQueryString(propertyLabel, operator, label),
113
- tags,
114
- filteringTags,
115
- };
64
+ /**
65
+ * Returns the valid operators for a given property.
66
+ * Extracts operators from the property's custom operator configuration.
67
+ * If none are configured, falls back to all available operators.
68
+ *
69
+ * The QueryFilteringScopedOperator can be a simple string (e.g., "=")
70
+ * or an object with operator and tokenType (e.g., { operator: ":", tokenType: "single" }).
71
+ * This function normalizes both formats and returns just the operator strings.
72
+ *
73
+ * @returns Array of valid operators for the property
74
+ *
75
+ * TODO: We omit passing the tokenType for now since it's not currently used in the UI. But will be needed for single/multi-selection.
76
+ */
77
+ function getValidOperatorsForProperty(property) {
78
+ const { operators } = property;
79
+ /* If no operators configured, return all available operators */
80
+ if (!operators || operators.length === 0) {
81
+ return QUERY_OPERATORS;
82
+ }
83
+ /*
84
+ * Extract operator strings from QueryFilteringScopedOperator format
85
+ * Handle both simple strings and objects with operator property
86
+ */
87
+ const operatorStrings = operators.map((op) => typeof op === "string" ? op : op.operator);
88
+ /* Filter to only valid QUERY_OPERATORS to ensure type safety */
89
+ return operatorStrings.filter((op) => QUERY_OPERATORS.includes(op));
90
+ }
91
+ /**
92
+ * Filters the list of operators based on the provided prefix.
93
+ * If the prefix is empty, all operators are returned.
94
+ */
95
+ function filterOperatorsByPrefix(operators, prefix) {
96
+ if (!prefix) {
97
+ return operators;
98
+ }
99
+ return operators.filter((operator) => operator.startsWith(prefix));
116
100
  }
117
- function generateAllValueSuggestions(filteringOptions = []) {
101
+ function generatePropertySuggestions(filteringProperties = [], filterText = "") {
102
+ const filteredProperties = [];
103
+ for (const property of filteringProperties) {
104
+ if (!property) {
105
+ continue;
106
+ }
107
+ if (matchesFilterText([
108
+ property.propertyLabel,
109
+ property.groupValuesLabel,
110
+ property.propertyGroup,
111
+ ].filter(Boolean), filterText)) {
112
+ filteredProperties.push(property);
113
+ }
114
+ }
115
+ const groups = createGroups(filteredProperties, (property) => property.propertyGroup, "Properties");
116
+ return groups.map((group) => ({
117
+ label: group.label,
118
+ options: group.options.map((property) => ({
119
+ value: buildQueryString(property.propertyLabel, "", ""),
120
+ label: property.propertyLabel,
121
+ })),
122
+ }));
123
+ }
124
+ function generateOperatorSuggestions(property, operatorPrefix = "") {
125
+ const operators = filterOperatorsByPrefix(getValidOperatorsForProperty(property), operatorPrefix);
126
+ if (operators.length === 0) {
127
+ return [];
128
+ }
129
+ return [
130
+ {
131
+ label: "Operators",
132
+ options: operators.map((operator) => {
133
+ var _a;
134
+ return ({
135
+ value: buildQueryString(property.propertyLabel, operator, ""),
136
+ label: buildQueryString(property.propertyLabel, operator, ""),
137
+ description: (_a = OPERATOR_LABELS[operator]) !== null && _a !== void 0 ? _a : "",
138
+ });
139
+ }),
140
+ },
141
+ ];
142
+ }
143
+ /**
144
+ * Creates value suggestions for autocomplete.
145
+ * When scopedProperty is provided, only shows values for that property (single group).
146
+ * When scopedProperty is omitted, searches across all properties (multiple groups).
147
+ * TODO: This could potentially contain an unlimited number of options if there are many values across properties.
148
+ * May need virtualization/async or other filtering mechanism.
149
+ */
150
+ function createValueSuggestions(filteringOptions = [], operator, filterText = "", scopedProperty) {
151
+ var _a;
118
152
  const groups = {};
119
153
  for (const option of filteringOptions) {
120
- if (!option || !option.property) {
154
+ if (!(option === null || option === void 0 ? void 0 : option.property)) {
155
+ continue;
156
+ }
157
+ /* If scoped to a property, filter to only that property's options */
158
+ if (scopedProperty && option.property !== scopedProperty) {
159
+ continue;
160
+ }
161
+ /* Build search fields */
162
+ const searchFields = [option.label, ...((_a = option.tags) !== null && _a !== void 0 ? _a : [])];
163
+ if (!scopedProperty) {
164
+ searchFields.push(option.property.propertyLabel);
165
+ }
166
+ const matches = matchesFilterText(searchFields.filter(Boolean), filterText);
167
+ if (!matches) {
121
168
  continue;
122
169
  }
123
170
  const groupLabel = option.property.groupValuesLabel || "Values";
@@ -127,43 +174,13 @@ function generateAllValueSuggestions(filteringOptions = []) {
127
174
  options: [],
128
175
  };
129
176
  }
130
- const { label, value, tags, filteringTags, property } = option;
131
- const options = QUERY_OPERATORS.map((operator) => createAutoCompleteOption(property.propertyLabel, operator, value, label, tags, filteringTags));
132
- groups[groupLabel].options.push(...options);
133
- }
134
- return Object.values(groups);
135
- }
136
- function generatePropertySuggestions(filteringProperties = []) {
137
- var _a;
138
- const defaultGroup = {
139
- label: "Properties",
140
- options: [],
141
- };
142
- const customGroups = {};
143
- for (const property of filteringProperties) {
144
- if (!property) {
145
- continue;
146
- }
147
- const groupLabel = (_a = property.propertyGroup) === null || _a === void 0 ? void 0 : _a.trim();
148
- if (groupLabel) {
149
- if (!customGroups[groupLabel]) {
150
- customGroups[groupLabel] = {
151
- label: groupLabel,
152
- options: [],
153
- };
154
- }
155
- customGroups[groupLabel].options.push(property);
156
- continue;
157
- }
158
- defaultGroup.options.push(property);
159
- }
160
- const groups = [
161
- ...Object.values(customGroups),
162
- ];
163
- if (defaultGroup.options.length > 0) {
164
- groups.push(defaultGroup);
177
+ groups[groupLabel].options.push({
178
+ value: buildQueryString(option.property.propertyLabel, operator, option.value),
179
+ label: option.label,
180
+ tags: option.tags,
181
+ });
165
182
  }
166
- return groups;
183
+ return Object.values(groups).filter((group) => group.options.length > 0);
167
184
  }
168
185
  export { generateAutoCompleteOptions };
169
186
  //# sourceMappingURL=generate-autocomplete-options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-autocomplete-options.js","sourceRoot":"","sources":["../../../../src/data/token-filter/helpers/generate-autocomplete-options.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAetE,SAAS,gBAAgB,CACvB,aAAqB,EACrB,QAAgB,EAChB,KAAa;IAEb,MAAM,KAAK,GAAG,CAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/D,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,gBAAgB;AAChB,MAAM,eAAe,GAA2B;IAC9C,GAAG,EAAE,UAAU;IACf,IAAI,EAAE,kBAAkB;IACxB,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,QAAQ;IACd,GAAG,EAAE,aAAa;IAClB,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE,6BAA6B;IACnC,IAAI,EAAE,0BAA0B;IAChC,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,cAAc;CACpB,CAAC;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;GAEG;AACH,SAAS,2BAA2B,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;oBACzB,KAAK,EAAE,UAAU;oBACjB,OAAO,EAAE,EAAE;iBACZ,CAAC;YACJ,CAAC;YACD,YAAY,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAChD,SAAS;QACX,CAAC;QAED,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,MAAM,GAAkC;QAC5C,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;KAC/B,CAAC;IAEF,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
1
+ {"version":3,"file":"generate-autocomplete-options.js","sourceRoot":"","sources":["../../../../src/data/token-filter/helpers/generate-autocomplete-options.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAoBpD,SAAS,2BAA2B,CAClC,UAAsB,EACtB,sBAAwC,EAAE,EAC1C,mBAAmC,EAAE;;IAErC,8DAA8D;IAC9D,IAAI,UAAU,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC;QAE1C,OAAO;YACL,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,OAAO,EAAE,sBAAsB,CAC7B,gBAAgB,EAChB,UAAU,CAAC,QAAQ,EACnB,UAAU,EACV,UAAU,CAAC,QAAQ,CACpB;SACF,CAAC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;YACnB,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { OptionGroup } from "../AutoSuggest.types.js";
2
+ /**
3
+ * Groups items into labeled groups with support for a default group.
4
+ * Empty or whitespace-only group labels are treated as belonging to the default group.
5
+ *
6
+ * @returns Array of groups with non-empty options
7
+ *
8
+ * @example
9
+ * const properties = [
10
+ * { name: "Status", group: "Metadata" },
11
+ * { name: "Region", group: "Location" },
12
+ * { name: "Type", group: "" },
13
+ * ];
14
+ * const groups = createGroups(
15
+ * properties,
16
+ * (p) => p.group,
17
+ * "Properties"
18
+ * );
19
+ *
20
+ * Returns:
21
+ * [
22
+ * { label: "Metadata", options: [{ name: "Status", group: "Metadata" }] },
23
+ * { label: "Location", options: [{ name: "Region", group: "Location" }] },
24
+ * { label: "Properties", options: [{ name: "Type", group: "" }] }
25
+ * ]
26
+ */
27
+ declare function createGroups<T>(items: T[], getGroupLabel: (item: T) => string | undefined | null, defaultGroupLabel?: string): OptionGroup<T>[];
28
+ export { createGroups };
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Groups items into labeled groups with support for a default group.
3
+ * Empty or whitespace-only group labels are treated as belonging to the default group.
4
+ *
5
+ * @returns Array of groups with non-empty options
6
+ *
7
+ * @example
8
+ * const properties = [
9
+ * { name: "Status", group: "Metadata" },
10
+ * { name: "Region", group: "Location" },
11
+ * { name: "Type", group: "" },
12
+ * ];
13
+ * const groups = createGroups(
14
+ * properties,
15
+ * (p) => p.group,
16
+ * "Properties"
17
+ * );
18
+ *
19
+ * Returns:
20
+ * [
21
+ * { label: "Metadata", options: [{ name: "Status", group: "Metadata" }] },
22
+ * { label: "Location", options: [{ name: "Region", group: "Location" }] },
23
+ * { label: "Properties", options: [{ name: "Type", group: "" }] }
24
+ * ]
25
+ */
26
+ function createGroups(items, getGroupLabel, defaultGroupLabel = "Default") {
27
+ const defaultGroup = {
28
+ label: defaultGroupLabel,
29
+ options: [],
30
+ };
31
+ const customGroups = {};
32
+ for (const item of items) {
33
+ if (!item) {
34
+ continue;
35
+ }
36
+ const rawLabel = getGroupLabel(item);
37
+ const groupLabel = rawLabel === null || rawLabel === void 0 ? void 0 : rawLabel.trim();
38
+ /* Empty string after trim or falsy values go to default group */
39
+ if (!groupLabel) {
40
+ defaultGroup.options.push(item);
41
+ continue;
42
+ }
43
+ if (!customGroups[groupLabel]) {
44
+ customGroups[groupLabel] = {
45
+ label: groupLabel,
46
+ options: [],
47
+ };
48
+ }
49
+ customGroups[groupLabel].options.push(item);
50
+ }
51
+ /* Custom groups first, then default group if it has items */
52
+ const groups = [...Object.values(customGroups)];
53
+ if (defaultGroup.options.length > 0) {
54
+ groups.push(defaultGroup);
55
+ }
56
+ return groups;
57
+ }
58
+ export { createGroups };
59
+ //# sourceMappingURL=grouping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grouping.js","sourceRoot":"","sources":["../../../../src/data/token-filter/helpers/grouping.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAS,YAAY,CACnB,KAAU,EACV,aAAqD,EACrD,iBAAiB,GAAG,SAAS;IAE7B,MAAM,YAAY,GAAmB;QACnC,KAAK,EAAE,iBAAiB;QACxB,OAAO,EAAE,EAAE;KACZ,CAAC;IACF,MAAM,YAAY,GAAmC,EAAE,CAAC;IAExD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,SAAS;QACX,CAAC;QAED,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QACrC,MAAM,UAAU,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,EAAE,CAAC;QAEpC,iEAAiE;QACjE,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAChC,SAAS;QACX,CAAC;QAED,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9B,YAAY,CAAC,UAAU,CAAC,GAAG;gBACzB,KAAK,EAAE,UAAU;gBACjB,OAAO,EAAE,EAAE;aACZ,CAAC;QACJ,CAAC;QAED,YAAY,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED,6DAA6D;IAC7D,MAAM,MAAM,GAAqB,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAElE,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { ParsedProperty, QueryFilterOperator } from "../TokenFilter.types.js";
2
+ declare const QUERY_OPERATORS: QueryFilterOperator[];
3
+ /**
4
+ * Match an operator from the input text.
5
+ * Operators are already sorted by specificity, so no re-sorting needed.
6
+ */
7
+ declare function matchOperator(allowedOperators: QueryFilterOperator[], text: string): QueryFilterOperator | undefined;
8
+ /**
9
+ * Match a property from the input text by longest property label.
10
+ *
11
+ * properties: [{ propertyLabel: "Instance" }, { propertyLabel: "Instance ID" }]
12
+ * text = "Instance ID:"
13
+ *
14
+ * Result: { propertyLabel: "Instance ID" }
15
+ */
16
+ declare function matchFilteringProperty(filteringProperties: ParsedProperty[], text: string): ParsedProperty | undefined;
17
+ /**
18
+ * Check if the input text is a valid prefix of any allowed operator.
19
+ * Returns the prefix if valid, null otherwise.
20
+ */
21
+ declare function matchOperatorPrefix(allowedOperators: QueryFilterOperator[], filteringText: string): string | null;
22
+ export { QUERY_OPERATORS, matchOperator, matchFilteringProperty, matchOperatorPrefix, };