@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.
- package/cjs/data/table/root/DataTableRoot.d.ts +27 -0
- package/cjs/data/table/root/DataTableRoot.js +8 -2
- package/cjs/data/table/root/DataTableRoot.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 +2 -14
- package/cjs/data/token-filter/AutoSuggest.js +13 -89
- package/cjs/data/token-filter/AutoSuggest.js.map +1 -1
- package/cjs/data/token-filter/AutoSuggest.types.d.ts +11 -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 +5 -0
- package/cjs/data/token-filter/TokenFilter.js +20 -10
- package/cjs/data/token-filter/TokenFilter.js.map +1 -1
- package/cjs/data/token-filter/TokenFilter.types.d.ts +8 -4
- package/cjs/data/token-filter/helpers/generate-autocomplete-options.d.ts +13 -61
- package/cjs/data/token-filter/helpers/generate-autocomplete-options.js +152 -135
- package/cjs/data/token-filter/helpers/generate-autocomplete-options.js.map +1 -1
- 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 +1 -7
- package/cjs/data/token-filter/helpers/parse-query-text.js +5 -50
- package/cjs/data/token-filter/helpers/parse-query-text.js.map +1 -1
- 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/toggle-group/useToggleGroup.js +5 -3
- package/cjs/toggle-group/useToggleGroup.js.map +1 -1
- package/esm/data/table/root/DataTableRoot.d.ts +27 -0
- package/esm/data/table/root/DataTableRoot.js +8 -2
- package/esm/data/table/root/DataTableRoot.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 +2 -14
- package/esm/data/token-filter/AutoSuggest.js +14 -90
- package/esm/data/token-filter/AutoSuggest.js.map +1 -1
- package/esm/data/token-filter/AutoSuggest.types.d.ts +11 -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 +5 -0
- package/esm/data/token-filter/TokenFilter.js +20 -10
- package/esm/data/token-filter/TokenFilter.js.map +1 -1
- package/esm/data/token-filter/TokenFilter.types.d.ts +8 -4
- package/esm/data/token-filter/helpers/generate-autocomplete-options.d.ts +13 -61
- package/esm/data/token-filter/helpers/generate-autocomplete-options.js +152 -135
- package/esm/data/token-filter/helpers/generate-autocomplete-options.js.map +1 -1
- 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 +1 -7
- package/esm/data/token-filter/helpers/parse-query-text.js +2 -45
- package/esm/data/token-filter/helpers/parse-query-text.js.map +1 -1
- 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/toggle-group/useToggleGroup.js +6 -4
- package/esm/toggle-group/useToggleGroup.js.map +1 -1
- package/package.json +3 -3
- package/src/data/table/root/DataTableRoot.tsx +30 -1
- package/src/data/table/td/DataTableTd.tsx +13 -6
- package/src/data/token-filter/AutoSuggest.tsx +33 -163
- package/src/data/token-filter/AutoSuggest.types.ts +13 -0
- package/src/data/token-filter/TokenFilter.tsx +21 -13
- package/src/data/token-filter/TokenFilter.types.ts +8 -4
- package/src/data/token-filter/helpers/generate-autocomplete-options.test.ts +836 -0
- package/src/data/token-filter/helpers/generate-autocomplete-options.ts +241 -186
- 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 +4 -213
- package/src/data/token-filter/helpers/parse-query-text.ts +7 -69
- 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/toggle-group/useToggleGroup.ts +6 -5
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operators ordered by specificity (longest/most specific first)
|
|
3
|
+
* This ensures longer operators like ">=" and "<=" are matched
|
|
4
|
+
* before shorter ones like ">" and "<"
|
|
5
|
+
*/
|
|
6
|
+
const Operators = {
|
|
7
|
+
">=": null,
|
|
8
|
+
"<=": null,
|
|
9
|
+
"!=": null,
|
|
10
|
+
"!:": null,
|
|
11
|
+
"!^": null,
|
|
12
|
+
"=": null,
|
|
13
|
+
":": null,
|
|
14
|
+
"^": null,
|
|
15
|
+
">": null,
|
|
16
|
+
"<": null,
|
|
17
|
+
};
|
|
18
|
+
const QUERY_OPERATORS = Object.keys(Operators);
|
|
19
|
+
/**
|
|
20
|
+
* Match an operator from the input text.
|
|
21
|
+
* Operators are already sorted by specificity, so no re-sorting needed.
|
|
22
|
+
*/
|
|
23
|
+
function matchOperator(allowedOperators, text) {
|
|
24
|
+
return allowedOperators.find((operator) => text.toLowerCase().startsWith(operator.toLowerCase()));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Match a property from the input text by longest property label.
|
|
28
|
+
*
|
|
29
|
+
* properties: [{ propertyLabel: "Instance" }, { propertyLabel: "Instance ID" }]
|
|
30
|
+
* text = "Instance ID:"
|
|
31
|
+
*
|
|
32
|
+
* Result: { propertyLabel: "Instance ID" }
|
|
33
|
+
*/
|
|
34
|
+
function matchFilteringProperty(filteringProperties, text) {
|
|
35
|
+
const lowerText = text.toLowerCase();
|
|
36
|
+
let bestMatch;
|
|
37
|
+
for (const prop of filteringProperties) {
|
|
38
|
+
if (lowerText.startsWith(prop.propertyLabel.toLowerCase())) {
|
|
39
|
+
if (!bestMatch ||
|
|
40
|
+
prop.propertyLabel.length > bestMatch.propertyLabel.length) {
|
|
41
|
+
bestMatch = prop;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return bestMatch;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Check if the input text is a valid prefix of any allowed operator.
|
|
49
|
+
* Returns the prefix if valid, null otherwise.
|
|
50
|
+
*/
|
|
51
|
+
function matchOperatorPrefix(allowedOperators, filteringText) {
|
|
52
|
+
const trimmedText = filteringText.trim();
|
|
53
|
+
if (trimmedText.length === 0) {
|
|
54
|
+
return "";
|
|
55
|
+
}
|
|
56
|
+
const isValidPrefix = allowedOperators.some((operator) => operator.toLowerCase().startsWith(trimmedText.toLowerCase()));
|
|
57
|
+
return isValidPrefix ? trimmedText : null;
|
|
58
|
+
}
|
|
59
|
+
export { QUERY_OPERATORS, matchOperator, matchFilteringProperty, matchOperatorPrefix, };
|
|
60
|
+
//# sourceMappingURL=operators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.js","sourceRoot":"","sources":["../../../../src/data/token-filter/helpers/operators.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,SAAS,GAAsC;IACnD,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;CACV,CAAC;AAEF,MAAM,eAAe,GAA0B,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAEtE;;;GAGG;AACH,SAAS,aAAa,CACpB,gBAAuC,EACvC,IAAY;IAEZ,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CACxC,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CACtD,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,sBAAsB,CAC7B,mBAAqC,EACrC,IAAY;IAEZ,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACrC,IAAI,SAAqC,CAAC;IAE1C,KAAK,MAAM,IAAI,IAAI,mBAAmB,EAAE,CAAC;QACvC,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;YAC3D,IACE,CAAC,SAAS;gBACV,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC,aAAa,CAAC,MAAM,EAC1D,CAAC;gBACD,SAAS,GAAG,IAAI,CAAC;YACnB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAC1B,gBAAuC,EACvC,aAAqB;IAErB,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC;IAEzC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CACvD,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAC7D,CAAC;IAEF,OAAO,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC;AAED,OAAO,EACL,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,mBAAmB,GACpB,CAAC"}
|
|
@@ -21,11 +21,5 @@ type ParsedText = {
|
|
|
21
21
|
* Handles partial input (e.g., user typing "Status !" to complete the operator).
|
|
22
22
|
*/
|
|
23
23
|
declare function parseQueryText(filteringText: string, filteringProperties: ParsedProperty[]): ParsedText;
|
|
24
|
-
|
|
25
|
-
* Operators ordered by specificity (longest/most specific first)
|
|
26
|
-
* This ensures longer operators like ">=" and "<=" are matched
|
|
27
|
-
* before shorter ones like ">" and "<"
|
|
28
|
-
*/
|
|
29
|
-
declare const QUERY_OPERATORS: QueryFilterOperator[];
|
|
30
|
-
export { QUERY_OPERATORS, parseQueryText };
|
|
24
|
+
export { parseQueryText };
|
|
31
25
|
export type { ParsedText };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { QUERY_OPERATORS, matchFilteringProperty, matchOperator, matchOperatorPrefix, } from "./operators.js";
|
|
1
2
|
/**
|
|
2
3
|
* Parse user input text to extract property, operator, and value components.
|
|
3
4
|
* Handles partial input (e.g., user typing "Status !" to complete the operator).
|
|
@@ -39,49 +40,5 @@ function parseQueryText(filteringText, filteringProperties) {
|
|
|
39
40
|
value: filteringText,
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
-
* Operators ordered by specificity (longest/most specific first)
|
|
44
|
-
* This ensures longer operators like ">=" and "<=" are matched
|
|
45
|
-
* before shorter ones like ">" and "<"
|
|
46
|
-
*/
|
|
47
|
-
const QUERY_OPERATORS = [
|
|
48
|
-
">=",
|
|
49
|
-
"<=",
|
|
50
|
-
"!=",
|
|
51
|
-
"!:",
|
|
52
|
-
"!^",
|
|
53
|
-
"=",
|
|
54
|
-
":",
|
|
55
|
-
"^",
|
|
56
|
-
">",
|
|
57
|
-
"<",
|
|
58
|
-
];
|
|
59
|
-
/**
|
|
60
|
-
* Match a property from the input text by longest property label.
|
|
61
|
-
* Case-insensitive matching.
|
|
62
|
-
*/
|
|
63
|
-
function matchFilteringProperty(filteringProperties, text) {
|
|
64
|
-
const sortedProperties = [...filteringProperties].sort((a, b) => b.propertyLabel.length - a.propertyLabel.length);
|
|
65
|
-
return sortedProperties.find((prop) => text.toLowerCase().startsWith(prop.propertyLabel.toLowerCase()));
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Check if the input text is a valid prefix of any allowed operator.
|
|
69
|
-
* Returns the prefix if valid, null otherwise.
|
|
70
|
-
*/
|
|
71
|
-
function matchOperatorPrefix(allowedOperators, filteringText) {
|
|
72
|
-
const trimmedText = filteringText.trim();
|
|
73
|
-
if (trimmedText.length === 0) {
|
|
74
|
-
return "";
|
|
75
|
-
}
|
|
76
|
-
const isValidPrefix = allowedOperators.some((operator) => operator.toLowerCase().startsWith(trimmedText.toLowerCase()));
|
|
77
|
-
return isValidPrefix ? trimmedText : null;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Match an operator from the input text.
|
|
81
|
-
* Operators are already sorted by specificity, so no re-sorting needed.
|
|
82
|
-
*/
|
|
83
|
-
function matchOperator(allowedOperators, text) {
|
|
84
|
-
return allowedOperators.find((operator) => text.toLowerCase().startsWith(operator.toLowerCase()));
|
|
85
|
-
}
|
|
86
|
-
export { QUERY_OPERATORS, parseQueryText };
|
|
43
|
+
export { parseQueryText };
|
|
87
44
|
//# sourceMappingURL=parse-query-text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-query-text.js","sourceRoot":"","sources":["../../../../src/data/token-filter/helpers/parse-query-text.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-query-text.js","sourceRoot":"","sources":["../../../../src/data/token-filter/helpers/parse-query-text.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAuBrB;;;GAGG;AACH,SAAS,cAAc,CACrB,aAAqB,EACrB,mBAAqC;IAErC,MAAM,QAAQ,GAAG,sBAAsB,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;IAC5E,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,gBAAgB,GAAG,aAAa,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QACvE,IAAI,gBAAgB,EAAE,CAAC;YACrB,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,QAAQ,EAAE,gBAAgB;gBAC1B,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE;aACpE,CAAC;QACJ,CAAC;QAED,OAAO;YACL,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,aAAa;SACrB,CAAC;IACJ,CAAC;IAED,MAAM,mBAAmB,GAAG,aAAa;SACtC,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC;SACxC,SAAS,EAAE,CAAC;IAEf,MAAM,QAAQ,GAAG,aAAa,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC;IAErE,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,QAAQ;YACR,QAAQ;YACR,KAAK,EAAE,mBAAmB,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE;SAClE,CAAC;IACJ,CAAC;IAED,MAAM,cAAc,GAAG,mBAAmB,CACxC,eAAe,EACf,mBAAmB,CACpB,CAAC;IAEF,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QAC5B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;IACxD,CAAC;IAED,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,aAAa;KACrB,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { QueryFilterOperator } from "../TokenFilter.types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Human-readable labels for query filter operators.
|
|
4
|
+
* Used for displaying operator descriptions in autocomplete suggestions.
|
|
5
|
+
* TODO: Support i18n
|
|
6
|
+
*/
|
|
7
|
+
declare const OPERATOR_LABELS: Record<QueryFilterOperator, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Builds a query string from property label, operator, and value.
|
|
10
|
+
* Only includes non-empty parts, joined by spaces.
|
|
11
|
+
* @returns Space-joined query string
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* buildQueryString("Status", "=", "active") // "Status = active"
|
|
15
|
+
* buildQueryString("Status", "=", "") // "Status ="
|
|
16
|
+
* buildQueryString("Status", "", "") // "Status"
|
|
17
|
+
* buildQueryString("", "", "") // ""
|
|
18
|
+
*/
|
|
19
|
+
declare function buildQueryString(propertyLabel: string, operator: string, value: string): string;
|
|
20
|
+
export { buildQueryString, OPERATOR_LABELS };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human-readable labels for query filter operators.
|
|
3
|
+
* Used for displaying operator descriptions in autocomplete suggestions.
|
|
4
|
+
* TODO: Support i18n
|
|
5
|
+
*/
|
|
6
|
+
const OPERATOR_LABELS = {
|
|
7
|
+
":": "contains",
|
|
8
|
+
"!:": "does not contain",
|
|
9
|
+
"=": "is",
|
|
10
|
+
"!=": "is not",
|
|
11
|
+
"^": "starts with",
|
|
12
|
+
"!^": "does not start with",
|
|
13
|
+
">=": "is greater than or equal to",
|
|
14
|
+
"<=": "is less than or equal to",
|
|
15
|
+
">": "is greater than",
|
|
16
|
+
"<": "is less than",
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Builds a query string from property label, operator, and value.
|
|
20
|
+
* Only includes non-empty parts, joined by spaces.
|
|
21
|
+
* @returns Space-joined query string
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* buildQueryString("Status", "=", "active") // "Status = active"
|
|
25
|
+
* buildQueryString("Status", "=", "") // "Status ="
|
|
26
|
+
* buildQueryString("Status", "", "") // "Status"
|
|
27
|
+
* buildQueryString("", "", "") // ""
|
|
28
|
+
*/
|
|
29
|
+
function buildQueryString(propertyLabel, operator, value) {
|
|
30
|
+
const parts = [propertyLabel, operator, value].filter(Boolean);
|
|
31
|
+
return parts.join(" ");
|
|
32
|
+
}
|
|
33
|
+
export { buildQueryString, OPERATOR_LABELS };
|
|
34
|
+
//# sourceMappingURL=query-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-builder.js","sourceRoot":"","sources":["../../../../src/data/token-filter/helpers/query-builder.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,eAAe,GAAwC;IAC3D,GAAG,EAAE,UAAU;IACf,IAAI,EAAE,kBAAkB;IACxB,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,QAAQ;IACd,GAAG,EAAE,aAAa;IAClB,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE,6BAA6B;IACnC,IAAI,EAAE,0BAA0B;IAChC,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,cAAc;CACpB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,SAAS,gBAAgB,CACvB,aAAqB,EACrB,QAAgB,EAChB,KAAa;IAEb,MAAM,KAAK,GAAG,CAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/D,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if search field values match the given filter text.
|
|
3
|
+
*
|
|
4
|
+
* @param searchFieldValues - Array of strings to search within (e.g., labels, tags, descriptions)
|
|
5
|
+
* @param filterText - The search text to match against
|
|
6
|
+
* @returns true if all space-separated parts of filterText are found in at least one searchFieldValue
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* matchesFilterText(['Hello World', 'foo'], 'hello') // true
|
|
10
|
+
* matchesFilterText(['Hello World', 'foo'], 'hello bar') // false
|
|
11
|
+
* matchesFilterText(['Hello World', 'bar'], 'hello bar') // true
|
|
12
|
+
* matchesFilterText([], 'test') // false
|
|
13
|
+
* matchesFilterText(['test'], '') // true (empty filter matches all)
|
|
14
|
+
*/
|
|
15
|
+
declare function matchesFilterText(searchFieldValues: string[], filterText: string): boolean;
|
|
16
|
+
export { matchesFilterText };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if search field values match the given filter text.
|
|
3
|
+
*
|
|
4
|
+
* @param searchFieldValues - Array of strings to search within (e.g., labels, tags, descriptions)
|
|
5
|
+
* @param filterText - The search text to match against
|
|
6
|
+
* @returns true if all space-separated parts of filterText are found in at least one searchFieldValue
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* matchesFilterText(['Hello World', 'foo'], 'hello') // true
|
|
10
|
+
* matchesFilterText(['Hello World', 'foo'], 'hello bar') // false
|
|
11
|
+
* matchesFilterText(['Hello World', 'bar'], 'hello bar') // true
|
|
12
|
+
* matchesFilterText([], 'test') // false
|
|
13
|
+
* matchesFilterText(['test'], '') // true (empty filter matches all)
|
|
14
|
+
*/
|
|
15
|
+
function matchesFilterText(searchFieldValues, filterText) {
|
|
16
|
+
/* Guard against null/undefined inputs */
|
|
17
|
+
if (!searchFieldValues || !Array.isArray(searchFieldValues)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (filterText === null || filterText === undefined) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
const normalizedFilter = filterText.trim().toLowerCase();
|
|
24
|
+
/* Empty filter matches everything */
|
|
25
|
+
if (!normalizedFilter) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
/* Split filter into parts ("nord land" -> ["nord", "land"]) */
|
|
29
|
+
const parts = normalizedFilter.split(/\s+/).filter(Boolean);
|
|
30
|
+
if (parts.length === 0) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
/* Normalize and filter out nullish values */
|
|
34
|
+
const normalizedFields = searchFieldValues
|
|
35
|
+
.map((value) => value === null || value === void 0 ? void 0 : value.toLowerCase())
|
|
36
|
+
.filter(Boolean);
|
|
37
|
+
/* If no valid fields to search, no match */
|
|
38
|
+
if (normalizedFields.length === 0) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
/* Every part of the filter must be found in at least one field */
|
|
42
|
+
return parts.every((part) => normalizedFields.some((field) => field.includes(part)));
|
|
43
|
+
}
|
|
44
|
+
export { matchesFilterText };
|
|
45
|
+
//# sourceMappingURL=text-matching.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-matching.js","sourceRoot":"","sources":["../../../../src/data/token-filter/helpers/text-matching.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,SAAS,iBAAiB,CACxB,iBAA2B,EAC3B,UAAkB;IAElB,yCAAyC;IACzC,IAAI,CAAC,iBAAiB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC5D,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,gBAAgB,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAEzD,qCAAqC;IACrC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+DAA+D;IAC/D,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE5D,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,6CAA6C;IAC7C,MAAM,gBAAgB,GAAG,iBAAiB;SACvC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW,EAAE,CAAC;SACpC,MAAM,CAAC,OAAO,CAAC,CAAC;IAEnB,4CAA4C;IAC5C,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,kEAAkE;IAClE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAC1B,gBAAgB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CACvD,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,6 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
12
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
13
13
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
14
14
|
import React, { forwardRef } from "react";
|
|
15
15
|
import { Floating } from "../../../utils/components/floating/Floating.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputController.js","sourceRoot":"","sources":["../../../../src/form/combobox/Input/InputController.tsx"],"names":[],"mappings":"AAAA,0DAA0D
|
|
1
|
+
{"version":3,"file":"InputController.js","sourceRoot":"","sources":["../../../../src/form/combobox/Input/InputController.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,0DAA0D;AAC1D,4DAA4D;AAC5D,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,6CAA6C,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AC,QAAQ,IAAI,QAAQ,EAAE,CAAC;oBACpC,OAAO;gBACT,CAAC;gBAED,gBAAgB,CAAC,IAAI,CAAC,CAAC;gBACvB,UAAU,EAAE,CAAC;YACf,CAAC;YAEA,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAC5B,oBAAC,KAAK,kBACJ,EAAE,EAAE,UAAU,CAAC,EAAE,EACjB,GAAG,EAAE,cAAc,EACnB,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,IACd,IAAI,EACR,CACH,CAAC,CAAC,CAAC,CACF,oBAAC,eAAe,IAAC,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI;gBAC3D,oBAAC,KAAK,kBACJ,EAAE,EAAE,UAAU,CAAC,EAAE,EACjB,GAAG,EAAE,cAAc,EACnB,cAAc,EAAE,cAAc,EAC9B,yBAAyB,EAAE,yBAAyB,EACpD,QAAQ,EAAE,QAAQ,IACd,IAAI,EACR,CACc,CACnB;YACA,gBAAgB,IAAI,oBAAC,gBAAgB,IAAC,GAAG,EAAE,mBAAmB,GAAI,CAC/D,CACU,CACnB,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,6 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
12
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
13
13
|
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
14
14
|
import React, { forwardRef } from "react";
|
|
15
15
|
import { CircleSlashIcon, CloudUpIcon } from "@navikt/aksel-icons";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileUploadDropzone.js","sourceRoot":"","sources":["../../../../src/form/file-upload/dropzone/FileUploadDropzone.tsx"],"names":[],"mappings":"AAAA,4DAA4D
|
|
1
|
+
{"version":3,"file":"FileUploadDropzone.js","sourceRoot":"","sources":["../../../../src/form/file-upload/dropzone/FileUploadDropzone.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,4DAA4D;AAC5D,0DAA0D;AAC1D,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,EAAE,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,kBAAkB,GAAG,UAAU,CAGnC,CAAC,KAA8B,EAAE,GAAG,EAAE,EAAE;IACxC,MAAM,EACJ,QAAQ,EACR,KAAK,EACL,KAAK,EACL,WAAW,EACX,SAAS,EACT,QAAQ,GAAG,IAAI,EACf,MAAM,EACN,SAAS,EACT,cAAc,EACd,SAAS,EACT,IAAI,EAAE,YAAY,GAAG,WAAW,EAChC,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,EAAE,EAAE,QAAQ,EACZ,YAAY,EAAE,KAAK,KAEjB,KAAK,E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C,CAAC,CAAC;AAEH,eAAe,kBAAkB,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
2
|
import { useControllableState } from "../utils/hooks/index.js";
|
|
3
3
|
export function useToggleGroup({ onChange, value, defaultValue = "", }) {
|
|
4
4
|
const [focusedValue, setFocusedValue] = useState(defaultValue);
|
|
@@ -8,9 +8,11 @@ export function useToggleGroup({ onChange, value, defaultValue = "", }) {
|
|
|
8
8
|
onChange,
|
|
9
9
|
});
|
|
10
10
|
/* Sync focused `value` with controlled `selectedValue` */
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (value != null) {
|
|
13
|
+
setFocusedValue(value);
|
|
14
|
+
}
|
|
15
|
+
}, [value]);
|
|
14
16
|
return {
|
|
15
17
|
selectedValue,
|
|
16
18
|
setSelectedValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToggleGroup.js","sourceRoot":"","sources":["../../src/toggle-group/useToggleGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useToggleGroup.js","sourceRoot":"","sources":["../../src/toggle-group/useToggleGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAGtD,MAAM,UAAU,cAAc,CAAC,EAC7B,QAAQ,EACR,KAAK,EACL,YAAY,GAAG,EAAE,GAC6C;IAC9D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC/D,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,oBAAoB,CAAC;QAC7D,YAAY;QACZ,KAAK;QACL,QAAQ;KACT,CAAC,CAAC;IAEH,0DAA0D;IAC1D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,eAAe,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO;QACL,aAAa;QACb,gBAAgB;QAChB,YAAY;QACZ,eAAe;KAChB,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.6.0",
|
|
4
4
|
"description": "React components from the Norwegian Labour and Welfare Administration.",
|
|
5
5
|
"author": "Aksel, a team part of the Norwegian Labour and Welfare Administration.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -705,8 +705,8 @@
|
|
|
705
705
|
"dependencies": {
|
|
706
706
|
"@floating-ui/react": "0.27.8",
|
|
707
707
|
"@floating-ui/react-dom": "^2.1.6",
|
|
708
|
-
"@navikt/aksel-icons": "^8.
|
|
709
|
-
"@navikt/ds-tokens": "^8.
|
|
708
|
+
"@navikt/aksel-icons": "^8.6.0",
|
|
709
|
+
"@navikt/ds-tokens": "^8.6.0",
|
|
710
710
|
"date-fns": "^4.0.0",
|
|
711
711
|
"react-day-picker": "9.7.0"
|
|
712
712
|
},
|
|
@@ -24,6 +24,10 @@ import { useTableKeyboardNav } from "./useTableKeyboardNav";
|
|
|
24
24
|
|
|
25
25
|
interface DataTableProps extends React.HTMLAttributes<HTMLTableElement> {
|
|
26
26
|
children: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Controls vertical cell padding.
|
|
29
|
+
* @default "normal"
|
|
30
|
+
*/
|
|
27
31
|
rowDensity?: "condensed" | "normal" | "spacious";
|
|
28
32
|
/**
|
|
29
33
|
* Zebra striped table
|
|
@@ -32,9 +36,11 @@ interface DataTableProps extends React.HTMLAttributes<HTMLTableElement> {
|
|
|
32
36
|
zebraStripes?: boolean;
|
|
33
37
|
/**
|
|
34
38
|
* Truncate content in cells and show ellipsis for overflowed text.
|
|
39
|
+
*
|
|
40
|
+
* **NB:** When using `layout="auto"`, you have to manually set a `maxWidth` on columns that should be truncated.
|
|
35
41
|
* @default true
|
|
36
42
|
*/
|
|
37
|
-
truncateContent?: boolean;
|
|
43
|
+
truncateContent?: boolean; // TODO: Consider making this default false when layout=auto, and maybe disallow it but add a wrap prop on the td-comp.
|
|
38
44
|
/**
|
|
39
45
|
* Enables keyboard navigation for table rows and cells.
|
|
40
46
|
* @default false
|
|
@@ -46,6 +52,21 @@ interface DataTableProps extends React.HTMLAttributes<HTMLTableElement> {
|
|
|
46
52
|
* Requires `withKeyboardNav` to be `true`.
|
|
47
53
|
*/
|
|
48
54
|
shouldBlockNavigation?: (event: KeyboardEvent) => boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Controls table layout.
|
|
57
|
+
*
|
|
58
|
+
* ### fixed
|
|
59
|
+
* Gives you full control of column widths. This is required for resizable columns.
|
|
60
|
+
*
|
|
61
|
+
* ### auto
|
|
62
|
+
* Makes the columns resize automatically based on the content.
|
|
63
|
+
* The table will take up at least 100% of available width.
|
|
64
|
+
*
|
|
65
|
+
* **NB:** When using this with `truncateContent`, you have to manually
|
|
66
|
+
* set a `contentMaxWidth` on cells that should be truncated.
|
|
67
|
+
* @default "fixed"
|
|
68
|
+
*/
|
|
69
|
+
layout?: "fixed" | "auto";
|
|
49
70
|
}
|
|
50
71
|
|
|
51
72
|
interface DataTableRootComponent extends React.ForwardRefExoticComponent<
|
|
@@ -143,6 +164,12 @@ interface DataTableRootComponent extends React.ForwardRefExoticComponent<
|
|
|
143
164
|
Tfoot: typeof DataTableTfoot;
|
|
144
165
|
}
|
|
145
166
|
|
|
167
|
+
/**
|
|
168
|
+
* TODO Component description etc.
|
|
169
|
+
*
|
|
170
|
+
* **NB:** To get sticky headers, you have to set a height restriction on the table container. You can use VStack for this:
|
|
171
|
+
* TODO example
|
|
172
|
+
*/
|
|
146
173
|
const DataTable = forwardRef<HTMLTableElement, DataTableProps>(
|
|
147
174
|
(
|
|
148
175
|
{
|
|
@@ -152,6 +179,7 @@ const DataTable = forwardRef<HTMLTableElement, DataTableProps>(
|
|
|
152
179
|
zebraStripes = false,
|
|
153
180
|
truncateContent = true,
|
|
154
181
|
shouldBlockNavigation,
|
|
182
|
+
layout = "fixed",
|
|
155
183
|
...rest
|
|
156
184
|
},
|
|
157
185
|
forwardedRef,
|
|
@@ -174,6 +202,7 @@ const DataTable = forwardRef<HTMLTableElement, DataTableProps>(
|
|
|
174
202
|
data-zebra-stripes={zebraStripes}
|
|
175
203
|
data-truncate-content={truncateContent}
|
|
176
204
|
data-density={rowDensity}
|
|
205
|
+
data-layout={layout}
|
|
177
206
|
tabIndex={tabIndex}
|
|
178
207
|
/>
|
|
179
208
|
</div>
|
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import { cl } from "../../../utils/helpers";
|
|
3
3
|
|
|
4
|
-
interface DataTableTdProps extends React.
|
|
4
|
+
interface DataTableTdProps extends React.TdHTMLAttributes<HTMLTableCellElement> {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Sets a max-width on the content wrapper div inside the cell.
|
|
7
|
+
* This is only needed when using `layout="auto"` together with
|
|
8
|
+
* `truncateContent` on `<DataTable>` and you want the cell to be truncated.
|
|
7
9
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
contentMaxWidth?: number | `${number}${string}`;
|
|
11
|
+
/**
|
|
12
|
+
* TODO: Consider a prop like this instead of contentMaxWidth to use together with layout=auto.
|
|
13
|
+
* Maybe even with layout=auto as a way to override truncateContent on single cells?
|
|
14
|
+
* Need to work on the name though. Or maybe have two separate props?
|
|
15
|
+
*/
|
|
16
|
+
//textWrap?: boolean | number | `${number}${string}`;
|
|
10
17
|
}
|
|
11
18
|
|
|
12
19
|
const DataTableTd = forwardRef<HTMLTableCellElement, DataTableTdProps>(
|
|
13
|
-
({ className, children, ...rest }, forwardedRef) => {
|
|
20
|
+
({ className, children, contentMaxWidth, ...rest }, forwardedRef) => {
|
|
14
21
|
return (
|
|
15
22
|
<td
|
|
16
23
|
{...rest}
|
|
17
24
|
ref={forwardedRef}
|
|
18
25
|
className={cl("aksel-data-table__td", className)}
|
|
19
26
|
>
|
|
20
|
-
<div>{children}</div>
|
|
27
|
+
<div style={{ maxWidth: contentMaxWidth }}>{children}</div>
|
|
21
28
|
</td>
|
|
22
29
|
);
|
|
23
30
|
},
|