@behio/storefront-sdk 2.6.0 → 2.6.1

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/README.md CHANGED
@@ -269,6 +269,12 @@ does not double quantities. Expired links fail with
269
269
  `be.storefront.cartLinkExpired`. Answer `GET /cart/link/_probe` with header
270
270
  `x-behio-cart-link: 1` so Behio Chat knows the storefront supports links.
271
271
 
272
+ ### Form validation errors (2.6.1)
273
+
274
+ `formFieldErrors(error)` retains every supported field code, including
275
+ `dateNotFuture`, `dateNotPast` and `tooManyFiles`. Display each error beside
276
+ its field and preserve entered values when a submission is rejected.
277
+
272
278
  ### Cart summary for page scripts (2.6)
273
279
 
274
280
  Browser cart responses dispatch `behio:cart` on `window` with
package/dist/index.js CHANGED
@@ -1006,16 +1006,19 @@ function validationFieldMessages(err2, locale = "en") {
1006
1006
  }
1007
1007
  return out;
1008
1008
  }
1009
- var FORM_FIELD_ERROR_CODES = /* @__PURE__ */ new Set([
1010
- "required",
1011
- "invalid",
1012
- "tooShort",
1013
- "tooLong",
1014
- "min",
1015
- "max",
1016
- "notOption",
1017
- "pattern"
1018
- ]);
1009
+ var FORM_FIELD_ERROR_CODES = {
1010
+ required: true,
1011
+ invalid: true,
1012
+ tooShort: true,
1013
+ tooLong: true,
1014
+ min: true,
1015
+ max: true,
1016
+ notOption: true,
1017
+ pattern: true,
1018
+ dateNotFuture: true,
1019
+ dateNotPast: true,
1020
+ tooManyFiles: true
1021
+ };
1019
1022
  function formFieldErrors(err2) {
1020
1023
  if (errorCode(err2) !== "be.forms.validationFailed") return [];
1021
1024
  const raw = errorParams(err2).errors;
@@ -1027,7 +1030,7 @@ function formFieldErrors(err2) {
1027
1030
  if (idx <= 0) continue;
1028
1031
  const key = entry.slice(0, idx);
1029
1032
  const code = entry.slice(idx + 1);
1030
- if (!FORM_FIELD_ERROR_CODES.has(code)) continue;
1033
+ if (!Object.prototype.hasOwnProperty.call(FORM_FIELD_ERROR_CODES, code)) continue;
1031
1034
  out.push({ key, code });
1032
1035
  }
1033
1036
  return out;
package/dist/index.mjs CHANGED
@@ -1006,16 +1006,19 @@ function validationFieldMessages(err2, locale = "en") {
1006
1006
  }
1007
1007
  return out;
1008
1008
  }
