@gooddata/sdk-ui-gen-ai 11.37.0-alpha.3 → 11.37.0-alpha.4
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.
|
@@ -4,7 +4,7 @@ import { useIntl } from "react-intl";
|
|
|
4
4
|
import { useSelector } from "react-redux";
|
|
5
5
|
import { catalogItemsSelector } from "../../store/chatWindow/chatWindowSelectors.js";
|
|
6
6
|
import { getCatalogItemId, getCompletionItemId, getOptions } from "./utils.js";
|
|
7
|
-
const
|
|
7
|
+
const TRIGGER_REGEX = /@[\p{L}\p{N}_]*/u;
|
|
8
8
|
export function useCompletion(selected, { canManage, canAnalyze }) {
|
|
9
9
|
const catalogItemsList = useSelector(catalogItemsSelector);
|
|
10
10
|
const usedItems = useRef(selected ?? []);
|
|
@@ -18,62 +18,41 @@ export function useCompletion(selected, { canManage, canAnalyze }) {
|
|
|
18
18
|
];
|
|
19
19
|
}, []);
|
|
20
20
|
const onWordCompletion = useCallback(async (context) => {
|
|
21
|
-
// Match the
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// Word and min length
|
|
26
|
-
const isValidAutocomplete = word && length;
|
|
27
|
-
if (!isValidAutocomplete) {
|
|
21
|
+
// Match the @ trigger before the cursor
|
|
22
|
+
const trigger = context.matchBefore(TRIGGER_REGEX);
|
|
23
|
+
// Trigger and min length
|
|
24
|
+
if (!trigger) {
|
|
28
25
|
return null;
|
|
29
26
|
}
|
|
27
|
+
const search = trigger?.text.substring(1) ?? "";
|
|
28
|
+
const from = (trigger?.from ?? context.pos) + 1;
|
|
30
29
|
const items = catalogItemsList;
|
|
31
30
|
// If no items are found, do not show the completion
|
|
32
31
|
if (items.length === 0) {
|
|
33
32
|
return null;
|
|
34
33
|
}
|
|
35
|
-
const options = getOptions(intl, {
|
|
34
|
+
const options = getOptions(intl, {
|
|
35
|
+
items,
|
|
36
|
+
search,
|
|
37
|
+
onCompletionSelected,
|
|
38
|
+
canManage,
|
|
39
|
+
canAnalyze,
|
|
40
|
+
});
|
|
36
41
|
// No options were found at all
|
|
37
42
|
if (options.length === 0) {
|
|
38
43
|
return null;
|
|
39
44
|
}
|
|
40
45
|
return {
|
|
41
46
|
options,
|
|
42
|
-
from
|
|
43
|
-
validFor: (text) => {
|
|
44
|
-
return !!options.find((opt) => opt.label.includes(text));
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}, [catalogItemsList, intl, onCompletionSelected, canManage, canAnalyze]);
|
|
48
|
-
const onExplicitCompletion = useCallback(async (context) => {
|
|
49
|
-
// Match the word before the cursor
|
|
50
|
-
const word = context.matchBefore(WORD_REGEX);
|
|
51
|
-
const items = catalogItemsList;
|
|
52
|
-
// If no items are found, do not show the completion
|
|
53
|
-
if (!items) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
const options = getOptions(intl, { items, onCompletionSelected, canManage, canAnalyze });
|
|
57
|
-
// No options were found at all
|
|
58
|
-
if (options.length === 0) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
options,
|
|
63
|
-
from: word?.from ?? context.pos,
|
|
47
|
+
from,
|
|
64
48
|
validFor: (text) => {
|
|
65
49
|
return !!options.find((opt) => opt.label.includes(text));
|
|
66
50
|
},
|
|
67
51
|
};
|
|
68
52
|
}, [catalogItemsList, intl, onCompletionSelected, canManage, canAnalyze]);
|
|
69
53
|
const onCompletion = useCallback(async (context) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
return onWordCompletion(context);
|
|
75
|
-
}
|
|
76
|
-
}, [onWordCompletion, onExplicitCompletion]);
|
|
54
|
+
return onWordCompletion(context);
|
|
55
|
+
}, [onWordCompletion]);
|
|
77
56
|
return {
|
|
78
57
|
onCompletion,
|
|
79
58
|
used: usedItems,
|
|
@@ -53,10 +53,7 @@ export function getItems(intl, item, { canManage, canAnalyze, onCompletionSelect
|
|
|
53
53
|
const type = "attribute";
|
|
54
54
|
const insert = `{${type}/${item.attribute.id}}`;
|
|
55
55
|
onCompletionSelected?.(completion);
|
|
56
|
-
view
|
|
57
|
-
changes: { from, to, insert },
|
|
58
|
-
selection: { anchor: from + insert.length },
|
|
59
|
-
});
|
|
56
|
+
applyItem(view, insert, from, to);
|
|
60
57
|
},
|
|
61
58
|
},
|
|
62
59
|
];
|
|
@@ -76,10 +73,7 @@ export function getItems(intl, item, { canManage, canAnalyze, onCompletionSelect
|
|
|
76
73
|
const type = "fact";
|
|
77
74
|
const insert = `{${type}/${item.fact.id}}`;
|
|
78
75
|
onCompletionSelected?.(completion);
|
|
79
|
-
view
|
|
80
|
-
changes: { from, to, insert },
|
|
81
|
-
selection: { anchor: from + insert.length },
|
|
82
|
-
});
|
|
76
|
+
applyItem(view, insert, from, to);
|
|
83
77
|
},
|
|
84
78
|
},
|
|
85
79
|
];
|
|
@@ -98,10 +92,7 @@ export function getItems(intl, item, { canManage, canAnalyze, onCompletionSelect
|
|
|
98
92
|
const type = "metric";
|
|
99
93
|
const insert = `{${type}/${item.measure.id}}`;
|
|
100
94
|
onCompletionSelected?.(completion);
|
|
101
|
-
view
|
|
102
|
-
changes: { from, to, insert },
|
|
103
|
-
selection: { anchor: from + insert.length },
|
|
104
|
-
});
|
|
95
|
+
applyItem(view, insert, from, to);
|
|
105
96
|
},
|
|
106
97
|
},
|
|
107
98
|
];
|
|
@@ -121,10 +112,7 @@ export function getItems(intl, item, { canManage, canAnalyze, onCompletionSelect
|
|
|
121
112
|
const type = "attribute";
|
|
122
113
|
const insert = `{${type}/${attr.attribute.id}}`;
|
|
123
114
|
onCompletionSelected?.(completion);
|
|
124
|
-
view
|
|
125
|
-
changes: { from, to, insert },
|
|
126
|
-
selection: { anchor: from + insert.length },
|
|
127
|
-
});
|
|
115
|
+
applyItem(view, insert, from, to);
|
|
128
116
|
},
|
|
129
117
|
};
|
|
130
118
|
});
|
|
@@ -142,10 +130,7 @@ export function getItems(intl, item, { canManage, canAnalyze, onCompletionSelect
|
|
|
142
130
|
const type = "date";
|
|
143
131
|
const insert = `{${type}/${item.dataSet.id}}`;
|
|
144
132
|
onCompletionSelected?.(completion);
|
|
145
|
-
view
|
|
146
|
-
changes: { from, to, insert },
|
|
147
|
-
selection: { anchor: from + insert.length },
|
|
148
|
-
});
|
|
133
|
+
applyItem(view, insert, from, to);
|
|
149
134
|
},
|
|
150
135
|
},
|
|
151
136
|
...dateItems,
|
|
@@ -153,6 +138,12 @@ export function getItems(intl, item, { canManage, canAnalyze, onCompletionSelect
|
|
|
153
138
|
}
|
|
154
139
|
return [];
|
|
155
140
|
}
|
|
141
|
+
function applyItem(view, insert, from, to) {
|
|
142
|
+
view.dispatch({
|
|
143
|
+
changes: { from: from - 1, to, insert },
|
|
144
|
+
selection: { anchor: from - 1 + insert.length },
|
|
145
|
+
});
|
|
146
|
+
}
|
|
156
147
|
// Utility: Get completion item ID
|
|
157
148
|
export function getCompletionItemId(data) {
|
|
158
149
|
return getCatalogItemId(data.item);
|
|
@@ -386,12 +386,12 @@ export const en_US = {
|
|
|
386
386
|
"crowdinContext": "Column header in autocomplete suggestions showing the date"
|
|
387
387
|
},
|
|
388
388
|
"gd.gen-ai.autocomplete.input-info.mac": {
|
|
389
|
-
"text": "
|
|
390
|
-
"crowdinContext": "
|
|
389
|
+
"text": "Type <code>@</code> for suggestions",
|
|
390
|
+
"crowdinContext": "Instruction for Mac users describing that object suggestions appear after typing @"
|
|
391
391
|
},
|
|
392
392
|
"gd.gen-ai.autocomplete.input-info.win": {
|
|
393
|
-
"text": "
|
|
394
|
-
"crowdinContext": "
|
|
393
|
+
"text": "Type <code>@</code> for suggestions",
|
|
394
|
+
"crowdinContext": "Instruction for Windows users describing that object suggestions appear after typing @"
|
|
395
395
|
},
|
|
396
396
|
"gd.gen-ai.visualisation.menu": {
|
|
397
397
|
"text": "More actions",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gooddata/sdk-ui-gen-ai",
|
|
3
|
-
"version": "11.37.0-alpha.
|
|
3
|
+
"version": "11.37.0-alpha.4",
|
|
4
4
|
"description": "GoodData GenAI SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "GoodData Corporation",
|
|
@@ -56,18 +56,18 @@
|
|
|
56
56
|
"reselect": "5.1.1",
|
|
57
57
|
"tslib": "2.8.1",
|
|
58
58
|
"uuid": "11.1.0",
|
|
59
|
-
"@gooddata/api-client-tiger": "11.37.0-alpha.
|
|
60
|
-
"@gooddata/sdk-backend-spi": "11.37.0-alpha.
|
|
61
|
-
"@gooddata/sdk-model": "11.37.0-alpha.
|
|
62
|
-
"@gooddata/sdk-ui-charts": "11.37.0-alpha.
|
|
63
|
-
"@gooddata/sdk-ui": "11.37.0-alpha.
|
|
64
|
-
"@gooddata/sdk-ui-dashboard": "11.37.0-alpha.
|
|
65
|
-
"@gooddata/sdk-ui-filters": "11.37.0-alpha.
|
|
66
|
-
"@gooddata/sdk-ui-
|
|
67
|
-
"@gooddata/sdk-ui-
|
|
68
|
-
"@gooddata/sdk-ui-semantic-search": "11.37.0-alpha.
|
|
69
|
-
"@gooddata/
|
|
70
|
-
"@gooddata/
|
|
59
|
+
"@gooddata/api-client-tiger": "11.37.0-alpha.4",
|
|
60
|
+
"@gooddata/sdk-backend-spi": "11.37.0-alpha.4",
|
|
61
|
+
"@gooddata/sdk-model": "11.37.0-alpha.4",
|
|
62
|
+
"@gooddata/sdk-ui-charts": "11.37.0-alpha.4",
|
|
63
|
+
"@gooddata/sdk-ui": "11.37.0-alpha.4",
|
|
64
|
+
"@gooddata/sdk-ui-dashboard": "11.37.0-alpha.4",
|
|
65
|
+
"@gooddata/sdk-ui-filters": "11.37.0-alpha.4",
|
|
66
|
+
"@gooddata/sdk-ui-kit": "11.37.0-alpha.4",
|
|
67
|
+
"@gooddata/sdk-ui-theme-provider": "11.37.0-alpha.4",
|
|
68
|
+
"@gooddata/sdk-ui-semantic-search": "11.37.0-alpha.4",
|
|
69
|
+
"@gooddata/util": "11.37.0-alpha.4",
|
|
70
|
+
"@gooddata/sdk-ui-pivot": "11.37.0-alpha.4"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@microsoft/api-documenter": "^7.17.0",
|
|
@@ -110,13 +110,13 @@
|
|
|
110
110
|
"typescript": "5.9.3",
|
|
111
111
|
"vitest": "4.1.0",
|
|
112
112
|
"vitest-dom": "0.1.1",
|
|
113
|
-
"@gooddata/eslint-config": "11.37.0-alpha.
|
|
114
|
-
"@gooddata/i18n-toolkit": "11.37.0-alpha.
|
|
115
|
-
"@gooddata/
|
|
116
|
-
"@gooddata/
|
|
117
|
-
"@gooddata/
|
|
118
|
-
"@gooddata/
|
|
119
|
-
"@gooddata/
|
|
113
|
+
"@gooddata/eslint-config": "11.37.0-alpha.4",
|
|
114
|
+
"@gooddata/i18n-toolkit": "11.37.0-alpha.4",
|
|
115
|
+
"@gooddata/reference-workspace": "11.37.0-alpha.4",
|
|
116
|
+
"@gooddata/sdk-backend-mockingbird": "11.37.0-alpha.4",
|
|
117
|
+
"@gooddata/oxlint-config": "11.37.0-alpha.4",
|
|
118
|
+
"@gooddata/stylelint-config": "11.37.0-alpha.4",
|
|
119
|
+
"@gooddata/sdk-ui-theme-provider": "11.37.0-alpha.4"
|
|
120
120
|
},
|
|
121
121
|
"peerDependencies": {
|
|
122
122
|
"react": "^18.0.0 || ^19.0.0",
|