optimized-react-component-library-xyz123 0.1.157 → 0.1.159

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
@@ -237,8 +237,10 @@ var CheckboxGroup = ({
237
237
  showPreview = false,
238
238
  activatedLanguage = "sv"
239
239
  }) => {
240
- var _a;
240
+ var _a, _b;
241
241
  const questionId = `question-${question.id}`;
242
+ const errorId = `error-${question.id}`;
243
+ const groupId = `checkbox-group-${question.id}`;
242
244
  const [checkedValues, setCheckedValues] = (0, import_react2.useState)([]);
243
245
  (0, import_react2.useEffect)(() => {
244
246
  var _a2;
@@ -259,34 +261,44 @@ var CheckboxGroup = ({
259
261
  setCheckedValues(updatedValues);
260
262
  const e = { target: { value: updatedValues.toString() } };
261
263
  handleQuestionInputChange(e, question);
262
- console.log(checkedValues);
264
+ console.log("checkedValues" + checkedValues);
263
265
  };
264
266
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
265
- !showPreview && question.visible && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { id: questionId, className: "pts-root-question pts-checkboxGroup-container", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("fieldset", { children: [
266
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("legend", { className: "checkboxGroup-legend", id: `label-${questionId}`, children: [
267
- question.questionLabel,
268
- " ",
269
- question.isQuestionMandatory && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "aria-hidden": true, className: "pts-root-mandatoryAsterisk", children: "*" }),
270
- " "
271
- ] }),
272
- (_a = question.options) == null ? void 0 : _a.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "checkboxGroup-options", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
273
- " ",
274
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
275
- "input",
276
- {
277
- type: "checkbox",
278
- name: `${question.id}-option`,
279
- id: `${question.id}-option-${index}`,
280
- value: option.label,
281
- checked: checkedValues.includes(option.label),
282
- onChange: (e) => handleInputChange(e, option.label),
283
- className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0
284
- }
285
- ),
286
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { htmlFor: `${question.id}-option-${index}`, children: option.label })
287
- ] }) }, index))
288
- ] }) }),
289
- " ",
267
+ !showPreview && question.visible && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { id: questionId, className: "pts-root-question pts-checkboxGroup-container", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
268
+ "fieldset",
269
+ {
270
+ "aria-required": question.isQuestionMandatory,
271
+ "aria-invalid": question.hasValidationError ? question.hasValidationError : void 0,
272
+ "aria-errormessage": question.hasValidationError ? errorId : void 0,
273
+ children: [
274
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("legend", { className: "pts-checkboxGroup-legend", id: `label-${groupId}`, children: [
275
+ question.questionLabel,
276
+ " ",
277
+ question.isQuestionMandatory && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "aria-hidden": true, className: "pts-root-mandatoryAsterisk", children: "*" })
278
+ ] }),
279
+ (_a = question.options) == null ? void 0 : _a.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "pts-checkboxGroup-options", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
280
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
281
+ "input",
282
+ {
283
+ type: "checkbox",
284
+ name: `${question.id}-option`,
285
+ id: `${question.id}-option-${index}`,
286
+ value: option.label,
287
+ checked: checkedValues.includes(option.label),
288
+ onChange: (e) => handleInputChange(e, option.label),
289
+ className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0
290
+ }
291
+ ),
292
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { htmlFor: `${groupId}-option-${index}`, children: option.label })
293
+ ] }) }, index)),
294
+ question.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "pts-root-error", id: errorId, children: [
295
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "aria-hidden": true, className: "errorDot", children: "!" }),
296
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sr-only", children: "Valideringsfel" }),
297
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "errorText", children: ((_b = question.validationDefaultMessesege) != null ? _b : activatedLanguage === "sv") ? "V\xE4nligen besvara" : "Please reply" })
298
+ ] })
299
+ ]
300
+ }
301
+ ) }),
290
302
  showPreview && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PreviewCheckboxGroup, { activatedLanguage, question })
291
303
  ] });
292
304
  };