@xyo-network/react-app-settings 2.78.0 → 2.78.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,249 @@
1
- import{DarkModeRounded as O,LightModeRounded as w}from"@mui/icons-material";import{IconButton as E}from"@mui/material";import{createContext as R}from"react";var B=(a=>(a.DarkMode="darkmode",a.Developer="developer",a.NavigationType="navigationType",a.NavigationCollapsed="navigationCollapsed",a.SeedPhrase="seedPhrase",a.MaxAccounts="maxAccounts",a))(B||{});var p=()=>({darkmode:!1,developer:!1,navigationType:"menu",navigationCollapsed:!1,seedPhrase:"",maxAccounts:1});var l=R(p());import{useState as i}from"react";import{assertEx as s}from"@xylabs/assert";import{assertDefinedEx as f}from"@xyo-network/react-shared";var d=class{defaults;prefix;constructor(e="AppSettings",t){this.prefix=e,this.defaults=t??{}}getBoolean(e){let t=localStorage.getItem(`${this.prefix}|${e}`);if(!t){s(typeof this.defaults[e]=="boolean",()=>"Default value is not boolean");let n=this.defaults[e];return s(n!==void 0,()=>`Missing Default for ${e}`),n}return t!=="false"}getNumber(e){let t=localStorage.getItem(`${this.prefix}|${e}`);if(!t){s(typeof this.defaults[e]=="number",()=>"Default value is not a number");let n=this.defaults[e];return s(n!==void 0,()=>`Missing Default for ${e}`),n}return Number.parseFloat(t)}getObject(e){let t=localStorage.getItem(`${this.prefix}|${e}`),n=t?JSON.parse(t):null;return n||(s(typeof this.defaults[e]=="object",()=>"Default value is not object"),s(this.defaults[e],()=>`Missing Default for ${e}`))}getString(e){let t=localStorage.getItem(`${this.prefix}|${e}`);if(!t){f(typeof this.defaults[e]=="string","Default value is not string");let n=this.defaults[e];return s(n!==void 0,()=>`Missing Default for ${e}`),n}return t}getStringArray(e){let t=localStorage.getItem(`${this.prefix}|${e}`)?.split(",");if(!t){f(Array.isArray(this.defaults[e]),"Default value is not array");let n=this.defaults[e];return s(n!==void 0,()=>`Missing Default for ${e}`),n}return t}setBoolean(e,t){localStorage.setItem(`${this.prefix}|${e}`,JSON.stringify(t))}setNumber(e,t){localStorage.setItem(`${this.prefix}|${e}`,JSON.stringify(t))}setObject(e,t){localStorage.setItem(`${this.prefix}|${e}`,JSON.stringify(t))}setString(e,t){localStorage.setItem(`${this.prefix}|${e}`,t)}setStringArray(e,t){localStorage.setItem(`${this.prefix}|${e}`,t.join(","))}};var g=class extends d{constructor(e="AppSettings",t){super(e,{...p(),...t})}get darkMode(){return this.getBoolean("darkmode")}set darkMode(e){this.setBoolean("darkmode",e)}get developerMode(){return this.getBoolean("developer")}set developerMode(e){this.setBoolean("developer",e)}get maxAccounts(){return this.getNumber("maxAccounts")}set maxAccounts(e){this.setNumber("maxAccounts",e)}get navigationCollapsed(){return this.getBoolean("navigationCollapsed")}set navigationCollapsed(e){this.setBoolean("navigationCollapsed",e)}get navigationType(){return this.getString("navigationType")}set navigationType(e){this.setString("navigationType",e)}get seedPhrase(){return this.getString("seedPhrase")}set seedPhrase(e){this.setString("seedPhrase",e)}};import{jsx as V}from"react/jsx-runtime";var te=({storage:o=new g,value:e,children:t,...n})=>{let[v,h]=i(o.developerMode),[a,m]=i(o.darkMode),[x,b]=i(o.navigationType),[M,S]=i(o.navigationCollapsed),[A,D]=i(o.seedPhrase),[y,C]=i(o.maxAccounts),P=r=>{o.developerMode=r,h(o.developerMode)},N=r=>{o.darkMode=r,m(o.darkMode)},T=r=>{o.navigationType=r,b(r)},k=r=>{o.navigationCollapsed=r,S(r)},$=r=>{o.seedPhrase=r,D(r)},I=r=>{o.maxAccounts=r,C(r)};return V(l.Provider,{value:{changeMaxAccounts:I,changeNavigationCollapsed:k,changeNavigationType:T,changeSeedPhrase:$,darkMode:a,developerMode:v,enableDarkMode:N,enableDeveloperMode:P,maxAccounts:y,navigationCollapsed:M,navigationType:x,seedPhrase:A,...e},...n,children:t})};import{useContext as W}from"react";var u=()=>W(l);import{jsx as c}from"react/jsx-runtime";var ge=o=>{let{darkMode:e,enableDarkMode:t}=u();return c(E,{onClick:()=>{t?.(!e)},...o,children:e?c(O,{}):c(w,{})})};var ve=({children:o=null})=>{let{developerMode:e}=u();return e?o:null};export{B as AppSettingSlug,l as AppSettingsContext,te as AppSettingsProvider,g as AppSettingsStorage,d as AppSettingsStorageBase,ge as DarkModeIconButton,ve as Developer,u as useAppSettings};
1
+ // src/components/DarkModeIconButton.tsx
2
+ import { DarkModeRounded as DarkModeRoundedIcon, LightModeRounded as LightModeRoundedIcon } from "@mui/icons-material";
3
+ import { IconButton } from "@mui/material";
4
+
5
+ // src/contexts/AppSettings/Context.ts
6
+ import { createContext } from "react";
7
+
8
+ // src/contexts/AppSettings/Slug.ts
9
+ var AppSettingSlug = /* @__PURE__ */ ((AppSettingSlug2) => {
10
+ AppSettingSlug2["DarkMode"] = "darkmode";
11
+ AppSettingSlug2["Developer"] = "developer";
12
+ AppSettingSlug2["NavigationType"] = "navigationType";
13
+ AppSettingSlug2["NavigationCollapsed"] = "navigationCollapsed";
14
+ AppSettingSlug2["SeedPhrase"] = "seedPhrase";
15
+ AppSettingSlug2["MaxAccounts"] = "maxAccounts";
16
+ return AppSettingSlug2;
17
+ })(AppSettingSlug || {});
18
+
19
+ // src/contexts/AppSettings/appSettingDefault.ts
20
+ var appSettingDefault = () => {
21
+ return {
22
+ ["darkmode" /* DarkMode */]: false,
23
+ ["developer" /* Developer */]: false,
24
+ ["navigationType" /* NavigationType */]: "menu",
25
+ ["navigationCollapsed" /* NavigationCollapsed */]: false,
26
+ ["seedPhrase" /* SeedPhrase */]: "",
27
+ ["maxAccounts" /* MaxAccounts */]: 1
28
+ };
29
+ };
30
+
31
+ // src/contexts/AppSettings/Context.ts
32
+ var AppSettingsContext = createContext(appSettingDefault());
33
+
34
+ // src/contexts/AppSettings/Provider.tsx
35
+ import { useState } from "react";
36
+
37
+ // src/contexts/AppSettings/StorageBase.ts
38
+ import { assertEx } from "@xylabs/assert";
39
+ import { assertDefinedEx } from "@xyo-network/react-shared";
40
+ var AppSettingsStorageBase = class {
41
+ defaults;
42
+ prefix;
43
+ constructor(prefix = "AppSettings", defaults) {
44
+ this.prefix = prefix;
45
+ this.defaults = defaults ?? {};
46
+ }
47
+ getBoolean(name) {
48
+ const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
49
+ if (!storedValue) {
50
+ assertEx(typeof this.defaults[name] === "boolean", () => "Default value is not boolean");
51
+ const defaultValue = this.defaults[name];
52
+ assertEx(defaultValue !== void 0, () => `Missing Default for ${name}`);
53
+ return defaultValue;
54
+ }
55
+ return storedValue !== "false";
56
+ }
57
+ getNumber(name) {
58
+ const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
59
+ if (!storedValue) {
60
+ assertEx(typeof this.defaults[name] === "number", () => "Default value is not a number");
61
+ const defaultValue = this.defaults[name];
62
+ assertEx(defaultValue !== void 0, () => `Missing Default for ${name}`);
63
+ return defaultValue;
64
+ }
65
+ return Number.parseFloat(storedValue);
66
+ }
67
+ getObject(name) {
68
+ const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
69
+ const parsedStoredValue = storedValue ? JSON.parse(storedValue) : null;
70
+ if (!parsedStoredValue) {
71
+ assertEx(typeof this.defaults[name] === "object", () => "Default value is not object");
72
+ return assertEx(this.defaults[name], () => `Missing Default for ${name}`);
73
+ }
74
+ return parsedStoredValue;
75
+ }
76
+ getString(name) {
77
+ const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
78
+ if (!storedValue) {
79
+ assertDefinedEx(typeof this.defaults[name] === "string", "Default value is not string");
80
+ const defaultValue = this.defaults[name];
81
+ assertEx(defaultValue !== void 0, () => `Missing Default for ${name}`);
82
+ return defaultValue;
83
+ }
84
+ return storedValue;
85
+ }
86
+ getStringArray(name) {
87
+ const storedValue = localStorage.getItem(`${this.prefix}|${name}`)?.split(",");
88
+ if (!storedValue) {
89
+ assertDefinedEx(Array.isArray(this.defaults[name]), "Default value is not array");
90
+ const defaultValue = this.defaults[name];
91
+ assertEx(defaultValue !== void 0, () => `Missing Default for ${name}`);
92
+ return defaultValue;
93
+ }
94
+ return storedValue;
95
+ }
96
+ setBoolean(name, value) {
97
+ localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value));
98
+ }
99
+ setNumber(name, value) {
100
+ localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value));
101
+ }
102
+ setObject(name, value) {
103
+ localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value));
104
+ }
105
+ setString(name, value) {
106
+ localStorage.setItem(`${this.prefix}|${name}`, value);
107
+ }
108
+ setStringArray(name, value) {
109
+ localStorage.setItem(`${this.prefix}|${name}`, value.join(","));
110
+ }
111
+ };
112
+
113
+ // src/contexts/AppSettings/Storage.ts
114
+ var AppSettingsStorage = class extends AppSettingsStorageBase {
115
+ constructor(prefix = "AppSettings", defaults) {
116
+ super(prefix, { ...appSettingDefault(), ...defaults });
117
+ }
118
+ get darkMode() {
119
+ return this.getBoolean("darkmode" /* DarkMode */);
120
+ }
121
+ set darkMode(value) {
122
+ this.setBoolean("darkmode" /* DarkMode */, value);
123
+ }
124
+ get developerMode() {
125
+ return this.getBoolean("developer" /* Developer */);
126
+ }
127
+ set developerMode(value) {
128
+ this.setBoolean("developer" /* Developer */, value);
129
+ }
130
+ get maxAccounts() {
131
+ return this.getNumber("maxAccounts" /* MaxAccounts */);
132
+ }
133
+ set maxAccounts(value) {
134
+ this.setNumber("maxAccounts" /* MaxAccounts */, value);
135
+ }
136
+ get navigationCollapsed() {
137
+ return this.getBoolean("navigationCollapsed" /* NavigationCollapsed */);
138
+ }
139
+ set navigationCollapsed(value) {
140
+ this.setBoolean("navigationCollapsed" /* NavigationCollapsed */, value);
141
+ }
142
+ get navigationType() {
143
+ return this.getString("navigationType" /* NavigationType */);
144
+ }
145
+ set navigationType(value) {
146
+ this.setString("navigationType" /* NavigationType */, value);
147
+ }
148
+ get seedPhrase() {
149
+ return this.getString("seedPhrase" /* SeedPhrase */);
150
+ }
151
+ set seedPhrase(value) {
152
+ this.setString("seedPhrase" /* SeedPhrase */, value);
153
+ }
154
+ };
155
+
156
+ // src/contexts/AppSettings/Provider.tsx
157
+ import { jsx } from "react/jsx-runtime";
158
+ var AppSettingsProvider = ({
159
+ storage = new AppSettingsStorage(),
160
+ value,
161
+ children,
162
+ ...props
163
+ }) => {
164
+ const [developerMode, setDeveloperMode] = useState(storage.developerMode);
165
+ const [darkMode, setDarkMode] = useState(storage.darkMode);
166
+ const [navigationType, setNavigationType] = useState(storage.navigationType);
167
+ const [navigationCollapsed, setNavigationCollapsed] = useState(storage.navigationCollapsed);
168
+ const [seedPhrase, setSeedPhrase] = useState(storage.seedPhrase);
169
+ const [maxAccounts, setMaxAccounts] = useState(storage.maxAccounts);
170
+ const enableDeveloperMode = (value2) => {
171
+ storage.developerMode = value2;
172
+ setDeveloperMode(storage.developerMode);
173
+ };
174
+ const enableDarkMode = (value2) => {
175
+ storage.darkMode = value2;
176
+ setDarkMode(storage.darkMode);
177
+ };
178
+ const changeNavigationType = (value2) => {
179
+ storage.navigationType = value2;
180
+ setNavigationType(value2);
181
+ };
182
+ const changeNavigationCollapsed = (value2) => {
183
+ storage.navigationCollapsed = value2;
184
+ setNavigationCollapsed(value2);
185
+ };
186
+ const changeSeedPhrase = (value2) => {
187
+ storage.seedPhrase = value2;
188
+ setSeedPhrase(value2);
189
+ };
190
+ const changeMaxAccounts = (value2) => {
191
+ storage.maxAccounts = value2;
192
+ setMaxAccounts(value2);
193
+ };
194
+ return /* @__PURE__ */ jsx(
195
+ AppSettingsContext.Provider,
196
+ {
197
+ value: {
198
+ changeMaxAccounts,
199
+ changeNavigationCollapsed,
200
+ changeNavigationType,
201
+ changeSeedPhrase,
202
+ darkMode,
203
+ developerMode,
204
+ enableDarkMode,
205
+ enableDeveloperMode,
206
+ maxAccounts,
207
+ navigationCollapsed,
208
+ navigationType,
209
+ seedPhrase,
210
+ ...value
211
+ },
212
+ ...props,
213
+ children
214
+ }
215
+ );
216
+ };
217
+
218
+ // src/contexts/AppSettings/useAppSettings.ts
219
+ import { useContext } from "react";
220
+ var useAppSettings = () => {
221
+ return useContext(AppSettingsContext);
222
+ };
223
+
224
+ // src/components/DarkModeIconButton.tsx
225
+ import { jsx as jsx2 } from "react/jsx-runtime";
226
+ var DarkModeIconButton = (props) => {
227
+ const { darkMode, enableDarkMode } = useAppSettings();
228
+ const handleDarkModeChange = () => {
229
+ enableDarkMode?.(!darkMode);
230
+ };
231
+ return /* @__PURE__ */ jsx2(IconButton, { onClick: handleDarkModeChange, ...props, children: darkMode ? /* @__PURE__ */ jsx2(DarkModeRoundedIcon, {}) : /* @__PURE__ */ jsx2(LightModeRoundedIcon, {}) });
232
+ };
233
+
234
+ // src/components/Developer.tsx
235
+ var Developer = ({ children = null }) => {
236
+ const { developerMode } = useAppSettings();
237
+ return developerMode ? children : null;
238
+ };
239
+ export {
240
+ AppSettingSlug,
241
+ AppSettingsContext,
242
+ AppSettingsProvider,
243
+ AppSettingsStorage,
244
+ AppSettingsStorageBase,
245
+ DarkModeIconButton,
246
+ Developer,
247
+ useAppSettings
248
+ };
2
249
  //# sourceMappingURL=index.js.map
