@navikt/ds-react 8.5.1 → 8.5.2

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 (95) 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 +16 -89
  9. package/cjs/data/token-filter/AutoSuggest.js.map +1 -1
  10. package/cjs/data/token-filter/AutoSuggest.types.d.ts +12 -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.js +18 -7
  14. package/cjs/data/token-filter/TokenFilter.js.map +1 -1
  15. package/cjs/data/token-filter/TokenFilter.types.d.ts +8 -2
  16. package/cjs/data/token-filter/helpers/generate-autocomplete-options.d.ts +12 -58
  17. package/cjs/data/token-filter/helpers/generate-autocomplete-options.js +159 -133
  18. package/cjs/data/token-filter/helpers/generate-autocomplete-options.js.map +1 -1
  19. package/cjs/data/token-filter/helpers/grouping.d.ts +28 -0
  20. package/cjs/data/token-filter/helpers/grouping.js +61 -0
  21. package/cjs/data/token-filter/helpers/grouping.js.map +1 -0
  22. package/cjs/data/token-filter/helpers/operators.d.ts +22 -0
  23. package/cjs/data/token-filter/helpers/operators.js +66 -0
  24. package/cjs/data/token-filter/helpers/operators.js.map +1 -0
  25. package/cjs/data/token-filter/helpers/parse-query-text.d.ts +1 -7
  26. package/cjs/data/token-filter/helpers/parse-query-text.js +5 -50
  27. package/cjs/data/token-filter/helpers/parse-query-text.js.map +1 -1
  28. package/cjs/data/token-filter/helpers/query-builder.d.ts +20 -0
  29. package/cjs/data/token-filter/helpers/query-builder.js +38 -0
  30. package/cjs/data/token-filter/helpers/query-builder.js.map +1 -0
  31. package/cjs/data/token-filter/helpers/text-matching.d.ts +16 -0
  32. package/cjs/data/token-filter/helpers/text-matching.js +47 -0
  33. package/cjs/data/token-filter/helpers/text-matching.js.map +1 -0
  34. package/cjs/form/combobox/Input/InputController.js +1 -1
  35. package/cjs/form/combobox/Input/InputController.js.map +1 -1
  36. package/cjs/form/file-upload/dropzone/FileUploadDropzone.js +1 -1
  37. package/cjs/form/file-upload/dropzone/FileUploadDropzone.js.map +1 -1
  38. package/esm/data/table/root/DataTableRoot.d.ts +27 -0
  39. package/esm/data/table/root/DataTableRoot.js +8 -2
  40. package/esm/data/table/root/DataTableRoot.js.map +1 -1
  41. package/esm/data/table/td/DataTableTd.d.ts +5 -4
  42. package/esm/data/table/td/DataTableTd.js +2 -2
  43. package/esm/data/table/td/DataTableTd.js.map +1 -1
  44. package/esm/data/token-filter/AutoSuggest.d.ts +2 -14
  45. package/esm/data/token-filter/AutoSuggest.js +17 -90
  46. package/esm/data/token-filter/AutoSuggest.js.map +1 -1
  47. package/esm/data/token-filter/AutoSuggest.types.d.ts +12 -0
  48. package/esm/data/token-filter/AutoSuggest.types.js +2 -0
  49. package/esm/data/token-filter/AutoSuggest.types.js.map +1 -0
  50. package/esm/data/token-filter/TokenFilter.js +18 -7
  51. package/esm/data/token-filter/TokenFilter.js.map +1 -1
  52. package/esm/data/token-filter/TokenFilter.types.d.ts +8 -2
  53. package/esm/data/token-filter/helpers/generate-autocomplete-options.d.ts +12 -58
  54. package/esm/data/token-filter/helpers/generate-autocomplete-options.js +159 -133
  55. package/esm/data/token-filter/helpers/generate-autocomplete-options.js.map +1 -1
  56. package/esm/data/token-filter/helpers/grouping.d.ts +28 -0
  57. package/esm/data/token-filter/helpers/grouping.js +59 -0
  58. package/esm/data/token-filter/helpers/grouping.js.map +1 -0
  59. package/esm/data/token-filter/helpers/operators.d.ts +22 -0
  60. package/esm/data/token-filter/helpers/operators.js +60 -0
  61. package/esm/data/token-filter/helpers/operators.js.map +1 -0
  62. package/esm/data/token-filter/helpers/parse-query-text.d.ts +1 -7
  63. package/esm/data/token-filter/helpers/parse-query-text.js +2 -45
  64. package/esm/data/token-filter/helpers/parse-query-text.js.map +1 -1
  65. package/esm/data/token-filter/helpers/query-builder.d.ts +20 -0
  66. package/esm/data/token-filter/helpers/query-builder.js +34 -0
  67. package/esm/data/token-filter/helpers/query-builder.js.map +1 -0
  68. package/esm/data/token-filter/helpers/text-matching.d.ts +16 -0
  69. package/esm/data/token-filter/helpers/text-matching.js +45 -0
  70. package/esm/data/token-filter/helpers/text-matching.js.map +1 -0
  71. package/esm/form/combobox/Input/InputController.js +1 -1
  72. package/esm/form/combobox/Input/InputController.js.map +1 -1
  73. package/esm/form/file-upload/dropzone/FileUploadDropzone.js +1 -1
  74. package/esm/form/file-upload/dropzone/FileUploadDropzone.js.map +1 -1
  75. package/package.json +3 -3
  76. package/src/data/table/root/DataTableRoot.tsx +30 -1
  77. package/src/data/table/td/DataTableTd.tsx +13 -6
  78. package/src/data/token-filter/AutoSuggest.tsx +38 -162
  79. package/src/data/token-filter/AutoSuggest.types.ts +14 -0
  80. package/src/data/token-filter/TokenFilter.tsx +16 -11
  81. package/src/data/token-filter/TokenFilter.types.ts +8 -2
  82. package/src/data/token-filter/helpers/generate-autocomplete-options.test.ts +896 -0
  83. package/src/data/token-filter/helpers/generate-autocomplete-options.ts +233 -188
  84. package/src/data/token-filter/helpers/grouping.test.ts +206 -0
  85. package/src/data/token-filter/helpers/grouping.ts +73 -0
  86. package/src/data/token-filter/helpers/operators.test.ts +281 -0
  87. package/src/data/token-filter/helpers/operators.ts +91 -0
  88. package/src/data/token-filter/helpers/parse-query-text.test.ts +4 -213
  89. package/src/data/token-filter/helpers/parse-query-text.ts +7 -69
  90. package/src/data/token-filter/helpers/query-builder.test.ts +126 -0
  91. package/src/data/token-filter/helpers/query-builder.ts +41 -0
  92. package/src/data/token-filter/helpers/text-matching.test.ts +125 -0
  93. package/src/data/token-filter/helpers/text-matching.ts +58 -0
  94. package/src/form/combobox/Input/InputController.tsx +0 -1
  95. package/src/form/file-upload/dropzone/FileUploadDropzone.tsx +0 -1
