@delopay/sdk 0.75.0 → 0.76.0

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.
@@ -4001,8 +4001,17 @@ var ALL_CUSTOM_FIELD_TYPES = [
4001
4001
  "textarea",
4002
4002
  "password",
4003
4003
  "email",
4004
- "select"
4004
+ "select",
4005
+ "checkbox"
4005
4006
  ];
4007
+ var CHECKBOX_CHECKED = "true";
4008
+ var CHECKBOX_UNCHECKED = "false";
4009
+ function isCheckboxChecked(value) {
4010
+ return typeof value === "string" && value.trim().toLowerCase() === CHECKBOX_CHECKED;
4011
+ }
4012
+ function customFieldIsTextLike(type) {
4013
+ return type !== "select" && type !== "checkbox";
4014
+ }
4006
4015
  var CUSTOM_FIELD_CONDITIONS_MAX = 10;
4007
4016
  var ALL_CUSTOM_FIELD_CONDITION_SOURCES = [
4008
4017
  "metadata",
@@ -4105,8 +4114,11 @@ function normalizeCustomField(raw, index) {
4105
4114
  labelTranslations: parseTranslations(o["labelTranslations"])
4106
4115
  };
4107
4116
  }).filter((o) => o.value.length > 0) : [];
4108
- const minLength = parseBoundedInt(f["minLength"]);
4109
- const maxLength = parseBoundedInt(f["maxLength"]);
4117
+ const textLike = customFieldIsTextLike(type);
4118
+ const minLength = textLike ? parseBoundedInt(f["minLength"]) : null;
4119
+ const maxLength = textLike ? parseBoundedInt(f["maxLength"]) : null;
4120
+ const rawDefault = typeof f["defaultValue"] === "string" ? f["defaultValue"] : "";
4121
+ const defaultValue = type === "checkbox" ? isCheckboxChecked(rawDefault) ? CHECKBOX_CHECKED : CHECKBOX_UNCHECKED : rawDefault;
4110
4122
  return {
4111
4123
  id: typeof f["id"] === "string" && f["id"] ? f["id"] : `field-${index}`,
4112
4124
  key,
@@ -4122,7 +4134,7 @@ function normalizeCustomField(raw, index) {
4122
4134
  minLength,
4123
4135
  // Guard inverted bounds at decode so consumers never see min > max.
4124
4136
  maxLength: maxLength !== null && minLength !== null && maxLength < minLength ? null : maxLength,
4125
- defaultValue: typeof f["defaultValue"] === "string" ? f["defaultValue"] : "",
4137
+ defaultValue,
4126
4138
  options,
4127
4139
  visibility: normalizeVisibility(f["visibility"])
4128
4140
  };
@@ -4165,9 +4177,13 @@ function encodeCustomFields(fields) {
4165
4177
  ...nonEmpty(f.helpTextTranslations) ? { helpTextTranslations: nonEmpty(f.helpTextTranslations) } : {},
4166
4178
  ...f.required ? { required: true } : {},
4167
4179
  ...f.enabled ? {} : { enabled: false },
4168
- ...f.minLength !== null ? { minLength: f.minLength } : {},
4169
- ...f.maxLength !== null ? { maxLength: f.maxLength } : {},
4170
- ...f.defaultValue ? { defaultValue: f.defaultValue } : {},
4180
+ // Length bounds only exist for free-text types; a choice control that
4181
+ // still carries them is stale state the decoder would drop anyway.
4182
+ ...customFieldIsTextLike(f.type) && f.minLength !== null ? { minLength: f.minLength } : {},
4183
+ ...customFieldIsTextLike(f.type) && f.maxLength !== null ? { maxLength: f.maxLength } : {},
4184
+ // A checkbox persists only "starts ticked"; unticked is the decoder's
4185
+ // default, so writing 'false' would be noise on every such field.
4186
+ ...f.type === "checkbox" ? isCheckboxChecked(f.defaultValue) ? { defaultValue: CHECKBOX_CHECKED } : {} : f.defaultValue ? { defaultValue: f.defaultValue } : {},
4171
4187
  ...f.type === "select" ? { options: f.options } : {},
4172
4188
  // Omitted for unconditional fields so the stored blob (and every
4173
4189
  // pre-feature payload) stays byte-identical to what it was.
@@ -4703,6 +4719,10 @@ export {
4703
4719
  CUSTOM_FIELDS_MAX,
4704
4720
  CUSTOM_FIELD_KEY_PATTERN,
4705
4721
  ALL_CUSTOM_FIELD_TYPES,
4722
+ CHECKBOX_CHECKED,
4723
+ CHECKBOX_UNCHECKED,
4724
+ isCheckboxChecked,
4725
+ customFieldIsTextLike,
4706
4726
  CUSTOM_FIELD_CONDITIONS_MAX,
4707
4727
  ALL_CUSTOM_FIELD_CONDITION_SOURCES,
4708
4728
  ALL_CUSTOM_FIELD_OPERATORS,
@@ -4729,4 +4749,4 @@ export {
4729
4749
  applyBrandingVariables,
4730
4750
  shadowFor
4731
4751
  };
4732
- //# sourceMappingURL=chunk-5J763YMV.js.map
4752
+ //# sourceMappingURL=chunk-D7DPAKI2.js.map