@navikt/ds-react 8.4.1 → 8.5.1
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/accordion/Accordion.d.ts +10 -0
- package/cjs/accordion/Accordion.js +2 -2
- package/cjs/accordion/Accordion.js.map +1 -1
- package/cjs/data/table/helpers/table-cell.d.ts +2 -2
- package/cjs/data/table/helpers/table-cell.js +2 -5
- package/cjs/data/table/helpers/table-cell.js.map +1 -1
- package/cjs/data/table/helpers/table-focus.d.ts +26 -2
- package/cjs/data/table/helpers/table-focus.js +60 -9
- package/cjs/data/table/helpers/table-focus.js.map +1 -1
- package/cjs/data/table/helpers/table-grid-nav.d.ts +40 -10
- package/cjs/data/table/helpers/table-grid-nav.js +102 -25
- package/cjs/data/table/helpers/table-grid-nav.js.map +1 -1
- package/cjs/data/table/helpers/table-keyboard.d.ts +24 -3
- package/cjs/data/table/helpers/table-keyboard.js +25 -5
- package/cjs/data/table/helpers/table-keyboard.js.map +1 -1
- package/cjs/data/table/hooks/useGridCache.d.ts +17 -0
- package/cjs/data/table/hooks/useGridCache.js +65 -0
- package/cjs/data/table/hooks/useGridCache.js.map +1 -0
- package/cjs/data/table/root/DataTableRoot.d.ts +14 -4
- package/cjs/data/table/root/DataTableRoot.js +4 -6
- package/cjs/data/table/root/DataTableRoot.js.map +1 -1
- package/cjs/data/table/root/useTableKeyboardNav.d.ts +10 -4
- package/cjs/data/table/root/useTableKeyboardNav.js +70 -99
- package/cjs/data/table/root/useTableKeyboardNav.js.map +1 -1
- package/cjs/data/token-filter/AutoSuggest.d.ts +21 -0
- package/cjs/data/token-filter/AutoSuggest.js +129 -0
- package/cjs/data/token-filter/AutoSuggest.js.map +1 -0
- package/cjs/data/token-filter/TokenFilter.d.ts +11 -0
- package/cjs/data/token-filter/TokenFilter.js +91 -0
- package/cjs/data/token-filter/TokenFilter.js.map +1 -0
- package/cjs/data/token-filter/TokenFilter.types.d.ts +46 -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 +70 -0
- package/cjs/data/token-filter/helpers/generate-autocomplete-options.js +171 -0
- package/cjs/data/token-filter/helpers/generate-autocomplete-options.js.map +1 -0
- package/cjs/data/token-filter/helpers/parse-query-text.d.ts +31 -0
- package/cjs/data/token-filter/helpers/parse-query-text.js +91 -0
- package/cjs/data/token-filter/helpers/parse-query-text.js.map +1 -0
- package/cjs/link-card/LinkCard.d.ts +13 -0
- package/cjs/link-card/LinkCard.js +2 -2
- package/cjs/link-card/LinkCard.js.map +1 -1
- package/cjs/process/Process.d.ts +1 -1
- package/cjs/tooltip/Tooltip.js +1 -1
- package/cjs/tooltip/Tooltip.js.map +1 -1
- package/esm/accordion/Accordion.d.ts +10 -0
- package/esm/accordion/Accordion.js +2 -2
- package/esm/accordion/Accordion.js.map +1 -1
- package/esm/data/table/helpers/table-cell.d.ts +2 -2
- package/esm/data/table/helpers/table-cell.js +2 -5
- package/esm/data/table/helpers/table-cell.js.map +1 -1
- package/esm/data/table/helpers/table-focus.d.ts +26 -2
- package/esm/data/table/helpers/table-focus.js +55 -9
- package/esm/data/table/helpers/table-focus.js.map +1 -1
- package/esm/data/table/helpers/table-grid-nav.d.ts +40 -10
- package/esm/data/table/helpers/table-grid-nav.js +96 -24
- package/esm/data/table/helpers/table-grid-nav.js.map +1 -1
- package/esm/data/table/helpers/table-keyboard.d.ts +24 -3
- package/esm/data/table/helpers/table-keyboard.js +24 -4
- package/esm/data/table/helpers/table-keyboard.js.map +1 -1
- package/esm/data/table/hooks/useGridCache.d.ts +17 -0
- package/esm/data/table/hooks/useGridCache.js +63 -0
- package/esm/data/table/hooks/useGridCache.js.map +1 -0
- package/esm/data/table/root/DataTableRoot.d.ts +14 -4
- package/esm/data/table/root/DataTableRoot.js +4 -6
- package/esm/data/table/root/DataTableRoot.js.map +1 -1
- package/esm/data/table/root/useTableKeyboardNav.d.ts +10 -4
- package/esm/data/table/root/useTableKeyboardNav.js +75 -104
- package/esm/data/table/root/useTableKeyboardNav.js.map +1 -1
- package/esm/data/token-filter/AutoSuggest.d.ts +21 -0
- package/esm/data/token-filter/AutoSuggest.js +93 -0
- package/esm/data/token-filter/AutoSuggest.js.map +1 -0
- package/esm/data/token-filter/TokenFilter.d.ts +11 -0
- package/esm/data/token-filter/TokenFilter.js +55 -0
- package/esm/data/token-filter/TokenFilter.js.map +1 -0
- package/esm/data/token-filter/TokenFilter.types.d.ts +46 -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 +70 -0
- package/esm/data/token-filter/helpers/generate-autocomplete-options.js +169 -0
- package/esm/data/token-filter/helpers/generate-autocomplete-options.js.map +1 -0
- package/esm/data/token-filter/helpers/parse-query-text.d.ts +31 -0
- package/esm/data/token-filter/helpers/parse-query-text.js +87 -0
- package/esm/data/token-filter/helpers/parse-query-text.js.map +1 -0
- package/esm/link-card/LinkCard.d.ts +13 -0
- package/esm/link-card/LinkCard.js +2 -2
- package/esm/link-card/LinkCard.js.map +1 -1
- package/esm/process/Process.d.ts +1 -1
- package/esm/tooltip/Tooltip.js +2 -2
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/package.json +3 -3
- package/src/accordion/Accordion.tsx +19 -2
- package/src/data/table/helpers/table-cell.ts +2 -7
- package/src/data/table/helpers/table-focus.ts +70 -9
- package/src/data/table/helpers/table-grid-nav.test.ts +659 -0
- package/src/data/table/helpers/table-grid-nav.ts +128 -32
- package/src/data/table/helpers/table-keyboard.test.ts +27 -27
- package/src/data/table/helpers/table-keyboard.ts +34 -4
- package/src/data/table/hooks/useGridCache.ts +73 -0
- package/src/data/table/root/DataTableRoot.tsx +21 -11
- package/src/data/table/root/useTableKeyboardNav.ts +110 -128
- package/src/data/token-filter/AutoSuggest.tsx +179 -0
- package/src/data/token-filter/TokenFilter.tsx +124 -0
- package/src/data/token-filter/TokenFilter.types.ts +79 -0
- package/src/data/token-filter/helpers/generate-autocomplete-options.ts +244 -0
- package/src/data/token-filter/helpers/parse-query-text.test.ts +410 -0
- package/src/data/token-filter/helpers/parse-query-text.ts +148 -0
- package/src/link-card/LinkCard.tsx +15 -1
- package/src/process/Process.tsx +1 -1
- package/src/tooltip/Tooltip.tsx +3 -3
|
@@ -0,0 +1,46 @@
|
|
|
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 QueryFilteringProperty = {
|
|
26
|
+
key: string;
|
|
27
|
+
propertyLabel: string;
|
|
28
|
+
groupValuesLabel: string;
|
|
29
|
+
group: string;
|
|
30
|
+
};
|
|
31
|
+
type QueryFilteringProperties = QueryFilteringProperty[];
|
|
32
|
+
type ParsedProperty = {
|
|
33
|
+
propertyKey: string;
|
|
34
|
+
propertyLabel: string;
|
|
35
|
+
groupValuesLabel: string;
|
|
36
|
+
propertyGroup: string;
|
|
37
|
+
externalProperty: QueryFilteringProperty;
|
|
38
|
+
};
|
|
39
|
+
type ParsedOption = {
|
|
40
|
+
property: ParsedProperty | null;
|
|
41
|
+
value: any;
|
|
42
|
+
label: string;
|
|
43
|
+
tags: string[];
|
|
44
|
+
filteringTags: string[];
|
|
45
|
+
};
|
|
46
|
+
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,70 @@
|
|
|
1
|
+
import type { ParsedOption, ParsedProperty } from "../TokenFilter.types.js";
|
|
2
|
+
import { type ParsedText } from "./parse-query-text.js";
|
|
3
|
+
interface OptionGroup<T> {
|
|
4
|
+
label: string;
|
|
5
|
+
options: T[];
|
|
6
|
+
}
|
|
7
|
+
interface AutoCompleteOption {
|
|
8
|
+
value: string;
|
|
9
|
+
label: string;
|
|
10
|
+
tags?: string[];
|
|
11
|
+
filteringTags?: string[];
|
|
12
|
+
description?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
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.
|
|
33
|
+
*
|
|
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.
|
|
36
|
+
*
|
|
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.
|
|
44
|
+
*/
|
|
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
|
+
} | {
|
|
67
|
+
value: string;
|
|
68
|
+
options: (OptionGroup<ParsedProperty> | OptionGroup<AutoCompleteOption>)[];
|
|
69
|
+
};
|
|
70
|
+
export { generateAutoCompleteOptions };
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { QUERY_OPERATORS } from "./parse-query-text.js";
|
|
2
|
+
function buildQueryString(propertyLabel, operator, value) {
|
|
3
|
+
const parts = [propertyLabel, operator, value].filter(Boolean);
|
|
4
|
+
return parts.join(" ");
|
|
5
|
+
}
|
|
6
|
+
/* TODO: i18n */
|
|
7
|
+
const OPERATOR_LABELS = {
|
|
8
|
+
":": "contains",
|
|
9
|
+
"!:": "does not contain",
|
|
10
|
+
"=": "is",
|
|
11
|
+
"!=": "is not",
|
|
12
|
+
"^": "starts with",
|
|
13
|
+
"!^": "does not start with",
|
|
14
|
+
">=": "is greater than or equal to",
|
|
15
|
+
"<=": "is less than or equal to",
|
|
16
|
+
">": "is greater than",
|
|
17
|
+
"<": "is less than",
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Grouping option for autocomplete suggestions structures:
|
|
21
|
+
*
|
|
22
|
+
* Step: "free-text" + empty value:
|
|
23
|
+
* - Group: "Properties" with all properties.
|
|
24
|
+
*
|
|
25
|
+
* Step: "free-text" with non-empty value:
|
|
26
|
+
* - Group: "Properties". All properties including the filter text in label or description or tags. String match.
|
|
27
|
+
* - Group: "Values". All "property = value" combinations where either the property label or value label or description or tags include the filter text. String match.
|
|
28
|
+
* - - Ignore all other operators than "=" for value suggestions.
|
|
29
|
+
*
|
|
30
|
+
* Step: "property" + empty value:
|
|
31
|
+
* - Group: "Operators". All operators valid for the selected property.
|
|
32
|
+
*
|
|
33
|
+
* Step: "property" + non-empty value:
|
|
34
|
+
* - Group: "Operators". All operators valid for the selected property with string match. Only relevant for multi letter operators like "!="
|
|
35
|
+
*
|
|
36
|
+
* Step: "operator" + empty value:
|
|
37
|
+
* - Group: "<Property> values". All values valid for the selected property and operator. String match on value label, description and tags.
|
|
38
|
+
*
|
|
39
|
+
* Step: "operator" + non-empty value:
|
|
40
|
+
* - Group: "<Property> values". All values valid for the selected property and operator with string match. String match on value label, description and tags.
|
|
41
|
+
*
|
|
42
|
+
*
|
|
43
|
+
* TODO:
|
|
44
|
+
* - Handle custom groups
|
|
45
|
+
* - Multi vs single-select: Allow operators for each options where user can define type to be enum: { operator: "=", tokenType: "enum" }. Enum-type options allow selecting multiple values, i.e state = ("active", "pending"))
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* TODO: Update based on instructions above.
|
|
49
|
+
*/
|
|
50
|
+
function generateAutoCompleteOptions(queryState, filteringProperties = [], filteringOptions = []) {
|
|
51
|
+
if (queryState.step === "property") {
|
|
52
|
+
if (!queryState.property) {
|
|
53
|
+
return {
|
|
54
|
+
value: queryState.value,
|
|
55
|
+
options: [],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const { propertyLabel, groupValuesLabel } = queryState.property;
|
|
59
|
+
const options = filteringOptions.filter((o) => o.property === queryState.property);
|
|
60
|
+
return {
|
|
61
|
+
value: queryState.value,
|
|
62
|
+
options: [
|
|
63
|
+
{
|
|
64
|
+
label: groupValuesLabel,
|
|
65
|
+
options: options.map(({ label, value, tags, filteringTags }) => ({
|
|
66
|
+
value: buildQueryString(propertyLabel, queryState.operator, value),
|
|
67
|
+
label,
|
|
68
|
+
tags,
|
|
69
|
+
filteringTags,
|
|
70
|
+
})),
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (queryState.step === "operator") {
|
|
76
|
+
return {
|
|
77
|
+
value: buildQueryString(queryState.property.propertyLabel, queryState.operatorPrefix, ""),
|
|
78
|
+
options: [
|
|
79
|
+
...generatePropertySuggestions(filteringProperties),
|
|
80
|
+
{
|
|
81
|
+
options: QUERY_OPERATORS.map((value) => {
|
|
82
|
+
var _a;
|
|
83
|
+
return ({
|
|
84
|
+
value: buildQueryString(queryState.property.propertyLabel, value, ""),
|
|
85
|
+
label: buildQueryString(queryState.property.propertyLabel, value, ""),
|
|
86
|
+
description: (_a = OPERATOR_LABELS[value]) !== null && _a !== void 0 ? _a : "",
|
|
87
|
+
});
|
|
88
|
+
}),
|
|
89
|
+
/* TODO: i18n */
|
|
90
|
+
label: "Operator",
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const needsValueSuggestions = !!queryState.value;
|
|
96
|
+
const needsPropertySuggestions = !(queryState.step === "free-text" && queryState.operator === "!:");
|
|
97
|
+
return {
|
|
98
|
+
value: queryState.value,
|
|
99
|
+
options: [
|
|
100
|
+
...(needsPropertySuggestions
|
|
101
|
+
? generatePropertySuggestions(filteringProperties)
|
|
102
|
+
: []),
|
|
103
|
+
...(needsValueSuggestions
|
|
104
|
+
? generateAllValueSuggestions(filteringOptions)
|
|
105
|
+
: []),
|
|
106
|
+
],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function createAutoCompleteOption(propertyLabel, operator, value, label, tags, filteringTags) {
|
|
110
|
+
return {
|
|
111
|
+
value: buildQueryString(propertyLabel, operator, value),
|
|
112
|
+
label: buildQueryString(propertyLabel, operator, label),
|
|
113
|
+
tags,
|
|
114
|
+
filteringTags,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function generateAllValueSuggestions(filteringOptions = []) {
|
|
118
|
+
const groups = {};
|
|
119
|
+
for (const option of filteringOptions) {
|
|
120
|
+
if (!option || !option.property) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const groupLabel = option.property.groupValuesLabel || "Values";
|
|
124
|
+
if (!groups[groupLabel]) {
|
|
125
|
+
groups[groupLabel] = {
|
|
126
|
+
label: groupLabel,
|
|
127
|
+
options: [],
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const { label, value, tags, filteringTags, property } = option;
|
|
131
|
+
const options = QUERY_OPERATORS.map((operator) => createAutoCompleteOption(property.propertyLabel, operator, value, label, tags, filteringTags));
|
|
132
|
+
groups[groupLabel].options.push(...options);
|
|
133
|
+
}
|
|
134
|
+
return Object.values(groups);
|
|
135
|
+
}
|
|
136
|
+
function generatePropertySuggestions(filteringProperties = []) {
|
|
137
|
+
var _a;
|
|
138
|
+
const defaultGroup = {
|
|
139
|
+
label: "Properties",
|
|
140
|
+
options: [],
|
|
141
|
+
};
|
|
142
|
+
const customGroups = {};
|
|
143
|
+
for (const property of filteringProperties) {
|
|
144
|
+
if (!property) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const groupLabel = (_a = property.propertyGroup) === null || _a === void 0 ? void 0 : _a.trim();
|
|
148
|
+
if (groupLabel) {
|
|
149
|
+
if (!customGroups[groupLabel]) {
|
|
150
|
+
customGroups[groupLabel] = {
|
|
151
|
+
label: groupLabel,
|
|
152
|
+
options: [],
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
customGroups[groupLabel].options.push(property);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
defaultGroup.options.push(property);
|
|
159
|
+
}
|
|
160
|
+
const groups = [
|
|
161
|
+
...Object.values(customGroups),
|
|
162
|
+
];
|
|
163
|
+
if (defaultGroup.options.length > 0) {
|
|
164
|
+
groups.push(defaultGroup);
|
|
165
|
+
}
|
|
166
|
+
return groups;
|
|
167
|
+
}
|
|
168
|
+
export { generateAutoCompleteOptions };
|
|
169
|
+
//# 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":"AACA,OAAO,EAAmB,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAetE,SAAS,gBAAgB,CACvB,aAAqB,EACrB,QAAgB,EAChB,KAAa;IAEb,MAAM,KAAK,GAAG,CAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/D,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,gBAAgB;AAChB,MAAM,eAAe,GAA2B;IAC9C,GAAG,EAAE,UAAU;IACf,IAAI,EAAE,kBAAkB;IACxB,GAAG,EAAE,IAAI;IACT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E,CAAC;QAC3C,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,SAAS;QACX,CAAC;QACD,MAAM,UAAU,GAAG,MAAA,QAAQ,CAAC,aAAa,0CAAE,IAAI,EAAE,CAAC;QAElD,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC9B,YAAY,CAAC,UAAU,CAAC,GAAG;oBACzB,KAAK,EAAE,UAAU;oBACjB,OAAO,EAAE,EAAE;iBACZ,CAAC;YACJ,CAAC;YACD,YAAY,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAChD,SAAS;QACX,CAAC;QAED,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,MAAM,GAAkC;QAC5C,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;KAC/B,CAAC;IAEF,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ParsedProperty, QueryFilterOperator } from "../TokenFilter.types.js";
|
|
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
|
+
/**
|
|
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 };
|
|
31
|
+
export type { ParsedText };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse user input text to extract property, operator, and value components.
|
|
3
|
+
* Handles partial input (e.g., user typing "Status !" to complete the operator).
|
|
4
|
+
*/
|
|
5
|
+
function parseQueryText(filteringText, filteringProperties) {
|
|
6
|
+
const property = matchFilteringProperty(filteringProperties, filteringText);
|
|
7
|
+
if (!property) {
|
|
8
|
+
const freeTextOperator = matchOperator(QUERY_OPERATORS, filteringText);
|
|
9
|
+
if (freeTextOperator) {
|
|
10
|
+
return {
|
|
11
|
+
step: "free-text",
|
|
12
|
+
operator: freeTextOperator,
|
|
13
|
+
value: filteringText.substring(freeTextOperator.length).trimStart(),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
step: "free-text",
|
|
18
|
+
value: filteringText,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const textWithoutProperty = filteringText
|
|
22
|
+
.substring(property.propertyLabel.length)
|
|
23
|
+
.trimStart();
|
|
24
|
+
const operator = matchOperator(QUERY_OPERATORS, textWithoutProperty);
|
|
25
|
+
if (operator) {
|
|
26
|
+
return {
|
|
27
|
+
step: "property",
|
|
28
|
+
property,
|
|
29
|
+
operator,
|
|
30
|
+
value: textWithoutProperty.substring(operator.length).trimStart(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const operatorPrefix = matchOperatorPrefix(QUERY_OPERATORS, textWithoutProperty);
|
|
34
|
+
if (operatorPrefix !== null) {
|
|
35
|
+
return { step: "operator", property, operatorPrefix };
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
step: "free-text",
|
|
39
|
+
value: filteringText,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
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 };
|
|
87
|
+
//# sourceMappingURL=parse-query-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-query-text.js","sourceRoot":"","sources":["../../../../src/data/token-filter/helpers/parse-query-text.ts"],"names":[],"mappings":"AAuBA;;;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,E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7B,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;;;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,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -24,6 +24,19 @@ interface LinkCardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
24
24
|
* @see [📝 Documentation](https://aksel.nav.no/grunnleggende/styling/farger-tokens)
|
|
25
25
|
*/
|
|
26
26
|
"data-color"?: AkselColor;
|
|
27
|
+
/**
|
|
28
|
+
* Changes the HTML element used for the root element.
|
|
29
|
+
*
|
|
30
|
+
* **When using `section`, provide either `aria-label` or `aria-labelledby` for better accessibility.**
|
|
31
|
+
* `axe-core` might warn about unique landmarks if you have multiple Accordions on page with the same label.
|
|
32
|
+
* In those cases consider updating to unique `aria-label` or `aria-labelledby` props.
|
|
33
|
+
* @see [📝 Landmarks unique](https://dequeuniversity.com/rules/axe/4.6/landmark-unique)
|
|
34
|
+
*
|
|
35
|
+
*
|
|
36
|
+
* **When using `article`, make sure `<LinkCard.Title />` is a heading and not a `span`.**
|
|
37
|
+
* @default "div"
|
|
38
|
+
*/
|
|
39
|
+
as?: "div" | "section" | "article";
|
|
27
40
|
}
|
|
28
41
|
interface LinkCardComponent extends React.ForwardRefExoticComponent<LinkCardProps & React.RefAttributes<HTMLDivElement>> {
|
|
29
42
|
/**
|
|
@@ -42,10 +42,10 @@ const { Provider: LinkCardContextProvider, useContext: useLinkCardContext } = cr
|
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
44
|
export const LinkCard = forwardRef((_a, forwardedRef) => {
|
|
45
|
-
var { children, className, arrow = true, arrowPosition = "baseline", size = "medium" } = _a, restProps = __rest(_a, ["children", "className", "arrow", "arrowPosition", "size"]);
|
|
45
|
+
var { children, className, arrow = true, arrowPosition = "baseline", size = "medium", as: Component = "div" } = _a, restProps = __rest(_a, ["children", "className", "arrow", "arrowPosition", "size", "as"]);
|
|
46
46
|
return (React.createElement(LinkCardContextProvider, { size: size },
|
|
47
47
|
React.createElement(LinkAnchorOverlay, { asChild: true },
|
|
48
|
-
React.createElement(BodyLong, Object.assign({ as:
|
|
48
|
+
React.createElement(BodyLong, Object.assign({ as: Component, size: size, ref: forwardedRef, "data-color": "neutral", className: cl("aksel-link-card", className, `aksel-link-card--${size}`), "data-align-arrow": arrowPosition }, restProps),
|
|
49
49
|
children,
|
|
50
50
|
arrow && (React.createElement(LinkAnchorArrow, { fontSize: size === "medium" ? "1.75rem" : "1.5rem", className: "aksel-link-card__arrow" }))))));
|
|
51
51
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkCard.js","sourceRoot":"","sources":["../../src/link-card/LinkCard.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAkB,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,UAAU,EACV,eAAe,EACf,iBAAiB,GAElB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"LinkCard.js","sourceRoot":"","sources":["../../src/link-card/LinkCard.t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,IAC/C,SAAS,GAEZ,QAAQ,CACL,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAOF;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CACpC,CAAC,EAAwD,EAAE,YAAY,EAAE,EAAE;QAA1E,EAAE,QAAQ,EAAE,SAAS,OAAmC,EAA9B,SAAS,cAAnC,yBAAqC,CAAF;IAClC,OAAO,CACL,2CACE,GAAG,EAAE,YAAY,uBAEjB,SAAS,EAAE,EAAE,CAAC,uBAAuB,EAAE,SAAS,CAAC,IAC7C,SAAS,GAEZ,QAAQ,CACL,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAcF;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CACrC,CACE,EAMqB,EACrB,YAAY,EACZ,EAAE;QARF,EACE,QAAQ,EACR,SAAS,EACT,WAAW,EACX,KAAK,OAEc,EADhB,SAAS,cALd,iDAMC,CADa;IAId,OAAO,CACL,2CACE,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,EAAE,CAAC,kCAAkC,EAAE,SAAS,CAAC,EAC5D,KAAK,kCACA,KAAK,KACR,WAAW,OAET,SAAS,GAEZ,QAAQ,CACL,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,QAAQ,CAAC,KAAK,GAAG,aAAa,CAAC;AAC/B,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAC;AACjC,QAAQ,CAAC,WAAW,GAAG,mBAAmB,CAAC;AAC3C,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAC;AACjC,QAAQ,CAAC,IAAI,GAAG,YAAY,CAAC;AAC7B,QAAQ,CAAC,KAAK,GAAG,aAAa,CAAC"}
|
package/esm/process/Process.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ interface ProcessProps extends React.HTMLAttributes<HTMLOListElement> {
|
|
|
3
3
|
/**
|
|
4
4
|
* `<Process.Event />` elements.
|
|
5
5
|
*/
|
|
6
|
-
children: React.
|
|
6
|
+
children: React.ReactNode;
|
|
7
7
|
/**
|
|
8
8
|
* Hides the "aktiv"-text when the event is active.
|
|
9
9
|
* @default false
|
package/esm/tooltip/Tooltip.js
CHANGED
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { autoUpdate, arrow as flArrow, flip, offset, safePolygon, shift, useDismiss, useFloating, useFocus, useHover, useInteractions, } from "@floating-ui/react";
|
|
13
|
-
import React, { forwardRef, useRef } from "react";
|
|
13
|
+
import React, { Fragment, forwardRef, useRef } from "react";
|
|
14
14
|
import { useModalContext } from "../modal/Modal.context.js";
|
|
15
15
|
import { Portal } from "../portal/index.js";
|
|
16
16
|
import { HStack } from "../primitives/stack/index.js";
|
|
@@ -133,7 +133,7 @@ function TooltipShortcuts({ shortcuts }) {
|
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
135
|
if (isKeyShortcutNested(shortcuts)) {
|
|
136
|
-
return (React.createElement("span", { className: "aksel-tooltip__keys", "aria-hidden": true }, shortcuts.map((key, index) => (React.createElement(
|
|
136
|
+
return (React.createElement("span", { className: "aksel-tooltip__keys", "aria-hidden": true }, shortcuts.map((key, index) => (React.createElement(Fragment, { key: key.join("+") },
|
|
137
137
|
React.createElement(HStack, { gap: "space-4" }, key.map((k, i) => (React.createElement(Detail, { as: "kbd", key: i, className: "aksel-tooltip__key" }, k)))),
|
|
138
138
|
index < shortcuts.length - 1 && (React.createElement("span", null,
|
|
139
139
|
" ",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EACL,UAAU,EACV,KAAK,IAAI,OAAO,EAChB,IAAI,EACJ,MAAM,EACN,WAAW,EACX,KAAK,EACL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,eAAe,GAChB,MAAM,oBAAoB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AC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CACjB,oBAAC,MAAM,IAAC,EAAE,EAAC,KAAK,EAAC,GAAG,EAAE,CAAC,EAAE,SAAS,EAAC,oBAAoB,IACpD,CAAC,CACK,CACV,CAAC,CACK;YACR,KAAK,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,CAC/B;;gBAAQ,SAAS,CAAC,mBAAmB,CAAC;oBAAS,CAChD,CACQ,CACZ,CAAC,CACG,CACR,CAAC;IACJ,CAAC;IAED,OAAO,CACL,8BAAM,SAAS,EAAC,qBAAqB,yBAClC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CACvB,oBAAC,MAAM,IAAC,EAAE,EAAC,KAAK,EAAC,GAAG,EAAE,CAAC,EAAE,SAAS,EAAC,oBAAoB,IACpD,CAAC,CACK,CACV,CAAC,CACG,CACR,CAAC;AACJ,CAAC;AAED,eAAe,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.5.1",
|
|
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.5.1",
|
|
709
|
+
"@navikt/ds-tokens": "^8.5.1",
|
|
710
710
|
"date-fns": "^4.0.0",
|
|
711
711
|
"react-day-picker": "9.7.0"
|
|
712
712
|
},
|
|
@@ -57,6 +57,16 @@ interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
57
57
|
* @see [📝 Documentation](https://aksel.nav.no/grunnleggende/styling/farger-tokens)
|
|
58
58
|
*/
|
|
59
59
|
"data-color"?: Exclude<AkselColor, AkselStatusColorRole>;
|
|
60
|
+
/**
|
|
61
|
+
* Changes the HTML element used for the root element.
|
|
62
|
+
*
|
|
63
|
+
* **When using `section`, provide either `aria-label` or `aria-labelledby` for better accessibility.**
|
|
64
|
+
* `axe-core` might warn about unique landmarks if you have multiple Accordions on page with the same label.
|
|
65
|
+
* In those cases consider updating to unique `aria-label` or `aria-labelledby` props.
|
|
66
|
+
* @see [📝 Landmarks unique](https://dequeuniversity.com/rules/axe/4.6/landmark-unique)
|
|
67
|
+
* @default "div"
|
|
68
|
+
*/
|
|
69
|
+
as?: "div" | "section";
|
|
60
70
|
}
|
|
61
71
|
|
|
62
72
|
/**
|
|
@@ -81,7 +91,14 @@ interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
81
91
|
*/
|
|
82
92
|
export const Accordion = forwardRef<HTMLDivElement, AccordionProps>(
|
|
83
93
|
(
|
|
84
|
-
{
|
|
94
|
+
{
|
|
95
|
+
className,
|
|
96
|
+
variant = "default",
|
|
97
|
+
size = "medium",
|
|
98
|
+
indent = true,
|
|
99
|
+
as: Component = "div",
|
|
100
|
+
...rest
|
|
101
|
+
},
|
|
85
102
|
ref,
|
|
86
103
|
) => {
|
|
87
104
|
const localRef = useRef<HTMLDivElement | null>(null);
|
|
@@ -117,7 +134,7 @@ export const Accordion = forwardRef<HTMLDivElement, AccordionProps>(
|
|
|
117
134
|
variant,
|
|
118
135
|
}}
|
|
119
136
|
>
|
|
120
|
-
<
|
|
137
|
+
<Component
|
|
121
138
|
{...omit(rest, ["headingSize"])}
|
|
122
139
|
className={cl(
|
|
123
140
|
"aksel-accordion",
|
|
@@ -4,20 +4,15 @@ function getFirstCell(tableRef: HTMLTableElement): Element | null {
|
|
|
4
4
|
return tableRef.querySelector("td, th");
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function focusInitialTableTarget(
|
|
8
8
|
tableRef: HTMLTableElement | null,
|
|
9
|
-
activeCell: Element | null,
|
|
10
9
|
): Element | null {
|
|
11
10
|
if (!tableRef) {
|
|
12
11
|
return null;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
if (activeCell) {
|
|
16
|
-
return activeCell;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
14
|
const firstCell = getFirstCell(tableRef);
|
|
20
15
|
return firstCell ? focusCell(firstCell) : null;
|
|
21
16
|
}
|
|
22
17
|
|
|
23
|
-
export {
|
|
18
|
+
export { getFirstCell, focusInitialTableTarget };
|