@juantroconisf/lib 5.1.0 → 5.2.0
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.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +7 -0
- package/dist/index.mjs +7 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SelectProps, AutocompleteProps } from '@heroui/react';
|
|
2
|
-
import { SingleSelection } from '@react-types/shared
|
|
2
|
+
import { SingleSelection } from '@react-types/shared';
|
|
3
3
|
|
|
4
4
|
type StateType = Record<string, any>;
|
|
5
5
|
interface NestedChangeProps<O extends StateType> {
|
|
@@ -161,6 +161,8 @@ interface HelpersFunc<O extends StateType> {
|
|
|
161
161
|
moveItem: <K extends ArrayKeys<O>>(arrayKey: K, from: number, to: number) => void;
|
|
162
162
|
/** Moves an item within an array using unique identifiers. */
|
|
163
163
|
moveById: <K extends ArrayKeys<O>>(arrayKey: K, fromId: string | number, toId: string | number) => void;
|
|
164
|
+
/** Gets an item from an array by its unique identifier (O(1) via indexMap). */
|
|
165
|
+
getItem: <K extends ArrayKeys<O>>(arrayKey: K, itemId: ItemIdType<O, K>) => ArrayElement<O[K]> | undefined;
|
|
164
166
|
}
|
|
165
167
|
/**
|
|
166
168
|
* The response object from the useForm hook.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SelectProps, AutocompleteProps } from '@heroui/react';
|
|
2
|
-
import { SingleSelection } from '@react-types/shared
|
|
2
|
+
import { SingleSelection } from '@react-types/shared';
|
|
3
3
|
|
|
4
4
|
type StateType = Record<string, any>;
|
|
5
5
|
interface NestedChangeProps<O extends StateType> {
|
|
@@ -161,6 +161,8 @@ interface HelpersFunc<O extends StateType> {
|
|
|
161
161
|
moveItem: <K extends ArrayKeys<O>>(arrayKey: K, from: number, to: number) => void;
|
|
162
162
|
/** Moves an item within an array using unique identifiers. */
|
|
163
163
|
moveById: <K extends ArrayKeys<O>>(arrayKey: K, fromId: string | number, toId: string | number) => void;
|
|
164
|
+
/** Gets an item from an array by its unique identifier (O(1) via indexMap). */
|
|
165
|
+
getItem: <K extends ArrayKeys<O>>(arrayKey: K, itemId: ItemIdType<O, K>) => ArrayElement<O[K]> | undefined;
|
|
164
166
|
}
|
|
165
167
|
/**
|
|
166
168
|
* The response object from the useForm hook.
|
package/dist/index.js
CHANGED
|
@@ -754,6 +754,13 @@ function useForm(initialState, {
|
|
|
754
754
|
arr[index] = value;
|
|
755
755
|
return { ...prev, [arrayKey]: arr };
|
|
756
756
|
});
|
|
757
|
+
},
|
|
758
|
+
getItem: (arrayKey, itemId) => {
|
|
759
|
+
const index = getIndex(String(arrayKey), itemId);
|
|
760
|
+
if (index !== void 0) {
|
|
761
|
+
return state[arrayKey][index];
|
|
762
|
+
}
|
|
763
|
+
return void 0;
|
|
757
764
|
}
|
|
758
765
|
},
|
|
759
766
|
isDirty: JSON.stringify(state) !== JSON.stringify(initialState),
|
package/dist/index.mjs
CHANGED
|
@@ -735,6 +735,13 @@ function useForm(initialState, {
|
|
|
735
735
|
arr[index] = value;
|
|
736
736
|
return { ...prev, [arrayKey]: arr };
|
|
737
737
|
});
|
|
738
|
+
},
|
|
739
|
+
getItem: (arrayKey, itemId) => {
|
|
740
|
+
const index = getIndex(String(arrayKey), itemId);
|
|
741
|
+
if (index !== void 0) {
|
|
742
|
+
return state[arrayKey][index];
|
|
743
|
+
}
|
|
744
|
+
return void 0;
|
|
738
745
|
}
|
|
739
746
|
},
|
|
740
747
|
isDirty: JSON.stringify(state) !== JSON.stringify(initialState),
|