@xyo-network/react-app-settings 4.0.4 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
package/dist/browser/index.mjs
CHANGED
@@ -10,15 +10,15 @@ import React2 from "react";
|
|
10
10
|
import { createContext } from "react";
|
11
11
|
|
12
12
|
// src/contexts/AppSettings/Slug.ts
|
13
|
-
var AppSettingSlug
|
14
|
-
(function(AppSettingSlug2) {
|
13
|
+
var AppSettingSlug = /* @__PURE__ */ function(AppSettingSlug2) {
|
15
14
|
AppSettingSlug2["DarkMode"] = "darkmode";
|
16
15
|
AppSettingSlug2["Developer"] = "developer";
|
17
16
|
AppSettingSlug2["NavigationType"] = "navigationType";
|
18
17
|
AppSettingSlug2["NavigationCollapsed"] = "navigationCollapsed";
|
19
18
|
AppSettingSlug2["SeedPhrase"] = "seedPhrase";
|
20
19
|
AppSettingSlug2["MaxAccounts"] = "maxAccounts";
|
21
|
-
|
20
|
+
return AppSettingSlug2;
|
21
|
+
}({});
|
22
22
|
|
23
23
|
// src/contexts/AppSettings/appSettingDefault.ts
|
24
24
|
var appSettingDefault = /* @__PURE__ */ __name(() => {
|
@@ -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;;;;UCAlBC,iBAAAA;;;;;;;GAAAA,mBAAAA,iBAAAA,CAAAA,EAAAA;;;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;;;AFkB1B,IAAMC,qBAAqBC,cAAuCC,kBAAAA,CAAAA;;;AGlBzE,OAAOC,SAASC,SAASC,gBAAgB;;;ACFzC,SAASC,gBAAgB;AACzB,SAASC,uBAAuB;AAEzB,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;AACjE,QAAI,CAACC,aAAa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AACrB,WAAAA;AAC5BG,gBAAYQ,iBAAiBX;AAC7BY,sBAAkBZ,MAAAA;EACpB,GAH6B;AAK7B,QAAMsB,4BAA4B,wBAACtB,WAAAA;AACjCG,gBAAYU,sBAAsBb;AAClCc,2BAAuBd,MAAAA;EACzB,GAHkC;AAKlC,QAAMuB,mBAAmB,wBAACvB,WAAAA;AACxBG,gBAAYY,aAAaf;AACzBgB,kBAAchB,MAAAA;EAChB,GAHyB;AAKzB,QAAMwB,oBAAoB,wBAACxB,WAAAA;AACzBG,gBAAYc,cAAcjB;AAC1BkB,mBAAelB,MAAAA;EACjB,GAH0B;AAK1B,SACE,sBAAA,cAACyB,mBAAmBC,UAAQ;;IAE1B1B,OAAO;MACLwB;MACAF;MACAD;MACAE;MACAd;MACAH;MACAc;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\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;;;ACA9B,IAAYC,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;;;AFkB1B,IAAMC,qBAAqBC,cAAuCC,kBAAAA,CAAAA;;;AGlBzE,OAAOC,SAASC,SAASC,gBAAgB;;;ACFzC,SAASC,gBAAgB;AACzB,SAASC,uBAAuB;AAEzB,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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C,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"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@xyo-network/react-app-settings",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.1.1",
|
4
4
|
"description": "Common React library for all XYO projects that use React",
|
5
5
|
"keywords": [
|
6
6
|
"xyo",
|
@@ -43,18 +43,18 @@
|
|
43
43
|
"lint-pkg": "npmPkgJsonLint ."
|
44
44
|
},
|
45
45
|
"dependencies": {
|
46
|
-
"@xylabs/assert": "^4.0
|
47
|
-
"@xylabs/react-shared": "^5.
|
48
|
-
"@xyo-network/react-shared": "^4.
|
46
|
+
"@xylabs/assert": "^4.2.0",
|
47
|
+
"@xylabs/react-shared": "^5.2.1",
|
48
|
+
"@xyo-network/react-shared": "^4.1.1"
|
49
49
|
},
|
50
50
|
"devDependencies": {
|
51
|
-
"@mui/icons-material": "^6.1.
|
52
|
-
"@mui/material": "^6.1.
|
53
|
-
"@mui/styles": "^6.1.
|
54
|
-
"@xylabs/ts-scripts-yarn3": "^4.
|
51
|
+
"@mui/icons-material": "^6.1.4",
|
52
|
+
"@mui/material": "^6.1.4",
|
53
|
+
"@mui/styles": "^6.1.4",
|
54
|
+
"@xylabs/ts-scripts-yarn3": "^4.2.1",
|
55
55
|
"react": "^18.3.1",
|
56
56
|
"react-dom": "^18.3.1",
|
57
|
-
"typescript": "^5.6.
|
57
|
+
"typescript": "^5.6.3"
|
58
58
|
},
|
59
59
|
"peerDependencies": {
|
60
60
|
"@mui/icons-material": "^6",
|