@statsbygg/layout 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Breadcrumbs.d.mts +10 -0
- package/dist/components/Breadcrumbs.d.ts +10 -0
- package/dist/components/Breadcrumbs.js +5 -0
- package/dist/components/Breadcrumbs.js.map +1 -0
- package/dist/components/Breadcrumbs.mjs +5 -0
- package/dist/components/Breadcrumbs.mjs.map +1 -0
- package/dist/components/GlobalFooter.d.mts +9 -0
- package/dist/components/GlobalFooter.d.ts +9 -0
- package/dist/components/GlobalFooter.js +5 -0
- package/dist/components/GlobalFooter.js.map +1 -0
- package/dist/components/GlobalFooter.mjs +5 -0
- package/dist/components/GlobalFooter.mjs.map +1 -0
- package/dist/components/GlobalHeader.d.mts +10 -0
- package/dist/components/GlobalHeader.d.ts +10 -0
- package/dist/components/GlobalHeader.js +5 -0
- package/dist/components/GlobalHeader.js.map +1 -0
- package/dist/components/GlobalHeader.mjs +5 -0
- package/dist/components/GlobalHeader.mjs.map +1 -0
- package/dist/components/MenuButton.d.mts +9 -0
- package/dist/components/MenuButton.d.ts +9 -0
- package/dist/components/MenuButton.js +5 -0
- package/dist/components/MenuButton.js.map +1 -0
- package/dist/components/MenuButton.mjs +5 -0
- package/dist/components/MenuButton.mjs.map +1 -0
- package/dist/components/RootLayout.d.mts +11 -0
- package/dist/components/RootLayout.d.ts +11 -0
- package/dist/components/RootLayout.js +5 -0
- package/dist/components/RootLayout.js.map +1 -0
- package/dist/components/RootLayout.mjs +5 -0
- package/dist/components/RootLayout.mjs.map +1 -0
- package/dist/index.d.mts +5 -40
- package/dist/index.d.ts +5 -40
- package/dist/store/globalState.d.mts +31 -0
- package/dist/store/globalState.d.ts +31 -0
- package/dist/store/globalState.js +30 -0
- package/dist/store/globalState.js.map +1 -0
- package/dist/store/globalState.mjs +30 -0
- package/dist/store/globalState.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface BreadcrumbsProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
zone: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare function SbBreadcrumbs({ className, zone }: BreadcrumbsProps): react_jsx_runtime.JSX.Element | null;
|
|
9
|
+
|
|
10
|
+
export { SbBreadcrumbs as Breadcrumbs, type BreadcrumbsProps };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface BreadcrumbsProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
zone: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare function SbBreadcrumbs({ className, zone }: BreadcrumbsProps): react_jsx_runtime.JSX.Element | null;
|
|
9
|
+
|
|
10
|
+
export { SbBreadcrumbs as Breadcrumbs, type BreadcrumbsProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Breadcrumbs/index.ts","/home/jimmy/dev/work/statsbygg-components/packages/layout/dist/components/Breadcrumbs.js"],"names":[],"mappings":"AAAA,qHAA6C;ACC7C;AACE;AACF,iDAAC","file":"/home/jimmy/dev/work/statsbygg-components/packages/layout/dist/components/Breadcrumbs.js","sourcesContent":["export { SbBreadcrumbs as Breadcrumbs } from './Breadcrumbs';\nexport type { BreadcrumbsProps } from './Breadcrumbs.types';",null]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Breadcrumbs/index.ts"],"sourcesContent":["export { SbBreadcrumbs as Breadcrumbs } from './Breadcrumbs';\nexport type { BreadcrumbsProps } from './Breadcrumbs.types';"],"mappings":"AAAA,SAA0B,qBAAmB;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface GlobalFooterProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare function GlobalFooter({ className }: GlobalFooterProps): react_jsx_runtime.JSX.Element;
|
|
8
|
+
|
|
9
|
+
export { GlobalFooter, type GlobalFooterProps };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface GlobalFooterProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare function GlobalFooter({ className }: GlobalFooterProps): react_jsx_runtime.JSX.Element;
|
|
8
|
+
|
|
9
|
+
export { GlobalFooter, type GlobalFooterProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/GlobalFooter/index.ts","/home/jimmy/dev/work/statsbygg-components/packages/layout/dist/components/GlobalFooter.js"],"names":[],"mappings":"AAAA,uHAA6B;ACC7B;AACE;AACF,kDAAC","file":"/home/jimmy/dev/work/statsbygg-components/packages/layout/dist/components/GlobalFooter.js","sourcesContent":["export { GlobalFooter } from './GlobalFooter';\nexport type { GlobalFooterProps } from './GlobalFooter.types';",null]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/GlobalFooter/index.ts"],"sourcesContent":["export { GlobalFooter } from './GlobalFooter';\nexport type { GlobalFooterProps } from './GlobalFooter.types';"],"mappings":"AAAA,SAAS,oBAAoB;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface GlobalHeaderProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
zone: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare function GlobalHeader({ className, zone }: GlobalHeaderProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { GlobalHeader, type GlobalHeaderProps };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface GlobalHeaderProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
zone: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare function GlobalHeader({ className, zone }: GlobalHeaderProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { GlobalHeader, type GlobalHeaderProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/GlobalHeader/index.ts","/home/jimmy/dev/work/statsbygg-components/packages/layout/dist/components/GlobalHeader.js"],"names":[],"mappings":"AAAA,uHAA6B;ACC7B;AACE;AACF,kDAAC","file":"/home/jimmy/dev/work/statsbygg-components/packages/layout/dist/components/GlobalHeader.js","sourcesContent":["export { GlobalHeader } from './GlobalHeader';\nexport type { GlobalHeaderProps } from './GlobalHeader.types';",null]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/GlobalHeader/index.ts"],"sourcesContent":["export { GlobalHeader } from './GlobalHeader';\nexport type { GlobalHeaderProps } from './GlobalHeader.types';"],"mappings":"AAAA,SAAS,oBAAoB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/MenuButton/index.ts","/home/jimmy/dev/work/statsbygg-components/packages/layout/dist/components/MenuButton.js"],"names":[],"mappings":"AAAA,mHAA2B;ACC3B;AACE;AACF,4CAAC","file":"/home/jimmy/dev/work/statsbygg-components/packages/layout/dist/components/MenuButton.js","sourcesContent":["export { MenuButton } from './MenuButton';\nexport type { MenuButtonProps } from './MenuButton.types';",null]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/MenuButton/index.ts"],"sourcesContent":["export { MenuButton } from './MenuButton';\nexport type { MenuButtonProps } from './MenuButton.types';"],"mappings":"AAAA,SAAS,kBAAkB;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface RootLayoutProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
zone: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare function RootLayout({ children, zone, className, }: RootLayoutProps): react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { RootLayout, type RootLayoutProps };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface RootLayoutProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
zone: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare function RootLayout({ children, zone, className, }: RootLayoutProps): react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { RootLayout, type RootLayoutProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/RootLayout/index.ts","/home/jimmy/dev/work/statsbygg-components/packages/layout/dist/components/RootLayout.js"],"names":[],"mappings":"AAAA,mHAA2B;ACC3B;AACE;AACF,4CAAC","file":"/home/jimmy/dev/work/statsbygg-components/packages/layout/dist/components/RootLayout.js","sourcesContent":["export { RootLayout } from './RootLayout';\nexport type { RootLayoutProps } from './RootLayout.types';",null]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/RootLayout/index.ts"],"sourcesContent":["export { RootLayout } from './RootLayout';\nexport type { RootLayoutProps } from './RootLayout.types';"],"mappings":"AAAA,SAAS,kBAAkB;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,40 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
zone: string;
|
|
8
|
-
className?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
declare function RootLayout({ children, zone, className, }: RootLayoutProps): react_jsx_runtime.JSX.Element;
|
|
12
|
-
|
|
13
|
-
type Theme = 'light' | 'dark' | 'system';
|
|
14
|
-
type GlobalState = {
|
|
15
|
-
user?: {
|
|
16
|
-
id: string;
|
|
17
|
-
name?: string;
|
|
18
|
-
} | null;
|
|
19
|
-
theme: Theme;
|
|
20
|
-
locale: string;
|
|
21
|
-
setUser: (user: GlobalState['user']) => void;
|
|
22
|
-
setTheme: (theme: Theme) => void;
|
|
23
|
-
setLocale: (locale: string) => void;
|
|
24
|
-
initialize: () => void | Promise<void>;
|
|
25
|
-
};
|
|
26
|
-
declare const useGlobalStore: zustand.UseBoundStore<Omit<zustand.StoreApi<GlobalState>, "setState" | "persist"> & {
|
|
27
|
-
setState(partial: GlobalState | Partial<GlobalState> | ((state: GlobalState) => GlobalState | Partial<GlobalState>), replace?: false | undefined): unknown;
|
|
28
|
-
setState(state: GlobalState | ((state: GlobalState) => GlobalState), replace: true): unknown;
|
|
29
|
-
persist: {
|
|
30
|
-
setOptions: (options: Partial<zustand_middleware.PersistOptions<GlobalState, unknown, unknown>>) => void;
|
|
31
|
-
clearStorage: () => void;
|
|
32
|
-
rehydrate: () => Promise<void> | void;
|
|
33
|
-
hasHydrated: () => boolean;
|
|
34
|
-
onHydrate: (fn: (state: GlobalState) => void) => () => void;
|
|
35
|
-
onFinishHydration: (fn: (state: GlobalState) => void) => () => void;
|
|
36
|
-
getOptions: () => Partial<zustand_middleware.PersistOptions<GlobalState, unknown, unknown>>;
|
|
37
|
-
};
|
|
38
|
-
}>;
|
|
39
|
-
|
|
40
|
-
export { type GlobalState, RootLayout, type RootLayoutProps, useGlobalStore };
|
|
1
|
+
export { RootLayout, RootLayoutProps } from './components/RootLayout.mjs';
|
|
2
|
+
export { GlobalState, useGlobalStore } from './store/globalState.mjs';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
|
+
import 'zustand/middleware';
|
|
5
|
+
import 'zustand';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,40 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
zone: string;
|
|
8
|
-
className?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
declare function RootLayout({ children, zone, className, }: RootLayoutProps): react_jsx_runtime.JSX.Element;
|
|
12
|
-
|
|
13
|
-
type Theme = 'light' | 'dark' | 'system';
|
|
14
|
-
type GlobalState = {
|
|
15
|
-
user?: {
|
|
16
|
-
id: string;
|
|
17
|
-
name?: string;
|
|
18
|
-
} | null;
|
|
19
|
-
theme: Theme;
|
|
20
|
-
locale: string;
|
|
21
|
-
setUser: (user: GlobalState['user']) => void;
|
|
22
|
-
setTheme: (theme: Theme) => void;
|
|
23
|
-
setLocale: (locale: string) => void;
|
|
24
|
-
initialize: () => void | Promise<void>;
|
|
25
|
-
};
|
|
26
|
-
declare const useGlobalStore: zustand.UseBoundStore<Omit<zustand.StoreApi<GlobalState>, "setState" | "persist"> & {
|
|
27
|
-
setState(partial: GlobalState | Partial<GlobalState> | ((state: GlobalState) => GlobalState | Partial<GlobalState>), replace?: false | undefined): unknown;
|
|
28
|
-
setState(state: GlobalState | ((state: GlobalState) => GlobalState), replace: true): unknown;
|
|
29
|
-
persist: {
|
|
30
|
-
setOptions: (options: Partial<zustand_middleware.PersistOptions<GlobalState, unknown, unknown>>) => void;
|
|
31
|
-
clearStorage: () => void;
|
|
32
|
-
rehydrate: () => Promise<void> | void;
|
|
33
|
-
hasHydrated: () => boolean;
|
|
34
|
-
onHydrate: (fn: (state: GlobalState) => void) => () => void;
|
|
35
|
-
onFinishHydration: (fn: (state: GlobalState) => void) => () => void;
|
|
36
|
-
getOptions: () => Partial<zustand_middleware.PersistOptions<GlobalState, unknown, unknown>>;
|
|
37
|
-
};
|
|
38
|
-
}>;
|
|
39
|
-
|
|
40
|
-
export { type GlobalState, RootLayout, type RootLayoutProps, useGlobalStore };
|
|
1
|
+
export { RootLayout, RootLayoutProps } from './components/RootLayout.js';
|
|
2
|
+
export { GlobalState, useGlobalStore } from './store/globalState.js';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
|
+
import 'zustand/middleware';
|
|
5
|
+
import 'zustand';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as zustand_middleware from 'zustand/middleware';
|
|
2
|
+
import * as zustand from 'zustand';
|
|
3
|
+
|
|
4
|
+
type Theme = 'light' | 'dark' | 'system';
|
|
5
|
+
type GlobalState = {
|
|
6
|
+
user?: {
|
|
7
|
+
id: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
} | null;
|
|
10
|
+
theme: Theme;
|
|
11
|
+
locale: string;
|
|
12
|
+
setUser: (user: GlobalState['user']) => void;
|
|
13
|
+
setTheme: (theme: Theme) => void;
|
|
14
|
+
setLocale: (locale: string) => void;
|
|
15
|
+
initialize: () => void | Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
declare const useGlobalStore: zustand.UseBoundStore<Omit<zustand.StoreApi<GlobalState>, "setState" | "persist"> & {
|
|
18
|
+
setState(partial: GlobalState | Partial<GlobalState> | ((state: GlobalState) => GlobalState | Partial<GlobalState>), replace?: false | undefined): unknown;
|
|
19
|
+
setState(state: GlobalState | ((state: GlobalState) => GlobalState), replace: true): unknown;
|
|
20
|
+
persist: {
|
|
21
|
+
setOptions: (options: Partial<zustand_middleware.PersistOptions<GlobalState, unknown, unknown>>) => void;
|
|
22
|
+
clearStorage: () => void;
|
|
23
|
+
rehydrate: () => Promise<void> | void;
|
|
24
|
+
hasHydrated: () => boolean;
|
|
25
|
+
onHydrate: (fn: (state: GlobalState) => void) => () => void;
|
|
26
|
+
onFinishHydration: (fn: (state: GlobalState) => void) => () => void;
|
|
27
|
+
getOptions: () => Partial<zustand_middleware.PersistOptions<GlobalState, unknown, unknown>>;
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
30
|
+
|
|
31
|
+
export { type GlobalState, type Theme, useGlobalStore };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as zustand_middleware from 'zustand/middleware';
|
|
2
|
+
import * as zustand from 'zustand';
|
|
3
|
+
|
|
4
|
+
type Theme = 'light' | 'dark' | 'system';
|
|
5
|
+
type GlobalState = {
|
|
6
|
+
user?: {
|
|
7
|
+
id: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
} | null;
|
|
10
|
+
theme: Theme;
|
|
11
|
+
locale: string;
|
|
12
|
+
setUser: (user: GlobalState['user']) => void;
|
|
13
|
+
setTheme: (theme: Theme) => void;
|
|
14
|
+
setLocale: (locale: string) => void;
|
|
15
|
+
initialize: () => void | Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
declare const useGlobalStore: zustand.UseBoundStore<Omit<zustand.StoreApi<GlobalState>, "setState" | "persist"> & {
|
|
18
|
+
setState(partial: GlobalState | Partial<GlobalState> | ((state: GlobalState) => GlobalState | Partial<GlobalState>), replace?: false | undefined): unknown;
|
|
19
|
+
setState(state: GlobalState | ((state: GlobalState) => GlobalState), replace: true): unknown;
|
|
20
|
+
persist: {
|
|
21
|
+
setOptions: (options: Partial<zustand_middleware.PersistOptions<GlobalState, unknown, unknown>>) => void;
|
|
22
|
+
clearStorage: () => void;
|
|
23
|
+
rehydrate: () => Promise<void> | void;
|
|
24
|
+
hasHydrated: () => boolean;
|
|
25
|
+
onHydrate: (fn: (state: GlobalState) => void) => () => void;
|
|
26
|
+
onFinishHydration: (fn: (state: GlobalState) => void) => () => void;
|
|
27
|
+
getOptions: () => Partial<zustand_middleware.PersistOptions<GlobalState, unknown, unknown>>;
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
30
|
+
|
|
31
|
+
export { type GlobalState, type Theme, useGlobalStore };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _zustand = require('zustand');
|
|
2
|
+
var _middleware = require('zustand/middleware');
|
|
3
|
+
const creator = (set, get) => ({
|
|
4
|
+
user: null,
|
|
5
|
+
theme: "light",
|
|
6
|
+
locale: "no",
|
|
7
|
+
setUser: (user) => set({ user }),
|
|
8
|
+
setTheme: (theme) => {
|
|
9
|
+
set({ theme });
|
|
10
|
+
if (typeof document !== "undefined") {
|
|
11
|
+
document.documentElement.setAttribute("data-color-scheme", theme);
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
setLocale: (locale) => set({ locale }),
|
|
15
|
+
initialize: () => {
|
|
16
|
+
if (typeof document !== "undefined") {
|
|
17
|
+
document.documentElement.setAttribute("data-color-scheme", get().theme);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const useGlobalStore = _zustand.create.call(void 0, )(
|
|
22
|
+
_middleware.persist.call(void 0, creator, {
|
|
23
|
+
name: "statsbygg-global-state",
|
|
24
|
+
storage: _middleware.createJSONStorage.call(void 0, () => localStorage)
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.useGlobalStore = useGlobalStore;
|
|
30
|
+
//# sourceMappingURL=globalState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/store/globalState.ts","/home/jimmy/dev/work/statsbygg-components/packages/layout/dist/store/globalState.js"],"names":[],"mappings":"AAAA,2GAAqC;AACrC,gDAA2C;AAc3C,MAAM,QAAA,EAAqE,CAAC,GAAA,EAAK,GAAA,EAAA,GAAA,CAAS;AAAA,EACxF,IAAA,EAAM,IAAA;AAAA,EACN,KAAA,EAAO,OAAA;AAAA,EACP,MAAA,EAAQ,IAAA;AAAA,EACR,OAAA,EAAS,CAAC,IAAA,EAAA,GAAS,GAAA,CAAI,EAAE,KAAK,CAAC,CAAA;AAAA,EAC/B,QAAA,EAAU,CAAC,KAAA,EAAA,GAAU;AACnB,IAAA,GAAA,CAAI,EAAE,MAAM,CAAC,CAAA;AACb,IAAA,GAAA,CAAI,OAAO,SAAA,IAAa,WAAA,EAAa;AACnC,MAAA,QAAA,CAAS,eAAA,CAAgB,YAAA,CAAa,mBAAA,EAAqB,KAAK,CAAA;AAAA,IAClE;AAAA,EACF,CAAA;AAAA,EACA,SAAA,EAAW,CAAC,MAAA,EAAA,GAAW,GAAA,CAAI,EAAE,OAAO,CAAC,CAAA;AAAA,EACrC,UAAA,EAAY,CAAA,EAAA,GAAM;AAChB,IAAA,GAAA,CAAI,OAAO,SAAA,IAAa,WAAA,EAAa;AACnC,MAAA,QAAA,CAAS,eAAA,CAAgB,YAAA,CAAa,mBAAA,EAAqB,GAAA,CAAI,CAAA,CAAE,KAAK,CAAA;AAAA,IACxE;AAAA,EACF;AACF,CAAA,CAAA;AAEO,MAAM,eAAA,EAAiB,6BAAA,CAAoB;AAAA,EAChD,iCAAA,OAAQ,EAAS;AAAA,IACf,IAAA,EAAM,wBAAA;AAAA,IACN,OAAA,EAAS,2CAAA,CAAkB,EAAA,GAAM,YAAY;AAAA,EAC/C,CAAC;AACH,CAAA;ACbA;AACE;AACF,wCAAC","file":"/home/jimmy/dev/work/statsbygg-components/packages/layout/dist/store/globalState.js","sourcesContent":["import { create, StateCreator } from 'zustand';\nimport { persist, createJSONStorage } from 'zustand/middleware';\n\nexport type Theme = 'light' | 'dark' | 'system';\n\nexport type GlobalState = {\n user?: { id: string; name?: string } | null;\n theme: Theme;\n locale: string;\n setUser: (user: GlobalState['user']) => void;\n setTheme: (theme: Theme) => void;\n setLocale: (locale: string) => void;\n initialize: () => void | Promise<void>;\n};\n\nconst creator: StateCreator<GlobalState, [['zustand/persist', unknown]]> = (set, get) => ({\n user: null,\n theme: 'light',\n locale: 'no',\n setUser: (user) => set({ user }),\n setTheme: (theme) => {\n set({ theme });\n if (typeof document !== 'undefined') {\n document.documentElement.setAttribute('data-color-scheme', theme);\n }\n },\n setLocale: (locale) => set({ locale }),\n initialize: () => {\n if (typeof document !== 'undefined') {\n document.documentElement.setAttribute('data-color-scheme', get().theme);\n }\n },\n});\n\nexport const useGlobalStore = create<GlobalState>()(\n persist(creator, {\n name: 'statsbygg-global-state',\n storage: createJSONStorage(() => localStorage),\n })\n);\n",null]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
import { persist, createJSONStorage } from "zustand/middleware";
|
|
3
|
+
const creator = (set, get) => ({
|
|
4
|
+
user: null,
|
|
5
|
+
theme: "light",
|
|
6
|
+
locale: "no",
|
|
7
|
+
setUser: (user) => set({ user }),
|
|
8
|
+
setTheme: (theme) => {
|
|
9
|
+
set({ theme });
|
|
10
|
+
if (typeof document !== "undefined") {
|
|
11
|
+
document.documentElement.setAttribute("data-color-scheme", theme);
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
setLocale: (locale) => set({ locale }),
|
|
15
|
+
initialize: () => {
|
|
16
|
+
if (typeof document !== "undefined") {
|
|
17
|
+
document.documentElement.setAttribute("data-color-scheme", get().theme);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const useGlobalStore = create()(
|
|
22
|
+
persist(creator, {
|
|
23
|
+
name: "statsbygg-global-state",
|
|
24
|
+
storage: createJSONStorage(() => localStorage)
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
export {
|
|
28
|
+
useGlobalStore
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=globalState.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/store/globalState.ts"],"sourcesContent":["import { create, StateCreator } from 'zustand';\nimport { persist, createJSONStorage } from 'zustand/middleware';\n\nexport type Theme = 'light' | 'dark' | 'system';\n\nexport type GlobalState = {\n user?: { id: string; name?: string } | null;\n theme: Theme;\n locale: string;\n setUser: (user: GlobalState['user']) => void;\n setTheme: (theme: Theme) => void;\n setLocale: (locale: string) => void;\n initialize: () => void | Promise<void>;\n};\n\nconst creator: StateCreator<GlobalState, [['zustand/persist', unknown]]> = (set, get) => ({\n user: null,\n theme: 'light',\n locale: 'no',\n setUser: (user) => set({ user }),\n setTheme: (theme) => {\n set({ theme });\n if (typeof document !== 'undefined') {\n document.documentElement.setAttribute('data-color-scheme', theme);\n }\n },\n setLocale: (locale) => set({ locale }),\n initialize: () => {\n if (typeof document !== 'undefined') {\n document.documentElement.setAttribute('data-color-scheme', get().theme);\n }\n },\n});\n\nexport const useGlobalStore = create<GlobalState>()(\n persist(creator, {\n name: 'statsbygg-global-state',\n storage: createJSONStorage(() => localStorage),\n })\n);\n"],"mappings":"AAAA,SAAS,cAA4B;AACrC,SAAS,SAAS,yBAAyB;AAc3C,MAAM,UAAqE,CAAC,KAAK,SAAS;AAAA,EACxF,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS,CAAC,SAAS,IAAI,EAAE,KAAK,CAAC;AAAA,EAC/B,UAAU,CAAC,UAAU;AACnB,QAAI,EAAE,MAAM,CAAC;AACb,QAAI,OAAO,aAAa,aAAa;AACnC,eAAS,gBAAgB,aAAa,qBAAqB,KAAK;AAAA,IAClE;AAAA,EACF;AAAA,EACA,WAAW,CAAC,WAAW,IAAI,EAAE,OAAO,CAAC;AAAA,EACrC,YAAY,MAAM;AAChB,QAAI,OAAO,aAAa,aAAa;AACnC,eAAS,gBAAgB,aAAa,qBAAqB,IAAI,EAAE,KAAK;AAAA,IACxE;AAAA,EACF;AACF;AAEO,MAAM,iBAAiB,OAAoB;AAAA,EAChD,QAAQ,SAAS;AAAA,IACf,MAAM;AAAA,IACN,SAAS,kBAAkB,MAAM,YAAY;AAAA,EAC/C,CAAC;AACH;","names":[]}
|