react-state-monad 1.0.21 → 1.0.23

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/index.cjs CHANGED
@@ -43,18 +43,17 @@ function useFieldState(state, field) {
43
43
  }
44
44
  function useRemapKeysState(state) {
45
45
  if (!state.hasValue) {
46
- return /* @__PURE__ */ new Map();
46
+ return {};
47
47
  }
48
48
  if (Array.isArray(state.value)) {
49
49
  console.warn("useRemapKeysState should be used with objects, use useRemapArray for arrays");
50
- return /* @__PURE__ */ new Map();
50
+ return {};
51
51
  }
52
52
  const keys = Object.keys(state.value);
53
- const map = /* @__PURE__ */ new Map();
54
- keys.forEach((key) => {
55
- map.set(key, useFieldState(state, key));
56
- });
57
- return map;
53
+ return keys.reduce((acc, key) => {
54
+ acc[key] = useFieldState(state, key);
55
+ return acc;
56
+ }, {});
58
57
  }
59
58
 
60
59
  // src/implementations/emptyState.ts
package/dist/index.d.cts CHANGED
@@ -79,15 +79,14 @@ type ValidFieldFrom<TObject, TField> = {
79
79
  */
80
80
  declare function useFieldState<TOriginal, TField>(state: StateObject<TOriginal>, field: ValidFieldFrom<TOriginal, TField>): StateObject<TField>;
81
81
  /**
82
- * Hook that remaps the keys of an object within a StateObject to a Map of StateObjects,
83
- * allowing for independent updates of each key while keeping the overall object state synchronized.
82
+ * Hook that remaps the keys of a state object to a record of StateObjects.
84
83
  *
85
84
  * @template TOriginal - The type of the original state object.
86
- * @param state - The StateObject containing the original object.
87
- * @returns A Map where each key is mapped to a new StateObject representing the value of that key,
88
- * allowing individual updates while keeping the object state synchronized.
85
+ * @template TField - The type of the field value to be derived.
86
+ * @param state - The StateObject containing the original state.
87
+ * @returns A record where each key is mapped to a new StateObject for the corresponding field.
89
88
  */
90
- declare function useRemapKeysState<TOriginal extends object, TField>(state: StateObject<TOriginal>): Map<string, StateObject<TField>>;
89
+ declare function useRemapKeysState<TOriginal extends object, TField>(state: StateObject<TOriginal>): Record<string, StateObject<TField>>;
91
90
 
92
91
  /**
93
92
  * Hook that allows you to derive and update a specific element in an array within a StateObject.
package/dist/index.d.ts CHANGED
@@ -79,15 +79,14 @@ type ValidFieldFrom<TObject, TField> = {
79
79
  */
80
80
  declare function useFieldState<TOriginal, TField>(state: StateObject<TOriginal>, field: ValidFieldFrom<TOriginal, TField>): StateObject<TField>;
81
81
  /**
82
- * Hook that remaps the keys of an object within a StateObject to a Map of StateObjects,
83
- * allowing for independent updates of each key while keeping the overall object state synchronized.
82
+ * Hook that remaps the keys of a state object to a record of StateObjects.
84
83
  *
85
84
  * @template TOriginal - The type of the original state object.
86
- * @param state - The StateObject containing the original object.
87
- * @returns A Map where each key is mapped to a new StateObject representing the value of that key,
88
- * allowing individual updates while keeping the object state synchronized.
85
+ * @template TField - The type of the field value to be derived.
86
+ * @param state - The StateObject containing the original state.
87
+ * @returns A record where each key is mapped to a new StateObject for the corresponding field.
89
88
  */
90
- declare function useRemapKeysState<TOriginal extends object, TField>(state: StateObject<TOriginal>): Map<string, StateObject<TField>>;
89
+ declare function useRemapKeysState<TOriginal extends object, TField>(state: StateObject<TOriginal>): Record<string, StateObject<TField>>;
91
90
 
92
91
  /**
93
92
  * Hook that allows you to derive and update a specific element in an array within a StateObject.
package/dist/index.js CHANGED
@@ -9,18 +9,17 @@ function useFieldState(state, field) {
9
9
  }
10
10
  function useRemapKeysState(state) {
11
11
  if (!state.hasValue) {
12
- return /* @__PURE__ */ new Map();
12
+ return {};
13
13
  }
14
14
  if (Array.isArray(state.value)) {
15
15
  console.warn("useRemapKeysState should be used with objects, use useRemapArray for arrays");
16
- return /* @__PURE__ */ new Map();
16
+ return {};
17
17
  }
18
18
  const keys = Object.keys(state.value);
19
- const map = /* @__PURE__ */ new Map();
20
- keys.forEach((key) => {
21
- map.set(key, useFieldState(state, key));
22
- });
23
- return map;
19
+ return keys.reduce((acc, key) => {
20
+ acc[key] = useFieldState(state, key);
21
+ return acc;
22
+ }, {});
24
23
  }
25
24
 
26
25
  // src/implementations/emptyState.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-state-monad",
3
3
  "type": "module",
4
- "version": "1.0.21",
4
+ "version": "1.0.23",
5
5
  "description": "A set of hooks to manage/transform/filter states with monads in React",
6
6
  "keywords": [
7
7
  "maybe",