cogsbox-state 0.5.482 → 0.5.483
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 -3
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.js +2 -2
- package/dist/CogsState.js.map +1 -1
- package/dist/CogsStateClient.d.ts +2 -2
- package/dist/CogsStateClient.d.ts.map +1 -1
- package/dist/CogsStateClient.js.map +1 -1
- package/dist/Components.d.ts +3 -3
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js.map +1 -1
- package/dist/PluginRunner.d.ts +2 -2
- package/dist/PluginRunner.d.ts.map +1 -1
- package/dist/PluginRunner.js +79 -78
- package/dist/PluginRunner.js.map +1 -1
- package/dist/pluginStore.d.ts +1 -0
- package/dist/pluginStore.d.ts.map +1 -1
- package/dist/pluginStore.js +22 -18
- package/dist/pluginStore.js.map +1 -1
- package/dist/plugins.d.ts +4 -4
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +37 -47
- package/src/CogsStateClient.tsx +2 -2
- package/src/Components.tsx +4 -3
- package/src/PluginRunner.tsx +31 -34
- package/src/pluginStore.ts +7 -1
- package/src/plugins.ts +5 -6
package/src/pluginStore.ts
CHANGED
|
@@ -39,6 +39,7 @@ export type ClientActivityEvent = {
|
|
|
39
39
|
type PluginRegistryStore = {
|
|
40
40
|
stateHandlers: Map<string, StateObject<any>>; // stateKey -> handler
|
|
41
41
|
registerStateHandler: (stateKey: string, handler: StateObject<any>) => void;
|
|
42
|
+
unregisterStateHandler: (stateKey: string) => void;
|
|
42
43
|
registeredPlugins: readonly CogsPlugin<any, any, any, any, any>[];
|
|
43
44
|
setRegisteredPlugins: (
|
|
44
45
|
plugins: readonly CogsPlugin<any, any, any, any, any>[]
|
|
@@ -78,7 +79,12 @@ export const pluginStore = create<PluginRegistryStore>((set, get) => ({
|
|
|
78
79
|
set((state) => {
|
|
79
80
|
const newMap = new Map(state.stateHandlers);
|
|
80
81
|
newMap.set(stateKey, handler);
|
|
81
|
-
|
|
82
|
+
return { stateHandlers: newMap };
|
|
83
|
+
}),
|
|
84
|
+
unregisterStateHandler: (stateKey) =>
|
|
85
|
+
set((state) => {
|
|
86
|
+
const newMap = new Map(state.stateHandlers);
|
|
87
|
+
newMap.delete(stateKey);
|
|
82
88
|
return { stateHandlers: newMap };
|
|
83
89
|
}),
|
|
84
90
|
registeredPlugins: [],
|
package/src/plugins.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type
|
|
2
|
+
import type { ReactNode, RefObject } from 'react';
|
|
3
3
|
import { StateObject, UpdateTypeDetail } from './CogsState';
|
|
4
4
|
import {
|
|
5
5
|
getGlobalStore,
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
setAllFieldsDisabled,
|
|
8
8
|
} from './store';
|
|
9
9
|
import { ClientActivityEvent } from './pluginStore';
|
|
10
|
-
import { RefObject } from 'react';
|
|
11
10
|
|
|
12
11
|
type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
13
12
|
|
|
@@ -228,7 +227,7 @@ export type FormWrapperParams<
|
|
|
228
227
|
TFieldMetaData,
|
|
229
228
|
TStateSlice = any,
|
|
230
229
|
> = ScopedMetadataMethods<TFieldMetaData> & {
|
|
231
|
-
element:
|
|
230
|
+
element: ReactNode;
|
|
232
231
|
path: string[];
|
|
233
232
|
stateKey: string;
|
|
234
233
|
options: TOptions;
|
|
@@ -307,7 +306,7 @@ export type CogsPlugin<
|
|
|
307
306
|
TFieldMetaData,
|
|
308
307
|
any
|
|
309
308
|
>
|
|
310
|
-
) =>
|
|
309
|
+
) => ReactNode;
|
|
311
310
|
|
|
312
311
|
chainMethods?: TChainMethods;
|
|
313
312
|
};
|
|
@@ -602,7 +601,7 @@ export type PluginFormWrapperFn<
|
|
|
602
601
|
TFieldMetaData,
|
|
603
602
|
any
|
|
604
603
|
>
|
|
605
|
-
) =>
|
|
604
|
+
) => ReactNode;
|
|
606
605
|
|
|
607
606
|
export type CogsPluginBuilder<
|
|
608
607
|
TName extends string,
|
|
@@ -774,7 +773,7 @@ export type CogsPluginBuilder<
|
|
|
774
773
|
true,
|
|
775
774
|
TNewState
|
|
776
775
|
>;
|
|
777
|
-
});
|
|
776
|
+
});
|
|
778
777
|
|
|
779
778
|
export type CreatePluginStart<
|
|
780
779
|
TName extends string,
|