optimized-react-component-library-xyz123 0.19.22 → 0.19.24

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 CHANGED
@@ -419,14 +419,13 @@ var TextFieldStandard = ({
419
419
  showPreview = false,
420
420
  activatedLanguage
421
421
  }) => {
422
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
422
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
423
423
  const questionId = `question-${question.id}`;
424
424
  const inputId = `textField-${question.id}`;
425
425
  const aboutId = `about-${question.id}`;
426
426
  const errorId = `error-${question.id}`;
427
- const defaultMaxLength = 100;
428
427
  const answerLength = (_b = (_a = question.answer) == null ? void 0 : _a.length) != null ? _b : 0;
429
- const maxLength = (_d = (_c = question.questionExtraAttribute) == null ? void 0 : _c.answerMaxLength) != null ? _d : defaultMaxLength;
428
+ const maxLength = 100;
430
429
  const isTooLong = answerLength > maxLength;
431
430
  const maxLengthErrorText = activatedLanguage === "en" ? `The text must be ${maxLength} characters or less` : `Texten f\xE5r max vara ${maxLength} tecken`;
432
431
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
@@ -434,7 +433,7 @@ var TextFieldStandard = ({
434
433
  "div",
435
434
  {
436
435
  id: questionId,
437
- className: `pts-root-question pts-textField-container${((_e = question.questionExtraAttribute) == null ? void 0 : _e.disabled) ? " pts-textField-disabled" : ""}${question.aboutText ? " pts-question-hasAbout" : ""}`.trim(),
436
+ className: `pts-root-question pts-textField-container${((_c = question.questionExtraAttribute) == null ? void 0 : _c.disabled) ? " pts-textField-disabled" : ""}${question.aboutText ? " pts-question-hasAbout" : ""}`.trim(),
438
437
  children: [
439
438
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { htmlFor: inputId, children: [
440
439
  question.questionLabel,
@@ -454,25 +453,25 @@ var TextFieldStandard = ({
454
453
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
455
454
  "input",
456
455
  {
457
- type: (_g = (_f = question.questionExtraAttribute) == null ? void 0 : _f.inputType) != null ? _g : "text",
458
- autoComplete: (_i = (_h = question.questionExtraAttribute) == null ? void 0 : _h.autoComplete) != null ? _i : void 0,
459
- inputMode: (_k = (_j = question.questionExtraAttribute) == null ? void 0 : _j.inputMode) != null ? _k : void 0,
456
+ type: (_e = (_d = question.questionExtraAttribute) == null ? void 0 : _d.inputType) != null ? _e : "text",
457
+ autoComplete: (_g = (_f = question.questionExtraAttribute) == null ? void 0 : _f.autoComplete) != null ? _g : void 0,
458
+ inputMode: (_i = (_h = question.questionExtraAttribute) == null ? void 0 : _h.inputMode) != null ? _i : void 0,
460
459
  name: `question-name-${question.id}`,
461
460
  className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0,
462
461
  onChange: (e) => handleQuestionInputChange(e, question),
463
462
  value: question.answer,
464
463
  id: inputId,
465
- disabled: (_l = question.questionExtraAttribute) == null ? void 0 : _l.disabled,
464
+ disabled: (_j = question.questionExtraAttribute) == null ? void 0 : _j.disabled,
466
465
  required: question.isQuestionMandatory,
467
466
  "aria-required": question.isQuestionMandatory,
468
467
  "aria-describedby": [question.aboutText ? aboutId : null].filter(Boolean).join(" ") || void 0,
469
468
  "aria-invalid": question.hasValidationError,
470
469
  "aria-errormessage": question.hasValidationError ? errorId : void 0,
471
- spellCheck: (_n = (_m = question.questionExtraAttribute) == null ? void 0 : _m.spellCheck) != null ? _n : void 0,
472
- autoCapitalize: (_p = (_o = question.questionExtraAttribute) == null ? void 0 : _o.autoCapitalize) != null ? _p : void 0
470
+ spellCheck: (_l = (_k = question.questionExtraAttribute) == null ? void 0 : _k.spellCheck) != null ? _l : void 0,
471
+ autoCapitalize: (_n = (_m = question.questionExtraAttribute) == null ? void 0 : _m.autoCapitalize) != null ? _n : void 0
473
472
  }
474
473
  ),
475
- question.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "pts-root-error", id: errorId, children: [
474
+ !isTooLong && question.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "pts-root-error", id: errorId, children: [
476
475
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "aria-hidden": true, className: "errorDot", children: "!" }),
477
476
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "sr-only", children: "Valideringsfel" }),
478
477
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "errorText", children: question.validationDefaultMessesege })
@@ -1217,6 +1216,11 @@ var hasQuestionValidationError = (question, questions) => {
1217
1216
  error = true;
1218
1217
  }
1219
1218
  }
1219
+ if (question.questionType === "TextField") {
1220
+ if (question.answer.length > 100) {
1221
+ error = true;
1222
+ }
1223
+ }
1220
1224
  if (((_c = question.validationType) == null ? void 0 : _c.find((e) => e === "email")) && (question.isQuestionMandatory || question.answer !== "")) {
1221
1225
  const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
1222
1226
  if (!emailRegex.test(question.answer)) {