contentoh-components-library 21.5.99 → 21.6.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/dist/components/atoms/GeneralButton/styles.js +1 -1
- package/dist/components/atoms/GeneralInput/index.js +249 -54
- package/dist/components/atoms/GeneralInput/styles.js +7 -3
- package/dist/components/atoms/InputFormatter/index.js +223 -68
- package/dist/components/atoms/InputFormatter/styles.js +20 -4
- package/dist/components/molecules/StatusAsignationInfo/index.js +11 -1
- package/dist/components/molecules/TabsMenu/index.js +13 -1
- package/dist/components/molecules/TagAndInput/index.js +364 -24
- package/dist/components/molecules/TagAndInput/styles.js +2 -2
- package/dist/components/organisms/FullProductNameHeader/index.js +6 -22
- package/dist/components/organisms/InputGroup/index.js +22 -18
- package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +150 -337
- package/dist/components/pages/ProviderProductEdition/context/provider-product-edition.context.js +15 -15
- package/dist/components/pages/ProviderProductEdition/index.js +393 -352
- package/dist/components/pages/ProviderProductEdition/utils.js +1 -0
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +125 -211
- package/dist/components/pages/RetailerProductEdition/index.js +1743 -2239
- package/dist/components/pages/RetailerProductEdition/styles.js +4 -2
- package/dist/components/pages/RetailerProductEdition/utils.js +251 -2
- package/dist/contexts/AiProductEdition.js +34 -22
- package/package.json +4 -2
- package/src/ai/utils/compare-strings.js +45 -0
- package/src/assets/images/Icons/arrow.png +0 -0
- package/src/assets/images/Icons/cancel.png +0 -0
- package/src/assets/images/Icons/ia-icon.png +0 -0
- package/src/assets/images/Icons/loading.svg +5 -0
- package/src/assets/images/Icons/reload.png +0 -0
- package/src/components/atoms/GeneralButton/styles.js +4 -0
- package/src/components/atoms/GeneralInput/index.js +241 -60
- package/src/components/atoms/GeneralInput/styles.js +81 -0
- package/src/components/atoms/InputFormatter/index.js +200 -51
- package/src/components/atoms/InputFormatter/styles.js +284 -0
- package/src/components/atoms/RetailerSelector/RetailerSelector.stories.js +10 -0
- package/src/components/atoms/RetailerSelector/index.js +3 -0
- package/src/components/atoms/RetailerSelector/styles.js +0 -0
- package/src/components/molecules/StatusAsignationInfo/index.js +9 -1
- package/src/components/molecules/TabsMenu/index.js +12 -0
- package/src/components/molecules/TagAndInput/index.js +294 -21
- package/src/components/molecules/TagAndInput/styles.js +59 -17
- package/src/components/organisms/ChangeStatusModal/index.jsx +488 -0
- package/src/components/organisms/ChangeStatusModal/styles.js +333 -0
- package/src/components/organisms/FullProductNameHeader/index.js +4 -28
- package/src/components/organisms/FullTabsMenu/index.js +1 -1
- package/src/components/organisms/InputGroup/index.js +12 -4
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +174 -202
- package/src/components/pages/ProviderProductEdition/context/provider-product-edition.context.jsx +14 -14
- package/src/components/pages/ProviderProductEdition/index.js +486 -417
- package/src/components/pages/ProviderProductEdition/utils.js +2 -2
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +136 -243
- package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +575 -0
- package/src/components/pages/RetailerProductEdition/context/provider-product-edition.reducer.js +62 -0
- package/src/components/pages/RetailerProductEdition/context/reducers/active-state.js +344 -0
- package/src/components/pages/RetailerProductEdition/context/reducers/inputs.js +155 -0
- package/src/components/pages/RetailerProductEdition/context/reducers/product.js +114 -0
- package/src/components/pages/RetailerProductEdition/context/reducers/system.js +60 -0
- package/src/components/pages/RetailerProductEdition/index.js +1580 -1719
- package/src/components/pages/RetailerProductEdition/index_old.js +1979 -0
- package/src/components/pages/RetailerProductEdition/stories/Auditor.stories.js +101 -0
- package/src/components/pages/RetailerProductEdition/stories/ImageEditor.stories.js +115 -0
- package/src/components/pages/RetailerProductEdition/stories/TextEditor.stories.js +174 -0
- package/src/components/pages/RetailerProductEdition/styles.js +67 -2
- package/src/components/pages/RetailerProductEdition/utils.js +240 -0
- package/src/contexts/AiProductEdition.jsx +356 -0
- package/src/global-files/statusDictionary.js +103 -0
|
@@ -47,7 +47,7 @@ var _variables = require("../../../global-files/variables");
|
|
|
47
47
|
|
|
48
48
|
var _templateObject;
|
|
49
49
|
|
|
50
|
-
var Container = _styledComponents.default.button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n background-color: #e33aa9;\n border: none;\n border-radius: 30px;\n color: #fff;\n font-family: ", ";\n font-style: normal;\n font-weight: normal;\n font-size: 18px;\n line-height: 22px;\n padding: 10px 25px;\n cursor: pointer;\n\n &:hover {\n opacity: 0.7;\n }\n\n &.general-purple-button {\n background-color: #603888;\n }\n\n &.general-transparent-button {\n background-color: transparent;\n border: 1px solid #503d66;\n color: #503d66;\n }\n &.general-white-button {\n background-color: ", ";\n color: ", ";\n }\n\n &.general-green-button {\n background-color: #71de56;\n }\n\n &.circular-button {\n width: 25px;\n height: 25px;\n padding: 0;\n background-color: transparent;\n background-repeat: no-repeat;\n background-position: center;\n\n &.accept-button {\n background-image: url(", ");\n }\n\n &.reject-button {\n background-image: url(", ");\n }\n\n &.null-button {\n background-image: url(", ");\n }\n\n &.save-button {\n background-image: url(", ");\n border: 1px solid ", ";\n border-radius: 15px;\n\n &:hover {\n background-image: url(", ");\n background-color: ", ";\n border: 1px solid ", ";\n }\n }\n\n &.delete-button {\n background-image: url(", ");\n border: 1px solid ", ";\n border-radius: 15px;\n background-size: 15px;\n\n &:hover {\n background-image: url(", ");\n background-color: ", ";\n border: 1px solid ", ";\n }\n }\n\n &.download-button {\n background-image: url(", ");\n border: 1px solid ", ";\n border-radius: 15px;\n background-size: 15px;\n\n &:hover {\n color: white;\n background-color: ", ";\n border: 1px solid ", ";\n }\n }\n\n &.disabled {\n opacity: 0.5;\n }\n\n img {\n width: 100%;\n }\n\n &.version-button {\n color: ", ";\n border: 1px solid ", ";\n border-radius: 15px;\n font-size: 12px;\n line-height: 25px;\n text-align: center;\n filter: brightness(.35);\n }\n }\n\n &.general-arrow-button {\n background-image: url(", ");\n width: 27px;\n height: 27px;\n background-color: transparent;\n background-repeat: no-repeat;\n background-position: center;\n }\n\n &.close-button {\n width: 52px;\n height: 52px;\n background-color: transparent;\n background-repeat: no-repeat;\n background-position: center;\n background-image: url(", ");\n }\n\n &.close-buttonv2 {\n width: 52px;\n height: 52px;\n background-color: transparent;\n background-repeat: no-repeat;\n background-position: center;\n background-image: url(", ");\n }\n\n &.close-button-white {\n width: 52px;\n height: 52px;\n background-color: transparent;\n background-repeat: no-repeat;\n background-position: center;\n background-image: url(", ");\n }\n\n &.open-modal-button {\n background-color: transparent;\n border: none;\n cursor: pointer;\n position: absolute;\n right: 10px;\n bottom: 10px;\n background-color: transparent;\n background-repeat: no-repeat;\n background-position: center;\n width: 21px;\n height: 21px;\n padding: 0;\n border-radius: 0;\n background-image: url(", ");\n }\n\n &.grid-layout,\n &.row-layout {\n background-color: transparent;\n background-repeat: no-repeat;\n width: 24px;\n height: 24px;\n padding: 0;\n }\n\n &.grid-layout {\n background-image: url(", ");\n }\n\n &.row-layout {\n background-image: url(", ");\n }\n\n &.general-button-disabled {\n background-color: grey;\n color: ", ";\n\n &:hover {\n opacity: 1;\n }\n }\n &.general-button-rec {\n background:#85BC5B;\n color: ", ";\n padding: 4px 5px;\n border-radius: 3px;\n font-size: 10px;\n height: 20px;\n line-height: 12px;\n text-align: center;\n }\n\n &.general-button-sol {\n background-color: #e33aa9;\n border: none;\n border-radius: 50px;\n color: ", ";\n height: 34px;\n font-family: Avenir Next;\n font-style: normal;\n font-weight: normal;\n font-size: 12px;\n line-height: 14px;\n padding: 10px 15px;\n cursor: pointer;\n }\n"])), function (props) {
|
|
50
|
+
var Container = _styledComponents.default.button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n background-color: #e33aa9;\n border: none;\n border-radius: 30px;\n color: #fff;\n font-family: ", ";\n font-style: normal;\n font-weight: normal;\n font-size: 18px;\n line-height: 22px;\n padding: 10px 25px;\n cursor: pointer;\n\n &:hover {\n opacity: 0.7;\n }\n\n &.general-purple-button {\n background-color: #603888;\n }\n\n &.general-pink-button {\n background-color: #E33AA9;\n }\n\n &.general-transparent-button {\n background-color: transparent;\n border: 1px solid #503d66;\n color: #503d66;\n }\n &.general-white-button {\n background-color: ", ";\n color: ", ";\n }\n\n &.general-green-button {\n background-color: #71de56;\n }\n\n &.circular-button {\n width: 25px;\n height: 25px;\n padding: 0;\n background-color: transparent;\n background-repeat: no-repeat;\n background-position: center;\n\n &.accept-button {\n background-image: url(", ");\n }\n\n &.reject-button {\n background-image: url(", ");\n }\n\n &.null-button {\n background-image: url(", ");\n }\n\n &.save-button {\n background-image: url(", ");\n border: 1px solid ", ";\n border-radius: 15px;\n\n &:hover {\n background-image: url(", ");\n background-color: ", ";\n border: 1px solid ", ";\n }\n }\n\n &.delete-button {\n background-image: url(", ");\n border: 1px solid ", ";\n border-radius: 15px;\n background-size: 15px;\n\n &:hover {\n background-image: url(", ");\n background-color: ", ";\n border: 1px solid ", ";\n }\n }\n\n &.download-button {\n background-image: url(", ");\n border: 1px solid ", ";\n border-radius: 15px;\n background-size: 15px;\n\n &:hover {\n color: white;\n background-color: ", ";\n border: 1px solid ", ";\n }\n }\n\n &.disabled {\n opacity: 0.5;\n }\n\n img {\n width: 100%;\n }\n\n &.version-button {\n color: ", ";\n border: 1px solid ", ";\n border-radius: 15px;\n font-size: 12px;\n line-height: 25px;\n text-align: center;\n filter: brightness(.35);\n }\n }\n\n &.general-arrow-button {\n background-image: url(", ");\n width: 27px;\n height: 27px;\n background-color: transparent;\n background-repeat: no-repeat;\n background-position: center;\n }\n\n &.close-button {\n width: 52px;\n height: 52px;\n background-color: transparent;\n background-repeat: no-repeat;\n background-position: center;\n background-image: url(", ");\n }\n\n &.close-buttonv2 {\n width: 52px;\n height: 52px;\n background-color: transparent;\n background-repeat: no-repeat;\n background-position: center;\n background-image: url(", ");\n }\n\n &.close-button-white {\n width: 52px;\n height: 52px;\n background-color: transparent;\n background-repeat: no-repeat;\n background-position: center;\n background-image: url(", ");\n }\n\n &.open-modal-button {\n background-color: transparent;\n border: none;\n cursor: pointer;\n position: absolute;\n right: 10px;\n bottom: 10px;\n background-color: transparent;\n background-repeat: no-repeat;\n background-position: center;\n width: 21px;\n height: 21px;\n padding: 0;\n border-radius: 0;\n background-image: url(", ");\n }\n\n &.grid-layout,\n &.row-layout {\n background-color: transparent;\n background-repeat: no-repeat;\n width: 24px;\n height: 24px;\n padding: 0;\n }\n\n &.grid-layout {\n background-image: url(", ");\n }\n\n &.row-layout {\n background-image: url(", ");\n }\n\n &.general-button-disabled {\n background-color: grey;\n color: ", ";\n\n &:hover {\n opacity: 1;\n }\n }\n &.general-button-rec {\n background:#85BC5B;\n color: ", ";\n padding: 4px 5px;\n border-radius: 3px;\n font-size: 10px;\n height: 20px;\n line-height: 12px;\n text-align: center;\n }\n\n &.general-button-sol {\n background-color: #e33aa9;\n border: none;\n border-radius: 50px;\n color: ", ";\n height: 34px;\n font-family: Avenir Next;\n font-style: normal;\n font-weight: normal;\n font-size: 12px;\n line-height: 14px;\n padding: 10px 15px;\n cursor: pointer;\n }\n"])), function (props) {
|
|
51
51
|
return props.buttonFont;
|
|
52
52
|
}, _variables.GlobalColors.s1, _variables.GlobalColors.original_purpura, _acceptIcon.default, _rejectIcon.default, _nullIcon.default, _saveIcon.default, _variables.GlobalColors.color_gray, _saveIconHover.default, _variables.GlobalColors.color_pink, _variables.GlobalColors.color_pink, _deleteIcon.default, _variables.GlobalColors.s3, _deleteIconHover.default, _variables.GlobalColors.magenta_s2, _variables.GlobalColors.magenta_s2, _downloadIcon.default, _variables.GlobalColors.s3, _variables.GlobalColors.magenta_s2, _variables.GlobalColors.magenta_s2, _variables.GlobalColors.color_purple, _variables.GlobalColors.color_purple, _arrowIcon.default, _closeIcon.default, _closeIconv.default, _closeIconWhite.default, _openModal.default, _rowLayout.default, _gridLayout.default, _variables.GlobalColors.white, _variables.GlobalColors.white, _variables.GlobalColors.white);
|
|
53
53
|
|
|
@@ -17,9 +17,27 @@ var _InputFormatter = require("../InputFormatter");
|
|
|
17
17
|
|
|
18
18
|
var _CheckBox = require("../CheckBox");
|
|
19
19
|
|
|
20
|
+
var _iaIcon = _interopRequireDefault(require("../../../assets/images/Icons/ia-icon.png"));
|
|
21
|
+
|
|
22
|
+
var _loading = _interopRequireDefault(require("../../../assets/images/Icons/loading.svg"));
|
|
23
|
+
|
|
24
|
+
var _arrow = _interopRequireDefault(require("../../../assets/images/Icons/arrow.png"));
|
|
25
|
+
|
|
26
|
+
var _cancel = _interopRequireDefault(require("../../../assets/images/Icons/cancel.png"));
|
|
27
|
+
|
|
28
|
+
var _reload = _interopRequireDefault(require("../../../assets/images/Icons/reload.png"));
|
|
29
|
+
|
|
30
|
+
var _AiProductEdition = require("../../../contexts/AiProductEdition");
|
|
31
|
+
|
|
32
|
+
var _styles2 = require("../InputFormatter/styles");
|
|
33
|
+
|
|
34
|
+
var _compareStrings = require("../../../ai/utils/compare-strings");
|
|
35
|
+
|
|
20
36
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
37
|
|
|
22
38
|
var GeneralInput = function GeneralInput(_ref) {
|
|
39
|
+
var _currentSuggestion$in, _currentSuggestion$in2, _currentSuggestion$in3, _suggestions$inputId2, _currentSuggestion$in4, _suggestions$inputId3;
|
|
40
|
+
|
|
23
41
|
var inputType = _ref.inputType,
|
|
24
42
|
inputId = _ref.inputId,
|
|
25
43
|
inputName = _ref.inputName,
|
|
@@ -44,7 +62,35 @@ var GeneralInput = function GeneralInput(_ref) {
|
|
|
44
62
|
inputOnChange = _ref.inputOnChange,
|
|
45
63
|
disabled = _ref.disabled,
|
|
46
64
|
onKeyDown = _ref.onKeyDown,
|
|
47
|
-
auditClass = _ref.auditClass
|
|
65
|
+
auditClass = _ref.auditClass,
|
|
66
|
+
_ref$hasAiGeneration = _ref.hasAiGeneration,
|
|
67
|
+
hasAiGeneration = _ref$hasAiGeneration === void 0 ? false : _ref$hasAiGeneration,
|
|
68
|
+
_ref$isBenefitInput = _ref.isBenefitInput,
|
|
69
|
+
isBenefitInput = _ref$isBenefitInput === void 0 ? false : _ref$isBenefitInput,
|
|
70
|
+
_ref$isAiGenerationLo = _ref.isAiGenerationLoading,
|
|
71
|
+
isAiGenerationLoading = _ref$isAiGenerationLo === void 0 ? false : _ref$isAiGenerationLo,
|
|
72
|
+
_ref$isAiRegeneration = _ref.isAiRegenerationLoading,
|
|
73
|
+
isAiRegenerationLoading = _ref$isAiRegeneration === void 0 ? false : _ref$isAiRegeneration,
|
|
74
|
+
_ref$isAiActive = _ref.isAiActive,
|
|
75
|
+
isAiActive = _ref$isAiActive === void 0 ? false : _ref$isAiActive,
|
|
76
|
+
_ref$isAiAvailable = _ref.isAiAvailable,
|
|
77
|
+
isAiAvailable = _ref$isAiAvailable === void 0 ? false : _ref$isAiAvailable,
|
|
78
|
+
_ref$aiGenerated = _ref.aiGenerated,
|
|
79
|
+
aiGenerated = _ref$aiGenerated === void 0 ? false : _ref$aiGenerated,
|
|
80
|
+
_ref$setIsAiActive = _ref.setIsAiActive,
|
|
81
|
+
setIsAiActive = _ref$setIsAiActive === void 0 ? function () {} : _ref$setIsAiActive,
|
|
82
|
+
_ref$handlerAiGenerat = _ref.handlerAiGeneration,
|
|
83
|
+
_handlerAiGeneration = _ref$handlerAiGenerat === void 0 ? function () {} : _ref$handlerAiGenerat,
|
|
84
|
+
_ref$handlerRegenerat = _ref.handlerRegenerateSuggestions,
|
|
85
|
+
_handlerRegenerateSuggestions = _ref$handlerRegenerat === void 0 ? function () {} : _ref$handlerRegenerat,
|
|
86
|
+
_ref$handleChangeSugg = _ref.handleChangeSuggestion,
|
|
87
|
+
handleChangeSuggestion = _ref$handleChangeSugg === void 0 ? function () {} : _ref$handleChangeSugg;
|
|
88
|
+
|
|
89
|
+
var _useAiProductEdition = (0, _AiProductEdition.useAiProductEdition)(),
|
|
90
|
+
isCreators = _useAiProductEdition.isCreators,
|
|
91
|
+
suggestions = _useAiProductEdition.suggestions,
|
|
92
|
+
currentSuggestion = _useAiProductEdition.currentSuggestion,
|
|
93
|
+
setCurrentSuggestionValue = _useAiProductEdition.setCurrentSuggestionValue;
|
|
48
94
|
|
|
49
95
|
var _useState = (0, _react.useState)({
|
|
50
96
|
value: inputValue
|
|
@@ -58,28 +104,27 @@ var GeneralInput = function GeneralInput(_ref) {
|
|
|
58
104
|
requiredEmpty = _useState4[0],
|
|
59
105
|
setRequiredEmpty = _useState4[1];
|
|
60
106
|
|
|
61
|
-
var
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
} else if (updatedDatasheets || updatedDescriptions || inputType === "textarea") {
|
|
67
|
-
var generalValue;
|
|
107
|
+
var _useState5 = (0, _react.useState)(false),
|
|
108
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
109
|
+
aiSuggestionAccepted = _useState6[0],
|
|
110
|
+
setAiSuggestionAccepted = _useState6[1];
|
|
68
111
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
value: generalValue
|
|
74
|
-
});
|
|
75
|
-
} else {
|
|
76
|
-
generalValue = inputType === "checkbox" ? evt.target.checked : evt.target.value;
|
|
77
|
-
setTextValue({
|
|
78
|
-
value: generalValue
|
|
79
|
-
});
|
|
80
|
-
}
|
|
112
|
+
var _useState7 = (0, _react.useState)(inputValue),
|
|
113
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
114
|
+
valueAccepted = _useState8[0],
|
|
115
|
+
setValueAccepted = _useState8[1];
|
|
81
116
|
|
|
82
|
-
|
|
117
|
+
var updateParentData = function updateParentData(generalValue, isAiAccepted) {
|
|
118
|
+
var newBaseValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
119
|
+
setTextValue({
|
|
120
|
+
value: generalValue
|
|
121
|
+
});
|
|
122
|
+
var baseToCompare = newBaseValue !== null ? newBaseValue : valueAccepted;
|
|
123
|
+
var similarity = (0, _compareStrings.getTextSimilarityPercentage)(baseToCompare, generalValue);
|
|
124
|
+
var generatedWithAi = (isAiAccepted || aiGenerated) && similarity >= 50;
|
|
125
|
+
|
|
126
|
+
if (updatedDatasheets || updatedDescriptions || inputType === "textarea") {
|
|
127
|
+
var dataSave = (updatedDatasheets === null || updatedDatasheets === void 0 ? void 0 : updatedDatasheets.slice()) || [];
|
|
83
128
|
|
|
84
129
|
if ((dataSave === null || dataSave === void 0 ? void 0 : dataSave.length) > 0) {
|
|
85
130
|
var index = dataSave.findIndex(function (e) {
|
|
@@ -87,25 +132,52 @@ var GeneralInput = function GeneralInput(_ref) {
|
|
|
87
132
|
});
|
|
88
133
|
|
|
89
134
|
if (index !== -1) {
|
|
90
|
-
if (generalValue !== inputValue)
|
|
135
|
+
if (generalValue !== inputValue) {
|
|
136
|
+
dataSave[index].value = generalValue;
|
|
137
|
+
dataSave[index].aiSuggestionAccepted = generatedWithAi;
|
|
138
|
+
} else {
|
|
139
|
+
dataSave.splice(index, 1);
|
|
140
|
+
}
|
|
91
141
|
} else {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
142
|
+
if (generalValue !== inputValue) {
|
|
143
|
+
dataSave.push({
|
|
144
|
+
articleId: articleId,
|
|
145
|
+
attributeId: inputId,
|
|
146
|
+
value: generalValue,
|
|
147
|
+
aiSuggestionAccepted: generatedWithAi
|
|
148
|
+
});
|
|
149
|
+
}
|
|
97
150
|
}
|
|
98
151
|
} else {
|
|
99
152
|
if (generalValue !== inputValue) {
|
|
100
153
|
dataSave.push({
|
|
101
154
|
articleId: articleId,
|
|
102
155
|
attributeId: inputId,
|
|
103
|
-
value: generalValue
|
|
156
|
+
value: generalValue,
|
|
157
|
+
aiSuggestionAccepted: generatedWithAi
|
|
104
158
|
});
|
|
105
159
|
}
|
|
106
160
|
}
|
|
107
161
|
|
|
108
162
|
setUpdatedDatasheets(dataSave);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
var onHandleChange = function onHandleChange(evt) {
|
|
167
|
+
if (validateInput) {
|
|
168
|
+
setTextValue({
|
|
169
|
+
value: validateInput(evt, position, inputsArray)
|
|
170
|
+
});
|
|
171
|
+
} else if (updatedDatasheets || updatedDescriptions || inputType === "textarea") {
|
|
172
|
+
var generalValue;
|
|
173
|
+
|
|
174
|
+
if ((optionList === null || optionList === void 0 ? void 0 : optionList.length) > 0) {
|
|
175
|
+
generalValue = evt.target.value;
|
|
176
|
+
} else {
|
|
177
|
+
generalValue = inputType === "checkbox" ? evt.target.checked : evt.target.value;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
updateParentData(generalValue, aiSuggestionAccepted);
|
|
109
181
|
} else {
|
|
110
182
|
setTextValue({
|
|
111
183
|
value: evt.target.value
|
|
@@ -115,20 +187,52 @@ var GeneralInput = function GeneralInput(_ref) {
|
|
|
115
187
|
};
|
|
116
188
|
|
|
117
189
|
(0, _react.useEffect)(function () {
|
|
118
|
-
var
|
|
190
|
+
var _suggestions$inputId;
|
|
119
191
|
|
|
120
|
-
|
|
121
|
-
|
|
192
|
+
if (!isCreators) return;
|
|
193
|
+
if (Object.keys(suggestions).length === 0) return;
|
|
194
|
+
if (currentSuggestion !== null && currentSuggestion !== void 0 && currentSuggestion[inputId]) return;
|
|
195
|
+
var firstSuggestion = suggestions === null || suggestions === void 0 ? void 0 : (_suggestions$inputId = suggestions[inputId]) === null || _suggestions$inputId === void 0 ? void 0 : _suggestions$inputId[0];
|
|
196
|
+
if (!firstSuggestion) return;
|
|
197
|
+
setCurrentSuggestionValue({
|
|
198
|
+
inputId: inputId,
|
|
199
|
+
index: 0,
|
|
200
|
+
value: firstSuggestion === null || firstSuggestion === void 0 ? void 0 : firstSuggestion.value
|
|
201
|
+
});
|
|
202
|
+
}, [suggestions]);
|
|
203
|
+
(0, _react.useEffect)(function () {
|
|
204
|
+
if (!isAiActive || !isCreators) return;
|
|
205
|
+
setAiSuggestionAccepted(false);
|
|
206
|
+
}, [isAiActive]);
|
|
207
|
+
(0, _react.useEffect)(function () {
|
|
208
|
+
if (!isCreators) return;
|
|
122
209
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
210
|
+
if (!isAiActive && !aiSuggestionAccepted) {
|
|
211
|
+
setTextValue({
|
|
212
|
+
value: valueAccepted
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}, [suggestions, isAiActive]);
|
|
216
|
+
(0, _react.useEffect)(function () {
|
|
217
|
+
var _textValue$value;
|
|
126
218
|
|
|
127
|
-
|
|
219
|
+
setRequiredEmpty(isRequired && (((_textValue$value = textValue.value) === null || _textValue$value === void 0 ? void 0 : _textValue$value.length) === 0 || textValue.value === undefined));
|
|
220
|
+
}, [textValue]); // const numberInputOnWheelPreventChange = (e) => {
|
|
221
|
+
// // Prevent the input value change
|
|
222
|
+
// e.target.blur();
|
|
223
|
+
// // Prevent the page/container scrolling
|
|
224
|
+
// e.stopPropagation();
|
|
225
|
+
// // Refocus immediately, on the next tick (after the current function is done)
|
|
226
|
+
// setTimeout(() => e.target.focus(), 0);
|
|
227
|
+
// };
|
|
228
|
+
//AI Generation
|
|
128
229
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
230
|
+
var handleAcceptSuggestion = function handleAcceptSuggestion(suggestionValue) {
|
|
231
|
+
if (!suggestionValue || !isCreators) return;
|
|
232
|
+
setValueAccepted(suggestionValue);
|
|
233
|
+
setAiSuggestionAccepted(true);
|
|
234
|
+
setIsAiActive(false);
|
|
235
|
+
updateParentData(suggestionValue, true, suggestionValue);
|
|
132
236
|
};
|
|
133
237
|
|
|
134
238
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Container, {
|
|
@@ -157,21 +261,94 @@ var GeneralInput = function GeneralInput(_ref) {
|
|
|
157
261
|
},
|
|
158
262
|
defaultChecked: textValue.value === "true" ? true : false,
|
|
159
263
|
disabled: disabled
|
|
160
|
-
}) : inputType !== "textarea" ? /*#__PURE__*/(0, _jsxRuntime.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
264
|
+
}) : inputType !== "textarea" ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
265
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles2.InputContainer, {
|
|
266
|
+
className: hasAiGeneration ? "ai-generation" : "",
|
|
267
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
268
|
+
type: inputType,
|
|
269
|
+
disabled: disabled,
|
|
270
|
+
id: inputId,
|
|
271
|
+
size: inputSize,
|
|
272
|
+
className: "general-input ".concat(isAiActive && isBenefitInput && "ia-input"),
|
|
273
|
+
placeholder: inputPlaceholder,
|
|
274
|
+
value: isAiActive ? currentSuggestion === null || currentSuggestion === void 0 ? void 0 : (_currentSuggestion$in = currentSuggestion[inputId]) === null || _currentSuggestion$in === void 0 ? void 0 : _currentSuggestion$in.value : textValue.value,
|
|
275
|
+
onInput: function onInput(e) {
|
|
276
|
+
return onHandleChange(e);
|
|
277
|
+
},
|
|
278
|
+
maxLength: maxChar,
|
|
279
|
+
required: isRequired,
|
|
280
|
+
onKeyDown: onKeyDown // onWheel={numberInputOnWheelPreventChange}
|
|
281
|
+
|
|
282
|
+
}), hasAiGeneration && isBenefitInput && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
283
|
+
className: "icon_container ".concat(isAiAvailable ? "ai-available" : '', " ").concat(isAiActive ? 'ai-active' : ''),
|
|
284
|
+
title: !isAiAvailable ? 'Debes de completar ficha técnica e imágenes para desbloquear la generación con IA' : '',
|
|
285
|
+
onClick: function onClick() {
|
|
286
|
+
_handlerAiGeneration({
|
|
287
|
+
type: "attribute"
|
|
288
|
+
});
|
|
289
|
+
},
|
|
290
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
291
|
+
className: "".concat(isAiGenerationLoading ? 'loading' : ''),
|
|
292
|
+
src: isAiGenerationLoading ? _loading.default : isAiActive ? _cancel.default : _iaIcon.default
|
|
293
|
+
})
|
|
294
|
+
})]
|
|
295
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles2.BottomContainer, {
|
|
296
|
+
className: isAiActive ? "with-ai" : "",
|
|
297
|
+
children: isAiActive && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
298
|
+
className: "ai-options",
|
|
299
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles2.OptionsContainer, {
|
|
300
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
301
|
+
className: "arrow ".concat((currentSuggestion === null || currentSuggestion === void 0 ? void 0 : (_currentSuggestion$in2 = currentSuggestion[inputId]) === null || _currentSuggestion$in2 === void 0 ? void 0 : _currentSuggestion$in2.index) === 0 && "disabled"),
|
|
302
|
+
onClick: function onClick() {
|
|
303
|
+
handleChangeSuggestion({
|
|
304
|
+
action: "prev"
|
|
305
|
+
});
|
|
306
|
+
},
|
|
307
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
308
|
+
src: _arrow.default,
|
|
309
|
+
alt: ""
|
|
310
|
+
})
|
|
311
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
|
|
312
|
+
children: [(currentSuggestion === null || currentSuggestion === void 0 ? void 0 : (_currentSuggestion$in3 = currentSuggestion[inputId]) === null || _currentSuggestion$in3 === void 0 ? void 0 : _currentSuggestion$in3.index) + 1 || 1, "/", suggestions === null || suggestions === void 0 ? void 0 : (_suggestions$inputId2 = suggestions[inputId]) === null || _suggestions$inputId2 === void 0 ? void 0 : _suggestions$inputId2.length]
|
|
313
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
314
|
+
className: "arrow right ".concat((currentSuggestion === null || currentSuggestion === void 0 ? void 0 : (_currentSuggestion$in4 = currentSuggestion[inputId]) === null || _currentSuggestion$in4 === void 0 ? void 0 : _currentSuggestion$in4.index) === (suggestions === null || suggestions === void 0 ? void 0 : (_suggestions$inputId3 = suggestions[inputId]) === null || _suggestions$inputId3 === void 0 ? void 0 : _suggestions$inputId3.length) - 1 && "disabled"),
|
|
315
|
+
onClick: function onClick() {},
|
|
316
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
317
|
+
onClick: function onClick() {
|
|
318
|
+
handleChangeSuggestion({
|
|
319
|
+
action: "next"
|
|
320
|
+
});
|
|
321
|
+
},
|
|
322
|
+
src: _arrow.default,
|
|
323
|
+
alt: "ai icon"
|
|
324
|
+
})
|
|
325
|
+
})]
|
|
326
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles2.ButtonsContainer, {
|
|
327
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
328
|
+
className: "reload-suggestions ".concat(isAiRegenerationLoading && "loading"),
|
|
329
|
+
onClick: function onClick() {
|
|
330
|
+
_handlerRegenerateSuggestions({
|
|
331
|
+
type: "attribute"
|
|
332
|
+
});
|
|
333
|
+
},
|
|
334
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
335
|
+
className: "",
|
|
336
|
+
src: isAiRegenerationLoading ? _loading.default : _reload.default
|
|
337
|
+
})
|
|
338
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
339
|
+
className: "accept-suggestion",
|
|
340
|
+
onClick: function onClick() {
|
|
341
|
+
var _currentSuggestion$in5;
|
|
342
|
+
|
|
343
|
+
handleAcceptSuggestion(currentSuggestion === null || currentSuggestion === void 0 ? void 0 : (_currentSuggestion$in5 = currentSuggestion[inputId]) === null || _currentSuggestion$in5 === void 0 ? void 0 : _currentSuggestion$in5.value);
|
|
344
|
+
},
|
|
345
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
346
|
+
children: "Aceptar sugerencia"
|
|
347
|
+
})
|
|
348
|
+
})]
|
|
349
|
+
})]
|
|
350
|
+
})
|
|
351
|
+
})]
|
|
175
352
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputFormatter.InputFormatter, {
|
|
176
353
|
name: inputName,
|
|
177
354
|
inputId: inputId,
|
|
@@ -183,7 +360,25 @@ var GeneralInput = function GeneralInput(_ref) {
|
|
|
183
360
|
setUpdatedDescriptions: setUpdatedDescriptions,
|
|
184
361
|
maxChar: maxChar,
|
|
185
362
|
isRequired: isRequired,
|
|
186
|
-
disabled: disabled
|
|
363
|
+
disabled: disabled,
|
|
364
|
+
hasAiGeneration: hasAiGeneration && inputId != 'commentary-box',
|
|
365
|
+
isAiAvailable: isAiAvailable,
|
|
366
|
+
aiGenerated: aiGenerated,
|
|
367
|
+
handlerAiGeneration: function handlerAiGeneration() {
|
|
368
|
+
_handlerAiGeneration({
|
|
369
|
+
type: "description"
|
|
370
|
+
});
|
|
371
|
+
},
|
|
372
|
+
handlerRegenerateSuggestions: function handlerRegenerateSuggestions() {
|
|
373
|
+
_handlerRegenerateSuggestions({
|
|
374
|
+
type: "description"
|
|
375
|
+
});
|
|
376
|
+
},
|
|
377
|
+
handleChangeSuggestion: handleChangeSuggestion,
|
|
378
|
+
isAiGenerationLoading: isAiGenerationLoading,
|
|
379
|
+
isAiRegenerationLoading: isAiRegenerationLoading,
|
|
380
|
+
isAiActive: isAiActive,
|
|
381
|
+
setIsAiActive: setIsAiActive
|
|
187
382
|
})
|
|
188
383
|
});
|
|
189
384
|
};
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.Container = void 0;
|
|
8
|
+
exports.InputContainer = exports.Container = void 0;
|
|
9
9
|
|
|
10
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
|
|
11
11
|
|
|
@@ -13,7 +13,7 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
13
13
|
|
|
14
14
|
var _variables = require("../../../global-files/variables");
|
|
15
15
|
|
|
16
|
-
var _templateObject;
|
|
16
|
+
var _templateObject, _templateObject2;
|
|
17
17
|
|
|
18
18
|
var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n\n > div {\n label {\n &:before {\n outline: 1px solid ", ";\n }\n }\n }\n\n input,\n textarea {\n width: 100%;\n border: 1px solid\n ", ";\n\n font-family: ", ";\n color: ", ";\n font-weight: normal;\n font-size: 12px;\n line-height: 15px;\n padding: 10px;\n outline: none;\n border-radius: 5px;\n resize: none;\n\n &:focus {\n border: 1px solid ", ";\n }\n }\n\n select {\n background: #fafafa;\n outline: none;\n border: 1px solid\n ", ";\n width: 100%;\n cursor: pointer;\n font-family: ", ";\n color: ", ";\n font-size: 12px;\n line-height: 21px;\n padding: 10px;\n border-right: 2px solid #e33aa9;\n\n &:focus {\n border: 1px solid ", ";\n }\n }\n\n p {\n font-family: ", ";\n font-size: 12px;\n color: ", ";\n }\n\n &.audit-class {\n input,\n .quill {\n border: 1px solid #8a6caa;\n background-color: #ededfc;\n }\n }\n\n .btnReviewState {\n display: \"flex\";\n flex-direction: \"column\";\n border: 1px solid lightgray;\n border-radius: 3px;\n z-index: 1000;\n /* position: absolute; */\n }\n\n .btnReviewState button {\n border: none;\n background: white;\n border-radius: 3px;\n }\n .btnReviewState button:hover {\n background: lightgray;\n }\n"])), function (_ref) {
|
|
19
19
|
var isRequired = _ref.isRequired;
|
|
@@ -26,4 +26,8 @@ var Container = _styledComponents.default.div(_templateObject || (_templateObjec
|
|
|
26
26
|
return isRequired ? "red" : "".concat(_variables.GlobalColors.s2);
|
|
27
27
|
}, _variables.FontFamily.AvenirNext, _variables.GlobalColors.deep_gray, _variables.GlobalColors.magenta_s2, _variables.FontFamily.Raleway, _variables.GlobalColors.deep_gray);
|
|
28
28
|
|
|
29
|
-
exports.Container = Container;
|
|
29
|
+
exports.Container = Container;
|
|
30
|
+
|
|
31
|
+
var InputContainer = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n\n &.ai-generation {\n position: relative;\n\n cursor: pointer;\n\n .ia-input {\n padding-right: 2.5rem;\n }\n\n .icon_container {\n position: absolute;\n right: 10px;\n top: 50%;\n transform: translateY(-50%);\n width: 20px;\n height: 20px;\n padding: 4px;\n\n border-radius: 50%;\n overflow: hidden;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 1;\n\n &::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n\n background: linear-gradient(\n 120deg,\n #ffffff 10%,\n #ffe0f4 50%,\n #ffffff 90%\n );\n background-size: 200% 200%;\n\n animation: ai-shimmer 3s ease-in-out infinite alternate;\n z-index: -1;\n }\n\n &.ai-available::before{\n\n background: gray;\n background-size: 200% 200%;\n\n }\n\n img {\n width: 100%;\n height: 100%;\n object-fit: contain;\n position: relative;\n z-index: 2;\n }\n\n img.loading {\n width: 20px;\n height: 20px;\n }\n\n }\n }\n\n @keyframes ai-shimmer {\n 0% {\n background-position: 0% 50%;\n }\n 100% {\n background-position: 100% 50%;\n }\n }\n\n"])));
|
|
32
|
+
|
|
33
|
+
exports.InputContainer = InputContainer;
|