@faasjs/react 3.7.0-beta.9 → 3.7.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/README.md +3 -0
- package/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +10 -3
- package/dist/index.mjs +9 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -56,6 +56,7 @@ npm install @faasjs/react react
|
|
|
56
56
|
- [useEqualMemoize](functions/useEqualMemoize.md)
|
|
57
57
|
- [useFaas](functions/useFaas.md)
|
|
58
58
|
- [useFormContext](functions/useFormContext.md)
|
|
59
|
+
- [usePrevious](functions/usePrevious.md)
|
|
59
60
|
- [useSplittingState](functions/useSplittingState.md)
|
|
60
61
|
- [validValues](functions/validValues.md)
|
|
61
62
|
- [withFaasData](functions/withFaasData.md)
|
|
@@ -88,6 +89,7 @@ npm install @faasjs/react react
|
|
|
88
89
|
- [FormItemName](type-aliases/FormItemName.md)
|
|
89
90
|
- [FormItemProps](type-aliases/FormItemProps.md)
|
|
90
91
|
- [FormLabelElementProps](type-aliases/FormLabelElementProps.md)
|
|
92
|
+
- [FormLang](type-aliases/FormLang.md)
|
|
91
93
|
- [FormProps](type-aliases/FormProps.md)
|
|
92
94
|
- [FormRule](type-aliases/FormRule.md)
|
|
93
95
|
- [FormRules](type-aliases/FormRules.md)
|
|
@@ -101,4 +103,5 @@ npm install @faasjs/react react
|
|
|
101
103
|
## Variables
|
|
102
104
|
|
|
103
105
|
- [FormDefaultElements](variables/FormDefaultElements.md)
|
|
106
|
+
- [FormDefaultLang](variables/FormDefaultLang.md)
|
|
104
107
|
- [FormDefaultRules](variables/FormDefaultRules.md)
|
package/dist/index.d.mts
CHANGED
|
@@ -57,6 +57,14 @@ declare function useEqualMemo<T>(callback: () => T, dependencies: any[]): T;
|
|
|
57
57
|
* @returns The result of the `useCallback` hook with memoized dependencies.
|
|
58
58
|
*/
|
|
59
59
|
declare function useEqualCallback<T extends (...args: any[]) => any>(callback: T, dependencies: any[]): T;
|
|
60
|
+
/**
|
|
61
|
+
* Hook to store the previous value of a state or prop.
|
|
62
|
+
*
|
|
63
|
+
* @template T - The type of the value.
|
|
64
|
+
* @param {T} value - The current value to be stored.
|
|
65
|
+
* @returns {T | undefined} - The previous value, or undefined if there is no previous value.
|
|
66
|
+
*/
|
|
67
|
+
declare function usePrevious<T>(value: T): T | undefined;
|
|
60
68
|
|
|
61
69
|
/**
|
|
62
70
|
* Creates a splitting context with the given default value.
|
|
@@ -515,4 +523,4 @@ declare const FormContextProvider: <NewT extends FormContextProps<Record<string,
|
|
|
515
523
|
}) => react.ReactNode;
|
|
516
524
|
declare const useFormContext: <NewT extends FormContextProps<Record<string, any>, FormRules> = FormContextProps<Record<string, any>, FormRules>>() => Readonly<NewT>;
|
|
517
525
|
|
|
518
|
-
export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, FormContainer as Form, type FormButtonElementProps, type FormContextProps, FormContextProvider, FormDefaultElements, FormDefaultRules, type FormDefaultRulesOptions, type FormElementTypes, type FormInputElementProps, FormItem, type FormItemName, type FormItemProps, type FormLabelElementProps, type FormProps, type FormRule, type FormRules, type InferFormRulesOptions, type OnError, OptionalWrapper, type OptionalWrapperProps, createSplittingContext, equal, faas, getClient, useConstant, useEqualCallback, useEqualEffect, useEqualMemo, useEqualMemoize, useFaas, type useFaasOptions, useFormContext, useSplittingState, validValues, withFaasData };
|
|
526
|
+
export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, FormContainer as Form, type FormButtonElementProps, type FormContextProps, FormContextProvider, FormDefaultElements, FormDefaultLang, FormDefaultRules, type FormDefaultRulesOptions, type FormElementTypes, type FormInputElementProps, FormItem, type FormItemName, type FormItemProps, type FormLabelElementProps, type FormLang, type FormProps, type FormRule, type FormRules, type InferFormRulesOptions, type OnError, OptionalWrapper, type OptionalWrapperProps, createSplittingContext, equal, faas, getClient, useConstant, useEqualCallback, useEqualEffect, useEqualMemo, useEqualMemoize, useFaas, type useFaasOptions, useFormContext, usePrevious, useSplittingState, validValues, withFaasData };
|
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,14 @@ declare function useEqualMemo<T>(callback: () => T, dependencies: any[]): T;
|
|
|
57
57
|
* @returns The result of the `useCallback` hook with memoized dependencies.
|
|
58
58
|
*/
|
|
59
59
|
declare function useEqualCallback<T extends (...args: any[]) => any>(callback: T, dependencies: any[]): T;
|
|
60
|
+
/**
|
|
61
|
+
* Hook to store the previous value of a state or prop.
|
|
62
|
+
*
|
|
63
|
+
* @template T - The type of the value.
|
|
64
|
+
* @param {T} value - The current value to be stored.
|
|
65
|
+
* @returns {T | undefined} - The previous value, or undefined if there is no previous value.
|
|
66
|
+
*/
|
|
67
|
+
declare function usePrevious<T>(value: T): T | undefined;
|
|
60
68
|
|
|
61
69
|
/**
|
|
62
70
|
* Creates a splitting context with the given default value.
|
|
@@ -515,4 +523,4 @@ declare const FormContextProvider: <NewT extends FormContextProps<Record<string,
|
|
|
515
523
|
}) => react.ReactNode;
|
|
516
524
|
declare const useFormContext: <NewT extends FormContextProps<Record<string, any>, FormRules> = FormContextProps<Record<string, any>, FormRules>>() => Readonly<NewT>;
|
|
517
525
|
|
|
518
|
-
export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, FormContainer as Form, type FormButtonElementProps, type FormContextProps, FormContextProvider, FormDefaultElements, FormDefaultRules, type FormDefaultRulesOptions, type FormElementTypes, type FormInputElementProps, FormItem, type FormItemName, type FormItemProps, type FormLabelElementProps, type FormProps, type FormRule, type FormRules, type InferFormRulesOptions, type OnError, OptionalWrapper, type OptionalWrapperProps, createSplittingContext, equal, faas, getClient, useConstant, useEqualCallback, useEqualEffect, useEqualMemo, useEqualMemoize, useFaas, type useFaasOptions, useFormContext, useSplittingState, validValues, withFaasData };
|
|
526
|
+
export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, FormContainer as Form, type FormButtonElementProps, type FormContextProps, FormContextProvider, FormDefaultElements, FormDefaultLang, FormDefaultRules, type FormDefaultRulesOptions, type FormElementTypes, type FormInputElementProps, FormItem, type FormItemName, type FormItemProps, type FormLabelElementProps, type FormLang, type FormProps, type FormRule, type FormRules, type InferFormRulesOptions, type OnError, OptionalWrapper, type OptionalWrapperProps, createSplittingContext, equal, faas, getClient, useConstant, useEqualCallback, useEqualEffect, useEqualMemo, useEqualMemoize, useFaas, type useFaasOptions, useFormContext, usePrevious, useSplittingState, validValues, withFaasData };
|
package/dist/index.js
CHANGED
|
@@ -48,10 +48,8 @@ function equal(a, b) {
|
|
|
48
48
|
case Promise:
|
|
49
49
|
return a === b;
|
|
50
50
|
case Object: {
|
|
51
|
-
const
|
|
52
|
-
for (const key of keys) {
|
|
51
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]))
|
|
53
52
|
if (!equal(a[key], b[key])) return false;
|
|
54
|
-
}
|
|
55
53
|
return true;
|
|
56
54
|
}
|
|
57
55
|
default:
|
|
@@ -79,6 +77,13 @@ function useEqualCallback(callback, dependencies) {
|
|
|
79
77
|
useEqualMemoize(dependencies)
|
|
80
78
|
);
|
|
81
79
|
}
|
|
80
|
+
function usePrevious(value) {
|
|
81
|
+
const ref = react.useRef();
|
|
82
|
+
react.useEffect(() => {
|
|
83
|
+
ref.current = value;
|
|
84
|
+
});
|
|
85
|
+
return ref.current;
|
|
86
|
+
}
|
|
82
87
|
function useSplittingState(initialStates) {
|
|
83
88
|
const states = {};
|
|
84
89
|
for (const key of Object.keys(initialStates)) {
|
|
@@ -547,6 +552,7 @@ exports.FaasReactClient = FaasReactClient;
|
|
|
547
552
|
exports.Form = FormContainer;
|
|
548
553
|
exports.FormContextProvider = FormContextProvider;
|
|
549
554
|
exports.FormDefaultElements = FormDefaultElements;
|
|
555
|
+
exports.FormDefaultLang = FormDefaultLang;
|
|
550
556
|
exports.FormDefaultRules = FormDefaultRules;
|
|
551
557
|
exports.FormItem = FormItem;
|
|
552
558
|
exports.OptionalWrapper = OptionalWrapper;
|
|
@@ -561,6 +567,7 @@ exports.useEqualMemo = useEqualMemo;
|
|
|
561
567
|
exports.useEqualMemoize = useEqualMemoize;
|
|
562
568
|
exports.useFaas = useFaas;
|
|
563
569
|
exports.useFormContext = useFormContext;
|
|
570
|
+
exports.usePrevious = usePrevious;
|
|
564
571
|
exports.useSplittingState = useSplittingState;
|
|
565
572
|
exports.validValues = validValues;
|
|
566
573
|
exports.withFaasData = withFaasData;
|
package/dist/index.mjs
CHANGED
|
@@ -46,10 +46,8 @@ function equal(a, b) {
|
|
|
46
46
|
case Promise:
|
|
47
47
|
return a === b;
|
|
48
48
|
case Object: {
|
|
49
|
-
const
|
|
50
|
-
for (const key of keys) {
|
|
49
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]))
|
|
51
50
|
if (!equal(a[key], b[key])) return false;
|
|
52
|
-
}
|
|
53
51
|
return true;
|
|
54
52
|
}
|
|
55
53
|
default:
|
|
@@ -77,6 +75,13 @@ function useEqualCallback(callback, dependencies) {
|
|
|
77
75
|
useEqualMemoize(dependencies)
|
|
78
76
|
);
|
|
79
77
|
}
|
|
78
|
+
function usePrevious(value) {
|
|
79
|
+
const ref = useRef();
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
ref.current = value;
|
|
82
|
+
});
|
|
83
|
+
return ref.current;
|
|
84
|
+
}
|
|
80
85
|
function useSplittingState(initialStates) {
|
|
81
86
|
const states = {};
|
|
82
87
|
for (const key of Object.keys(initialStates)) {
|
|
@@ -539,4 +544,4 @@ function FormContainer({
|
|
|
539
544
|
FormContainer.displayName = "FormContainer";
|
|
540
545
|
FormContainer.whyDidYouRender = true;
|
|
541
546
|
|
|
542
|
-
export { ErrorBoundary, FaasDataWrapper, FaasReactClient, FormContainer as Form, FormContextProvider, FormDefaultElements, FormDefaultRules, FormItem, OptionalWrapper, createSplittingContext, equal, faas, getClient, useConstant, useEqualCallback, useEqualEffect, useEqualMemo, useEqualMemoize, useFaas, useFormContext, useSplittingState, validValues, withFaasData };
|
|
547
|
+
export { ErrorBoundary, FaasDataWrapper, FaasReactClient, FormContainer as Form, FormContextProvider, FormDefaultElements, FormDefaultLang, FormDefaultRules, FormItem, OptionalWrapper, createSplittingContext, equal, faas, getClient, useConstant, useEqualCallback, useEqualEffect, useEqualMemo, useEqualMemoize, useFaas, useFormContext, usePrevious, useSplittingState, validValues, withFaasData };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/react",
|
|
3
|
-
"version": "3.7.0
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@faasjs/browser": "3.7.0
|
|
37
|
+
"@faasjs/browser": "3.7.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@faasjs/browser": "3.7.0
|
|
40
|
+
"@faasjs/browser": "3.7.0",
|
|
41
41
|
"@types/react": "*",
|
|
42
42
|
"react": "*"
|
|
43
43
|
},
|