@@ -1,70 +1,24 @@
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
17
  declare function generateAutoCompleteOptions(queryState: ParsedText, filteringProperties?: ParsedProperty[], filteringOptions?: ParsedOption[]): {
46
18
  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
- })[];
19
+ options: OptionGroup<AutoCompleteOption>[];
66
20
  } | {
67
21
  value: string;
68
- options: (OptionGroup<ParsedProperty> | OptionGroup<AutoCompleteOption>)[];
22
+ options: OptionGroup<ParsedProperty>[];
69
23
  };
70
24
  export { generateAutoCompleteOptions };
@@ -1,123 +1,178 @@
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
- };
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";
19
5
  /**
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.
6
+ * Generates "options" to be used as autosuggest-ottion based on the current query state.
32
7
  *
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 "!="
8
+ * The query parser recognizes three states:
9
+ * - "property": User has selected/matched a property and operator ("Status = active")
10
+ * - "operator": User has matched a property but is typing the operator ("Status" or "Status !")
11
+ * - "free-text": User is typing freely without a property match (e.g., "act" or "!: test")
35
12
  *
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.
13
+ * @returns
14
+ * - value: The canonical query string representation for the current state.
15
+ * Used by the UI to determine cursor position and input replacement.
16
+ * - options: Grouped suggestions to display (properties, operators, or values).
49
17
  */
