@xyo-network/react-app-settings 4.1.8 → 4.1.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/browser/WebAppNavigationType.d.ts +1 -0
- package/dist/browser/WebAppNavigationType.d.ts.map +1 -1
- package/dist/browser/components/DarkModeIconButton.d.ts +1 -0
- package/dist/browser/components/DarkModeIconButton.d.ts.map +1 -1
- package/dist/browser/components/Developer.d.ts +1 -0
- package/dist/browser/components/Developer.d.ts.map +1 -1
- package/dist/browser/contexts/AppSettings/Context.d.ts +2 -0
- package/dist/browser/contexts/AppSettings/Context.d.ts.map +1 -1
- package/dist/browser/contexts/AppSettings/Provider.d.ts +4 -3
- package/dist/browser/contexts/AppSettings/Provider.d.ts.map +1 -1
- package/dist/browser/contexts/AppSettings/Slug.d.ts +1 -0
- package/dist/browser/contexts/AppSettings/Slug.d.ts.map +1 -1
- package/dist/browser/contexts/AppSettings/Storage.d.ts +1 -0
- package/dist/browser/contexts/AppSettings/Storage.d.ts.map +1 -1
- package/dist/browser/contexts/AppSettings/StorageBase.d.ts +1 -0
- package/dist/browser/contexts/AppSettings/StorageBase.d.ts.map +1 -1
- package/dist/browser/contexts/AppSettings/appSettingDefault.d.ts +1 -0
- package/dist/browser/contexts/AppSettings/appSettingDefault.d.ts.map +1 -1
- package/dist/browser/contexts/AppSettings/useAppSettings.d.ts +1 -0
- package/dist/browser/contexts/AppSettings/useAppSettings.d.ts.map +1 -1
- package/dist/browser/index.mjs +3 -4
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +2 -4
- package/src/WebAppNavigationType.ts +1 -0
- package/src/components/DarkModeIconButton.tsx +1 -0
- package/src/components/Developer.tsx +1 -0
- package/src/contexts/AppSettings/Context.ts +2 -0
- package/src/contexts/AppSettings/Provider.tsx +4 -3
- package/src/contexts/AppSettings/Slug.ts +1 -0
- package/src/contexts/AppSettings/Storage.ts +1 -0
- package/src/contexts/AppSettings/StorageBase.ts +4 -4
- package/src/contexts/AppSettings/appSettingDefault.ts +1 -0
- package/src/contexts/AppSettings/useAppSettings.ts +1 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"WebAppNavigationType.d.ts","sourceRoot":"","sources":["../../src/WebAppNavigationType.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,SAAS,CAAA"}
|
1
|
+
{"version":3,"file":"WebAppNavigationType.d.ts","sourceRoot":"","sources":["../../src/WebAppNavigationType.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,SAAS,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DarkModeIconButton.d.ts","sourceRoot":"","sources":["../../../src/components/DarkModeIconButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpD,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAcxD,CAAA"}
|
1
|
+
{"version":3,"file":"DarkModeIconButton.d.ts","sourceRoot":"","sources":["../../../src/components/DarkModeIconButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpD,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,iEAAiE;AACjE,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAcxD,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Developer.d.ts","sourceRoot":"","sources":["../../../src/components/Developer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAIzC,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,CAI1D,CAAA"}
|
1
|
+
{"version":3,"file":"Developer.d.ts","sourceRoot":"","sources":["../../../src/components/Developer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAIzC,iEAAiE;AACjE,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,CAI1D,CAAA"}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { WebAppNavigationType } from '../../WebAppNavigationType.ts';
|
2
|
+
/** @deprecated import from @xylabs/react-app-settings instead */
|
2
3
|
export interface AppSettingsContextProps {
|
3
4
|
changeMaxAccounts?: (value: number) => void;
|
4
5
|
changeNavigationCollapsed?: (value: boolean) => void;
|
@@ -13,5 +14,6 @@ export interface AppSettingsContextProps {
|
|
13
14
|
navigationType?: WebAppNavigationType;
|
14
15
|
seedPhrase?: string;
|
15
16
|
}
|
17
|
+
/** @deprecated import from @xylabs/react-app-settings instead */
|
16
18
|
export declare const AppSettingsContext: import("react").Context<AppSettingsContextProps>;
|
17
19
|
//# sourceMappingURL=Context.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/Context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAGzE,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3C,yBAAyB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACpD,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAA;IAC5D,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACzC,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,cAAc,CAAC,EAAE,oBAAoB,CAAA;IACrC,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,eAAO,MAAM,kBAAkB,kDAA8D,CAAA"}
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/Context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAGzE,iEAAiE;AACjE,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3C,yBAAyB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACpD,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAA;IAC5D,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACzC,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,cAAc,CAAC,EAAE,oBAAoB,CAAA;IACrC,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,iEAAiE;AACjE,eAAO,MAAM,kBAAkB,kDAA8D,CAAA"}
|
@@ -1,10 +1,11 @@
|
|
1
|
-
import type {
|
2
|
-
import type { ProviderProps } from 'react';
|
1
|
+
import type { PropsWithChildren, ProviderProps } from 'react';
|
3
2
|
import React from 'react';
|
4
3
|
import type { AppSettingsContextProps } from './Context.ts';
|
5
4
|
import { AppSettingsStorage } from './Storage.ts';
|
5
|
+
/** @deprecated import from @xylabs/react-app-settings instead */
|
6
6
|
export interface AppSettingsProviderProps<T extends AppSettingsContextProps = AppSettingsContextProps> extends ProviderProps<T> {
|
7
7
|
storage?: AppSettingsStorage;
|
8
8
|
}
|
9
|
-
|
9
|
+
/** @deprecated import from @xylabs/react-app-settings instead */
|
10
|
+
export declare const AppSettingsProvider: React.FC<PropsWithChildren<AppSettingsProviderProps>>;
|
10
11
|
//# sourceMappingURL=Provider.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC7D,OAAO,KAA4B,MAAM,OAAO,CAAA;AAGhD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEjD,iEAAiE;AACjE,MAAM,WAAW,wBAAwB,CAAC,CAAC,SAAS,uBAAuB,GAAG,uBAAuB,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IAC7H,OAAO,CAAC,EAAE,kBAAkB,CAAA;CAC7B;AAED,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,CAoErF,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Slug.d.ts","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/Slug.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,cAAc,mBAAmB;IACjC,mBAAmB,wBAAwB;IAC3C,UAAU,eAAe;IACzB,WAAW,gBAAgB;CAC5B"}
|
1
|
+
{"version":3,"file":"Slug.d.ts","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/Slug.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,oBAAY,cAAc;IACxB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,cAAc,mBAAmB;IACjC,mBAAmB,wBAAwB;IAC3C,UAAU,eAAe;IACzB,WAAW,gBAAgB;CAC5B"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { WebAppNavigationType } from '../../WebAppNavigationType.ts';
|
2
2
|
import { AppSettingsStorageBase } from './StorageBase.ts';
|
3
|
+
/** @deprecated import from @xylabs/react-app-settings instead */
|
3
4
|
export declare class AppSettingsStorage extends AppSettingsStorageBase {
|
4
5
|
constructor(prefix?: string, defaults?: Record<string, unknown>);
|
5
6
|
get darkMode(): boolean;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Storage.d.ts","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/Storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAGzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAEzD,qBAAa,kBAAmB,SAAQ,sBAAsB;gBAChD,MAAM,SAAgB,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAItE,IAAI,QAAQ,IAIQ,OAAO,CAF1B;IAED,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,EAE1B;IAED,IAAI,aAAa,IAIQ,OAAO,CAF/B;IAED,IAAI,aAAa,CAAC,KAAK,EAAE,OAAO,EAE/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@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"StorageBase.d.ts","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/StorageBase.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"StorageBase.d.ts","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/StorageBase.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,MAAM,CAAQ;gBACV,MAAM,SAAgB,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAKtE,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAWjC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAW/B,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;IAU7B,SAAS,CAAC,IAAI,EAAE,MAAM;IAWtB,cAAc,CAAC,IAAI,EAAE,MAAM;IAW3B,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;IAIvC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAIrC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAInC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAIrC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;CAG7C"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"appSettingDefault.d.ts","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/appSettingDefault.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,QAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAS1D,CAAA"}
|
1
|
+
{"version":3,"file":"appSettingDefault.d.ts","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/appSettingDefault.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,QAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAS1D,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useAppSettings.d.ts","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/useAppSettings.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,sDAE1B,CAAA"}
|
1
|
+
{"version":3,"file":"useAppSettings.d.ts","sourceRoot":"","sources":["../../../../src/contexts/AppSettings/useAppSettings.ts"],"names":[],"mappings":"AAIA,iEAAiE;AACjE,eAAO,MAAM,cAAc,sDAE1B,CAAA"}
|
package/dist/browser/index.mjs
CHANGED
@@ -39,8 +39,7 @@ var AppSettingsContext = createContext(appSettingDefault());
|
|
39
39
|
import React, { useMemo, useState } from "react";
|
40
40
|
|
41
41
|
// src/contexts/AppSettings/StorageBase.ts
|
42
|
-
import { assertEx } from "@xylabs/assert";
|
43
|
-
import { assertDefinedEx } from "@xyo-network/react-shared";
|
42
|
+
import { assertDefinedEx, assertEx } from "@xylabs/assert";
|
44
43
|
var AppSettingsStorageBase = class {
|
45
44
|
static {
|
46
45
|
__name(this, "AppSettingsStorageBase");
|
@@ -83,7 +82,7 @@ var AppSettingsStorageBase = class {
|
|
83
82
|
getString(name) {
|
84
83
|
const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
|
85
84
|
if (!storedValue) {
|
86
|
-
assertDefinedEx(typeof this.defaults[name] === "string", "Default value is not string");
|
85
|
+
assertDefinedEx(typeof this.defaults[name] === "string", () => "Default value is not string");
|
87
86
|
const defaultValue = this.defaults[name];
|
88
87
|
assertEx(defaultValue !== void 0, () => `Missing Default for ${name}`);
|
89
88
|
return defaultValue;
|
@@ -93,7 +92,7 @@ var AppSettingsStorageBase = class {
|
|
93
92
|
getStringArray(name) {
|
94
93
|
const storedValue = localStorage.getItem(`${this.prefix}|${name}`)?.split(",");
|
95
94
|
if (!storedValue) {
|
96
|
-
assertDefinedEx(Array.isArray(this.defaults[name]), "Default value is not array");
|
95
|
+
assertDefinedEx(Array.isArray(this.defaults[name]), () => "Default value is not array");
|
97
96
|
const defaultValue = this.defaults[name];
|
98
97
|
assertEx(defaultValue !== void 0, () => `Missing Default for ${name}`);
|
99
98
|
return defaultValue;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/components/DarkModeIconButton.tsx","../../src/contexts/AppSettings/Context.ts","../../src/contexts/AppSettings/Slug.ts","../../src/contexts/AppSettings/appSettingDefault.ts","../../src/contexts/AppSettings/Provider.tsx","../../src/contexts/AppSettings/StorageBase.ts","../../src/contexts/AppSettings/Storage.ts","../../src/contexts/AppSettings/useAppSettings.ts","../../src/components/Developer.tsx"],"sourcesContent":["import { DarkModeRounded as DarkModeRoundedIcon, LightModeRounded as LightModeRoundedIcon } from '@mui/icons-material'\nimport type { IconButtonProps } from '@mui/material'\nimport { IconButton } from '@mui/material'\nimport React from 'react'\n\nimport { useAppSettings } from '../contexts/index.ts'\n\nexport const DarkModeIconButton: React.FC<IconButtonProps> = (props) => {\n const { darkMode, enableDarkMode } = useAppSettings()\n\n const handleDarkModeChange = () => {\n enableDarkMode?.(!darkMode)\n }\n\n return (\n <IconButton onClick={handleDarkModeChange} {...props}>\n {darkMode\n ? <DarkModeRoundedIcon />\n : <LightModeRoundedIcon />}\n </IconButton>\n )\n}\n","import { createContext } from 'react'\n\nimport type { WebAppNavigationType } from '../../WebAppNavigationType.ts'\nimport { appSettingDefault } from './appSettingDefault.ts'\n\nexport interface AppSettingsContextProps {\n changeMaxAccounts?: (value: number) => void\n changeNavigationCollapsed?: (value: boolean) => void\n changeNavigationType?: (value: WebAppNavigationType) => void\n changeSeedPhrase?: (value: string) => void\n darkMode?: boolean\n developerMode?: boolean\n enableDarkMode?: (value: boolean) => void\n enableDeveloperMode?: (value: boolean) => void\n maxAccounts?: number\n navigationCollapsed?: boolean\n navigationType?: WebAppNavigationType\n seedPhrase?: string\n}\n\nexport const AppSettingsContext = createContext<AppSettingsContextProps>(appSettingDefault())\n","export enum AppSettingSlug {\n DarkMode = 'darkmode',\n Developer = 'developer',\n NavigationType = 'navigationType',\n NavigationCollapsed = 'navigationCollapsed',\n SeedPhrase = 'seedPhrase',\n MaxAccounts = 'maxAccounts',\n}\n","import { AppSettingSlug } from './Slug.ts'\n\nexport const appSettingDefault = (): Record<string, unknown> => {\n return {\n [AppSettingSlug.DarkMode]: false,\n [AppSettingSlug.Developer]: false,\n [AppSettingSlug.NavigationType]: 'menu',\n [AppSettingSlug.NavigationCollapsed]: false,\n [AppSettingSlug.SeedPhrase]: '',\n [AppSettingSlug.MaxAccounts]: 1,\n }\n}\n","import type { WithChildren } from '@xylabs/react-shared'\nimport type { ProviderProps } from 'react'\nimport React, { useMemo, useState } from 'react'\n\nimport type { WebAppNavigationType } from '../../WebAppNavigationType.ts'\nimport type { AppSettingsContextProps } from './Context.ts'\nimport { AppSettingsContext } from './Context.ts'\nimport { AppSettingsStorage } from './Storage.ts'\n\nexport interface AppSettingsProviderProps<T extends AppSettingsContextProps = AppSettingsContextProps> extends ProviderProps<T> {\n storage?: AppSettingsStorage\n}\n\nexport const AppSettingsProvider: React.FC<WithChildren<AppSettingsProviderProps>> = ({\n storage,\n value,\n children,\n ...props\n}) => {\n const storageMemo = useMemo(() => storage ?? new AppSettingsStorage(), [storage])\n const [developerMode, setDeveloperMode] = useState(storageMemo.developerMode)\n const [darkMode, setDarkMode] = useState(storageMemo.darkMode)\n const [navigationType, setNavigationType] = useState(storageMemo.navigationType)\n const [navigationCollapsed, setNavigationCollapsed] = useState(storageMemo.navigationCollapsed)\n const [seedPhrase, setSeedPhrase] = useState(storageMemo.seedPhrase)\n const [maxAccounts, setMaxAccounts] = useState(storageMemo.maxAccounts)\n\n const enableDeveloperMode = (value: boolean) => {\n storageMemo.developerMode = value\n setDeveloperMode(storageMemo.developerMode)\n }\n\n const enableDarkMode = (value: boolean) => {\n storageMemo.darkMode = value\n setDarkMode(storageMemo.darkMode)\n }\n\n const changeNavigationType = (value: WebAppNavigationType) => {\n storageMemo.navigationType = value\n setNavigationType(value)\n }\n\n const changeNavigationCollapsed = (value: boolean) => {\n storageMemo.navigationCollapsed = value\n setNavigationCollapsed(value)\n }\n\n const changeSeedPhrase = (value: string) => {\n storageMemo.seedPhrase = value\n setSeedPhrase(value)\n }\n\n const changeMaxAccounts = (value: number) => {\n storageMemo.maxAccounts = value\n setMaxAccounts(value)\n }\n\n return (\n <AppSettingsContext.Provider\n // eslint-disable-next-line @eslint-react/no-unstable-context-value\n value={{\n changeMaxAccounts,\n changeNavigationCollapsed,\n changeNavigationType,\n changeSeedPhrase,\n darkMode,\n developerMode,\n enableDarkMode,\n enableDeveloperMode,\n maxAccounts,\n navigationCollapsed,\n navigationType,\n seedPhrase,\n\n ...value,\n }}\n {...props}\n >\n {children}\n </AppSettingsContext.Provider>\n )\n}\n","import { assertEx } from '@xylabs/assert'\nimport { assertDefinedEx } from '@xyo-network/react-shared'\n\nexport class AppSettingsStorageBase {\n private defaults: Record<string, unknown>\n private prefix: string\n constructor(prefix = 'AppSettings', defaults?: Record<string, unknown>) {\n this.prefix = prefix\n this.defaults = defaults ?? {}\n }\n\n getBoolean(name: string): boolean {\n const storedValue = localStorage.getItem(`${this.prefix}|${name}`)\n if (!storedValue) {\n assertEx(typeof this.defaults[name] === 'boolean', () => 'Default value is not boolean')\n const defaultValue = this.defaults[name] as boolean\n assertEx(defaultValue !== undefined, () => `Missing Default for ${name}`)\n return defaultValue\n }\n return storedValue !== 'false'\n }\n\n getNumber(name: string): number {\n const storedValue = localStorage.getItem(`${this.prefix}|${name}`)\n if (!storedValue) {\n assertEx(typeof this.defaults[name] === 'number', () => 'Default value is not a number')\n const defaultValue = this.defaults[name] as number\n assertEx(defaultValue !== undefined, () => `Missing Default for ${name}`)\n return defaultValue\n }\n return Number.parseFloat(storedValue)\n }\n\n getObject<T>(name: string): T {\n const storedValue = localStorage.getItem(`${this.prefix}|${name}`)\n const parsedStoredValue = storedValue ? JSON.parse(storedValue) : null\n if (!parsedStoredValue) {\n assertEx(typeof this.defaults[name] === 'object', () => 'Default value is not object')\n return assertEx(this.defaults[name] as T, () => `Missing Default for ${name}`)\n }\n return parsedStoredValue as T\n }\n\n getString(name: string) {\n const storedValue = localStorage.getItem(`${this.prefix}|${name}`)\n if (!storedValue) {\n assertDefinedEx(typeof this.defaults[name] === 'string', 'Default value is not string')\n const defaultValue = this.defaults[name] as string\n assertEx(defaultValue !== undefined, () => `Missing Default for ${name}`)\n return defaultValue\n }\n return storedValue\n }\n\n getStringArray(name: string) {\n const storedValue = localStorage.getItem(`${this.prefix}|${name}`)?.split(',')\n if (!storedValue) {\n assertDefinedEx(Array.isArray(this.defaults[name]), 'Default value is not array')\n const defaultValue = this.defaults[name] as string[]\n assertEx(defaultValue !== undefined, () => `Missing Default for ${name}`)\n return defaultValue\n }\n return storedValue\n }\n\n setBoolean(name: string, value: boolean) {\n localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value))\n }\n\n setNumber(name: string, value: number) {\n localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value))\n }\n\n setObject<T>(name: string, value: T) {\n localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value))\n }\n\n setString(name: string, value: string) {\n localStorage.setItem(`${this.prefix}|${name}`, value)\n }\n\n setStringArray(name: string, value: string[]) {\n localStorage.setItem(`${this.prefix}|${name}`, value.join(','))\n }\n}\n","import type { WebAppNavigationType } from '../../WebAppNavigationType.ts'\nimport { appSettingDefault } from './appSettingDefault.ts'\nimport { AppSettingSlug } from './Slug.ts'\nimport { AppSettingsStorageBase } from './StorageBase.ts'\n\nexport class AppSettingsStorage extends AppSettingsStorageBase {\n constructor(prefix = 'AppSettings', defaults?: Record<string, unknown>) {\n super(prefix, { ...appSettingDefault(), ...defaults })\n }\n\n get darkMode() {\n return this.getBoolean(AppSettingSlug.DarkMode)\n }\n\n set darkMode(value: boolean) {\n this.setBoolean(AppSettingSlug.DarkMode, value)\n }\n\n get developerMode() {\n return this.getBoolean(AppSettingSlug.Developer)\n }\n\n set developerMode(value: boolean) {\n this.setBoolean(AppSettingSlug.Developer, value)\n }\n\n get maxAccounts() {\n return this.getNumber(AppSettingSlug.MaxAccounts)\n }\n\n set maxAccounts(value: number) {\n this.setNumber(AppSettingSlug.MaxAccounts, value)\n }\n\n get navigationCollapsed() {\n return this.getBoolean(AppSettingSlug.NavigationCollapsed)\n }\n\n set navigationCollapsed(value: boolean) {\n this.setBoolean(AppSettingSlug.NavigationCollapsed, value)\n }\n\n get navigationType() {\n return this.getString(AppSettingSlug.NavigationType) as WebAppNavigationType\n }\n\n set navigationType(value: WebAppNavigationType) {\n this.setString(AppSettingSlug.NavigationType, value)\n }\n\n get seedPhrase() {\n return this.getString(AppSettingSlug.SeedPhrase)\n }\n\n set seedPhrase(value: string) {\n this.setString(AppSettingSlug.SeedPhrase, value)\n }\n}\n","import { useContext } from 'react'\n\nimport { AppSettingsContext } from './Context.ts'\n\nexport const useAppSettings = () => {\n return useContext(AppSettingsContext)\n}\n","import type { ReactElement } from 'react'\n\nimport { useAppSettings } from '../contexts/index.ts'\n\nexport const Developer: React.FC<{ children: ReactElement }> = ({ children = null }) => {\n const { developerMode } = useAppSettings()\n\n return developerMode ? children : null\n}\n"],"mappings":";;;;AAAA,SAASA,mBAAmBC,qBAAqBC,oBAAoBC,4BAA4B;AAEjG,SAASC,kBAAkB;AAC3B,OAAOC,YAAW;;;ACHlB,SAASC,qBAAqB;;;ACAvB,IAAKC,iBAAAA,yBAAAA,iBAAAA;;;;;;;SAAAA;;;;ACEL,IAAMC,oBAAoB,6BAAA;AAC/B,SAAO;IACL,CAACC,eAAeC,QAAQ,GAAG;IAC3B,CAACD,eAAeE,SAAS,GAAG;IAC5B,CAACF,eAAeG,cAAc,GAAG;IACjC,CAACH,eAAeI,mBAAmB,GAAG;IACtC,CAACJ,eAAeK,UAAU,GAAG;IAC7B,CAACL,eAAeM,WAAW,GAAG;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ACAc;MACAD;MACAF;MACAJ;MACAF;MACAI;MAEA,GAAGf;IACL;IACC,GAAGE;KAEHD,QAAAA;AAGP,GApEqF;;;AGbrF,SAAS0B,kBAAkB;AAIpB,IAAMC,iBAAiB,6BAAA;AAC5B,SAAOC,WAAWC,kBAAAA;AACpB,GAF8B;;;APGvB,IAAMC,qBAAgD,wBAACC,UAAAA;AAC5D,QAAM,EAAEC,UAAUC,eAAc,IAAKC,eAAAA;AAErC,QAAMC,uBAAuB,6BAAA;AAC3BF,qBAAiB,CAACD,QAAAA;EACpB,GAF6B;AAI7B,SACE,gBAAAI,OAAA,cAACC,YAAAA;IAAWC,SAASH;IAAuB,GAAGJ;KAC5CC,WACG,gBAAAI,OAAA,cAACG,qBAAAA,IAAAA,IACD,gBAAAH,OAAA,cAACI,sBAAAA,IAAAA,CAAAA;AAGX,GAd6D;;;AQHtD,IAAMC,YAAkD,wBAAC,EAAEC,WAAW,KAAI,MAAE;AACjF,QAAM,EAAEC,cAAa,IAAKC,eAAAA;AAE1B,SAAOD,gBAAgBD,WAAW;AACpC,GAJ+D;","names":["DarkModeRounded","DarkModeRoundedIcon","LightModeRounded","LightModeRoundedIcon","IconButton","React","createContext","AppSettingSlug","appSettingDefault","AppSettingSlug","DarkMode","Developer","NavigationType","NavigationCollapsed","SeedPhrase","MaxAccounts","AppSettingsContext","createContext","appSettingDefault","React","useMemo","useState","assertEx","assertDefinedEx","AppSettingsStorageBase","defaults","prefix","constructor","getBoolean","name","storedValue","localStorage","getItem","assertEx","defaultValue","undefined","getNumber","Number","parseFloat","getObject","parsedStoredValue","JSON","parse","getString","assertDefinedEx","getStringArray","split","Array","isArray","setBoolean","value","setItem","stringify","setNumber","setObject","setString","setStringArray","join","AppSettingsStorage","AppSettingsStorageBase","constructor","prefix","defaults","appSettingDefault","darkMode","getBoolean","AppSettingSlug","DarkMode","value","setBoolean","developerMode","Developer","maxAccounts","getNumber","MaxAccounts","setNumber","navigationCollapsed","NavigationCollapsed","navigationType","getString","NavigationType","setString","seedPhrase","SeedPhrase","AppSettingsProvider","storage","value","children","props","storageMemo","useMemo","AppSettingsStorage","developerMode","setDeveloperMode","useState","darkMode","setDarkMode","navigationType","setNavigationType","navigationCollapsed","setNavigationCollapsed","seedPhrase","setSeedPhrase","maxAccounts","setMaxAccounts","enableDeveloperMode","enableDarkMode","changeNavigationType","changeNavigationCollapsed","changeSeedPhrase","changeMaxAccounts","AppSettingsContext","Provider","useContext","useAppSettings","useContext","AppSettingsContext","DarkModeIconButton","props","darkMode","enableDarkMode","useAppSettings","handleDarkModeChange","React","IconButton","onClick","DarkModeRoundedIcon","LightModeRoundedIcon","Developer","children","developerMode","useAppSettings"]}
|
1
|
+
{"version":3,"sources":["../../src/components/DarkModeIconButton.tsx","../../src/contexts/AppSettings/Context.ts","../../src/contexts/AppSettings/Slug.ts","../../src/contexts/AppSettings/appSettingDefault.ts","../../src/contexts/AppSettings/Provider.tsx","../../src/contexts/AppSettings/StorageBase.ts","../../src/contexts/AppSettings/Storage.ts","../../src/contexts/AppSettings/useAppSettings.ts","../../src/components/Developer.tsx"],"sourcesContent":["import { DarkModeRounded as DarkModeRoundedIcon, LightModeRounded as LightModeRoundedIcon } from '@mui/icons-material'\nimport type { IconButtonProps } from '@mui/material'\nimport { IconButton } from '@mui/material'\nimport React from 'react'\n\nimport { useAppSettings } from '../contexts/index.ts'\n\n/** @deprecated import from @xylabs/react-app-settings instead */\nexport const DarkModeIconButton: React.FC<IconButtonProps> = (props) => {\n const { darkMode, enableDarkMode } = useAppSettings()\n\n const handleDarkModeChange = () => {\n enableDarkMode?.(!darkMode)\n }\n\n return (\n <IconButton onClick={handleDarkModeChange} {...props}>\n {darkMode\n ? <DarkModeRoundedIcon />\n : <LightModeRoundedIcon />}\n </IconButton>\n )\n}\n","import { createContext } from 'react'\n\nimport type { WebAppNavigationType } from '../../WebAppNavigationType.ts'\nimport { appSettingDefault } from './appSettingDefault.ts'\n\n/** @deprecated import from @xylabs/react-app-settings instead */\nexport interface AppSettingsContextProps {\n changeMaxAccounts?: (value: number) => void\n changeNavigationCollapsed?: (value: boolean) => void\n changeNavigationType?: (value: WebAppNavigationType) => void\n changeSeedPhrase?: (value: string) => void\n darkMode?: boolean\n developerMode?: boolean\n enableDarkMode?: (value: boolean) => void\n enableDeveloperMode?: (value: boolean) => void\n maxAccounts?: number\n navigationCollapsed?: boolean\n navigationType?: WebAppNavigationType\n seedPhrase?: string\n}\n\n/** @deprecated import from @xylabs/react-app-settings instead */\nexport const AppSettingsContext = createContext<AppSettingsContextProps>(appSettingDefault())\n","/** @deprecated import from @xylabs/react-app-settings instead */\nexport enum AppSettingSlug {\n DarkMode = 'darkmode',\n Developer = 'developer',\n NavigationType = 'navigationType',\n NavigationCollapsed = 'navigationCollapsed',\n SeedPhrase = 'seedPhrase',\n MaxAccounts = 'maxAccounts',\n}\n","import { AppSettingSlug } from './Slug.ts'\n\n/** @deprecated import from @xylabs/react-app-settings instead */\nexport const appSettingDefault = (): Record<string, unknown> => {\n return {\n [AppSettingSlug.DarkMode]: false,\n [AppSettingSlug.Developer]: false,\n [AppSettingSlug.NavigationType]: 'menu',\n [AppSettingSlug.NavigationCollapsed]: false,\n [AppSettingSlug.SeedPhrase]: '',\n [AppSettingSlug.MaxAccounts]: 1,\n }\n}\n","import type { PropsWithChildren, ProviderProps } from 'react'\nimport React, { useMemo, useState } from 'react'\n\nimport type { WebAppNavigationType } from '../../WebAppNavigationType.ts'\nimport type { AppSettingsContextProps } from './Context.ts'\nimport { AppSettingsContext } from './Context.ts'\nimport { AppSettingsStorage } from './Storage.ts'\n\n/** @deprecated import from @xylabs/react-app-settings instead */\nexport interface AppSettingsProviderProps<T extends AppSettingsContextProps = AppSettingsContextProps> extends ProviderProps<T> {\n storage?: AppSettingsStorage\n}\n\n/** @deprecated import from @xylabs/react-app-settings instead */\nexport const AppSettingsProvider: React.FC<PropsWithChildren<AppSettingsProviderProps>> = ({\n storage,\n value,\n children,\n ...props\n}) => {\n const storageMemo = useMemo(() => storage ?? new AppSettingsStorage(), [storage])\n const [developerMode, setDeveloperMode] = useState(storageMemo.developerMode)\n const [darkMode, setDarkMode] = useState(storageMemo.darkMode)\n const [navigationType, setNavigationType] = useState(storageMemo.navigationType)\n const [navigationCollapsed, setNavigationCollapsed] = useState(storageMemo.navigationCollapsed)\n const [seedPhrase, setSeedPhrase] = useState(storageMemo.seedPhrase)\n const [maxAccounts, setMaxAccounts] = useState(storageMemo.maxAccounts)\n\n const enableDeveloperMode = (value: boolean) => {\n storageMemo.developerMode = value\n setDeveloperMode(storageMemo.developerMode)\n }\n\n const enableDarkMode = (value: boolean) => {\n storageMemo.darkMode = value\n setDarkMode(storageMemo.darkMode)\n }\n\n const changeNavigationType = (value: WebAppNavigationType) => {\n storageMemo.navigationType = value\n setNavigationType(value)\n }\n\n const changeNavigationCollapsed = (value: boolean) => {\n storageMemo.navigationCollapsed = value\n setNavigationCollapsed(value)\n }\n\n const changeSeedPhrase = (value: string) => {\n storageMemo.seedPhrase = value\n setSeedPhrase(value)\n }\n\n const changeMaxAccounts = (value: number) => {\n storageMemo.maxAccounts = value\n setMaxAccounts(value)\n }\n\n return (\n <AppSettingsContext.Provider\n // eslint-disable-next-line @eslint-react/no-unstable-context-value\n value={{\n changeMaxAccounts,\n changeNavigationCollapsed,\n changeNavigationType,\n changeSeedPhrase,\n darkMode,\n developerMode,\n enableDarkMode,\n enableDeveloperMode,\n maxAccounts,\n navigationCollapsed,\n navigationType,\n seedPhrase,\n\n ...value,\n }}\n {...props}\n >\n {children}\n </AppSettingsContext.Provider>\n )\n}\n","import { assertDefinedEx, assertEx } from '@xylabs/assert'\n\n/** @deprecated import from @xylabs/react-app-settings instead */\nexport class AppSettingsStorageBase {\n private defaults: Record<string, unknown>\n private prefix: string\n constructor(prefix = 'AppSettings', defaults?: Record<string, unknown>) {\n this.prefix = prefix\n this.defaults = defaults ?? {}\n }\n\n getBoolean(name: string): boolean {\n const storedValue = localStorage.getItem(`${this.prefix}|${name}`)\n if (!storedValue) {\n assertEx(typeof this.defaults[name] === 'boolean', () => 'Default value is not boolean')\n const defaultValue = this.defaults[name] as boolean\n assertEx(defaultValue !== undefined, () => `Missing Default for ${name}`)\n return defaultValue\n }\n return storedValue !== 'false'\n }\n\n getNumber(name: string): number {\n const storedValue = localStorage.getItem(`${this.prefix}|${name}`)\n if (!storedValue) {\n assertEx(typeof this.defaults[name] === 'number', () => 'Default value is not a number')\n const defaultValue = this.defaults[name] as number\n assertEx(defaultValue !== undefined, () => `Missing Default for ${name}`)\n return defaultValue\n }\n return Number.parseFloat(storedValue)\n }\n\n getObject<T>(name: string): T {\n const storedValue = localStorage.getItem(`${this.prefix}|${name}`)\n const parsedStoredValue = storedValue ? JSON.parse(storedValue) : null\n if (!parsedStoredValue) {\n assertEx(typeof this.defaults[name] === 'object', () => 'Default value is not object')\n return assertEx(this.defaults[name] as T, () => `Missing Default for ${name}`)\n }\n return parsedStoredValue as T\n }\n\n getString(name: string) {\n const storedValue = localStorage.getItem(`${this.prefix}|${name}`)\n if (!storedValue) {\n assertDefinedEx(typeof this.defaults[name] === 'string', () => 'Default value is not string')\n const defaultValue = this.defaults[name] as string\n assertEx(defaultValue !== undefined, () => `Missing Default for ${name}`)\n return defaultValue\n }\n return storedValue\n }\n\n getStringArray(name: string) {\n const storedValue = localStorage.getItem(`${this.prefix}|${name}`)?.split(',')\n if (!storedValue) {\n assertDefinedEx(Array.isArray(this.defaults[name]), () => 'Default value is not array')\n const defaultValue = this.defaults[name] as string[]\n assertEx(defaultValue !== undefined, () => `Missing Default for ${name}`)\n return defaultValue\n }\n return storedValue\n }\n\n setBoolean(name: string, value: boolean) {\n localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value))\n }\n\n setNumber(name: string, value: number) {\n localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value))\n }\n\n setObject<T>(name: string, value: T) {\n localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value))\n }\n\n setString(name: string, value: string) {\n localStorage.setItem(`${this.prefix}|${name}`, value)\n }\n\n setStringArray(name: string, value: string[]) {\n localStorage.setItem(`${this.prefix}|${name}`, value.join(','))\n }\n}\n","import type { WebAppNavigationType } from '../../WebAppNavigationType.ts'\nimport { appSettingDefault } from './appSettingDefault.ts'\nimport { AppSettingSlug } from './Slug.ts'\nimport { AppSettingsStorageBase } from './StorageBase.ts'\n\n/** @deprecated import from @xylabs/react-app-settings instead */\nexport class AppSettingsStorage extends AppSettingsStorageBase {\n constructor(prefix = 'AppSettings', defaults?: Record<string, unknown>) {\n super(prefix, { ...appSettingDefault(), ...defaults })\n }\n\n get darkMode() {\n return this.getBoolean(AppSettingSlug.DarkMode)\n }\n\n set darkMode(value: boolean) {\n this.setBoolean(AppSettingSlug.DarkMode, value)\n }\n\n get developerMode() {\n return this.getBoolean(AppSettingSlug.Developer)\n }\n\n set developerMode(value: boolean) {\n this.setBoolean(AppSettingSlug.Developer, value)\n }\n\n get maxAccounts() {\n return this.getNumber(AppSettingSlug.MaxAccounts)\n }\n\n set maxAccounts(value: number) {\n this.setNumber(AppSettingSlug.MaxAccounts, value)\n }\n\n get navigationCollapsed() {\n return this.getBoolean(AppSettingSlug.NavigationCollapsed)\n }\n\n set navigationCollapsed(value: boolean) {\n this.setBoolean(AppSettingSlug.NavigationCollapsed, value)\n }\n\n get navigationType() {\n return this.getString(AppSettingSlug.NavigationType) as WebAppNavigationType\n }\n\n set navigationType(value: WebAppNavigationType) {\n this.setString(AppSettingSlug.NavigationType, value)\n }\n\n get seedPhrase() {\n return this.getString(AppSettingSlug.SeedPhrase)\n }\n\n set seedPhrase(value: string) {\n this.setString(AppSettingSlug.SeedPhrase, value)\n }\n}\n","import { useContext } from 'react'\n\nimport { AppSettingsContext } from './Context.ts'\n\n/** @deprecated import from @xylabs/react-app-settings instead */\nexport const useAppSettings = () => {\n return useContext(AppSettingsContext)\n}\n","import type { ReactElement } from 'react'\n\nimport { useAppSettings } from '../contexts/index.ts'\n\n/** @deprecated import from @xylabs/react-app-settings instead */\nexport const Developer: React.FC<{ children: ReactElement }> = ({ children = null }) => {\n const { developerMode } = useAppSettings()\n\n return developerMode ? children : null\n}\n"],"mappings":";;;;AAAA,SAASA,mBAAmBC,qBAAqBC,oBAAoBC,4BAA4B;AAEjG,SAASC,kBAAkB;AAC3B,OAAOC,YAAW;;;ACHlB,SAASC,qBAAqB;;;ACCvB,IAAKC,iBAAAA,yBAAAA,iBAAAA;;;;;;;SAAAA;;;;ACEL,IAAMC,oBAAoB,6BAAA;AAC/B,SAAO;IACL,CAACC,eAAeC,QAAQ,GAAG;IAC3B,CAACD,eAAeE,SAAS,GAAG;IAC5B,CAACF,eAAeG,cAAc,GAAG;IACjC,CAACH,eAAeI,mBAAmB,GAAG;IACtC,CAACJ,eAAeK,UAAU,GAAG;IAC7B,CAACL,eAAeM,WAAW,GAAG;EAChC;AACF,GATiC;;;AFmB1B,IAAMC,qBAAqBC,cAAuCC,kBAAAA,CAAAA;;;AGrBzE,OAAOC,SAASC,SAASC,gBAAgB;;;ACDzC,SAASC,iBAAiBC,gBAAgB;AAGnC,IAAMC,yBAAN,MAAMA;EAHb,OAGaA;;;EACHC;EACAC;EACRC,YAAYD,SAAS,eAAeD,UAAoC;AACtE,SAAKC,SAASA;AACd,SAAKD,WAAWA,YAAY,CAAC;EAC/B;EAEAG,WAAWC,MAAuB;AAChC,UAAMC,cAAcC,aAAaC,QAAQ,GAAG,KAAKN,MAAM,IAAIG,IAAAA,EAAM;AACjE,QAAI,CAACC,aAAa;AAChBG,eAAS,OAAO,KAAKR,SAASI,IAAAA,MAAU,WAAW,MAAM,8BAAA;AACzD,YAAMK,eAAe,KAAKT,SAASI,IAAAA;AACnCI,eAASC,iBAAiBC,QAAW,MAAM,uBAAuBN,IAAAA,EAAM;AACxE,aAAOK;IACT;AACA,WAAOJ,gBAAgB;EACzB;EAEAM,UAAUP,MAAsB;AAC9B,UAAMC,cAAcC,aAAaC,QAAQ,GAAG,KAAKN,MAAM,IAAIG,IAAAA,EAAM;AACj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ModeRoundedIcon","IconButton","React","createContext","AppSettingSlug","appSettingDefault","AppSettingSlug","DarkMode","Developer","NavigationType","NavigationCollapsed","SeedPhrase","MaxAccounts","AppSettingsContext","createContext","appSettingDefault","React","useMemo","useState","assertDefinedEx","assertEx","AppSettingsStorageBase","defaults","prefix","constructor","getBoolean","name","storedValue","localStorage","getItem","assertEx","defaultValue","undefined","getNumber","Number","parseFloat","getObject","parsedStoredValue","JSON","parse","getString","assertDefinedEx","getStringArray","split","Array","isArray","setBoolean","value","setItem","stringify","setNumber","setObject","setString","setStringArray","join","AppSettingsStorage","AppSettingsStorageBase","constructor","prefix","defaults","appSettingDefault","darkMode","getBoolean","AppSettingSlug","DarkMode","value","setBoolean","developerMode","Developer","maxAccounts","getNumber","MaxAccounts","setNumber","navigationCollapsed","NavigationCollapsed","navigationType","getString","NavigationType","setString","seedPhrase","SeedPhrase","AppSettingsProvider","storage","value","children","props","storageMemo","useMemo","AppSettingsStorage","developerMode","setDeveloperMode","useState","darkMode","setDarkMode","navigationType","setNavigationType","navigationCollapsed","setNavigationCollapsed","seedPhrase","setSeedPhrase","maxAccounts","setMaxAccounts","enableDeveloperMode","enableDarkMode","changeNavigationType","changeNavigationCollapsed","changeSeedPhrase","changeMaxAccounts","AppSettingsContext","Provider","useContext","useAppSettings","useContext","AppSettingsContext","DarkModeIconButton","props","darkMode","enableDarkMode","useAppSettings","handleDarkModeChange","React","IconButton","onClick","DarkModeRoundedIcon","LightModeRoundedIcon","Developer","children","developerMode","useAppSettings"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@xyo-network/react-app-settings",
|
3
|
-
"version": "4.1.
|
3
|
+
"version": "4.1.9",
|
4
4
|
"description": "Common React library for all XYO projects that use React",
|
5
5
|
"keywords": [
|
6
6
|
"xyo",
|
@@ -43,9 +43,7 @@
|
|
43
43
|
"lint-pkg": "npmPkgJsonLint ."
|
44
44
|
},
|
45
45
|
"dependencies": {
|
46
|
-
"@xylabs/assert": "^4.3.
|
47
|
-
"@xylabs/react-shared": "^5.2.4",
|
48
|
-
"@xyo-network/react-shared": "^4.1.8"
|
46
|
+
"@xylabs/assert": "^4.3.3"
|
49
47
|
},
|
50
48
|
"devDependencies": {
|
51
49
|
"@mui/icons-material": "^6.1.5",
|
@@ -5,6 +5,7 @@ import React from 'react'
|
|
5
5
|
|
6
6
|
import { useAppSettings } from '../contexts/index.ts'
|
7
7
|
|
8
|
+
/** @deprecated import from @xylabs/react-app-settings instead */
|
8
9
|
export const DarkModeIconButton: React.FC<IconButtonProps> = (props) => {
|
9
10
|
const { darkMode, enableDarkMode } = useAppSettings()
|
10
11
|
|
@@ -2,6 +2,7 @@ import type { ReactElement } from 'react'
|
|
2
2
|
|
3
3
|
import { useAppSettings } from '../contexts/index.ts'
|
4
4
|
|
5
|
+
/** @deprecated import from @xylabs/react-app-settings instead */
|
5
6
|
export const Developer: React.FC<{ children: ReactElement }> = ({ children = null }) => {
|
6
7
|
const { developerMode } = useAppSettings()
|
7
8
|
|
@@ -3,6 +3,7 @@ import { createContext } from 'react'
|
|
3
3
|
import type { WebAppNavigationType } from '../../WebAppNavigationType.ts'
|
4
4
|
import { appSettingDefault } from './appSettingDefault.ts'
|
5
5
|
|
6
|
+
/** @deprecated import from @xylabs/react-app-settings instead */
|
6
7
|
export interface AppSettingsContextProps {
|
7
8
|
changeMaxAccounts?: (value: number) => void
|
8
9
|
changeNavigationCollapsed?: (value: boolean) => void
|
@@ -18,4 +19,5 @@ export interface AppSettingsContextProps {
|
|
18
19
|
seedPhrase?: string
|
19
20
|
}
|
20
21
|
|
22
|
+
/** @deprecated import from @xylabs/react-app-settings instead */
|
21
23
|
export const AppSettingsContext = createContext<AppSettingsContextProps>(appSettingDefault())
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import type {
|
2
|
-
import type { ProviderProps } from 'react'
|
1
|
+
import type { PropsWithChildren, ProviderProps } from 'react'
|
3
2
|
import React, { useMemo, useState } from 'react'
|
4
3
|
|
5
4
|
import type { WebAppNavigationType } from '../../WebAppNavigationType.ts'
|
@@ -7,11 +6,13 @@ import type { AppSettingsContextProps } from './Context.ts'
|
|
7
6
|
import { AppSettingsContext } from './Context.ts'
|
8
7
|
import { AppSettingsStorage } from './Storage.ts'
|
9
8
|
|
9
|
+
/** @deprecated import from @xylabs/react-app-settings instead */
|
10
10
|
export interface AppSettingsProviderProps<T extends AppSettingsContextProps = AppSettingsContextProps> extends ProviderProps<T> {
|
11
11
|
storage?: AppSettingsStorage
|
12
12
|
}
|
13
13
|
|
14
|
-
|
14
|
+
/** @deprecated import from @xylabs/react-app-settings instead */
|
15
|
+
export const AppSettingsProvider: React.FC<PropsWithChildren<AppSettingsProviderProps>> = ({
|
15
16
|
storage,
|
16
17
|
value,
|
17
18
|
children,
|
@@ -3,6 +3,7 @@ import { appSettingDefault } from './appSettingDefault.ts'
|
|
3
3
|
import { AppSettingSlug } from './Slug.ts'
|
4
4
|
import { AppSettingsStorageBase } from './StorageBase.ts'
|
5
5
|
|
6
|
+
/** @deprecated import from @xylabs/react-app-settings instead */
|
6
7
|
export class AppSettingsStorage extends AppSettingsStorageBase {
|
7
8
|
constructor(prefix = 'AppSettings', defaults?: Record<string, unknown>) {
|
8
9
|
super(prefix, { ...appSettingDefault(), ...defaults })
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { assertEx } from '@xylabs/assert'
|
2
|
-
import { assertDefinedEx } from '@xyo-network/react-shared'
|
1
|
+
import { assertDefinedEx, assertEx } from '@xylabs/assert'
|
3
2
|
|
3
|
+
/** @deprecated import from @xylabs/react-app-settings instead */
|
4
4
|
export class AppSettingsStorageBase {
|
5
5
|
private defaults: Record<string, unknown>
|
6
6
|
private prefix: string
|
@@ -44,7 +44,7 @@ export class AppSettingsStorageBase {
|
|
44
44
|
getString(name: string) {
|
45
45
|
const storedValue = localStorage.getItem(`${this.prefix}|${name}`)
|
46
46
|
if (!storedValue) {
|
47
|
-
assertDefinedEx(typeof this.defaults[name] === 'string', 'Default value is not string')
|
47
|
+
assertDefinedEx(typeof this.defaults[name] === 'string', () => 'Default value is not string')
|
48
48
|
const defaultValue = this.defaults[name] as string
|
49
49
|
assertEx(defaultValue !== undefined, () => `Missing Default for ${name}`)
|
50
50
|
return defaultValue
|
@@ -55,7 +55,7 @@ export class AppSettingsStorageBase {
|
|
55
55
|
getStringArray(name: string) {
|
56
56
|
const storedValue = localStorage.getItem(`${this.prefix}|${name}`)?.split(',')
|
57
57
|
if (!storedValue) {
|
58
|
-
assertDefinedEx(Array.isArray(this.defaults[name]), 'Default value is not array')
|
58
|
+
assertDefinedEx(Array.isArray(this.defaults[name]), () => 'Default value is not array')
|
59
59
|
const defaultValue = this.defaults[name] as string[]
|
60
60
|
assertEx(defaultValue !== undefined, () => `Missing Default for ${name}`)
|
61
61
|
return defaultValue
|