@getopenpay/openpay-js-react 0.0.9 → 0.0.10-alpha.4002911

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +64 -25
  2. package/dist/index.js +119 -114
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -7,14 +7,30 @@ declare type AllFieldNames = z.infer<typeof AllFieldNames>;
7
7
 
8
8
  export declare const CardCvcElement: FC<ElementProps>;
9
9
 
10
- export declare const CardElement: FC<ElementProps>;
10
+ export declare const CardElement: FC<ElementProps<typeof CardPlaceholder>>;
11
11
 
12
12
  export declare const CardExpiryElement: FC<ElementProps>;
13
13
 
14
14
  export declare const CardNumberElement: FC<ElementProps>;
15
15
 
16
- export declare type ElementProps = {
17
- styles?: ElementsStyle;
16
+ declare const CardPlaceholder: z.ZodObject<{
17
+ cardNumber: z.ZodOptional<z.ZodString>;
18
+ expiry: z.ZodOptional<z.ZodString>;
19
+ cvc: z.ZodOptional<z.ZodString>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ cardNumber?: string | undefined;
22
+ expiry?: string | undefined;
23
+ cvc?: string | undefined;
24
+ }, {
25
+ cardNumber?: string | undefined;
26
+ expiry?: string | undefined;
27
+ cvc?: string | undefined;
28
+ }>;
29
+
30
+ declare type CardPlaceholder = z.infer<typeof CardPlaceholder>;
31
+
32
+ export declare type ElementProps<PlaceholderType extends z.ZodTypeAny = z.ZodString> = {
33
+ styles?: ElementsStyle<z.ZodOptional<PlaceholderType>>;
18
34
  };
19
35
 
20
36
  declare type ElementsContextValue = {
@@ -50,10 +66,7 @@ export declare type ElementsFormProps = {
50
66
  baseUrl?: string;
51
67
  };
52
68
 
53
- /**
54
- * Styles
55
- */
56
- declare const ElementsStyle: z.ZodObject<{
69
+ declare const ElementsStyle: <T extends z.ZodTypeAny>(placeholderType: T) => z.ZodObject<z.objectUtil.extendShape<{
57
70
  backgroundColor: z.ZodOptional<z.ZodString>;
58
71
  color: z.ZodOptional<z.ZodString>;
59
72
  fontFamily: z.ZodOptional<z.ZodString>;
@@ -61,25 +74,51 @@ declare const ElementsStyle: z.ZodObject<{
61
74
  fontWeight: z.ZodOptional<z.ZodString>;
62
75
  margin: z.ZodOptional<z.ZodString>;
63
76
  padding: z.ZodOptional<z.ZodString>;
64
- }, "strip", z.ZodTypeAny, {
65
- backgroundColor?: string | undefined;
66
- color?: string | undefined;
67
- fontFamily?: string | undefined;
68
- fontSize?: string | undefined;
69
- fontWeight?: string | undefined;
70
- margin?: string | undefined;
71
- padding?: string | undefined;
72
77
  }, {
73
- backgroundColor?: string | undefined;
74
- color?: string | undefined;
75
- fontFamily?: string | undefined;
76
- fontSize?: string | undefined;
77
- fontWeight?: string | undefined;
78
- margin?: string | undefined;
79
- padding?: string | undefined;
80
- }>;
81
-
82
- declare type ElementsStyle = z.infer<typeof ElementsStyle>;
78
+ placeholder: T;
79
+ }>, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<z.objectUtil.extendShape<{
80
+ backgroundColor: z.ZodOptional<z.ZodString>;
81
+ color: z.ZodOptional<z.ZodString>;
82
+ fontFamily: z.ZodOptional<z.ZodString>;
83
+ fontSize: z.ZodOptional<z.ZodString>;
84
+ fontWeight: z.ZodOptional<z.ZodString>;
85
+ margin: z.ZodOptional<z.ZodString>;
86
+ padding: z.ZodOptional<z.ZodString>;
87
+ }, {
88
+ placeholder: T;
89
+ }>>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<z.objectUtil.extendShape<{
90
+ backgroundColor: z.ZodOptional<z.ZodString>;
91
+ color: z.ZodOptional<z.ZodString>;
92
+ fontFamily: z.ZodOptional<z.ZodString>;
93
+ fontSize: z.ZodOptional<z.ZodString>;
94
+ fontWeight: z.ZodOptional<z.ZodString>;
95
+ margin: z.ZodOptional<z.ZodString>;
96
+ padding: z.ZodOptional<z.ZodString>;
97
+ }, {
98
+ placeholder: T;
99
+ }>>, any>[k]; } : never, z.baseObjectInputType<z.objectUtil.extendShape<{
100
+ backgroundColor: z.ZodOptional<z.ZodString>;
101
+ color: z.ZodOptional<z.ZodString>;
102
+ fontFamily: z.ZodOptional<z.ZodString>;
103
+ fontSize: z.ZodOptional<z.ZodString>;
104
+ fontWeight: z.ZodOptional<z.ZodString>;
105
+ margin: z.ZodOptional<z.ZodString>;
106
+ padding: z.ZodOptional<z.ZodString>;
107
+ }, {
108
+ placeholder: T;
109
+ }>> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<z.objectUtil.extendShape<{
110
+ backgroundColor: z.ZodOptional<z.ZodString>;
111
+ color: z.ZodOptional<z.ZodString>;
112
+ fontFamily: z.ZodOptional<z.ZodString>;
113
+ fontSize: z.ZodOptional<z.ZodString>;
114
+ fontWeight: z.ZodOptional<z.ZodString>;
115
+ margin: z.ZodOptional<z.ZodString>;
116
+ padding: z.ZodOptional<z.ZodString>;
117
+ }, {
118
+ placeholder: T;
119
+ }>>[k_1]; } : never>;
120
+
121
+ declare type ElementsStyle<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof ElementsStyle<T>>>;
83
122
 
84
123
  /**
85
124
  * Expected input fields
package/dist/index.js CHANGED
@@ -357,7 +357,7 @@ var p;
357
357
  r.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, r.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
358
358
  })(p || (p = {}));
359
359
  var we, Ee;
360
- class B {
360
+ class W {
361
361
  constructor(e, t, n, s) {
362
362
  this._cachedPath = [], this.parent = e, this.data = t, this._path = n, this._key = s;
363
363
  }
@@ -492,7 +492,7 @@ class _ {
492
492
  return this._refinement((n, s) => e(n) ? !0 : (s.addIssue(typeof t == "function" ? t(n, s) : t), !1));
493
493
  }
494
494
  _refinement(e) {
495
- return new V({
495
+ return new z({
496
496
  schema: this,
497
497
  typeName: y.ZodEffects,
498
498
  effect: { type: "refinement", refinement: e }
@@ -502,7 +502,7 @@ class _ {
502
502
  return this._refinement(e);
503
503
  }
504
504
  optional() {
505
- return F.create(this, this._def);
505
+ return B.create(this, this._def);
506
506
  }
507
507
  nullable() {
508
508
  return ie.create(this, this._def);
@@ -511,7 +511,7 @@ class _ {
511
511
  return this.nullable().optional();
512
512
  }
513
513
  array() {
514
- return $.create(this, this._def);
514
+ return V.create(this, this._def);
515
515
  }
516
516
  promise() {
517
517
  return ge.create(this, this._def);
@@ -523,7 +523,7 @@ class _ {
523
523
  return Ae.create(this, e, this._def);
524
524
  }
525
525
  transform(e) {
526
- return new V({
526
+ return new z({
527
527
  ...g(this._def),
528
528
  schema: this,
529
529
  typeName: y.ZodEffects,
@@ -593,7 +593,7 @@ function Lt(r) {
593
593
  function $r(r, e) {
594
594
  return !!((e === "v4" || !e) && jr.test(r) || (e === "v6" || !e) && Mr.test(r));
595
595
  }
596
- class U extends _ {
596
+ class $ extends _ {
597
597
  _parse(e) {
598
598
  if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
599
599
  const a = this._getOrReturnCtx(e);
@@ -744,7 +744,7 @@ class U extends _ {
744
744
  });
745
745
  }
746
746
  _addCheck(e) {
747
- return new U({
747
+ return new $({
748
748
  ...this._def,
749
749
  checks: [...this._def.checks, e]
750
750
  });
@@ -870,19 +870,19 @@ class U extends _ {
870
870
  return this.min(1, p.errToObj(e));
871
871
  }
872
872
  trim() {
873
- return new U({
873
+ return new $({
874
874
  ...this._def,
875
875
  checks: [...this._def.checks, { kind: "trim" }]
876
876
  });
877
877
  }
878
878
  toLowerCase() {
879
- return new U({
879
+ return new $({
880
880
  ...this._def,
881
881
  checks: [...this._def.checks, { kind: "toLowerCase" }]
882
882
  });
883
883
  }
884
884
  toUpperCase() {
885
- return new U({
885
+ return new $({
886
886
  ...this._def,
887
887
  checks: [...this._def.checks, { kind: "toUpperCase" }]
888
888
  });
@@ -942,9 +942,9 @@ class U extends _ {
942
942
  return e;
943
943
  }
944
944
  }
945
- U.create = (r) => {
945
+ $.create = (r) => {
946
946
  var e;
947
- return new U({
947
+ return new $({
948
948
  checks: [],
949
949
  typeName: y.ZodString,
950
950
  coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
@@ -1457,7 +1457,7 @@ Je.create = (r) => new Je({
1457
1457
  typeName: y.ZodVoid,
1458
1458
  ...g(r)
1459
1459
  });
1460
- class $ extends _ {
1460
+ class V extends _ {
1461
1461
  _parse(e) {
1462
1462
  const { ctx: t, status: n } = this._processInputParams(e), s = this._def;
1463
1463
  if (t.parsedType !== f.array)
@@ -1493,27 +1493,27 @@ class $ extends _ {
1493
1493
  exact: !1,
1494
1494
  message: s.maxLength.message
1495
1495
  }), n.dirty()), t.common.async)
1496
- return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new B(t, i, t.path, o)))).then((i) => I.mergeArray(n, i));
1497
- const a = [...t.data].map((i, o) => s.type._parseSync(new B(t, i, t.path, o)));
1496
+ return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new W(t, i, t.path, o)))).then((i) => I.mergeArray(n, i));
1497
+ const a = [...t.data].map((i, o) => s.type._parseSync(new W(t, i, t.path, o)));
1498
1498
  return I.mergeArray(n, a);
1499
1499
  }
1500
1500
  get element() {
1501
1501
  return this._def.type;
1502
1502
  }
1503
1503
  min(e, t) {
1504
- return new $({
1504
+ return new V({
1505
1505
  ...this._def,
1506
1506
  minLength: { value: e, message: p.toString(t) }
1507
1507
  });
1508
1508
  }
1509
1509
  max(e, t) {
1510
- return new $({
1510
+ return new V({
1511
1511
  ...this._def,
1512
1512
  maxLength: { value: e, message: p.toString(t) }
1513
1513
  });
1514
1514
  }
1515
1515
  length(e, t) {
1516
- return new $({
1516
+ return new V({
1517
1517
  ...this._def,
1518
1518
  exactLength: { value: e, message: p.toString(t) }
1519
1519
  });
@@ -1522,7 +1522,7 @@ class $ extends _ {
1522
1522
  return this.min(1, e);
1523
1523
  }
1524
1524
  }
1525
- $.create = (r, e) => new $({
1525
+ V.create = (r, e) => new V({
1526
1526
  type: r,
1527
1527
  minLength: null,
1528
1528
  maxLength: null,
@@ -1535,16 +1535,16 @@ function he(r) {
1535
1535
  const e = {};
1536
1536
  for (const t in r.shape) {
1537
1537
  const n = r.shape[t];
1538
- e[t] = F.create(he(n));
1538
+ e[t] = B.create(he(n));
1539
1539
  }
1540
1540
  return new w({
1541
1541
  ...r._def,
1542
1542
  shape: () => e
1543
1543
  });
1544
- } else return r instanceof $ ? new $({
1544
+ } else return r instanceof V ? new V({
1545
1545
  ...r._def,
1546
1546
  type: he(r.element)
1547
- }) : r instanceof F ? F.create(he(r.unwrap())) : r instanceof ie ? ie.create(he(r.unwrap())) : r instanceof W ? W.create(r.items.map((e) => he(e))) : r;
1547
+ }) : r instanceof B ? B.create(he(r.unwrap())) : r instanceof ie ? ie.create(he(r.unwrap())) : r instanceof q ? q.create(r.items.map((e) => he(e))) : r;
1548
1548
  }
1549
1549
  class w extends _ {
1550
1550
  constructor() {
@@ -1574,7 +1574,7 @@ class w extends _ {
1574
1574
  const m = a[d], b = s.data[d];
1575
1575
  u.push({
1576
1576
  key: { status: "valid", value: d },
1577
- value: m._parse(new B(s, b, s.path, d)),
1577
+ value: m._parse(new W(s, b, s.path, d)),
1578
1578
  alwaysSet: d in s.data
1579
1579
  });
1580
1580
  }
@@ -1599,7 +1599,7 @@ class w extends _ {
1599
1599
  u.push({
1600
1600
  key: { status: "valid", value: m },
1601
1601
  value: d._parse(
1602
- new B(s, b, s.path, m)
1602
+ new W(s, b, s.path, m)
1603
1603
  //, ctx.child(key), value, getParsedType(value)
1604
1604
  ),
1605
1605
  alwaysSet: m in s.data
@@ -1799,7 +1799,7 @@ class w extends _ {
1799
1799
  t[n] = this.shape[n];
1800
1800
  else {
1801
1801
  let a = this.shape[n];
1802
- for (; a instanceof F; )
1802
+ for (; a instanceof B; )
1803
1803
  a = a._def.innerType;
1804
1804
  t[n] = a;
1805
1805
  }
@@ -1906,7 +1906,7 @@ Ne.create = (r, e) => new Ne({
1906
1906
  typeName: y.ZodUnion,
1907
1907
  ...g(e)
1908
1908
  });
1909
- const K = (r) => r instanceof Pe ? K(r.schema) : r instanceof V ? K(r.innerType()) : r instanceof je ? [r.value] : r instanceof ae ? r.options : r instanceof Me ? x.objectValues(r.enum) : r instanceof De ? K(r._def.innerType) : r instanceof Re ? [void 0] : r instanceof Ie ? [null] : r instanceof F ? [void 0, ...K(r.unwrap())] : r instanceof ie ? [null, ...K(r.unwrap())] : r instanceof pt || r instanceof Ue ? K(r.unwrap()) : r instanceof Le ? K(r._def.innerType) : [];
1909
+ const Y = (r) => r instanceof Pe ? Y(r.schema) : r instanceof z ? Y(r.innerType()) : r instanceof je ? [r.value] : r instanceof ae ? r.options : r instanceof Me ? x.objectValues(r.enum) : r instanceof De ? Y(r._def.innerType) : r instanceof Re ? [void 0] : r instanceof Ie ? [null] : r instanceof B ? [void 0, ...Y(r.unwrap())] : r instanceof ie ? [null, ...Y(r.unwrap())] : r instanceof pt || r instanceof Ue ? Y(r.unwrap()) : r instanceof Le ? Y(r._def.innerType) : [];
1910
1910
  class Qe extends _ {
1911
1911
  _parse(e) {
1912
1912
  const { ctx: t } = this._processInputParams(e);
@@ -1951,7 +1951,7 @@ class Qe extends _ {
1951
1951
  static create(e, t, n) {
1952
1952
  const s = /* @__PURE__ */ new Map();
1953
1953
  for (const a of t) {
1954
- const i = K(a.shape[e]);
1954
+ const i = Y(a.shape[e]);
1955
1955
  if (!i.length)
1956
1956
  throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
1957
1957
  for (const o of i) {
@@ -2033,7 +2033,7 @@ Ae.create = (r, e, t) => new Ae({
2033
2033
  typeName: y.ZodIntersection,
2034
2034
  ...g(t)
2035
2035
  });
2036
- class W extends _ {
2036
+ class q extends _ {
2037
2037
  _parse(e) {
2038
2038
  const { status: t, ctx: n } = this._processInputParams(e);
2039
2039
  if (n.parsedType !== f.array)
@@ -2059,7 +2059,7 @@ class W extends _ {
2059
2059
  }), t.dirty());
2060
2060
  const a = [...n.data].map((i, o) => {
2061
2061
  const u = this._def.items[o] || this._def.rest;
2062
- return u ? u._parse(new B(n, i, n.path, o)) : null;
2062
+ return u ? u._parse(new W(n, i, n.path, o)) : null;
2063
2063
  }).filter((i) => !!i);
2064
2064
  return n.common.async ? Promise.all(a).then((i) => I.mergeArray(t, i)) : I.mergeArray(t, a);
2065
2065
  }
@@ -2067,16 +2067,16 @@ class W extends _ {
2067
2067
  return this._def.items;
2068
2068
  }
2069
2069
  rest(e) {
2070
- return new W({
2070
+ return new q({
2071
2071
  ...this._def,
2072
2072
  rest: e
2073
2073
  });
2074
2074
  }
2075
2075
  }
2076
- W.create = (r, e) => {
2076
+ q.create = (r, e) => {
2077
2077
  if (!Array.isArray(r))
2078
2078
  throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2079
- return new W({
2079
+ return new q({
2080
2080
  items: r,
2081
2081
  typeName: y.ZodTuple,
2082
2082
  rest: null,
@@ -2101,8 +2101,8 @@ class Ze extends _ {
2101
2101
  const s = [], a = this._def.keyType, i = this._def.valueType;
2102
2102
  for (const o in n.data)
2103
2103
  s.push({
2104
- key: a._parse(new B(n, o, n.path, o)),
2105
- value: i._parse(new B(n, n.data[o], n.path, o)),
2104
+ key: a._parse(new W(n, o, n.path, o)),
2105
+ value: i._parse(new W(n, n.data[o], n.path, o)),
2106
2106
  alwaysSet: o in n.data
2107
2107
  });
2108
2108
  return n.common.async ? I.mergeObjectAsync(t, s) : I.mergeObjectSync(t, s);
@@ -2117,7 +2117,7 @@ class Ze extends _ {
2117
2117
  typeName: y.ZodRecord,
2118
2118
  ...g(n)
2119
2119
  }) : new Ze({
2120
- keyType: U.create(),
2120
+ keyType: $.create(),
2121
2121
  valueType: e,
2122
2122
  typeName: y.ZodRecord,
2123
2123
  ...g(t)
@@ -2140,8 +2140,8 @@ class Ge extends _ {
2140
2140
  received: n.parsedType
2141
2141
  }), v;
2142
2142
  const s = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([o, u], d) => ({
2143
- key: s._parse(new B(n, o, n.path, [d, "key"])),
2144
- value: a._parse(new B(n, u, n.path, [d, "value"]))
2143
+ key: s._parse(new W(n, o, n.path, [d, "key"])),
2144
+ value: a._parse(new W(n, u, n.path, [d, "value"]))
2145
2145
  }));
2146
2146
  if (n.common.async) {
2147
2147
  const o = /* @__PURE__ */ new Map();
@@ -2207,7 +2207,7 @@ class le extends _ {
2207
2207
  }
2208
2208
  return { status: t.value, value: d };
2209
2209
  }
2210
- const o = [...n.data.values()].map((u, d) => a._parse(new B(n, u, n.path, d)));
2210
+ const o = [...n.data.values()].map((u, d) => a._parse(new W(n, u, n.path, d)));
2211
2211
  return n.common.async ? Promise.all(o).then((u) => i(u)) : i(o);
2212
2212
  }
2213
2213
  min(e, t) {
@@ -2284,11 +2284,11 @@ class pe extends _ {
2284
2284
  if (this._def.returns instanceof ge) {
2285
2285
  const o = this;
2286
2286
  return N(async function(...u) {
2287
- const d = new Z([]), m = await o._def.args.parseAsync(u, a).catch((q) => {
2288
- throw d.addIssue(n(u, q)), d;
2287
+ const d = new Z([]), m = await o._def.args.parseAsync(u, a).catch((H) => {
2288
+ throw d.addIssue(n(u, H)), d;
2289
2289
  }), b = await Reflect.apply(i, this, m);
2290
- return await o._def.returns._def.type.parseAsync(b, a).catch((q) => {
2291
- throw d.addIssue(s(b, q)), d;
2290
+ return await o._def.returns._def.type.parseAsync(b, a).catch((H) => {
2291
+ throw d.addIssue(s(b, H)), d;
2292
2292
  });
2293
2293
  });
2294
2294
  } else {
@@ -2313,7 +2313,7 @@ class pe extends _ {
2313
2313
  args(...e) {
2314
2314
  return new pe({
2315
2315
  ...this._def,
2316
- args: W.create(e).rest(de.create())
2316
+ args: q.create(e).rest(de.create())
2317
2317
  });
2318
2318
  }
2319
2319
  returns(e) {
@@ -2330,7 +2330,7 @@ class pe extends _ {
2330
2330
  }
2331
2331
  static create(e, t, n) {
2332
2332
  return new pe({
2333
- args: e || W.create([]).rest(de.create()),
2333
+ args: e || q.create([]).rest(de.create()),
2334
2334
  returns: t || de.create(),
2335
2335
  typeName: y.ZodFunction,
2336
2336
  ...g(n)
@@ -2496,7 +2496,7 @@ ge.create = (r, e) => new ge({
2496
2496
  typeName: y.ZodPromise,
2497
2497
  ...g(e)
2498
2498
  });
2499
- class V extends _ {
2499
+ class z extends _ {
2500
2500
  innerType() {
2501
2501
  return this._def.schema;
2502
2502
  }
@@ -2573,19 +2573,19 @@ class V extends _ {
2573
2573
  x.assertNever(s);
2574
2574
  }
2575
2575
  }
2576
- V.create = (r, e, t) => new V({
2576
+ z.create = (r, e, t) => new z({
2577
2577
  schema: r,
2578
2578
  typeName: y.ZodEffects,
2579
2579
  effect: e,
2580
2580
  ...g(t)
2581
2581
  });
2582
- V.createWithPreprocess = (r, e, t) => new V({
2582
+ z.createWithPreprocess = (r, e, t) => new z({
2583
2583
  schema: e,
2584
2584
  effect: { type: "preprocess", transform: r },
2585
2585
  typeName: y.ZodEffects,
2586
2586
  ...g(t)
2587
2587
  });
2588
- class F extends _ {
2588
+ class B extends _ {
2589
2589
  _parse(e) {
2590
2590
  return this._getType(e) === f.undefined ? N(void 0) : this._def.innerType._parse(e);
2591
2591
  }
@@ -2593,7 +2593,7 @@ class F extends _ {
2593
2593
  return this._def.innerType;
2594
2594
  }
2595
2595
  }
2596
- F.create = (r, e) => new F({
2596
+ B.create = (r, e) => new B({
2597
2597
  innerType: r,
2598
2598
  typeName: y.ZodOptional,
2599
2599
  ...g(e)
@@ -2777,8 +2777,8 @@ var y;
2777
2777
  })(y || (y = {}));
2778
2778
  const Br = (r, e = {
2779
2779
  message: `Input not instance of ${r.name}`
2780
- }) => $t((t) => t instanceof r, e), Vt = U.create, zt = ne.create, Wr = Xe.create, qr = se.create, Ft = Oe.create, Hr = ue.create, Kr = Ye.create, Yr = Re.create, Jr = Ie.create, Gr = ve.create, Xr = de.create, Qr = J.create, en = Je.create, tn = $.create, rn = w.create, nn = w.strictCreate, sn = Ne.create, an = Qe.create, on = Ae.create, cn = W.create, dn = Ze.create, un = Ge.create, ln = le.create, fn = pe.create, hn = Pe.create, mn = je.create, pn = ae.create, yn = Me.create, vn = ge.create, Ct = V.create, gn = F.create, _n = ie.create, xn = V.createWithPreprocess, bn = $e.create, kn = () => Vt().optional(), wn = () => zt().optional(), En = () => Ft().optional(), Tn = {
2781
- string: (r) => U.create({ ...r, coerce: !0 }),
2780
+ }) => $t((t) => t instanceof r, e), Vt = $.create, zt = ne.create, Wr = Xe.create, qr = se.create, Ft = Oe.create, Hr = ue.create, Kr = Ye.create, Yr = Re.create, Jr = Ie.create, Gr = ve.create, Xr = de.create, Qr = J.create, en = Je.create, tn = V.create, rn = w.create, nn = w.strictCreate, sn = Ne.create, an = Qe.create, on = Ae.create, cn = q.create, dn = Ze.create, un = Ge.create, ln = le.create, fn = pe.create, hn = Pe.create, mn = je.create, pn = ae.create, yn = Me.create, vn = ge.create, Ct = z.create, gn = B.create, _n = ie.create, xn = z.createWithPreprocess, bn = $e.create, kn = () => Vt().optional(), wn = () => zt().optional(), En = () => Ft().optional(), Tn = {
2781
+ string: (r) => $.create({ ...r, coerce: !0 }),
2782
2782
  number: (r) => ne.create({ ...r, coerce: !0 }),
2783
2783
  boolean: (r) => Oe.create({
2784
2784
  ...r,
@@ -2813,7 +2813,7 @@ var h = /* @__PURE__ */ Object.freeze({
2813
2813
  getParsedType: te,
2814
2814
  ZodType: _,
2815
2815
  datetimeRegex: Lt,
2816
- ZodString: U,
2816
+ ZodString: $,
2817
2817
  ZodNumber: ne,
2818
2818
  ZodBigInt: se,
2819
2819
  ZodBoolean: Oe,
@@ -2825,12 +2825,12 @@ var h = /* @__PURE__ */ Object.freeze({
2825
2825
  ZodUnknown: de,
2826
2826
  ZodNever: J,
2827
2827
  ZodVoid: Je,
2828
- ZodArray: $,
2828
+ ZodArray: V,
2829
2829
  ZodObject: w,
2830
2830
  ZodUnion: Ne,
2831
2831
  ZodDiscriminatedUnion: Qe,
2832
2832
  ZodIntersection: Ae,
2833
- ZodTuple: W,
2833
+ ZodTuple: q,
2834
2834
  ZodRecord: Ze,
2835
2835
  ZodMap: Ge,
2836
2836
  ZodSet: le,
@@ -2840,9 +2840,9 @@ var h = /* @__PURE__ */ Object.freeze({
2840
2840
  ZodEnum: ae,
2841
2841
  ZodNativeEnum: Me,
2842
2842
  ZodPromise: ge,
2843
- ZodEffects: V,
2844
- ZodTransformer: V,
2845
- ZodOptional: F,
2843
+ ZodEffects: z,
2844
+ ZodTransformer: z,
2845
+ ZodOptional: B,
2846
2846
  ZodNullable: ie,
2847
2847
  ZodDefault: De,
2848
2848
  ZodCatch: Le,
@@ -2903,7 +2903,7 @@ var h = /* @__PURE__ */ Object.freeze({
2903
2903
  quotelessJson: Er,
2904
2904
  ZodError: Z
2905
2905
  });
2906
- const M = h.string().trim().min(1, { message: "Cannot be blank" }), Y = h.string().trim().optional(), Ot = (r) => h.nullable(r.optional());
2906
+ const D = h.string().trim().min(1, { message: "Cannot be blank" }), M = h.string().trim().optional(), Ot = (r) => h.nullable(r.optional());
2907
2907
  var Bt = /* @__PURE__ */ ((r) => (r.FIRST_NAME = "firstName", r.LAST_NAME = "lastName", r.EMAIL = "email", r.ZIP_CODE = "zipCode", r.CITY = "city", r.STATE = "state", r.COUNTRY = "country", r.ADDRESS = "address", r.PHONE = "phone", r.PROMOTION_CODE = "promotionCode", r))(Bt || {});
2908
2908
  const Wt = h.nativeEnum(Bt);
2909
2909
  var qt = /* @__PURE__ */ ((r) => (r.CARD_NUMBER = "cardNumber", r.CARD_EXPIRY = "cardExpiry", r.CARD_CVC = "cardCvc", r))(qt || {});
@@ -2913,13 +2913,18 @@ const Ht = h.nativeEnum(qt), Cn = h.union([Wt, Ht]), Kt = h.object({
2913
2913
  metadata: Ot(h.record(h.string(), h.any()))
2914
2914
  });
2915
2915
  h.object({
2916
- backgroundColor: Y,
2917
- color: Y,
2918
- fontFamily: Y,
2919
- fontSize: Y,
2920
- fontWeight: Y,
2921
- margin: Y,
2922
- padding: Y
2916
+ cardNumber: M,
2917
+ expiry: M,
2918
+ cvc: M
2919
+ });
2920
+ h.object({
2921
+ backgroundColor: M,
2922
+ color: M,
2923
+ fontFamily: M,
2924
+ fontSize: M,
2925
+ fontWeight: M,
2926
+ margin: M,
2927
+ padding: M
2923
2928
  });
2924
2929
  const k = h.enum([
2925
2930
  // Element -> Form
@@ -2945,32 +2950,32 @@ const k = h.enum([
2945
2950
  elementType: Ht
2946
2951
  }), An = k.extract(["LOAD_ERROR", "TOKENIZE_ERROR", "CHECKOUT_ERROR"]), Zn = h.object({
2947
2952
  type: An,
2948
- message: M
2953
+ message: D
2949
2954
  }), Pn = k.extract(["VALIDATION_ERROR"]), jn = h.object({
2950
2955
  type: Pn,
2951
2956
  elementType: Cn,
2952
2957
  errors: h.array(h.string())
2953
2958
  }), Mn = h.object({
2954
2959
  type: h.literal(k.enum.LOADED),
2955
- sessionId: M,
2956
- height: M,
2960
+ sessionId: D,
2961
+ height: D,
2957
2962
  totalAmountAtoms: h.number(),
2958
- currency: Y,
2963
+ currency: M,
2959
2964
  checkoutPaymentMethods: h.array(Kt)
2960
2965
  }), Dn = h.object({
2961
2966
  type: h.literal(k.enum.PAYMENT_FLOW_STARTED),
2962
2967
  nextActionMetadata: h.record(h.string(), h.any()),
2963
2968
  paymentFlowMetadata: h.any().optional()
2964
2969
  }), Ln = h.object({
2965
- firstName: M,
2966
- lastName: M,
2967
- email: M,
2968
- zipCode: M,
2969
- country: M,
2970
- promotionCode: Y
2970
+ firstName: D,
2971
+ lastName: D,
2972
+ email: D,
2973
+ zipCode: D,
2974
+ country: D,
2975
+ promotionCode: M
2971
2976
  }), Un = k.extract(["TOKENIZE", "CHECKOUT", "START_PAYMENT_FLOW"]), Yt = h.object({
2972
2977
  type: Un,
2973
- sessionId: M,
2978
+ sessionId: D,
2974
2979
  checkoutPaymentMethod: Kt,
2975
2980
  paymentFlowMetadata: h.any().optional()
2976
2981
  }).extend(Ln.shape), $n = h.object({
@@ -2993,9 +2998,9 @@ const k = h.enum([
2993
2998
  Dn
2994
2999
  ]), Fn = h.object({
2995
3000
  payload: zn,
2996
- nonce: M,
2997
- formId: M,
2998
- elementId: M
3001
+ nonce: D,
3002
+ formId: D,
3003
+ elementId: D
2999
3004
  });
3000
3005
  h.object({
3001
3006
  isLoading: h.boolean(),
@@ -3044,7 +3049,7 @@ const Bn = (r) => {
3044
3049
  elementId: t
3045
3050
  };
3046
3051
  r.postMessage(JSON.stringify(a), s);
3047
- }, qn = "https://cde.getopenpay.com", Hn = {
3052
+ }, qn = "https://cde.openpaystaging.com", Hn = {
3048
3053
  usd: "usd",
3049
3054
  brl: "brl"
3050
3055
  }, Gt = (r) => {
@@ -3207,11 +3212,11 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3207
3212
  for (const m of fs.options) {
3208
3213
  const b = m.replace("_", "");
3209
3214
  try {
3210
- const T = t.find((H) => H.provider === m && H.processor_name === "stripe");
3215
+ const T = t.find((K) => K.provider === m && K.processor_name === "stripe");
3211
3216
  if (!T)
3212
3217
  throw new Error(`${b} is not available as a checkout method`);
3213
- const q = Gn(T.metadata), A = await Kn(q, r, e), z = await A.canMakePayment();
3214
- if (!z)
3218
+ const H = Gn(T.metadata), A = await Kn(H, r, e), F = await A.canMakePayment();
3219
+ if (!F)
3215
3220
  throw new Error(`Cannot make payment with ${b} for this session`);
3216
3221
  const tt = async () => {
3217
3222
  try {
@@ -3225,15 +3230,15 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3225
3230
  ))
3226
3231
  return;
3227
3232
  A.show();
3228
- const H = await Jn(A);
3229
- s(H, T);
3230
- } catch (H) {
3231
- i(Qt(H));
3233
+ const K = await Jn(A);
3234
+ s(K, T);
3235
+ } catch (K) {
3236
+ i(Qt(K));
3232
3237
  }
3233
3238
  };
3234
3239
  u.set(m, {
3235
3240
  isLoading: !1,
3236
- isAvailable: z[hs[m]],
3241
+ isAvailable: F[hs[m]],
3237
3242
  startFlow: tt
3238
3243
  });
3239
3244
  } catch {
@@ -3255,14 +3260,14 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3255
3260
  onCheckoutStarted: m,
3256
3261
  onCheckoutSuccess: b,
3257
3262
  onCheckoutError: T,
3258
- baseUrl: q
3259
- } = r, A = q ?? qn, [z, tt] = R(void 0), [H, vt] = R([]), [er, tr] = R("1px"), [gt, rr] = R(!1), [G, Ve] = R(void 0), [_t, _e] = R(!1), [fe, nr] = R([]), [oe, sr] = R({}), [xt, bt] = R(0), [kt, ce] = R(!1), [X, ar] = R(void 0), [rt, ir] = R(void 0), [ze, or] = R(void 0), [xe, cr] = R(void 0), [nt, dr] = R(void 0), Q = Te(() => `opjs-form-${Zt()}`, []), ee = Nt(null), st = ke(
3263
+ baseUrl: H
3264
+ } = r, A = H ?? qn, [F, tt] = R(void 0), [K, vt] = R([]), [er, tr] = R("1px"), [gt, rr] = R(!1), [G, Ve] = R(void 0), [_t, _e] = R(!1), [fe, nr] = R([]), [oe, sr] = R({}), [xt, bt] = R(0), [kt, ce] = R(!1), [X, ar] = R(void 0), [rt, ir] = R(void 0), [ze, or] = R(void 0), [xe, cr] = R(void 0), [nt, dr] = R(void 0), Q = Te(() => `opjs-form-${Zt()}`, []), ee = Nt(null), st = ke(
3260
3265
  (C) => {
3261
3266
  if (C.origin !== A || !C.source) return;
3262
- const P = C.source, S = Wn(JSON.parse(C.data)), D = S.elementId;
3263
- if (S.formId !== Q || !D || S.nonce in H)
3267
+ const P = C.source, S = Wn(JSON.parse(C.data)), L = S.elementId;
3268
+ if (S.formId !== Q || !L || S.nonce in K)
3264
3269
  return;
3265
- vt((L) => [...L, S.nonce]);
3270
+ vt((U) => [...U, S.nonce]);
3266
3271
  const E = S.payload, j = E.type;
3267
3272
  if (j === k.enum.FOCUS && s)
3268
3273
  s(S.elementId);
@@ -3271,10 +3276,10 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3271
3276
  else if (j === k.enum.CHANGE && i)
3272
3277
  i(S.elementId);
3273
3278
  else if (j === k.enum.LOADED) {
3274
- const L = fe.find((it) => it.contentWindow === P);
3275
- if (_e(!1), !L)
3279
+ const U = fe.find((it) => it.contentWindow === P);
3280
+ if (_e(!1), !U)
3276
3281
  return;
3277
- sr((it) => ({ ...it, [D]: P }));
3282
+ sr((it) => ({ ...it, [L]: P }));
3278
3283
  const be = E.height ? `${E.height}px` : "100%";
3279
3284
  tr(be), or(E.totalAmountAtoms), ir(E.currency), cr(E.checkoutPaymentMethods), X || ar(E.sessionId);
3280
3285
  } else if (j === k.enum.TOKENIZE_STARTED)
@@ -3285,27 +3290,27 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3285
3290
  if (!G)
3286
3291
  throw new Error("extraData not populated");
3287
3292
  Xn(E, nt).then(() => {
3288
- Be(P, Q, D, { ...G, type: "CHECKOUT" }, A), ce(!0), Ve(void 0), m && m();
3289
- }).catch((L) => {
3290
- const be = Qt(L);
3293
+ Be(P, Q, L, { ...G, type: "CHECKOUT" }, A), ce(!0), Ve(void 0), m && m();
3294
+ }).catch((U) => {
3295
+ const be = Qt(U);
3291
3296
  _e(!1), ce(!1), T && T(be);
3292
3297
  });
3293
3298
  } else if (j === k.enum.TOKENIZE_SUCCESS && G) {
3294
- const L = xt + 1, be = L === Object.keys(oe).length;
3295
- !kt && (be || E.isReadyForCheckout) ? (Be(P, Q, D, G, A), ce(!0), Ve(void 0)) : bt(L);
3299
+ const U = xt + 1, be = U === Object.keys(oe).length;
3300
+ !kt && (be || E.isReadyForCheckout) ? (Be(P, Q, L, G, A), ce(!0), Ve(void 0)) : bt(U);
3296
3301
  } else if (j === k.enum.CHECKOUT_SUCCESS)
3297
3302
  _e(!1), bt(0), ce(!1), b && b(E.invoiceUrls, E.subscriptionIds, E.customerId);
3298
3303
  else if (j === k.enum.LOAD_ERROR)
3299
3304
  u && u(E.message);
3300
3305
  else if (j === k.enum.VALIDATION_ERROR) {
3301
- const L = G == null ? void 0 : G.checkoutPaymentMethod.provider;
3302
- (L === "credit_card" || L === void 0) && d && d(E.elementType, E.errors, D);
3306
+ const U = G == null ? void 0 : G.checkoutPaymentMethod.provider;
3307
+ (U === "credit_card" || U === void 0) && d && d(E.elementType, E.errors, L);
3303
3308
  } else (j === k.enum.TOKENIZE_ERROR || j === k.enum.CHECKOUT_ERROR) && (_e(!1), ce(!1), T && T(E.message));
3304
3309
  },
3305
3310
  [
3306
3311
  Q,
3307
3312
  X,
3308
- H,
3313
+ K,
3309
3314
  G,
3310
3315
  fe,
3311
3316
  oe,
@@ -3335,8 +3340,8 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3335
3340
  C
3336
3341
  );
3337
3342
  if (P) {
3338
- for (const [S, D] of Object.entries(oe))
3339
- D && Be(D, Q, S, P, A);
3343
+ for (const [S, L] of Object.entries(oe))
3344
+ L && Be(L, Q, S, P, A);
3340
3345
  P.type = k.enum.CHECKOUT, Ve(P);
3341
3346
  }
3342
3347
  }, [ee, oe, Q, d, X, A, xe]), at = ke(
@@ -3357,8 +3362,8 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3357
3362
  [fe]
3358
3363
  ), fr = async (C, P) => {
3359
3364
  if (!(!ee.current || !d || !X || !xe))
3360
- for (const [S, D] of Object.entries(oe)) {
3361
- if (!D) continue;
3365
+ for (const [S, L] of Object.entries(oe)) {
3366
+ if (!L) continue;
3362
3367
  const Et = {
3363
3368
  stripePmId: C.paymentMethod.id
3364
3369
  }, E = ht(
@@ -3370,7 +3375,7 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3370
3375
  Et
3371
3376
  );
3372
3377
  if (E) {
3373
- dr(C), ce(!0), Ve(E), Be(D, Q, S, E, A);
3378
+ dr(C), ce(!0), Ve(E), Be(L, Q, S, E, A);
3374
3379
  break;
3375
3380
  }
3376
3381
  }
@@ -3379,7 +3384,7 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3379
3384
  }, mr = {
3380
3385
  formId: Q,
3381
3386
  formHeight: er,
3382
- referer: z,
3387
+ referer: F,
3383
3388
  checkoutSecureToken: t,
3384
3389
  registerIframe: lr,
3385
3390
  baseUrl: A
@@ -3398,14 +3403,14 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3398
3403
  };
3399
3404
  return /* @__PURE__ */ re(At.Provider, { value: mr, children: /* @__PURE__ */ re("div", { className: n, ref: ee, children: e(pr) }) });
3400
3405
  }, ys = (r) => JSON.stringify(r), et = (r) => {
3401
- const { subPath: e, styles: t } = r, { formId: n, referer: s, formHeight: a, checkoutSecureToken: i, registerIframe: o, baseUrl: u } = _r(), [d, m] = R(!1), b = Nt(null), T = Te(() => t ? ys(t) : "", [t]), q = Te(() => ({
3406
+ const { subPath: e, styles: t } = r, { formId: n, referer: s, formHeight: a, checkoutSecureToken: i, registerIframe: o, baseUrl: u } = _r(), [d, m] = R(!1), b = Nt(null), T = Te(() => t ? ys(t) : "", [t]), H = Te(() => ({
3402
3407
  border: "none",
3403
3408
  width: "100%",
3404
3409
  height: a
3405
3410
  }), [a]), A = Te(() => {
3406
3411
  if (!i || !s) return "";
3407
- const z = new URLSearchParams();
3408
- return z.append("referer", s), z.append("styles", T), z.append("formId", n), z.append("secureToken", i), z.toString();
3412
+ const F = new URLSearchParams();
3413
+ return F.append("referer", s), F.append("styles", T), F.append("formId", n), F.append("secureToken", i), F.toString();
3409
3414
  }, [T, n, s, i]);
3410
3415
  return We(() => m(!0), []), We(() => {
3411
3416
  !b.current || !d || o(b.current);
@@ -3414,7 +3419,7 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3414
3419
  {
3415
3420
  name: `${e}-element`,
3416
3421
  src: `${u}/app/v1/${e}-element/?${A}`,
3417
- style: q,
3422
+ style: H,
3418
3423
  ref: b
3419
3424
  }
3420
3425
  ) : /* @__PURE__ */ re("div", {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getopenpay/openpay-js-react",
3
- "version": "0.0.9",
3
+ "version": "0.0.10-alpha.4002911",
4
4
  "description": "Accept payments through OpenPay, right on your site",
5
5
  "author": "OpenPay <info@getopenpay.com> (https://getopenpay.com)",
6
6
  "type": "module",