@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,126 +1,173 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateAutoCompleteOptions = generateAutoCompleteOptions;
4
- const parse_query_text_1 = require("./parse-query-text");
5
- function buildQueryString(propertyLabel, operator, value) {
6
- const parts = [propertyLabel, operator, value].filter(Boolean);
7
- return parts.join(" ");
8
- }
9
- /* TODO: i18n */
10
- const OPERATOR_LABELS = {
11
- ":": "contains",
12
- "!:": "does not contain",
13
- "=": "is",
14
- "!=": "is not",
15
- "^": "starts with",
16
- "!^": "does not start with",
17
- ">=": "is greater than or equal to",
18
- "<=": "is less than or equal to",
19
- ">": "is greater than",
20
- "<": "is less than",
21
- };
22
- /**
23
- * Grouping option for autocomplete suggestions structures:
24
- *
25
- * Step: "free-text" + empty value:
26
- * - Group: "Properties" with all properties.
27
- *
28
- * Step: "free-text" with non-empty value:
29
- * - Group: "Properties". All properties including the filter text in label or description or tags. String match.
30
- * - Group: "Values". All "property = value" combinations where either the property label or value label or description or tags include the filter text. String match.
31
- * - - Ignore all other operators than "=" for value suggestions.
32
- *
33
- * Step: "property" + empty value:
34
- * - Group: "Operators". All operators valid for the selected property.
35
- *
36
- * Step: "property" + non-empty value:
37
- * - Group: "Operators". All operators valid for the selected property with string match. Only relevant for multi letter operators like "!="
38
- *
39
- * Step: "operator" + empty value:
40
- * - Group: "<Property> values". All values valid for the selected property and operator. String match on value label, description and tags.
41
- *
42
- * Step: "operator" + non-empty value:
43
- * - Group: "<Property> values". All values valid for the selected property and operator with string match. String match on value label, description and tags.
44
- *
45
- *
46
- * TODO:
47
- * - Handle custom groups
48
- * - 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"))
49
- */
50
- /**
51
- * TODO: Update based on instructions above.
52
- */
4
+ const grouping_1 = require("./grouping");
5
+ const operators_1 = require("./operators");
6
+ const query_builder_1 = require("./query-builder");
7
+ const text_matching_1 = require("./text-matching");
53
8
  function generateAutoCompleteOptions(queryState, filteringProperties = [], filteringOptions = []) {
9
+ var _a;
10
+ /* State: Property and operator are matched, suggest values */
54
11
  if (queryState.step === "property") {
55
- if (!queryState.property) {
12
+ const filterText = queryState.value || "";
13
+ return {
14
+ value: queryState.value,
15
+ options: createValueSuggestions(filteringOptions, queryState.operator, filterText, queryState.property),
16
+ };
17
+ }
18
+ /* State: Property matched, but operator is incomplete */
19
+ if (queryState.step === "operator") {
20
+ const operators = filterOperatorsByPrefix(getValidOperatorsForProperty(queryState.property), queryState.operatorPrefix);
21
+ const partialQuery = (0, query_builder_1.buildQueryString)(queryState.property.propertyLabel, queryState.operatorPrefix, "");
22
+ /**
23
+ * Edge case: User typed an invalid operator prefix that doesn't match any operators.
24
+ * This can happen when typing characters that don't start any valid operator.
25
+ * Return empty suggestions gracefully - the UI will show "no results".
26
+ */
27
+ if (operators.length === 0) {
56
28
  return {
57
- value: queryState.value,
29
+ value: partialQuery,
58
30
  options: [],
59
31
  };
60
32
  }
61
- const { propertyLabel, groupValuesLabel } = queryState.property;
62
- const options = filteringOptions.filter((o) => o.property === queryState.property);
63
33
  return {
64
- value: queryState.value,
65
- options: [
66
- {
67
- label: groupValuesLabel,
68
- options: options.map(({ label, value, tags, filteringTags }) => ({
69
- value: buildQueryString(propertyLabel, queryState.operator, value),
70
- label,
71
- tags,
72
- filteringTags,
73
- })),
74
- },
75
- ],
34
+ value: partialQuery,
35
+ options: generateOperatorSuggestions(queryState.property, queryState.operatorPrefix),
76
36
  };
77
37
  }
78
- if (queryState.step === "operator") {
38
+ /*
39
+ * Edge case: Input starts with operator but has no value yet (user typed just "!=")
40
+ * Wait for value before showing suggestions
41
+ */
42
+ if (!queryState.value && queryState.operator) {
79
43
  return {
80
- value: buildQueryString(queryState.property.propertyLabel, queryState.operatorPrefix, ""),
81
- options: [
82
- ...generatePropertySuggestions(filteringProperties),
83
- {
84
- options: parse_query_text_1.QUERY_OPERATORS.map((value) => {
85
- var _a;
86
- return ({
87
- value: buildQueryString(queryState.property.propertyLabel, value, ""),
88
- label: buildQueryString(queryState.property.propertyLabel, value, ""),
89
- description: (_a = OPERATOR_LABELS[value]) !== null && _a !== void 0 ? _a : "",
90
- });
91
- }),
92
- /* TODO: i18n */
93
- label: "Operator",
94
- },
95
- ],
44
+ value: "",
45
+ options: [],
96
46
  };
97
47
  }
98
- const needsValueSuggestions = !!queryState.value;
99
- const needsPropertySuggestions = !(queryState.step === "free-text" && queryState.operator === "!:");
48
+ /* Empty input: Show all properties */
49
+ if (!queryState.value) {
50
+ return {
51
+ value: "",
52
+ options: generatePropertySuggestions(filteringProperties),
53
+ };
54
+ }
55
+ /*
56
+ * Free-text search: Show matching values across all properties
57
+ * Use the detected operator if input started with one (e.g., "!= test"), otherwise default to "="
58
+ */
100
59
  return {
101
60
  value: queryState.value,
102
61
  options: [
103
- ...(needsPropertySuggestions
104
- ? generatePropertySuggestions(filteringProperties)
105
- : []),
106
- ...(needsValueSuggestions
107
- ? generateAllValueSuggestions(filteringOptions)
108
- : []),
62
+ ...generatePropertySuggestions(filteringProperties, queryState.value),
63
+ ...createValueSuggestions(filteringOptions, (_a = queryState.operator) !== null && _a !== void 0 ? _a : "=", queryState.value),
109
64
  ],
110
65
  };
111
66
  }
112
- function createAutoCompleteOption(propertyLabel, operator, value, label, tags, filteringTags) {
113
- return {
114
- value: buildQueryString(propertyLabel, operator, value),
115
- label: buildQueryString(propertyLabel, operator, label),
116
- tags,
117
- filteringTags,
118
- };
67
+ /**
68
+ * Returns the valid operators for a given property.
69
+ * Extracts operators from the property's custom operator configuration.
70
+ * If none are configured, falls back to all available operators.
71
+ *
72
+ * The QueryFilteringScopedOperator can be a simple string (e.g., "=")
73
+ * or an object with operator and tokenType (e.g., { operator: ":", tokenType: "single" }).
74
+ * This function normalizes both formats and returns just the operator strings.
75
+ *
76
+ * @returns Array of valid operators for the property
77
+ *
78
+ * 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.
79
+ */
80
+ function getValidOperatorsForProperty(property) {
81
+ const { operators } = property;
82
+ /* If no operators configured, return all available operators */
83
+ if (!operators || operators.length === 0) {
84
+ return operators_1.QUERY_OPERATORS;
85
+ }
86
+ /*
87
+ * Extract operator strings from QueryFilteringScopedOperator format
88
+ * Handle both simple strings and objects with operator property
89
+ */
90
+ const operatorStrings = operators.map((op) => typeof op === "string" ? op : op.operator);
91
+ /* Filter to only valid QUERY_OPERATORS to ensure type safety */
92
+ return operatorStrings.filter((op) => operators_1.QUERY_OPERATORS.includes(op));
93
+ }
94
+ /**
95
+ * Filters the list of operators based on the provided prefix.
96
+ * If the prefix is empty, all operators are returned.
97
+ */
98
+ function filterOperatorsByPrefix(operators, prefix) {
99
+ if (!prefix) {
100
+ return operators;
101
+ }
102
+ return operators.filter((operator) => operator.startsWith(prefix));
119
103
  }
120
- function generateAllValueSuggestions(filteringOptions = []) {
104
+ function generatePropertySuggestions(filteringProperties = [], filterText = "") {
105
+ const filteredProperties = [];
106
+ for (const property of filteringProperties) {
107
+ if (!property) {
108
+ continue;
109
+ }
110
+ if ((0, text_matching_1.matchesFilterText)([
111
+ property.propertyLabel,
112
+ property.groupValuesLabel,
113
+ property.propertyGroup,
114
+ ].filter(Boolean), filterText)) {
115
+ filteredProperties.push(property);
116
+ }
117
+ }
118
+ const groups = (0, grouping_1.createGroups)(filteredProperties, (property) => property.propertyGroup, "Properties");
119
+ return groups.map((group) => ({
120
+ label: group.label,
121
+ options: group.options.map((property) => ({
122
+ value: (0, query_builder_1.buildQueryString)(property.propertyLabel, "", ""),
123
+ label: property.propertyLabel,
124
+ })),
125
+ }));
126
+ }
127
+ function generateOperatorSuggestions(property, operatorPrefix = "") {
128
+ const operators = filterOperatorsByPrefix(getValidOperatorsForProperty(property), operatorPrefix);
129
+ if (operators.length === 0) {
130
+ return [];
131
+ }
132
+ return [
133
+ {
134
+ label: "Operators",
135
+ options: operators.map((operator) => {
136
+ var _a;
137
+ return ({
138
+ value: (0, query_builder_1.buildQueryString)(property.propertyLabel, operator, ""),
139
+ label: (0, query_builder_1.buildQueryString)(property.propertyLabel, operator, ""),
140
+ description: (_a = query_builder_1.OPERATOR_LABELS[operator]) !== null && _a !== void 0 ? _a : "",
141
+ });
142
+ }),
143
+ },
144
+ ];
145
+ }
146
+ /**
147
+ * Creates value suggestions for autocomplete.
148
+ * When scopedProperty is provided, only shows values for that property (single group).
149
+ * When scopedProperty is omitted, searches across all properties (multiple groups).
150
+ * TODO: This could potentially contain an unlimited number of options if there are many values across properties.
151
+ * May need virtualization/async or other filtering mechanism.
152
+ */
153
+ function createValueSuggestions(filteringOptions = [], operator, filterText = "", scopedProperty) {
154
+ var _a;
121
155
  const groups = {};
122
156
  for (const option of filteringOptions) {
123
- if (!option || !option.property) {
157
+ if (!(option === null || option === void 0 ? void 0 : option.property)) {
158
+ continue;
159
+ }
160
+ /* If scoped to a property, filter to only that property's options */
161
+ if (scopedProperty && option.property !== scopedProperty) {
162
+ continue;
163
+ }
164
+ /* Build search fields */
165
+ const searchFields = [option.label, ...((_a = option.tags) !== null && _a !== void 0 ? _a : [])];
166
+ if (!scopedProperty) {
167
+ searchFields.push(option.property.propertyLabel);
168
+ }
169
+ const matches = (0, text_matching_1.matchesFilterText)(searchFields.filter(Boolean), filterText);
170
+ if (!matches) {
124
171
  continue;
125
172
  }
126
173
  const groupLabel = option.property.groupValuesLabel || "Values";
@@ -130,42 +177,12 @@ function generateAllValueSuggestions(filteringOptions = []) {
130
177
  options: [],
131
178
  };
132
179
  }
133
- const { label, value, tags, filteringTags, property } = option;
134
- const options = parse_query_text_1.QUERY_OPERATORS.map((operator) => createAutoCompleteOption(property.propertyLabel, operator, value, label, tags, filteringTags));
135
- groups[groupLabel].options.push(...options);
136
- }
137
- return Object.values(groups);
138
- }
139
- function generatePropertySuggestions(filteringProperties = []) {
140
- var _a;
141
- const defaultGroup = {
142
- label: "Properties",
143
- options: [],
144
- };
145
- const customGroups = {};
146
- for (const property of filteringProperties) {
147
- if (!property) {
148
- continue;
149
- }
150
- const groupLabel = (_a = property.propertyGroup) === null || _a === void 0 ? void 0 : _a.trim();
151
- if (groupLabel) {
152
- if (!customGroups[groupLabel]) {
153
- customGroups[groupLabel] = {
154
- label: groupLabel,
155
- options: [],
156
- };
157
- }
158
- customGroups[groupLabel].options.push(property);
159
- continue;
160
- }
161
- defaultGroup.options.push(property);
162
- }
163
- const groups = [
164
- ...Object.values(customGroups),
165
- ];
166
- if (defaultGroup.options.length > 0) {
167
- groups.push(defaultGroup);
180
+ groups[groupLabel].options.push({
181
+ value: (0, query_builder_1.buildQueryString)(option.property.propertyLabel, operator, option.value),
182
+ label: option.label,
183
+ tags: option.tags,
184
+ });
168
185
  }
169
- return groups;
186
+ return Object.values(groups).filter((group) => group.options.length > 0);
170
187
  }
171
188
  //# 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":";;AAmPS,kEAA2B;AAlPpC,yDAAsE;AAetE,SAAS,gBAAgB,CACvB,aAAqB,EACrB,QAAgB,EAChB,KAAa;IAEb,MAAM,KAAK,GAAG,CAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,CAAC,CA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AAC/B,CAAC;AAED,SAAS,2BAA2B,CAClC,sBAAwC,EAAE;;IAE1C,MAAM,YAAY,GAAgC;QAChD,KAAK,EAAE,YAAY;QACnB,OAAO,EAAE,EAAE;KACZ,CAAC;IACF,MAAM,YAAY,GAAgD,EAAE,CAAC;IAErE,KAAK,MAAM,QAAQ,IAAI,mBAAmB,EAAE,CAAC;QAC3C,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,SAAS;QACX,CAAC;QACD,MAAM,UAAU,GAAG,MAAA,QAAQ,CAAC,aAAa,0CAAE,IAAI,EAAE,CAAC;QAElD,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC9B,YAAY,CAAC,UAAU,CAAC,GAAG;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"}
1
+ {"version":3,"file":"generate-autocomplete-options.js","sourceRoot":"","sources":["../../../../src/data/token-filter/helpers/generate-autocomplete-options.ts"],"names":[],"mappings":";;AA0SS,kEAA2B;AApSpC,yCAA0C;AAC1C,2CAA8C;AAE9C,mDAAoE;AACpE,mDAAoD;AAoBpD,SAAS,2BAA2B,CAClC,UAAsB,EACtB,sBAAwC,EAAE,EAC1C,mBAAm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,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,IAAA,gCAAgB,EACrB,MAAM,CAAC,QAAQ,CAAC,aAAa,EAC7B,QAAQ,EACR,MAAM,CAAC,KAAK,CACb;YACD,KAAK,EAAE,MAAM,CAAC,KAAK;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"}
@@ -0,0 +1,28 @@
1
+ import type { OptionGroup } from "../AutoSuggest.types";
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,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createGroups = createGroups;
4
+ /**
5
+ * Groups items into labeled groups with support for a default group.
6
+ * Empty or whitespace-only group labels are treated as belonging to the default group.
7
+ *
8
+ * @returns Array of groups with non-empty options
9
+ *
10
+ * @example
11
+ * const properties = [
12
+ * { name: "Status", group: "Metadata" },
13
+ * { name: "Region", group: "Location" },
14
+ * { name: "Type", group: "" },
15
+ * ];
16
+ * const groups = createGroups(
17
+ * properties,
18
+ * (p) => p.group,
19
+ * "Properties"
20
+ * );
21
+ *
22
+ * Returns:
23
+ * [
24
+ * { label: "Metadata", options: [{ name: "Status", group: "Metadata" }] },
25
+ * { label: "Location", options: [{ name: "Region", group: "Location" }] },
26
+ * { label: "Properties", options: [{ name: "Type", group: "" }] }
27
+ * ]
28
+ */
29
+ function createGroups(items, getGroupLabel, defaultGroupLabel = "Default") {
30
+ const defaultGroup = {
31
+ label: defaultGroupLabel,
32
+ options: [],
33
+ };
34
+ const customGroups = {};
35
+ for (const item of items) {
36
+ if (!item) {
37
+ continue;
38
+ }
39
+ const rawLabel = getGroupLabel(item);
40
+ const groupLabel = rawLabel === null || rawLabel === void 0 ? void 0 : rawLabel.trim();
41
+ /* Empty string after trim or falsy values go to default group */
42
+ if (!groupLabel) {
43
+ defaultGroup.options.push(item);
44
+ continue;
45
+ }
46
+ if (!customGroups[groupLabel]) {
47
+ customGroups[groupLabel] = {
48
+ label: groupLabel,
49
+ options: [],
50
+ };
51
+ }
52
+ customGroups[groupLabel].options.push(item);
53
+ }
54
+ /* Custom groups first, then default group if it has items */
55
+ const groups = [...Object.values(customGroups)];
56
+ if (defaultGroup.options.length > 0) {
57
+ groups.push(defaultGroup);
58
+ }
59
+ return groups;
60
+ }
61
+ //# sourceMappingURL=grouping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grouping.js","sourceRoot":"","sources":["../../../../src/data/token-filter/helpers/grouping.ts"],"names":[],"mappings":";;AAwES,oCAAY;AAtErB;;;;;;;;;;;;;;;;;;;;;;;;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"}
@@ -0,0 +1,22 @@
1
+ import type { ParsedProperty, QueryFilterOperator } from "../TokenFilter.types";
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,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QUERY_OPERATORS = void 0;
4
+ exports.matchOperator = matchOperator;
5
+ exports.matchFilteringProperty = matchFilteringProperty;
6
+ exports.matchOperatorPrefix = matchOperatorPrefix;
7
+ /**
8
+ * Operators ordered by specificity (longest/most specific first)
9
+ * This ensures longer operators like ">=" and "<=" are matched
10
+ * before shorter ones like ">" and "<"
11
+ */
12
+ const Operators = {
13
+ ">=": null,
14
+ "<=": null,
15
+ "!=": null,
16
+ "!:": null,
17
+ "!^": null,
18
+ "=": null,
19
+ ":": null,
20
+ "^": null,
21
+ ">": null,
22
+ "<": null,
23
+ };
24
+ const QUERY_OPERATORS = Object.keys(Operators);
25
+ exports.QUERY_OPERATORS = QUERY_OPERATORS;
26
+ /**
27
+ * Match an operator from the input text.
28
+ * Operators are already sorted by specificity, so no re-sorting needed.
29
+ */
30
+ function matchOperator(allowedOperators, text) {
31
+ return allowedOperators.find((operator) => text.toLowerCase().startsWith(operator.toLowerCase()));
32
+ }
33
+ /**
34
+ * Match a property from the input text by longest property label.
35
+ *
36
+ * properties: [{ propertyLabel: "Instance" }, { propertyLabel: "Instance ID" }]
37
+ * text = "Instance ID:"
38
+ *
39
+ * Result: { propertyLabel: "Instance ID" }
40
+ */
41
+ function matchFilteringProperty(filteringProperties, text) {
42
+ const lowerText = text.toLowerCase();
43
+ let bestMatch;
44
+ for (const prop of filteringProperties) {
45
+ if (lowerText.startsWith(prop.propertyLabel.toLowerCase())) {
46
+ if (!bestMatch ||
47
+ prop.propertyLabel.length > bestMatch.propertyLabel.length) {
48
+ bestMatch = prop;
49
+ }
50
+ }
51
+ }
52
+ return bestMatch;
53
+ }
54
+ /**
55
+ * Check if the input text is a valid prefix of any allowed operator.
56
+ * Returns the prefix if valid, null otherwise.
57
+ */
58
+ function matchOperatorPrefix(allowedOperators, filteringText) {
59
+ const trimmedText = filteringText.trim();
60
+ if (trimmedText.length === 0) {
61
+ return "";
62
+ }
63
+ const isValidPrefix = allowedOperators.some((operator) => operator.toLowerCase().startsWith(trimmedText.toLowerCase()));
64
+ return isValidPrefix ? trimmedText : null;
65
+ }
66
+ //# sourceMappingURL=operators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operators.js","sourceRoot":"","sources":["../../../../src/data/token-filter/helpers/operators.ts"],"names":[],"mappings":";;;AAuFE,sCAAa;AACb,wDAAsB;AACtB,kDAAmB;AAvFrB;;;;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;AAkEpE,0CAAe;AAhEjB;;;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"}
@@ -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 };
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QUERY_OPERATORS = void 0;
4
3
  exports.parseQueryText = parseQueryText;
4
+ const operators_1 = require("./operators");
5
5
  /**
6
6
  * Parse user input text to extract property, operator, and value components.
7
7
  * Handles partial input (e.g., user typing "Status !" to complete the operator).
8
8
  */
9
9
  function parseQueryText(filteringText, filteringProperties) {
10
- const property = matchFilteringProperty(filteringProperties, filteringText);
10
+ const property = (0, operators_1.matchFilteringProperty)(filteringProperties, filteringText);
11
11
  if (!property) {
12
- const freeTextOperator = matchOperator(QUERY_OPERATORS, filteringText);
12
+ const freeTextOperator = (0, operators_1.matchOperator)(operators_1.QUERY_OPERATORS, filteringText);
13
13
  if (freeTextOperator) {
14
14
  return {
15
15
  step: "free-text",
@@ -25,7 +25,7 @@ function parseQueryText(filteringText, filteringProperties) {
25
25
  const textWithoutProperty = filteringText
26
26
  .substring(property.propertyLabel.length)
27
27
  .trimStart();
28
- const operator = matchOperator(QUERY_OPERATORS, textWithoutProperty);
28
+ const operator = (0, operators_1.matchOperator)(operators_1.QUERY_OPERATORS, textWithoutProperty);
29
29
  if (operator) {
30
30
  return {
31
31
  step: "property",
@@ -34,7 +34,7 @@ function parseQueryText(filteringText, filteringProperties) {
34
34
  value: textWithoutProperty.substring(operator.length).trimStart(),
35
35
  };
36
36
  }
37
- const operatorPrefix = matchOperatorPrefix(QUERY_OPERATORS, textWithoutProperty);
37
+ const operatorPrefix = (0, operators_1.matchOperatorPrefix)(operators_1.QUERY_OPERATORS, textWithoutProperty);
38
38
  if (operatorPrefix !== null) {
39
39
  return { step: "operator", property, operatorPrefix };
40
40
  }
@@ -43,49 +43,4 @@ function parseQueryText(filteringText, filteringProperties) {
43
43
  value: filteringText,
44
44
  };
45
45
  }
46
- /**
47
- * Operators ordered by specificity (longest/most specific first)
48
- * This ensures longer operators like ">=" and "<=" are matched
49
- * before shorter ones like ">" and "<"
50
- */
51
- const QUERY_OPERATORS = [
52
- ">=",
53
- "<=",
54
- "!=",
55
- "!:",
56
- "!^",
57
- "=",
58
- ":",
59
- "^",
60
- ">",
61
- "<",
62
- ];
63
- exports.QUERY_OPERATORS = QUERY_OPERATORS;
64
- /**
65
- * Match a property from the input text by longest property label.
66
- * Case-insensitive matching.
67
- */
68
- function matchFilteringProperty(filteringProperties, text) {
69
- const sortedProperties = [...filteringProperties].sort((a, b) => b.propertyLabel.length - a.propertyLabel.length);
70
- return sortedProperties.find((prop) => text.toLowerCase().startsWith(prop.propertyLabel.toLowerCase()));
71
- }
72
- /**
73
- * Check if the input text is a valid prefix of any allowed operator.
74
- * Returns the prefix if valid, null otherwise.
75
- */
76
- function matchOperatorPrefix(allowedOperators, filteringText) {
77
- const trimmedText = filteringText.trim();
78
- if (trimmedText.length === 0) {
79
- return "";
80
- }
81
- const isValidPrefix = allowedOperators.some((operator) => operator.toLowerCase().startsWith(trimmedText.toLowerCase()));
82
- return isValidPrefix ? trimmedText : null;
83
- }
84
- /**
85
- * Match an operator from the input text.
86
- * Operators are already sorted by specificity, so no re-sorting needed.
87
- */
88
- function matchOperator(allowedOperators, text) {
89
- return allowedOperators.find((operator) => text.toLowerCase().startsWith(operator.toLowerCase()));
90
- }
91
46
  //# sourceMappingURL=parse-query-text.js.map