optimized-react-component-library-xyz123 3.3.1 → 3.3.2
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 +36 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/css/styles.css +1 -1
package/dist/index.js
CHANGED
|
@@ -386,20 +386,31 @@ var InputTextarea = ({
|
|
|
386
386
|
showPreview = false,
|
|
387
387
|
activatedLanguage
|
|
388
388
|
}) => {
|
|
389
|
-
var _a, _b, _c, _d, _e, _f;
|
|
389
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
390
390
|
const questionId = `question-${question.id}`;
|
|
391
391
|
const inputId = `textarea-${question.id}`;
|
|
392
392
|
const aboutId = `about-${question.id}`;
|
|
393
393
|
const errorId = `error-${question.id}`;
|
|
394
|
-
const [localAnswer, setLocalAnswer] = (0, import_react3.useState)(question.answer);
|
|
394
|
+
const [localAnswer, setLocalAnswer] = (0, import_react3.useState)((_a = question.answer) != null ? _a : "");
|
|
395
|
+
const lastSyncedAnswer = (0, import_react3.useRef)((_b = question.answer) != null ? _b : "");
|
|
396
|
+
(0, import_react3.useEffect)(() => {
|
|
397
|
+
var _a2;
|
|
398
|
+
const incomingFromRedux = (_a2 = question.answer) != null ? _a2 : "";
|
|
399
|
+
if (incomingFromRedux !== lastSyncedAnswer.current) {
|
|
400
|
+
setLocalAnswer(incomingFromRedux);
|
|
401
|
+
lastSyncedAnswer.current = incomingFromRedux;
|
|
402
|
+
}
|
|
403
|
+
}, [question.answer]);
|
|
395
404
|
const defaultMaxLength = 1e3;
|
|
396
|
-
const answerLength = (
|
|
397
|
-
const maxLength = (
|
|
405
|
+
const answerLength = (_d = (_c = question.answer) == null ? void 0 : _c.length) != null ? _d : 0;
|
|
406
|
+
const maxLength = (_f = (_e = question.questionExtraAttribute) == null ? void 0 : _e.answerMaxLength) != null ? _f : defaultMaxLength;
|
|
398
407
|
const isTooLong = answerLength > maxLength;
|
|
399
408
|
const counterText = activatedLanguage === "en" ? `${answerLength} of ${maxLength} characters` : `${answerLength} av ${maxLength} tecken`;
|
|
400
409
|
const maxLengthErrorText = activatedLanguage === "en" ? `The text must be ${maxLength} characters or less` : `Texten f\xE5r inte vara l\xE4ngre \xE4n ${maxLength} tecken`;
|
|
401
|
-
const
|
|
402
|
-
|
|
410
|
+
const handleOnChange = (e) => {
|
|
411
|
+
const value = e.target.value;
|
|
412
|
+
setLocalAnswer(value);
|
|
413
|
+
lastSyncedAnswer.current = value;
|
|
403
414
|
handleQuestionInputChange(e, question);
|
|
404
415
|
};
|
|
405
416
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
@@ -428,7 +439,7 @@ var InputTextarea = ({
|
|
|
428
439
|
"textarea",
|
|
429
440
|
{
|
|
430
441
|
className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0,
|
|
431
|
-
onChange:
|
|
442
|
+
onChange: handleOnChange,
|
|
432
443
|
value: localAnswer,
|
|
433
444
|
required: question.isQuestionMandatory,
|
|
434
445
|
"aria-required": question.isQuestionMandatory,
|
|
@@ -438,13 +449,13 @@ var InputTextarea = ({
|
|
|
438
449
|
}
|
|
439
450
|
),
|
|
440
451
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "pts-textarea-counter-error-container", children: [
|
|
441
|
-
!((
|
|
452
|
+
!((_g = question.questionExtraAttribute) == null ? void 0 : _g.hideTextCounter) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { "aria-live": "polite", className: `pts-character-counter`, children: counterText }),
|
|
442
453
|
!isTooLong && question.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
443
454
|
ValidationMessage_default,
|
|
444
455
|
{
|
|
445
456
|
showValidationMessage: true,
|
|
446
457
|
validationId: errorId,
|
|
447
|
-
validationMessesege: (
|
|
458
|
+
validationMessesege: (_h = question.validationDefaultMessesege) != null ? _h : "",
|
|
448
459
|
activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv"
|
|
449
460
|
}
|
|
450
461
|
),
|
|
@@ -494,20 +505,22 @@ var TextFieldStandard = ({
|
|
|
494
505
|
showPreview = false,
|
|
495
506
|
activatedLanguage
|
|
496
507
|
}) => {
|
|
497
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
508
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
498
509
|
const questionId = `question-${question.id}`;
|
|
499
510
|
const inputId = `textField-${question.id}`;
|
|
500
511
|
const aboutId = `about-${question.id}`;
|
|
501
512
|
const errorId = `error-${question.id}`;
|
|
502
513
|
const [localAnswer, setLocalAnswer] = (0, import_react4.useState)((_a = question.answer) != null ? _a : "");
|
|
503
|
-
const lastSyncedAnswer = (0, import_react4.useRef)(question.answer);
|
|
514
|
+
const lastSyncedAnswer = (0, import_react4.useRef)((_b = question.answer) != null ? _b : "");
|
|
504
515
|
(0, import_react4.useEffect)(() => {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
516
|
+
var _a2;
|
|
517
|
+
const incomingFromRedux = (_a2 = question.answer) != null ? _a2 : "";
|
|
518
|
+
if (incomingFromRedux !== lastSyncedAnswer.current) {
|
|
519
|
+
setLocalAnswer(incomingFromRedux);
|
|
520
|
+
lastSyncedAnswer.current = incomingFromRedux;
|
|
508
521
|
}
|
|
509
522
|
}, [question.answer]);
|
|
510
|
-
const answerLength = (
|
|
523
|
+
const answerLength = (_c = localAnswer == null ? void 0 : localAnswer.length) != null ? _c : 0;
|
|
511
524
|
const maxLength = 100;
|
|
512
525
|
const isTooLong = answerLength > maxLength;
|
|
513
526
|
const maxLengthErrorText = activatedLanguage === "en" ? `The text must be ${maxLength} characters or less` : `Texten f\xE5r inte vara l\xE4ngre \xE4n ${maxLength} tecken`;
|
|
@@ -522,7 +535,7 @@ var TextFieldStandard = ({
|
|
|
522
535
|
"div",
|
|
523
536
|
{
|
|
524
537
|
id: questionId,
|
|
525
|
-
className: `pts-root-question pts-textField-container ${((
|
|
538
|
+
className: `pts-root-question pts-textField-container ${((_d = question.questionExtraAttribute) == null ? void 0 : _d.disabled) ? " pts-textField-disabled" : ""}${question.aboutText ? " pts-question-hasAbout" : ""}`.trim(),
|
|
526
539
|
children: [
|
|
527
540
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { htmlFor: inputId, children: [
|
|
528
541
|
question.questionLabel,
|
|
@@ -542,21 +555,21 @@ var TextFieldStandard = ({
|
|
|
542
555
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
543
556
|
"input",
|
|
544
557
|
{
|
|
545
|
-
type: (
|
|
546
|
-
autoComplete: (
|
|
547
|
-
inputMode: (
|
|
558
|
+
type: (_f = (_e = question.questionExtraAttribute) == null ? void 0 : _e.inputType) != null ? _f : "text",
|
|
559
|
+
autoComplete: (_h = (_g = question.questionExtraAttribute) == null ? void 0 : _g.autoComplete) != null ? _h : void 0,
|
|
560
|
+
inputMode: (_j = (_i = question.questionExtraAttribute) == null ? void 0 : _i.inputMode) != null ? _j : void 0,
|
|
548
561
|
name: `question-name-${question.id}`,
|
|
549
562
|
className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0,
|
|
550
563
|
onChange: handleOnChange,
|
|
551
564
|
value: localAnswer,
|
|
552
565
|
id: inputId,
|
|
553
|
-
disabled: (
|
|
566
|
+
disabled: (_k = question.questionExtraAttribute) == null ? void 0 : _k.disabled,
|
|
554
567
|
required: question.isQuestionMandatory,
|
|
555
568
|
"aria-required": question.isQuestionMandatory,
|
|
556
569
|
"aria-describedby": [question.aboutText ? aboutId : null, question.hasValidationError ? errorId : null].filter(Boolean).join(" ") || void 0,
|
|
557
570
|
"aria-invalid": question.hasValidationError,
|
|
558
|
-
spellCheck: (
|
|
559
|
-
autoCapitalize: (
|
|
571
|
+
spellCheck: (_m = (_l = question.questionExtraAttribute) == null ? void 0 : _l.spellCheck) != null ? _m : void 0,
|
|
572
|
+
autoCapitalize: (_o = (_n = question.questionExtraAttribute) == null ? void 0 : _n.autoCapitalize) != null ? _o : void 0
|
|
560
573
|
}
|
|
561
574
|
),
|
|
562
575
|
!isTooLong && question.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -564,7 +577,7 @@ var TextFieldStandard = ({
|
|
|
564
577
|
{
|
|
565
578
|
showValidationMessage: true,
|
|
566
579
|
validationId: errorId,
|
|
567
|
-
validationMessesege: (
|
|
580
|
+
validationMessesege: (_p = question.validationDefaultMessesege) != null ? _p : "",
|
|
568
581
|
activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv"
|
|
569
582
|
}
|
|
570
583
|
),
|