@cripty2001/utils 0.0.161 → 0.0.163
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-whispr.d.ts +1 -1
- package/dist/react-whispr.js +7 -2
- package/package.json +1 -1
package/dist/react-whispr.d.ts
CHANGED
|
@@ -195,6 +195,6 @@ export type AsyncInputValue<C extends Record<string, JSONEncodable>, R extends R
|
|
|
195
195
|
*/
|
|
196
196
|
export declare function useAsyncInput<C extends Record<string, JSONEncodable>, R extends Record<string, JSONEncodable>>(value: AsyncInputValue<C, R>, setValue: (value: AsyncInputValue<C, R>) => void, handler: (config: C) => Promise<R>): [
|
|
197
197
|
value: C,
|
|
198
|
-
setValue: (
|
|
198
|
+
setValue: (updater: (draft: C) => C | void) => void,
|
|
199
199
|
result: R | null
|
|
200
200
|
];
|
package/dist/react-whispr.js
CHANGED
|
@@ -388,11 +388,16 @@ function useAsyncInput(value, setValue, handler) {
|
|
|
388
388
|
(0, react_1.useEffect)(() => {
|
|
389
389
|
if (result === null)
|
|
390
390
|
return;
|
|
391
|
+
if (result._meta.ts <= meta.ts)
|
|
392
|
+
return;
|
|
391
393
|
setValue(result);
|
|
392
394
|
}, [result, setValue]);
|
|
393
|
-
const returnedSetValue = (0, react_1.useCallback)((
|
|
395
|
+
const returnedSetValue = (0, react_1.useCallback)((updater) => {
|
|
396
|
+
const cloned = structuredClone(meta.config);
|
|
397
|
+
const new_data = updater(cloned);
|
|
398
|
+
const chosen = new_data ?? cloned;
|
|
394
399
|
setMeta({
|
|
395
|
-
config:
|
|
400
|
+
config: chosen,
|
|
396
401
|
ts: Date.now(),
|
|
397
402
|
});
|
|
398
403
|
}, [setMeta]);
|
package/package.json
CHANGED