contentoh-components-library 21.6.11 → 21.6.12

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.
@@ -86,6 +86,19 @@ var GeneralInput = function GeneralInput(_ref) {
86
86
  _ref$handleChangeSugg = _ref.handleChangeSuggestion,
87
87
  handleChangeSuggestion = _ref$handleChangeSugg === void 0 ? function () {} : _ref$handleChangeSugg;
88
88
 
89
+ var parseOptionList = function parseOptionList(list) {
90
+ if (Array.isArray(list)) return list;
91
+ if (!list) return [];
92
+
93
+ try {
94
+ return JSON.parse(list);
95
+ } catch (_unused) {
96
+ return String(list).split(",").map(function (s) {
97
+ return s.trim();
98
+ }).filter(Boolean);
99
+ }
100
+ };
101
+
89
102
  var _useAiProductEdition = (0, _AiProductEdition.useAiProductEdition)(),
90
103
  isCreators = _useAiProductEdition.isCreators,
91
104
  suggestions = _useAiProductEdition.suggestions,
@@ -248,7 +261,7 @@ var GeneralInput = function GeneralInput(_ref) {
248
261
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
249
262
  value: "",
250
263
  children: description
251
- }), JSON.parse(optionList || "[]").map(function (element, index) {
264
+ }), parseOptionList(optionList).map(function (element, index) {
252
265
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
253
266
  value: element,
254
267
  children: element
@@ -126,7 +126,7 @@ var InputFormatter = function InputFormatter(_ref) {
126
126
  return value.replace(/<\/p><p>/gm, "\n").replace(/<\/?br>|<\/?p>/gm, "").replace(/\&nbsp;/gm, " ").replace(/\&amp;/gm, "&");
127
127
  };
128
128
 
129
- var _onChange = function onChange(valueInput, h) {
129
+ var _onChange = function onChange(valueInput, h, source) {
130
130
  var value = "";
131
131
 
132
132
  try {
@@ -147,7 +147,7 @@ var InputFormatter = function InputFormatter(_ref) {
147
147
 
148
148
  setCharsCounter(h.getLength() - 1);
149
149
  value = valueFormater(value);
150
- updateParentDescriptions(value, aiSuggestionAccepted);
150
+ if (source === "user") updateParentDescriptions(value, aiSuggestionAccepted);
151
151
  };
152
152
 
153
153
  var updateParentDescriptions = function updateParentDescriptions(finalValue, isAiAccepted) {
@@ -261,8 +261,8 @@ var InputFormatter = function InputFormatter(_ref) {
261
261
  e.preventDefault();
262
262
  }
263
263
  },
264
- onChange: function onChange(valueInput, user, range, h) {
265
- return _onChange(valueInput, h);
264
+ onChange: function onChange(valueInput, delta, source, h) {
265
+ return _onChange(valueInput, h, source);
266
266
  },
267
267
  onChangeSelection: getSelection,
268
268
  className: "quill ".concat(hasAiGeneration && "has-ai", " ").concat(isAiActive && "ai-generation")
@@ -44,7 +44,7 @@ var normalizeProduct = function normalizeProduct(product) {
44
44
  summary: productData.summary || null,
45
45
  version: productData.version || 0,
46
46
  // from tasks
47
- id_order: productData.orderId || 0,
47
+ id_order: productData.orderId || null,
48
48
  status: productData.statusByRetailer ? (0, _statusDictionary.getMinorStatusFromRetailerMap)(productData.statusByRetailer) : productData.status || null,
49
49
  datasheet_status: productData.datasheet_status || null,
50
50
  description_status: productData.description_status || null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.6.11",
3
+ "version": "21.6.12",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -54,6 +54,16 @@ export const GeneralInput = ({
54
54
 
55
55
  }) => {
56
56
 
57
+ const parseOptionList = (list) => {
58
+ if (Array.isArray(list)) return list;
59
+ if (!list) return [];
60
+ try {
61
+ return JSON.parse(list);
62
+ } catch {
63
+ return String(list).split(",").map((s) => s.trim()).filter(Boolean);
64
+ }
65
+ };
66
+
57
67
  const {
58
68
  isCreators,
59
69
  suggestions,
@@ -211,7 +221,7 @@ export const GeneralInput = ({
211
221
  disabled={disabled}
212
222
  >
213
223
  <option value="">{description}</option>
214
- {JSON.parse(optionList || "[]").map((element, index) => (
224
+ {parseOptionList(optionList).map((element, index) => (
215
225
  <option key={element + "-" + index} value={element}>
216
226
  {element}
217
227
  </option>
@@ -75,7 +75,7 @@ export const InputFormatter = ({
75
75
  .replace(/\&amp;/gm, "&");
76
76
  };
77
77
 
78
- const onChange = (valueInput, h) => {
78
+ const onChange = (valueInput, h, source) => {
79
79
  let value = "";
80
80
  try {
81
81
  if (h.getLength() - 1 <= maxLength) {
@@ -99,7 +99,7 @@ export const InputFormatter = ({
99
99
  setCharsCounter(h.getLength() - 1);
100
100
  value = valueFormater(value);
101
101
 
102
- updateParentDescriptions(value, aiSuggestionAccepted);
102
+ if (source === "user") updateParentDescriptions(value, aiSuggestionAccepted);
103
103
  };
104
104
 
105
105
  const updateParentDescriptions = (finalValue, isAiAccepted) => {
@@ -231,9 +231,10 @@ export const InputFormatter = ({
231
231
  e.preventDefault();
232
232
  }
233
233
  }}
234
- onChange={(valueInput, user, range, h) => onChange(valueInput, h)}
234
+ onChange={(valueInput, delta, source, h) => onChange(valueInput, h, source)}
235
235
  onChangeSelection={getSelection}
236
236
  className={`quill ${hasAiGeneration && "has-ai"} ${isAiActive && "ai-generation"}`}
237
+
237
238
  />
238
239
  }
239
240
  {
@@ -45,7 +45,7 @@ export const normalizeProduct = (product) => {
45
45
  version: productData.version || 0,
46
46
 
47
47
  // from tasks
48
- id_order: productData.orderId || 0,
48
+ id_order: productData.orderId || null,
49
49
  status: productData.statusByRetailer
50
50
  ? getMinorStatusFromRetailerMap(productData.statusByRetailer)
51
51
  : productData.status || null,