@justifi/webcomponents 4.0.0 → 4.0.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.
Files changed (91) hide show
  1. package/CHANGELOG.md +26 -2
  2. package/changelog-template.hbs +3 -34
  3. package/dist/cjs/{Payment-5781460e.js → Payment-ac4dea02.js} +1 -1
  4. package/dist/cjs/index.esm-8df4906e.js +2092 -0
  5. package/dist/cjs/justifi-bank-account-form.cjs.entry.js +2 -2
  6. package/dist/cjs/justifi-billing-form_2.cjs.entry.js +14 -2104
  7. package/dist/cjs/justifi-business-address.cjs.entry.js +66 -0
  8. package/dist/cjs/justifi-card-form.cjs.entry.js +2 -2
  9. package/dist/cjs/justifi-payment-form.cjs.entry.js +4 -4
  10. package/dist/cjs/justifi-payment-method-form.cjs.entry.js +14 -14
  11. package/dist/cjs/justifi-payments-list.cjs.entry.js +9 -9
  12. package/dist/cjs/loader.cjs.js +1 -1
  13. package/dist/cjs/select-input_2.cjs.entry.js +2 -4
  14. package/dist/cjs/webcomponents.cjs.js +1 -1
  15. package/dist/collection/api/Api.js +3 -5
  16. package/dist/collection/api/Payment.js +1 -1
  17. package/dist/collection/api/mockData/MockPayments.js +24 -22
  18. package/dist/collection/collection-manifest.json +1 -0
  19. package/dist/collection/components/bank-account-form/bank-account-form.js +2 -2
  20. package/dist/collection/components/bank-account-form/bank-account-form.stories.js +13 -9
  21. package/dist/collection/components/bank-account-form/example.js +54 -0
  22. package/dist/collection/components/billing-form/billing-form-schema.js +1 -4
  23. package/dist/collection/components/billing-form/billing-form.js +7 -2
  24. package/dist/collection/components/billing-form/billing-form.stories.js +4 -4
  25. package/dist/collection/components/billing-form/example.js +26 -0
  26. package/dist/collection/components/billing-form/state-options.js +61 -61
  27. package/dist/collection/components/business-address/business-address-schema.js +13 -0
  28. package/dist/collection/components/business-address/business-address.css +2325 -0
  29. package/dist/collection/components/business-address/business-address.js +99 -0
  30. package/dist/collection/components/card-form/card-form.js +2 -2
  31. package/dist/collection/components/card-form/card-form.stories.js +11 -7
  32. package/dist/collection/components/card-form/example.js +59 -0
  33. package/dist/collection/components/payment-form/example.js +23 -0
  34. package/dist/collection/components/payment-form/payment-form.css +2 -0
  35. package/dist/collection/components/payment-form/payment-form.js +2 -2
  36. package/dist/collection/components/payment-form/payment-form.stories.js +15 -12
  37. package/dist/collection/components/payment-form/payment-method-selector.css +5 -0
  38. package/dist/collection/components/payment-form/payment-method-selector.js +2 -3
  39. package/dist/collection/components/payment-method-form/get-computed-theme.js +1 -1
  40. package/dist/collection/components/payment-method-form/message-event-types.js +1 -1
  41. package/dist/collection/components/payment-method-form/payment-method-form.js +5 -8
  42. package/dist/collection/components/payments-list/payments-list.js +4 -4
  43. package/dist/collection/components/select-input/select-input.js +3 -4
  44. package/dist/collection/components/text-input/text-input.js +2 -3
  45. package/dist/collection/utils/utils.js +1 -5
  46. package/dist/components/Payment.js +1 -1
  47. package/dist/components/billing-form.js +4 -2093
  48. package/dist/components/index.d.ts +1 -0
  49. package/dist/components/index.js +1 -0
  50. package/dist/components/justifi-bank-account-form.js +2 -2
  51. package/dist/components/justifi-business-address.d.ts +11 -0
  52. package/dist/components/justifi-business-address.js +96 -0
  53. package/dist/components/justifi-card-form.js +2 -2
  54. package/dist/components/justifi-payment-form.js +3 -3
  55. package/dist/components/justifi-payments-list.js +8 -8
  56. package/dist/components/payment-method-form.js +14 -14
  57. package/dist/components/payment-method-selector.js +3 -4
  58. package/dist/components/select-input2.js +1 -2
  59. package/dist/components/state-options.js +2088 -0
  60. package/dist/components/text-input2.js +1 -2
  61. package/dist/esm/{Payment-3f7570a8.js → Payment-c86e1e84.js} +1 -1
  62. package/dist/esm/index.esm-c6a89005.js +2088 -0
  63. package/dist/esm/justifi-bank-account-form.entry.js +2 -2
  64. package/dist/esm/justifi-billing-form_2.entry.js +7 -2097
  65. package/dist/esm/justifi-business-address.entry.js +62 -0
  66. package/dist/esm/justifi-card-form.entry.js +2 -2
  67. package/dist/esm/justifi-payment-form.entry.js +4 -4
  68. package/dist/esm/justifi-payment-method-form.entry.js +14 -14
  69. package/dist/esm/justifi-payments-list.entry.js +9 -9
  70. package/dist/esm/loader.js +1 -1
  71. package/dist/esm/select-input_2.entry.js +2 -4
  72. package/dist/esm/webcomponents.js +1 -1
  73. package/dist/types/components/bank-account-form/bank-account-form.d.ts +5 -5
  74. package/dist/types/components/billing-form/billing-form.d.ts +5 -0
  75. package/dist/types/components/business-address/business-address-schema.d.ts +23 -0
  76. package/dist/types/components/business-address/business-address.d.ts +11 -0
  77. package/dist/types/components/card-form/card-form.d.ts +5 -5
  78. package/dist/types/components/payment-method-form/get-computed-theme.d.ts +1 -1
  79. package/dist/types/components.d.ts +19 -4
  80. package/dist/webcomponents/p-039e3540.entry.js +1 -0
  81. package/dist/webcomponents/{p-64b19598.entry.js → p-11e5bef9.entry.js} +1 -1
  82. package/dist/webcomponents/p-20732337.js +1 -0
  83. package/dist/webcomponents/p-5b5e8351.entry.js +1 -0
  84. package/dist/webcomponents/{p-48bd3d00.entry.js → p-5b68fa52.entry.js} +1 -1
  85. package/dist/webcomponents/{p-bf40b1ca.entry.js → p-7747c086.entry.js} +1 -1
  86. package/dist/webcomponents/webcomponents.css +1 -1
  87. package/dist/webcomponents/webcomponents.esm.js +1 -1
  88. package/package.json +8 -5
  89. package/readme.md +7 -3
  90. package/dist/webcomponents/p-2530278e.entry.js +0 -1
  91. /package/dist/webcomponents/{p-21e020a8.js → p-1ca0646b.js} +0 -0
@@ -1,1851 +1,8 @@
1
1
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
+ import { c as create$3, a as create$6, S as StateOptions } from './state-options.js';
2
3
  import { d as defineCustomElement$2 } from './select-input2.js';
3
4
  import { d as defineCustomElement$1 } from './text-input2.js';
4
5
 
