@navikt/ds-react 8.5.0 → 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.
- package/cjs/data/table/helpers/table-grid-nav.d.ts +9 -15
- package/cjs/data/table/helpers/table-grid-nav.js +18 -25
- package/cjs/data/table/helpers/table-grid-nav.js.map +1 -1
- package/cjs/data/table/helpers/table-keyboard.d.ts +1 -1
- package/cjs/data/table/helpers/table-keyboard.js +1 -6
- package/cjs/data/table/helpers/table-keyboard.js.map +1 -1
- package/cjs/data/table/root/DataTableRoot.d.ts +41 -4
- package/cjs/data/table/root/DataTableRoot.js +10 -6
- package/cjs/data/table/root/DataTableRoot.js.map +1 -1
- package/cjs/data/table/root/useTableKeyboardNav.d.ts +1 -1
- package/cjs/data/table/root/useTableKeyboardNav.js +32 -19
- package/cjs/data/table/root/useTableKeyboardNav.js.map +1 -1
- package/cjs/data/table/td/DataTableTd.d.ts +5 -4
- package/cjs/data/table/td/DataTableTd.js +2 -2
- package/cjs/data/table/td/DataTableTd.js.map +1 -1
- package/cjs/data/token-filter/AutoSuggest.d.ts +9 -0
- package/cjs/data/token-filter/AutoSuggest.js +56 -0
- package/cjs/data/token-filter/AutoSuggest.js.map +1 -0
- package/cjs/data/token-filter/AutoSuggest.types.d.ts +12 -0
- package/cjs/data/token-filter/AutoSuggest.types.js +3 -0
- package/cjs/data/token-filter/AutoSuggest.types.js.map +1 -0
- package/cjs/data/token-filter/TokenFilter.d.ts +11 -0
- package/cjs/data/token-filter/TokenFilter.js +102 -0
- package/cjs/data/token-filter/TokenFilter.js.map +1 -0
- package/cjs/data/token-filter/TokenFilter.types.d.ts +52 -0
- package/cjs/data/token-filter/TokenFilter.types.js +3 -0
- package/cjs/data/token-filter/TokenFilter.types.js.map +1 -0
- package/cjs/data/token-filter/helpers/generate-autocomplete-options.d.ts +24 -0
- package/cjs/data/token-filter/helpers/generate-autocomplete-options.js +197 -0
- package/cjs/data/token-filter/helpers/generate-autocomplete-options.js.map +1 -0
- package/cjs/data/token-filter/helpers/grouping.d.ts +28 -0
- package/cjs/data/token-filter/helpers/grouping.js +61 -0
- package/cjs/data/token-filter/helpers/grouping.js.map +1 -0
- package/cjs/data/token-filter/helpers/operators.d.ts +22 -0
- package/cjs/data/token-filter/helpers/operators.js +66 -0
- package/cjs/data/token-filter/helpers/operators.js.map +1 -0
- package/cjs/data/token-filter/helpers/parse-query-text.d.ts +25 -0
- package/cjs/data/token-filter/helpers/parse-query-text.js +46 -0
- package/cjs/data/token-filter/helpers/parse-query-text.js.map +1 -0
- package/cjs/data/token-filter/helpers/query-builder.d.ts +20 -0
- package/cjs/data/token-filter/helpers/query-builder.js +38 -0
- package/cjs/data/token-filter/helpers/query-builder.js.map +1 -0
- package/cjs/data/token-filter/helpers/text-matching.d.ts +16 -0
- package/cjs/data/token-filter/helpers/text-matching.js +47 -0
- package/cjs/data/token-filter/helpers/text-matching.js.map +1 -0
- package/cjs/form/combobox/Input/InputController.js +1 -1
- package/cjs/form/combobox/Input/InputController.js.map +1 -1
- package/cjs/form/file-upload/dropzone/FileUploadDropzone.js +1 -1
- package/cjs/form/file-upload/dropzone/FileUploadDropzone.js.map +1 -1
- package/cjs/tooltip/Tooltip.js +1 -1
- package/cjs/tooltip/Tooltip.js.map +1 -1
- package/cjs/utils/i18n/locales/nb.d.ts +75 -154
- package/cjs/utils/i18n/locales/nb.js +75 -154
- package/cjs/utils/i18n/locales/nb.js.map +1 -1
- package/esm/data/table/helpers/table-grid-nav.d.ts +9 -15
- package/esm/data/table/helpers/table-grid-nav.js +18 -25
- package/esm/data/table/helpers/table-grid-nav.js.map +1 -1
- package/esm/data/table/helpers/table-keyboard.d.ts +1 -1
- package/esm/data/table/helpers/table-keyboard.js +1 -6
- package/esm/data/table/helpers/table-keyboard.js.map +1 -1
- package/esm/data/table/root/DataTableRoot.d.ts +41 -4
- package/esm/data/table/root/DataTableRoot.js +10 -6
- package/esm/data/table/root/DataTableRoot.js.map +1 -1
- package/esm/data/table/root/useTableKeyboardNav.d.ts +1 -1
- package/esm/data/table/root/useTableKeyboardNav.js +32 -19
- package/esm/data/table/root/useTableKeyboardNav.js.map +1 -1
- package/esm/data/table/td/DataTableTd.d.ts +5 -4
- package/esm/data/table/td/DataTableTd.js +2 -2
- package/esm/data/table/td/DataTableTd.js.map +1 -1
- package/esm/data/token-filter/AutoSuggest.d.ts +9 -0
- package/esm/data/token-filter/AutoSuggest.js +20 -0
- package/esm/data/token-filter/AutoSuggest.js.map +1 -0
- package/esm/data/token-filter/AutoSuggest.types.d.ts +12 -0
- package/esm/data/token-filter/AutoSuggest.types.js +2 -0
- package/esm/data/token-filter/AutoSuggest.types.js.map +1 -0
- package/esm/data/token-filter/TokenFilter.d.ts +11 -0
- package/esm/data/token-filter/TokenFilter.js +66 -0
- package/esm/data/token-filter/TokenFilter.js.map +1 -0
- package/esm/data/token-filter/TokenFilter.types.d.ts +52 -0
- package/esm/data/token-filter/TokenFilter.types.js +2 -0
- package/esm/data/token-filter/TokenFilter.types.js.map +1 -0
- package/esm/data/token-filter/helpers/generate-autocomplete-options.d.ts +24 -0
- package/esm/data/token-filter/helpers/generate-autocomplete-options.js +195 -0
- package/esm/data/token-filter/helpers/generate-autocomplete-options.js.map +1 -0
- package/esm/data/token-filter/helpers/grouping.d.ts +28 -0
- package/esm/data/token-filter/helpers/grouping.js +59 -0
- package/esm/data/token-filter/helpers/grouping.js.map +1 -0
- package/esm/data/token-filter/helpers/operators.d.ts +22 -0
- package/esm/data/token-filter/helpers/operators.js +60 -0
- package/esm/data/token-filter/helpers/operators.js.map +1 -0
- package/esm/data/token-filter/helpers/parse-query-text.d.ts +25 -0
- package/esm/data/token-filter/helpers/parse-query-text.js +44 -0
- package/esm/data/token-filter/helpers/parse-query-text.js.map +1 -0
- package/esm/data/token-filter/helpers/query-builder.d.ts +20 -0
- package/esm/data/token-filter/helpers/query-builder.js +34 -0
- package/esm/data/token-filter/helpers/query-builder.js.map +1 -0
- package/esm/data/token-filter/helpers/text-matching.d.ts +16 -0
- package/esm/data/token-filter/helpers/text-matching.js +45 -0
- package/esm/data/token-filter/helpers/text-matching.js.map +1 -0
- package/esm/form/combobox/Input/InputController.js +1 -1
- package/esm/form/combobox/Input/InputController.js.map +1 -1
- package/esm/form/file-upload/dropzone/FileUploadDropzone.js +1 -1
- package/esm/form/file-upload/dropzone/FileUploadDropzone.js.map +1 -1
- package/esm/tooltip/Tooltip.js +2 -2
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/utils/i18n/locales/nb.d.ts +75 -154
- package/esm/utils/i18n/locales/nb.js +75 -154
- package/esm/utils/i18n/locales/nb.js.map +1 -1
- package/package.json +3 -3
- package/src/data/table/helpers/table-grid-nav.test.ts +659 -0
- package/src/data/table/helpers/table-grid-nav.ts +19 -38
- package/src/data/table/helpers/table-keyboard.ts +1 -10
- package/src/data/table/root/DataTableRoot.tsx +50 -10
- package/src/data/table/root/useTableKeyboardNav.ts +35 -23
- package/src/data/table/td/DataTableTd.tsx +13 -6
- package/src/data/token-filter/AutoSuggest.tsx +55 -0
- package/src/data/token-filter/AutoSuggest.types.ts +14 -0
- package/src/data/token-filter/TokenFilter.tsx +129 -0
- package/src/data/token-filter/TokenFilter.types.ts +85 -0
- package/src/data/token-filter/helpers/generate-autocomplete-options.test.ts +896 -0
- package/src/data/token-filter/helpers/generate-autocomplete-options.ts +289 -0
- package/src/data/token-filter/helpers/grouping.test.ts +206 -0
- package/src/data/token-filter/helpers/grouping.ts +73 -0
- package/src/data/token-filter/helpers/operators.test.ts +281 -0
- package/src/data/token-filter/helpers/operators.ts +91 -0
- package/src/data/token-filter/helpers/parse-query-text.test.ts +201 -0
- package/src/data/token-filter/helpers/parse-query-text.ts +86 -0
- package/src/data/token-filter/helpers/query-builder.test.ts +126 -0
- package/src/data/token-filter/helpers/query-builder.ts +41 -0
- package/src/data/token-filter/helpers/text-matching.test.ts +125 -0
- package/src/data/token-filter/helpers/text-matching.ts +58 -0
- package/src/form/combobox/Input/InputController.tsx +0 -1
- package/src/form/file-upload/dropzone/FileUploadDropzone.tsx +0 -1
- package/src/tooltip/Tooltip.tsx +3 -3
- package/src/utils/i18n/locales/nb.ts +4 -83
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.TokenFilter = void 0;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const popover_1 = require("../../popover");
|
|
39
|
+
const helpers_1 = require("../../utils/helpers");
|
|
40
|
+
const AutoSuggest_1 = require("./AutoSuggest");
|
|
41
|
+
const generate_autocomplete_options_1 = require("./helpers/generate-autocomplete-options");
|
|
42
|
+
const parse_query_text_1 = require("./helpers/parse-query-text");
|
|
43
|
+
exports.TokenFilter = (0, react_1.forwardRef)(({ query, className, filteringProperties, filteringOptions }, ref) => {
|
|
44
|
+
const [inputAnchor, setInputAnchor] = (0, react_1.useState)(null);
|
|
45
|
+
const [filterText, setFilterText] = (0, react_1.useState)("");
|
|
46
|
+
const { properties, options } = derrivedFilterState(filteringProperties, filteringOptions);
|
|
47
|
+
const queryState = (0, parse_query_text_1.parseQueryText)(filterText, properties);
|
|
48
|
+
const autoCompleteOptions = (0, generate_autocomplete_options_1.generateAutoCompleteOptions)(queryState, properties, options);
|
|
49
|
+
const handleSelectOption = (value) => {
|
|
50
|
+
setFilterText(value);
|
|
51
|
+
setCustomOpen(false);
|
|
52
|
+
};
|
|
53
|
+
const [customOpen, setCustomOpen] = (0, react_1.useState)(false);
|
|
54
|
+
return (react_1.default.createElement("div", { ref: ref, className: (0, helpers_1.cl)("aksel-property-filter", className), role: "search" },
|
|
55
|
+
react_1.default.createElement("input", { type: "text", className: "aksel-property-filter__input", placeholder: "Type to filter...", ref: setInputAnchor, value: filterText, onChange: (e) => setFilterText(e.target.value), onFocus: () => setCustomOpen(true) }),
|
|
56
|
+
react_1.default.createElement(popover_1.Popover, { anchorEl: inputAnchor, open: customOpen, onClose: () => {
|
|
57
|
+
setFilterText("");
|
|
58
|
+
setCustomOpen(false);
|
|
59
|
+
} },
|
|
60
|
+
react_1.default.createElement(AutoSuggest_1.AutoSuggest
|
|
61
|
+
/* @ts-expect-error TODO: handle conversion better */
|
|
62
|
+
, {
|
|
63
|
+
/* @ts-expect-error TODO: handle conversion better */
|
|
64
|
+
options: autoCompleteOptions.options, onSelect: handleSelectOption })),
|
|
65
|
+
query.tokens.map((token, index) => {
|
|
66
|
+
return (react_1.default.createElement("div", { key: index, className: "aksel-property-filter__token" },
|
|
67
|
+
react_1.default.createElement("strong", null, token.propertyKey),
|
|
68
|
+
" ",
|
|
69
|
+
token.operator,
|
|
70
|
+
" "));
|
|
71
|
+
}),
|
|
72
|
+
react_1.default.createElement("ul", null, filteringProperties.map((prop) => (react_1.default.createElement("li", { key: prop.key }, prop.propertyLabel)))),
|
|
73
|
+
react_1.default.createElement("pre", null, JSON.stringify(queryState, null, 2)),
|
|
74
|
+
react_1.default.createElement("pre", null, JSON.stringify(autoCompleteOptions, null, 2))));
|
|
75
|
+
});
|
|
76
|
+
function derrivedFilterState(filteringProperties, filteringOptions) {
|
|
77
|
+
var _a, _b, _c;
|
|
78
|
+
const propertyMap = new Map();
|
|
79
|
+
for (const property of filteringProperties) {
|
|
80
|
+
propertyMap.set(property.key, {
|
|
81
|
+
propertyKey: property.key,
|
|
82
|
+
propertyLabel: (_a = property === null || property === void 0 ? void 0 : property.propertyLabel) !== null && _a !== void 0 ? _a : "",
|
|
83
|
+
groupValuesLabel: (_b = property === null || property === void 0 ? void 0 : property.groupValuesLabel) !== null && _b !== void 0 ? _b : "",
|
|
84
|
+
propertyGroup: property === null || property === void 0 ? void 0 : property.group,
|
|
85
|
+
operators: (_c = property === null || property === void 0 ? void 0 : property.operators) !== null && _c !== void 0 ? _c : [],
|
|
86
|
+
/* defaultOperator: property?.defaultOperator ?? '=', */
|
|
87
|
+
externalProperty: property,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const internalOptions = filteringOptions.map((option) => {
|
|
91
|
+
var _a, _b, _c, _d, _e;
|
|
92
|
+
return ({
|
|
93
|
+
property: (_a = propertyMap.get(option.propertyKey)) !== null && _a !== void 0 ? _a : null,
|
|
94
|
+
value: option.value,
|
|
95
|
+
label: (_c = (_b = option.label) !== null && _b !== void 0 ? _b : option.value) !== null && _c !== void 0 ? _c : "",
|
|
96
|
+
tags: (_d = option.tags) !== null && _d !== void 0 ? _d : [],
|
|
97
|
+
filteringTags: (_e = option.filteringTags) !== null && _e !== void 0 ? _e : [],
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
return { properties: [...propertyMap.values()], options: internalOptions };
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=TokenFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenFilter.js","sourceRoot":"","sources":["../../../src/data/token-filter/TokenFilter.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAoD;AACpD,2CAAwC;AACxC,iDAAyC;AACzC,+CAA4C;AAQ5C,2FAAsF;AACtF,iEAA4D;AAU/C,QAAA,WAAW,GAAG,IAAA,kBAAU,EACnC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,EAAE,GAAG,EAAE,EAAE;IACnE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,EAC5C,IAAI,CACL,CAAC;IAEF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAS,EAAE,CAAC,CAAC;IACzD,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,mBAAmB,CACjD,mBAAmB,EACnB,gBAAgB,CACjB,CAAC;IAEF,MAAM,UAAU,GAAG,IAAA,iCAAc,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAE1D,MAAM,mBAAmB,GAAG,IAAA,2DAA2B,EACrD,UAAU,EACV,UAAU,EACV,OAAO,CACR,CAAC;IAEF,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAE,EAAE;QAC3C,aAAa,CAAC,KAAK,CAAC,CAAC;QACrB,aAAa,CAAC,KAAK,CAAC,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,EAAE;YACvB,aAAa,EAAE,MAAA,MAAM,CAAC,aAAa,mCAAI,EAAE;SAC1C,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"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
type QueryFilterOperator = "<" | "<=" | ">" | ">=" | ":" | "!:" | "=" | "!=" | "^" | "!^" | (string & {});
|
|
2
|
+
type QueryFilterOperation = "and" | "or";
|
|
3
|
+
type QueryFilterToken = {
|
|
4
|
+
propertyKey: string;
|
|
5
|
+
operator: QueryFilterOperator;
|
|
6
|
+
value: any;
|
|
7
|
+
};
|
|
8
|
+
type QueryFilterQuery = {
|
|
9
|
+
tokens: QueryFilterToken[];
|
|
10
|
+
operation: QueryFilterOperation;
|
|
11
|
+
};
|
|
12
|
+
type QueryFilteringOption = {
|
|
13
|
+
propertyKey: string;
|
|
14
|
+
value: any;
|
|
15
|
+
label?: string;
|
|
16
|
+
tags?: string[];
|
|
17
|
+
filteringTags?: string[];
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
};
|
|
20
|
+
type QueryFilteringOptions = QueryFilteringOption[];
|
|
21
|
+
type QueryFilteringOptionGroup = {
|
|
22
|
+
label: string;
|
|
23
|
+
options: QueryFilteringOptions;
|
|
24
|
+
};
|
|
25
|
+
type QueryFilteringScopedOperator = string | {
|
|
26
|
+
operator: string;
|
|
27
|
+
tokenType: "single" | "multiple";
|
|
28
|
+
};
|
|
29
|
+
type QueryFilteringProperty = {
|
|
30
|
+
key: string;
|
|
31
|
+
propertyLabel: string;
|
|
32
|
+
groupValuesLabel?: string;
|
|
33
|
+
group?: string;
|
|
34
|
+
operators?: QueryFilteringScopedOperator[];
|
|
35
|
+
};
|
|
36
|
+
type QueryFilteringProperties = QueryFilteringProperty[];
|
|
37
|
+
type ParsedProperty = {
|
|
38
|
+
propertyKey: string;
|
|
39
|
+
propertyLabel: string;
|
|
40
|
+
groupValuesLabel: string;
|
|
41
|
+
propertyGroup: string;
|
|
42
|
+
operators: QueryFilteringScopedOperator[];
|
|
43
|
+
externalProperty: QueryFilteringProperty;
|
|
44
|
+
};
|
|
45
|
+
type ParsedOption = {
|
|
46
|
+
property: ParsedProperty | null;
|
|
47
|
+
value: any;
|
|
48
|
+
label: string;
|
|
49
|
+
tags: string[];
|
|
50
|
+
filteringTags: string[];
|
|
51
|
+
};
|
|
52
|
+
export type { QueryFilterOperator, QueryFilterQuery, QueryFilteringOptions, QueryFilteringProperty, QueryFilterOperation, QueryFilteringProperties, ParsedProperty, ParsedOption, QueryFilteringOption, QueryFilteringOptionGroup, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenFilter.types.js","sourceRoot":"","sources":["../../../src/data/token-filter/TokenFilter.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AutoCompleteOption, OptionGroup } from "../AutoSuggest.types";
|
|
2
|
+
import type { ParsedOption, ParsedProperty } from "../TokenFilter.types";
|
|
3
|
+
import { type ParsedText } from "./parse-query-text";
|
|
4
|
+
/**
|
|
5
|
+
* Generates "options" to be used as autosuggest-ottion based on the current query state.
|
|
6
|
+
*
|
|
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")
|
|
11
|
+
*
|
|
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).
|
|
16
|
+
*/
|
|
17
|
+
declare function generateAutoCompleteOptions(queryState: ParsedText, filteringProperties?: ParsedProperty[], filteringOptions?: ParsedOption[]): {
|
|
18
|
+
value: string;
|
|
19
|
+
options: OptionGroup<AutoCompleteOption>[];
|
|
20
|
+
} | {
|
|
21
|
+
value: string;
|
|
22
|
+
options: OptionGroup<ParsedProperty>[];
|
|
23
|
+
};
|
|
24
|
+
export { generateAutoCompleteOptions };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateAutoCompleteOptions = generateAutoCompleteOptions;
|
|
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");
|
|
8
|
+
/**
|
|
9
|
+
* Generates "options" to be used as autosuggest-ottion based on the current query state.
|
|
10
|
+
*
|
|
11
|
+
* The query parser recognizes three states:
|
|
12
|
+
* - "property": User has selected/matched a property and operator ("Status = active")
|
|
13
|
+
* - "operator": User has matched a property but is typing the operator ("Status" or "Status !")
|
|
14
|
+
* - "free-text": User is typing freely without a property match (e.g., "act" or "!: test")
|
|
15
|
+
*
|
|
16
|
+
* @returns
|
|
17
|
+
* - value: The canonical query string representation for the current state.
|
|
18
|
+
* Used by the UI to determine cursor position and input replacement.
|
|
19
|
+
* - options: Grouped suggestions to display (properties, operators, or values).
|
|
20
|
+
*/
|
|
21
|
+
function generateAutoCompleteOptions(queryState, filteringProperties = [], filteringOptions = []) {
|
|
22
|
+
var _a;
|
|
23
|
+
/* State: Property and operator are matched, suggest values */
|
|
24
|
+
if (queryState.step === "property") {
|
|
25
|
+
const filterText = queryState.value || "";
|
|
26
|
+
return {
|
|
27
|
+
value: queryState.value,
|
|
28
|
+
options: createValueSuggestions(filteringOptions, queryState.operator, filterText, queryState.property),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/* State: Property matched, but operator is incomplete */
|
|
32
|
+
if (queryState.step === "operator") {
|
|
33
|
+
const operators = filterOperatorsByPrefix(getValidOperatorsForProperty(queryState.property), queryState.operatorPrefix);
|
|
34
|
+
const partialQuery = (0, query_builder_1.buildQueryString)(queryState.property.propertyLabel, queryState.operatorPrefix, "");
|
|
35
|
+
/**
|
|
36
|
+
* Edge case: User typed an invalid operator prefix that doesn't match any operators.
|
|
37
|
+
* This can happen when typing characters that don't start any valid operator.
|
|
38
|
+
* Return empty suggestions gracefully - the UI will show "no results".
|
|
39
|
+
*
|
|
40
|
+
* TODO: When per-property operator configuration is implemented,
|
|
41
|
+
* this could also occur when a property restricts which operators are valid.
|
|
42
|
+
*/
|
|
43
|
+
if (operators.length === 0) {
|
|
44
|
+
return {
|
|
45
|
+
value: partialQuery,
|
|
46
|
+
options: [],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
value: partialQuery,
|
|
51
|
+
options: generateOperatorSuggestions(queryState.property, queryState.operatorPrefix),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/*
|
|
55
|
+
* Edge case: Input starts with operator but has no value yet (user typed just "!=")
|
|
56
|
+
* Wait for value before showing suggestions
|
|
57
|
+
*/
|
|
58
|
+
if (!queryState.value && queryState.operator) {
|
|
59
|
+
return {
|
|
60
|
+
value: "",
|
|
61
|
+
options: [],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/* Empty input: Show all properties */
|
|
65
|
+
if (!queryState.value) {
|
|
66
|
+
return {
|
|
67
|
+
value: "",
|
|
68
|
+
options: generatePropertySuggestions(filteringProperties),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/*
|
|
72
|
+
* Free-text search: Show matching values across all properties
|
|
73
|
+
* Use the detected operator if input started with one (e.g., "!= test"), otherwise default to "="
|
|
74
|
+
*/
|
|
75
|
+
return {
|
|
76
|
+
value: queryState.value,
|
|
77
|
+
options: createValueSuggestions(filteringOptions, (_a = queryState.operator) !== null && _a !== void 0 ? _a : "=", queryState.value),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns the valid operators for a given property.
|
|
82
|
+
* Extracts operators from the property's custom operator configuration.
|
|
83
|
+
* If none are configured, falls back to all available operators.
|
|
84
|
+
*
|
|
85
|
+
* The QueryFilteringScopedOperator can be a simple string (e.g., "=")
|
|
86
|
+
* or an object with operator and tokenType (e.g., { operator: ":", tokenType: "single" }).
|
|
87
|
+
* This function normalizes both formats and returns just the operator strings.
|
|
88
|
+
*
|
|
89
|
+
* @returns Array of valid operators for the property
|
|
90
|
+
*
|
|
91
|
+
* 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.
|
|
92
|
+
*/
|
|
93
|
+
function getValidOperatorsForProperty(property) {
|
|
94
|
+
const { operators } = property;
|
|
95
|
+
/* If no operators configured, return all available operators */
|
|
96
|
+
if (!operators || operators.length === 0) {
|
|
97
|
+
return operators_1.QUERY_OPERATORS;
|
|
98
|
+
}
|
|
99
|
+
/*
|
|
100
|
+
* Extract operator strings from QueryFilteringScopedOperator format
|
|
101
|
+
* Handle both simple strings and objects with operator property
|
|
102
|
+
*/
|
|
103
|
+
const operatorStrings = operators.map((op) => typeof op === "string" ? op : op.operator);
|
|
104
|
+
/* Filter to only valid QUERY_OPERATORS to ensure type safety */
|
|
105
|
+
return operatorStrings.filter((op) => operators_1.QUERY_OPERATORS.includes(op));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Filters the list of operators based on the provided prefix.
|
|
109
|
+
* If the prefix is empty, all operators are returned.
|
|
110
|
+
*/
|
|
111
|
+
function filterOperatorsByPrefix(operators, prefix) {
|
|
112
|
+
if (!prefix) {
|
|
113
|
+
return operators;
|
|
114
|
+
}
|
|
115
|
+
return operators.filter((operator) => operator.startsWith(prefix));
|
|
116
|
+
}
|
|
117
|
+
function generatePropertySuggestions(filteringProperties = [], filterText = "") {
|
|
118
|
+
const filteredProperties = [];
|
|
119
|
+
for (const property of filteringProperties) {
|
|
120
|
+
if (!property) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if ((0, text_matching_1.matchesFilterText)([
|
|
124
|
+
property.propertyLabel,
|
|
125
|
+
property.groupValuesLabel,
|
|
126
|
+
property.propertyGroup,
|
|
127
|
+
].filter(Boolean), filterText)) {
|
|
128
|
+
filteredProperties.push(property);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return (0, grouping_1.createGroups)(filteredProperties, (property) => property.propertyGroup, "Properties");
|
|
132
|
+
}
|
|
133
|
+
function generateOperatorSuggestions(property, operatorPrefix = "") {
|
|
134
|
+
const operators = filterOperatorsByPrefix(getValidOperatorsForProperty(property), operatorPrefix);
|
|
135
|
+
if (operators.length === 0) {
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
return [
|
|
139
|
+
{
|
|
140
|
+
label: "Operators",
|
|
141
|
+
options: operators.map((operator) => {
|
|
142
|
+
var _a;
|
|
143
|
+
return ({
|
|
144
|
+
value: (0, query_builder_1.buildQueryString)(property.propertyLabel, operator, ""),
|
|
145
|
+
label: (0, query_builder_1.buildQueryString)(property.propertyLabel, operator, ""),
|
|
146
|
+
description: (_a = query_builder_1.OPERATOR_LABELS[operator]) !== null && _a !== void 0 ? _a : "",
|
|
147
|
+
});
|
|
148
|
+
}),
|
|
149
|
+
},
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Creates value suggestions for autocomplete.
|
|
154
|
+
* When scopedProperty is provided, only shows values for that property (single group).
|
|
155
|
+
* When scopedProperty is omitted, searches across all properties (multiple groups).
|
|
156
|
+
*/
|
|
157
|
+
function createValueSuggestions(filteringOptions = [], operator, filterText = "", scopedProperty) {
|
|
158
|
+
var _a, _b;
|
|
159
|
+
const groups = {};
|
|
160
|
+
for (const option of filteringOptions) {
|
|
161
|
+
if (!(option === null || option === void 0 ? void 0 : option.property)) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
/* If scoped to a property, filter to only that property's options */
|
|
165
|
+
if (scopedProperty && option.property !== scopedProperty) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
/* Build search fields */
|
|
169
|
+
const searchFields = [
|
|
170
|
+
option.label,
|
|
171
|
+
...((_a = option.tags) !== null && _a !== void 0 ? _a : []),
|
|
172
|
+
...((_b = option.filteringTags) !== null && _b !== void 0 ? _b : []),
|
|
173
|
+
];
|
|
174
|
+
if (!scopedProperty) {
|
|
175
|
+
searchFields.push(option.property.propertyLabel);
|
|
176
|
+
}
|
|
177
|
+
const matches = (0, text_matching_1.matchesFilterText)(searchFields.filter(Boolean), filterText);
|
|
178
|
+
if (!matches) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
const groupLabel = option.property.groupValuesLabel || "Values";
|
|
182
|
+
if (!groups[groupLabel]) {
|
|
183
|
+
groups[groupLabel] = {
|
|
184
|
+
label: groupLabel,
|
|
185
|
+
options: [],
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
groups[groupLabel].options.push({
|
|
189
|
+
value: (0, query_builder_1.buildQueryString)(option.property.propertyLabel, operator, option.value),
|
|
190
|
+
label: option.label,
|
|
191
|
+
tags: option.tags,
|
|
192
|
+
filteringTags: option.filteringTags,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
return Object.values(groups).filter((group) => group.options.length > 0);
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=generate-autocomplete-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-autocomplete-options.js","sourceRoot":"","sources":["../../../../src/data/token-filter/helpers/generate-autocomplete-options.ts"],"names":[],"mappings":";;AAgSS,kEAA2B;AA1RpC,yCAA0C;AAC1C,2CAA8C;AAE9C,mDAAoE;AACpE,mDAAoD;AAEpD;;;;;;;;;;;;GAYG;AACH,SAAS,2BAA2B,CAClC,UAAsB,EACtB,sBAAwC,EAAE,EAC1C,mBAAmC,EAAE;;IAErC,8DAA8D;IAC9D,IAAI,UA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,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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ParsedProperty, QueryFilterOperator } from "../TokenFilter.types";
|
|
2
|
+
type ParsedText = {
|
|
3
|
+
/** User has typed property + complete operator + value (e.g., "Status != active") */
|
|
4
|
+
step: "property";
|
|
5
|
+
property: ParsedProperty;
|
|
6
|
+
operator: QueryFilterOperator;
|
|
7
|
+
value: string;
|
|
8
|
+
} | {
|
|
9
|
+
/** User is typing the operator after property (e.g., "Status !") */
|
|
10
|
+
step: "operator";
|
|
11
|
+
property: ParsedProperty;
|
|
12
|
+
operatorPrefix: string;
|
|
13
|
+
} | {
|
|
14
|
+
/** No property match; treat as free-text search */
|
|
15
|
+
step: "free-text";
|
|
16
|
+
value: string;
|
|
17
|
+
operator?: QueryFilterOperator;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Parse user input text to extract property, operator, and value components.
|
|
21
|
+
* Handles partial input (e.g., user typing "Status !" to complete the operator).
|
|
22
|
+
*/
|
|
23
|
+
declare function parseQueryText(filteringText: string, filteringProperties: ParsedProperty[]): ParsedText;
|
|
24
|
+
export { parseQueryText };
|
|
25
|
+
export type { ParsedText };
|