@socotra/ec-react-utils 2.25.0-next.4 → 2.25.0-next.5

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.es.js CHANGED
@@ -1054,8 +1054,8 @@ const Gc = (e) => {
1054
1054
  truthyLabel: k = "True",
1055
1055
  falsyLabel: I = "False",
1056
1056
  hiddenExceptions: O = [],
1057
- readOnly: F = !1
1058
- } = e, U = [];
1057
+ readOnly: U = !1
1058
+ } = e, G = [];
1059
1059
  let Q = {};
1060
1060
  const Le = {
1061
1061
  properties: {}
@@ -1064,12 +1064,12 @@ const Gc = (e) => {
1064
1064
  }, Op = {
1065
1065
  properties: {}
1066
1066
  }, zp = Object.fromEntries(
1067
- Object.entries(t ?? {}).filter(([M, G]) => {
1067
+ Object.entries(t ?? {}).filter(([M, F]) => {
1068
1068
  var wt;
1069
- const je = (wt = G.scope) == null ? void 0 : wt.split(",").map((Oe) => Oe.trim());
1069
+ const je = (wt = F.scope) == null ? void 0 : wt.split(",").map((Oe) => Oe.trim());
1070
1070
  if (je && !r.some((Oe) => je.includes(Oe)))
1071
1071
  return !1;
1072
- const xe = G.tag;
1072
+ const xe = F.tag;
1073
1073
  if (xe != null && xe.includes("hidden"))
1074
1074
  return O.length > 0 ? O.includes(M) : !1;
1075
1075
  const ct = xe == null ? void 0 : xe.find(
@@ -1087,12 +1087,12 @@ const Gc = (e) => {
1087
1087
  if ($t === "==" && Et === Zt || $t === "!=" && Et !== Zt) return !1;
1088
1088
  }
1089
1089
  return !0;
1090
- }).map(([M, G]) => {
1090
+ }).map(([M, F]) => {
1091
1091
  var Ti, _i, Ai, wi, $i, Ei, Li, xi, Si, Pi, Ci, ki, Di, qi, Oi, zi, Ii, Ni;
1092
1092
  let je = !1, xe = !1, ct = !1, wt = !1;
1093
- const Oe = G.displayName ?? M, tr = (Ti = G.type) == null ? void 0 : Ti.slice(-1), $t = G.maxLength, Nt = G.minLength, Rt = G.max, Et = G.min, Zt = G.constraint, vi = G.regex, bi = G.precision, He = G.tag ?? [];
1094
- let H = G.type ?? "", Bt;
1095
- const ze = F || He.includes("readOnly");
1093
+ const Oe = F.displayName ?? M, tr = (Ti = F.type) == null ? void 0 : Ti.slice(-1), $t = F.maxLength, Nt = F.minLength, Rt = F.max, Et = F.min, Zt = F.constraint, vi = F.regex, bi = F.precision, He = F.tag ?? [];
1094
+ let H = F.type ?? "", Bt;
1095
+ const ze = U || He.includes("readOnly");
1096
1096
  let jt = !1;
1097
1097
  switch (tr) {
1098
1098
  case "*":
@@ -1151,9 +1151,9 @@ const Gc = (e) => {
1151
1151
  m,
1152
1152
  `${E == null ? void 0 : E.staticLocator}.${M}`
1153
1153
  );
1154
- w && se && (G.options = se), y && Ie && (G.options = Ie), d && Mt && (G.options = Mt), E && lt && (G.options = lt);
1154
+ w && se && (F.options = se), y && Ie && (F.options = Ie), d && Mt && (F.options = Mt), E && lt && (F.options = lt);
1155
1155
  }
1156
- if (!je && !ct && U.push(M), ct) {
1156
+ if (!je && !ct && G.push(M), ct) {
1157
1157
  const se = s == null ? void 0 : s[H];
1158
1158
  if (se) {
1159
1159
  let Ie = xe ? [] : {};
@@ -1163,7 +1163,7 @@ const Gc = (e) => {
1163
1163
  dataTypes: s,
1164
1164
  ignoreConstraints: u,
1165
1165
  evaluatedConstraints: m,
1166
- rootDisplayName: G.displayName ?? se.displayName ?? M,
1166
+ rootDisplayName: F.displayName ?? se.displayName ?? M,
1167
1167
  customDataTypeKey: M,
1168
1168
  quote: y,
1169
1169
  isStaticData: A,
@@ -1188,11 +1188,15 @@ const Gc = (e) => {
1188
1188
  }
1189
1189
  ), Mt.definitions = {}, Q = {
1190
1190
  ...Q,
1191
- [`${H}`]: Mt
1191
+ [`${H}`]: {
1192
+ ...Mt,
1193
+ // title should be taken care by the property that is referencing to this custom data type.
1194
+ title: void 0
1195
+ }
1192
1196
  }, xe ? [
1193
1197
  M,
1194
1198
  {
1195
- title: G.displayName ?? se.displayName ?? M,
1199
+ title: F.displayName ?? se.displayName ?? M,
1196
1200
  type: "array",
1197
1201
  default: Ie,
1198
1202
  items: {
@@ -1205,7 +1209,7 @@ const Gc = (e) => {
1205
1209
  ] : [
1206
1210
  M,
1207
1211
  {
1208
- title: se.displayName ?? M,
1212
+ title: F.displayName ?? se.displayName ?? M,
1209
1213
  default: Ie,
1210
1214
  $ref: `#/definitions/${H}`,
1211
1215
  ...He && { tag: He },
@@ -1217,20 +1221,20 @@ const Gc = (e) => {
1217
1221
  let Lt = "";
1218
1222
  if (d) {
1219
1223
  const se = (d == null ? void 0 : d.accountState) === "validated" ? M.charAt(0).toLowerCase() + M.slice(1) : M;
1220
- Lt = (Si = d == null ? void 0 : d.data) != null && Si[se] ? (Pi = d == null ? void 0 : d.data) == null ? void 0 : Pi[se] : H === "boolean" ? !!G.defaultValue : G.defaultValue;
1224
+ Lt = (Si = d == null ? void 0 : d.data) != null && Si[se] ? (Pi = d == null ? void 0 : d.data) == null ? void 0 : Pi[se] : H === "boolean" ? !!F.defaultValue : F.defaultValue;
1221
1225
  }
1222
1226
  if (y) {
1223
1227
  const se = A ? y.static : (Ci = y.element) == null ? void 0 : Ci.data;
1224
- Lt = se != null && se[M] ? se == null ? void 0 : se[M] : H === "boolean" ? !!G.defaultValue : G.defaultValue;
1228
+ Lt = se != null && se[M] ? se == null ? void 0 : se[M] : H === "boolean" ? !!F.defaultValue : F.defaultValue;
1225
1229
  }
1226
- if (w && (Lt = (ki = w == null ? void 0 : w.data) != null && ki[M] ? (Di = w == null ? void 0 : w.data) == null ? void 0 : Di[M] : H === "boolean" ? !!G.defaultValue : G.defaultValue), T && A && (qi = T == null ? void 0 : T.static) != null && qi[M] && (Lt = (Oi = T == null ? void 0 : T.static) != null && Oi[M] ? (zi = T == null ? void 0 : T.static) == null ? void 0 : zi[M] : H === "boolean" ? !!G.defaultValue : G.defaultValue), xe)
1230
+ if (w && (Lt = (ki = w == null ? void 0 : w.data) != null && ki[M] ? (Di = w == null ? void 0 : w.data) == null ? void 0 : Di[M] : H === "boolean" ? !!F.defaultValue : F.defaultValue), T && A && (qi = T == null ? void 0 : T.static) != null && qi[M] && (Lt = (Oi = T == null ? void 0 : T.static) != null && Oi[M] ? (zi = T == null ? void 0 : T.static) == null ? void 0 : zi[M] : H === "boolean" ? !!F.defaultValue : F.defaultValue), xe)
1227
1231
  return [
1228
1232
  M,
1229
1233
  {
1230
1234
  title: Oe,
1231
1235
  type: "array",
1232
1236
  default: Lt,
1233
- ...G.tag ? G.tag.includes(
1237
+ ...F.tag ? F.tag.includes(
1234
1238
  "multiselect"
1235
1239
  /* MultiSelect */
1236
1240
  ) && !ct && {
@@ -1243,8 +1247,8 @@ const Gc = (e) => {
1243
1247
  ...Et && { min: Et },
1244
1248
  ...Rt && { max: Rt },
1245
1249
  ...Bt && { format: Bt },
1246
- ...vi && { pattern: G.regex },
1247
- ...G.options && { enum: G.options },
1250
+ ...vi && { pattern: F.regex },
1251
+ ...F.options && { enum: F.options },
1248
1252
  ...wt && { timezone: i },
1249
1253
  ...jt && { nullable: jt },
1250
1254
  ...ze && { readOnly: ze }
@@ -1270,8 +1274,8 @@ const Gc = (e) => {
1270
1274
  ...Rt && { maximum: parseFloat(Rt) },
1271
1275
  ...bi && { multipleOf: 1 / Math.pow(10, bi) },
1272
1276
  ...Bt && { format: Bt },
1273
- ...G.options && { enum: G.options },
1274
- ...vi && { pattern: G.regex },
1277
+ ...F.options && { enum: F.options },
1278
+ ...vi && { pattern: F.regex },
1275
1279
  ...He && { tag: He },
1276
1280
  ...Tn && { currency: Tn },
1277
1281
  ...wt && { timezone: i },
@@ -1292,7 +1296,7 @@ const Gc = (e) => {
1292
1296
  title: l || "",
1293
1297
  type: "object",
1294
1298
  definitions: Q,
1295
- required: U,
1299
+ required: G,
1296
1300
  properties: zp,
1297
1301
  if: Le,
1298
1302
  then: qp,
@@ -2671,27 +2675,27 @@ const Vc = (e, t) => {
2671
2675
  var w, x, k, I;
2672
2676
  const r = e.exposures ?? {}, i = e.coverages ?? {}, s = e.policyLines ?? {}, l = e.exposureGroups ?? {}, d = (t ?? []).map(
2673
2677
  (O) => {
2674
- const { name: F, quantifier: U } = Ca(O);
2675
- return { name: F, quantifier: U };
2678
+ const { name: U, quantifier: G } = Ca(O);
2679
+ return { name: U, quantifier: G };
2676
2680
  }
2677
2681
  ), m = Object.keys(r).filter(
2678
2682
  (O) => {
2679
2683
  if (d.find(
2680
- (U) => U.name === O
2684
+ (G) => G.name === O
2681
2685
  ))
2682
2686
  return !0;
2683
2687
  }
2684
2688
  ), y = Object.keys(i).filter(
2685
2689
  (O) => {
2686
2690
  if (d.find(
2687
- (U) => U.name === O
2691
+ (G) => G.name === O
2688
2692
  ))
2689
2693
  return !0;
2690
2694
  }
2691
2695
  ), T = Object.keys(s).filter(
2692
2696
  (O) => {
2693
2697
  if (d.find(
2694
- (U) => U.name === O
2698
+ (G) => G.name === O
2695
2699
  ))
2696
2700
  return !0;
2697
2701
  }
@@ -2699,7 +2703,7 @@ const Vc = (e, t) => {
2699
2703
  l
2700
2704
  ).filter((O) => {
2701
2705
  if (d.find(
2702
- (U) => U.name === O
2706
+ (G) => G.name === O
2703
2707
  ))
2704
2708
  return !0;
2705
2709
  }), E = {
@@ -2711,22 +2715,22 @@ const Vc = (e, t) => {
2711
2715
  for (const O of m)
2712
2716
  E.exposures[O] = {
2713
2717
  ...r[O],
2714
- quantifier: ((w = d.find((F) => F.name === O)) == null ? void 0 : w.quantifier) ?? ""
2718
+ quantifier: ((w = d.find((U) => U.name === O)) == null ? void 0 : w.quantifier) ?? ""
2715
2719
  };
2716
2720
  for (const O of y)
2717
2721
  E.coverages[O] = {
2718
2722
  ...i[O],
2719
- quantifier: ((x = d.find((F) => F.name === O)) == null ? void 0 : x.quantifier) ?? ""
2723
+ quantifier: ((x = d.find((U) => U.name === O)) == null ? void 0 : x.quantifier) ?? ""
2720
2724
  };
2721
2725
  for (const O of T)
2722
2726
  E.policyLines[O] = {
2723
2727
  ...s[O],
2724
- quantifier: ((k = d.find((F) => F.name === O)) == null ? void 0 : k.quantifier) ?? ""
2728
+ quantifier: ((k = d.find((U) => U.name === O)) == null ? void 0 : k.quantifier) ?? ""
2725
2729
  };
2726
2730
  for (const O of A)
2727
2731
  E.exposureGroups[O] = {
2728
2732
  ...l[O],
2729
- quantifier: ((I = d.find((F) => F.name === O)) == null ? void 0 : I.quantifier) ?? ""
2733
+ quantifier: ((I = d.find((U) => U.name === O)) == null ? void 0 : I.quantifier) ?? ""
2730
2734
  };
2731
2735
  return E;
2732
2736
  }, Pt = ({
@@ -4025,38 +4029,38 @@ const Nv = /* @__PURE__ */ L("$ZodObject", (e, t) => {
4025
4029
  }), Rv = /* @__PURE__ */ L("$ZodObjectJIT", (e, t) => {
4026
4030
  Nv.init(e, t);
4027
4031
  const r = e._zod.parse, i = mo(() => ll(t)), s = (A) => {
4028
- const E = new av(["shape", "payload", "ctx"]), w = i.value, x = (F) => {
4029
- const U = Ji(F);
4030
- return `shape[${U}]._zod.run({ value: input[${U}], issues: [] }, ctx)`;
4032
+ const E = new av(["shape", "payload", "ctx"]), w = i.value, x = (U) => {
4033
+ const G = Ji(U);
4034
+ return `shape[${G}]._zod.run({ value: input[${G}], issues: [] }, ctx)`;
4031
4035
  };
4032
4036
  E.write("const input = payload.value;");
4033
4037
  const k = /* @__PURE__ */ Object.create(null);
4034
4038
  let I = 0;
4035
- for (const F of w.keys)
4036
- k[F] = `key_${I++}`;
4039
+ for (const U of w.keys)
4040
+ k[U] = `key_${I++}`;
4037
4041
  E.write("const newResult = {}");
4038
- for (const F of w.keys) {
4039
- const U = k[F], Q = Ji(F);
4040
- E.write(`const ${U} = ${x(F)};`), E.write(`
4041
- if (${U}.issues.length) {
4042
- payload.issues = payload.issues.concat(${U}.issues.map(iss => ({
4042
+ for (const U of w.keys) {
4043
+ const G = k[U], Q = Ji(U);
4044
+ E.write(`const ${G} = ${x(U)};`), E.write(`
4045
+ if (${G}.issues.length) {
4046
+ payload.issues = payload.issues.concat(${G}.issues.map(iss => ({
4043
4047
  ...iss,
4044
4048
  path: iss.path ? [${Q}, ...iss.path] : [${Q}]
4045
4049
  })));
4046
4050
  }
4047
4051
 
4048
- if (${U}.value === undefined) {
4052
+ if (${G}.value === undefined) {
4049
4053
  if (${Q} in input) {
4050
4054
  newResult[${Q}] = undefined;
4051
4055
  }
4052
4056
  } else {
4053
- newResult[${Q}] = ${U}.value;
4057
+ newResult[${Q}] = ${G}.value;
4054
4058
  }
4055
4059
  `);
4056
4060
  }
4057
4061
  E.write("payload.value = newResult;"), E.write("return payload;");
4058
4062
  const O = E.compile();
4059
- return (F, U) => O(A, F, U);
4063
+ return (U, G) => O(A, U, G);
4060
4064
  };
4061
4065
  let l;
4062
4066
  const u = Tr, d = !Wc.jitless, m = d && Vy.value, y = t.catchall;
@@ -17812,9 +17816,9 @@ function uO(e, t, r, i, s, l) {
17812
17816
  break;
17813
17817
  }
17814
17818
  if (w) {
17815
- if (!iO(t, function(O, F) {
17816
- if (!sO(w, F) && (x === O || s(x, O, r, i, l)))
17817
- return w.push(F);
17819
+ if (!iO(t, function(O, U) {
17820
+ if (!sO(w, U) && (x === O || s(x, O, r, i, l)))
17821
+ return w.push(U);
17818
17822
  })) {
17819
17823
  E = !1;
17820
17824
  break;
@@ -17893,10 +17897,10 @@ function NO(e, t, r, i, s, l) {
17893
17897
  l.set(e, t), l.set(t, e);
17894
17898
  for (var I = u; ++A < m; ) {
17895
17899
  E = d[A];
17896
- var O = e[E], F = t[E];
17900
+ var O = e[E], U = t[E];
17897
17901
  if (i)
17898
- var U = u ? i(F, O, E, t, e, l) : i(O, F, E, e, t, l);
17899
- if (!(U === void 0 ? O === F || s(O, F, r, i, l) : U)) {
17902
+ var G = u ? i(U, O, E, t, e, l) : i(O, U, E, e, t, l);
17903
+ if (!(G === void 0 ? O === U || s(O, U, r, i, l) : G)) {
17900
17904
  k = !1;
17901
17905
  break;
17902
17906
  }
@@ -19119,19 +19123,19 @@ const mR = /* @__PURE__ */ P("$ZodObject", (e, t) => {
19119
19123
  }), yR = /* @__PURE__ */ P("$ZodObjectJIT", (e, t) => {
19120
19124
  mR.init(e, t);
19121
19125
  const r = e._zod.parse, i = ui(() => Ap(t)), s = (E) => {
19122
- const w = new ZN(["shape", "payload", "ctx"]), x = i.value, k = (U) => {
19123
- const Q = nc(U);
19126
+ const w = new ZN(["shape", "payload", "ctx"]), x = i.value, k = (G) => {
19127
+ const Q = nc(G);
19124
19128
  return `shape[${Q}]._zod.run({ value: input[${Q}], issues: [] }, ctx)`;
19125
19129
  };
19126
19130
  w.write("const input = payload.value;");
19127
19131
  const I = /* @__PURE__ */ Object.create(null);
19128
19132
  let O = 0;
19129
- for (const U of x.keys)
19130
- I[U] = `key_${O++}`;
19133
+ for (const G of x.keys)
19134
+ I[G] = `key_${O++}`;
19131
19135
  w.write("const newResult = {}");
19132
- for (const U of x.keys) {
19133
- const Q = I[U], Le = nc(U);
19134
- w.write(`const ${Q} = ${k(U)};`), w.write(`
19136
+ for (const G of x.keys) {
19137
+ const Q = I[G], Le = nc(G);
19138
+ w.write(`const ${Q} = ${k(G)};`), w.write(`
19135
19139
  if (${Q}.issues.length) {
19136
19140
  payload.issues = payload.issues.concat(${Q}.issues.map(iss => ({
19137
19141
  ...iss,
@@ -19149,8 +19153,8 @@ const mR = /* @__PURE__ */ P("$ZodObject", (e, t) => {
19149
19153
  `);
19150
19154
  }
19151
19155
  w.write("payload.value = newResult;"), w.write("return payload;");
19152
- const F = w.compile();
19153
- return (U, Q) => F(E, U, Q);
19156
+ const U = w.compile();
19157
+ return (G, Q) => U(E, G, Q);
19154
19158
  };
19155
19159
  let l;
19156
19160
  const u = Or, d = !dp.jitless, y = d && NI.value, T = t.catchall;