@goldenpine/react-form-builder2 0.20.3-build.2 → 0.20.3-build.4

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.
@@ -13,17 +13,30 @@ var ComponentLabel = function ComponentLabel(props) {
13
13
  if (!labelText) {
14
14
  return null;
15
15
  }
16
+
17
+ // Since we use <div> to replace <span> in the label in form-elements-edit.jsx to support multiple-line labels,
18
+ // we need to ensure that the required label, *, is inserted correctly.
19
+ // If it's simply appended the label string, it will show on a new line.
20
+ // The workaround is to insert it before the first closing </div> or </li> tag if it exists,
21
+ // so it appears at the end of the first line of the label.
22
+ var updatedLabel = labelText;
23
+ if (hasRequiredLabel) {
24
+ var insertSpan = '<span class="label-required" style="color:red;">*</span>';
25
+ var closingTagRegex = /<\/(div|li)>/i; // case-insensitive match for </div> or </li>
26
+
27
+ if (closingTagRegex.test(labelText)) {
28
+ updatedLabel = labelText.replace(closingTagRegex, "".concat(insertSpan, "</$1>"));
29
+ } else {
30
+ // Neither </div> nor </li> found — append at the end
31
+ updatedLabel = labelText + insertSpan;
32
+ }
33
+ }
16
34
  return /*#__PURE__*/_react["default"].createElement("label", {
17
35
  className: props.className || 'form-label'
18
36
  }, /*#__PURE__*/_react["default"].createElement("span", {
19
37
  dangerouslySetInnerHTML: {
20
- __html: labelText
21
- }
22
- }), hasRequiredLabel && /*#__PURE__*/_react["default"].createElement("span", {
23
- className: "label-required",
24
- style: {
25
- color: "red"
38
+ __html: updatedLabel
26
39
  }
27
- }, "*"));
40
+ }));
28
41
  };
29
42
  var _default = exports["default"] = ComponentLabel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goldenpine/react-form-builder2",
3
- "version": "0.20.3-build.2",
3
+ "version": "0.20.3-build.4",
4
4
  "description": "A complete form builder for react.",
5
5
  "main": "lib/index.js",
6
6
  "types": "types/index.d.ts",