contentoh-components-library 21.5.84 → 21.5.85
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.
|
@@ -114,10 +114,12 @@ var GeneralInput = function GeneralInput(_ref) {
|
|
|
114
114
|
setValueAccepted = _useState8[1];
|
|
115
115
|
|
|
116
116
|
var updateParentData = function updateParentData(generalValue, isAiAccepted) {
|
|
117
|
+
var newBaseValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
117
118
|
setTextValue({
|
|
118
119
|
value: generalValue
|
|
119
120
|
});
|
|
120
|
-
var
|
|
121
|
+
var baseToCompare = newBaseValue !== null ? newBaseValue : valueAccepted;
|
|
122
|
+
var similarity = (0, _compareStrings.getTextSimilarityPercentage)(baseToCompare, generalValue);
|
|
121
123
|
var generatedWithAi = (isAiAccepted || aiGenerated) && similarity >= 50;
|
|
122
124
|
|
|
123
125
|
if (updatedDatasheets || updatedDescriptions || inputType === "textarea") {
|
|
@@ -230,7 +232,7 @@ var GeneralInput = function GeneralInput(_ref) {
|
|
|
230
232
|
setValueAccepted(suggestionValue);
|
|
231
233
|
setAiSuggestionAccepted(true);
|
|
232
234
|
setIsAiActive(false);
|
|
233
|
-
updateParentData(suggestionValue, true);
|
|
235
|
+
updateParentData(suggestionValue, true, suggestionValue);
|
|
234
236
|
};
|
|
235
237
|
|
|
236
238
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Container, {
|
|
@@ -350,7 +350,7 @@ var TagAndInput = function TagAndInput(_ref) {
|
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
setInputsGeneratedWithAi(function (prev) {
|
|
353
|
-
return (0, _objectSpread6.default)((0, _objectSpread6.default)({}, prev), {}, (0, _defineProperty2.default)({}, "".concat(inputId, "-").concat(inputType, "-").concat(version
|
|
353
|
+
return (0, _objectSpread6.default)((0, _objectSpread6.default)({}, prev), {}, (0, _defineProperty2.default)({}, "".concat(inputId, "-").concat(inputType, "-").concat(version), {
|
|
354
354
|
inputType: inputType,
|
|
355
355
|
inputId: inputId,
|
|
356
356
|
version: version,
|
|
@@ -362,7 +362,7 @@ var TagAndInput = function TagAndInput(_ref) {
|
|
|
362
362
|
(0, _react.useEffect)(function () {
|
|
363
363
|
var _inputsGeneratedWithA;
|
|
364
364
|
|
|
365
|
-
setIsAiGenerated(!!((_inputsGeneratedWithA = inputsGeneratedWithAi["".concat(inputId, "-").concat(inputType, "-").concat(version
|
|
365
|
+
setIsAiGenerated(!!((_inputsGeneratedWithA = inputsGeneratedWithAi["".concat(inputId, "-").concat(inputType, "-").concat(version)]) !== null && _inputsGeneratedWithA !== void 0 && _inputsGeneratedWithA.isAiGenerated));
|
|
366
366
|
}, [inputsGeneratedWithAi]);
|
|
367
367
|
(0, _react.useEffect)(function () {
|
|
368
368
|
setInputsUsingAi(function (prev) {
|
package/package.json
CHANGED
|
@@ -68,11 +68,12 @@ export const GeneralInput = ({
|
|
|
68
68
|
const [aiSuggestionAccepted, setAiSuggestionAccepted] = useState(false);
|
|
69
69
|
const [valueAccepted, setValueAccepted] = useState(inputValue);
|
|
70
70
|
|
|
71
|
-
const updateParentData = (generalValue, isAiAccepted) => {
|
|
72
|
-
|
|
71
|
+
const updateParentData = (generalValue, isAiAccepted, newBaseValue = null) => {
|
|
73
72
|
setTextValue({ value: generalValue });
|
|
74
73
|
|
|
75
|
-
const
|
|
74
|
+
const baseToCompare = newBaseValue !== null ? newBaseValue : valueAccepted;
|
|
75
|
+
|
|
76
|
+
const similarity = getTextSimilarityPercentage(baseToCompare, generalValue);
|
|
76
77
|
|
|
77
78
|
const generatedWithAi = (isAiAccepted || aiGenerated) && similarity >= 50;
|
|
78
79
|
|
|
@@ -186,13 +187,13 @@ export const GeneralInput = ({
|
|
|
186
187
|
//AI Generation
|
|
187
188
|
|
|
188
189
|
const handleAcceptSuggestion = (suggestionValue) => {
|
|
189
|
-
|
|
190
|
+
if(!suggestionValue) return;
|
|
190
191
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
setValueAccepted(suggestionValue);
|
|
193
|
+
setAiSuggestionAccepted(true);
|
|
194
|
+
setIsAiActive(false);
|
|
194
195
|
|
|
195
|
-
|
|
196
|
+
updateParentData(suggestionValue, true, suggestionValue);
|
|
196
197
|
}
|
|
197
198
|
|
|
198
199
|
return (
|
|
@@ -234,7 +234,6 @@ export const TagAndInput = ({
|
|
|
234
234
|
}, [boxOnboardingList]);
|
|
235
235
|
|
|
236
236
|
useEffect(() => {
|
|
237
|
-
|
|
238
237
|
const currentDescriptionUpdate = Array.isArray(updatedDescriptions)
|
|
239
238
|
? updatedDescriptions.find(desc => desc?.attributeId === inputId)
|
|
240
239
|
: null;
|
|
@@ -253,7 +252,7 @@ export const TagAndInput = ({
|
|
|
253
252
|
|
|
254
253
|
setInputsGeneratedWithAi(prev => ({
|
|
255
254
|
...prev,
|
|
256
|
-
[`${inputId}-${inputType}-${version
|
|
255
|
+
[`${inputId}-${inputType}-${version}`]: {
|
|
257
256
|
inputType,
|
|
258
257
|
inputId,
|
|
259
258
|
version,
|
|
@@ -265,9 +264,7 @@ export const TagAndInput = ({
|
|
|
265
264
|
}, [updatedDescriptions, updatedDatasheets, aiGenerated, inputId]);
|
|
266
265
|
|
|
267
266
|
useEffect(() => {
|
|
268
|
-
|
|
269
|
-
setIsAiGenerated(!!inputsGeneratedWithAi[`${inputId}-${inputType}-${version ?? label}`]?.isAiGenerated);
|
|
270
|
-
|
|
267
|
+
setIsAiGenerated(!!inputsGeneratedWithAi[`${inputId}-${inputType}-${version}`]?.isAiGenerated);
|
|
271
268
|
}, [inputsGeneratedWithAi]);
|
|
272
269
|
|
|
273
270
|
useEffect(() => {
|