@getopenpay/openpay-js 0.1.15-alpha.09caa9f → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +17 -3
- package/dist/index.es.js +543 -556
- package/dist/index.umd.js +10 -10
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -146,7 +146,21 @@ export declare enum FieldName {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
declare class FormCallbacks {
|
|
149
|
-
private
|
|
149
|
+
private static readonly NOOP = () => {};
|
|
150
|
+
private _callbacks: Required<AllCallbacks>;
|
|
151
|
+
|
|
152
|
+
constructor() {
|
|
153
|
+
this._callbacks = FormCallbacks.createEmptyCallbacks();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private static createEmptyCallbacks = (): Required<AllCallbacks> => {
|
|
157
|
+
const x: AllCallbacks = {};
|
|
158
|
+
Object.keys(ZodFormCallbacks.keyof().enum).forEach((key) => {
|
|
159
|
+
// @ts-expect-error - trust the process
|
|
160
|
+
x[key] = FormCallbacks.NOOP;
|
|
161
|
+
});
|
|
162
|
+
return x as Required<AllCallbacks>;
|
|
163
|
+
};
|
|
150
164
|
|
|
151
165
|
static fromObject = (obj: unknown) => {
|
|
152
166
|
const instance = new FormCallbacks();
|
|
@@ -159,9 +173,9 @@ declare class FormCallbacks {
|
|
|
159
173
|
*/
|
|
160
174
|
setCallbacks = (rawCallbacks: AllCallbacks) => {
|
|
161
175
|
// Making sure to reinitialize
|
|
162
|
-
this._callbacks =
|
|
176
|
+
this._callbacks = FormCallbacks.createEmptyCallbacks();
|
|
163
177
|
Object.entries(rawCallbacks).forEach(([key, rawCallback]) => {
|
|
164
|
-
const safeCallback = makeCallbackSafe(key, rawCallback ??
|
|
178
|
+
const safeCallback = makeCallbackSafe(key, rawCallback ?? FormCallbacks.NOOP, err__);
|
|
165
179
|
// @ts-expect-error - trust the process
|
|
166
180
|
this._callbacks[key] = safeCallback;
|
|
167
181
|
});
|