@xyo-network/react-webapp 2.26.6 → 2.26.9

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.
@@ -0,0 +1,8 @@
1
+ import { AxiosError } from 'axios';
2
+ import { PropsWithChildren } from 'react';
3
+ export interface HandleItemDetailLoadingProps<T> {
4
+ apiError: AxiosError | undefined;
5
+ notFound: boolean;
6
+ searchResult: T | undefined;
7
+ }
8
+ export declare function ResultLoader<T>(props: PropsWithChildren<HandleItemDetailLoadingProps<T>>): JSX.Element;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ResultLoader = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_flexbox_1 = require("@xylabs/react-flexbox");
6
+ const NotFoundPage_1 = require("./NotFoundPage");
7
+ function ResultLoader(props) {
8
+ const { notFound, apiError, searchResult, children } = props;
9
+ if (notFound) {
10
+ return (0, jsx_runtime_1.jsx)(NotFoundPage_1.NotFound, {});
11
+ }
12
+ // Defer error handling to the children
13
+ if (apiError) {
14
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
15
+ }
16
+ if (searchResult === undefined) {
17
+ return (0, jsx_runtime_1.jsx)(react_flexbox_1.FlexGrowRow, { busy: true, minHeight: "50px" });
18
+ }
19
+ else {
20
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
21
+ }
22
+ }
23
+ exports.ResultLoader = ResultLoader;
24
+ //# sourceMappingURL=ResultLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResultLoader.js","sourceRoot":"","sources":["../../../src/components/ResultLoader.tsx"],"names":[],"mappings":";;;;AAAA,yDAAmD;AAInD,iDAAyC;AAQzC,SAAgB,YAAY,CAAI,KAAyD;IACvF,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IAC5D,IAAI,QAAQ,EAAE;QACZ,OAAO,uBAAC,uBAAQ,KAAG,CAAA;KACpB;IACD,uCAAuC;IACvC,IAAI,QAAQ,EAAE;QACZ,OAAO,2DAAG,QAAQ,GAAI,CAAA;KACvB;IACD,IAAI,YAAY,KAAK,SAAS,EAAE;QAC9B,OAAO,uBAAC,2BAAW,IAAC,IAAI,QAAC,SAAS,EAAC,MAAM,GAAG,CAAA;KAC7C;SAAM;QACL,OAAO,2DAAG,QAAQ,GAAI,CAAA;KACvB;AACH,CAAC;AAdD,oCAcC"}
@@ -2,3 +2,4 @@ export * from './Chrome';
2
2
  export * from './ErrorPage';
3
3
  export * from './NotFoundPage';
4
4
  export * from './Page';
5
+ export * from './ResultLoader';
@@ -5,4 +5,5 @@ tslib_1.__exportStar(require("./Chrome"), exports);
5
5
  tslib_1.__exportStar(require("./ErrorPage"), exports);
6
6
  tslib_1.__exportStar(require("./NotFoundPage"), exports);
7
7
  tslib_1.__exportStar(require("./Page"), exports);
