@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
@@ -8,6 +8,10 @@ import { DataTableThead, type DataTableTheadProps } from "../thead/DataTableThea
8
8
  import { DataTableTr, type DataTableTrProps } from "../tr/DataTableTr";
9
9
  interface DataTableProps extends React.HTMLAttributes<HTMLTableElement> {
10
10
  children: React.ReactNode;
11
+ /**
12
+ * Controls vertical cell padding.
13
+ * @default "normal"
14
+ */
11
15
  rowDensity?: "condensed" | "normal" | "spacious";
12
16
  /**
13
17
  * Zebra striped table
@@ -16,6 +20,8 @@ interface DataTableProps extends React.HTMLAttributes<HTMLTableElement> {
16
20
  zebraStripes?: boolean;
17
21
  /**
18
22
  * Truncate content in cells and show ellipsis for overflowed text.
23
+ *
24
+ * **NB:** When using `layout="auto"`, you have to manually set a `maxWidth` on columns that should be truncated.
19
25
  * @default true
20
26
  */
21
27
  truncateContent?: boolean;
@@ -30,6 +36,21 @@ interface DataTableProps extends React.HTMLAttributes<HTMLTableElement> {
30
36
  * Requires `withKeyboardNav` to be `true`.
31
37
  */
32
38
  shouldBlockNavigation?: (event: KeyboardEvent) => boolean;
39
+ /**
40
+ * Controls table layout.
41
+ *
42
+ * ### fixed
43
+ * Gives you full control of column widths. This is required for resizable columns.
44
+ *
45
+ * ### auto
46
+ * Makes the columns resize automatically based on the content.
47
+ * The table will take up at least 100% of available width.
48
+ *
49
+ * **NB:** When using this with `truncateContent`, you have to manually
50
+ * set a `contentMaxWidth` on cells that should be truncated.
51
+ * @default "fixed"
52
+ */
53
+ layout?: "fixed" | "auto";
33
54
  }
34
55
  interface DataTableRootComponent extends React.ForwardRefExoticComponent<DataTableProps & React.RefAttributes<HTMLTableElement>> {
35
56
  /**
@@ -123,6 +144,12 @@ interface DataTableRootComponent extends React.ForwardRefExoticComponent<DataTab
123
144
  */
124
145
  Tfoot: typeof DataTableTfoot;
125
146
  }
147
+ /**
148
+ * TODO Component description etc.
149
+ *
150
+ * **NB:** To get sticky headers, you have to set a height restriction on the table container. You can use VStack for this:
151
+ * TODO example
152
+ */
126
153
  declare const DataTable: DataTableRootComponent;
127
154
  export { DataTable, DataTableCaption, DataTableTbody, DataTableTd, DataTableTfoot, DataTableTh, DataTableThead, DataTableTr, };
128
155
  export default DataTable;
@@ -63,8 +63,14 @@ Object.defineProperty(exports, "DataTableThead", { enumerable: true, get: functi
63
63
  const DataTableTr_1 = require("../tr/DataTableTr");
64
64
  Object.defineProperty(exports, "DataTableTr", { enumerable: true, get: function () { return DataTableTr_1.DataTableTr; } });
65
65
  const useTableKeyboardNav_1 = require("./useTableKeyboardNav");
66
+ /**
67
+ * TODO Component description etc.
68
+ *
69
+ * **NB:** To get sticky headers, you have to set a height restriction on the table container. You can use VStack for this:
70
+ * TODO example
71
+ */
66
72
  const DataTable = (0, react_1.forwardRef)((_a, forwardedRef) => {
67
- var { className, rowDensity = "normal", withKeyboardNav = false, zebraStripes = false, truncateContent = true, shouldBlockNavigation } = _a, rest = __rest(_a, ["className", "rowDensity", "withKeyboardNav", "zebraStripes", "truncateContent", "shouldBlockNavigation"]);
73
+ var { className, rowDensity = "normal", withKeyboardNav = false, zebraStripes = false, truncateContent = true, shouldBlockNavigation, layout = "fixed" } = _a, rest = __rest(_a, ["className", "rowDensity", "withKeyboardNav", "zebraStripes", "truncateContent", "shouldBlockNavigation", "layout"]);
68
74
  const [tableRef, setTableRef] = (0, react_1.useState)(null);
69
75
  const mergedRef = (0, hooks_1.useMergeRefs)(forwardedRef, setTableRef);
70
76
  const { tabIndex } = (0, useTableKeyboardNav_1.useTableKeyboardNav)(tableRef, {
@@ -73,7 +79,7 @@ const DataTable = (0, react_1.forwardRef)((_a, forwardedRef) => {
73
79
  });
74
80
  return (react_1.default.createElement("div", { className: "aksel-data-table__border-wrapper" },
75
81
  react_1.default.createElement("div", { className: "aksel-data-table__scroll-wrapper" },
76
- react_1.default.createElement("table", Object.assign({}, rest, { ref: mergedRef, className: (0, helpers_1.cl)("aksel-data-table", className), "data-zebra-stripes": zebraStripes, "data-truncate-content": truncateContent, "data-density": rowDensity, tabIndex: tabIndex })))));
82
+ react_1.default.createElement("table", Object.assign({}, rest, { ref: mergedRef, className: (0, helpers_1.cl)("aksel-data-table", className), "data-zebra-stripes": zebraStripes, "data-truncate-content": truncateContent, "data-density": rowDensity, "data-layout": layout, tabIndex: tabIndex })))));
77
83
  });
78
84
  exports.DataTable = DataTable;
79
85
  DataTable.Caption = DataTableCaption_1.DataTableCaption;
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableRoot.js","sourceRoot":"","sources":["../../../../src/data/table/root/DataTableRoot.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAoD;AACpD,oDAA4C;AAC5C,gDAAoD;AACpD,kEAGqC;AA4LnC,iGA9LA,mCAAgB,OA8LA;AA3LlB,4DAGiC;AAyL/B,+FA3LA,+BAAc,OA2LA;AAxLhB,mDAAuE;AAyLrE,4FAzLO,yBAAW,OAyLP;AAxLb,4DAGiC;AAsL/B,+FAxLA,+BAAc,OAwLA;AArLhB,mDAAuE;AAsLrE,4FAtLO,yBAAW,OAsLP;AArLb,4DAGiC;AAmL/B,+FArLA,+BAAc,OAqLA;AAlLhB,mDAAuE;AAmLrE,4FAnLO,yBAAW,OAmLP;AAlLb,+DAA4D;AA2H5D,MAAM,SAAS,GAAG,I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T,eAAe,kBACxB,UAAU,iBACX,MAAM,EACnB,QAAQ,EAAE,QAAQ,IAClB,CACE,CACF,CACP,CAAC;AACJ,CAAC,CACwB,CAAC;AAW1B,8BAAS;AATX,SAAS,CAAC,OAAO,GAAG,mCAAgB,CAAC;AACrC,SAAS,CAAC,KAAK,GAAG,+BAAc,CAAC;AACjC,SAAS,CAAC,KAAK,GAAG,+BAAc,CAAC;AACjC,SAAS,CAAC,EAAE,GAAG,yBAAW,CAAC;AAC3B,SAAS,CAAC,EAAE,GAAG,yBAAW,CAAC;AAC3B,SAAS,CAAC,EAAE,GAAG,yBAAW,CAAC;AAC3B,SAAS,CAAC,KAAK,GAAG,+BAAc,CAAC;AAYjC,kBAAe,SAAS,CAAC"}
@@ -1,10 +1,11 @@
1
1
  import React from "react";
2
- interface DataTableTdProps extends React.HTMLAttributes<HTMLTableCellElement> {
2
+ interface DataTableTdProps extends React.TdHTMLAttributes<HTMLTableCellElement> {
3
3
  /**
4
- * TODO: Shouldnt be needed to declare these here... But getting type-errors if not
4
+ * Sets a max-width on the content wrapper div inside the cell.
5
+ * This is only needed when using `layout="auto"` together with
6
+ * `truncateContent` on `<DataTable>` and you want the cell to be truncated.
5
7
  */
6
- colSpan?: number;
7
- rowSpan?: number;
8
+ contentMaxWidth?: number | `${number}${string}`;
8
9
  }
9
10
  declare const DataTableTd: React.ForwardRefExoticComponent<DataTableTdProps & React.RefAttributes<HTMLTableCellElement>>;
10
11
  export { DataTableTd };
@@ -48,9 +48,9 @@ exports.DataTableTd = void 0;
48
48
  const react_1 = __importStar(require("react"));
49
49
  const helpers_1 = require("../../../utils/helpers");
50
50
  const DataTableTd = (0, react_1.forwardRef)((_a, forwardedRef) => {
51
- var { className, children } = _a, rest = __rest(_a, ["className", "children"]);
51
+ var { className, children, contentMaxWidth } = _a, rest = __rest(_a, ["className", "children", "contentMaxWidth"]);
52
52
  return (react_1.default.createElement("td", Object.assign({}, rest, { ref: forwardedRef, className: (0, helpers_1.cl)("aksel-data-table__td", className) }),
53
- react_1.default.createElement("div", null, children)));
53
+ react_1.default.createElement("div", { style: { maxWidth: contentMaxWidth } }, children)));
54
54
  });
55
55
  exports.DataTableTd = DataTableTd;
56
56
  //# sourceMappingURL=DataTableTd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableTd.js","sourceRoot":"","sources":["../../../../src/data/table/td/DataTableTd.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0C;AAC1C,oDAA4C;AAU5C,MAAM,WAAW,GAAG,IAAA,kBAAU,EAC5B,CAAC,EAAgC,EAAE,YAAY,EAAE,EAAE;QAAlD,EAAE,SAAS,EAAE,QAAQ,OAAW,EAAN,IAAI,cAA9B,yBAAgC,CAAF;IAC7B,OAAO,CACL,sDACM,IAAI,IACR,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,IAAA,YAAE,EAAC,sBAAsB,EAAE,SAAS,CAAC;QAEhD,2CAAM,QAAQ,CAAO,CAClB,CACN,CAAC;AACJ,CAAC,CACF,CAAC;AAEO,kCAAW"}
1
+ {"version":3,"file":"DataTableTd.js","sourceRoot":"","sources":["../../../../src/data/table/td/DataTableTd.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0C;AAC1C,oDAA4C;AAiB5C,MAAM,WAAW,GAAG,IAAA,kBAAU,EAC5B,CAAC,EAAiD,EAAE,YAAY,EAAE,EAAE;QAAnE,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,OAAW,EAAN,IAAI,cAA/C,4CAAiD,CAAF;IAC9C,OAAO,CACL,sDACM,IAAI,IACR,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,IAAA,YAAE,EAAC,sBAAsB,EAAE,SAAS,CAAC;QAEhD,uCAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAG,QAAQ,CAAO,CACxD,CACN,CAAC;AACJ,CAAC,CACF,CAAC;AAEO,kCAAW"}
@@ -1,19 +1,7 @@
1
1
  import React from "react";
2
- interface AutoSuggestOption {
3
- value: string;
4
- label: string;
5
- tags?: string[];
6
- filteringTags?: string[];
7
- description?: string;
8
- }
9
- interface AutoSuggestGroup {
10
- label: string;
11
- options: AutoSuggestOption[];
12
- }
2
+ import type { AutoCompleteOption, OptionGroup } from "./AutoSuggest.types";
13
3
  interface AutoSuggestProps {
14
- options: AutoSuggestGroup[];
15
- value: string;
16
- filterText: string;
4
+ options: OptionGroup<AutoCompleteOption>[];
17
5
  onSelect: (value: string) => void;
18
6
  className?: string;
19
7
  }
@@ -32,98 +32,22 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __rest = (this && this.__rest) || function (s, e) {
36
- var t = {};
37
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
38
- t[p] = s[p];
39
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
40
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
41
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
42
- t[p[i]] = s[p[i]];
43
- }
44
- return t;
45
- };
46
35
  Object.defineProperty(exports, "__esModule", { value: true });
47
36
  exports.AutoSuggest = void 0;
48
37
  const react_1 = __importStar(require("react"));
49
- const helpers_1 = require("../../utils/helpers");
50
- const AutoSuggest = (0, react_1.forwardRef)(({ options, value, filterText, onSelect, className }, ref) => {
51
- console.info({ options, value, filterText });
52
- /* const highlightedText = filterText === undefined ? value : filterText; */
53
- /* const filterValue = (value || "").toLowerCase();
54
-
55
- const filteredGroups = options
56
- .map((group) => ({
57
- ...group,
58
- options: group.options.filter((option) => {
59
- const searchableText = [
60
- option.label,
61
- option.description,
62
- ...(option.filteringTags ?? []),
63
- ...(option.tags ?? []),
64
- ]
65
- .filter(Boolean)
66
- .join(" ")
67
- .toLowerCase();
68
- return searchableText.includes(filterValue);
69
- }),
70
- }))
71
- .filter((group) => group.options.length > 0); */
72
- const { items } = useAutosuggestItems({ options, filterValue: filterText });
73
- console.info({ items });
74
- return (react_1.default.createElement("div", { ref: ref, className: (0, helpers_1.cl)("aksel-auto-suggest", className) }, options.map((group) => (react_1.default.createElement("div", { key: group.label, className: "aksel-auto-suggest__group" },
75
- react_1.default.createElement("div", { className: "aksel-auto-suggest__group-label" }, group.label),
76
- react_1.default.createElement("ul", { className: "aksel-auto-suggest__list" }, group.options.map((option) => (react_1.default.createElement("li", { key: option.value, className: "aksel-auto-suggest__item" },
77
- react_1.default.createElement("button", { type: "button", className: "aksel-auto-suggest__button", onClick: () => onSelect(option.value) },
78
- react_1.default.createElement("span", { className: "aksel-auto-suggest__label" }, option.label),
79
- option.description && (react_1.default.createElement("span", { className: "aksel-auto-suggest__description" }, option.description)),
80
- option.tags && option.tags.length > 0 && (react_1.default.createElement("div", { className: "aksel-auto-suggest__tags" }, option.tags.map((tag) => (react_1.default.createElement("span", { key: tag, className: "aksel-auto-suggest__tag" }, tag)))))))))))))));
38
+ const box_1 = require("../../primitives/box");
39
+ const stack_1 = require("../../primitives/stack");
40
+ const typography_1 = require("../../typography");
41
+ const AutoSuggest = (0, react_1.forwardRef)(({ options, onSelect }, ref) => {
42
+ return (react_1.default.createElement(box_1.Box, { ref: ref, padding: "space-6" }, options.map((group) => (react_1.default.createElement("div", { key: group.label },
43
+ react_1.default.createElement(typography_1.Label, { as: "div" }, group.label),
44
+ react_1.default.createElement(stack_1.VStack, { gap: "space-4" }, group.options.map((option) => {
45
+ return (react_1.default.createElement("div", { key: option.value },
46
+ react_1.default.createElement("button", { type: "button", onClick: () => onSelect(option.value) },
47
+ react_1.default.createElement("span", null, option.label),
48
+ option.description && react_1.default.createElement("span", null, option.description),
49
+ option.tags && option.tags.length > 0 && (react_1.default.createElement("div", null, option.tags.map((tag) => (react_1.default.createElement("span", { key: tag }, tag))))))));
50
+ })))))));
81
51
  });
82
52
  exports.AutoSuggest = AutoSuggest;
83
- function useAutosuggestItems({ options, filterValue }) {
84
- const { items } = (0, react_1.useMemo)(() => createItems(options), [options]);
85
- const filteredItems = (0, react_1.useMemo)(() => {
86
- const localFilteredItems = items;
87
- if (filterValue) {
88
- localFilteredItems.unshift({
89
- value: filterValue,
90
- type: "use-entered",
91
- label: `Use "${filterValue}"`,
92
- option: { value: filterValue },
93
- });
94
- }
95
- return localFilteredItems;
96
- }, [items, filterValue]);
97
- return { items: filteredItems };
98
- }
99
- function createItems(options) {
100
- const items = [];
101
- const itemToGroup = new WeakMap();
102
- for (const option of options) {
103
- if (isGroup(option)) {
104
- for (const item of flattenGroup(option, itemToGroup)) {
105
- items.push(item);
106
- }
107
- }
108
- else {
109
- items.push(Object.assign(Object.assign({}, option), { option }));
110
- }
111
- }
112
- return { items };
113
- }
114
- function flattenGroup(group, map) {
115
- var _a;
116
- const { options } = group, rest = __rest(group, ["options"]);
117
- const groupItem = Object.assign(Object.assign({}, rest), { type: "parent", option: group });
118
- const items = [groupItem];
119
- for (const option of options) {
120
- const childOption = Object.assign(Object.assign({}, option), { type: "child", disabled: (_a = option.disabled) !== null && _a !== void 0 ? _a : false, option, parent: group });
121
- items.push(childOption);
122
- map.set(childOption, groupItem);
123
- }
124
- return items;
125
- }
126
- function isGroup(optionOrGroup) {
127
- return "options" in optionOrGroup;
128
- }
129
53
  //# sourceMappingURL=AutoSuggest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AutoSuggest.js","sourceRoot":"","sources":["../../../src/data/token-filter/AutoSuggest.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAmD;AACnD,iDAAyC;AA2BzC,MAAM,WAAW,GAAG,IAAA,kBAAU,EAC5B,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,EAAE;IAC3D,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AO,EAAC,SAAS,IAC7B,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACtB,uCAAK,GAAG,EAAE,KAAK,CAAC,KAAK;QACnB,8BAAC,kBAAK,IAAC,EAAE,EAAC,KAAK,IAAE,KAAK,CAAC,KAAK,CAAS;QACrC,8BAAC,cAAM,IAAC,GAAG,EAAC,SAAS,IAClB,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YAC5B,OAAO,CACL,uCAAK,GAAG,EAAE,MAAM,CAAC,KAAK;gBACpB,0CACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC;oBAErC,4CAAO,MAAM,CAAC,KAAK,CAAQ;oBAC1B,MAAM,CAAC,WAAW,IAAI,4CAAO,MAAM,CAAC,WAAW,CAAQ;oBACvD,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CACxC,2CACG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CACxB,wCAAM,GAAG,EAAE,GAAG,IAAG,GAAG,CAAQ,CAC7B,CAAC,CACE,CACP,CACM,CACL,CACP,CAAC;QACJ,CAAC,CAAC,CACK,CACL,CACP,CAAC,CACE,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEO,kCAAW"}
@@ -0,0 +1,11 @@
1
+ interface OptionGroup<T> {
2
+ label: string;
3
+ options: T[];
4
+ }
5
+ interface AutoCompleteOption {
6
+ value: string;
7
+ label: string;
8
+ tags?: string[];
9
+ description?: string;
10
+ }
11
+ export type { AutoCompleteOption, OptionGroup };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=AutoSuggest.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoSuggest.types.js","sourceRoot":"","sources":["../../../src/data/token-filter/AutoSuggest.types.ts"],"names":[],"mappings":""}
@@ -7,5 +7,10 @@ type TokenFilterProps = {
7
7
  filteringOptions: QueryFilteringOptions;
8
8
  filteringProperties: QueryFilteringProperties;
9
9
  };
10
+ /**
11
+ * TODO:
12
+ * - Implement onChange handler to update query state when user selects an autocomplete option.
13
+ * - Handle token rendering and editing (e.g., show tokens for matched properties/operators/values, allow deleting tokens).
14
+ */
10
15
  export declare const TokenFilter: React.ForwardRefExoticComponent<TokenFilterProps & React.RefAttributes<HTMLDivElement>>;
11
16
  export {};
@@ -37,20 +37,32 @@ exports.TokenFilter = void 0;
37
37
  const react_1 = __importStar(require("react"));
38
38
  const popover_1 = require("../../popover");
39
39
  const helpers_1 = require("../../utils/helpers");
40
+ const AutoSuggest_1 = require("./AutoSuggest");
40
41
  const generate_autocomplete_options_1 = require("./helpers/generate-autocomplete-options");
41
42
  const parse_query_text_1 = require("./helpers/parse-query-text");
43
+ /**
44
+ * TODO:
45
+ * - Implement onChange handler to update query state when user selects an autocomplete option.
46
+ * - Handle token rendering and editing (e.g., show tokens for matched properties/operators/values, allow deleting tokens).
47
+ */
42
48
  exports.TokenFilter = (0, react_1.forwardRef)(({ query, className, filteringProperties, filteringOptions }, ref) => {
43
49
  const [inputAnchor, setInputAnchor] = (0, react_1.useState)(null);
44
50
  const [filterText, setFilterText] = (0, react_1.useState)("");
45
51
  const { properties, options } = derrivedFilterState(filteringProperties, filteringOptions);
46
52
  const queryState = (0, parse_query_text_1.parseQueryText)(filterText, properties);
47
53
  const autoCompleteOptions = (0, generate_autocomplete_options_1.generateAutoCompleteOptions)(queryState, properties, options);
48
- /* const handleSelectOption = (value: string) => {
49
- setFilterText(value);
50
- }; */
54
+ const handleSelectOption = (value) => {
55
+ setFilterText(value);
56
+ setCustomOpen(false);
57
+ };
58
+ const [customOpen, setCustomOpen] = (0, react_1.useState)(false);
51
59
  return (react_1.default.createElement("div", { ref: ref, className: (0, helpers_1.cl)("aksel-property-filter", className), role: "search" },
52
- 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) }),
53
- react_1.default.createElement(popover_1.Popover, { anchorEl: inputAnchor, open: filterText.length > 0, onClose: () => setFilterText("") }, "a"),
60
+ 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) }),
61
+ react_1.default.createElement(popover_1.Popover, { anchorEl: inputAnchor, open: customOpen, onClose: () => {
62
+ setFilterText("");
63
+ setCustomOpen(false);
64
+ } },
65
+ react_1.default.createElement(AutoSuggest_1.AutoSuggest, { options: autoCompleteOptions.options, onSelect: handleSelectOption })),
54
66
  query.tokens.map((token, index) => {
55
67
  return (react_1.default.createElement("div", { key: index, className: "aksel-property-filter__token" },
56
68
  react_1.default.createElement("strong", null, token.propertyKey),
@@ -59,11 +71,10 @@ exports.TokenFilter = (0, react_1.forwardRef)(({ query, className, filteringProp
59
71
  " "));
60
72
  }),
61
73
  react_1.default.createElement("ul", null, filteringProperties.map((prop) => (react_1.default.createElement("li", { key: prop.key }, prop.propertyLabel)))),
62
- react_1.default.createElement("pre", null, JSON.stringify(queryState, null, 2)),
63
74
  react_1.default.createElement("pre", null, JSON.stringify(autoCompleteOptions, null, 2))));
64
75
  });
