revdev-components 0.31.0 → 0.33.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/build/hooks/api/index.d.ts +4 -0
- package/build/hooks/api/interfaces.d.ts +19 -0
- package/build/hooks/api/lazy-object.d.ts +2 -0
- package/build/hooks/api/lazy-query.d.ts +2 -0
- package/build/hooks/api/mutation.d.ts +2 -0
- package/build/hooks/index.d.ts +1 -0
- package/build/index.js +75 -0
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare enum ApiStatus {
|
|
2
|
+
Loading = 0,
|
|
3
|
+
Error = 1,
|
|
4
|
+
Success = 2,
|
|
5
|
+
NotFound = 3
|
|
6
|
+
}
|
|
7
|
+
export type ApiResponse<TResponse> = {
|
|
8
|
+
data?: TResponse;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
isSuccess: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type ApiRequestMethod<TRequest> = (request: TRequest) => void;
|
|
13
|
+
export interface ApiMutationResponse<TResponse, TRequest> {
|
|
14
|
+
request: ApiRequestMethod<TRequest>;
|
|
15
|
+
response?: TResponse;
|
|
16
|
+
status: ApiStatus;
|
|
17
|
+
}
|
|
18
|
+
export type ApiLazyQueryMethod<TResponse, TRequest> = () => readonly [ApiRequestMethod<TRequest>, ApiResponse<TResponse>, any];
|
|
19
|
+
export type ApiMutationMethod<TResponse, TRequest> = () => readonly [ApiRequestMethod<TRequest>, ApiResponse<TResponse>];
|
package/build/hooks/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -4754,6 +4754,78 @@ function useRouterQuery() {
|
|
|
4754
4754
|
return query;
|
|
4755
4755
|
}
|
|
4756
4756
|
|
|
4757
|
+
exports.ApiStatus = void 0;
|
|
4758
|
+
(function (ApiStatus) {
|
|
4759
|
+
ApiStatus[ApiStatus["Loading"] = 0] = "Loading";
|
|
4760
|
+
ApiStatus[ApiStatus["Error"] = 1] = "Error";
|
|
4761
|
+
ApiStatus[ApiStatus["Success"] = 2] = "Success";
|
|
4762
|
+
ApiStatus[ApiStatus["NotFound"] = 3] = "NotFound";
|
|
4763
|
+
})(exports.ApiStatus || (exports.ApiStatus = {}));
|
|
4764
|
+
|
|
4765
|
+
function useApiLazyQueryRequest(request, useLazyQuery) {
|
|
4766
|
+
var _a = React.useState(exports.ApiStatus.Loading), status = _a[0], setStatus = _a[1];
|
|
4767
|
+
var _b = useLazyQuery(), requestMethod = _b[0], responseObject = _b[1];
|
|
4768
|
+
React.useEffect(function () {
|
|
4769
|
+
if (request) {
|
|
4770
|
+
requestMethod(request);
|
|
4771
|
+
}
|
|
4772
|
+
}, [requestMethod, request]);
|
|
4773
|
+
React.useEffect(function () {
|
|
4774
|
+
if (responseObject.isSuccess) {
|
|
4775
|
+
var data = responseObject.data;
|
|
4776
|
+
if (data) {
|
|
4777
|
+
setStatus(exports.ApiStatus.Success);
|
|
4778
|
+
}
|
|
4779
|
+
else {
|
|
4780
|
+
setStatus(exports.ApiStatus.NotFound);
|
|
4781
|
+
}
|
|
4782
|
+
}
|
|
4783
|
+
}, [responseObject]);
|
|
4784
|
+
return [responseObject.data, status];
|
|
4785
|
+
}
|
|
4786
|
+
|
|
4787
|
+
function useApiLazyQuery(useLazyQuery, success) {
|
|
4788
|
+
var _a = React.useState(exports.ApiStatus.Loading), status = _a[0], setStatus = _a[1];
|
|
4789
|
+
var _b = useLazyQuery(), requestMethod = _b[0], responseObject = _b[1];
|
|
4790
|
+
React.useEffect(function () {
|
|
4791
|
+
if (responseObject.isSuccess) {
|
|
4792
|
+
var data = responseObject.data;
|
|
4793
|
+
if (data) {
|
|
4794
|
+
success === null || success === void 0 ? void 0 : success(data);
|
|
4795
|
+
}
|
|
4796
|
+
setStatus(exports.ApiStatus.Success);
|
|
4797
|
+
}
|
|
4798
|
+
}, [responseObject]);
|
|
4799
|
+
return React.useMemo(function () {
|
|
4800
|
+
return {
|
|
4801
|
+
request: requestMethod,
|
|
4802
|
+
response: responseObject.data,
|
|
4803
|
+
status: status,
|
|
4804
|
+
};
|
|
4805
|
+
}, [requestMethod, responseObject, status]);
|
|
4806
|
+
}
|
|
4807
|
+
|
|
4808
|
+
function useApiMutation(useMutation, success) {
|
|
4809
|
+
var _a = React.useState(exports.ApiStatus.Loading), status = _a[0], setStatus = _a[1];
|
|
4810
|
+
var _b = useMutation(), requestMethod = _b[0], responseObject = _b[1];
|
|
4811
|
+
React.useEffect(function () {
|
|
4812
|
+
if (responseObject.isSuccess) {
|
|
4813
|
+
var data = responseObject.data;
|
|
4814
|
+
if (data) {
|
|
4815
|
+
success === null || success === void 0 ? void 0 : success(data);
|
|
4816
|
+
}
|
|
4817
|
+
setStatus(exports.ApiStatus.Success);
|
|
4818
|
+
}
|
|
4819
|
+
}, [responseObject]);
|
|
4820
|
+
return React.useMemo(function () {
|
|
4821
|
+
return {
|
|
4822
|
+
request: requestMethod,
|
|
4823
|
+
response: responseObject.data,
|
|
4824
|
+
status: status,
|
|
4825
|
+
};
|
|
4826
|
+
}, [requestMethod, responseObject, status]);
|
|
4827
|
+
}
|
|
4828
|
+
|
|
4757
4829
|
var s$d = {"root":"index-module_root__f8fnA"};
|
|
4758
4830
|
|
|
4759
4831
|
var DivisionRow = function (_a) {
|
|
@@ -5013,6 +5085,9 @@ exports.SelectField = SelectField;
|
|
|
5013
5085
|
exports.SocialIcon = SocialIcon;
|
|
5014
5086
|
exports.SocialIconNameList = SocialIconNameList;
|
|
5015
5087
|
exports.TextAreaField = TextAreaField;
|
|
5088
|
+
exports.useApiLazyQuery = useApiLazyQuery;
|
|
5089
|
+
exports.useApiLazyQueryRequest = useApiLazyQueryRequest;
|
|
5090
|
+
exports.useApiMutation = useApiMutation;
|
|
5016
5091
|
exports.useAppFormRules = useAppFormRules;
|
|
5017
5092
|
exports.useDebounceEffect = useDebounceEffect;
|
|
5018
5093
|
exports.useDidMount = useDidMount;
|