@gravity-ui/data-source 0.1.2 → 0.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/build/cjs/react/components/DataInfiniteLoader/DataInfiniteLoader.d.ts +1 -1
- package/build/cjs/react/components/DataInfiniteLoader/DataInfiniteLoader.js +12 -8
- package/build/cjs/react/components/DataInfiniteLoader/DataInfiniteLoader.js.map +1 -1
- package/build/cjs/react/components/DataInfiniteLoader/types.d.ts +7 -4
- package/build/cjs/react/components/DataInfiniteLoader/types.js.map +1 -1
- package/build/cjs/react/components/DataLoader/DataLoader.d.ts +1 -1
- package/build/cjs/react/components/DataLoader/DataLoader.js +6 -3
- package/build/cjs/react/components/DataLoader/DataLoader.js.map +1 -1
- package/build/cjs/react/components/DataLoader/types.d.ts +5 -3
- package/build/cjs/react/components/DataLoader/types.js.map +1 -1
- package/build/esm/react/components/DataInfiniteLoader/DataInfiniteLoader.d.ts +1 -1
- package/build/esm/react/components/DataInfiniteLoader/DataInfiniteLoader.js +12 -8
- package/build/esm/react/components/DataInfiniteLoader/DataInfiniteLoader.js.map +1 -1
- package/build/esm/react/components/DataInfiniteLoader/types.d.ts +7 -4
- package/build/esm/react/components/DataInfiniteLoader/types.js.map +1 -1
- package/build/esm/react/components/DataLoader/DataLoader.d.ts +1 -1
- package/build/esm/react/components/DataLoader/DataLoader.js +6 -3
- package/build/esm/react/components/DataLoader/DataLoader.js.map +1 -1
- package/build/esm/react/components/DataLoader/types.d.ts +5 -3
- package/build/esm/react/components/DataLoader/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { DataInfiniteLoaderProps } from './types';
|
|
3
|
-
export declare const DataInfiniteLoader: <TError>({ status, error, errorAction: errorActionProp, hasNextPage, fetchNextPage, isFetchingNextPage, LoadingView, ErrorView, MoreView, children, }: DataInfiniteLoaderProps<TError>) => React.ReactNode;
|
|
3
|
+
export declare const DataInfiniteLoader: <TError>({ status, error, errorAction: errorActionProp, hasNextPage, fetchNextPage, isFetchingNextPage, LoadingView, ErrorView, MoreView, loadingViewProps, errorViewProps, moreViewProps, children, }: DataInfiniteLoaderProps<TError>) => React.ReactNode;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DataInfiniteLoader = void 0;
|
|
7
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
7
8
|
var _react = _interopRequireDefault(require("react"));
|
|
8
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -17,32 +18,35 @@ var DataInfiniteLoader = exports.DataInfiniteLoader = function DataInfiniteLoade
|
|
|
17
18
|
LoadingView = _ref.LoadingView,
|
|
18
19
|
ErrorView = _ref.ErrorView,
|
|
19
20
|
MoreView = _ref.MoreView,
|
|
21
|
+
loadingViewProps = _ref.loadingViewProps,
|
|
22
|
+
errorViewProps = _ref.errorViewProps,
|
|
23
|
+
moreViewProps = _ref.moreViewProps,
|
|
20
24
|
children = _ref.children;
|
|
21
25
|
var errorAction = _react.default.useMemo(function () {
|
|
22
26
|
return typeof errorActionProp === 'function' ? {
|
|
23
27
|
handler: errorActionProp
|
|
24
28
|
} : errorActionProp;
|
|
25
29
|
}, [errorActionProp]);
|
|
26
|
-
var
|
|
30
|
+
var renderContent = function renderContent() {
|
|
27
31
|
if (status === 'loading') {
|
|
28
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(LoadingView, {});
|
|
32
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(LoadingView, (0, _objectSpread2.default)({}, loadingViewProps));
|
|
29
33
|
}
|
|
30
34
|
if (status === 'error') {
|
|
31
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ErrorView, {
|
|
35
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ErrorView, (0, _objectSpread2.default)({
|
|
32
36
|
error: error,
|
|
33
37
|
action: errorAction
|
|
34
|
-
});
|
|
38
|
+
}, errorViewProps));
|
|
35
39
|
}
|
|
36
40
|
if (status === 'success' && hasNextPage) {
|
|
37
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(MoreView, {
|
|
41
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(MoreView, (0, _objectSpread2.default)({
|
|
38
42
|
isLoading: isFetchingNextPage,
|
|
39
43
|
onClick: fetchNextPage
|
|
40
|
-
});
|
|
44
|
+
}, moreViewProps));
|
|
41
45
|
}
|
|
42
46
|
return null;
|
|
43
|
-
}
|
|
47
|
+
};
|
|
44
48
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
45
|
-
children: [status === 'success' ? children : null,
|
|
49
|
+
children: [status === 'success' ? children : null, renderContent()]
|
|
46
50
|
});
|
|
47
51
|
};
|
|
48
52
|
// #sourceMappingURL=DataInfiniteLoader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_jsxRuntime","e","__esModule","default","DataInfiniteLoader","exports","_ref","status","error","errorActionProp","errorAction","hasNextPage","fetchNextPage","isFetchingNextPage","LoadingView","ErrorView","MoreView","children","React","useMemo","handler","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_jsxRuntime","e","__esModule","default","DataInfiniteLoader","exports","_ref","status","error","errorActionProp","errorAction","hasNextPage","fetchNextPage","isFetchingNextPage","LoadingView","ErrorView","MoreView","loadingViewProps","errorViewProps","moreViewProps","children","React","useMemo","handler","renderContent","_jsx","_objectSpread","action","isLoading","onClick","_jsxs","_Fragment"],"sources":["DataInfiniteLoader.tsx"],"sourcesContent":["import React from 'react';\n\nimport type {ErrorViewProps} from '../types';\n\nimport type {DataInfiniteLoaderProps} from './types';\n\nexport const DataInfiniteLoader = <TError,>({\n status,\n error,\n errorAction: errorActionProp,\n hasNextPage,\n fetchNextPage,\n isFetchingNextPage,\n LoadingView,\n ErrorView,\n MoreView,\n loadingViewProps,\n errorViewProps,\n moreViewProps,\n children,\n}: DataInfiniteLoaderProps<TError>): React.ReactNode => {\n const errorAction = React.useMemo<ErrorViewProps<TError>['action']>(\n () =>\n typeof errorActionProp === 'function' ? {handler: errorActionProp} : errorActionProp,\n [errorActionProp],\n );\n\n const renderContent = () => {\n if (status === 'loading') {\n return <LoadingView {...loadingViewProps} />;\n }\n\n if (status === 'error') {\n return <ErrorView error={error} action={errorAction} {...errorViewProps} />;\n }\n\n if (status === 'success' && hasNextPage) {\n return (\n <MoreView\n isLoading={isFetchingNextPage}\n onClick={fetchNextPage}\n {...moreViewProps}\n />\n );\n }\n\n return null;\n };\n\n return (\n <>\n {status === 'success' ? children : null}\n {renderContent()}\n </>\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,IAAAC,WAAA,GAAAD,OAAA;AAAA,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAMnB,IAAMG,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,SAArBA,kBAAkBA,CAAAE,IAAA,EAcyB;EAAA,IAbpDC,MAAM,GAAAD,IAAA,CAANC,MAAM;IACNC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACQC,eAAe,GAAAH,IAAA,CAA5BI,WAAW;IACXC,WAAW,GAAAL,IAAA,CAAXK,WAAW;IACXC,aAAa,GAAAN,IAAA,CAAbM,aAAa;IACbC,kBAAkB,GAAAP,IAAA,CAAlBO,kBAAkB;IAClBC,WAAW,GAAAR,IAAA,CAAXQ,WAAW;IACXC,SAAS,GAAAT,IAAA,CAATS,SAAS;IACTC,QAAQ,GAAAV,IAAA,CAARU,QAAQ;IACRC,gBAAgB,GAAAX,IAAA,CAAhBW,gBAAgB;IAChBC,cAAc,GAAAZ,IAAA,CAAdY,cAAc;IACdC,aAAa,GAAAb,IAAA,CAAba,aAAa;IACbC,QAAQ,GAAAd,IAAA,CAARc,QAAQ;EAER,IAAMV,WAAW,GAAGW,cAAK,CAACC,OAAO,CAC7B;IAAA,OACI,OAAOb,eAAe,KAAK,UAAU,GAAG;MAACc,OAAO,EAAEd;IAAe,CAAC,GAAGA,eAAe;EAAA,GACxF,CAACA,eAAe,CACpB,CAAC;EAED,IAAMe,aAAa,GAAG,SAAhBA,aAAaA,CAAA,EAAS;IACxB,IAAIjB,MAAM,KAAK,SAAS,EAAE;MACtB,oBAAO,IAAAkB,eAAA,EAACX,WAAW,MAAAY,sBAAA,MAAKT,gBAAgB,CAAG,CAAC;IAChD;IAEA,IAAIV,MAAM,KAAK,OAAO,EAAE;MACpB,oBAAO,IAAAkB,eAAA,EAACV,SAAS,MAAAW,sBAAA;QAAClB,KAAK,EAAEA,KAAM;QAACmB,MAAM,EAAEjB;MAAY,GAAKQ,cAAc,CAAG,CAAC;IAC/E;IAEA,IAAIX,MAAM,KAAK,SAAS,IAAII,WAAW,EAAE;MACrC,oBACI,IAAAc,eAAA,EAACT,QAAQ,MAAAU,sBAAA;QACLE,SAAS,EAAEf,kBAAmB;QAC9BgB,OAAO,EAAEjB;MAAc,GACnBO,aAAa,CACpB,CAAC;IAEV;IAEA,OAAO,IAAI;EACf,CAAC;EAED,oBACI,IAAAW,gBAAA,EAAAC,oBAAA;IAAAX,QAAA,GACKb,MAAM,KAAK,SAAS,GAAGa,QAAQ,GAAG,IAAI,EACtCI,aAAa,CAAC,CAAC;EAAA,CAClB,CAAC;AAEX,CAAC","ignoreList":[]}
|
|
@@ -5,15 +5,18 @@ export interface MoreViewProps {
|
|
|
5
5
|
isLoading: boolean;
|
|
6
6
|
onClick: () => void;
|
|
7
7
|
}
|
|
8
|
-
export interface DataInfiniteLoaderProps<TError> {
|
|
8
|
+
export interface DataInfiniteLoaderProps<TError, TLoadingViewProps extends {} = {}, TErrorViewProps extends ErrorViewProps<TError> = ErrorViewProps<TError>, TMoreViewProps extends MoreViewProps = MoreViewProps> {
|
|
9
9
|
status: DataLoaderStatus;
|
|
10
10
|
error: TError | null;
|
|
11
11
|
errorAction?: ErrorAction | ErrorAction['handler'];
|
|
12
12
|
hasNextPage: boolean;
|
|
13
13
|
fetchNextPage: () => unknown;
|
|
14
14
|
isFetchingNextPage: boolean;
|
|
15
|
-
LoadingView: ComponentType
|
|
16
|
-
ErrorView: ComponentType<
|
|
17
|
-
MoreView: ComponentType<
|
|
15
|
+
LoadingView: ComponentType<TLoadingViewProps>;
|
|
16
|
+
ErrorView: ComponentType<TErrorViewProps>;
|
|
17
|
+
MoreView: ComponentType<TMoreViewProps>;
|
|
18
|
+
loadingViewProps?: TLoadingViewProps;
|
|
19
|
+
errorViewProps?: Omit<TErrorViewProps, keyof ErrorViewProps<TError>>;
|
|
20
|
+
moreViewProps?: Omit<TMoreViewProps, keyof MoreViewProps>;
|
|
18
21
|
children: ReactNode;
|
|
19
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {ComponentType, ReactNode} from 'react';\n\nimport type {DataLoaderStatus} from '../../../core';\nimport type {ErrorAction, ErrorViewProps} from '../types';\n\nexport interface MoreViewProps {\n isLoading: boolean;\n onClick: () => void;\n}\n\nexport interface DataInfiniteLoaderProps<TError> {\n status: DataLoaderStatus;\n error: TError | null;\n errorAction?: ErrorAction | ErrorAction['handler'];\n hasNextPage: boolean;\n fetchNextPage: () => unknown;\n isFetchingNextPage: boolean;\n LoadingView: ComponentType
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {ComponentType, ReactNode} from 'react';\n\nimport type {DataLoaderStatus} from '../../../core';\nimport type {ErrorAction, ErrorViewProps} from '../types';\n\nexport interface MoreViewProps {\n isLoading: boolean;\n onClick: () => void;\n}\n\nexport interface DataInfiniteLoaderProps<\n TError,\n TLoadingViewProps extends {} = {},\n TErrorViewProps extends ErrorViewProps<TError> = ErrorViewProps<TError>,\n TMoreViewProps extends MoreViewProps = MoreViewProps,\n> {\n status: DataLoaderStatus;\n error: TError | null;\n errorAction?: ErrorAction | ErrorAction['handler'];\n hasNextPage: boolean;\n fetchNextPage: () => unknown;\n isFetchingNextPage: boolean;\n LoadingView: ComponentType<TLoadingViewProps>;\n ErrorView: ComponentType<TErrorViewProps>;\n MoreView: ComponentType<TMoreViewProps>;\n loadingViewProps?: TLoadingViewProps;\n errorViewProps?: Omit<TErrorViewProps, keyof ErrorViewProps<TError>>;\n moreViewProps?: Omit<TMoreViewProps, keyof MoreViewProps>;\n children: ReactNode;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { DataLoaderProps } from './types';
|
|
3
|
-
export declare const DataLoader: <TError>({ status, error, errorAction: errorActionProp, LoadingView, ErrorView, children, }: DataLoaderProps<TError>) => React.ReactNode;
|
|
3
|
+
export declare const DataLoader: <TError>({ status, error, errorAction: errorActionProp, LoadingView, ErrorView, loadingViewProps, errorViewProps, children, }: DataLoaderProps<TError>) => React.ReactNode;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DataLoader = void 0;
|
|
7
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
7
8
|
var _react = _interopRequireDefault(require("react"));
|
|
8
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -13,6 +14,8 @@ var DataLoader = exports.DataLoader = function DataLoader(_ref) {
|
|
|
13
14
|
errorActionProp = _ref.errorAction,
|
|
14
15
|
LoadingView = _ref.LoadingView,
|
|
15
16
|
ErrorView = _ref.ErrorView,
|
|
17
|
+
loadingViewProps = _ref.loadingViewProps,
|
|
18
|
+
errorViewProps = _ref.errorViewProps,
|
|
16
19
|
children = _ref.children;
|
|
17
20
|
var errorAction = _react.default.useMemo(function () {
|
|
18
21
|
return typeof errorActionProp === 'function' ? {
|
|
@@ -20,13 +23,13 @@ var DataLoader = exports.DataLoader = function DataLoader(_ref) {
|
|
|
20
23
|
} : errorActionProp;
|
|
21
24
|
}, [errorActionProp]);
|
|
22
25
|
if (status === 'loading') {
|
|
23
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(LoadingView, {});
|
|
26
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(LoadingView, (0, _objectSpread2.default)({}, loadingViewProps));
|
|
24
27
|
}
|
|
25
28
|
if (status === 'error') {
|
|
26
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ErrorView, {
|
|
29
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ErrorView, (0, _objectSpread2.default)({
|
|
27
30
|
error: error,
|
|
28
31
|
action: errorAction
|
|
29
|
-
});
|
|
32
|
+
}, errorViewProps));
|
|
30
33
|
}
|
|
31
34
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
32
35
|
children: children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_jsxRuntime","e","__esModule","default","DataLoader","exports","_ref","status","error","errorActionProp","errorAction","LoadingView","ErrorView","children","React","useMemo","handler","_jsx","action","_Fragment"],"sources":["DataLoader.tsx"],"sourcesContent":["import React from 'react';\n\nimport type {ErrorViewProps} from '../types';\n\nimport type {DataLoaderProps} from './types';\n\nexport const DataLoader = <TError,>({\n status,\n error,\n errorAction: errorActionProp,\n LoadingView,\n ErrorView,\n children,\n}: DataLoaderProps<TError>): React.ReactNode => {\n const errorAction = React.useMemo<ErrorViewProps<TError>['action']>(\n () =>\n typeof errorActionProp === 'function' ? {handler: errorActionProp} : errorActionProp,\n [errorActionProp],\n );\n\n if (status === 'loading') {\n return <LoadingView />;\n }\n\n if (status === 'error') {\n return <ErrorView error={error} action={errorAction} />;\n }\n\n return <>{children}</>;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_jsxRuntime","e","__esModule","default","DataLoader","exports","_ref","status","error","errorActionProp","errorAction","LoadingView","ErrorView","loadingViewProps","errorViewProps","children","React","useMemo","handler","_jsx","_objectSpread","action","_Fragment"],"sources":["DataLoader.tsx"],"sourcesContent":["import React from 'react';\n\nimport type {ErrorViewProps} from '../types';\n\nimport type {DataLoaderProps} from './types';\n\nexport const DataLoader = <TError,>({\n status,\n error,\n errorAction: errorActionProp,\n LoadingView,\n ErrorView,\n loadingViewProps,\n errorViewProps,\n children,\n}: DataLoaderProps<TError>): React.ReactNode => {\n const errorAction = React.useMemo<ErrorViewProps<TError>['action']>(\n () =>\n typeof errorActionProp === 'function' ? {handler: errorActionProp} : errorActionProp,\n [errorActionProp],\n );\n\n if (status === 'loading') {\n return <LoadingView {...loadingViewProps} />;\n }\n\n if (status === 'error') {\n return <ErrorView error={error} action={errorAction} {...errorViewProps} />;\n }\n\n return <>{children}</>;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,IAAAC,WAAA,GAAAD,OAAA;AAAA,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAMnB,IAAMG,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,SAAbA,UAAUA,CAAAE,IAAA,EASyB;EAAA,IAR5CC,MAAM,GAAAD,IAAA,CAANC,MAAM;IACNC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACQC,eAAe,GAAAH,IAAA,CAA5BI,WAAW;IACXC,WAAW,GAAAL,IAAA,CAAXK,WAAW;IACXC,SAAS,GAAAN,IAAA,CAATM,SAAS;IACTC,gBAAgB,GAAAP,IAAA,CAAhBO,gBAAgB;IAChBC,cAAc,GAAAR,IAAA,CAAdQ,cAAc;IACdC,QAAQ,GAAAT,IAAA,CAARS,QAAQ;EAER,IAAML,WAAW,GAAGM,cAAK,CAACC,OAAO,CAC7B;IAAA,OACI,OAAOR,eAAe,KAAK,UAAU,GAAG;MAACS,OAAO,EAAET;IAAe,CAAC,GAAGA,eAAe;EAAA,GACxF,CAACA,eAAe,CACpB,CAAC;EAED,IAAIF,MAAM,KAAK,SAAS,EAAE;IACtB,oBAAO,IAAAY,eAAA,EAACR,WAAW,MAAAS,sBAAA,MAAKP,gBAAgB,CAAG,CAAC;EAChD;EAEA,IAAIN,MAAM,KAAK,OAAO,EAAE;IACpB,oBAAO,IAAAY,eAAA,EAACP,SAAS,MAAAQ,sBAAA;MAACZ,KAAK,EAAEA,KAAM;MAACa,MAAM,EAAEX;IAAY,GAAKI,cAAc,CAAG,CAAC;EAC/E;EAEA,oBAAO,IAAAK,eAAA,EAAAG,oBAAA;IAAAP,QAAA,EAAGA;EAAQ,CAAG,CAAC;AAC1B,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ComponentType, ReactNode } from 'react';
|
|
2
2
|
import type { DataLoaderStatus } from '../../../core';
|
|
3
3
|
import type { ErrorAction, ErrorViewProps } from '../types';
|
|
4
|
-
export interface DataLoaderProps<TError> {
|
|
4
|
+
export interface DataLoaderProps<TError, TLoadingViewProps extends {} = {}, TErrorViewProps extends ErrorViewProps<TError> = ErrorViewProps<TError>> {
|
|
5
5
|
status: DataLoaderStatus;
|
|
6
6
|
error: TError | null;
|
|
7
7
|
errorAction?: ErrorAction | ErrorAction['handler'];
|
|
8
|
-
LoadingView: ComponentType
|
|
9
|
-
ErrorView: ComponentType<
|
|
8
|
+
LoadingView: ComponentType<TLoadingViewProps>;
|
|
9
|
+
ErrorView: ComponentType<TErrorViewProps>;
|
|
10
|
+
loadingViewProps?: TLoadingViewProps;
|
|
11
|
+
errorViewProps?: Omit<TErrorViewProps, keyof ErrorViewProps<TError>>;
|
|
10
12
|
children: ReactNode;
|
|
11
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {ComponentType, ReactNode} from 'react';\n\nimport type {DataLoaderStatus} from '../../../core';\nimport type {ErrorAction, ErrorViewProps} from '../types';\n\nexport interface DataLoaderProps<TError> {\n status: DataLoaderStatus;\n error: TError | null;\n errorAction?: ErrorAction | ErrorAction['handler'];\n LoadingView: ComponentType
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {ComponentType, ReactNode} from 'react';\n\nimport type {DataLoaderStatus} from '../../../core';\nimport type {ErrorAction, ErrorViewProps} from '../types';\n\nexport interface DataLoaderProps<\n TError,\n TLoadingViewProps extends {} = {},\n TErrorViewProps extends ErrorViewProps<TError> = ErrorViewProps<TError>,\n> {\n status: DataLoaderStatus;\n error: TError | null;\n errorAction?: ErrorAction | ErrorAction['handler'];\n LoadingView: ComponentType<TLoadingViewProps>;\n ErrorView: ComponentType<TErrorViewProps>;\n loadingViewProps?: TLoadingViewProps;\n errorViewProps?: Omit<TErrorViewProps, keyof ErrorViewProps<TError>>;\n children: ReactNode;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { DataInfiniteLoaderProps } from './types';
|
|
3
|
-
export declare const DataInfiniteLoader: <TError>({ status, error, errorAction: errorActionProp, hasNextPage, fetchNextPage, isFetchingNextPage, LoadingView, ErrorView, MoreView, children, }: DataInfiniteLoaderProps<TError>) => React.ReactNode;
|
|
3
|
+
export declare const DataInfiniteLoader: <TError>({ status, error, errorAction: errorActionProp, hasNextPage, fetchNextPage, isFetchingNextPage, LoadingView, ErrorView, MoreView, loadingViewProps, errorViewProps, moreViewProps, children, }: DataInfiniteLoaderProps<TError>) => React.ReactNode;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
4
|
export var DataInfiniteLoader = function DataInfiniteLoader(_ref) {
|
|
@@ -10,32 +11,35 @@ export var DataInfiniteLoader = function DataInfiniteLoader(_ref) {
|
|
|
10
11
|
LoadingView = _ref.LoadingView,
|
|
11
12
|
ErrorView = _ref.ErrorView,
|
|
12
13
|
MoreView = _ref.MoreView,
|
|
14
|
+
loadingViewProps = _ref.loadingViewProps,
|
|
15
|
+
errorViewProps = _ref.errorViewProps,
|
|
16
|
+
moreViewProps = _ref.moreViewProps,
|
|
13
17
|
children = _ref.children;
|
|
14
18
|
var errorAction = React.useMemo(function () {
|
|
15
19
|
return typeof errorActionProp === 'function' ? {
|
|
16
20
|
handler: errorActionProp
|
|
17
21
|
} : errorActionProp;
|
|
18
22
|
}, [errorActionProp]);
|
|
19
|
-
var
|
|
23
|
+
var renderContent = function renderContent() {
|
|
20
24
|
if (status === 'loading') {
|
|
21
|
-
return /*#__PURE__*/_jsx(LoadingView, {});
|
|
25
|
+
return /*#__PURE__*/_jsx(LoadingView, _objectSpread({}, loadingViewProps));
|
|
22
26
|
}
|
|
23
27
|
if (status === 'error') {
|
|
24
|
-
return /*#__PURE__*/_jsx(ErrorView, {
|
|
28
|
+
return /*#__PURE__*/_jsx(ErrorView, _objectSpread({
|
|
25
29
|
error: error,
|
|
26
30
|
action: errorAction
|
|
27
|
-
});
|
|
31
|
+
}, errorViewProps));
|
|
28
32
|
}
|
|
29
33
|
if (status === 'success' && hasNextPage) {
|
|
30
|
-
return /*#__PURE__*/_jsx(MoreView, {
|
|
34
|
+
return /*#__PURE__*/_jsx(MoreView, _objectSpread({
|
|
31
35
|
isLoading: isFetchingNextPage,
|
|
32
36
|
onClick: fetchNextPage
|
|
33
|
-
});
|
|
37
|
+
}, moreViewProps));
|
|
34
38
|
}
|
|
35
39
|
return null;
|
|
36
|
-
}
|
|
40
|
+
};
|
|
37
41
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
38
|
-
children: [status === 'success' ? children : null,
|
|
42
|
+
children: [status === 'success' ? children : null, renderContent()]
|
|
39
43
|
});
|
|
40
44
|
};
|
|
41
45
|
// #sourceMappingURL=DataInfiniteLoader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","DataInfiniteLoader","_ref","status","error","errorActionProp","errorAction","hasNextPage","fetchNextPage","isFetchingNextPage","LoadingView","ErrorView","MoreView","children","useMemo","handler","
|
|
1
|
+
{"version":3,"names":["React","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","DataInfiniteLoader","_ref","status","error","errorActionProp","errorAction","hasNextPage","fetchNextPage","isFetchingNextPage","LoadingView","ErrorView","MoreView","loadingViewProps","errorViewProps","moreViewProps","children","useMemo","handler","renderContent","_objectSpread","action","isLoading","onClick"],"sources":["DataInfiniteLoader.tsx"],"sourcesContent":["import React from 'react';\n\nimport type {ErrorViewProps} from '../types';\n\nimport type {DataInfiniteLoaderProps} from './types';\n\nexport const DataInfiniteLoader = <TError,>({\n status,\n error,\n errorAction: errorActionProp,\n hasNextPage,\n fetchNextPage,\n isFetchingNextPage,\n LoadingView,\n ErrorView,\n MoreView,\n loadingViewProps,\n errorViewProps,\n moreViewProps,\n children,\n}: DataInfiniteLoaderProps<TError>): React.ReactNode => {\n const errorAction = React.useMemo<ErrorViewProps<TError>['action']>(\n () =>\n typeof errorActionProp === 'function' ? {handler: errorActionProp} : errorActionProp,\n [errorActionProp],\n );\n\n const renderContent = () => {\n if (status === 'loading') {\n return <LoadingView {...loadingViewProps} />;\n }\n\n if (status === 'error') {\n return <ErrorView error={error} action={errorAction} {...errorViewProps} />;\n }\n\n if (status === 'success' && hasNextPage) {\n return (\n <MoreView\n isLoading={isFetchingNextPage}\n onClick={fetchNextPage}\n {...moreViewProps}\n />\n );\n }\n\n return null;\n };\n\n return (\n <>\n {status === 'success' ? children : null}\n {renderContent()}\n </>\n );\n};\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAM1B,OAAO,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAAC,IAAA,EAcyB;EAAA,IAbpDC,MAAM,GAAAD,IAAA,CAANC,MAAM;IACNC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACQC,eAAe,GAAAH,IAAA,CAA5BI,WAAW;IACXC,WAAW,GAAAL,IAAA,CAAXK,WAAW;IACXC,aAAa,GAAAN,IAAA,CAAbM,aAAa;IACbC,kBAAkB,GAAAP,IAAA,CAAlBO,kBAAkB;IAClBC,WAAW,GAAAR,IAAA,CAAXQ,WAAW;IACXC,SAAS,GAAAT,IAAA,CAATS,SAAS;IACTC,QAAQ,GAAAV,IAAA,CAARU,QAAQ;IACRC,gBAAgB,GAAAX,IAAA,CAAhBW,gBAAgB;IAChBC,cAAc,GAAAZ,IAAA,CAAdY,cAAc;IACdC,aAAa,GAAAb,IAAA,CAAba,aAAa;IACbC,QAAQ,GAAAd,IAAA,CAARc,QAAQ;EAER,IAAMV,WAAW,GAAGZ,KAAK,CAACuB,OAAO,CAC7B;IAAA,OACI,OAAOZ,eAAe,KAAK,UAAU,GAAG;MAACa,OAAO,EAAEb;IAAe,CAAC,GAAGA,eAAe;EAAA,GACxF,CAACA,eAAe,CACpB,CAAC;EAED,IAAMc,aAAa,GAAG,SAAhBA,aAAaA,CAAA,EAAS;IACxB,IAAIhB,MAAM,KAAK,SAAS,EAAE;MACtB,oBAAOP,IAAA,CAACc,WAAW,EAAAU,aAAA,KAAKP,gBAAgB,CAAG,CAAC;IAChD;IAEA,IAAIV,MAAM,KAAK,OAAO,EAAE;MACpB,oBAAOP,IAAA,CAACe,SAAS,EAAAS,aAAA;QAAChB,KAAK,EAAEA,KAAM;QAACiB,MAAM,EAAEf;MAAY,GAAKQ,cAAc,CAAG,CAAC;IAC/E;IAEA,IAAIX,MAAM,KAAK,SAAS,IAAII,WAAW,EAAE;MACrC,oBACIX,IAAA,CAACgB,QAAQ,EAAAQ,aAAA;QACLE,SAAS,EAAEb,kBAAmB;QAC9Bc,OAAO,EAAEf;MAAc,GACnBO,aAAa,CACpB,CAAC;IAEV;IAEA,OAAO,IAAI;EACf,CAAC;EAED,oBACIf,KAAA,CAAAF,SAAA;IAAAkB,QAAA,GACKb,MAAM,KAAK,SAAS,GAAGa,QAAQ,GAAG,IAAI,EACtCG,aAAa,CAAC,CAAC;EAAA,CAClB,CAAC;AAEX,CAAC","ignoreList":[]}
|
|
@@ -5,15 +5,18 @@ export interface MoreViewProps {
|
|
|
5
5
|
isLoading: boolean;
|
|
6
6
|
onClick: () => void;
|
|
7
7
|
}
|
|
8
|
-
export interface DataInfiniteLoaderProps<TError> {
|
|
8
|
+
export interface DataInfiniteLoaderProps<TError, TLoadingViewProps extends {} = {}, TErrorViewProps extends ErrorViewProps<TError> = ErrorViewProps<TError>, TMoreViewProps extends MoreViewProps = MoreViewProps> {
|
|
9
9
|
status: DataLoaderStatus;
|
|
10
10
|
error: TError | null;
|
|
11
11
|
errorAction?: ErrorAction | ErrorAction['handler'];
|
|
12
12
|
hasNextPage: boolean;
|
|
13
13
|
fetchNextPage: () => unknown;
|
|
14
14
|
isFetchingNextPage: boolean;
|
|
15
|
-
LoadingView: ComponentType
|
|
16
|
-
ErrorView: ComponentType<
|
|
17
|
-
MoreView: ComponentType<
|
|
15
|
+
LoadingView: ComponentType<TLoadingViewProps>;
|
|
16
|
+
ErrorView: ComponentType<TErrorViewProps>;
|
|
17
|
+
MoreView: ComponentType<TMoreViewProps>;
|
|
18
|
+
loadingViewProps?: TLoadingViewProps;
|
|
19
|
+
errorViewProps?: Omit<TErrorViewProps, keyof ErrorViewProps<TError>>;
|
|
20
|
+
moreViewProps?: Omit<TMoreViewProps, keyof MoreViewProps>;
|
|
18
21
|
children: ReactNode;
|
|
19
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {ComponentType, ReactNode} from 'react';\n\nimport type {DataLoaderStatus} from '../../../core';\nimport type {ErrorAction, ErrorViewProps} from '../types';\n\nexport interface MoreViewProps {\n isLoading: boolean;\n onClick: () => void;\n}\n\nexport interface DataInfiniteLoaderProps<TError> {\n status: DataLoaderStatus;\n error: TError | null;\n errorAction?: ErrorAction | ErrorAction['handler'];\n hasNextPage: boolean;\n fetchNextPage: () => unknown;\n isFetchingNextPage: boolean;\n LoadingView: ComponentType
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {ComponentType, ReactNode} from 'react';\n\nimport type {DataLoaderStatus} from '../../../core';\nimport type {ErrorAction, ErrorViewProps} from '../types';\n\nexport interface MoreViewProps {\n isLoading: boolean;\n onClick: () => void;\n}\n\nexport interface DataInfiniteLoaderProps<\n TError,\n TLoadingViewProps extends {} = {},\n TErrorViewProps extends ErrorViewProps<TError> = ErrorViewProps<TError>,\n TMoreViewProps extends MoreViewProps = MoreViewProps,\n> {\n status: DataLoaderStatus;\n error: TError | null;\n errorAction?: ErrorAction | ErrorAction['handler'];\n hasNextPage: boolean;\n fetchNextPage: () => unknown;\n isFetchingNextPage: boolean;\n LoadingView: ComponentType<TLoadingViewProps>;\n ErrorView: ComponentType<TErrorViewProps>;\n MoreView: ComponentType<TMoreViewProps>;\n loadingViewProps?: TLoadingViewProps;\n errorViewProps?: Omit<TErrorViewProps, keyof ErrorViewProps<TError>>;\n moreViewProps?: Omit<TMoreViewProps, keyof MoreViewProps>;\n children: ReactNode;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { DataLoaderProps } from './types';
|
|
3
|
-
export declare const DataLoader: <TError>({ status, error, errorAction: errorActionProp, LoadingView, ErrorView, children, }: DataLoaderProps<TError>) => React.ReactNode;
|
|
3
|
+
export declare const DataLoader: <TError>({ status, error, errorAction: errorActionProp, LoadingView, ErrorView, loadingViewProps, errorViewProps, children, }: DataLoaderProps<TError>) => React.ReactNode;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
4
|
export var DataLoader = function DataLoader(_ref) {
|
|
@@ -6,6 +7,8 @@ export var DataLoader = function DataLoader(_ref) {
|
|
|
6
7
|
errorActionProp = _ref.errorAction,
|
|
7
8
|
LoadingView = _ref.LoadingView,
|
|
8
9
|
ErrorView = _ref.ErrorView,
|
|
10
|
+
loadingViewProps = _ref.loadingViewProps,
|
|
11
|
+
errorViewProps = _ref.errorViewProps,
|
|
9
12
|
children = _ref.children;
|
|
10
13
|
var errorAction = React.useMemo(function () {
|
|
11
14
|
return typeof errorActionProp === 'function' ? {
|
|
@@ -13,13 +16,13 @@ export var DataLoader = function DataLoader(_ref) {
|
|
|
13
16
|
} : errorActionProp;
|
|
14
17
|
}, [errorActionProp]);
|
|
15
18
|
if (status === 'loading') {
|
|
16
|
-
return /*#__PURE__*/_jsx(LoadingView, {});
|
|
19
|
+
return /*#__PURE__*/_jsx(LoadingView, _objectSpread({}, loadingViewProps));
|
|
17
20
|
}
|
|
18
21
|
if (status === 'error') {
|
|
19
|
-
return /*#__PURE__*/_jsx(ErrorView, {
|
|
22
|
+
return /*#__PURE__*/_jsx(ErrorView, _objectSpread({
|
|
20
23
|
error: error,
|
|
21
24
|
action: errorAction
|
|
22
|
-
});
|
|
25
|
+
}, errorViewProps));
|
|
23
26
|
}
|
|
24
27
|
return /*#__PURE__*/_jsx(_Fragment, {
|
|
25
28
|
children: children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","jsx","_jsx","Fragment","_Fragment","DataLoader","_ref","status","error","errorActionProp","errorAction","LoadingView","ErrorView","children","useMemo","handler","action"],"sources":["DataLoader.tsx"],"sourcesContent":["import React from 'react';\n\nimport type {ErrorViewProps} from '../types';\n\nimport type {DataLoaderProps} from './types';\n\nexport const DataLoader = <TError,>({\n status,\n error,\n errorAction: errorActionProp,\n LoadingView,\n ErrorView,\n children,\n}: DataLoaderProps<TError>): React.ReactNode => {\n const errorAction = React.useMemo<ErrorViewProps<TError>['action']>(\n () =>\n typeof errorActionProp === 'function' ? {handler: errorActionProp} : errorActionProp,\n [errorActionProp],\n );\n\n if (status === 'loading') {\n return <LoadingView />;\n }\n\n if (status === 'error') {\n return <ErrorView error={error} action={errorAction} />;\n }\n\n return <>{children}</>;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA;AAM1B,OAAO,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CAAAC,IAAA,
|
|
1
|
+
{"version":3,"names":["React","jsx","_jsx","Fragment","_Fragment","DataLoader","_ref","status","error","errorActionProp","errorAction","LoadingView","ErrorView","loadingViewProps","errorViewProps","children","useMemo","handler","_objectSpread","action"],"sources":["DataLoader.tsx"],"sourcesContent":["import React from 'react';\n\nimport type {ErrorViewProps} from '../types';\n\nimport type {DataLoaderProps} from './types';\n\nexport const DataLoader = <TError,>({\n status,\n error,\n errorAction: errorActionProp,\n LoadingView,\n ErrorView,\n loadingViewProps,\n errorViewProps,\n children,\n}: DataLoaderProps<TError>): React.ReactNode => {\n const errorAction = React.useMemo<ErrorViewProps<TError>['action']>(\n () =>\n typeof errorActionProp === 'function' ? {handler: errorActionProp} : errorActionProp,\n [errorActionProp],\n );\n\n if (status === 'loading') {\n return <LoadingView {...loadingViewProps} />;\n }\n\n if (status === 'error') {\n return <ErrorView error={error} action={errorAction} {...errorViewProps} />;\n }\n\n return <>{children}</>;\n};\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA;AAM1B,OAAO,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CAAAC,IAAA,EASyB;EAAA,IAR5CC,MAAM,GAAAD,IAAA,CAANC,MAAM;IACNC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACQC,eAAe,GAAAH,IAAA,CAA5BI,WAAW;IACXC,WAAW,GAAAL,IAAA,CAAXK,WAAW;IACXC,SAAS,GAAAN,IAAA,CAATM,SAAS;IACTC,gBAAgB,GAAAP,IAAA,CAAhBO,gBAAgB;IAChBC,cAAc,GAAAR,IAAA,CAAdQ,cAAc;IACdC,QAAQ,GAAAT,IAAA,CAARS,QAAQ;EAER,IAAML,WAAW,GAAGV,KAAK,CAACgB,OAAO,CAC7B;IAAA,OACI,OAAOP,eAAe,KAAK,UAAU,GAAG;MAACQ,OAAO,EAAER;IAAe,CAAC,GAAGA,eAAe;EAAA,GACxF,CAACA,eAAe,CACpB,CAAC;EAED,IAAIF,MAAM,KAAK,SAAS,EAAE;IACtB,oBAAOL,IAAA,CAACS,WAAW,EAAAO,aAAA,KAAKL,gBAAgB,CAAG,CAAC;EAChD;EAEA,IAAIN,MAAM,KAAK,OAAO,EAAE;IACpB,oBAAOL,IAAA,CAACU,SAAS,EAAAM,aAAA;MAACV,KAAK,EAAEA,KAAM;MAACW,MAAM,EAAET;IAAY,GAAKI,cAAc,CAAG,CAAC;EAC/E;EAEA,oBAAOZ,IAAA,CAAAE,SAAA;IAAAW,QAAA,EAAGA;EAAQ,CAAG,CAAC;AAC1B,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ComponentType, ReactNode } from 'react';
|
|
2
2
|
import type { DataLoaderStatus } from '../../../core';
|
|
3
3
|
import type { ErrorAction, ErrorViewProps } from '../types';
|
|
4
|
-
export interface DataLoaderProps<TError> {
|
|
4
|
+
export interface DataLoaderProps<TError, TLoadingViewProps extends {} = {}, TErrorViewProps extends ErrorViewProps<TError> = ErrorViewProps<TError>> {
|
|
5
5
|
status: DataLoaderStatus;
|
|
6
6
|
error: TError | null;
|
|
7
7
|
errorAction?: ErrorAction | ErrorAction['handler'];
|
|
8
|
-
LoadingView: ComponentType
|
|
9
|
-
ErrorView: ComponentType<
|
|
8
|
+
LoadingView: ComponentType<TLoadingViewProps>;
|
|
9
|
+
ErrorView: ComponentType<TErrorViewProps>;
|
|
10
|
+
loadingViewProps?: TLoadingViewProps;
|
|
11
|
+
errorViewProps?: Omit<TErrorViewProps, keyof ErrorViewProps<TError>>;
|
|
10
12
|
children: ReactNode;
|
|
11
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {ComponentType, ReactNode} from 'react';\n\nimport type {DataLoaderStatus} from '../../../core';\nimport type {ErrorAction, ErrorViewProps} from '../types';\n\nexport interface DataLoaderProps<TError> {\n status: DataLoaderStatus;\n error: TError | null;\n errorAction?: ErrorAction | ErrorAction['handler'];\n LoadingView: ComponentType
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {ComponentType, ReactNode} from 'react';\n\nimport type {DataLoaderStatus} from '../../../core';\nimport type {ErrorAction, ErrorViewProps} from '../types';\n\nexport interface DataLoaderProps<\n TError,\n TLoadingViewProps extends {} = {},\n TErrorViewProps extends ErrorViewProps<TError> = ErrorViewProps<TError>,\n> {\n status: DataLoaderStatus;\n error: TError | null;\n errorAction?: ErrorAction | ErrorAction['handler'];\n LoadingView: ComponentType<TLoadingViewProps>;\n ErrorView: ComponentType<TErrorViewProps>;\n loadingViewProps?: TLoadingViewProps;\n errorViewProps?: Omit<TErrorViewProps, keyof ErrorViewProps<TError>>;\n children: ReactNode;\n}\n"],"mappings":"","ignoreList":[]}
|