8
+ tslib_1.__exportStar(require("./ResultLoader"), exports);
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,mDAAwB;AACxB,sDAA2B;AAC3B,yDAA8B;AAC9B,iDAAsB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,mDAAwB;AACxB,sDAA2B;AAC3B,yDAA8B;AAC9B,iDAAsB;AACtB,yDAA8B"}
@@ -0,0 +1,8 @@
1
+ import { AxiosError } from 'axios';
2
+ import { PropsWithChildren } from 'react';
3
+ export interface HandleItemDetailLoadingProps<T> {
4
+ apiError: AxiosError | undefined;
5
+ notFound: boolean;
6
+ searchResult: T | undefined;
7
+ }
8
+ export declare function ResultLoader<T>(props: PropsWithChildren<HandleItemDetailLoadingProps<T>>): JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { FlexGrowRow } from '@xylabs/react-flexbox';
3
+ import { NotFound } from './NotFoundPage';
4
+ export function ResultLoader(props) {
5
+ const { notFound, apiError, searchResult, children } = props;
6
+ if (notFound) {
7
+ return _jsx(NotFound, {});
8
+ }
9
+ // Defer error handling to the children
10
+ if (apiError) {
11
+ return _jsx(_Fragment, { children: children });
12
+ }
13
+ if (searchResult === undefined) {
14
+ return _jsx(FlexGrowRow, { busy: true, minHeight: "50px" });
15
+ }
16
+ else {
17
+ return _jsx(_Fragment, { children: children });
18
+ }
19
+ }
20
+ //# sourceMappingURL=ResultLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResultLoader.js","sourceRoot":"","sources":["../../../src/components/ResultLoader.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAInD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAQzC,MAAM,UAAU,YAAY,CAAI,KAAyD;IACvF,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IAC5D,IAAI,QAAQ,EAAE;QACZ,OAAO,KAAC,QAAQ,KAAG,CAAA;KACpB;IACD,uCAAuC;IACvC,IAAI,QAAQ,EAAE;QACZ,OAAO,4BAAG,QAAQ,GAAI,CAAA;KACvB;IACD,IAAI,YAAY,KAAK,SAAS,EAAE;QAC9B,OAAO,KAAC,WAAW,IAAC,IAAI,QAAC,SAAS,EAAC,MAAM,GAAG,CAAA;KAC7C;SAAM;QACL,OAAO,4BAAG,QAAQ,GAAI,CAAA;KACvB;AACH,CAAC"}
@@ -2,3 +2,4 @@ export * from './Chrome';
2
2
  export * from './ErrorPage';
3
3
  export * from './NotFoundPage';
4
4
  export * from './Page';
5
+ export * from './ResultLoader';
@@ -2,4 +2,5 @@ export * from './Chrome';
2
2
  export * from './ErrorPage';
3
3
  export * from './NotFoundPage';
4
4
  export * from './Page';
5
+ export * from './ResultLoader';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,QAAQ,CAAA;AACtB,cAAc,gBAAgB,CAAA"}
package/package.json CHANGED
@@ -12,16 +12,18 @@
12
12
  "dependencies": {
13
13
  "@emotion/react": "^11.9.3",
14
14
  "@emotion/styled": "^11.9.3",
15
- "@mui/material": "^5.8.6",
16
- "@xylabs/react-button": "^2.14.4",
17
- "@xylabs/react-flexbox": "^2.14.4",
18
- "@xylabs/react-pixel": "^2.14.4",
19
- "@xylabs/react-shared": "^2.14.4",
15
+ "@mui/material": "^5.8.7",
16
+ "@xylabs/react-button": "^2.14.5",
17
+ "@xylabs/react-flexbox": "^2.14.5",
18
+ "@xylabs/react-link": "^2.14.5",
19
+ "@xylabs/react-pixel": "^2.14.5",
20
+ "@xylabs/react-shared": "^2.14.5",
20
21
  "@xylabs/sdk-js": "^2.5.9",
21
- "@xyo-network/react-app-settings": "^2.26.6",
22
- "@xyo-network/react-appbar": "^2.26.6",
23
- "@xyo-network/react-footer": "^2.26.6",
24
- "@xyo-network/react-shared": "^2.26.6",
22
+ "@xyo-network/react-app-settings": "^2.26.9",
23
+ "@xyo-network/react-appbar": "^2.26.9",
24
+ "@xyo-network/react-footer": "^2.26.9",
25
+ "@xyo-network/react-shared": "^2.26.9",
26
+ "axios": "^0.27.2",
25
27
  "react": "^18.2.0",
26
28
  "react-dom": "^18.2.0",
27
29
  "react-helmet": "^6.1.0",
@@ -30,11 +32,10 @@
30
32
  },
31
33
  "description": "Common React library for all XYO projects that use React",
