@functionalcms/svelte-components 2.13.5 → 2.13.8

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.
@@ -1,16 +1,17 @@
1
- <script>import { Visiblity, HeaderNavigationItem } from "./Menu.js";
1
+ <script>import { HeaderNavigationItem } from "./Menu.js";
2
2
  import { pages as pagesStore } from "../../stores/pages.js";
3
3
  import { selectVisible } from "./MenuFunctions.js";
4
- export let authentication = false;
4
+ import { isAuthenticated } from "./authentication.js";
5
+ import { page } from "$app/stores";
5
6
  export let css = "";
6
7
  export let navCss = "";
7
8
  export let localPages = [];
8
9
  $:
9
10
  activePages = !localPages || localPages.length == 0 ? $pagesStore : localPages;
10
11
  $:
11
- visibility = authentication ? Visiblity.Authenticated : Visiblity.NotAuthenticated;
12
+ pagesVisiblity = isAuthenticated(page);
12
13
  $:
13
- visibleNavItems = selectVisible(activePages, visibility);
14
+ visibleNavItems = selectVisible(activePages, pagesVisiblity);
14
15
  const klasses = ["flex", "flex-dynamic-row", css ? css : ""].filter((c) => c).join(" ");
15
16
  </script>
16
17
 
@@ -19,7 +20,7 @@ const klasses = ["flex", "flex-dynamic-row", css ? css : ""].filter((c) => c).jo
19
20
  <slot name="mobile" pages={visibleNavItems} />
20
21
  </div>
21
22
  <div class="desktop">
22
- <slot name="desktop" pages={visibleNavItems}/>
23
+ <slot name="desktop" pages={visibleNavItems} />
23
24
  </div>
24
25
  </nav>
25
26
 
@@ -2,7 +2,6 @@ import { SvelteComponent } from "svelte";
2
2
  import { HeaderNavigationItem } from './Menu.js';
3
3
  declare const __propDef: {
4
4
  props: {
5
- authentication?: boolean | undefined;
6
5
  css?: string | undefined;
7
6
  navCss?: string | undefined;
8
7
  localPages?: HeaderNavigationItem[] | undefined;
@@ -0,0 +1 @@
1
+ export declare function isAuthenticated(page: any): any;
@@ -0,0 +1,8 @@
1
+ import { Visiblity } from '@functionalcms/svelte-components';
2
+ import { get } from 'svelte/store';
3
+ export function isAuthenticated(page) {
4
+ const pageStore = get(page);
5
+ const isAuthenticated = pageStore?.data?.session != null;
6
+ const visibility = isAuthenticated ? Visiblity.Authenticated : Visiblity.NotAuthenticated;
7
+ return visibility;
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalcms/svelte-components",
3
- "version": "2.13.5",
3
+ "version": "2.13.8",
4
4
  "watch": {
5
5
  "build": {
6
6
  "patterns": [
@@ -60,5 +60,6 @@
60
60
  },
61
61
  "svelte": "./dist/index.js",
62
62
  "types": "./dist/index.d.ts",
63
- "type": "module"
63
+ "type": "module",
64
+ "sideEffects": false
64
65
  }