@dmitryvim/form-builder 0.2.12 → 0.2.13

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/esm/index.js CHANGED
@@ -56,13 +56,6 @@ function addFormatHint(element, parts, state) {
56
56
  );
57
57
  }
58
58
  }
59
- function addRequiredHint(element, parts, state) {
60
- if (element.required) {
61
- parts.push(t("hintRequired", state));
62
- } else {
63
- parts.push(t("hintOptional", state));
64
- }
65
- }
66
59
  function addPatternHint(element, parts, state) {
67
60
  if (element.pattern) {
68
61
  parts.push(t("hintPattern", state, { pattern: element.pattern }));
@@ -70,7 +63,6 @@ function addPatternHint(element, parts, state) {
70
63
  }
71
64
  function makeFieldHint(element, state) {
72
65
  const parts = [];
73
- addRequiredHint(element, parts, state);
74
66
  addLengthHint(element, parts, state);
75
67
  if (element.type !== "slider") {
76
68
  addRangeHint(element, parts, state);
@@ -1294,10 +1286,12 @@ function renderSelectElement(element, ctx, wrapper, pathKey) {
1294
1286
  selectInput.addEventListener("change", handleChange);
1295
1287
  }
1296
1288
  wrapper.appendChild(selectInput);
1297
- const selectHint = document.createElement("p");
1298
- selectHint.className = "text-xs text-gray-500 mt-1";
1299
- selectHint.textContent = makeFieldHint(element, state);
1300
- wrapper.appendChild(selectHint);
1289
+ if (!state.config.readonly) {
1290
+ const selectHint = document.createElement("p");
1291
+ selectHint.className = "text-xs text-gray-500 mt-1";
1292
+ selectHint.textContent = makeFieldHint(element, state);
1293
+ wrapper.appendChild(selectHint);
1294
+ }
1301
1295
  }
1302
1296
  function renderMultipleSelectElement(element, ctx, wrapper, pathKey) {
1303
1297
  const state = ctx.state;
@@ -1430,10 +1424,12 @@ function renderMultipleSelectElement(element, ctx, wrapper, pathKey) {
1430
1424
  values.forEach((value) => addSelectItem(value));
1431
1425
  updateAddButton();
1432
1426
  updateRemoveButtons();
1433
- const hint = document.createElement("p");
1434
- hint.className = "text-xs text-gray-500 mt-1";
1435
- hint.textContent = makeFieldHint(element, state);
1436
- wrapper.appendChild(hint);
1427
+ if (!state.config.readonly) {
1428
+ const hint = document.createElement("p");
1429
+ hint.className = "text-xs text-gray-500 mt-1";
1430
+ hint.textContent = makeFieldHint(element, state);
1431
+ wrapper.appendChild(hint);
1432
+ }
1437
1433
  }
1438
1434
  function validateSelectElement(element, key, context) {
1439
1435
  const errors = [];
@@ -2859,14 +2855,16 @@ function renderColourElement(element, ctx, wrapper, pathKey) {
2859
2855
  const editUI = createEditColourUI(initialValue, pathKey, ctx);
2860
2856
  wrapper.appendChild(editUI);
2861
2857
  }
2862
- const colourHint = document.createElement("p");
2863
- colourHint.className = "mt-1";
2864
- colourHint.style.cssText = `
2865
- font-size: var(--fb-font-size-small);
2866
- color: var(--fb-text-secondary-color);
2867
- `;
2868
- colourHint.textContent = makeFieldHint(element, state);
2869
- wrapper.appendChild(colourHint);
2858
+ if (!state.config.readonly) {
2859
+ const colourHint = document.createElement("p");
2860
+ colourHint.className = "mt-1";
2861
+ colourHint.style.cssText = `
2862
+ font-size: var(--fb-font-size-small);
2863
+ color: var(--fb-text-secondary-color);
2864
+ `;
2865
+ colourHint.textContent = makeFieldHint(element, state);
2866
+ wrapper.appendChild(colourHint);
2867
+ }
2870
2868
  }
2871
2869
  function renderMultipleColourElement(element, ctx, wrapper, pathKey) {
2872
2870
  const state = ctx.state;
@@ -3004,14 +3002,16 @@ function renderMultipleColourElement(element, ctx, wrapper, pathKey) {
3004
3002
  values.forEach((value) => addColourItem(value));
3005
3003
  updateAddButton();
3006
3004
  updateRemoveButtons();
3007
- const hint = document.createElement("p");
3008
- hint.className = "mt-1";
3009
- hint.style.cssText = `
3010
- font-size: var(--fb-font-size-small);
3011
- color: var(--fb-text-secondary-color);
3012
- `;
3013
- hint.textContent = makeFieldHint(element, state);
3014
- wrapper.appendChild(hint);
3005
+ if (!state.config.readonly) {
3006
+ const hint = document.createElement("p");
3007
+ hint.className = "mt-1";
3008
+ hint.style.cssText = `
3009
+ font-size: var(--fb-font-size-small);
3010
+ color: var(--fb-text-secondary-color);
3011
+ `;
3012
+ hint.textContent = makeFieldHint(element, state);
3013
+ wrapper.appendChild(hint);
3014
+ }
3015
3015
  }
3016
3016
  function validateColourElement(element, key, context) {
3017
3017
  const errors = [];
@@ -3323,14 +3323,16 @@ function renderSliderElement(element, ctx, wrapper, pathKey) {
3323
3323
  state.config.readonly
3324
3324
  );
3325
3325
  wrapper.appendChild(sliderUI);
3326
- const hint = document.createElement("p");
3327
- hint.className = "mt-1";
3328
- hint.style.cssText = `
3329
- font-size: var(--fb-font-size-small);
3330
- color: var(--fb-text-secondary-color);
3331
- `;
3332
- hint.textContent = makeFieldHint(element, state);
3333
- wrapper.appendChild(hint);
3326
+ if (!state.config.readonly) {
3327
+ const hint = document.createElement("p");
3328
+ hint.className = "mt-1";
3329
+ hint.style.cssText = `
3330
+ font-size: var(--fb-font-size-small);
3331
+ color: var(--fb-text-secondary-color);
3332
+ `;
3333
+ hint.textContent = makeFieldHint(element, state);
3334
+ wrapper.appendChild(hint);
3335
+ }
3334
3336
  }
3335
3337
  function renderMultipleSliderElement(element, ctx, wrapper, pathKey) {
3336
3338
  if (element.min === void 0 || element.min === null) {
@@ -3479,14 +3481,16 @@ function renderMultipleSliderElement(element, ctx, wrapper, pathKey) {
3479
3481
  values.forEach((value) => addSliderItem(value));
3480
3482
  updateAddButton();
3481
3483
  updateRemoveButtons();
3482
- const hint = document.createElement("p");
3483
- hint.className = "mt-1";
3484
- hint.style.cssText = `
3485
- font-size: var(--fb-font-size-small);
3486
- color: var(--fb-text-secondary-color);
3487
- `;
3488
- hint.textContent = makeFieldHint(element, state);
3489
- wrapper.appendChild(hint);
3484
+ if (!state.config.readonly) {
3485
+ const hint = document.createElement("p");
3486
+ hint.className = "mt-1";
3487
+ hint.style.cssText = `
3488
+ font-size: var(--fb-font-size-small);
3489
+ color: var(--fb-text-secondary-color);
3490
+ `;
3491
+ hint.textContent = makeFieldHint(element, state);
3492
+ wrapper.appendChild(hint);
3493
+ }
3490
3494
  }
3491
3495
  function validateSliderElement(element, key, context) {
3492
3496
  const errors = [];