@xyo-network/react-webapp 2.26.4 → 2.26.7
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/cjs/components/Chrome.d.ts +0 -3
- package/dist/cjs/components/Chrome.js +2 -2
- package/dist/cjs/components/Chrome.js.map +1 -1
- package/dist/cjs/components/ErrorPage.d.ts +2 -3
- package/dist/cjs/components/ErrorPage.js +1 -1
- package/dist/cjs/components/ErrorPage.js.map +1 -1
- package/dist/cjs/components/Page.d.ts +1 -3
- package/dist/cjs/components/Page.js +3 -3
- package/dist/cjs/components/Page.js.map +1 -1
- package/dist/esm/components/ResultLoader.d.ts +8 -0
- package/dist/esm/components/ResultLoader.js +20 -0
- package/dist/esm/components/ResultLoader.js.map +1 -0
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/package.json +7 -6
- package/src/components/ResultLoader.stories.tsx +37 -0
- package/src/components/ResultLoader.tsx +27 -0
- package/src/components/index.ts +1 -0
- package/dist/cjs/contexts/AppSettings/Context.d.ts +0 -11
- package/dist/cjs/contexts/AppSettings/Context.js +0 -7
- package/dist/cjs/contexts/AppSettings/Context.js.map +0 -1
- package/dist/cjs/contexts/AppSettings/Provider.d.ts +0 -8
- package/dist/cjs/contexts/AppSettings/Provider.js +0 -34
- package/dist/cjs/contexts/AppSettings/Provider.js.map +0 -1
- package/dist/cjs/contexts/AppSettings/Slug.d.ts +0 -5
- package/dist/cjs/contexts/AppSettings/Slug.js +0 -10
- package/dist/cjs/contexts/AppSettings/Slug.js.map +0 -1
- package/dist/cjs/contexts/AppSettings/Storage.d.ts +0 -11
- package/dist/cjs/contexts/AppSettings/Storage.js +0 -31
- package/dist/cjs/contexts/AppSettings/Storage.js.map +0 -1
- package/dist/cjs/contexts/AppSettings/StorageBase.d.ts +0 -15
- package/dist/cjs/contexts/AppSettings/StorageBase.js +0 -78
- package/dist/cjs/contexts/AppSettings/StorageBase.js.map +0 -1
- package/dist/cjs/contexts/AppSettings/appSettingDefault.d.ts +0 -1
- package/dist/cjs/contexts/AppSettings/appSettingDefault.js +0 -13
- package/dist/cjs/contexts/AppSettings/appSettingDefault.js.map +0 -1
- package/dist/cjs/contexts/AppSettings/index.d.ts +0 -6
- package/dist/cjs/contexts/AppSettings/index.js +0 -10
- package/dist/cjs/contexts/AppSettings/index.js.map +0 -1
- package/dist/cjs/contexts/AppSettings/useAppSettings.d.ts +0 -1
- package/dist/cjs/contexts/AppSettings/useAppSettings.js +0 -10
- package/dist/cjs/contexts/AppSettings/useAppSettings.js.map +0 -1
- package/dist/cjs/contexts/index.d.ts +0 -1
- package/dist/cjs/contexts/index.js +0 -5
- package/dist/cjs/contexts/index.js.map +0 -1
- package/dist/esm/contexts/AppSettings/Context.d.ts +0 -11
- package/dist/esm/contexts/AppSettings/Context.js +0 -4
- package/dist/esm/contexts/AppSettings/Context.js.map +0 -1
- package/dist/esm/contexts/AppSettings/Provider.d.ts +0 -8
- package/dist/esm/contexts/AppSettings/Provider.js +0 -31
- package/dist/esm/contexts/AppSettings/Provider.js.map +0 -1
- package/dist/esm/contexts/AppSettings/Slug.d.ts +0 -5
- package/dist/esm/contexts/AppSettings/Slug.js +0 -7
- package/dist/esm/contexts/AppSettings/Slug.js.map +0 -1
- package/dist/esm/contexts/AppSettings/Storage.d.ts +0 -11
- package/dist/esm/contexts/AppSettings/Storage.js +0 -27
- package/dist/esm/contexts/AppSettings/Storage.js.map +0 -1
- package/dist/esm/contexts/AppSettings/StorageBase.d.ts +0 -15
- package/dist/esm/contexts/AppSettings/StorageBase.js +0 -73
- package/dist/esm/contexts/AppSettings/StorageBase.js.map +0 -1
- package/dist/esm/contexts/AppSettings/appSettingDefault.d.ts +0 -1
- package/dist/esm/contexts/AppSettings/appSettingDefault.js +0 -9
- package/dist/esm/contexts/AppSettings/appSettingDefault.js.map +0 -1
- package/dist/esm/contexts/AppSettings/index.d.ts +0 -6
- package/dist/esm/contexts/AppSettings/index.js +0 -7
- package/dist/esm/contexts/AppSettings/index.js.map +0 -1
- package/dist/esm/contexts/AppSettings/useAppSettings.d.ts +0 -1
- package/dist/esm/contexts/AppSettings/useAppSettings.js +0 -6
- package/dist/esm/contexts/AppSettings/useAppSettings.js.map +0 -1
- package/dist/esm/contexts/index.d.ts +0 -1
- package/dist/esm/contexts/index.js +0 -2
- package/dist/esm/contexts/index.js.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { FlexBoxProps } from '@xylabs/react-flexbox';
|
|
2
|
-
import { WebAppNavigationType } from '@xyo-network/react-app-settings';
|
|
3
2
|
import { ReactNode } from 'react';
|
|
4
3
|
export interface WebAppChromeProps extends FlexBoxProps {
|
|
5
4
|
appName: string;
|
|
@@ -7,7 +6,5 @@ export interface WebAppChromeProps extends FlexBoxProps {
|
|
|
7
6
|
appbar?: ReactNode;
|
|
8
7
|
errorPage?: ReactNode;
|
|
9
8
|
footerElevation?: number;
|
|
10
|
-
navigationType?: WebAppNavigationType;
|
|
11
|
-
menuItems?: ReactNode;
|
|
12
9
|
}
|
|
13
10
|
export declare const WebAppChrome: React.FC<WebAppChromeProps>;
|
|
@@ -11,8 +11,8 @@ const react_shared_1 = require("@xyo-network/react-shared");
|
|
|
11
11
|
const react_helmet_1 = require("react-helmet");
|
|
12
12
|
const ErrorPage_1 = require("./ErrorPage");
|
|
13
13
|
const WebAppChrome = (_a) => {
|
|
14
|
-
var {
|
|
15
|
-
return ((0, jsx_runtime_1.jsxs)(react_flexbox_1.FlexCol, Object.assign({ alignItems: "stretch",
|
|
14
|
+
var { footerElevation = 4, errorPage, appbar, footer, children, appName } = _a, props = tslib_1.__rest(_a, ["footerElevation", "errorPage", "appbar", "footer", "children", "appName"]);
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)(react_flexbox_1.FlexCol, Object.assign({ alignItems: "stretch", height: "100vh" }, props, { children: [(0, jsx_runtime_1.jsx)(react_helmet_1.Helmet, Object.assign({ defaultTitle: appName, titleTemplate: `%s | ${appName}` }, { children: (0, jsx_runtime_1.jsx)("meta", { content: "website", property: "og:type" }) })), appbar !== null && appbar !== void 0 ? appbar : (0, jsx_runtime_1.jsx)(react_appbar_1.ApplicationAppBar, {}), (0, jsx_runtime_1.jsx)(react_flexbox_1.FlexGrowCol, Object.assign({ overflow: "hidden", justifyContent: "flex-start", alignItems: "stretch" }, { children: (0, jsx_runtime_1.jsx)(react_shared_1.ErrorBoundary, Object.assign({ fallback: errorPage !== null && errorPage !== void 0 ? errorPage : (0, jsx_runtime_1.jsx)(ErrorPage_1.WebAppErrorPage, {}) }, { children: children })) })), (0, jsx_runtime_1.jsx)(material_1.Paper, Object.assign({ elevation: footerElevation, square: true }, { children: footer !== null && footer !== void 0 ? footer : (0, jsx_runtime_1.jsx)(react_footer_1.Footer, { dynamicHeight: true }) }))] })));
|
|
16
16
|
};
|
|
17
17
|
exports.WebAppChrome = WebAppChrome;
|
|
18
18
|
//# sourceMappingURL=Chrome.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chrome.js","sourceRoot":"","sources":["../../../src/components/Chrome.tsx"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"Chrome.js","sourceRoot":"","sources":["../../../src/components/Chrome.tsx"],"names":[],"mappings":";;;;;AAAA,4CAAqC;AACrC,yDAA0E;AAC1E,4DAA6D;AAC7D,4DAAkD;AAClD,4DAAyD;AAEzD,+CAAqC;AAErC,2CAA6C;AAUtC,MAAM,YAAY,GAAgC,CAAC,EAA+E,EAAE,EAAE;QAAnF,EAAE,eAAe,GAAG,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,OAAY,EAAP,KAAK,sBAA7E,2EAA+E,CAAF;IACrI,OAAO,CACL,wBAAC,uBAAO,kBAAC,UAAU,EAAC,SAAS,EAAC,MAAM,EAAC,OAAO,IAAK,KAAK,eACpD,uBAAC,qBAAM,kBAAC,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,OAAO,EAAE,gBAC7D,iCAAM,OAAO,EAAC,SAAS,EAAC,QAAQ,EAAC,SAAS,GAAG,IACtC,EACR,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,uBAAC,gCAAiB,KAAG,EAChC,uBAAC,2BAAW,kBAAC,QAAQ,EAAC,QAAQ,EAAC,cAAc,EAAC,YAAY,EAAC,UAAU,EAAC,SAAS,gBAC7E,uBAAC,4BAAa,kBAAC,QAAQ,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,uBAAC,2BAAe,KAAG,gBAAG,QAAQ,IAAiB,IACzE,EACd,uBAAC,gBAAK,kBAAC,SAAS,EAAE,eAAe,EAAE,MAAM,sBACtC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,uBAAC,qBAAM,IAAC,aAAa,SAAG,IAC7B,KACA,CACX,CAAA;AACH,CAAC,CAAA;AAfY,QAAA,YAAY,gBAexB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
export declare const WebAppErrorPage: React.FC<WebAppPageProps>;
|
|
2
|
+
export declare const WebAppErrorPage: () => JSX.Element;
|
|
4
3
|
/** @deprecated use WebAppErrorPage instead */
|
|
5
|
-
export declare const ErrorPage:
|
|
4
|
+
export declare const ErrorPage: () => JSX.Element;
|
|
@@ -4,7 +4,7 @@ exports.ErrorPage = exports.WebAppErrorPage = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_button_1 = require("@xylabs/react-button");
|
|
6
6
|
const Page_1 = require("./Page");
|
|
7
|
-
const WebAppErrorPage = (
|
|
7
|
+
const WebAppErrorPage = () => ((0, jsx_runtime_1.jsxs)(Page_1.WebAppPage, Object.assign({ title: "Oops! Something went wrong" }, { children: [(0, jsx_runtime_1.jsx)("h1", { children: "Oops! Something went wrong!" }), (0, jsx_runtime_1.jsx)(react_button_1.ButtonEx, Object.assign({ href: "/", variant: "contained" }, { children: "Homepage" }))] })));
|
|
8
8
|
exports.WebAppErrorPage = WebAppErrorPage;
|
|
9
9
|
/** @deprecated use WebAppErrorPage instead */
|
|
10
10
|
exports.ErrorPage = exports.WebAppErrorPage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorPage.js","sourceRoot":"","sources":["../../../src/components/ErrorPage.tsx"],"names":[],"mappings":";;;;AAAA,uDAA+C;AAE/C,
|
|
1
|
+
{"version":3,"file":"ErrorPage.js","sourceRoot":"","sources":["../../../src/components/ErrorPage.tsx"],"names":[],"mappings":";;;;AAAA,uDAA+C;AAE/C,iCAAmC;AAE5B,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,CACnC,wBAAC,iBAAU,kBAAC,KAAK,EAAC,4BAA4B,iBAC5C,yEAAoC,EACpC,uBAAC,uBAAQ,kBAAC,IAAI,EAAC,GAAG,EAAC,OAAO,EAAC,WAAW,8BAE3B,KACA,CACd,CAAA;AAPY,QAAA,eAAe,mBAO3B;AAED,8CAA8C;AACjC,QAAA,SAAS,GAAG,uBAAe,CAAA"}
|
|
@@ -2,11 +2,9 @@ import { ContainerProps } from '@mui/material';
|
|
|
2
2
|
import { FlexBoxProps } from '@xylabs/react-flexbox';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
export interface WebAppPageProps extends FlexBoxProps {
|
|
5
|
-
container?: ContainerProps['maxWidth']
|
|
5
|
+
container?: ContainerProps['maxWidth'];
|
|
6
6
|
disableGutters?: boolean;
|
|
7
7
|
breadcrumbs?: ReactNode;
|
|
8
|
-
disableBreadcrumbGutter?: boolean;
|
|
9
|
-
spacing?: string | number;
|
|
10
8
|
}
|
|
11
9
|
export declare const WebAppPage: React.FC<WebAppPageProps>;
|
|
12
10
|
/** @deprecated use WebAppPagePage instead */
|
|
@@ -10,7 +10,7 @@ const react_shared_1 = require("@xylabs/react-shared");
|
|
|
10
10
|
const react_helmet_1 = require("react-helmet");
|
|
11
11
|
const react_router_dom_1 = require("react-router-dom");
|
|
12
12
|
const WebAppPage = (_a) => {
|
|
13
|
-
var {
|
|
13
|
+
var { disableGutters, title, container, breadcrumbs, children } = _a, props = tslib_1.__rest(_a, ["disableGutters", "title", "container", "breadcrumbs", "children"]);
|
|
14
14
|
const userEvents = (0, react_pixel_1.useUserEvents)();
|
|
15
15
|
const { pathname } = (0, react_router_dom_1.useLocation)();
|
|
16
16
|
(0, react_shared_1.useAsyncEffect)(
|
|
@@ -18,8 +18,8 @@ const WebAppPage = (_a) => {
|
|
|
18
18
|
() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
19
19
|
yield (userEvents === null || userEvents === void 0 ? void 0 : userEvents.viewContent({ name: title !== null && title !== void 0 ? title : 'NodeBasePage', path: location.pathname }));
|
|
20
20
|
}), [pathname, title, userEvents]);
|
|
21
|
-
const Body = (props) => ((0, jsx_runtime_1.jsxs)(react_flexbox_1.FlexGrowCol, Object.assign({ gap:
|
|
22
|
-
return ((0, jsx_runtime_1.jsxs)(react_flexbox_1.FlexGrowCol, Object.assign({ alignItems: "stretch", justifyContent: "flex-start", minHeight: 0,
|
|
21
|
+
const Body = (props) => ((0, jsx_runtime_1.jsxs)(react_flexbox_1.FlexGrowCol, Object.assign({ gap: 2, paddingY: 2, justifyContent: "flex-start", alignItems: "stretch" }, props, { children: [breadcrumbs, children] })));
|
|
22
|
+
return ((0, jsx_runtime_1.jsxs)(react_flexbox_1.FlexGrowCol, Object.assign({ alignItems: "stretch", justifyContent: "flex-start", minHeight: 0, overflow: "visible scroll" }, { children: [(0, jsx_runtime_1.jsx)(react_helmet_1.Helmet, { title: title }), container ? ((0, jsx_runtime_1.jsx)(material_1.Container, Object.assign({ disableGutters: disableGutters, style: { alignItems: 'stretch', display: 'flex', flexDirection: 'column', flexGrow: 1, justifyContent: 'flex-start' }, maxWidth: container }, { children: (0, jsx_runtime_1.jsx)(Body, Object.assign({}, props)) }))) : ((0, jsx_runtime_1.jsx)(Body, Object.assign({ paddingX: disableGutters ? 0 : 1 }, props)))] })));
|
|
23
23
|
};
|
|
24
24
|
exports.WebAppPage = WebAppPage;
|
|
25
25
|
/** @deprecated use WebAppPagePage instead */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Page.js","sourceRoot":"","sources":["../../../src/components/Page.tsx"],"names":[],"mappings":";;;;;AAAA,4CAAyD;AACzD,
|
|
1
|
+
{"version":3,"file":"Page.js","sourceRoot":"","sources":["../../../src/components/Page.tsx"],"names":[],"mappings":";;;;;AAAA,4CAAyD;AACzD,yDAAiE;AACjE,qDAAmD;AACnD,uDAAqD;AAErD,+CAAqC;AACrC,uDAA8C;AAOvC,MAAM,UAAU,GAA8B,CAAC,EAAqE,EAAE,EAAE;QAAzE,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,OAAY,EAAP,KAAK,sBAAnE,mEAAqE,CAAF;IACvH,MAAM,UAAU,GAAG,IAAA,2BAAa,GAAE,CAAA;IAClC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,8BAAW,GAAE,CAAA;IAElC,IAAA,6BAAc;IACZ,uDAAuD;IACvD,GAAS,EAAE;QACT,MAAM,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,cAAc,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA,CAAA;IAC3F,CAAC,CAAA,EACD,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,CAC9B,CAAA;IAED,MAAM,IAAI,GAA2B,CAAC,KAAK,EAAE,EAAE,CAAC,CAC9C,wBAAC,2BAAW,kBAAC,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,cAAc,EAAC,YAAY,EAAC,UAAU,EAAC,SAAS,IAAK,KAAK,eACzF,WAAW,EACX,QAAQ,KACG,CACf,CAAA;IAED,OAAO,CACL,wBAAC,2BAAW,kBAAC,UAAU,EAAC,SAAS,EAAC,cAAc,EAAC,YAAY,EAAC,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAC,gBAAgB,iBACnG,uBAAC,qBAAM,IAAC,KAAK,EAAE,KAAK,GAAI,EACvB,SAAS,CAAC,CAAC,CAAC,CACX,uBAAC,oBAAS,kBACR,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAE,cAAc,EAAE,YAAY,EAAE,EACrH,QAAQ,EAAE,SAAS,gBAEnB,uBAAC,IAAI,oBAAK,KAAK,EAAI,IACT,CACb,CAAC,CAAC,CAAC,CACF,uBAAC,IAAI,kBAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAM,KAAK,EAAI,CACtD,KACW,CACf,CAAA;AACH,CAAC,CAAA;AAnCY,QAAA,UAAU,cAmCtB;AAED,6CAA6C;AAChC,QAAA,QAAQ,GAAG,kBAAU,CAAA"}
|
|
@@ -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"}
|
|
@@ -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,15 +12,16 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@emotion/react": "^11.9.3",
|
|
14
14
|
"@emotion/styled": "^11.9.3",
|
|
15
|
-
"@mui/material": "^5.8.
|
|
15
|
+
"@mui/material": "^5.8.6",
|
|
16
16
|
"@xylabs/react-button": "^2.14.4",
|
|
17
17
|
"@xylabs/react-flexbox": "^2.14.4",
|
|
18
18
|
"@xylabs/react-pixel": "^2.14.4",
|
|
19
19
|
"@xylabs/react-shared": "^2.14.4",
|
|
20
|
-
"@
|
|
21
|
-
"@xyo-network/react-
|
|
22
|
-
"@xyo-network/react-
|
|
23
|
-
"@xyo-network/react-
|
|
20
|
+
"@xylabs/sdk-js": "^2.5.9",
|
|
21
|
+
"@xyo-network/react-app-settings": "^2.26.7",
|
|
22
|
+
"@xyo-network/react-appbar": "^2.26.7",
|
|
23
|
+
"@xyo-network/react-footer": "^2.26.7",
|
|
24
|
+
"@xyo-network/react-shared": "^2.26.7",
|
|
24
25
|
"react": "^18.2.0",
|
|
25
26
|
"react-dom": "^18.2.0",
|
|
26
27
|
"react-helmet": "^6.1.0",
|
|
@@ -85,6 +86,6 @@
|
|
|
85
86
|
},
|
|
86
87
|
"sideEffects": false,
|
|
87
88
|
"types": "dist/esm/index.d.ts",
|
|
88
|
-
"version": "2.26.
|
|
89
|
+
"version": "2.26.7",
|
|
89
90
|
"packageManager": "yarn@3.1.1"
|
|
90
91
|
}
|
|
@@ -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
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { WebAppNavigationType } from '@xyo-network/react-app-settings';
|
|
3
|
-
export interface AppSettingsContextProps {
|
|
4
|
-
darkMode?: boolean;
|
|
5
|
-
developerMode?: boolean;
|
|
6
|
-
enableDarkMode?: (value: boolean) => void;
|
|
7
|
-
enableDeveloperMode?: (value: boolean) => void;
|
|
8
|
-
changeNavigationType?: (value: WebAppNavigationType) => void;
|
|
9
|
-
navigationType?: WebAppNavigationType;
|
|
10
|
-
}
|
|
11
|
-
export declare const AppSettingsContext: import("react").Context<AppSettingsContextProps>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppSettingsContext = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const appSettingDefault_1 = require("./appSettingDefault");
|
|
6
|
-
exports.AppSettingsContext = (0, react_1.createContext)((0, appSettingDefault_1.appSettingDefault)());
|
|
7
|
-
//# sourceMappingURL=Context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/Context.ts"],"names":[],"mappings":";;;AACA,iCAAqC;AAErC,2DAAuD;AAW1C,QAAA,kBAAkB,GAAG,IAAA,qBAAa,EAA0B,IAAA,qCAAiB,GAAE,CAAC,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { WithChildren } from '@xylabs/react-shared';
|
|
2
|
-
import { ProviderProps } from 'react';
|
|
3
|
-
import { AppSettingsContextProps } from './Context';
|
|
4
|
-
import { AppSettingsStorage } from './Storage';
|
|
5
|
-
export interface AppSettingsProviderProps<T extends AppSettingsContextProps = AppSettingsContextProps> extends ProviderProps<T> {
|
|
6
|
-
storage?: AppSettingsStorage;
|
|
7
|
-
}
|
|
8
|
-
export declare const AppSettingsProvider: React.FC<WithChildren<AppSettingsProviderProps>>;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppSettingsProvider = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const Context_1 = require("./Context");
|
|
8
|
-
const Storage_1 = require("./Storage");
|
|
9
|
-
const AppSettingsProvider = (_a) => {
|
|
10
|
-
var { storage = new Storage_1.AppSettingsStorage(), value, children } = _a, props = tslib_1.__rest(_a, ["storage", "value", "children"]);
|
|
11
|
-
const [developerMode, setDeveloperMode] = (0, react_1.useState)(storage.developerMode);
|
|
12
|
-
const [darkMode, setDarkMode] = (0, react_1.useState)(storage.darkMode);
|
|
13
|
-
const [navigationType, setNaviagtionType] = (0, react_1.useState)(storage.navigationType);
|
|
14
|
-
const enableDeveloperMode = (value) => {
|
|
15
|
-
storage.developerMode = value;
|
|
16
|
-
setDeveloperMode(storage.developerMode);
|
|
17
|
-
};
|
|
18
|
-
const enableDarkMode = (value) => {
|
|
19
|
-
storage.darkMode = value;
|
|
20
|
-
setDarkMode(storage.darkMode);
|
|
21
|
-
};
|
|
22
|
-
const changeNavigationType = (value) => {
|
|
23
|
-
storage.navigationType = value;
|
|
24
|
-
setNaviagtionType(value);
|
|
25
|
-
};
|
|
26
|
-
return ((0, jsx_runtime_1.jsx)(Context_1.AppSettingsContext.Provider, Object.assign({ value: Object.assign({ changeNavigationType,
|
|
27
|
-
darkMode,
|
|
28
|
-
developerMode,
|
|
29
|
-
enableDarkMode,
|
|
30
|
-
enableDeveloperMode,
|
|
31
|
-
navigationType }, value) }, props, { children: children })));
|
|
32
|
-
};
|
|
33
|
-
exports.AppSettingsProvider = AppSettingsProvider;
|
|
34
|
-
//# sourceMappingURL=Provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/Provider.tsx"],"names":[],"mappings":";;;;;AAEA,iCAA+C;AAE/C,uCAAuE;AACvE,uCAA8C;AAMvC,MAAM,mBAAmB,GAAqD,CAAC,EAAiE,EAAE,EAAE;QAArE,EAAE,OAAO,GAAG,IAAI,4BAAkB,EAAE,EAAE,KAAK,EAAE,QAAQ,OAAY,EAAP,KAAK,sBAA/D,gCAAiE,CAAF;IACnJ,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAAC,OAAO,CAAC,aAAa,CAAC,CAAA;IACzE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC1D,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IAE5E,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAAE,EAAE;QAC7C,OAAO,CAAC,aAAa,GAAG,KAAK,CAAA;QAC7B,gBAAgB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;IACzC,CAAC,CAAA;IAED,MAAM,cAAc,GAAG,CAAC,KAAc,EAAE,EAAE;QACxC,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAA;QACxB,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC/B,CAAC,CAAA;IAED,MAAM,oBAAoB,GAAG,CAAC,KAA2B,EAAE,EAAE;QAC3D,OAAO,CAAC,cAAc,GAAG,KAAK,CAAA;QAC9B,iBAAiB,CAAC,KAAK,CAAC,CAAA;IAC1B,CAAC,CAAA;IAED,OAAO,CACL,uBAAC,4BAAkB,CAAC,QAAQ,kBAC1B,KAAK,kBACH,oBAAoB;YACpB,QAAQ;YACR,aAAa;YACb,cAAc;YACd,mBAAmB;YACnB,cAAc,IAEX,KAAK,KAEN,KAAK,cAER,QAAQ,IACmB,CAC/B,CAAA;AACH,CAAC,CAAA;AArCY,QAAA,mBAAmB,uBAqC/B"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppSettingSlug = void 0;
|
|
4
|
-
var AppSettingSlug;
|
|
5
|
-
(function (AppSettingSlug) {
|
|
6
|
-
AppSettingSlug["DarkMode"] = "darkmode";
|
|
7
|
-
AppSettingSlug["Developer"] = "developer";
|
|
8
|
-
AppSettingSlug["NavigationType"] = "navgiationType";
|
|
9
|
-
})(AppSettingSlug = exports.AppSettingSlug || (exports.AppSettingSlug = {}));
|
|
10
|
-
//# sourceMappingURL=Slug.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Slug.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/Slug.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,yCAAuB,CAAA;IACvB,mDAAiC,CAAA;AACnC,CAAC,EAJW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAIzB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { WebAppNavigationType } from '@xyo-network/react-app-settings';
|
|
2
|
-
import { AppSettingsStorageBase } from './StorageBase';
|
|
3
|
-
export declare class AppSettingsStorage extends AppSettingsStorageBase {
|
|
4
|
-
constructor(prefix?: string, defaults?: Record<string, unknown>);
|
|
5
|
-
get darkMode(): boolean;
|
|
6
|
-
set darkMode(value: boolean);
|
|
7
|
-
get developerMode(): boolean;
|
|
8
|
-
set developerMode(value: boolean);
|
|
9
|
-
get navigationType(): WebAppNavigationType;
|
|
10
|
-
set navigationType(value: WebAppNavigationType);
|
|
11
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppSettingsStorage = void 0;
|
|
4
|
-
const appSettingDefault_1 = require("./appSettingDefault");
|
|
5
|
-
const Slug_1 = require("./Slug");
|
|
6
|
-
const StorageBase_1 = require("./StorageBase");
|
|
7
|
-
class AppSettingsStorage extends StorageBase_1.AppSettingsStorageBase {
|
|
8
|
-
constructor(prefix = 'AppSettings', defaults) {
|
|
9
|
-
super(prefix, Object.assign(Object.assign({}, (0, appSettingDefault_1.appSettingDefault)()), defaults));
|
|
10
|
-
}
|
|
11
|
-
get darkMode() {
|
|
12
|
-
return this.getBoolean(Slug_1.AppSettingSlug.DarkMode);
|
|
13
|
-
}
|
|
14
|
-
set darkMode(value) {
|
|
15
|
-
this.setBoolean(Slug_1.AppSettingSlug.DarkMode, value);
|
|
16
|
-
}
|
|
17
|
-
get developerMode() {
|
|
18
|
-
return this.getBoolean(Slug_1.AppSettingSlug.Developer);
|
|
19
|
-
}
|
|
20
|
-
set developerMode(value) {
|
|
21
|
-
this.setBoolean(Slug_1.AppSettingSlug.Developer, value);
|
|
22
|
-
}
|
|
23
|
-
get navigationType() {
|
|
24
|
-
return this.getString(Slug_1.AppSettingSlug.NavigationType);
|
|
25
|
-
}
|
|
26
|
-
set navigationType(value) {
|
|
27
|
-
this.setString(Slug_1.AppSettingSlug.NavigationType, value);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.AppSettingsStorage = AppSettingsStorage;
|
|
31
|
-
//# sourceMappingURL=Storage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Storage.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/Storage.ts"],"names":[],"mappings":";;;AAEA,2DAAuD;AACvD,iCAAuC;AACvC,+CAAsD;AAEtD,MAAa,kBAAmB,SAAQ,oCAAsB;IAC5D,YAAY,MAAM,GAAG,aAAa,EAAE,QAAkC;QACpE,KAAK,CAAC,MAAM,kCAAO,IAAA,qCAAiB,GAAE,GAAK,QAAQ,EAAG,CAAA;IACxD,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,UAAU,CAAC,qBAAc,CAAC,QAAQ,CAAC,CAAA;IACjD,CAAC;IAED,IAAI,QAAQ,CAAC,KAAc;QACzB,IAAI,CAAC,UAAU,CAAC,qBAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;IACjD,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,qBAAc,CAAC,SAAS,CAAC,CAAA;IAClD,CAAC;IAED,IAAI,aAAa,CAAC,KAAc;QAC9B,IAAI,CAAC,UAAU,CAAC,qBAAc,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;IAClD,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,qBAAc,CAAC,cAAc,CAAyB,CAAA;IAC9E,CAAC;IAED,IAAI,cAAc,CAAC,KAA2B;QAC5C,IAAI,CAAC,SAAS,CAAC,qBAAc,CAAC,cAAc,EAAE,KAAK,CAAC,CAAA;IACtD,CAAC;CACF;AA5BD,gDA4BC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare class AppSettingsStorageBase {
|
|
2
|
-
private prefix;
|
|
3
|
-
private defaults;
|
|
4
|
-
constructor(prefix?: string, defaults?: Record<string, unknown>);
|
|
5
|
-
getBoolean(name: string): boolean;
|
|
6
|
-
setBoolean(name: string, value: boolean): void;
|
|
7
|
-
setNumber(name: string, value: number): void;
|
|
8
|
-
getNumber(name: string): number;
|
|
9
|
-
getString(name: string): string;
|
|
10
|
-
setString(name: string, value: string): void;
|
|
11
|
-
getStringArray(name: string): string[];
|
|
12
|
-
setStringArray(name: string, value: string[]): void;
|
|
13
|
-
getObject<T>(name: string): T;
|
|
14
|
-
setObject<T>(name: string, value: T): void;
|
|
15
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppSettingsStorageBase = void 0;
|
|
4
|
-
const sdk_js_1 = require("@xylabs/sdk-js");
|
|
5
|
-
const react_shared_1 = require("@xyo-network/react-shared");
|
|
6
|
-
class AppSettingsStorageBase {
|
|
7
|
-
constructor(prefix = 'AppSettings', defaults) {
|
|
8
|
-
this.prefix = prefix;
|
|
9
|
-
this.defaults = defaults !== null && defaults !== void 0 ? defaults : {};
|
|
10
|
-
}
|
|
11
|
-
getBoolean(name) {
|
|
12
|
-
const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
|
|
13
|
-
if (!storedValue) {
|
|
14
|
-
(0, sdk_js_1.assertEx)(typeof this.defaults[name] === 'boolean', 'Default value is not boolean');
|
|
15
|
-
const defaultValue = this.defaults[name];
|
|
16
|
-
(0, sdk_js_1.assertEx)(defaultValue !== undefined, `Missing Default for ${name}`);
|
|
17
|
-
return defaultValue;
|
|
18
|
-
}
|
|
19
|
-
return storedValue !== 'false';
|
|
20
|
-
}
|
|
21
|
-
setBoolean(name, value) {
|
|
22
|
-
localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value));
|
|
23
|
-
}
|
|
24
|
-
setNumber(name, value) {
|
|
25
|
-
localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value));
|
|
26
|
-
}
|
|
27
|
-
getNumber(name) {
|
|
28
|
-
const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
|
|
29
|
-
if (!storedValue) {
|
|
30
|
-
(0, sdk_js_1.assertEx)(typeof this.defaults[name] === 'boolean', 'Default value is not boolean');
|
|
31
|
-
const defaultValue = this.defaults[name];
|
|
32
|
-
(0, sdk_js_1.assertEx)(defaultValue !== undefined, `Missing Default for ${name}`);
|
|
33
|
-
return defaultValue;
|
|
34
|
-
}
|
|
35
|
-
return parseFloat(storedValue);
|
|
36
|
-
}
|
|
37
|
-
getString(name) {
|
|
38
|
-
const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
|
|
39
|
-
if (!storedValue) {
|
|
40
|
-
(0, react_shared_1.assertDefinedEx)(typeof this.defaults[name] === 'string', 'Default value is not string');
|
|
41
|
-
const defaultValue = this.defaults[name];
|
|
42
|
-
(0, sdk_js_1.assertEx)(defaultValue !== undefined, `Missing Default for ${name}`);
|
|
43
|
-
return defaultValue;
|
|
44
|
-
}
|
|
45
|
-
return storedValue;
|
|
46
|
-
}
|
|
47
|
-
setString(name, value) {
|
|
48
|
-
localStorage.setItem(`${this.prefix}|${name}`, value);
|
|
49
|
-
}
|
|
50
|
-
getStringArray(name) {
|
|
51
|
-
var _a;
|
|
52
|
-
const storedValue = (_a = localStorage.getItem(`${this.prefix}|${name}`)) === null || _a === void 0 ? void 0 : _a.split(',');
|
|
53
|
-
if (!storedValue) {
|
|
54
|
-
(0, react_shared_1.assertDefinedEx)(Array.isArray(this.defaults[name]), 'Default value is not array');
|
|
55
|
-
const defaultValue = this.defaults[name];
|
|
56
|
-
(0, sdk_js_1.assertEx)(defaultValue !== undefined, `Missing Default for ${name}`);
|
|
57
|
-
return defaultValue;
|
|
58
|
-
}
|
|
59
|
-
return storedValue;
|
|
60
|
-
}
|
|
61
|
-
setStringArray(name, value) {
|
|
62
|
-
localStorage.setItem(`${this.prefix}|${name}`, value.join(','));
|
|
63
|
-
}
|
|
64
|
-
getObject(name) {
|
|
65
|
-
const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
|
|
66
|
-
const parsedStoredValue = storedValue ? JSON.parse(storedValue) : null;
|
|
67
|
-
if (!parsedStoredValue) {
|
|
68
|
-
(0, sdk_js_1.assertEx)(typeof this.defaults[name] === 'object', 'Default value is not object');
|
|
69
|
-
return (0, sdk_js_1.assertEx)(this.defaults[name], `Missing Default for ${name}`);
|
|
70
|
-
}
|
|
71
|
-
return parsedStoredValue;
|
|
72
|
-
}
|
|
73
|
-
setObject(name, value) {
|
|
74
|
-
localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
exports.AppSettingsStorageBase = AppSettingsStorageBase;
|
|
78
|
-
//# sourceMappingURL=StorageBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StorageBase.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/StorageBase.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AACzC,4DAA2D;AAE3D,MAAa,sBAAsB;IAGjC,YAAY,MAAM,GAAG,aAAa,EAAE,QAAkC;QACpE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,QAAQ,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAA;IAChC,CAAC;IAEM,UAAU,CAAC,IAAY;QAC5B,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC,CAAA;QAClE,IAAI,CAAC,WAAW,EAAE;YAChB,IAAA,iBAAQ,EAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,8BAA8B,CAAC,CAAA;YAClF,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAY,CAAA;YACnD,IAAA,iBAAQ,EAAC,YAAY,KAAK,SAAS,EAAE,uBAAuB,IAAI,EAAE,CAAC,CAAA;YACnE,OAAO,YAAY,CAAA;SACpB;QACD,OAAO,W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tE,IAAI,CAAC,iBAAiB,EAAE;YACtB,IAAA,iBAAQ,EAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,QAAQ,EAAE,6BAA6B,CAAC,CAAA;YAChF,OAAO,IAAA,iBAAQ,EAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAM,EAAE,uBAAuB,IAAI,EAAE,CAAC,CAAA;SACzE;QACD,OAAO,iBAAsB,CAAA;IAC/B,CAAC;IAEM,SAAS,CAAI,IAAY,EAAE,KAAQ;QACxC,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;IACvE,CAAC;CACF;AAjFD,wDAiFC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const appSettingDefault: () => Record<string, unknown>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.appSettingDefault = void 0;
|
|
4
|
-
const Slug_1 = require("./Slug");
|
|
5
|
-
const appSettingDefault = () => {
|
|
6
|
-
return {
|
|
7
|
-
[Slug_1.AppSettingSlug.DarkMode]: false,
|
|
8
|
-
[Slug_1.AppSettingSlug.Developer]: false,
|
|
9
|
-
[Slug_1.AppSettingSlug.NavigationType]: 'menu',
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
exports.appSettingDefault = appSettingDefault;
|
|
13
|
-
//# sourceMappingURL=appSettingDefault.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appSettingDefault.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/appSettingDefault.ts"],"names":[],"mappings":";;;AAAA,iCAAuC;AAEhC,MAAM,iBAAiB,GAAG,GAA4B,EAAE;IAC7D,OAAO;QACL,CAAC,qBAAc,CAAC,QAAQ,CAAC,EAAE,KAAK;QAChC,CAAC,qBAAc,CAAC,SAAS,CAAC,EAAE,KAAK;QACjC,CAAC,qBAAc,CAAC,cAAc,CAAC,EAAE,MAAM;KACxC,CAAA;AACH,CAAC,CAAA;AANY,QAAA,iBAAiB,qBAM7B"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./Context"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./Provider"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./Slug"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./Storage"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./StorageBase"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./useAppSettings"), exports);
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,qDAA0B;AAC1B,iDAAsB;AACtB,oDAAyB;AACzB,wDAA6B;AAC7B,2DAAgC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useAppSettings: () => import("./Context").AppSettingsContextProps;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useAppSettings = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const Context_1 = require("./Context");
|
|
6
|
-
const useAppSettings = () => {
|
|
7
|
-
return (0, react_1.useContext)(Context_1.AppSettingsContext);
|
|
8
|
-
};
|
|
9
|
-
exports.useAppSettings = useAppSettings;
|
|
10
|
-
//# sourceMappingURL=useAppSettings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useAppSettings.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/useAppSettings.ts"],"names":[],"mappings":";;;AAAA,iCAAkC;AAElC,uCAA8C;AAEvC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,OAAO,IAAA,kBAAU,EAAC,4BAAkB,CAAC,CAAA;AACvC,CAAC,CAAA;AAFY,QAAA,cAAc,kBAE1B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './AppSettings';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contexts/index.ts"],"names":[],"mappings":";;;AAAA,wDAA6B"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { WebAppNavigationType } from '@xyo-network/react-app-settings';
|
|
3
|
-
export interface AppSettingsContextProps {
|
|
4
|
-
darkMode?: boolean;
|
|
5
|
-
developerMode?: boolean;
|
|
6
|
-
enableDarkMode?: (value: boolean) => void;
|
|
7
|
-
enableDeveloperMode?: (value: boolean) => void;
|
|
8
|
-
changeNavigationType?: (value: WebAppNavigationType) => void;
|
|
9
|
-
navigationType?: WebAppNavigationType;
|
|
10
|
-
}
|
|
11
|
-
export declare const AppSettingsContext: import("react").Context<AppSettingsContextProps>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/Context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAErC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAWvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAA0B,iBAAiB,EAAE,CAAC,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { WithChildren } from '@xylabs/react-shared';
|
|
2
|
-
import { ProviderProps } from 'react';
|
|
3
|
-
import { AppSettingsContextProps } from './Context';
|
|
4
|
-
import { AppSettingsStorage } from './Storage';
|
|
5
|
-
export interface AppSettingsProviderProps<T extends AppSettingsContextProps = AppSettingsContextProps> extends ProviderProps<T> {
|
|
6
|
-
storage?: AppSettingsStorage;
|
|
7
|
-
}
|
|
8
|
-
export declare const AppSettingsProvider: React.FC<WithChildren<AppSettingsProviderProps>>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { AppSettingsContext } from './Context';
|
|
4
|
-
import { AppSettingsStorage } from './Storage';
|
|
5
|
-
export const AppSettingsProvider = ({ storage = new AppSettingsStorage(), value, children, ...props }) => {
|
|
6
|
-
const [developerMode, setDeveloperMode] = useState(storage.developerMode);
|
|
7
|
-
const [darkMode, setDarkMode] = useState(storage.darkMode);
|
|
8
|
-
const [navigationType, setNaviagtionType] = useState(storage.navigationType);
|
|
9
|
-
const enableDeveloperMode = (value) => {
|
|
10
|
-
storage.developerMode = value;
|
|
11
|
-
setDeveloperMode(storage.developerMode);
|
|
12
|
-
};
|
|
13
|
-
const enableDarkMode = (value) => {
|
|
14
|
-
storage.darkMode = value;
|
|
15
|
-
setDarkMode(storage.darkMode);
|
|
16
|
-
};
|
|
17
|
-
const changeNavigationType = (value) => {
|
|
18
|
-
storage.navigationType = value;
|
|
19
|
-
setNaviagtionType(value);
|
|
20
|
-
};
|
|
21
|
-
return (_jsx(AppSettingsContext.Provider, { value: {
|
|
22
|
-
changeNavigationType,
|
|
23
|
-
darkMode,
|
|
24
|
-
developerMode,
|
|
25
|
-
enableDarkMode,
|
|
26
|
-
enableDeveloperMode,
|
|
27
|
-
navigationType,
|
|
28
|
-
...value,
|
|
29
|
-
}, ...props, children: children }));
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=Provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/Provider.tsx"],"names":[],"mappings":";AAEA,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AQ,GACmB,CAC/B,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export var AppSettingSlug;
|
|
2
|
-
(function (AppSettingSlug) {
|
|
3
|
-
AppSettingSlug["DarkMode"] = "darkmode";
|
|
4
|
-
AppSettingSlug["Developer"] = "developer";
|
|
5
|
-
AppSettingSlug["NavigationType"] = "navgiationType";
|
|
6
|
-
})(AppSettingSlug || (AppSettingSlug = {}));
|
|
7
|
-
//# sourceMappingURL=Slug.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Slug.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/Slug.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,yCAAuB,CAAA;IACvB,mDAAiC,CAAA;AACnC,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { WebAppNavigationType } from '@xyo-network/react-app-settings';
|
|
2
|
-
import { AppSettingsStorageBase } from './StorageBase';
|
|
3
|
-
export declare class AppSettingsStorage extends AppSettingsStorageBase {
|
|
4
|
-
constructor(prefix?: string, defaults?: Record<string, unknown>);
|
|
5
|
-
get darkMode(): boolean;
|
|
6
|
-
set darkMode(value: boolean);
|
|
7
|
-
get developerMode(): boolean;
|
|
8
|
-
set developerMode(value: boolean);
|
|
9
|
-
get navigationType(): WebAppNavigationType;
|
|
10
|
-
set navigationType(value: WebAppNavigationType);
|
|
11
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { appSettingDefault } from './appSettingDefault';
|
|
2
|
-
import { AppSettingSlug } from './Slug';
|
|
3
|
-
import { AppSettingsStorageBase } from './StorageBase';
|
|
4
|
-
export class AppSettingsStorage extends AppSettingsStorageBase {
|
|
5
|
-
constructor(prefix = 'AppSettings', defaults) {
|
|
6
|
-
super(prefix, { ...appSettingDefault(), ...defaults });
|
|
7
|
-
}
|
|
8
|
-
get darkMode() {
|
|
9
|
-
return this.getBoolean(AppSettingSlug.DarkMode);
|
|
10
|
-
}
|
|
11
|
-
set darkMode(value) {
|
|
12
|
-
this.setBoolean(AppSettingSlug.DarkMode, value);
|
|
13
|
-
}
|
|
14
|
-
get developerMode() {
|
|
15
|
-
return this.getBoolean(AppSettingSlug.Developer);
|
|
16
|
-
}
|
|
17
|
-
set developerMode(value) {
|
|
18
|
-
this.setBoolean(AppSettingSlug.Developer, value);
|
|
19
|
-
}
|
|
20
|
-
get navigationType() {
|
|
21
|
-
return this.getString(AppSettingSlug.NavigationType);
|
|
22
|
-
}
|
|
23
|
-
set navigationType(value) {
|
|
24
|
-
this.setString(AppSettingSlug.NavigationType, value);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=Storage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Storage.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/Storage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAEtD,MAAM,OAAO,kBAAmB,SAAQ,sBAAsB;IAC5D,YAAY,MAAM,GAAG,aAAa,EAAE,QAAkC;QACpE,KAAK,CAAC,MAAM,EAAE,EAAE,GAAG,iBAAiB,EAAE,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAA;IACxD,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAA;IACjD,CAAC;IAED,IAAI,QAAQ,CAAC,KAAc;QACzB,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;IACjD,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,CAAA;IAClD,CAAC;IAED,IAAI,aAAa,CAAC,KAAc;QAC9B,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;IAClD,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,cAAc,CAAyB,CAAA;IAC9E,CAAC;IAED,IAAI,cAAc,CAAC,KAA2B;QAC5C,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,cAAc,EAAE,KAAK,CAAC,CAAA;IACtD,CAAC;CACF"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare class AppSettingsStorageBase {
|
|
2
|
-
private prefix;
|
|
3
|
-
private defaults;
|
|
4
|
-
constructor(prefix?: string, defaults?: Record<string, unknown>);
|
|
5
|
-
getBoolean(name: string): boolean;
|
|
6
|
-
setBoolean(name: string, value: boolean): void;
|
|
7
|
-
setNumber(name: string, value: number): void;
|
|
8
|
-
getNumber(name: string): number;
|
|
9
|
-
getString(name: string): string;
|
|
10
|
-
setString(name: string, value: string): void;
|
|
11
|
-
getStringArray(name: string): string[];
|
|
12
|
-
setStringArray(name: string, value: string[]): void;
|
|
13
|
-
getObject<T>(name: string): T;
|
|
14
|
-
setObject<T>(name: string, value: T): void;
|
|
15
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/sdk-js';
|
|
2
|
-
import { assertDefinedEx } from '@xyo-network/react-shared';
|
|
3
|
-
export class AppSettingsStorageBase {
|
|
4
|
-
constructor(prefix = 'AppSettings', defaults) {
|
|
5
|
-
this.prefix = prefix;
|
|
6
|
-
this.defaults = defaults ?? {};
|
|
7
|
-
}
|
|
8
|
-
getBoolean(name) {
|
|
9
|
-
const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
|
|
10
|
-
if (!storedValue) {
|
|
11
|
-
assertEx(typeof this.defaults[name] === 'boolean', 'Default value is not boolean');
|
|
12
|
-
const defaultValue = this.defaults[name];
|
|
13
|
-
assertEx(defaultValue !== undefined, `Missing Default for ${name}`);
|
|
14
|
-
return defaultValue;
|
|
15
|
-
}
|
|
16
|
-
return storedValue !== 'false';
|
|
17
|
-
}
|
|
18
|
-
setBoolean(name, value) {
|
|
19
|
-
localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value));
|
|
20
|
-
}
|
|
21
|
-
setNumber(name, value) {
|
|
22
|
-
localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value));
|
|
23
|
-
}
|
|
24
|
-
getNumber(name) {
|
|
25
|
-
const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
|
|
26
|
-
if (!storedValue) {
|
|
27
|
-
assertEx(typeof this.defaults[name] === 'boolean', 'Default value is not boolean');
|
|
28
|
-
const defaultValue = this.defaults[name];
|
|
29
|
-
assertEx(defaultValue !== undefined, `Missing Default for ${name}`);
|
|
30
|
-
return defaultValue;
|
|
31
|
-
}
|
|
32
|
-
return parseFloat(storedValue);
|
|
33
|
-
}
|
|
34
|
-
getString(name) {
|
|
35
|
-
const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
|
|
36
|
-
if (!storedValue) {
|
|
37
|
-
assertDefinedEx(typeof this.defaults[name] === 'string', 'Default value is not string');
|
|
38
|
-
const defaultValue = this.defaults[name];
|
|
39
|
-
assertEx(defaultValue !== undefined, `Missing Default for ${name}`);
|
|
40
|
-
return defaultValue;
|
|
41
|
-
}
|
|
42
|
-
return storedValue;
|
|
43
|
-
}
|
|
44
|
-
setString(name, value) {
|
|
45
|
-
localStorage.setItem(`${this.prefix}|${name}`, value);
|
|
46
|
-
}
|
|
47
|
-
getStringArray(name) {
|
|
48
|
-
const storedValue = localStorage.getItem(`${this.prefix}|${name}`)?.split(',');
|
|
49
|
-
if (!storedValue) {
|
|
50
|
-
assertDefinedEx(Array.isArray(this.defaults[name]), 'Default value is not array');
|
|
51
|
-
const defaultValue = this.defaults[name];
|
|
52
|
-
assertEx(defaultValue !== undefined, `Missing Default for ${name}`);
|
|
53
|
-
return defaultValue;
|
|
54
|
-
}
|
|
55
|
-
return storedValue;
|
|
56
|
-
}
|
|
57
|
-
setStringArray(name, value) {
|
|
58
|
-
localStorage.setItem(`${this.prefix}|${name}`, value.join(','));
|
|
59
|
-
}
|
|
60
|
-
getObject(name) {
|
|
61
|
-
const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
|
|
62
|
-
const parsedStoredValue = storedValue ? JSON.parse(storedValue) : null;
|
|
63
|
-
if (!parsedStoredValue) {
|
|
64
|
-
assertEx(typeof this.defaults[name] === 'object', 'Default value is not object');
|
|
65
|
-
return assertEx(this.defaults[name], `Missing Default for ${name}`);
|
|
66
|
-
}
|
|
67
|
-
return parsedStoredValue;
|
|
68
|
-
}
|
|
69
|
-
setObject(name, value) {
|
|
70
|
-
localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=StorageBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StorageBase.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/StorageBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3D,MAAM,OAAO,sBAAsB;IAGjC,YAAY,MAAM,GAAG,aAAa,EAAE,QAAkC;QACpE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,EAAE,CAAA;IAChC,CAAC;IAEM,UAAU,CAAC,IAAY;QAC5B,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC,CAAA;QAClE,IAAI,CAAC,WAAW,EAAE;Y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AAI,IAAY;QAC9B,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC,CAAA;QAClE,MAAM,iBAAiB,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QACtE,IAAI,CAAC,iBAAiB,EAAE;YACtB,QAAQ,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,QAAQ,EAAE,6BAA6B,CAAC,CAAA;YAChF,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAM,EAAE,uBAAuB,IAAI,EAAE,CAAC,CAAA;SACzE;QACD,OAAO,iBAAsB,CAAA;IAC/B,CAAC;IAEM,SAAS,CAAI,IAAY,EAAE,KAAQ;QACxC,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;IACvE,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const appSettingDefault: () => Record<string, unknown>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AppSettingSlug } from './Slug';
|
|
2
|
-
export const appSettingDefault = () => {
|
|
3
|
-
return {
|
|
4
|
-
[AppSettingSlug.DarkMode]: false,
|
|
5
|
-
[AppSettingSlug.Developer]: false,
|
|
6
|
-
[AppSettingSlug.NavigationType]: 'menu',
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=appSettingDefault.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appSettingDefault.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/appSettingDefault.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAEvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAA4B,EAAE;IAC7D,OAAO;QACL,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,KAAK;QAChC,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,KAAK;QACjC,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,MAAM;KACxC,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useAppSettings: () => import("./Context").AppSettingsContextProps;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useAppSettings.js","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/useAppSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAE9C,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,OAAO,UAAU,CAAC,kBAAkB,CAAC,CAAA;AACvC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './AppSettings';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
|