@fluid-topics/ft-wc-utils 1.1.45 → 1.1.46

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.
@@ -22,15 +22,13 @@ export class FtReduxStore {
22
22
  });
23
23
  const reduxStore = configureStore({
24
24
  reducer: (state, action) => {
25
- var _a;
26
- switch (action.type) {
27
- case "CLEAR_FT_REDUX_STORE":
28
- return reduxSlice.getInitialState();
29
- case "DEFAULT_STATE_FIELDS_VALUES_SETTER":
30
- return { ...state, ...((_a = action.overwrites) !== null && _a !== void 0 ? _a : {}) };
31
- default:
32
- return reduxSlice.reducer(state, action);
25
+ if (action.type === "CLEAR_FT_REDUX_STORE") {
26
+ return reduxSlice.getInitialState();
33
27
  }
28
+ else if (typeof action.type === "string" && action.type.startsWith("DEFAULT_VALUE_SETTER__")) {
29
+ return { ...state, ...(action.overwrites) };
30
+ }
31
+ return reduxSlice.reducer(state, action);
34
32
  }
35
33
  });
36
34
  return window.ftReduxStores[options.name] = new FtReduxStore(reduxSlice, reduxStore);
@@ -43,9 +41,9 @@ export class FtReduxStore {
43
41
  this.commands = new FtCommandQueue();
44
42
  // Add proxy to automatically dispatch changes
45
43
  this.actions = new Proxy(this.reduxSlice.actions, {
46
- get: (target, p, receiver) => {
44
+ get: (actions, p, receiver) => {
47
45
  const actionName = p;
48
- const action = target[actionName];
46
+ const action = actions[actionName];
49
47
  if (action) {
50
48
  return (...args) => {
51
49
  const result = action(...args);
@@ -66,7 +64,7 @@ export class FtReduxStore {
66
64
  }
67
65
  setState(state) {
68
66
  this.reduxStore.dispatch({
69
- type: "DEFAULT_STATE_FIELDS_VALUES_SETTER",
67
+ type: "DEFAULT_VALUE_SETTER__" + Object.keys(state).join("_"),
70
68
  overwrites: state
71
69
  });
72
70
  }
@@ -19,9 +19,9 @@ export type DefaultStateReducer<State> = {
19
19
  [key in keyof State]: (state: State, payload: PayloadAction<State[key]>) => void;
20
20
  };
21
21
  export declare function isFtReduxStore<State, CR extends SliceCaseReducers<State>, A extends Action>(o: any): o is FtReduxStore<State, CR, A>;
22
- export type DefaultSetStateFieldsValuesAction = {
23
- type: "DEFAULT_STATE_FIELDS_VALUES_SETTER";
24
- overwrites: Record<string, any>;
22
+ export type DefaultValueSetterAction<State = any> = {
23
+ type: string;
24
+ overwrites: Partial<State>;
25
25
  };
26
26
  export type DefaultClearStoreAction = {
27
27
  type: "CLEAR_FT_REDUX_STORE";
@@ -34,5 +34,5 @@ export interface FtCreateReduxStoreOptions<State = any, CR extends SliceCaseRedu
34
34
  reducers?: ValidateSliceCaseReducers<State, CR>;
35
35
  extraReducers?: CreateSliceOptions<State>["extraReducers"];
36
36
  }
37
- export type FtReduxStoreActions<A> = A | DefaultSetStateFieldsValuesAction | DefaultClearStoreAction;
37
+ export type FtReduxStoreActions<A, State = any> = A | DefaultValueSetterAction<State> | DefaultClearStoreAction;
38
38
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-wc-utils",
3
- "version": "1.1.45",
3
+ "version": "1.1.46",
4
4
  "description": "Internal web components tools",
5
5
  "author": "Fluid Topics <devtopics@antidot.net>",
6
6
  "license": "ISC",
@@ -23,5 +23,5 @@
23
23
  "lit": "3.1.0",
24
24
  "mark.js": "8.11.1"
25
25
  },
26
- "gitHead": "6f166986bd8187f17e3d5a70f366596807be03c1"
26
+ "gitHead": "023f346e70fcbd9980c41b0c7ede0c199ca699bc"
27
27
  }