50
18
  function generateAutoCompleteOptions(queryState, filteringProperties = [], filteringOptions = []) {
19
+ var _a;
20
+ /* State: Property and operator are matched, suggest values */
51
21
  if (queryState.step === "property") {
52
- if (!queryState.property) {
22
+ const filterText = queryState.value || "";
23
+ return {
24
+ value: queryState.value,
25
+ options: createValueSuggestions(filteringOptions, queryState.operator, filterText, queryState.property),
26
+ };
27
+ }
28
+ /* State: Property matched, but operator is incomplete */
29
+ if (queryState.step === "operator") {
30
+ const operators = filterOperatorsByPrefix(getValidOperatorsForProperty(queryState.property), queryState.operatorPrefix);
31
+ const partialQuery = buildQueryString(queryState.property.propertyLabel, queryState.operatorPrefix, "");
32
+ /**
33
+ * Edge case: User typed an invalid operator prefix that doesn't match any operators.
34
+ * This can happen when typing characters that don't start any valid operator.
35
+ * Return empty suggestions gracefully - the UI will show "no results".
36
+ *
37
+ * TODO: When per-property operator configuration is implemented,
38
+ * this could also occur when a property restricts which operators are valid.
39
+ */
40
+ if (operators.length === 0) {
53
41
  return {
54
- value: queryState.value,
42
+ value: partialQuery,
55
43
  options: [],
56
44
  };
57
45
  }
58
- const { propertyLabel, groupValuesLabel } = queryState.property;
59
- const options = filteringOptions.filter((o) => o.property === queryState.property);
60
46
  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
- ],
47
+ value: partialQuery,
48
+ options: generateOperatorSuggestions(queryState.property, queryState.operatorPrefix),
73
49
  };
74
50
  }
75
- if (queryState.step === "operator") {
51
+ /*
52
+ * Edge case: Input starts with operator but has no value yet (user typed just "!=")
53
+ * Wait for value before showing suggestions
54
+ */
55
+ if (!queryState.value && queryState.operator) {
56
+ return {
57
+ value: "",
58
+ options: [],
59
+ };
60
+ }
61
+ /* Empty input: Show all properties */
62
+ if (!queryState.value) {
76
63
  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
- ],
64
+ value: "",
65
+ options: generatePropertySuggestions(filteringProperties),
93
66
  };
94
67
  }
95
- const needsValueSuggestions = !!queryState.value;
96
- const needsPropertySuggestions = !(queryState.step === "free-text" && queryState.operator === "!:");
68
+ /*
69
+ * Free-text search: Show matching values across all properties
70
+ * Use the detected operator if input started with one (e.g., "!= test"), otherwise default to "="
71
+ */
97
72
  return {
98
73
  value: queryState.value,
99
- options: [
100
- ...(needsPropertySuggestions
101
- ? generatePropertySuggestions(filteringProperties)
102
- : []),
103
- ...(needsValueSuggestions
104
- ? generateAllValueSuggestions(filteringOptions)
105
- : []),
106
- ],
74
+ options: createValueSuggestions(filteringOptions, (_a = queryState.operator) !== null && _a !== void 0 ? _a : "=", queryState.value),
107
75
  };
108
76
  }
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
- };
77
+ /**
78
+ * Returns the valid operators for a given property.
79
+ * Extracts operators from the property's custom operator configuration.
80
+ * If none are configured, falls back to all available operators.
81
+ *
82
+ * The QueryFilteringScopedOperator can be a simple string (e.g., "=")
83
+ * or an object with operator and tokenType (e.g., { operator: ":", tokenType: "single" }).
84
+ * This function normalizes both formats and returns just the operator strings.
85
+ *
86
+ * @returns Array of valid operators for the property
87
+ *
88
+ * 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.
89
+ */
90
+ function getValidOperatorsForProperty(property) {
91
+ const { operators } = property;
92
+ /* If no operators configured, return all available operators */
93
+ if (!operators || operators.length === 0) {
94
+ return QUERY_OPERATORS;
95
+ }
96
+ /*
97
+ * Extract operator strings from QueryFilteringScopedOperator format
98
+ * Handle both simple strings and objects with operator property
99
+ */
100
+ const operatorStrings = operators.map((op) => typeof op === "string" ? op : op.operator);
101
+ /* Filter to only valid QUERY_OPERATORS to ensure type safety */
102
+ return operatorStrings.filter((op) => QUERY_OPERATORS.includes(op));
116
103
  }
