optimized-react-component-library-xyz123 3.0.2 → 3.1.0
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/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -499,13 +499,22 @@ var TextFieldStandard = ({
|
|
|
499
499
|
const inputId = `textField-${question.id}`;
|
|
500
500
|
const aboutId = `about-${question.id}`;
|
|
501
501
|
const errorId = `error-${question.id}`;
|
|
502
|
-
const [localAnswer, setLocalAnswer] = (0, import_react4.useState)(question.answer);
|
|
503
|
-
const
|
|
502
|
+
const [localAnswer, setLocalAnswer] = (0, import_react4.useState)((_a = question.answer) != null ? _a : "");
|
|
503
|
+
const lastSyncedAnswer = (0, import_react4.useRef)(question.answer);
|
|
504
|
+
(0, import_react4.useEffect)(() => {
|
|
505
|
+
if (question.answer && question.answer !== lastSyncedAnswer.current) {
|
|
506
|
+
setLocalAnswer(question.answer);
|
|
507
|
+
lastSyncedAnswer.current = question.answer;
|
|
508
|
+
}
|
|
509
|
+
}, [question.answer]);
|
|
510
|
+
const answerLength = (_b = localAnswer == null ? void 0 : localAnswer.length) != null ? _b : 0;
|
|
504
511
|
const maxLength = 100;
|
|
505
512
|
const isTooLong = answerLength > maxLength;
|
|
506
513
|
const maxLengthErrorText = activatedLanguage === "en" ? `The text must be ${maxLength} characters or less` : `Texten f\xE5r inte vara l\xE4ngre \xE4n ${maxLength} tecken`;
|
|
507
|
-
const
|
|
508
|
-
|
|
514
|
+
const handleOnChange = (e) => {
|
|
515
|
+
const value = e.target.value;
|
|
516
|
+
setLocalAnswer(value);
|
|
517
|
+
lastSyncedAnswer.current = value;
|
|
509
518
|
handleQuestionInputChange(e, question);
|
|
510
519
|
};
|
|
511
520
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
@@ -538,7 +547,7 @@ var TextFieldStandard = ({
|
|
|
538
547
|
inputMode: (_i = (_h = question.questionExtraAttribute) == null ? void 0 : _h.inputMode) != null ? _i : void 0,
|
|
539
548
|
name: `question-name-${question.id}`,
|
|
540
549
|
className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0,
|
|
541
|
-
onChange:
|
|
550
|
+
onChange: handleOnChange,
|
|
542
551
|
value: localAnswer,
|
|
543
552
|
id: inputId,
|
|
544
553
|
disabled: (_j = question.questionExtraAttribute) == null ? void 0 : _j.disabled,
|