@cripty2001/utils 0.0.160 → 0.0.162
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 +5 -3
- 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
|
@@ -375,7 +375,6 @@ function useAsyncInput(value, setValue, handler) {
|
|
|
375
375
|
// }
|
|
376
376
|
// }, [meta]);
|
|
377
377
|
const result_d = useAsync(async ({ config, ts }) => {
|
|
378
|
-
console.log("useAsyncInput", { config, ts });
|
|
379
378
|
const r = await handler(config);
|
|
380
379
|
return {
|
|
381
380
|
...r,
|
|
@@ -391,9 +390,12 @@ function useAsyncInput(value, setValue, handler) {
|
|
|
391
390
|
return;
|
|
392
391
|
setValue(result);
|
|
393
392
|
}, [result, setValue]);
|
|
394
|
-
const returnedSetValue = (0, react_1.useCallback)((
|
|
393
|
+
const returnedSetValue = (0, react_1.useCallback)((updater) => {
|
|
394
|
+
const cloned = structuredClone(meta.config);
|
|
395
|
+
const new_data = updater(cloned);
|
|
396
|
+
const chosen = new_data ?? cloned;
|
|
395
397
|
setMeta({
|
|
396
|
-
config:
|
|
398
|
+
config: chosen,
|
|
397
399
|
ts: Date.now(),
|
|
398
400
|
});
|
|
399
401
|
}, [setMeta]);
|
package/package.json
CHANGED