65
76
  function derrivedFilterState(filteringProperties, filteringOptions) {
66
- var _a, _b;
77
+ var _a, _b, _c;
67
78
  const propertyMap = new Map();
68
79
  for (const property of filteringProperties) {
69
80
  propertyMap.set(property.key, {
@@ -71,19 +82,18 @@ function derrivedFilterState(filteringProperties, filteringOptions) {
71
82
  propertyLabel: (_a = property === null || property === void 0 ? void 0 : property.propertyLabel) !== null && _a !== void 0 ? _a : "",
72
83
  groupValuesLabel: (_b = property === null || property === void 0 ? void 0 : property.groupValuesLabel) !== null && _b !== void 0 ? _b : "",
73
84
  propertyGroup: property === null || property === void 0 ? void 0 : property.group,
74
- /* operators: (property?.operators ?? []).map(op => (typeof op === 'string' ? op : op.operator)), */
85
+ operators: (_c = property === null || property === void 0 ? void 0 : property.operators) !== null && _c !== void 0 ? _c : [],
75
86
  /* defaultOperator: property?.defaultOperator ?? '=', */
76
87
  externalProperty: property,
77
88
  });
78
89
  }
79
90
  const internalOptions = filteringOptions.map((option) => {
80
- var _a, _b, _c, _d, _e;
91
+ var _a, _b, _c, _d;
81
92
  return ({
82
93
  property: (_a = propertyMap.get(option.propertyKey)) !== null && _a !== void 0 ? _a : null,
83
94
  value: option.value,
84
95
  label: (_c = (_b = option.label) !== null && _b !== void 0 ? _b : option.value) !== null && _c !== void 0 ? _c : "",
85
96
  tags: (_d = option.tags) !== null && _d !== void 0 ? _d : [],
86
- filteringTags: (_e = option.filteringTags) !== null && _e !== void 0 ? _e : [],
87
97
  });
88
98
  });
89
99
  return { properties: [...propertyMap.values()], options: internalOptions };
@@ -1 +1 @@
1
- {"version":3,"file":"TokenFilter.js","sourceRoot":"","sources":["../../../src/data/token-filter/TokenFilter.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAoD;AACpD,2CAAwC;AACxC,iDAAyC;AAQzC,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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Q,CAAC,GAAG,EAAE;YAC5B,WAAW,EAAE,QAAQ,CAAC,GAAG;YACzB,aAAa,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,aAAa,mCAAI,EAAE;YAC5C,gBAAgB,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,gBAAgB,mCAAI,EAAE;YAClD,aAAa,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK;YAC9B,SAAS,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,SAAS,mCAAI,EAAE;YACpC,wDAAwD;YACxD,gBAAgB,EAAE,QAAQ;SAC3B,CAAC,CAAC;IACL,CAAC;IAED,MAAM,eAAe,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;;QAAC,OAAA,CAAC;YACxD,QAAQ,EAAE,MAAA,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,mCAAI,IAAI;YACrD,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,KAAK,EAAE,MAAA,MAAA,MAAM,CAAC,KAAK,mCAAI,MAAM,CAAC,KAAK,mCAAI,EAAE;YACzC,IAAI,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,EAAE;SACxB,CAAC,CAAA;KAAA,CAAC,CAAC;IAEJ,OAAO,EAAE,UAAU,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;AAC7E,CAAC"}
@@ -14,7 +14,6 @@ type QueryFilteringOption = {
14
14
  value: any;
15
15
  label?: string;
16
16
  tags?: string[];
17
- filteringTags?: string[];
18
17
  disabled?: boolean;
19
18
  };
20
19
  type QueryFilteringOptions = QueryFilteringOption[];
@@ -22,11 +21,16 @@ type QueryFilteringOptionGroup = {
22
21
  label: string;
23
22
  options: QueryFilteringOptions;
24
23
  };
24
+ type QueryFilteringScopedOperator = string | {
25
+ operator: string;
26
+ tokenType: "single" | "multiple";
27
+ };
25
28
  type QueryFilteringProperty = {
26
29
  key: string;
27
30
  propertyLabel: string;
28
- groupValuesLabel: string;
29
- group: string;
31
+ groupValuesLabel?: string;
32
+ group?: string;
33
+ operators?: QueryFilteringScopedOperator[];
30
34
  };
31
35
  type QueryFilteringProperties = QueryFilteringProperty[];
32
36
  type ParsedProperty = {
@@ -34,6 +38,7 @@ type ParsedProperty = {
34
38
  propertyLabel: string;
35
39
  groupValuesLabel: string;
36
40
  propertyGroup: string;
41
+ operators: QueryFilteringScopedOperator[];
37
42
  externalProperty: QueryFilteringProperty;
38
43
  };
39
44
  type ParsedOption = {
@@ -41,6 +46,5 @@ type ParsedOption = {
41
46
  value: any;
42
47
  label: string;
43
48
  tags: string[];
44
- filteringTags: string[];
45
49
  };
46
50
  export type { QueryFilterOperator, QueryFilterQuery, QueryFilteringOptions, QueryFilteringProperty, QueryFilterOperation, QueryFilteringProperties, ParsedProperty, ParsedOption, QueryFilteringOption, QueryFilteringOptionGroup, };
@@ -1,70 +1,22 @@
1
+ import type { AutoCompleteOption, OptionGroup } from "../AutoSuggest.types";
1
2
  import type { ParsedOption, ParsedProperty } from "../TokenFilter.types";
2
3
  import { type ParsedText } from "./parse-query-text";
3
- interface OptionGroup<T> {
4
- label: string;
5
- options: T[];
6
- }
7
- interface AutoCompleteOption {
8
- value: string;
9
- label: string;
10
- tags?: string[];
11
- filteringTags?: string[];
12
- description?: string;
13
- }
14
4
  /**
15
- * Grouping option for autocomplete suggestions structures:
16
- *
17
- * Step: "free-text" + empty value:
18
- * - Group: "Properties" with all properties.
19
- *
20
- * Step: "free-text" with non-empty value:
21
- * - Group: "Properties". All properties including the filter text in label or description or tags. String match.
22
- * - Group: "Values". All "property = value" combinations where either the property label or value label or description or tags include the filter text. String match.
23
- * - - Ignore all other operators than "=" for value suggestions.
24
- *
25
- * Step: "property" + empty value:
26
- * - Group: "Operators". All operators valid for the selected property.
27
- *
28
- * Step: "property" + non-empty value:
29
- * - Group: "Operators". All operators valid for the selected property with string match. Only relevant for multi letter operators like "!="
30
- *
31
- * Step: "operator" + empty value:
32
- * - Group: "<Property> values". All values valid for the selected property and operator. String match on value label, description and tags.
5
+ * Generates "options" to be used as autosuggest-ottion based on the current query state.
33
6
  *
34
- * Step: "operator" + non-empty value:
35
- * - Group: "<Property> values". All values valid for the selected property and operator with string match. String match on value label, description and tags.
7
+ * The query parser recognizes three states:
8
+ * - "property": User has selected/matched a property and operator ("Status = active")
9
+ * - "operator": User has matched a property but is typing the operator ("Status" or "Status !")
10
+ * - "free-text": User is typing freely without a property match (e.g., "act" or "!: test")
36
11
  *
37
- *
38
- * TODO:
39
- * - Handle custom groups
40
- * - Multi vs single-select: Allow operators for each options where user can define type to be enum: { operator: "=", tokenType: "enum" }. Enum-type options allow selecting multiple values, i.e state = ("active", "pending"))
41
- */
42
- /**
43
- * TODO: Update based on instructions above.
12
+ * @returns
13
+ * - value: The canonical query string representation for the current state.
14
+ * Used by the UI to determine cursor position and input replacement.
15
+ * - options: Grouped suggestions to display (properties, operators, or values).
44
16
  */
45
- declare function generateAutoCompleteOptions(queryState: ParsedText, filteringProperties?: ParsedProperty[], filteringOptions?: ParsedOption[]): {
46
- value: string;
47
- options: {
48
- label: string;
49
- options: {
50
- value: string;
51
- label: string;
52
- tags: string[];
53
- filteringTags: string[];
54
- }[];
55
- }[];
56
- } | {
57
- value: string;
58
- options: (OptionGroup<ParsedProperty> | {
59
- options: {
60
- value: string;
61
- label: string;
62
- description: string;
63
- }[];
64
- label: string;
65
- })[];
66
- } | {
17
+ type AutoCompleteResult = {
67
18
  value: string;
68
- options: (OptionGroup<ParsedProperty> | OptionGroup<AutoCompleteOption>)[];
19
+ options: OptionGroup<AutoCompleteOption>[];
69
20
  };
21
+ declare function generateAutoCompleteOptions(queryState: ParsedText, filteringProperties?: ParsedProperty[], filteringOptions?: ParsedOption[]): AutoCompleteResult;
70
22
  export { generateAutoCompleteOptions };