@@ -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 { IconButton, IconButtonProps } from '@mui/material'\n\nimport { useAppSettings } from '../contexts'\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 { WebAppNavigationType } from '../../WebAppNavigationType'\nimport { appSettingDefault } from './appSettingDefault'\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'\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 { WithChildren } from '@xylabs/react-shared'\nimport { ProviderProps, useState } from 'react'\n\nimport { WebAppNavigationType } from '../../WebAppNavigationType'\nimport { AppSettingsContext, AppSettingsContextProps } from './Context'\nimport { AppSettingsStorage } from './Storage'\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 = new AppSettingsStorage(),\n value,\n children,\n ...props\n}) => {\n const [developerMode, setDeveloperMode] = useState(storage.developerMode)\n const [darkMode, setDarkMode] = useState(storage.darkMode)\n const [navigationType, setNavigationType] = useState(storage.navigationType)\n const [navigationCollapsed, setNavigationCollapsed] = useState(storage.navigationCollapsed)\n const [seedPhrase, setSeedPhrase] = useState(storage.seedPhrase)\n const [maxAccounts, setMaxAccounts] = useState(storage.maxAccounts)\n\n const enableDeveloperMode = (value: boolean) => {\n storage.developerMode = value\n setDeveloperMode(storage.developerMode)\n }\n\n const enableDarkMode = (value: boolean) => {\n storage.darkMode = value\n setDarkMode(storage.darkMode)\n }\n\n const changeNavigationType = (value: WebAppNavigationType) => {\n storage.navigationType = value\n setNavigationType(value)\n }\n\n const changeNavigationCollapsed = (value: boolean) => {\n storage.navigationCollapsed = value\n setNavigationCollapsed(value)\n }\n\n const changeSeedPhrase = (value: string) => {\n storage.seedPhrase = value\n setSeedPhrase(value)\n }\n\n const changeMaxAccounts = (value: number) => {\n storage.maxAccounts = value\n setMaxAccounts(value)\n }\n\n return (\n <AppSettingsContext.Provider\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 { WebAppNavigationType } from '../../WebAppNavigationType'\nimport { appSettingDefault } from './appSettingDefault'\nimport { AppSettingSlug } from './Slug'\nimport { AppSettingsStorageBase } from './StorageBase'\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'\n\nexport const useAppSettings = () => {\n return useContext(AppSettingsContext)\n}\n","import { ReactElement } from 'react'\n\nimport { useAppSettings } from '../contexts'\n\nexport const Developer: React.FC<{ children: ReactElement }> = ({ children = null }) => {\n const { developerMode } = useAppSettings()\n\n return developerMode ? children : null\n}\n"],"mappings":"AAAA,OAAS,mBAAmBA,EAAqB,oBAAoBC,MAA4B,sBACjG,OAAS,cAAAC,MAAmC,gBCD5C,OAAS,iBAAAC,MAAqB,QCAvB,IAAKC,OACVA,EAAA,SAAW,WACXA,EAAA,UAAY,YACZA,EAAA,eAAiB,iBACjBA,EAAA,oBAAsB,sBACtBA,EAAA,WAAa,aACbA,EAAA,YAAc,cANJA,OAAA,ICEL,IAAMC,E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,EAEzC,OAAOD,EAAgBD,EAAW,IACpC","names":["DarkModeRoundedIcon","LightModeRoundedIcon","IconButton","createContext","AppSettingSlug","appSettingDefault","AppSettingsContext","createContext","appSettingDefault","useState","assertEx","assertDefinedEx","AppSettingsStorageBase","prefix","defaults","name","storedValue","defaultValue","parsedStoredValue","value","AppSettingsStorage","AppSettingsStorageBase","prefix","defaults","appSettingDefault","value","jsx","AppSettingsProvider","storage","AppSettingsStorage","value","children","props","developerMode","setDeveloperMode","useState","darkMode","setDarkMode","navigationType","setNavigationType","navigationCollapsed","setNavigationCollapsed","seedPhrase","setSeedPhrase","maxAccounts","setMaxAccounts","enableDeveloperMode","enableDarkMode","changeNavigationType","changeNavigationCollapsed","changeSeedPhrase","changeMaxAccounts","AppSettingsContext","useContext","useAppSettings","useContext","AppSettingsContext","jsx","DarkModeIconButton","props","darkMode","enableDarkMode","useAppSettings","IconButton","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 { IconButton, IconButtonProps } from '@mui/material'\n\nimport { useAppSettings } from '../contexts'\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 { WebAppNavigationType } from '../../WebAppNavigationType'\nimport { appSettingDefault } from './appSettingDefault'\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'\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 { WithChildren } from '@xylabs/react-shared'\nimport { ProviderProps, useState } from 'react'\n\nimport { WebAppNavigationType } from '../../WebAppNavigationType'\nimport { AppSettingsContext, AppSettingsContextProps } from './Context'\nimport { AppSettingsStorage } from './Storage'\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 = new AppSettingsStorage(),\n value,\n children,\n ...props\n}) => {\n const [developerMode, setDeveloperMode] = useState(storage.developerMode)\n const [darkMode, setDarkMode] = useState(storage.darkMode)\n const [navigationType, setNavigationType] = useState(storage.navigationType)\n const [navigationCollapsed, setNavigationCollapsed] = useState(storage.navigationCollapsed)\n const [seedPhrase, setSeedPhrase] = useState(storage.seedPhrase)\n const [maxAccounts, setMaxAccounts] = useState(storage.maxAccounts)\n\n const enableDeveloperMode = (value: boolean) => {\n storage.developerMode = value\n setDeveloperMode(storage.developerMode)\n }\n\n const enableDarkMode = (value: boolean) => {\n storage.darkMode = value\n setDarkMode(storage.darkMode)\n }\n\n const changeNavigationType = (value: WebAppNavigationType) => {\n storage.navigationType = value\n setNavigationType(value)\n }\n\n const changeNavigationCollapsed = (value: boolean) => {\n storage.navigationCollapsed = value\n setNavigationCollapsed(value)\n }\n\n const changeSeedPhrase = (value: string) => {\n storage.seedPhrase = value\n setSeedPhrase(value)\n }\n\n const changeMaxAccounts = (value: number) => {\n storage.maxAccounts = value\n setMaxAccounts(value)\n }\n\n return (\n <AppSettingsContext.Provider\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 { WebAppNavigationType } from '../../WebAppNavigationType'\nimport { appSettingDefault } from './appSettingDefault'\nimport { AppSettingSlug } from './Slug'\nimport { AppSettingsStorageBase } from './StorageBase'\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'\n\nexport const useAppSettings = () => {\n return useContext(AppSettingsContext)\n}\n","import { ReactElement } from 'react'\n\nimport { useAppSettings } from '../contexts'\n\nexport const Developer: React.FC<{ children: ReactElement }> = ({ children = null }) => {\n const { developerMode } = useAppSettings()\n\n return developerMode ? children : null\n}\n"],"mappings":";AAAA,SAAS,mBAAmB,qBAAqB,oBAAoB,4BAA4B;AACjG,SAAS,kBAAmC;;;ACD5C,SAAS,qBAAqB;;;ACAvB,IAAK,iBAAL,kBAAKA,oBAAL;AACL,EAAAA,gBAAA,cAAW;AACX,EAAAA,gBAAA,eAAY;AACZ,EAAAA,gBAAA,oBAAiB;AACjB,EAAAA,gBAAA,yBAAsB;AACtB,EAAAA,gBAAA,gBAAa;AACb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A;AAAA,QACA;AAAA,QACA;AAAA,QAEA,GAAG;AAAA,MACL;AAAA,MACC,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;;;AG7EA,SAAS,kBAAkB;AAIpB,IAAM,iBAAiB,MAAM;AAClC,SAAO,WAAW,kBAAkB;AACtC;;;APSQ,gBAAAC,YAAA;AAVD,IAAM,qBAAgD,CAAC,UAAU;AACtE,QAAM,EAAE,UAAU,eAAe,IAAI,eAAe;AAEpD,QAAM,uBAAuB,MAAM;AACjC,qBAAiB,CAAC,QAAQ;AAAA,EAC5B;AAEA,SACE,gBAAAA,KAAC,cAAW,SAAS,sBAAuB,GAAG,OAC5C,qBACC,gBAAAA,KAAC,uBAAoB,IACrB,gBAAAA,KAAC,wBAAqB,GAC1B;AAEJ;;;AQfO,IAAM,YAAkD,CAAC,EAAE,WAAW,KAAK,MAAM;AACtF,QAAM,EAAE,cAAc,IAAI,eAAe;AAEzC,SAAO,gBAAgB,WAAW;AACpC;","names":["AppSettingSlug","value","jsx"]}
@@ -1,2 +1,284 @@
1
- "use strict";var h=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var L=(o,e)=>{for(var t in e)h(o,t,{get:e[t],enumerable:!0})},q=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of J(e))!j.call(o,a)&&a!==t&&h(o,a,{get:()=>e[a],enumerable:!(n=F(e,a))||n.enumerable});return o};var z=o=>q(h({},"__esModule",{value:!0}),o);var Q={};L(Q,{AppSettingSlug:()=>x,AppSettingsContext:()=>l,AppSettingsProvider:()=>G,AppSettingsStorage:()=>g,AppSettingsStorageBase:()=>d,DarkModeIconButton:()=>H,Developer:()=>K,useAppSettings:()=>u});module.exports=z(Q);var v=require("@mui/icons-material"),A=require("@mui/material");var b=require("react");var x=(i=>(i.DarkMode="darkmode",i.Developer="developer",i.NavigationType="navigationType",i.NavigationCollapsed="navigationCollapsed",i.SeedPhrase="seedPhrase",i.MaxAccounts="maxAccounts",i))(x||{});var c=()=>({darkmode:!1,developer:!1,navigationType:"menu",navigationCollapsed:!1,seedPhrase:"",maxAccounts:1});var l=(0,b.createContext)(c());var p=require("react");var s=require("@xylabs/assert"),m=require("@xyo-network/react-shared"),d=class{defaults;prefix;constructor(e="AppSettings",t){this.prefix=e,this.defaults=t??{}}getBoolean(e){let t=localStorage.getItem(`${this.prefix}|${e}`);if(!t){(0,s.assertEx)(typeof this.defaults[e]=="boolean",()=>"Default value is not boolean");let n=this.defaults[e];return(0,s.assertEx)(n!==void 0,()=>`Missing Default for ${e}`),n}return t!=="false"}getNumber(e){let t=localStorage.getItem(`${this.prefix}|${e}`);if(!t){(0,s.assertEx)(typeof this.defaults[e]=="number",()=>"Default value is not a number");let n=this.defaults[e];return(0,s.assertEx)(n!==void 0,()=>`Missing Default for ${e}`),n}return Number.parseFloat(t)}getObject(e){let t=localStorage.getItem(`${this.prefix}|${e}`),n=t?JSON.parse(t):null;return n||((0,s.assertEx)(typeof this.defaults[e]=="object",()=>"Default value is not object"),(0,s.assertEx)(this.defaults[e],()=>`Missing Default for ${e}`))}getString(e){let t=localStorage.getItem(`${this.prefix}|${e}`);if(!t){(0,m.assertDefinedEx)(typeof this.defaults[e]=="string","Default value is not string");let n=this.defaults[e];return(0,s.assertEx)(n!==void 0,()=>`Missing Default for ${e}`),n}return t}getStringArray(e){var n;let t=(n=localStorage.getItem(`${this.prefix}|${e}`))==null?void 0:n.split(",");if(!t){(0,m.assertDefinedEx)(Array.isArray(this.defaults[e]),"Default value is not array");let a=this.defaults[e];return(0,s.assertEx)(a!==void 0,()=>`Missing Default for ${e}`),a}return t}setBoolean(e,t){localStorage.setItem(`${this.prefix}|${e}`,JSON.stringify(t))}setNumber(e,t){localStorage.setItem(`${this.prefix}|${e}`,JSON.stringify(t))}setObject(e,t){localStorage.setItem(`${this.prefix}|${e}`,JSON.stringify(t))}setString(e,t){localStorage.setItem(`${this.prefix}|${e}`,t)}setStringArray(e,t){localStorage.setItem(`${this.prefix}|${e}`,t.join(","))}};var g=class extends d{constructor(e="AppSettings",t){super(e,{...c(),...t})}get darkMode(){return this.getBoolean("darkmode")}set darkMode(e){this.setBoolean("darkmode",e)}get developerMode(){return this.getBoolean("developer")}set developerMode(e){this.setBoolean("developer",e)}get maxAccounts(){return this.getNumber("maxAccounts")}set maxAccounts(e){this.setNumber("maxAccounts",e)}get navigationCollapsed(){return this.getBoolean("navigationCollapsed")}set navigationCollapsed(e){this.setBoolean("navigationCollapsed",e)}get navigationType(){return this.getString("navigationType")}set navigationType(e){this.setString("navigationType",e)}get seedPhrase(){return this.getString("seedPhrase")}set seedPhrase(e){this.setString("seedPhrase",e)}};var S=require("react/jsx-runtime"),G=({storage:o=new g,value:e,children:t,...n})=>{let[a,y]=(0,p.useState)(o.developerMode),[i,C]=(0,p.useState)(o.darkMode),[D,P]=(0,p.useState)(o.navigationType),[N,T]=(0,p.useState)(o.navigationCollapsed),[k,$]=(0,p.useState)(o.seedPhrase),[I,B]=(0,p.useState)(o.maxAccounts),R=r=>{o.developerMode=r,y(o.developerMode)},V=r=>{o.darkMode=r,C(o.darkMode)},W=r=>{o.navigationType=r,P(r)},O=r=>{o.navigationCollapsed=r,T(r)},w=r=>{o.seedPhrase=r,$(r)},E=r=>{o.maxAccounts=r,B(r)};return(0,S.jsx)(l.Provider,{value:{changeMaxAccounts:E,changeNavigationCollapsed:O,changeNavigationType:W,changeSeedPhrase:w,darkMode:i,developerMode:a,enableDarkMode:V,enableDeveloperMode:R,maxAccounts:I,navigationCollapsed:N,navigationType:D,seedPhrase:k,...e},...n,children:t})};var M=require("react");var u=()=>(0,M.useContext)(l);var f=require("react/jsx-runtime"),H=o=>{let{darkMode:e,enableDarkMode:t}=u();return(0,f.jsx)(A.IconButton,{onClick:()=>{t==null||t(!e)},...o,children:e?(0,f.jsx)(v.DarkModeRounded,{}):(0,f.jsx)(v.LightModeRounded,{})})};var K=({children:o=null})=>{let{developerMode:e}=u();return e?o:null};0&&(module.exports={AppSettingSlug,AppSettingsContext,AppSettingsProvider,AppSettingsStorage,AppSettingsStorageBase,DarkModeIconButton,Developer,useAppSettings});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ AppSettingSlug: () => AppSettingSlug,
24
+ AppSettingsContext: () => AppSettingsContext,
25
+ AppSettingsProvider: () => AppSettingsProvider,
26
+ AppSettingsStorage: () => AppSettingsStorage,
27
+ AppSettingsStorageBase: () => AppSettingsStorageBase,
28
+ DarkModeIconButton: () => DarkModeIconButton,
29
+ Developer: () => Developer,
30
+ useAppSettings: () => useAppSettings
31
+ });
32
+ module.exports = __toCommonJS(src_exports);
33
+
34
+ // src/components/DarkModeIconButton.tsx
35
+ var import_icons_material = require("@mui/icons-material");
36
+ var import_material = require("@mui/material");
37
+
38
+ // src/contexts/AppSettings/Context.ts
39
+ var import_react = require("react");
40
+
41
+ // src/contexts/AppSettings/Slug.ts
42
+ var AppSettingSlug = /* @__PURE__ */ ((AppSettingSlug2) => {
43
+ AppSettingSlug2["DarkMode"] = "darkmode";
44
+ AppSettingSlug2["Developer"] = "developer";
45
+ AppSettingSlug2["NavigationType"] = "navigationType";
46
+ AppSettingSlug2["NavigationCollapsed"] = "navigationCollapsed";
47
+ AppSettingSlug2["SeedPhrase"] = "seedPhrase";
48
+ AppSettingSlug2["MaxAccounts"] = "maxAccounts";
49
+ return AppSettingSlug2;
50
+ })(AppSettingSlug || {});
51
+
52
+ // src/contexts/AppSettings/appSettingDefault.ts
53
+ var appSettingDefault = () => {
54
+ return {
55
+ ["darkmode" /* DarkMode */]: false,
56
+ ["developer" /* Developer */]: false,
57
+ ["navigationType" /* NavigationType */]: "menu",
58
+ ["navigationCollapsed" /* NavigationCollapsed */]: false,
59
+ ["seedPhrase" /* SeedPhrase */]: "",
60
+ ["maxAccounts" /* MaxAccounts */]: 1
61
+ };
62
+ };
63
+
64
+ // src/contexts/AppSettings/Context.ts
65
+ var AppSettingsContext = (0, import_react.createContext)(appSettingDefault());
66
+
67
+ // src/contexts/AppSettings/Provider.tsx
68
+ var import_react2 = require("react");
69
+
70
+ // src/contexts/AppSettings/StorageBase.ts
71
+ var import_assert = require("@xylabs/assert");
72
+ var import_react_shared = require("@xyo-network/react-shared");
73
+ var AppSettingsStorageBase = class {
74
+ defaults;
75
+ prefix;
76
+ constructor(prefix = "AppSettings", defaults) {
77
+ this.prefix = prefix;
78
+ this.defaults = defaults ?? {};
79
+ }
80
+ getBoolean(name) {
81
+ const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
82
+ if (!storedValue) {
83
+ (0, import_assert.assertEx)(typeof this.defaults[name] === "boolean", () => "Default value is not boolean");
84
+ const defaultValue = this.defaults[name];
85
+ (0, import_assert.assertEx)(defaultValue !== void 0, () => `Missing Default for ${name}`);
86
+ return defaultValue;
87
+ }
88
+ return storedValue !== "false";
89
+ }
90
+ getNumber(name) {
91
+ const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
92
+ if (!storedValue) {
93
+ (0, import_assert.assertEx)(typeof this.defaults[name] === "number", () => "Default value is not a number");
94
+ const defaultValue = this.defaults[name];
95
+ (0, import_assert.assertEx)(defaultValue !== void 0, () => `Missing Default for ${name}`);
96
+ return defaultValue;
97
+ }
98
+ return Number.parseFloat(storedValue);
99
+ }
100
+ getObject(name) {
101
+ const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
102
+ const parsedStoredValue = storedValue ? JSON.parse(storedValue) : null;
103
+ if (!parsedStoredValue) {
104
+ (0, import_assert.assertEx)(typeof this.defaults[name] === "object", () => "Default value is not object");
105
+ return (0, import_assert.assertEx)(this.defaults[name], () => `Missing Default for ${name}`);
106
+ }
107
+ return parsedStoredValue;
108
+ }
109
+ getString(name) {
110
+ const storedValue = localStorage.getItem(`${this.prefix}|${name}`);
111
+ if (!storedValue) {
112
+ (0, import_react_shared.assertDefinedEx)(typeof this.defaults[name] === "string", "Default value is not string");
113
+ const defaultValue = this.defaults[name];
114
+ (0, import_assert.assertEx)(defaultValue !== void 0, () => `Missing Default for ${name}`);
115
+ return defaultValue;
116
+ }
117
+ return storedValue;
118
+ }
119
+ getStringArray(name) {
120
+ var _a;
121
+ const storedValue = (_a = localStorage.getItem(`${this.prefix}|${name}`)) == null ? void 0 : _a.split(",");
122
+ if (!storedValue) {
123
+ (0, import_react_shared.assertDefinedEx)(Array.isArray(this.defaults[name]), "Default value is not array");
124
+ const defaultValue = this.defaults[name];
125
+ (0, import_assert.assertEx)(defaultValue !== void 0, () => `Missing Default for ${name}`);
126
+ return defaultValue;
127
+ }
128
+ return storedValue;
129
+ }
130
+ setBoolean(name, value) {
131
+ localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value));
132
+ }
133
+ setNumber(name, value) {
134
+ localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value));
135
+ }
136
+ setObject(name, value) {
137
+ localStorage.setItem(`${this.prefix}|${name}`, JSON.stringify(value));
138
+ }
139
+ setString(name, value) {
140
+ localStorage.setItem(`${this.prefix}|${name}`, value);
141
+ }
142
+ setStringArray(name, value) {
143
+ localStorage.setItem(`${this.prefix}|${name}`, value.join(","));
144
+ }
145
+ };
146
+
147
+ // src/contexts/AppSettings/Storage.ts
148
+ var AppSettingsStorage = class extends AppSettingsStorageBase {
149
+ constructor(prefix = "AppSettings", defaults) {
150
+ super(prefix, { ...appSettingDefault(), ...defaults });
151
+ }
152
+ get darkMode() {
153
+ return this.getBoolean("darkmode" /* DarkMode */);
154
+ }
155
+ set darkMode(value) {
156
+ this.setBoolean("darkmode" /* DarkMode */, value);
157
+ }
158
+ get developerMode() {
159
+ return this.getBoolean("developer" /* Developer */);
160
+ }
161
+ set developerMode(value) {
162
+ this.setBoolean("developer" /* Developer */, value);
163
+ }
164
+ get maxAccounts() {
165
+ return this.getNumber("maxAccounts" /* MaxAccounts */);
166
+ }
167
+ set maxAccounts(value) {
168
+ this.setNumber("maxAccounts" /* MaxAccounts */, value);
169
+ }
170
+ get navigationCollapsed() {
171
+ return this.getBoolean("navigationCollapsed" /* NavigationCollapsed */);
172
+ }
173
+ set navigationCollapsed(value) {
174
+ this.setBoolean("navigationCollapsed" /* NavigationCollapsed */, value);
175
+ }
176
+ get navigationType() {
177
+ return this.getString("navigationType" /* NavigationType */);
178
+ }
179
+ set navigationType(value) {
180
+ this.setString("navigationType" /* NavigationType */, value);
181
+ }
182
+ get seedPhrase() {
183
+ return this.getString("seedPhrase" /* SeedPhrase */);
184
+ }
185
+ set seedPhrase(value) {
186
+ this.setString("seedPhrase" /* SeedPhrase */, value);
187
+ }
188
+ };
189
+
190
+ // src/contexts/AppSettings/Provider.tsx
191
+ var import_jsx_runtime = require("react/jsx-runtime");
192
+ var AppSettingsProvider = ({
193
+ storage = new AppSettingsStorage(),
194
+ value,
195
+ children,
196
+ ...props
197
+ }) => {
198
+ const [developerMode, setDeveloperMode] = (0, import_react2.useState)(storage.developerMode);
199
+ const [darkMode, setDarkMode] = (0, import_react2.useState)(storage.darkMode);
200
+ const [navigationType, setNavigationType] = (0, import_react2.useState)(storage.navigationType);
201
+ const [navigationCollapsed, setNavigationCollapsed] = (0, import_react2.useState)(storage.navigationCollapsed);
202
+ const [seedPhrase, setSeedPhrase] = (0, import_react2.useState)(storage.seedPhrase);
203
+ const [maxAccounts, setMaxAccounts] = (0, import_react2.useState)(storage.maxAccounts);
204
+ const enableDeveloperMode = (value2) => {
205
+ storage.developerMode = value2;
206
+ setDeveloperMode(storage.developerMode);
207
+ };
208
+ const enableDarkMode = (value2) => {
209
+ storage.darkMode = value2;
210
+ setDarkMode(storage.darkMode);
211
+ };
212
+ const changeNavigationType = (value2) => {
213
+ storage.navigationType = value2;
214
+ setNavigationType(value2);
215
+ };
216
+ const changeNavigationCollapsed = (value2) => {
217
+ storage.navigationCollapsed = value2;
218
+ setNavigationCollapsed(value2);
219
+ };
220
+ const changeSeedPhrase = (value2) => {
221
+ storage.seedPhrase = value2;
222
+ setSeedPhrase(value2);
223
+ };
224
+ const changeMaxAccounts = (value2) => {
225
+ storage.maxAccounts = value2;
226
+ setMaxAccounts(value2);
227
+ };
228
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
229
+ AppSettingsContext.Provider,
230
+ {
231
+ value: {
232
+ changeMaxAccounts,
233
+ changeNavigationCollapsed,
234
+ changeNavigationType,
235
+ changeSeedPhrase,
236
+ darkMode,
237
+ developerMode,
238
+ enableDarkMode,
239
+ enableDeveloperMode,
240
+ maxAccounts,
241
+ navigationCollapsed,
242
+ navigationType,
243
+ seedPhrase,
244
+ ...value
245
+ },
246
+ ...props,
247
+ children
248
+ }
249
+ );
250
+ };
251
+
252
+ // src/contexts/AppSettings/useAppSettings.ts
253
+ var import_react3 = require("react");
254
+ var useAppSettings = () => {
255
+ return (0, import_react3.useContext)(AppSettingsContext);
256
+ };
257
+
258
+ // src/components/DarkModeIconButton.tsx
259
+ var import_jsx_runtime2 = require("react/jsx-runtime");
260
+ var DarkModeIconButton = (props) => {
261
+ const { darkMode, enableDarkMode } = useAppSettings();
262
+ const handleDarkModeChange = () => {
263
+ enableDarkMode == null ? void 0 : enableDarkMode(!darkMode);
264
+ };
265
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material.IconButton, { onClick: handleDarkModeChange, ...props, children: darkMode ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.DarkModeRounded, {}) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.LightModeRounded, {}) });
266
+ };
267
+
268
+ // src/components/Developer.tsx
269
+ var Developer = ({ children = null }) => {
270
+ const { developerMode } = useAppSettings();
271
+ return developerMode ? children : null;
272
+ };
273
+ // Annotate the CommonJS export names for ESM import in node:
274
+ 0 && (module.exports = {
275
+ AppSettingSlug,
276
+ AppSettingsContext,
277
+ AppSettingsProvider,
278
+ AppSettingsStorage,
279
+ AppSettingsStorageBase,
280
+ DarkModeIconButton,
281
+ Developer,
282
+ useAppSettings
283
+ });
2
284
  //# sourceMappingURL=index.cjs.map