117
- function generateAllValueSuggestions(filteringOptions = []) {
104
+ /**
105
+ * Filters the list of operators based on the provided prefix.
106
+ * If the prefix is empty, all operators are returned.
107
+ */
108
+ function filterOperatorsByPrefix(operators, prefix) {
109
+ if (!prefix) {
110
+ return operators;
111
+ }
112
+ return operators.filter((operator) => operator.startsWith(prefix));
113
+ }
114
+ function generatePropertySuggestions(filteringProperties = [], filterText = "") {
115
+ const filteredProperties = [];
116
+ for (const property of filteringProperties) {
117
+ if (!property) {
118
+ continue;
119
+ }
120
+ if (matchesFilterText([
121
+ property.propertyLabel,
122
+ property.groupValuesLabel,
123
+ property.propertyGroup,
124
+ ].filter(Boolean), filterText)) {
125
+ filteredProperties.push(property);
126
+ }
127
+ }
128
+ return createGroups(filteredProperties, (property) => property.propertyGroup, "Properties");
129
+ }
130
+ function generateOperatorSuggestions(property, operatorPrefix = "") {
131
+ const operators = filterOperatorsByPrefix(getValidOperatorsForProperty(property), operatorPrefix);
132
+ if (operators.length === 0) {
133
+ return [];
134
+ }
135
+ return [
136
+ {
137
+ label: "Operators",
138
+ options: operators.map((operator) => {
139
+ var _a;
140
+ return ({
141
+ value: buildQueryString(property.propertyLabel, operator, ""),
142
+ label: buildQueryString(property.propertyLabel, operator, ""),
143
+ description: (_a = OPERATOR_LABELS[operator]) !== null && _a !== void 0 ? _a : "",
144
+ });
145
+ }),
146
+ },
147
+ ];
148
+ }
149
+ /**
150
+ * Creates value suggestions for autocomplete.
151
+ * When scopedProperty is provided, only shows values for that property (single group).
152
+ * When scopedProperty is omitted, searches across all properties (multiple groups).
153
+ */
154
+ function createValueSuggestions(filteringOptions = [], operator, filterText = "", scopedProperty) {
155
+ var _a, _b;
118
156
  const groups = {};
119
157
  for (const option of filteringOptions) {
120
- if (!option || !option.property) {
158
+ if (!(option === null || option === void 0 ? void 0 : option.property)) {
159
+ continue;
160
+ }
161
+ /* If scoped to a property, filter to only that property's options */
162
+ if (scopedProperty && option.property !== scopedProperty) {
163
+ continue;
164
+ }
165
+ /* Build search fields */
166
+ const searchFields = [
167
+ option.label,
168
+ ...((_a = option.tags) !== null && _a !== void 0 ? _a : []),
169
+ ...((_b = option.filteringTags) !== null && _b !== void 0 ? _b : []),
170
+ ];
171
+ if (!scopedProperty) {
172
+ searchFields.push(option.property.propertyLabel);
173
+ }
174
+ const matches = matchesFilterText(searchFields.filter(Boolean), filterText);
175
+ if (!matches) {
121
176
  continue;
122
177
  }
123
178
  const groupLabel = option.property.groupValuesLabel || "Values";
@@ -127,43 +182,14 @@ function generateAllValueSuggestions(filteringOptions = []) {
127
182
  options: [],
128
183
  };
129
184
  }
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);
185
+ groups[groupLabel].options.push({
186
+ value: buildQueryString(option.property.propertyLabel, operator, option.value),
187
+ label: option.label,
188
+ tags: option.tags,
189
+ filteringTags: option.filteringTags,
190
+ });
165
191
  }
166
- return groups;
192
+ return Object.values(groups).filter((group) => group.options.length > 0);
167
193
  }
168
194
  export { generateAutoCompleteOptions };
169
195
  //# 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,CAClC,UAAsB,EACtB,sBAAwC,EAAE,EAC1C,mBAAmC,EAAE;IAErC,IAAI,UAAU,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;YACzB,OAAO;gBACL,KAAK,EAAE,UAAU,CAAC,KAAK;gBACvB,OAAO,EAAE,EAAE;aACZ,CAAC;QACJ,CAAC;QACD,MAAM,EAAE,aAAa,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAAC,QAAQ,CAAC;QAChE,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CACrC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,UAAU,CAAC,QAAQ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5B,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;AAEpD;;;;;;;;;;;;GAYG;AACH,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;IACJ,CAAC;IAED,yDAAyD;IACzD,IAAI,UAAU,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACnC,MAAM,SAAS,GAAG,uBAAuB,CACvC,4BAA4B,CAAC,UAAU,CAAC,QAAQ,CAAC,EACjD,UAAU,CAAC,cAAc,CAC1B,CAAC;QAEF,MAAM,YAAY,GAAG,gBAAgB,CACnC,UAAU,CAAC,QAAQ,CAAC,aAAa,EACjC,UAAU,CAAC,cAAc,EACzB,EAAE,CACH,CAAC;QAEF;;;;;;;WAOG;QACH,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO;gBACL,KAAK,EAAE,YAAY;gBACnB,OA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,QAAQ,CAAC,gBAAgB,IAAI,QAAQ,CAAC;QAEhE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;YACxB,MAAM,CAAC,UAAU,CAAC,GAAG;gBACnB,KAAK,EAAE,UAAU;gBACjB,OAAO,EAAE,EAAE;aACZ,CAAC;QACJ,CAAC;QAED,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;YAC9B,KAAK,EAAE,gBAAgB,CACrB,MAAM,CAAC,QAAQ,CAAC,aAAa,EAC7B,QAAQ,EACR,MAAM,CAAC,KAAK,CACb;YACD,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,aAAa,EAAE,MAAM,CAAC,aAAa;SACpC,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/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sedProperty, 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, };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Operators ordered by specificity (longest/most specific first)