1009
- var FORM_FIELD_ERROR_CODES = /* @__PURE__ */ new Set([
1010
- "required",
1011
- "invalid",
1012
- "tooShort",
1013
- "tooLong",
1014
- "min",
1015
- "max",
1016
- "notOption",
1017
- "pattern"
1018
- ]);
1009
+ var FORM_FIELD_ERROR_CODES = {
1010
+ required: true,
1011
+ invalid: true,
1012
+ tooShort: true,
1013
+ tooLong: true,
1014
+ min: true,
1015
+ max: true,
1016
+ notOption: true,
1017
+ pattern: true,
1018
+ dateNotFuture: true,
1019
+ dateNotPast: true,
1020
+ tooManyFiles: true
1021
+ };
1019
1022
  function formFieldErrors(err2) {
1020
1023
  if (errorCode(err2) !== "be.forms.validationFailed") return [];
1021
1024
  const raw = errorParams(err2).errors;
@@ -1027,7 +1030,7 @@ function formFieldErrors(err2) {
1027
1030
  if (idx <= 0) continue;
1028
1031
  const key = entry.slice(0, idx);
1029
1032
  const code = entry.slice(idx + 1);
1030
- if (!FORM_FIELD_ERROR_CODES.has(code)) continue;
1033
+ if (!Object.prototype.hasOwnProperty.call(FORM_FIELD_ERROR_CODES, code)) continue;
1031
1034
  out.push({ key, code });
1032
1035
  }
1033
1036
  return out;
package/dist/react.js CHANGED
@@ -4019,16 +4019,19 @@ function errorParams(err) {
4019
4019
  const params = body?.params;
4020
4020
  return params && typeof params === "object" && !Array.isArray(params) ? params : {};
4021
4021
  }
4022
- var FORM_FIELD_ERROR_CODES = /* @__PURE__ */ new Set([
4023
- "required",
4024
- "invalid",
4025
- "tooShort",
4026
- "tooLong",
4027
- "min",
4028
- "max",
4029
- "notOption",
4030
- "pattern"
4031
- ]);
4022
+ var FORM_FIELD_ERROR_CODES = {
4023
+ required: true,
4024
+ invalid: true,
4025
+ tooShort: true,
4026
+ tooLong: true,
4027
+ min: true,
4028
+ max: true,
4029
+ notOption: true,
4030
+ pattern: true,
4031
+ dateNotFuture: true,
4032
+ dateNotPast: true,
4033
+ tooManyFiles: true
4034
+ };
4032
4035
  function formFieldErrors(err) {
4033
4036
  if (errorCode(err) !== "be.forms.validationFailed") return [];
4034
4037
  const raw = errorParams(err).errors;
@@ -4040,7 +4043,7 @@ function formFieldErrors(err) {
4040
4043
  if (idx <= 0) continue;
4041
4044
  const key = entry.slice(0, idx);
4042
4045
  const code = entry.slice(idx + 1);
4043
- if (!FORM_FIELD_ERROR_CODES.has(code)) continue;
4046
+ if (!Object.prototype.hasOwnProperty.call(FORM_FIELD_ERROR_CODES, code)) continue;
4044
4047
  out.push({ key, code });
4045
4048
  }
4046
4049
  return out;
package/dist/react.mjs CHANGED
@@ -3909,16 +3909,19 @@ function errorParams(err) {
3909
3909
  const params = body?.params;
3910
3910
  return params && typeof params === "object" && !Array.isArray(params) ? params : {};
3911
3911
  }
3912
- var FORM_FIELD_ERROR_CODES = /* @__PURE__ */ new Set([
3913
- "required",
3914
- "invalid",
3915
- "tooShort",
3916
- "tooLong",
3917
- "min",
3918
- "max",
3919
- "notOption",
3920
- "pattern"
3921
- ]);
3912
+ var FORM_FIELD_ERROR_CODES = {
3913
+ required: true,
3914
+ invalid: true,
3915
+ tooShort: true,
3916
+ tooLong: true,
3917
+ min: true,
3918
+ max: true,
3919
+ notOption: true,
3920
+ pattern: true,
3921
+ dateNotFuture: true,
3922
+ dateNotPast: true,
3923
+ tooManyFiles: true
3924
+ };
3922
3925
  function formFieldErrors(err) {
3923
3926
  if (errorCode(err) !== "be.forms.validationFailed") return [];
3924
3927
  const raw = errorParams(err).errors;
@@ -3930,7 +3933,7 @@ function formFieldErrors(err) {
3930
3933
  if (idx <= 0) continue;
3931
3934
  const key = entry.slice(0, idx);
3932
3935
  const code = entry.slice(idx + 1);
3933
- if (!FORM_FIELD_ERROR_CODES.has(code)) continue;
3936
+ if (!Object.prototype.hasOwnProperty.call(FORM_FIELD_ERROR_CODES, code)) continue;
3934
3937
  out.push({ key, code });
3935
3938
  }
3936
3939
  return out;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behio/storefront-sdk",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "description": "TypeScript SDK for Behio headless e-commerce: core client + React hooks",
5
5
  "author": "Behio",
6
6
  "license": "MIT",