@chekinapp/ui 0.0.56 → 0.0.57

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.cjs CHANGED
@@ -505,6 +505,7 @@ __export(index_exports, {
505
505
  cn: () => cn,
506
506
  copyToClipboard: () => copyToClipboard,
507
507
  emptyMediaVariants: () => emptyMediaVariants,
508
+ getErrorMessage: () => getErrorMessage,
508
509
  getScrollableAreaState: () => getScrollableAreaState,
509
510
  getSidebarState: () => getSidebarState,
510
511
  inputVariants: () => inputVariants,
@@ -14470,6 +14471,44 @@ var DEVICE_BREAKPOINTS = {
14470
14471
  laptopL: "1400px",
14471
14472
  desktop: "2560px"
14472
14473
  };
14474
+
14475
+ // src/lib/getErrorMessage.ts
14476
+ function getErrorMessage(error) {
14477
+ let message = "";
14478
+ if (!error) {
14479
+ return message;
14480
+ }
14481
+ if (typeof error === "string") {
14482
+ return error;
14483
+ }
14484
+ if (error?.details) {
14485
+ return error?.details;
14486
+ }
14487
+ if (error?.errors?.length) {
14488
+ const nonFieldErrors = "non_field_errors";
14489
+ Object.values(error.errors).forEach((err) => {
14490
+ const error2 = err;
14491
+ message += ` ${error2.field && error2.field !== nonFieldErrors ? `${error2.field}: ` : ""} ${error2.message}
14492
+ `;
14493
+ });
14494
+ } else if (error?.message) {
14495
+ message = error.message;
14496
+ } else {
14497
+ if (typeof error === "object") {
14498
+ Object.values(error).forEach((err) => {
14499
+ message += ` ${err}
14500
+ `;
14501
+ });
14502
+ }
14503
+ }
14504
+ if (typeof message === "object") {
14505
+ return "";
14506
+ }
14507
+ if (message?.startsWith("Unexpected JSON")) {
14508
+ return "Server error.";
14509
+ }
14510
+ return message;
14511
+ }
14473
14512
  // Annotate the CommonJS export names for ESM import in node:
14474
14513
  0 && (module.exports = {
14475
14514
  Accordion,
@@ -14757,6 +14796,7 @@ var DEVICE_BREAKPOINTS = {
14757
14796
  cn,
14758
14797
  copyToClipboard,
14759
14798
  emptyMediaVariants,
14799
+ getErrorMessage,
14760
14800
  getScrollableAreaState,
14761
14801
  getSidebarState,
14762
14802
  inputVariants,