@ozura/elements 1.3.1-next.71 → 1.3.1-next.72
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/react/index.cjs.js +34 -12
- package/dist/react/index.cjs.js.map +1 -1
- package/dist/react/index.esm.js +34 -12
- package/dist/react/index.esm.js.map +1 -1
- package/dist/vue/index.cjs.js +35 -11
- package/dist/vue/index.cjs.js.map +1 -1
- package/dist/vue/index.esm.js +35 -11
- package/dist/vue/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.esm.js
CHANGED
|
@@ -2273,9 +2273,11 @@ const OzContext = createContext({
|
|
|
2273
2273
|
notifyUnmount: () => { },
|
|
2274
2274
|
notifyMount: () => { },
|
|
2275
2275
|
notifyTokenize: () => { },
|
|
2276
|
+
notifyChange: () => { },
|
|
2276
2277
|
mountedCount: 0,
|
|
2277
2278
|
readyCount: 0,
|
|
2278
2279
|
tokenizeCount: 0,
|
|
2280
|
+
changeTick: 0,
|
|
2279
2281
|
});
|
|
2280
2282
|
/**
|
|
2281
2283
|
* Creates and owns an OzVault instance for the lifetime of this component.
|
|
@@ -2288,6 +2290,7 @@ function OzElements({ sessionUrl, getSessionKey, fetchWaxKey, pubKey, frameBaseU
|
|
|
2288
2290
|
const [mountedCount, setMountedCount] = useState(0);
|
|
2289
2291
|
const [readyCount, setReadyCount] = useState(0);
|
|
2290
2292
|
const [tokenizeCount, setTokenizeCount] = useState(0);
|
|
2293
|
+
const [changeTick, setChangeTick] = useState(0);
|
|
2291
2294
|
const onLoadErrorRef = useRef(onLoadError);
|
|
2292
2295
|
onLoadErrorRef.current = onLoadError;
|
|
2293
2296
|
const onWaxRefreshRef = useRef(onSessionRefresh !== null && onSessionRefresh !== void 0 ? onSessionRefresh : onWaxRefresh);
|
|
@@ -2410,7 +2413,8 @@ function OzElements({ sessionUrl, getSessionKey, fetchWaxKey, pubKey, frameBaseU
|
|
|
2410
2413
|
setReadyCount(n => Math.max(0, n - 1));
|
|
2411
2414
|
}, []);
|
|
2412
2415
|
const notifyTokenize = useCallback(() => setTokenizeCount(n => n + 1), []);
|
|
2413
|
-
const
|
|
2416
|
+
const notifyChange = useCallback(() => setChangeTick(n => n + 1), []);
|
|
2417
|
+
const value = useMemo(() => ({ vault, initError, notifyMount, notifyReady, notifyUnmount, notifyTokenize, notifyChange, mountedCount, readyCount, tokenizeCount, changeTick }), [vault, initError, notifyMount, notifyReady, notifyUnmount, notifyTokenize, notifyChange, mountedCount, readyCount, tokenizeCount, changeTick]);
|
|
2414
2418
|
return jsx(OzContext.Provider, { value: value, children: children });
|
|
2415
2419
|
}
|
|
2416
2420
|
/**
|
|
@@ -2419,23 +2423,41 @@ function OzElements({ sessionUrl, getSessionKey, fetchWaxKey, pubKey, frameBaseU
|
|
|
2419
2423
|
*/
|
|
2420
2424
|
function useOzElements() {
|
|
2421
2425
|
var _a, _b;
|
|
2422
|
-
const { vault, initError, mountedCount, readyCount, notifyTokenize, tokenizeCount } = useContext(OzContext);
|
|
2426
|
+
const { vault, initError, mountedCount, readyCount, notifyTokenize, notifyChange, tokenizeCount } = useContext(OzContext);
|
|
2423
2427
|
const createToken = useCallback(async (options) => {
|
|
2424
2428
|
if (!vault) {
|
|
2425
2429
|
return Promise.reject(new OzError('useOzElements must be called inside an <OzElements> provider.'));
|
|
2426
2430
|
}
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
+
// Start the call so vault._tokenizing flips synchronously, then notify so
|
|
2432
|
+
// `isTokenizing` re-renders as `true`. Notify again on settle so it returns
|
|
2433
|
+
// to `false`. (vault.isTokenizing is a plain getter — nothing else would
|
|
2434
|
+
// trigger a render while the call is in flight.)
|
|
2435
|
+
const promise = vault.createToken(options);
|
|
2436
|
+
notifyChange();
|
|
2437
|
+
try {
|
|
2438
|
+
const result = await promise;
|
|
2439
|
+
notifyTokenize();
|
|
2440
|
+
return result;
|
|
2441
|
+
}
|
|
2442
|
+
finally {
|
|
2443
|
+
notifyChange();
|
|
2444
|
+
}
|
|
2445
|
+
}, [vault, notifyTokenize, notifyChange]);
|
|
2431
2446
|
const createBankToken = useCallback(async (options) => {
|
|
2432
2447
|
if (!vault) {
|
|
2433
2448
|
return Promise.reject(new OzError('useOzElements must be called inside an <OzElements> provider.'));
|
|
2434
2449
|
}
|
|
2435
|
-
const
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2450
|
+
const promise = vault.createBankToken(options);
|
|
2451
|
+
notifyChange();
|
|
2452
|
+
try {
|
|
2453
|
+
const result = await promise;
|
|
2454
|
+
notifyTokenize();
|
|
2455
|
+
return result;
|
|
2456
|
+
}
|
|
2457
|
+
finally {
|
|
2458
|
+
notifyChange();
|
|
2459
|
+
}
|
|
2460
|
+
}, [vault, notifyTokenize, notifyChange]);
|
|
2439
2461
|
const reset = useCallback(() => {
|
|
2440
2462
|
vault === null || vault === void 0 ? void 0 : vault.reset();
|
|
2441
2463
|
}, [vault]);
|
|
@@ -2477,7 +2499,7 @@ function OzFieldBase({ type, variant, style, placeholder, disabled, loadTimeoutM
|
|
|
2477
2499
|
const elementRef = useRef(null);
|
|
2478
2500
|
const [loaded, setLoaded] = useState(false);
|
|
2479
2501
|
const [loadError, setLoadError] = useState(null);
|
|
2480
|
-
const { vault, notifyMount, notifyReady, notifyUnmount } = useContext(OzContext);
|
|
2502
|
+
const { vault, notifyMount, notifyReady, notifyUnmount, notifyChange } = useContext(OzContext);
|
|
2481
2503
|
const onChangeRef = useRef(onChange);
|
|
2482
2504
|
const onFocusRef = useRef(onFocus);
|
|
2483
2505
|
const onBlurRef = useRef(onBlur);
|
|
@@ -2509,7 +2531,7 @@ function OzFieldBase({ type, variant, style, placeholder, disabled, loadTimeoutM
|
|
|
2509
2531
|
notifyReady();
|
|
2510
2532
|
(_a = onReadyRef.current) === null || _a === void 0 ? void 0 : _a.call(onReadyRef);
|
|
2511
2533
|
});
|
|
2512
|
-
element.on('change', (e) => { var _a;
|
|
2534
|
+
element.on('change', (e) => { var _a; (_a = onChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onChangeRef, e); notifyChange(); });
|
|
2513
2535
|
element.on('focus', () => { var _a; return (_a = onFocusRef.current) === null || _a === void 0 ? void 0 : _a.call(onFocusRef); });
|
|
2514
2536
|
element.on('blur', () => { var _a; return (_a = onBlurRef.current) === null || _a === void 0 ? void 0 : _a.call(onBlurRef); });
|
|
2515
2537
|
element.on('loaderror', (e) => {
|