5
- /**
6
- * Based on Kendo UI Core expression code <https://github.com/telerik/kendo-ui-core#license-information>
7
- */
8
-
9
- function Cache(maxSize) {
10
- this._maxSize = maxSize;
11
- this.clear();
12
- }
13
- Cache.prototype.clear = function () {
14
- this._size = 0;
15
- this._values = Object.create(null);
16
- };
17
- Cache.prototype.get = function (key) {
18
- return this._values[key]
19
- };
20
- Cache.prototype.set = function (key, value) {
21
- this._size >= this._maxSize && this.clear();
22
- if (!(key in this._values)) this._size++;
23
-
24
- return (this._values[key] = value)
25
- };
26
-
27
- var SPLIT_REGEX = /[^.^\]^[]+|(?=\[\]|\.\.)/g,
28
- DIGIT_REGEX = /^\d+$/,
29
- LEAD_DIGIT_REGEX = /^\d/,
30
- SPEC_CHAR_REGEX = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,
31
- CLEAN_QUOTES_REGEX = /^\s*(['"]?)(.*?)(\1)\s*$/,
32
- MAX_CACHE_SIZE = 512;
33
-
34
- var pathCache = new Cache(MAX_CACHE_SIZE),
35
- setCache = new Cache(MAX_CACHE_SIZE),
36
- getCache = new Cache(MAX_CACHE_SIZE);
37
-
38
- var propertyExpr = {
39
- Cache: Cache,
40
-
41
- split: split,
42
-
43
- normalizePath: normalizePath,
44
-
45
- setter: function (path) {
46
- var parts = normalizePath(path);
47
-
48
- return (
49
- setCache.get(path) ||
50
- setCache.set(path, function setter(obj, value) {
51
- var index = 0;
52
- var len = parts.length;
53
- var data = obj;
54
-
55
- while (index < len - 1) {
56
- var part = parts[index];
57
- if (
58
- part === '__proto__' ||
59
- part === 'constructor' ||
60
- part === 'prototype'
61
- ) {
62
- return obj
63
- }
64
-
65
- data = data[parts[index++]];
66
- }
67
- data[parts[index]] = value;
68
- })
69
- )
70
- },
71
-
72
- getter: function (path, safe) {
73
- var parts = normalizePath(path);
74
- return (
75
- getCache.get(path) ||
76
- getCache.set(path, function getter(data) {
77
- var index = 0,
78
- len = parts.length;
79
- while (index < len) {
80
- if (data != null || !safe) data = data[parts[index++]];
81
- else return
82
- }
83
- return data
84
- })
85
- )
86
- },
87
-
88
- join: function (segments) {
89
- return segments.reduce(function (path, part) {
90
- return (
91
- path +
92
- (isQuoted(part) || DIGIT_REGEX.test(part)
93
- ? '[' + part + ']'
94
- : (path ? '.' : '') + part)
95
- )
96
- }, '')
97
- },
98
-
99
- forEach: function (path, cb, thisArg) {
100
- forEach(Array.isArray(path) ? path : split(path), cb, thisArg);
101
- },
102
- };
103
-
104
- function normalizePath(path) {
105
- return (
106
- pathCache.get(path) ||
107
- pathCache.set(
108
- path,
109
- split(path).map(function (part) {
110
- return part.replace(CLEAN_QUOTES_REGEX, '$2')
111
- })
112
- )
113
- )
114
- }
115
-
116
- function split(path) {
117
- return path.match(SPLIT_REGEX) || ['']
118
- }
119
-
120
- function forEach(parts, iter, thisArg) {
121
- var len = parts.length,
122
- part,
123
- idx,
124
- isArray,
125
- isBracket;
126
-
127
- for (idx = 0; idx < len; idx++) {
128
- part = parts[idx];
129
-
130
- if (part) {
131
- if (shouldBeQuoted(part)) {
132
- part = '"' + part + '"';
133
- }
134
-
135
- isBracket = isQuoted(part);
136
- isArray = !isBracket && /^\d+$/.test(part);
137
-
138
- iter.call(thisArg, part, isBracket, isArray, idx, parts);
139
- }
140
- }
141
- }
142
-
143
- function isQuoted(str) {
144
- return (
145
- typeof str === 'string' && str && ["'", '"'].indexOf(str.charAt(0)) !== -1
146
- )
147
- }
148
-
149
- function hasLeadingNumber(part) {
150
- return part.match(LEAD_DIGIT_REGEX) && !part.match(DIGIT_REGEX)
151
- }
152
-
153
- function hasSpecialChars(part) {
154
- return SPEC_CHAR_REGEX.test(part)
155
- }
156
-
157
- function shouldBeQuoted(part) {
158
- return !isQuoted(part) && (hasLeadingNumber(part) || hasSpecialChars(part))
159
- }
160
-
161
- const reWords = /[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g;
162
-
163
- const words = (str) => str.match(reWords) || [];
164
-
165
- const upperFirst = (str) => str[0].toUpperCase() + str.slice(1);
166
-
167
- const join = (str, d) => words(str).join(d).toLowerCase();
168
-
169
- const camelCase = (str) =>
170
- words(str).reduce(
171
- (acc, next) =>
172
- `${acc}${
173
- !acc
174
- ? next.toLowerCase()
175
- : next[0].toUpperCase() + next.slice(1).toLowerCase()
176
- }`,
177
- '',
178
- );
179
-
180
- const pascalCase = (str) => upperFirst(camelCase(str));
181
-
182
- const snakeCase = (str) => join(str, '_');
183
-
184
- const kebabCase = (str) => join(str, '-');
185
-
186
- const sentenceCase = (str) => upperFirst(join(str, ' '));
187
-
188
- const titleCase = (str) => words(str).map(upperFirst).join(' ');
189
-
190
- var tinyCase = {
191
- words,
192
- upperFirst,
193
- camelCase,
194
- pascalCase,
195
- snakeCase,
196
- kebabCase,
197
- sentenceCase,
198
- titleCase,
199
- };
200
-
201
- /**
202
- * Topological sorting function
203
- *
204
- * @param {Array} edges
205
- * @returns {Array}
206
- */
207
-
208
- var toposort_1 = function(edges) {
209
- return toposort(uniqueNodes(edges), edges)
210
- };
211
-
212
- var array$1 = toposort;
213
-
214
- function toposort(nodes, edges) {
215
- var cursor = nodes.length
216
- , sorted = new Array(cursor)
217
- , visited = {}
218
- , i = cursor
219
- // Better data structures make algorithm much faster.
220
- , outgoingEdges = makeOutgoingEdges(edges)
221
- , nodesHash = makeNodesHash(nodes);
222
-
223
- // check for unknown nodes
224
- edges.forEach(function(edge) {
225
- if (!nodesHash.has(edge[0]) || !nodesHash.has(edge[1])) {
226
- throw new Error('Unknown node. There is an unknown node in the supplied edges.')
227
- }
228
- });
229
-
230
- while (i--) {
231
- if (!visited[i]) visit(nodes[i], i, new Set());
232
- }
233
-
234
- return sorted
235
-
236
- function visit(node, i, predecessors) {
237
- if(predecessors.has(node)) {
238
- var nodeRep;
239
- try {
240
- nodeRep = ", node was:" + JSON.stringify(node);
241
- } catch(e) {
242
- nodeRep = "";
243
- }
244
- throw new Error('Cyclic dependency' + nodeRep)
245
- }
246
-
247
- if (!nodesHash.has(node)) {
248
- throw new Error('Found unknown node. Make sure to provided all involved nodes. Unknown node: '+JSON.stringify(node))
249
- }
250
-
251
- if (visited[i]) return;
252
- visited[i] = true;
253
-
254
- var outgoing = outgoingEdges.get(node) || new Set();
255
- outgoing = Array.from(outgoing);
256
-
257
- if (i = outgoing.length) {
258
- predecessors.add(node);
259
- do {
260
- var child = outgoing[--i];
261
- visit(child, nodesHash.get(child), predecessors);
262
- } while (i)
263
- predecessors.delete(node);
264
- }
265
-
266
- sorted[--cursor] = node;
267
- }
268
- }
269
-
270
- function uniqueNodes(arr){
271
- var res = new Set();
272
- for (var i = 0, len = arr.length; i < len; i++) {
273
- var edge = arr[i];
274
- res.add(edge[0]);
275
- res.add(edge[1]);
276
- }
277
- return Array.from(res)
278
- }
279
-
280
- function makeOutgoingEdges(arr){
281
- var edges = new Map();
282
- for (var i = 0, len = arr.length; i < len; i++) {
283
- var edge = arr[i];
284
- if (!edges.has(edge[0])) edges.set(edge[0], new Set());
285
- if (!edges.has(edge[1])) edges.set(edge[1], new Set());
286
- edges.get(edge[0]).add(edge[1]);
287
- }
288
- return edges
289
- }
290
-
291
- function makeNodesHash(arr){
292
- var res = new Map();
293
- for (var i = 0, len = arr.length; i < len; i++) {
294
- res.set(arr[i], i);
295
- }
296
- return res
297
- }
298
- toposort_1.array = array$1;
299
-
300
- const toString = Object.prototype.toString;
301
- const errorToString = Error.prototype.toString;
302
- const regExpToString = RegExp.prototype.toString;
303
- const symbolToString = typeof Symbol !== 'undefined' ? Symbol.prototype.toString : () => '';
304
- const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
305
- function printNumber(val) {
306
- if (val != +val) return 'NaN';
307
- const isNegativeZero = val === 0 && 1 / val < 0;
308
- return isNegativeZero ? '-0' : '' + val;
309
- }
310
- function printSimpleValue(val, quoteStrings = false) {
311
- if (val == null || val === true || val === false) return '' + val;
312
- const typeOf = typeof val;
313
- if (typeOf === 'number') return printNumber(val);
314
- if (typeOf === 'string') return quoteStrings ? `"${val}"` : val;
315
- if (typeOf === 'function') return '[Function ' + (val.name || 'anonymous') + ']';
316
- if (typeOf === 'symbol') return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
317
- const tag = toString.call(val).slice(8, -1);
318
- if (tag === 'Date') return isNaN(val.getTime()) ? '' + val : val.toISOString(val);
319
- if (tag === 'Error' || val instanceof Error) return '[' + errorToString.call(val) + ']';
320
- if (tag === 'RegExp') return regExpToString.call(val);
321
- return null;
322
- }
323
- function printValue(value, quoteStrings) {
324
- let result = printSimpleValue(value, quoteStrings);
325
- if (result !== null) return result;
326
- return JSON.stringify(value, function (key, value) {
327
- let result = printSimpleValue(this[key], quoteStrings);
328
- if (result !== null) return result;
329
- return value;
330
- }, 2);
331
- }
332
-
333
- function toArray(value) {
334
- return value == null ? [] : [].concat(value);
335
- }
336
-
337
- let strReg = /\$\{\s*(\w+)\s*\}/g;
338
- class ValidationError extends Error {
339
- static formatError(message, params) {
340
- const path = params.label || params.path || 'this';
341
- if (path !== params.path) params = Object.assign({}, params, {
342
- path
343
- });
344
- if (typeof message === 'string') return message.replace(strReg, (_, key) => printValue(params[key]));
345
- if (typeof message === 'function') return message(params);
346
- return message;
347
- }
348
- static isError(err) {
349
- return err && err.name === 'ValidationError';
350
- }
351
- constructor(errorOrErrors, value, field, type) {
352
- super();
353
- this.value = void 0;
354
- this.path = void 0;
355
- this.type = void 0;
356
- this.errors = void 0;
357
- this.params = void 0;
358
- this.inner = void 0;
359
- this.name = 'ValidationError';
360
- this.value = value;
361
- this.path = field;
362
- this.type = type;
363
- this.errors = [];
364
- this.inner = [];
365
- toArray(errorOrErrors).forEach(err => {
366
- if (ValidationError.isError(err)) {
367
- this.errors.push(...err.errors);
368
- this.inner = this.inner.concat(err.inner.length ? err.inner : err);
369
- } else {
370
- this.errors.push(err);
371
- }
372
- });
373
- this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0];
374
- if (Error.captureStackTrace) Error.captureStackTrace(this, ValidationError);
375
- }
376
- }
377
-
378
- let mixed = {
379
- default: '${path} is invalid',
380
- required: '${path} is a required field',
381
- defined: '${path} must be defined',
382
- notNull: '${path} cannot be null',
383
- oneOf: '${path} must be one of the following values: ${values}',
384
- notOneOf: '${path} must not be one of the following values: ${values}',
385
- notType: ({
386
- path,
387
- type,
388
- value,
389
- originalValue
390
- }) => {
391
- const castMsg = originalValue != null && originalValue !== value ? ` (cast from the value \`${printValue(originalValue, true)}\`).` : '.';
392
- return type !== 'mixed' ? `${path} must be a \`${type}\` type, ` + `but the final value was: \`${printValue(value, true)}\`` + castMsg : `${path} must match the configured type. ` + `The validated value was: \`${printValue(value, true)}\`` + castMsg;
393
- }
394
- };
395
- let string = {
396
- length: '${path} must be exactly ${length} characters',
397
- min: '${path} must be at least ${min} characters',
398
- max: '${path} must be at most ${max} characters',
399
- matches: '${path} must match the following: "${regex}"',
400
- email: '${path} must be a valid email',
401
- url: '${path} must be a valid URL',
402
- uuid: '${path} must be a valid UUID',
403
- trim: '${path} must be a trimmed string',
404
- lowercase: '${path} must be a lowercase string',
405
- uppercase: '${path} must be a upper case string'
406
- };
407
- let number = {
408
- min: '${path} must be greater than or equal to ${min}',
409
- max: '${path} must be less than or equal to ${max}',
410
- lessThan: '${path} must be less than ${less}',
411
- moreThan: '${path} must be greater than ${more}',
412
- positive: '${path} must be a positive number',
413
- negative: '${path} must be a negative number',
414
- integer: '${path} must be an integer'
415
- };
416
- let date = {
417
- min: '${path} field must be later than ${min}',
418
- max: '${path} field must be at earlier than ${max}'
419
- };
420
- let boolean = {
421
- isValue: '${path} field must be ${value}'
422
- };
423
- let object = {
424
- noUnknown: '${path} field has unspecified keys: ${unknown}'
425
- };
426
- let array = {
427
- min: '${path} field must have at least ${min} items',
428
- max: '${path} field must have less than or equal to ${max} items',
429
- length: '${path} must have ${length} items'
430
- };
431
- Object.assign(Object.create(null), {
432
- mixed,
433
- string,
434
- number,
435
- date,
436
- object,
437
- array,
438
- boolean
439
- });
440
-
441
- const isSchema = obj => obj && obj.__isYupSchema__;
442
-
443
- class Condition {
444
- static fromOptions(refs, config) {
445
- if (!config.then && !config.otherwise) throw new TypeError('either `then:` or `otherwise:` is required for `when()` conditions');
446
- let {
447
- is,
448
- then,
449
- otherwise
450
- } = config;
451
- let check = typeof is === 'function' ? is : (...values) => values.every(value => value === is);
452
- return new Condition(refs, (values, schema) => {
453
- var _branch;
454
- let branch = check(...values) ? then : otherwise;
455
- return (_branch = branch == null ? void 0 : branch(schema)) != null ? _branch : schema;
456
- });
457
- }
458
- constructor(refs, builder) {
459
- this.fn = void 0;
460
- this.refs = refs;
461
- this.refs = refs;
462
- this.fn = builder;
463
- }
464
- resolve(base, options) {
465
- let values = this.refs.map(ref =>
466
- // TODO: ? operator here?
467
- ref.getValue(options == null ? void 0 : options.value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context));
468
- let schema = this.fn(values, base, options);
469
- if (schema === undefined ||
470
- // @ts-ignore this can be base
471
- schema === base) {
472
- return base;
473
- }
474
- if (!isSchema(schema)) throw new TypeError('conditions must return a schema object');
475
- return schema.resolve(options);
476
- }
477
- }
478
-
479
- const prefixes = {
480
- context: '$',
481
- value: '.'
482
- };
483
- class Reference {
484
- constructor(key, options = {}) {
485
- this.key = void 0;
486
- this.isContext = void 0;
487
- this.isValue = void 0;
488
- this.isSibling = void 0;
489
- this.path = void 0;
490
- this.getter = void 0;
491
- this.map = void 0;
492
- if (typeof key !== 'string') throw new TypeError('ref must be a string, got: ' + key);
493
- this.key = key.trim();
494
- if (key === '') throw new TypeError('ref must be a non-empty string');
495
- this.isContext = this.key[0] === prefixes.context;
496
- this.isValue = this.key[0] === prefixes.value;
497
- this.isSibling = !this.isContext && !this.isValue;
498
- let prefix = this.isContext ? prefixes.context : this.isValue ? prefixes.value : '';
499
- this.path = this.key.slice(prefix.length);
500
- this.getter = this.path && propertyExpr.getter(this.path, true);
501
- this.map = options.map;
502
- }
503
- getValue(value, parent, context) {
504
- let result = this.isContext ? context : this.isValue ? value : parent;
505
- if (this.getter) result = this.getter(result || {});
506
- if (this.map) result = this.map(result);
507
- return result;
508
- }
509
-
510
- /**
511
- *
512
- * @param {*} value
513
- * @param {Object} options
514
- * @param {Object=} options.context
515
- * @param {Object=} options.parent
516
- */
517
- cast(value, options) {
518
- return this.getValue(value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context);
519
- }
520
- resolve() {
521
- return this;
522
- }
523
- describe() {
524
- return {
525
- type: 'ref',
526
- key: this.key
527
- };
528
- }
529
- toString() {
530
- return `Ref(${this.key})`;
531
- }
532
- static isRef(value) {
533
- return value && value.__isYupRef;
534
- }
535
- }
536
-
537
- // @ts-ignore
538
- Reference.prototype.__isYupRef = true;
539
-
540
- const isAbsent = value => value == null;
541
-
542
- function createValidation(config) {
543
- function validate({
544
- value,
545
- path = '',
546
- options,
547
- originalValue,
548
- schema
549
- }, panic, next) {
550
- const {
551
- name,
552
- test,
553
- params,
554
- message,
555
- skipAbsent
556
- } = config;
557
- let {
558
- parent,
559
- context,
560
- abortEarly = schema.spec.abortEarly
561
- } = options;
562
- function resolve(item) {
563
- return Reference.isRef(item) ? item.getValue(value, parent, context) : item;
564
- }
565
- function createError(overrides = {}) {
566
- const nextParams = Object.assign({
567
- value,
568
- originalValue,
569
- label: schema.spec.label,
570
- path: overrides.path || path,
571
- spec: schema.spec
572
- }, params, overrides.params);
573
- for (const key of Object.keys(nextParams)) nextParams[key] = resolve(nextParams[key]);
574
- const error = new ValidationError(ValidationError.formatError(overrides.message || message, nextParams), value, nextParams.path, overrides.type || name);
575
- error.params = nextParams;
576
- return error;
577
- }
578
- const invalid = abortEarly ? panic : next;
579
- let ctx = {
580
- path,
581
- parent,
582
- type: name,
583
- from: options.from,
584
- createError,
585
- resolve,
586
- options,
587
- originalValue,
588
- schema
589
- };
590
- const handleResult = validOrError => {
591
- if (ValidationError.isError(validOrError)) invalid(validOrError);else if (!validOrError) invalid(createError());else next(null);
592
- };
593
- const handleError = err => {
594
- if (ValidationError.isError(err)) invalid(err);else panic(err);
595
- };
596
- const shouldSkip = skipAbsent && isAbsent(value);
597
- if (!options.sync) {
598
- try {
599
- Promise.resolve(!shouldSkip ? test.call(ctx, value, ctx) : true).then(handleResult, handleError);
600
- } catch (err) {
601
- handleError(err);
602
- }
603
- return;
604
- }
605
- let result;
606
- try {
607
- var _result;
608
- result = !shouldSkip ? test.call(ctx, value, ctx) : true;
609
- if (typeof ((_result = result) == null ? void 0 : _result.then) === 'function') {
610
- throw new Error(`Validation test of type: "${ctx.type}" returned a Promise during a synchronous validate. ` + `This test will finish after the validate call has returned`);
611
- }
612
- } catch (err) {
613
- handleError(err);
614
- return;
615
- }
616
- handleResult(result);
617
- }
618
- validate.OPTIONS = config;
619
- return validate;
620
- }
621
-
622
- function getIn(schema, path, value, context = value) {
623
- let parent, lastPart, lastPartDebug;
624
-
625
- // root path: ''
626
- if (!path) return {
627
- parent,
628
- parentPath: path,
629
- schema
630
- };
631
- propertyExpr.forEach(path, (_part, isBracket, isArray) => {
632
- let part = isBracket ? _part.slice(1, _part.length - 1) : _part;
633
- schema = schema.resolve({
634
- context,
635
- parent,
636
- value
637
- });
638
- let isTuple = schema.type === 'tuple';
639
- let idx = isArray ? parseInt(part, 10) : 0;
640
- if (schema.innerType || isTuple) {
641
- if (isTuple && !isArray) throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${lastPartDebug}" must contain an index to the tuple element, e.g. "${lastPartDebug}[0]"`);
642
- if (value && idx >= value.length) {
643
- throw new Error(`Yup.reach cannot resolve an array item at index: ${_part}, in the path: ${path}. ` + `because there is no value at that index. `);
644
- }
645
- parent = value;
646
- value = value && value[idx];
647
- schema = isTuple ? schema.spec.types[idx] : schema.innerType;
648
- }
649
-
650
- // sometimes the array index part of a path doesn't exist: "nested.arr.child"
651
- // in these cases the current part is the next schema and should be processed
652
- // in this iteration. For cases where the index signature is included this
653
- // check will fail and we'll handle the `child` part on the next iteration like normal
654
- if (!isArray) {
655
- if (!schema.fields || !schema.fields[part]) throw new Error(`The schema does not contain the path: ${path}. ` + `(failed at: ${lastPartDebug} which is a type: "${schema.type}")`);
656
- parent = value;
657
- value = value && value[part];
658
- schema = schema.fields[part];
659
- }
660
- lastPart = part;
661
- lastPartDebug = isBracket ? '[' + _part + ']' : '.' + _part;
662
- });
663
- return {
664
- schema,
665
- parent,
666
- parentPath: lastPart
667
- };
668
- }
669
-
670
- class ReferenceSet extends Set {
671
- describe() {
672
- const description = [];
673
- for (const item of this.values()) {
674
- description.push(Reference.isRef(item) ? item.describe() : item);
675
- }
676
- return description;
677
- }
678
- resolveAll(resolve) {
679
- let result = [];
680
- for (const item of this.values()) {
681
- result.push(resolve(item));
682
- }
683
- return result;
684
- }
685
- clone() {
686
- return new ReferenceSet(this.values());
687
- }
688
- merge(newItems, removeItems) {
689
- const next = this.clone();
690
- newItems.forEach(value => next.add(value));
691
- removeItems.forEach(value => next.delete(value));
692
- return next;
693
- }
694
- }
695
-
696
- // tweaked from https://github.com/Kelin2025/nanoclone/blob/0abeb7635bda9b68ef2277093f76dbe3bf3948e1/src/index.js
697
- function clone(src, seen = new Map()) {
698
- if (isSchema(src) || !src || typeof src !== 'object') return src;
699
- if (seen.has(src)) return seen.get(src);
700
- let copy;
701
- if (src instanceof Date) {
702
- // Date
703
- copy = new Date(src.getTime());
704
- seen.set(src, copy);
705
- } else if (src instanceof RegExp) {
706
- // RegExp
707
- copy = new RegExp(src);
708
- seen.set(src, copy);
709
- } else if (Array.isArray(src)) {
710
- // Array
711
- copy = new Array(src.length);
712
- seen.set(src, copy);
713
- for (let i = 0; i < src.length; i++) copy[i] = clone(src[i], seen);
714
- } else if (src instanceof Map) {
715
- // Map
716
- copy = new Map();
717
- seen.set(src, copy);
718
- for (const [k, v] of src.entries()) copy.set(k, clone(v, seen));
719
- } else if (src instanceof Set) {
720
- // Set
721
- copy = new Set();
722
- seen.set(src, copy);
723
- for (const v of src) copy.add(clone(v, seen));
724
- } else if (src instanceof Object) {
725
- // Object
726
- copy = {};
727
- seen.set(src, copy);
728
- for (const [k, v] of Object.entries(src)) copy[k] = clone(v, seen);
729
- } else {
730
- throw Error(`Unable to clone ${src}`);
731
- }
732
- return copy;
733
- }
734
-
735
- class Schema {
736
- constructor(options) {
737
- this.type = void 0;
738
- this.deps = [];
739
- this.tests = void 0;
740
- this.transforms = void 0;
741
- this.conditions = [];
742
- this._mutate = void 0;
743
- this.internalTests = {};
744
- this._whitelist = new ReferenceSet();
745
- this._blacklist = new ReferenceSet();
746
- this.exclusiveTests = Object.create(null);
747
- this._typeCheck = void 0;
748
- this.spec = void 0;
749
- this.tests = [];
750
- this.transforms = [];
751
- this.withMutation(() => {
752
- this.typeError(mixed.notType);
753
- });
754
- this.type = options.type;
755
- this._typeCheck = options.check;
756
- this.spec = Object.assign({
757
- strip: false,
758
- strict: false,
759
- abortEarly: true,
760
- recursive: true,
761
- nullable: false,
762
- optional: true,
763
- coerce: true
764
- }, options == null ? void 0 : options.spec);
765
- this.withMutation(s => {
766
- s.nonNullable();
767
- });
768
- }
769
-
770
- // TODO: remove
771
- get _type() {
772
- return this.type;
773
- }
774
- clone(spec) {
775
- if (this._mutate) {
776
- if (spec) Object.assign(this.spec, spec);
777
- return this;
778
- }
779
-
780
- // if the nested value is a schema we can skip cloning, since
781
- // they are already immutable
782
- const next = Object.create(Object.getPrototypeOf(this));
783
-
784
- // @ts-expect-error this is readonly
785
- next.type = this.type;
786
- next._typeCheck = this._typeCheck;
787
- next._whitelist = this._whitelist.clone();
788
- next._blacklist = this._blacklist.clone();
789
- next.internalTests = Object.assign({}, this.internalTests);
790
- next.exclusiveTests = Object.assign({}, this.exclusiveTests);
791
-
792
- // @ts-expect-error this is readonly
793
- next.deps = [...this.deps];
794
- next.conditions = [...this.conditions];
795
- next.tests = [...this.tests];
796
- next.transforms = [...this.transforms];
797
- next.spec = clone(Object.assign({}, this.spec, spec));
798
- return next;
799
- }
800
- label(label) {
801
- let next = this.clone();
802
- next.spec.label = label;
803
- return next;
804
- }
805
- meta(...args) {
806
- if (args.length === 0) return this.spec.meta;
807
- let next = this.clone();
808
- next.spec.meta = Object.assign(next.spec.meta || {}, args[0]);
809
- return next;
810
- }
811
- withMutation(fn) {
812
- let before = this._mutate;
813
- this._mutate = true;
814
- let result = fn(this);
815
- this._mutate = before;
816
- return result;
817
- }
818
- concat(schema) {
819
- if (!schema || schema === this) return this;
820
- if (schema.type !== this.type && this.type !== 'mixed') throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${schema.type}`);
821
- let base = this;
822
- let combined = schema.clone();
823
- const mergedSpec = Object.assign({}, base.spec, combined.spec);
824
- combined.spec = mergedSpec;
825
- combined.internalTests = Object.assign({}, base.internalTests, combined.internalTests);
826
-
827
- // manually merge the blacklist/whitelist (the other `schema` takes
828
- // precedence in case of conflicts)
829
- combined._whitelist = base._whitelist.merge(schema._whitelist, schema._blacklist);
830
- combined._blacklist = base._blacklist.merge(schema._blacklist, schema._whitelist);
831
-
832
- // start with the current tests
833
- combined.tests = base.tests;
834
- combined.exclusiveTests = base.exclusiveTests;
835
-
836
- // manually add the new tests to ensure
837
- // the deduping logic is consistent
838
- combined.withMutation(next => {
839
- schema.tests.forEach(fn => {
840
- next.test(fn.OPTIONS);
841
- });
842
- });
843
- combined.transforms = [...base.transforms, ...combined.transforms];
844
- return combined;
845
- }
846
- isType(v) {
847
- if (v == null) {
848
- if (this.spec.nullable && v === null) return true;
849
- if (this.spec.optional && v === undefined) return true;
850
- return false;
851
- }
852
- return this._typeCheck(v);
853
- }
854
- resolve(options) {
855
- let schema = this;
856
- if (schema.conditions.length) {
857
- let conditions = schema.conditions;
858
- schema = schema.clone();
859
- schema.conditions = [];
860
- schema = conditions.reduce((prevSchema, condition) => condition.resolve(prevSchema, options), schema);
861
- schema = schema.resolve(options);
862
- }
863
- return schema;
864
- }
865
- resolveOptions(options) {
866
- var _options$strict, _options$abortEarly, _options$recursive;
867
- return Object.assign({}, options, {
868
- from: options.from || [],
869
- strict: (_options$strict = options.strict) != null ? _options$strict : this.spec.strict,
870
- abortEarly: (_options$abortEarly = options.abortEarly) != null ? _options$abortEarly : this.spec.abortEarly,
871
- recursive: (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive
872
- });
873
- }
874
-
875
- /**
876
- * Run the configured transform pipeline over an input value.
877
- */
878
-
879
- cast(value, options = {}) {
880
- let resolvedSchema = this.resolve(Object.assign({
881
- value
882
- }, options));
883
- let allowOptionality = options.assert === 'ignore-optionality';
884
- let result = resolvedSchema._cast(value, options);
885
- if (options.assert !== false && !resolvedSchema.isType(result)) {
886
- if (allowOptionality && isAbsent(result)) {
887
- return result;
888
- }
889
- let formattedValue = printValue(value);
890
- let formattedResult = printValue(result);
891
- throw new TypeError(`The value of ${options.path || 'field'} could not be cast to a value ` + `that satisfies the schema type: "${resolvedSchema.type}". \n\n` + `attempted value: ${formattedValue} \n` + (formattedResult !== formattedValue ? `result of cast: ${formattedResult}` : ''));
892
- }
893
- return result;
894
- }
895
- _cast(rawValue, _options) {
896
- let value = rawValue === undefined ? rawValue : this.transforms.reduce((prevValue, fn) => fn.call(this, prevValue, rawValue, this), rawValue);
897
- if (value === undefined) {
898
- value = this.getDefault();
899
- }
900
- return value;
901
- }
902
- _validate(_value, options = {}, panic, next) {
903
- let {
904
- path,
905
- originalValue = _value,
906
- strict = this.spec.strict
907
- } = options;
908
- let value = _value;
909
- if (!strict) {
910
- value = this._cast(value, Object.assign({
911
- assert: false
912
- }, options));
913
- }
914
- let initialTests = [];
915
- for (let test of Object.values(this.internalTests)) {
916
- if (test) initialTests.push(test);
917
- }
918
- this.runTests({
919
- path,
920
- value,
921
- originalValue,
922
- options,
923
- tests: initialTests
924
- }, panic, initialErrors => {
925
- // even if we aren't ending early we can't proceed further if the types aren't correct
926
- if (initialErrors.length) {
927
- return next(initialErrors, value);
928
- }
929
- this.runTests({
930
- path,
931
- value,
932
- originalValue,
933
- options,
934
- tests: this.tests
935
- }, panic, next);
936
- });
937
- }
938
-
939
- /**
940
- * Executes a set of validations, either schema, produced Tests or a nested
941
- * schema validate result.
942
- */
943
- runTests(runOptions, panic, next) {
944
- let fired = false;
945
- let {
946
- tests,
947
- value,
948
- originalValue,
949
- path,
950
- options
951
- } = runOptions;
952
- let panicOnce = arg => {
953
- if (fired) return;
954
- fired = true;
955
- panic(arg, value);
956
- };
957
- let nextOnce = arg => {
958
- if (fired) return;
959
- fired = true;
960
- next(arg, value);
961
- };
962
- let count = tests.length;
963
- let nestedErrors = [];
964
- if (!count) return nextOnce([]);
965
- let args = {
966
- value,
967
- originalValue,
968
- path,
969
- options,
970
- schema: this
971
- };
972
- for (let i = 0; i < tests.length; i++) {
973
- const test = tests[i];
974
- test(args, panicOnce, function finishTestRun(err) {
975
- if (err) {
976
- nestedErrors = nestedErrors.concat(err);
977
- }
978
- if (--count <= 0) {
979
- nextOnce(nestedErrors);
980
- }
981
- });
982
- }
983
- }
984
- asNestedTest({
985
- key,
986
- index,
987
- parent,
988
- parentPath,
989
- originalParent,
990
- options
991
- }) {
992
- const k = key != null ? key : index;
993
- if (k == null) {
994
- throw TypeError('Must include `key` or `index` for nested validations');
995
- }
996
- const isIndex = typeof k === 'number';
997
- let value = parent[k];
998
- const testOptions = Object.assign({}, options, {
999
- // Nested validations fields are always strict:
1000
- // 1. parent isn't strict so the casting will also have cast inner values
1001
- // 2. parent is strict in which case the nested values weren't cast either
1002
- strict: true,
1003
- parent,
1004
- value,
1005
- originalValue: originalParent[k],
1006
- // FIXME: tests depend on `index` being passed around deeply,
1007
- // we should not let the options.key/index bleed through
1008
- key: undefined,
1009
- // index: undefined,
1010
- [isIndex ? 'index' : 'key']: k,
1011
- path: isIndex || k.includes('.') ? `${parentPath || ''}[${value ? k : `"${k}"`}]` : (parentPath ? `${parentPath}.` : '') + key
1012
- });
1013
- return (_, panic, next) => this.resolve(testOptions)._validate(value, testOptions, panic, next);
1014
- }
1015
- validate(value, options) {
1016
- let schema = this.resolve(Object.assign({}, options, {
1017
- value
1018
- }));
1019
- return new Promise((resolve, reject) => schema._validate(value, options, (error, parsed) => {
1020
- if (ValidationError.isError(error)) error.value = parsed;
1021
- reject(error);
1022
- }, (errors, validated) => {
1023
- if (errors.length) reject(new ValidationError(errors, validated));else resolve(validated);
1024
- }));
1025
- }
1026
- validateSync(value, options) {
1027
- let schema = this.resolve(Object.assign({}, options, {
1028
- value
1029
- }));
1030
- let result;
1031
- schema._validate(value, Object.assign({}, options, {
1032
- sync: true
1033
- }), (error, parsed) => {
1034
- if (ValidationError.isError(error)) error.value = parsed;
1035
- throw error;
1036
- }, (errors, validated) => {
1037
- if (errors.length) throw new ValidationError(errors, value);
1038
- result = validated;
1039
- });
1040
- return result;
1041
- }
1042
- isValid(value, options) {
1043
- return this.validate(value, options).then(() => true, err => {
1044
- if (ValidationError.isError(err)) return false;
1045
- throw err;
1046
- });
1047
- }
1048
- isValidSync(value, options) {
1049
- try {
1050
- this.validateSync(value, options);
1051
- return true;
1052
- } catch (err) {
1053
- if (ValidationError.isError(err)) return false;
1054
- throw err;
1055
- }
1056
- }
1057
- _getDefault() {
1058
- let defaultValue = this.spec.default;
1059
- if (defaultValue == null) {
1060
- return defaultValue;
1061
- }
1062
- return typeof defaultValue === 'function' ? defaultValue.call(this) : clone(defaultValue);
1063
- }
1064
- getDefault(options
1065
- // If schema is defaulted we know it's at least not undefined
1066
- ) {
1067
- let schema = this.resolve(options || {});
1068
- return schema._getDefault();
1069
- }
1070
- default(def) {
1071
- if (arguments.length === 0) {
1072
- return this._getDefault();
1073
- }
1074
- let next = this.clone({
1075
- default: def
1076
- });
1077
- return next;
1078
- }
1079
- strict(isStrict = true) {
1080
- return this.clone({
1081
- strict: isStrict
1082
- });
1083
- }
1084
- nullability(nullable, message) {
1085
- const next = this.clone({
1086
- nullable
1087
- });
1088
- next.internalTests.nullable = createValidation({
1089
- message,
1090
- name: 'nullable',
1091
- test(value) {
1092
- return value === null ? this.schema.spec.nullable : true;
1093
- }
1094
- });
1095
- return next;
1096
- }
1097
- optionality(optional, message) {
1098
- const next = this.clone({
1099
- optional
1100
- });
1101
- next.internalTests.optionality = createValidation({
1102
- message,
1103
- name: 'optionality',
1104
- test(value) {
1105
- return value === undefined ? this.schema.spec.optional : true;
1106
- }
1107
- });
1108
- return next;
1109
- }
1110
- optional() {
1111
- return this.optionality(true);
1112
- }
1113
- defined(message = mixed.defined) {
1114
- return this.optionality(false, message);
1115
- }
1116
- nullable() {
1117
- return this.nullability(true);
1118
- }
1119
- nonNullable(message = mixed.notNull) {
1120
- return this.nullability(false, message);
1121
- }
1122
- required(message = mixed.required) {
1123
- return this.clone().withMutation(next => next.nonNullable(message).defined(message));
1124
- }
1125
- notRequired() {
1126
- return this.clone().withMutation(next => next.nullable().optional());
1127
- }
1128
- transform(fn) {
1129
- let next = this.clone();
1130
- next.transforms.push(fn);
1131
- return next;
1132
- }
1133
-
1134
- /**
1135
- * Adds a test function to the schema's queue of tests.
1136
- * tests can be exclusive or non-exclusive.
1137
- *
1138
- * - exclusive tests, will replace any existing tests of the same name.
1139
- * - non-exclusive: can be stacked
1140
- *
1141
- * If a non-exclusive test is added to a schema with an exclusive test of the same name
1142
- * the exclusive test is removed and further tests of the same name will be stacked.
1143
- *
1144
- * If an exclusive test is added to a schema with non-exclusive tests of the same name
1145
- * the previous tests are removed and further tests of the same name will replace each other.
1146
- */
1147
-
1148
- test(...args) {
1149
- let opts;
1150
- if (args.length === 1) {
1151
- if (typeof args[0] === 'function') {
1152
- opts = {
1153
- test: args[0]
1154
- };
1155
- } else {
1156
- opts = args[0];
1157
- }
1158
- } else if (args.length === 2) {
1159
- opts = {
1160
- name: args[0],
1161
- test: args[1]
1162
- };
1163
- } else {
1164
- opts = {
1165
- name: args[0],
1166
- message: args[1],
1167
- test: args[2]
1168
- };
1169
- }
1170
- if (opts.message === undefined) opts.message = mixed.default;
1171
- if (typeof opts.test !== 'function') throw new TypeError('`test` is a required parameters');
1172
- let next = this.clone();
1173
- let validate = createValidation(opts);
1174
- let isExclusive = opts.exclusive || opts.name && next.exclusiveTests[opts.name] === true;
1175
- if (opts.exclusive) {
1176
- if (!opts.name) throw new TypeError('Exclusive tests must provide a unique `name` identifying the test');
1177
- }
1178
- if (opts.name) next.exclusiveTests[opts.name] = !!opts.exclusive;
1179
- next.tests = next.tests.filter(fn => {
1180
- if (fn.OPTIONS.name === opts.name) {
1181
- if (isExclusive) return false;
1182
- if (fn.OPTIONS.test === validate.OPTIONS.test) return false;
1183
- }
1184
- return true;
1185
- });
1186
- next.tests.push(validate);
1187
- return next;
1188
- }
1189
- when(keys, options) {
1190
- if (!Array.isArray(keys) && typeof keys !== 'string') {
1191
- options = keys;
1192
- keys = '.';
1193
- }
1194
- let next = this.clone();
1195
- let deps = toArray(keys).map(key => new Reference(key));
1196
- deps.forEach(dep => {
1197
- // @ts-ignore readonly array
1198
- if (dep.isSibling) next.deps.push(dep.key);
1199
- });
1200
- next.conditions.push(typeof options === 'function' ? new Condition(deps, options) : Condition.fromOptions(deps, options));
1201
- return next;
1202
- }
1203
- typeError(message) {
1204
- let next = this.clone();
1205
- next.internalTests.typeError = createValidation({
1206
- message,
1207
- name: 'typeError',
1208
- test(value) {
1209
- if (!isAbsent(value) && !this.schema._typeCheck(value)) return this.createError({
1210
- params: {
1211
- type: this.schema.type
1212
- }
1213
- });
1214
- return true;
1215
- }
1216
- });
1217
- return next;
1218
- }
1219
- oneOf(enums, message = mixed.oneOf) {
1220
- let next = this.clone();
1221
- enums.forEach(val => {
1222
- next._whitelist.add(val);
1223
- next._blacklist.delete(val);
1224
- });
1225
- next.internalTests.whiteList = createValidation({
1226
- message,
1227
- name: 'oneOf',
1228
- skipAbsent: true,
1229
- test(value) {
1230
- let valids = this.schema._whitelist;
1231
- let resolved = valids.resolveAll(this.resolve);
1232
- return resolved.includes(value) ? true : this.createError({
1233
- params: {
1234
- values: Array.from(valids).join(', '),
1235
- resolved
1236
- }
1237
- });
1238
- }
1239
- });
1240
- return next;
1241
- }
1242
- notOneOf(enums, message = mixed.notOneOf) {
1243
- let next = this.clone();
1244
- enums.forEach(val => {
1245
- next._blacklist.add(val);
1246
- next._whitelist.delete(val);
1247
- });
1248
- next.internalTests.blacklist = createValidation({
1249
- message,
1250
- name: 'notOneOf',
1251
- test(value) {
1252
- let invalids = this.schema._blacklist;
1253
- let resolved = invalids.resolveAll(this.resolve);
1254
- if (resolved.includes(value)) return this.createError({
1255
- params: {
1256
- values: Array.from(invalids).join(', '),
1257
- resolved
1258
- }
1259
- });
1260
- return true;
1261
- }
1262
- });
1263
- return next;
1264
- }
1265
- strip(strip = true) {
1266
- let next = this.clone();
1267
- next.spec.strip = strip;
1268
- return next;
1269
- }
1270
-
1271
- /**
1272
- * Return a serialized description of the schema including validations, flags, types etc.
1273
- *
1274
- * @param options Provide any needed context for resolving runtime schema alterations (lazy, when conditions, etc).
1275
- */
1276
- describe(options) {
1277
- const next = (options ? this.resolve(options) : this).clone();
1278
- const {
1279
- label,
1280
- meta,
1281
- optional,
1282
- nullable
1283
- } = next.spec;
1284
- const description = {
1285
- meta,
1286
- label,
1287
- optional,
1288
- nullable,
1289
- default: next.getDefault(options),
1290
- type: next.type,
1291
- oneOf: next._whitelist.describe(),
1292
- notOneOf: next._blacklist.describe(),
1293
- tests: next.tests.map(fn => ({
1294
- name: fn.OPTIONS.name,
1295
- params: fn.OPTIONS.params
1296
- })).filter((n, idx, list) => list.findIndex(c => c.name === n.name) === idx)
1297
- };
1298
- return description;
1299
- }
1300
- }
1301
- // @ts-expect-error
1302
- Schema.prototype.__isYupSchema__ = true;
1303
- for (const method of ['validate', 'validateSync']) Schema.prototype[`${method}At`] = function (path, value, options = {}) {
1304
- const {
1305
- parent,
1306
- parentPath,
1307
- schema
1308
- } = getIn(this, path, value, options.context);
1309
- return schema[method](parent && parent[parentPath], Object.assign({}, options, {
1310
- parent,
1311
- path
1312
- }));
1313
- };
1314
- for (const alias of ['equals', 'is']) Schema.prototype[alias] = Schema.prototype.oneOf;
1315
- for (const alias of ['not', 'nope']) Schema.prototype[alias] = Schema.prototype.notOneOf;
1316
-
1317
- // Taken from HTML spec: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
1318
- let rEmail =
1319
- // eslint-disable-next-line
1320
- /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
1321
- let rUrl =
1322
- // eslint-disable-next-line
1323
- /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;
1324
-
1325
- // eslint-disable-next-line
1326
- let rUUID = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
1327
- let isTrimmed = value => isAbsent(value) || value === value.trim();
1328
- let objStringTag = {}.toString();
1329
- function create$6() {
1330
- return new StringSchema();
1331
- }
1332
- class StringSchema extends Schema {
1333
- constructor() {
1334
- super({
1335
- type: 'string',
1336
- check(value) {
1337
- if (value instanceof String) value = value.valueOf();
1338
- return typeof value === 'string';
1339
- }
1340
- });
1341
- this.withMutation(() => {
1342
- this.transform((value, _raw, ctx) => {
1343
- if (!ctx.spec.coerce || ctx.isType(value)) return value;
1344
-
1345
- // don't ever convert arrays
1346
- if (Array.isArray(value)) return value;
1347
- const strValue = value != null && value.toString ? value.toString() : value;
1348
-
1349
- // no one wants plain objects converted to [Object object]
1350
- if (strValue === objStringTag) return value;
1351
- return strValue;
1352
- });
1353
- });
1354
- }
1355
- required(message) {
1356
- return super.required(message).withMutation(schema => schema.test({
1357
- message: message || mixed.required,
1358
- name: 'required',
1359
- skipAbsent: true,
1360
- test: value => !!value.length
1361
- }));
1362
- }
1363
- notRequired() {
1364
- return super.notRequired().withMutation(schema => {
1365
- schema.tests = schema.tests.filter(t => t.OPTIONS.name !== 'required');
1366
- return schema;
1367
- });
1368
- }
1369
- length(length, message = string.length) {
1370
- return this.test({
1371
- message,
1372
- name: 'length',
1373
- exclusive: true,
1374
- params: {
1375
- length
1376
- },
1377
- skipAbsent: true,
1378
- test(value) {
1379
- return value.length === this.resolve(length);
1380
- }
1381
- });
1382
- }
1383
- min(min, message = string.min) {
1384
- return this.test({
1385
- message,
1386
- name: 'min',
1387
- exclusive: true,
1388
- params: {
1389
- min
1390
- },
1391
- skipAbsent: true,
1392
- test(value) {
1393
- return value.length >= this.resolve(min);
1394
- }
1395
- });
1396
- }
1397
- max(max, message = string.max) {
1398
- return this.test({
1399
- name: 'max',
1400
- exclusive: true,
1401
- message,
1402
- params: {
1403
- max
1404
- },
1405
- skipAbsent: true,
1406
- test(value) {
1407
- return value.length <= this.resolve(max);
1408
- }
1409
- });
1410
- }
1411
- matches(regex, options) {
1412
- let excludeEmptyString = false;
1413
- let message;
1414
- let name;
1415
- if (options) {
1416
- if (typeof options === 'object') {
1417
- ({
1418
- excludeEmptyString = false,
1419
- message,
1420
- name
1421
- } = options);
1422
- } else {
1423
- message = options;
1424
- }
1425
- }
1426
- return this.test({
1427
- name: name || 'matches',
1428
- message: message || string.matches,
1429
- params: {
1430
- regex
1431
- },
1432
- skipAbsent: true,
1433
- test: value => value === '' && excludeEmptyString || value.search(regex) !== -1
1434
- });
1435
- }
1436
- email(message = string.email) {
1437
- return this.matches(rEmail, {
1438
- name: 'email',
1439
- message,
1440
- excludeEmptyString: true
1441
- });
1442
- }
1443
- url(message = string.url) {
1444
- return this.matches(rUrl, {
1445
- name: 'url',
1446
- message,
1447
- excludeEmptyString: true
1448
- });
1449
- }
1450
- uuid(message = string.uuid) {
1451
- return this.matches(rUUID, {
1452
- name: 'uuid',
1453
- message,
1454
- excludeEmptyString: false
1455
- });
1456
- }
1457
-
1458
- //-- transforms --
1459
- ensure() {
1460
- return this.default('').transform(val => val === null ? '' : val);
1461
- }
1462
- trim(message = string.trim) {
1463
- return this.transform(val => val != null ? val.trim() : val).test({
1464
- message,
1465
- name: 'trim',
1466
- test: isTrimmed
1467
- });
1468
- }
1469
- lowercase(message = string.lowercase) {
1470
- return this.transform(value => !isAbsent(value) ? value.toLowerCase() : value).test({
1471
- message,
1472
- name: 'string_case',
1473
- exclusive: true,
1474
- skipAbsent: true,
1475
- test: value => isAbsent(value) || value === value.toLowerCase()
1476
- });
1477
- }
1478
- uppercase(message = string.uppercase) {
1479
- return this.transform(value => !isAbsent(value) ? value.toUpperCase() : value).test({
1480
- message,
1481
- name: 'string_case',
1482
- exclusive: true,
1483
- skipAbsent: true,
1484
- test: value => isAbsent(value) || value === value.toUpperCase()
1485
- });
1486
- }
1487
- }
1488
- create$6.prototype = StringSchema.prototype;
1489
-
1490
- // @ts-expect-error
1491
- function sortFields(fields, excludedEdges = []) {
1492
- let edges = [];
1493
- let nodes = new Set();
1494
- let excludes = new Set(excludedEdges.map(([a, b]) => `${a}-${b}`));
1495
- function addNode(depPath, key) {
1496
- let node = propertyExpr.split(depPath)[0];
1497
- nodes.add(node);
1498
- if (!excludes.has(`${key}-${node}`)) edges.push([key, node]);
1499
- }
1500
- for (const key of Object.keys(fields)) {
1501
- let value = fields[key];
1502
- nodes.add(key);
1503
- if (Reference.isRef(value) && value.isSibling) addNode(value.path, key);else if (isSchema(value) && 'deps' in value) value.deps.forEach(path => addNode(path, key));
1504
- }
1505
- return toposort_1.array(Array.from(nodes), edges).reverse();
1506
- }
1507
-
1508
- function findIndex(arr, err) {
1509
- let idx = Infinity;
1510
- arr.some((key, ii) => {
1511
- var _err$path;
1512
- if ((_err$path = err.path) != null && _err$path.includes(key)) {
1513
- idx = ii;
1514
- return true;
1515
- }
1516
- });
1517
- return idx;
1518
- }
1519
- function sortByKeyOrder(keys) {
1520
- return (a, b) => {
1521
- return findIndex(keys, a) - findIndex(keys, b);
1522
- };
1523
- }
1524
-
1525
- const parseJson = (value, _, ctx) => {
1526
- if (typeof value !== 'string') {
1527
- return value;
1528
- }
1529
- let parsed = value;
1530
- try {
1531
- parsed = JSON.parse(value);
1532
- } catch (err) {
1533
- /* */
1534
- }
1535
- return ctx.isType(parsed) ? parsed : value;
1536
- };
1537
-
1538
- // @ts-ignore
1539
- function deepPartial(schema) {
1540
- if ('fields' in schema) {
1541
- const partial = {};
1542
- for (const [key, fieldSchema] of Object.entries(schema.fields)) {
1543
- partial[key] = deepPartial(fieldSchema);
1544
- }
1545
- return schema.setFields(partial);
1546
- }
1547
- if (schema.type === 'array') {
1548
- const nextArray = schema.optional();
1549
- if (nextArray.innerType) nextArray.innerType = deepPartial(nextArray.innerType);
1550
- return nextArray;
1551
- }
1552
- if (schema.type === 'tuple') {
1553
- return schema.optional().clone({
1554
- types: schema.spec.types.map(deepPartial)
1555
- });
1556
- }
1557
- if ('optional' in schema) {
1558
- return schema.optional();
1559
- }
1560
- return schema;
1561
- }
1562
- const deepHas = (obj, p) => {
1563
- const path = [...propertyExpr.normalizePath(p)];
1564
- if (path.length === 1) return path[0] in obj;
1565
- let last = path.pop();
1566
- let parent = propertyExpr.getter(propertyExpr.join(path), true)(obj);
1567
- return !!(parent && last in parent);
1568
- };
1569
- let isObject = obj => Object.prototype.toString.call(obj) === '[object Object]';
1570
- function unknown(ctx, value) {
1571
- let known = Object.keys(ctx.fields);
1572
- return Object.keys(value).filter(key => known.indexOf(key) === -1);
1573
- }
1574
- const defaultSort = sortByKeyOrder([]);
1575
- function create$3(spec) {
1576
- return new ObjectSchema(spec);
1577
- }
1578
- class ObjectSchema extends Schema {
1579
- constructor(spec) {
1580
- super({
1581
- type: 'object',
1582
- check(value) {
1583
- return isObject(value) || typeof value === 'function';
1584
- }
1585
- });
1586
- this.fields = Object.create(null);
1587
- this._sortErrors = defaultSort;
1588
- this._nodes = [];
1589
- this._excludedEdges = [];
1590
- this.withMutation(() => {
1591
- if (spec) {
1592
- this.shape(spec);
1593
- }
1594
- });
1595
- }
1596
- _cast(_value, options = {}) {
1597
- var _options$stripUnknown;
1598
- let value = super._cast(_value, options);
1599
-
1600
- //should ignore nulls here
1601
- if (value === undefined) return this.getDefault();
1602
- if (!this._typeCheck(value)) return value;
1603
- let fields = this.fields;
1604
- let strip = (_options$stripUnknown = options.stripUnknown) != null ? _options$stripUnknown : this.spec.noUnknown;
1605
- let props = [].concat(this._nodes, Object.keys(value).filter(v => !this._nodes.includes(v)));
1606
- let intermediateValue = {}; // is filled during the transform below
1607
- let innerOptions = Object.assign({}, options, {
1608
- parent: intermediateValue,
1609
- __validating: options.__validating || false
1610
- });
1611
- let isChanged = false;
1612
- for (const prop of props) {
1613
- let field = fields[prop];
1614
- let exists = (prop in value);
1615
- if (field) {
1616
- let fieldValue;
1617
- let inputValue = value[prop];
1618
-
1619
- // safe to mutate since this is fired in sequence
1620
- innerOptions.path = (options.path ? `${options.path}.` : '') + prop;
1621
- field = field.resolve({
1622
- value: inputValue,
1623
- context: options.context,
1624
- parent: intermediateValue
1625
- });
1626
- let fieldSpec = field instanceof Schema ? field.spec : undefined;
1627
- let strict = fieldSpec == null ? void 0 : fieldSpec.strict;
1628
- if (fieldSpec != null && fieldSpec.strip) {
1629
- isChanged = isChanged || prop in value;
1630
- continue;
1631
- }
1632
- fieldValue = !options.__validating || !strict ?
1633
- // TODO: use _cast, this is double resolving
1634
- field.cast(value[prop], innerOptions) : value[prop];
1635
- if (fieldValue !== undefined) {
1636
- intermediateValue[prop] = fieldValue;
1637
- }
1638
- } else if (exists && !strip) {
1639
- intermediateValue[prop] = value[prop];
1640
- }
1641
- if (exists !== prop in intermediateValue || intermediateValue[prop] !== value[prop]) {
1642
- isChanged = true;
1643
- }
1644
- }
1645
- return isChanged ? intermediateValue : value;
1646
- }
1647
- _validate(_value, options = {}, panic, next) {
1648
- let {
1649
- from = [],
1650
- originalValue = _value,
1651
- recursive = this.spec.recursive
1652
- } = options;
1653
- options.from = [{
1654
- schema: this,
1655
- value: originalValue
1656
- }, ...from];
1657
- // this flag is needed for handling `strict` correctly in the context of
1658
- // validation vs just casting. e.g strict() on a field is only used when validating
1659
- options.__validating = true;
1660
- options.originalValue = originalValue;
1661
- super._validate(_value, options, panic, (objectErrors, value) => {
1662
- if (!recursive || !isObject(value)) {
1663
- next(objectErrors, value);
1664
- return;
1665
- }
1666
- originalValue = originalValue || value;
1667
- let tests = [];
1668
- for (let key of this._nodes) {
1669
- let field = this.fields[key];
1670
- if (!field || Reference.isRef(field)) {
1671
- continue;
1672
- }
1673
- tests.push(field.asNestedTest({
1674
- options,
1675
- key,
1676
- parent: value,
1677
- parentPath: options.path,
1678
- originalParent: originalValue
1679
- }));
1680
- }
1681
- this.runTests({
1682
- tests,
1683
- value,
1684
- originalValue,
1685
- options
1686
- }, panic, fieldErrors => {
1687
- next(fieldErrors.sort(this._sortErrors).concat(objectErrors), value);
1688
- });
1689
- });
1690
- }
1691
- clone(spec) {
1692
- const next = super.clone(spec);
1693
- next.fields = Object.assign({}, this.fields);
1694
- next._nodes = this._nodes;
1695
- next._excludedEdges = this._excludedEdges;
1696
- next._sortErrors = this._sortErrors;
1697
- return next;
1698
- }
1699
- concat(schema) {
1700
- let next = super.concat(schema);
1701
- let nextFields = next.fields;
1702
- for (let [field, schemaOrRef] of Object.entries(this.fields)) {
1703
- const target = nextFields[field];
1704
- nextFields[field] = target === undefined ? schemaOrRef : target;
1705
- }
1706
- return next.withMutation(s => s.setFields(nextFields, this._excludedEdges));
1707
- }
1708
- _getDefault() {
1709
- if ('default' in this.spec) {
1710
- return super._getDefault();
1711
- }
1712
-
1713
- // if there is no default set invent one
1714
- if (!this._nodes.length) {
1715
- return undefined;
1716
- }
1717
- let dft = {};
1718
- this._nodes.forEach(key => {
1719
- const field = this.fields[key];
1720
- dft[key] = field && 'getDefault' in field ? field.getDefault() : undefined;
1721
- });
1722
- return dft;
1723
- }
1724
- setFields(shape, excludedEdges) {
1725
- let next = this.clone();
1726
- next.fields = shape;
1727
- next._nodes = sortFields(shape, excludedEdges);
1728
- next._sortErrors = sortByKeyOrder(Object.keys(shape));
1729
- // XXX: this carries over edges which may not be what you want
1730
- if (excludedEdges) next._excludedEdges = excludedEdges;
1731
- return next;
1732
- }
1733
- shape(additions, excludes = []) {
1734
- return this.clone().withMutation(next => {
1735
- let edges = next._excludedEdges;
1736
- if (excludes.length) {
1737
- if (!Array.isArray(excludes[0])) excludes = [excludes];
1738
- edges = [...next._excludedEdges, ...excludes];
1739
- }
1740
-
1741
- // XXX: excludes here is wrong
1742
- return next.setFields(Object.assign(next.fields, additions), edges);
1743
- });
1744
- }
1745
- partial() {
1746
- const partial = {};
1747
- for (const [key, schema] of Object.entries(this.fields)) {
1748
- partial[key] = 'optional' in schema && schema.optional instanceof Function ? schema.optional() : schema;
1749
- }
1750
- return this.setFields(partial);
1751
- }
1752
- deepPartial() {
1753
- const next = deepPartial(this);
1754
- return next;
1755
- }
1756
- pick(keys) {
1757
- const picked = {};
1758
- for (const key of keys) {
1759
- if (this.fields[key]) picked[key] = this.fields[key];
1760
- }
1761
- return this.setFields(picked);
1762
- }
1763
- omit(keys) {
1764
- const fields = Object.assign({}, this.fields);
1765
- for (const key of keys) {
1766
- delete fields[key];
1767
- }
1768
- return this.setFields(fields);
1769
- }
1770
- from(from, to, alias) {
1771
- let fromGetter = propertyExpr.getter(from, true);
1772
- return this.transform(obj => {
1773
- if (!obj) return obj;
1774
- let newObj = obj;
1775
- if (deepHas(obj, from)) {
1776
- newObj = Object.assign({}, obj);
1777
- if (!alias) delete newObj[from];
1778
- newObj[to] = fromGetter(obj);
1779
- }
1780
- return newObj;
1781
- });
1782
- }
1783
-
1784
- /** Parse an input JSON string to an object */
1785
- json() {
1786
- return this.transform(parseJson);
1787
- }
1788
- noUnknown(noAllow = true, message = object.noUnknown) {
1789
- if (typeof noAllow !== 'boolean') {
1790
- message = noAllow;
1791
- noAllow = true;
1792
- }
1793
- let next = this.test({
1794
- name: 'noUnknown',
1795
- exclusive: true,
1796
- message: message,
1797
- test(value) {
1798
- if (value == null) return true;
1799
- const unknownKeys = unknown(this.schema, value);
1800
- return !noAllow || unknownKeys.length === 0 || this.createError({
1801
- params: {
1802
- unknown: unknownKeys.join(', ')
1803
- }
1804
- });
1805
- }
1806
- });
1807
- next.spec.noUnknown = noAllow;
1808
- return next;
1809
- }
1810
- unknown(allow = true, message = object.noUnknown) {
1811
- return this.noUnknown(!allow, message);
1812
- }
1813
- transformKeys(fn) {
1814
- return this.transform(obj => {
1815
- if (!obj) return obj;
1816
- const result = {};
1817
- for (const key of Object.keys(obj)) result[fn(key)] = obj[key];
1818
- return result;
1819
- });
1820
- }
1821
- camelCase() {
1822
- return this.transformKeys(tinyCase.camelCase);
1823
- }
1824
- snakeCase() {
1825
- return this.transformKeys(tinyCase.snakeCase);
1826
- }
1827
- constantCase() {
1828
- return this.transformKeys(key => tinyCase.snakeCase(key).toUpperCase());
1829
- }
1830
- describe(options) {
1831
- let base = super.describe(options);
1832
- base.fields = {};
1833
- for (const [key, value] of Object.entries(this.fields)) {
1834
- var _innerOptions;
1835
- let innerOptions = options;
1836
- if ((_innerOptions = innerOptions) != null && _innerOptions.value) {
1837
- innerOptions = Object.assign({}, innerOptions, {
1838
- parent: innerOptions.value,
1839
- value: innerOptions.value[key]
1840
- });
1841
- }
1842
- base.fields[key] = value.describe(innerOptions);
1843
- }
1844
- return base;
1845
- }
1846
- }
1847
- create$3.prototype = ObjectSchema.prototype;
1848
-
1849
6
  const RegExZip = /^\d{5}/;
1850
7
  const BillingFormSchema = create$3({
1851
8
  name: create$6().required('Enter name'),
@@ -1853,255 +10,9 @@ const BillingFormSchema = create$3({
1853
10
  address_line2: create$6(),
1854
11
  address_city: create$6().required('Enter city'),
1855
12
  address_state: create$6().required('Choose state'),
1856
- address_postal_code: create$6()
1857
- .required('Enter ZIP')
1858
- .matches(RegExZip, 'Enter a valid ZIP')
1859
- .min(5, 'Enter a valid ZIP')
13
+ address_postal_code: create$6().required('Enter ZIP').matches(RegExZip, 'Enter a valid ZIP').min(5, 'Enter a valid ZIP'),
1860
14
  });
1861
15
 
1862
- const StateOptions = [
1863
- {
1864
- label: 'Choose state',
1865
- value: ''
1866
- },
1867
- {
1868
- label: 'Alabama',
1869
- value: 'AL'
1870
- },
1871
- {
1872
- label: 'Alaska',
1873
- value: 'AK'
1874
- },
1875
- {
1876
- label: 'American Samoa',
1877
- value: 'AS'
1878
- },
1879
- {
1880
- label: 'Arizona',
1881
- value: 'AZ'
1882
- },
1883
- {
1884
- label: 'Arkansas',
1885
- value: 'AR'
1886
- },
1887
- {
1888
- label: 'California',
1889
- value: 'CA'
1890
- },
1891
- {
1892
- label: 'Colorado',
1893
- value: 'CO'
1894
- },
1895
- {
1896
- label: 'Connecticut',
1897
- value: 'CT'
1898
- },
1899
- {
1900
- label: 'Delaware',
1901
- value: 'DE'
1902
- },
1903
- {
1904
- label: 'District Of Columbia',
1905
- value: 'DC'
1906
- },
1907
- {
1908
- label: 'Federated States Of Micronesia',
1909
- value: 'FM'
1910
- },
1911
- {
1912
- label: 'Florida',
1913
- value: 'FL'
1914
- },
1915
- {
1916
- label: 'Georgia',
1917
- value: 'GA'
1918
- },
1919
- {
1920
- label: 'Guam',
1921
- value: 'GU'
1922
- },
1923
- {
1924
- label: 'Hawaii',
1925
- value: 'HI'
1926
- },
1927
- {
1928
- label: 'Idaho',
1929
- value: 'ID'
1930
- },
1931
- {
1932
- label: 'Illinois',
1933
- value: 'IL'
1934
- },
1935
- {
1936
- label: 'Indiana',
1937
- value: 'IN'
1938
- },
1939
- {
1940
- label: 'Iowa',
1941
- value: 'IA'
1942
- },
1943
- {
1944
- label: 'Kansas',
1945
- value: 'KS'
1946
- },
1947
- {
1948
- label: 'Kentucky',
1949
- value: 'KY'
1950
- },
1951
- {
1952
- label: 'Louisiana',
1953
- value: 'LA'
1954
- },
1955
- {
1956
- label: 'Maine',
1957
- value: 'ME'
1958
- },
1959
- {
1960
- label: 'Marshall Islands',
1961
- value: 'MH'
1962
- },
1963
- {
1964
- label: 'Maryland',
1965
- value: 'MD'
1966
- },
1967
- {
1968
- label: 'Massachusetts',
1969
- value: 'MA'
1970
- },
1971
- {
1972
- label: 'Michigan',
1973
- value: 'MI'
1974
- },
1975
- {
1976
- label: 'Minnesota',
1977
- value: 'MN'
1978
- },
1979
- {
1980
- label: 'Mississippi',
1981
- value: 'MS'
1982
- },
1983
- {
1984
- label: 'Missouri',
1985
- value: 'MO'
1986
- },
1987
- {
1988
- label: 'Montana',
1989
- value: 'MT'
1990
- },
1991
- {
1992
- label: 'Nebraska',
1993
- value: 'NE'
1994
- },
1995
- {
1996
- label: 'Nevada',
1997
- value: 'NV'
1998
- },
1999
- {
2000
- label: 'New Hampshire',
2001
- value: 'NH'
2002
- },
2003
- {
2004
- label: 'New Jersey',
2005
- value: 'NJ'
2006
- },
2007
- {
2008
- label: 'New Mexico',
2009
- value: 'NM'
2010
- },
2011
- {
2012
- label: 'New York',
2013
- value: 'NY'
2014
- },
2015
- {
2016
- label: 'North Carolina',
2017
- value: 'NC'
2018
- },
2019
- {
2020
- label: 'North Dakota',
2021
- value: 'ND'
2022
- },
2023
- {
2024
- label: 'Northern Mariana Islands',
2025
- value: 'MP'
2026
- },
2027
- {
2028
- label: 'Ohio',
2029
- value: 'OH'
2030
- },
2031
- {
2032
- label: 'Oklahoma',
2033
- value: 'OK'
2034
- },
2035
- {
2036
- label: 'Oregon',
2037
- value: 'OR'
2038
- },
2039
- {
2040
- label: 'Palau',
2041
- value: 'PW'
2042
- },
2043
- {
2044
- label: 'Pennsylvania',
2045
- value: 'PA'
2046
- },
2047
- {
2048
- label: 'Puerto Rico',
2049
- value: 'PR'
2050
- },
2051
- {
2052
- label: 'Rhode Island',
2053
- value: 'RI'
2054
- },
2055
- {
2056
- label: 'South Carolina',
2057
- value: 'SC'
2058
- },
2059
- {
2060
- label: 'South Dakota',
2061
- value: 'SD'
2062
- },
2063
- {
2064
- label: 'Tennessee',
2065
- value: 'TN'
2066
- },
2067
- {
2068
- label: 'Texas',
2069
- value: 'TX'
2070
- },
2071
- {
2072
- label: 'Utah',
2073
- value: 'UT'
2074
- },
2075
- {
2076
- label: 'Vermont',
2077
- value: 'VT'
2078
- },
2079
- {
2080
- label: 'Virgin Islands',
2081
- value: 'VI'
2082
- },
2083
- {
2084
- label: 'Virginia',
2085
- value: 'VA'
2086
- },
2087
- {
2088
- label: 'Washington',
2089
- value: 'WA'
2090
- },
2091
- {
2092
- label: 'West Virginia',
2093
- value: 'WV'
2094
- },
2095
- {
2096
- label: 'Wisconsin',
2097
- value: 'WI'
2098
- },
2099
- {
2100
- label: 'Wyoming',
2101
- value: 'WY'
2102
- }
2103
- ];
2104
-
2105
16
  const billingFormCss = ":root{--bs-blue:#0d6efd;--bs-indigo:#6610f2;--bs-purple:#6f42c1;--bs-pink:#d63384;--bs-red:#dc3545;--bs-orange:#fd7e14;--bs-yellow:#ffc107;--bs-green:#198754;--bs-teal:#20c997;--bs-cyan:#0dcaf0;--bs-black:#000;--bs-white:#fff;--bs-gray:#6c757d;--bs-gray-dark:#343a40;--bs-gray-100:#f8f9fa;--bs-gray-200:#e9ecef;--bs-gray-300:#dee2e6;--bs-gray-400:#ced4da;--bs-gray-500:#adb5bd;--bs-gray-600:#6c757d;--bs-gray-700:#495057;--bs-gray-800:#343a40;--bs-gray-900:#212529;--bs-primary:#0d6efd;--bs-secondary:#6c757d;--bs-success:#198754;--bs-info:#0dcaf0;--bs-warning:#ffc107;--bs-danger:#dc3545;--bs-light:#f8f9fa;--bs-dark:#212529;--bs-primary-rgb:13, 110, 253;--bs-secondary-rgb:108, 117, 125;--bs-success-rgb:25, 135, 84;--bs-info-rgb:13, 202, 240;--bs-warning-rgb:255, 193, 7;--bs-danger-rgb:220, 53, 69;--bs-light-rgb:248, 249, 250;--bs-dark-rgb:33, 37, 41;--bs-white-rgb:255, 255, 255;--bs-black-rgb:0, 0, 0;--bs-body-color-rgb:33, 37, 41;--bs-body-bg-rgb:255, 255, 255;--bs-font-sans-serif:system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", \"Liberation Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";--bs-font-monospace:SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;--bs-gradient:linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));--bs-body-font-family:var(--bs-font-sans-serif);--bs-body-font-size:1rem;--bs-body-font-weight:400;--bs-body-line-height:1.5;--bs-body-color:#212529;--bs-body-bg:#fff;--bs-border-width:1px;--bs-border-style:solid;--bs-border-color:#dee2e6;--bs-border-color-translucent:rgba(0, 0, 0, 0.175);--bs-border-radius:0.375rem;--bs-border-radius-sm:0.25rem;--bs-border-radius-lg:0.5rem;--bs-border-radius-xl:1rem;--bs-border-radius-2xl:2rem;--bs-border-radius-pill:50rem;--bs-link-color:#0d6efd;--bs-link-hover-color:#0a58ca;--bs-code-color:#d63384;--bs-highlight-bg:#fff3cd}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion: no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)}hr{margin:1rem 0;color:inherit;border:0;border-top:1px solid;opacity:0.25}h6,h5,h4,h3,h2,h1{margin-top:0;margin-bottom:0.5rem;font-weight:500;line-height:1.2}h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width: 1200px){h1{font-size:2.5rem}}h2{font-size:calc(1.325rem + 0.9vw)}@media (min-width: 1200px){h2{font-size:2rem}}h3{font-size:calc(1.3rem + 0.6vw)}@media (min-width: 1200px){h3{font-size:1.75rem}}h4{font-size:calc(1.275rem + 0.3vw)}@media (min-width: 1200px){h4{font-size:1.5rem}}h5{font-size:1.25rem}h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[title]{text-decoration:underline dotted;cursor:help;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-left:2rem}ol,ul,dl{margin-top:0;margin-bottom:1rem}ol ol,ul ul,ol ul,ul ol{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:0.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:0.875em}mark{padding:0.1875em;background-color:var(--bs-highlight-bg)}sub,sup{position:relative;font-size:0.75em;line-height:0;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}a{color:var(--bs-link-color);text-decoration:underline}a:hover{color:var(--bs-link-hover-color)}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}pre,code,kbd,samp{font-family:var(--bs-font-monospace);font-size:1em}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:0.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:0.875em;color:var(--bs-code-color);word-wrap:break-word}a>code{color:inherit}kbd{padding:0.1875rem 0.375rem;font-size:0.875em;color:var(--bs-body-bg);background-color:var(--bs-body-color);border-radius:0.25rem}kbd kbd{padding:0;font-size:1em}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:0.5rem;padding-bottom:0.5rem;color:#6c757d;text-align:left}th{text-align:inherit;text-align:-webkit-match-parent}thead,tbody,tfoot,tr,td,th{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}input,button,select,optgroup,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]:not([type=date]):not([type=datetime-local]):not([type=month]):not([type=week]):not([type=time])::-webkit-calendar-picker-indicator{display:none !important}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}button:not(:disabled),[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:left;width:100%;padding:0;margin-bottom:0.5rem;font-size:calc(1.275rem + 0.3vw);line-height:inherit}@media (min-width: 1200px){legend{font-size:1.5rem}}legend+*{clear:left}::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-text,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:textfield}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::file-selector-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none !important}.row{--bs-gutter-x:1.5rem;--bs-gutter-y:0;display:flex;flex-wrap:wrap;margin-top:calc(-1 * var(--bs-gutter-y));margin-right:calc(-0.5 * var(--bs-gutter-x));margin-left:calc(-0.5 * var(--bs-gutter-x))}.row>*{flex-shrink:0;width:100%;max-width:100%;padding-right:calc(var(--bs-gutter-x) * 0.5);padding-left:calc(var(--bs-gutter-x) * 0.5);margin-top:var(--bs-gutter-y)}.col{flex:1 0 0%}.row-cols-auto>*{flex:0 0 auto;width:auto}.row-cols-1>*{flex:0 0 auto;width:100%}.row-cols-2>*{flex:0 0 auto;width:50%}.row-cols-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-4>*{flex:0 0 auto;width:25%}.row-cols-5>*{flex:0 0 auto;width:20%}.row-cols-6>*{flex:0 0 auto;width:16.6666666667%}.col-auto{flex:0 0 auto;width:auto}.col-1{flex:0 0 auto;width:8.33333333%}.col-2{flex:0 0 auto;width:16.66666667%}.col-3{flex:0 0 auto;width:25%}.col-4{flex:0 0 auto;width:33.33333333%}.col-5{flex:0 0 auto;width:41.66666667%}.col-6{flex:0 0 auto;width:50%}.col-7{flex:0 0 auto;width:58.33333333%}.col-8{flex:0 0 auto;width:66.66666667%}.col-9{flex:0 0 auto;width:75%}.col-10{flex:0 0 auto;width:83.33333333%}.col-11{flex:0 0 auto;width:91.66666667%}.col-12{flex:0 0 auto;width:100%}.offset-1{margin-left:8.33333333%}.offset-2{margin-left:16.66666667%}.offset-3{margin-left:25%}.offset-4{margin-left:33.33333333%}.offset-5{margin-left:41.66666667%}.offset-6{margin-left:50%}.offset-7{margin-left:58.33333333%}.offset-8{margin-left:66.66666667%}.offset-9{margin-left:75%}.offset-10{margin-left:83.33333333%}.offset-11{margin-left:91.66666667%}.g-0,.gx-0{--bs-gutter-x:0}.g-0,.gy-0{--bs-gutter-y:0}.g-1,.gx-1{--bs-gutter-x:0.25rem}.g-1,.gy-1{--bs-gutter-y:0.25rem}.g-2,.gx-2{--bs-gutter-x:0.5rem}.g-2,.gy-2{--bs-gutter-y:0.5rem}.g-3,.gx-3{--bs-gutter-x:1rem}.g-3,.gy-3{--bs-gutter-y:1rem}.g-4,.gx-4{--bs-gutter-x:1.5rem}.g-4,.gy-4{--bs-gutter-y:1.5rem}.g-5,.gx-5{--bs-gutter-x:3rem}.g-5,.gy-5{--bs-gutter-y:3rem}@media (min-width: 576px){.col-sm{flex:1 0 0%}.row-cols-sm-auto>*{flex:0 0 auto;width:auto}.row-cols-sm-1>*{flex:0 0 auto;width:100%}.row-cols-sm-2>*{flex:0 0 auto;width:50%}.row-cols-sm-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-sm-4>*{flex:0 0 auto;width:25%}.row-cols-sm-5>*{flex:0 0 auto;width:20%}.row-cols-sm-6>*{flex:0 0 auto;width:16.6666666667%}.col-sm-auto{flex:0 0 auto;width:auto}.col-sm-1{flex:0 0 auto;width:8.33333333%}.col-sm-2{flex:0 0 auto;width:16.66666667%}.col-sm-3{flex:0 0 auto;width:25%}.col-sm-4{flex:0 0 auto;width:33.33333333%}.col-sm-5{flex:0 0 auto;width:41.66666667%}.col-sm-6{flex:0 0 auto;width:50%}.col-sm-7{flex:0 0 auto;width:58.33333333%}.col-sm-8{flex:0 0 auto;width:66.66666667%}.col-sm-9{flex:0 0 auto;width:75%}.col-sm-10{flex:0 0 auto;width:83.33333333%}.col-sm-11{flex:0 0 auto;width:91.66666667%}.col-sm-12{flex:0 0 auto;width:100%}.offset-sm-0{margin-left:0}.offset-sm-1{margin-left:8.33333333%}.offset-sm-2{margin-left:16.66666667%}.offset-sm-3{margin-left:25%}.offset-sm-4{margin-left:33.33333333%}.offset-sm-5{margin-left:41.66666667%}.offset-sm-6{margin-left:50%}.offset-sm-7{margin-left:58.33333333%}.offset-sm-8{margin-left:66.66666667%}.offset-sm-9{margin-left:75%}.offset-sm-10{margin-left:83.33333333%}.offset-sm-11{margin-left:91.66666667%}.g-sm-0,.gx-sm-0{--bs-gutter-x:0}.g-sm-0,.gy-sm-0{--bs-gutter-y:0}.g-sm-1,.gx-sm-1{--bs-gutter-x:0.25rem}.g-sm-1,.gy-sm-1{--bs-gutter-y:0.25rem}.g-sm-2,.gx-sm-2{--bs-gutter-x:0.5rem}.g-sm-2,.gy-sm-2{--bs-gutter-y:0.5rem}.g-sm-3,.gx-sm-3{--bs-gutter-x:1rem}.g-sm-3,.gy-sm-3{--bs-gutter-y:1rem}.g-sm-4,.gx-sm-4{--bs-gutter-x:1.5rem}.g-sm-4,.gy-sm-4{--bs-gutter-y:1.5rem}.g-sm-5,.gx-sm-5{--bs-gutter-x:3rem}.g-sm-5,.gy-sm-5{--bs-gutter-y:3rem}}@media (min-width: 768px){.col-md{flex:1 0 0%}.row-cols-md-auto>*{flex:0 0 auto;width:auto}.row-cols-md-1>*{flex:0 0 auto;width:100%}.row-cols-md-2>*{flex:0 0 auto;width:50%}.row-cols-md-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-md-4>*{flex:0 0 auto;width:25%}.row-cols-md-5>*{flex:0 0 auto;width:20%}.row-cols-md-6>*{flex:0 0 auto;width:16.6666666667%}.col-md-auto{flex:0 0 auto;width:auto}.col-md-1{flex:0 0 auto;width:8.33333333%}.col-md-2{flex:0 0 auto;width:16.66666667%}.col-md-3{flex:0 0 auto;width:25%}.col-md-4{flex:0 0 auto;width:33.33333333%}.col-md-5{flex:0 0 auto;width:41.66666667%}.col-md-6{flex:0 0 auto;width:50%}.col-md-7{flex:0 0 auto;width:58.33333333%}.col-md-8{flex:0 0 auto;width:66.66666667%}.col-md-9{flex:0 0 auto;width:75%}.col-md-10{flex:0 0 auto;width:83.33333333%}.col-md-11{flex:0 0 auto;width:91.66666667%}.col-md-12{flex:0 0 auto;width:100%}.offset-md-0{margin-left:0}.offset-md-1{margin-left:8.33333333%}.offset-md-2{margin-left:16.66666667%}.offset-md-3{margin-left:25%}.offset-md-4{margin-left:33.33333333%}.offset-md-5{margin-left:41.66666667%}.offset-md-6{margin-left:50%}.offset-md-7{margin-left:58.33333333%}.offset-md-8{margin-left:66.66666667%}.offset-md-9{margin-left:75%}.offset-md-10{margin-left:83.33333333%}.offset-md-11{margin-left:91.66666667%}.g-md-0,.gx-md-0{--bs-gutter-x:0}.g-md-0,.gy-md-0{--bs-gutter-y:0}.g-md-1,.gx-md-1{--bs-gutter-x:0.25rem}.g-md-1,.gy-md-1{--bs-gutter-y:0.25rem}.g-md-2,.gx-md-2{--bs-gutter-x:0.5rem}.g-md-2,.gy-md-2{--bs-gutter-y:0.5rem}.g-md-3,.gx-md-3{--bs-gutter-x:1rem}.g-md-3,.gy-md-3{--bs-gutter-y:1rem}.g-md-4,.gx-md-4{--bs-gutter-x:1.5rem}.g-md-4,.gy-md-4{--bs-gutter-y:1.5rem}.g-md-5,.gx-md-5{--bs-gutter-x:3rem}.g-md-5,.gy-md-5{--bs-gutter-y:3rem}}@media (min-width: 992px){.col-lg{flex:1 0 0%}.row-cols-lg-auto>*{flex:0 0 auto;width:auto}.row-cols-lg-1>*{flex:0 0 auto;width:100%}.row-cols-lg-2>*{flex:0 0 auto;width:50%}.row-cols-lg-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-lg-4>*{flex:0 0 auto;width:25%}.row-cols-lg-5>*{flex:0 0 auto;width:20%}.row-cols-lg-6>*{flex:0 0 auto;width:16.6666666667%}.col-lg-auto{flex:0 0 auto;width:auto}.col-lg-1{flex:0 0 auto;width:8.33333333%}.col-lg-2{flex:0 0 auto;width:16.66666667%}.col-lg-3{flex:0 0 auto;width:25%}.col-lg-4{flex:0 0 auto;width:33.33333333%}.col-lg-5{flex:0 0 auto;width:41.66666667%}.col-lg-6{flex:0 0 auto;width:50%}.col-lg-7{flex:0 0 auto;width:58.33333333%}.col-lg-8{flex:0 0 auto;width:66.66666667%}.col-lg-9{flex:0 0 auto;width:75%}.col-lg-10{flex:0 0 auto;width:83.33333333%}.col-lg-11{flex:0 0 auto;width:91.66666667%}.col-lg-12{flex:0 0 auto;width:100%}.offset-lg-0{margin-left:0}.offset-lg-1{margin-left:8.33333333%}.offset-lg-2{margin-left:16.66666667%}.offset-lg-3{margin-left:25%}.offset-lg-4{margin-left:33.33333333%}.offset-lg-5{margin-left:41.66666667%}.offset-lg-6{margin-left:50%}.offset-lg-7{margin-left:58.33333333%}.offset-lg-8{margin-left:66.66666667%}.offset-lg-9{margin-left:75%}.offset-lg-10{margin-left:83.33333333%}.offset-lg-11{margin-left:91.66666667%}.g-lg-0,.gx-lg-0{--bs-gutter-x:0}.g-lg-0,.gy-lg-0{--bs-gutter-y:0}.g-lg-1,.gx-lg-1{--bs-gutter-x:0.25rem}.g-lg-1,.gy-lg-1{--bs-gutter-y:0.25rem}.g-lg-2,.gx-lg-2{--bs-gutter-x:0.5rem}.g-lg-2,.gy-lg-2{--bs-gutter-y:0.5rem}.g-lg-3,.gx-lg-3{--bs-gutter-x:1rem}.g-lg-3,.gy-lg-3{--bs-gutter-y:1rem}.g-lg-4,.gx-lg-4{--bs-gutter-x:1.5rem}.g-lg-4,.gy-lg-4{--bs-gutter-y:1.5rem}.g-lg-5,.gx-lg-5{--bs-gutter-x:3rem}.g-lg-5,.gy-lg-5{--bs-gutter-y:3rem}}@media (min-width: 1200px){.col-xl{flex:1 0 0%}.row-cols-xl-auto>*{flex:0 0 auto;width:auto}.row-cols-xl-1>*{flex:0 0 auto;width:100%}.row-cols-xl-2>*{flex:0 0 auto;width:50%}.row-cols-xl-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-xl-4>*{flex:0 0 auto;width:25%}.row-cols-xl-5>*{flex:0 0 auto;width:20%}.row-cols-xl-6>*{flex:0 0 auto;width:16.6666666667%}.col-xl-auto{flex:0 0 auto;width:auto}.col-xl-1{flex:0 0 auto;width:8.33333333%}.col-xl-2{flex:0 0 auto;width:16.66666667%}.col-xl-3{flex:0 0 auto;width:25%}.col-xl-4{flex:0 0 auto;width:33.33333333%}.col-xl-5{flex:0 0 auto;width:41.66666667%}.col-xl-6{flex:0 0 auto;width:50%}.col-xl-7{flex:0 0 auto;width:58.33333333%}.col-xl-8{flex:0 0 auto;width:66.66666667%}.col-xl-9{flex:0 0 auto;width:75%}.col-xl-10{flex:0 0 auto;width:83.33333333%}.col-xl-11{flex:0 0 auto;width:91.66666667%}.col-xl-12{flex:0 0 auto;width:100%}.offset-xl-0{margin-left:0}.offset-xl-1{margin-left:8.33333333%}.offset-xl-2{margin-left:16.66666667%}.offset-xl-3{margin-left:25%}.offset-xl-4{margin-left:33.33333333%}.offset-xl-5{margin-left:41.66666667%}.offset-xl-6{margin-left:50%}.offset-xl-7{margin-left:58.33333333%}.offset-xl-8{margin-left:66.66666667%}.offset-xl-9{margin-left:75%}.offset-xl-10{margin-left:83.33333333%}.offset-xl-11{margin-left:91.66666667%}.g-xl-0,.gx-xl-0{--bs-gutter-x:0}.g-xl-0,.gy-xl-0{--bs-gutter-y:0}.g-xl-1,.gx-xl-1{--bs-gutter-x:0.25rem}.g-xl-1,.gy-xl-1{--bs-gutter-y:0.25rem}.g-xl-2,.gx-xl-2{--bs-gutter-x:0.5rem}.g-xl-2,.gy-xl-2{--bs-gutter-y:0.5rem}.g-xl-3,.gx-xl-3{--bs-gutter-x:1rem}.g-xl-3,.gy-xl-3{--bs-gutter-y:1rem}.g-xl-4,.gx-xl-4{--bs-gutter-x:1.5rem}.g-xl-4,.gy-xl-4{--bs-gutter-y:1.5rem}.g-xl-5,.gx-xl-5{--bs-gutter-x:3rem}.g-xl-5,.gy-xl-5{--bs-gutter-y:3rem}}@media (min-width: 1400px){.col-xxl{flex:1 0 0%}.row-cols-xxl-auto>*{flex:0 0 auto;width:auto}.row-cols-xxl-1>*{flex:0 0 auto;width:100%}.row-cols-xxl-2>*{flex:0 0 auto;width:50%}.row-cols-xxl-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-xxl-4>*{flex:0 0 auto;width:25%}.row-cols-xxl-5>*{flex:0 0 auto;width:20%}.row-cols-xxl-6>*{flex:0 0 auto;width:16.6666666667%}.col-xxl-auto{flex:0 0 auto;width:auto}.col-xxl-1{flex:0 0 auto;width:8.33333333%}.col-xxl-2{flex:0 0 auto;width:16.66666667%}.col-xxl-3{flex:0 0 auto;width:25%}.col-xxl-4{flex:0 0 auto;width:33.33333333%}.col-xxl-5{flex:0 0 auto;width:41.66666667%}.col-xxl-6{flex:0 0 auto;width:50%}.col-xxl-7{flex:0 0 auto;width:58.33333333%}.col-xxl-8{flex:0 0 auto;width:66.66666667%}.col-xxl-9{flex:0 0 auto;width:75%}.col-xxl-10{flex:0 0 auto;width:83.33333333%}.col-xxl-11{flex:0 0 auto;width:91.66666667%}.col-xxl-12{flex:0 0 auto;width:100%}.offset-xxl-0{margin-left:0}.offset-xxl-1{margin-left:8.33333333%}.offset-xxl-2{margin-left:16.66666667%}.offset-xxl-3{margin-left:25%}.offset-xxl-4{margin-left:33.33333333%}.offset-xxl-5{margin-left:41.66666667%}.offset-xxl-6{margin-left:50%}.offset-xxl-7{margin-left:58.33333333%}.offset-xxl-8{margin-left:66.66666667%}.offset-xxl-9{margin-left:75%}.offset-xxl-10{margin-left:83.33333333%}.offset-xxl-11{margin-left:91.66666667%}.g-xxl-0,.gx-xxl-0{--bs-gutter-x:0}.g-xxl-0,.gy-xxl-0{--bs-gutter-y:0}.g-xxl-1,.gx-xxl-1{--bs-gutter-x:0.25rem}.g-xxl-1,.gy-xxl-1{--bs-gutter-y:0.25rem}.g-xxl-2,.gx-xxl-2{--bs-gutter-x:0.5rem}.g-xxl-2,.gy-xxl-2{--bs-gutter-y:0.5rem}.g-xxl-3,.gx-xxl-3{--bs-gutter-x:1rem}.g-xxl-3,.gy-xxl-3{--bs-gutter-y:1rem}.g-xxl-4,.gx-xxl-4{--bs-gutter-x:1.5rem}.g-xxl-4,.gy-xxl-4{--bs-gutter-y:1.5rem}.g-xxl-5,.gx-xxl-5{--bs-gutter-x:3rem}.g-xxl-5,.gy-xxl-5{--bs-gutter-y:3rem}}:host{font-family:system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", \"Liberation Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;display:block}justifi-billing-form{margin-left:calc(var(--jfi-layout-padding) * -1);margin-right:calc(var(--jfi-layout-padding) * -1)}*::part(label){color:var(--jfi-form-label-color);font-family:var(--jfi-form-label-font-family);font-weight:var(--jfi-form-label-font-weight);font-size:var(--jfi-form-label-font-size);margin:var(--jfi-form-label-margin)}*::part(input){background-color:var(--jfi-form-control-background-color);border-color:var(--jfi-form-control-border-color);border-width:var(--jfi-form-control-border-width);border-bottom-width:var(--jfi-form-control-border-bottom-width);border-left-width:var(--jfi-form-control-border-left-width);border-right-width:var(--jfi-form-control-border-right-width);border-top-width:var(--jfi-form-control-border-top-width);border-radius:var(--jfi-form-control-border-radius);border-style:var(--jfi-form-control-border-style);box-shadow:var(--jfi-form-control-box-shadow);color:var(--jfi-form-control-color);font-size:var(--jfi-form-control-font-size);font-weight:var(--jfi-form-control-font-weight);line-height:var(--jfi-form-control-line-height);margin:var(--jfi-form-control-margin);padding:var(--jfi-form-control-padding)}*::part(input):focus{color:var(--jfi-form-control-color-focus);border-color:var(--jfi-form-control-border-color-focus);box-shadow:var(--jfi-form-control-box-shadow-focus)}*::part(input-invalid){border-color:var(--jfi-form-control-border-color-error);box-shadow:var(--jfi-form-control-box-shadow-error)}*::part(input-invalid):focus{border-color:var(--jfi-form-control-border-color-error);box-shadow:var(--jfi-form-control-box-shadow-error-focus)}";
2106
17
 
2107
18
  const BillingForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
@@ -2109,7 +20,7 @@ const BillingForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
2109
20
  super();
2110
21
  this.__registerHost();
2111
22
  this.__attachShadow();
2112
- this.legendBlock = h("legend", null, this.legend);
23
+ this.legendBlock = (h("legend", null, this.legend));
2113
24
  this.legend = undefined;
2114
25
  this.billingFields = {
2115
26
  name: '',
@@ -2117,7 +28,7 @@ const BillingForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
2117
28
  address_line2: '',
2118
29
  address_city: '',
2119
30
  address_state: '',
2120
- address_postal_code: ''
31
+ address_postal_code: '',
2121
32
  };
2122
33
  this.billingFieldsErrors = {};
2123
34
  }