3
+ * This ensures longer operators like ">=" and "<=" are matched
4
+ * before shorter ones like ">" and "<"
5
+ */
6
+ const Operators = {
7
+ ">=": null,
8
+ "<=": null,
9
+ "!=": null,
10
+ "!:": null,
11
+ "!^": null,
12
+ "=": null,
13
+ ":": null,
14
+ "^": null,
15
+ ">": null,
16
+ "<": null,
17
+ };
18
+ const QUERY_OPERATORS = Object.keys(Operators);
19
+ /**
20
+ * Match an operator from the input text.
21
+ * Operators are already sorted by specificity, so no re-sorting needed.
22
+ */
23
+ function matchOperator(allowedOperators, text) {
24
+ return allowedOperators.find((operator) => text.toLowerCase().startsWith(operator.toLowerCase()));
25
+ }
26
+ /**
27
+ * Match a property from the input text by longest property label.
28
+ *
29
+ * properties: [{ propertyLabel: "Instance" }, { propertyLabel: "Instance ID" }]
30
+ * text = "Instance ID:"
31
+ *
32
+ * Result: { propertyLabel: "Instance ID" }
33
+ */
34
+ function matchFilteringProperty(filteringProperties, text) {
35
+ const lowerText = text.toLowerCase();
36
+ let bestMatch;
37
+ for (const prop of filteringProperties) {
38
+ if (lowerText.startsWith(prop.propertyLabel.toLowerCase())) {
39
+ if (!bestMatch ||
40
+ prop.propertyLabel.length > bestMatch.propertyLabel.length) {
41
+ bestMatch = prop;
42
+ }
43
+ }
44
+ }
45
+ return bestMatch;
46
+ }
47
+ /**
48
+ * Check if the input text is a valid prefix of any allowed operator.
49
+ * Returns the prefix if valid, null otherwise.
50
+ */
51
+ function matchOperatorPrefix(allowedOperators, filteringText) {
52
+ const trimmedText = filteringText.trim();
53
+ if (trimmedText.length === 0) {
54
+ return "";
55
+ }
56
+ const isValidPrefix = allowedOperators.some((operator) => operator.toLowerCase().startsWith(trimmedText.toLowerCase()));
57
+ return isValidPrefix ? trimmedText : null;
58
+ }
59
+ export { QUERY_OPERATORS, matchOperator, matchFilteringProperty, matchOperatorPrefix, };
60
+ //# sourceMappingURL=operators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operators.js","sourceRoot":"","sources":["../../../../src/data/token-filter/helpers/operators.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,SAAS,GAAsC;IACnD,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;CACV,CAAC;AAEF,MAAM,eAAe,GAA0B,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAEtE;;;GAGG;AACH,SAAS,aAAa,CACpB,gBAAuC,EACvC,IAAY;IAEZ,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CACxC,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CACtD,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,sBAAsB,CAC7B,mBAAqC,EACrC,IAAY;IAEZ,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACrC,IAAI,SAAqC,CAAC;IAE1C,KAAK,MAAM,IAAI,IAAI,mBAAmB,EAAE,CAAC;QACvC,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;YAC3D,IACE,CAAC,SAAS;gBACV,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC,aAAa,CAAC,MAAM,EAC1D,CAAC;gBACD,SAAS,GAAG,IAAI,CAAC;YACnB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAC1B,gBAAuC,EACvC,aAAqB;IAErB,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC;IAEzC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CACvD,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAC7D,CAAC;IAEF,OAAO,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC;AAED,OAAO,EACL,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,mBAAmB,GACpB,CAAC"}
@@ -21,11 +21,5 @@ type ParsedText = {
21
21
  * Handles partial input (e.g., user typing "Status !" to complete the operator).
22
22
  */
23
23
  declare function parseQueryText(filteringText: string, filteringProperties: ParsedProperty[]): ParsedText;
24
- /**
25
- * Operators ordered by specificity (longest/most specific first)
26
- * This ensures longer operators like ">=" and "<=" are matched
27
- * before shorter ones like ">" and "<"
28
- */
29
- declare const QUERY_OPERATORS: QueryFilterOperator[];
30
- export { QUERY_OPERATORS, parseQueryText };
24
+ export { parseQueryText };
31
25
  export type { ParsedText };