cogsbox-state 0.5.448 → 0.5.449
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/CogsState.d.ts +4 -7
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.jsx +308 -304
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +17 -17
package/package.json
CHANGED
package/src/CogsState.tsx
CHANGED
|
@@ -689,26 +689,13 @@ export function createCogsStateFromSync<
|
|
|
689
689
|
string,
|
|
690
690
|
{
|
|
691
691
|
schemas: { defaultValues: any };
|
|
692
|
-
apiParamsSchema?: z.ZodObject<any>;
|
|
692
|
+
apiParamsSchema?: z.ZodObject<any>;
|
|
693
693
|
[key: string]: any;
|
|
694
694
|
}
|
|
695
695
|
>;
|
|
696
696
|
notifications: Record<string, any>;
|
|
697
697
|
},
|
|
698
|
-
>(
|
|
699
|
-
syncSchema: TSyncSchema
|
|
700
|
-
): CogsApi<
|
|
701
|
-
{
|
|
702
|
-
[K in keyof TSyncSchema['schemas']]: TSyncSchema['schemas'][K]['schemas']['defaultValues'];
|
|
703
|
-
},
|
|
704
|
-
{
|
|
705
|
-
[K in keyof TSyncSchema['schemas']]: TSyncSchema['schemas'][K]['apiParamsSchema'] extends z.ZodObject<
|
|
706
|
-
infer U
|
|
707
|
-
>
|
|
708
|
-
? { [P in keyof U]: z.infer<U[P]> }
|
|
709
|
-
: never;
|
|
710
|
-
}[keyof TSyncSchema['schemas']]
|
|
711
|
-
> {
|
|
698
|
+
>(syncSchema: TSyncSchema) {
|
|
712
699
|
const schemas = syncSchema.schemas;
|
|
713
700
|
const initialState: any = {};
|
|
714
701
|
|
|
@@ -718,11 +705,24 @@ export function createCogsStateFromSync<
|
|
|
718
705
|
initialState[key] = entry?.schemas?.defaultValues || {};
|
|
719
706
|
}
|
|
720
707
|
|
|
721
|
-
// Create the
|
|
722
|
-
|
|
708
|
+
// Create the base CogsApi
|
|
709
|
+
const baseApi = createCogsState(initialState, {
|
|
723
710
|
__fromSyncSchema: true,
|
|
724
711
|
__syncNotifications: syncSchema.notifications,
|
|
725
712
|
});
|
|
713
|
+
|
|
714
|
+
// Override the useCogsState function to handle apiParams properly
|
|
715
|
+
const useCogsState = <K extends keyof TSyncSchema['schemas']>(
|
|
716
|
+
stateKey: K,
|
|
717
|
+
options?: any // Just make this flexible
|
|
718
|
+
) => {
|
|
719
|
+
return baseApi.useCogsState(stateKey as any, options);
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
return {
|
|
723
|
+
useCogsState,
|
|
724
|
+
setCogsOptions: baseApi.setCogsOptions,
|
|
725
|
+
};
|
|
726
726
|
}
|
|
727
727
|
|
|
728
728
|
const {
|