32
34
  "devDependencies": {
33
- "@babel/core": "^7.18.5",
34
- "@babel/preset-env": "^7.18.2",
35
+ "@babel/core": "^7.18.6",
36
+ "@babel/preset-env": "^7.18.6",
35
37
  "@storybook/react": "^6.5.9",
36
38
  "@types/react-helmet": "^6.1.5",
37
- "@xylabs/react-common": "^2.14.4",
38
39
  "@xylabs/tsconfig": "^1.0.14"
39
40
  },
40
41
  "browser": "dist/esm/index.js",
@@ -86,6 +87,6 @@
86
87
  },
87
88
  "sideEffects": false,
88
89
  "types": "dist/esm/index.d.ts",
89
- "version": "2.26.6",
90
+ "version": "2.26.9",
90
91
  "packageManager": "yarn@3.1.1"
91
92
  }
@@ -1,8 +1,8 @@
1
1
  /* eslint-disable import/no-internal-modules */
2
2
  import { Breadcrumbs, List } from '@mui/material'
3
3
  import { ComponentMeta, ComponentStory } from '@storybook/react'
4
- import { LinkEx } from '@xylabs/react-common'
5
4
  import { FlexCol, FlexRow } from '@xylabs/react-flexbox'
5
+ import { LinkEx } from '@xylabs/react-link'
6
6
  import { SiteMenuListItem } from '@xyo-network/react-appbar'
7
7
  import { BrowserRouter } from 'react-router-dom'
8
8
 
@@ -0,0 +1,37 @@
1
+ /* eslint-disable import/no-internal-modules */
2
+ import { ComponentStory, Meta } from '@storybook/react'
3
+ import { AxiosError } from 'axios'
4
+
5
+ import { ResultLoader } from './ResultLoader'
6
+
7
+ const StorybookEntry: Meta = {
8
+ argTypes: {},
9
+ component: ResultLoader,
10
+ parameters: {
11
+ docs: {
12
+ page: null,
13
+ },
14
+ },
15
+ title: 'webapp/ResultLoader',
16
+ }
17
+
18
+ const Template: ComponentStory<typeof ResultLoader> = (props) => {
19
+ return <ResultLoader {...props} />
20
+ }
21
+
22
+ const Default = Template.bind({})
23
+ Default.args = {}
24
+
25
+ const NotFound = Template.bind({})
26
+ NotFound.args = { notFound: true }
27
+
28
+ const ApiError = Template.bind({})
29
+ ApiError.args = { apiError: new AxiosError(), children: <h1>Shown in case of error</h1> }
30
+
31
+ const SearchResult = Template.bind({})
32
+ SearchResult.args = { children: <h1>Shown when there is a valid result</h1>, searchResult: 'foo' }
33
+
34
+ export { ApiError, Default, NotFound, SearchResult }
35
+
36
+ // eslint-disable-next-line import/no-default-export
37
+ export default StorybookEntry
@@ -0,0 +1,27 @@
1
+ import { FlexGrowRow } from '@xylabs/react-flexbox'
2
+ import { AxiosError } from 'axios'
3
+ import { PropsWithChildren } from 'react'
4
+
5
+ import { NotFound } from './NotFoundPage'
6
+
7
+ export interface HandleItemDetailLoadingProps<T> {
8
+ apiError: AxiosError | undefined
9
+ notFound: boolean
10
+ searchResult: T | undefined
11
+ }
12
+
13
+ export function ResultLoader<T>(props: PropsWithChildren<HandleItemDetailLoadingProps<T>>) {
14
+ const { notFound, apiError, searchResult, children } = props
15
+ if (notFound) {
16
+ return <NotFound />
17
+ }
18
+ // Defer error handling to the children
19
+ if (apiError) {
20
+ return <>{children}</>
21
+ }
22
+ if (searchResult === undefined) {
23
+ return <FlexGrowRow busy minHeight="50px" />
24
+ } else {
25
+ return <>{children}</>
26
+ }
27
+ }
@@ -2,3 +2,4 @@ export * from './Chrome'
2
2
  export * from './ErrorPage'
3
3
  export * from './NotFoundPage'
4
4
  export * from './Page'
5
+ export * from './ResultLoader'