@functionalcms/svelte-components 2.36.0 → 2.37.0

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.
@@ -28,7 +28,6 @@ const createUserSession = async (provider, event, sessionProvider) => {
28
28
  headers.append('Location', retrunToAddress != '' ? retrunToAddress : provider.redirectPath);
29
29
  headers.append('Set-Cookie', `${authSessionCookieName}=${sessionId}; HttpOnly; Secure; SameSite=Lax; Max-Age=${token.expires_in + 120}; Path=/`);
30
30
  headers.append('Set-Cookie', `retrunToAddress=; HttpOnly; Secure; SameSite=Lax; Max-Age=${token.expires_in + 120}; Path=/`);
31
- // `${authSessionCookieName}=${sessionId}; HttpOnly; Secure; SameSite=Lax; Max-Age=${token.expires_in}; Path=/`);
32
31
  }
33
32
  else {
34
33
  headers.append('Location', '/');
@@ -1,3 +1,3 @@
1
1
  import { type Handle } from '@sveltejs/kit';
2
- declare const authorizationHandle: (protectedPaths: Array<string>) => Handle;
2
+ declare const authorizationHandle: () => Handle;
3
3
  export default authorizationHandle;
@@ -1,22 +1,21 @@
1
1
  import { redirect } from '@sveltejs/kit';
2
- const authorizationHandle = (protectedPaths) => {
2
+ const authorizationHandle = () => {
3
3
  return async ({ event, resolve }) => {
4
4
  const path = event.url.pathname;
5
5
  if (path.startsWith('/auth/') === false) {
6
- for (let protectedPath of protectedPaths) {
7
- if (path.match(protectedPath)) {
8
- const session = event?.locals?.session;
9
- if (!session) {
10
- const cookieHeader = `retrunToAddress=${event.url.toString()}; HttpOnly; Secure; SameSite=Lax; Max-Age=3600; Path=/`;
11
- return new Response('Login user', {
12
- status: 303,
13
- headers: {
14
- location: '/auth/validate',
15
- 'set-cookie': cookieHeader,
16
- referrer: event.url.toString()
17
- }
18
- });
19
- }
6
+ const route = event.route;
7
+ if (route.id.includes('/(protect)/')) {
8
+ const session = event?.locals?.session;
9
+ if (!session) {
10
+ const cookieHeader = `retrunToAddress=${event.url.toString()}; HttpOnly; Secure; SameSite=Lax; Max-Age=3600; Path=/`;
11
+ return new Response('Login user', {
12
+ status: 303,
13
+ headers: {
14
+ location: '/auth/login',
15
+ 'set-cookie': cookieHeader,
16
+ referrer: event.url.toString()
17
+ }
18
+ });
20
19
  }
21
20
  }
22
21
  }
@@ -1,8 +1,5 @@
1
1
  import { AUTH_KEYCLOAK_ID, AUTH_KEYCLOAK_SECRET, AUTH_KEYCLOAK_ISSUER } from '$env/static/private';
2
- const authStateCookieName = 'auth_state';
3
- const stateIdGenerator = () => crypto.randomUUID();
4
2
  const getKeycloakIdentity = async (issuer, client_id, scope, redirectUrl) => {
5
- const state = stateIdGenerator();
6
3
  const headers = new Headers();
7
4
  headers.append('Location', '/auth/validate');
8
5
  return headers;
@@ -0,0 +1 @@
1
+ export declare function mergedClasses(...params: any[]): string;
@@ -0,0 +1,3 @@
1
+ export function mergedClasses(...params) {
2
+ return Array.from(params).flat(2).filter((c) => c).join(' ');
3
+ }
@@ -307,6 +307,7 @@ export let size = ComponentSize.Normal;
307
307
  export let justify = Justify.Center;
308
308
  export let alignItems = AlignItmes.Center;
309
309
  export let orientation = Orientation.Row;
310
+ export let role = "";
310
311
  $: isSmall = size === ComponentSize.Small;
311
312
  $: isLarge = size === ComponentSize.Large;
312
313
  $: klasses = [
@@ -330,7 +331,6 @@ $: klasses = [
330
331
  css ? css : "btn"
331
332
  ].filter((c) => c).join(" ");
332
333
  </script>
333
- <svelte:options customElement="active-link" />
334
- <a class={klasses} href={href}>
334
+ <a class={klasses} href={href} role={role}>
335
335
  <slot />
336
336
  </a>
@@ -19,6 +19,7 @@ declare const __propDef: {
19
19
  justify?: Justify;
20
20
  alignItems?: AlignItmes;
21
21
  orientation?: Orientation;
22
+ role?: string;
22
23
  };
23
24
  events: {
24
25
  [evt: string]: CustomEvent<any>;
@@ -1,27 +1,33 @@
1
1
  <script>import { Button } from "agnostic-svelte";
2
2
  import { Orientation, Placement } from "../Styling.js";
3
- import ColumnMenu from "./ColumnMenu.svelte";
3
+ import ColumnMenu from "./NavigationItems.svelte";
4
4
  import { HeaderNavigationItem } from "./Menu.js";
5
- export let buttonCss = "";
6
- export let contentCss = "";
7
- export let linkCss = "";
5
+ import { mergedClasses } from "../CssHelper.js";
6
+ export let css = {
7
+ buttonCss: [],
8
+ container: ["flex"],
9
+ link: []
10
+ };
8
11
  export let contentPosition = Placement.End;
9
12
  export let orientation = Orientation.Column;
10
13
  export let localPages = [];
11
- $: showContent = false;
14
+ $: expanded = false;
12
15
  $: showContentBeforeButton = contentPosition == Placement.Start;
16
+ $: buttonCss = mergedClasses(css.buttonCss);
13
17
  </script>
14
18
 
15
- {#if showContent && showContentBeforeButton}
16
- <ColumnMenu {localPages} {orientation} css={contentCss} />
19
+ {#if expanded && showContentBeforeButton}
20
+ <div aria-expanded={expanded}>
21
+ <ColumnMenu {localPages} {orientation} {css} />
22
+ </div>
17
23
  {/if}
18
- <div>
19
- <Button css={buttonCss} on:click={() => (showContent = !showContent)}>
20
- <slot name="handle">&#9776;</slot>
21
- </Button>
22
- </div>
23
- {#if showContent && !showContentBeforeButton}
24
- <ColumnMenu {localPages} {orientation} css={contentCss} linkCss={linkCss}/>
24
+ <Button css={buttonCss} on:click={() => (expanded = !expanded)}>
25
+ <slot name="handle">&#9776;</slot>
26
+ </Button>
27
+ {#if expanded && !showContentBeforeButton}
28
+ <div aria-expanded={expanded}>
29
+ <ColumnMenu {localPages} {orientation} {css} />
30
+ </div>
25
31
  {/if}
26
32
 
27
33
  <style>
@@ -3,9 +3,11 @@ import { Orientation, Placement } from '../Styling.js';
3
3
  import { HeaderNavigationItem } from './Menu.js';
4
4
  declare const __propDef: {
5
5
  props: {
6
- buttonCss?: string;
7
- contentCss?: string;
8
- linkCss?: string;
6
+ css?: {
7
+ buttonCss: string[];
8
+ container: string[];
9
+ link: string[];
10
+ };
9
11
  contentPosition?: Placement;
10
12
  orientation?: Orientation;
11
13
  localPages?: Array<HeaderNavigationItem>;
@@ -2,15 +2,17 @@
2
2
  import { selectVisible } from "./MenuFunctions.js";
3
3
  import { isAuthenticated } from "./authentication.js";
4
4
  import { page } from "$app/stores";
5
- export let css = "";
6
- export let navCss = "";
5
+ import { mergedClasses } from "../CssHelper.js";
6
+ export let css = {
7
+ container: []
8
+ };
7
9
  export let localPages = [];
8
10
  $: pagesVisiblity = isAuthenticated($page);
9
11
  $: visibleNavItems = selectVisible(localPages, pagesVisiblity);
10
- const klasses = ["flex", "flex-dynamic-row", css ? css : ""].filter((c) => c).join(" ");
12
+ const klasses = mergedClasses("flex", "flex-dynamic-row", css.container);
11
13
  </script>
12
14
 
13
- <nav class={navCss}>
15
+ <nav class={klasses}>
14
16
  <div class="mobile">
15
17
  <slot name="mobile" pages={visibleNavItems} />
16
18
  </div>
@@ -2,8 +2,9 @@ import { SvelteComponent } from "svelte";
2
2
  import { HeaderNavigationItem } from './Menu.js';
3
3
  declare const __propDef: {
4
4
  props: {
5
- css?: string;
6
- navCss?: string;
5
+ css?: {
6
+ container: string[];
7
+ };
7
8
  localPages?: Array<HeaderNavigationItem>;
8
9
  };
9
10
  events: {
@@ -1,10 +1,14 @@
1
1
  <script>import { HeaderNavigationItem } from "./Menu.js";
2
2
  import { afterNavigate } from "$app/navigation";
3
3
  import { Drawer, Button } from "agnostic-svelte";
4
- import { page } from "$app/stores";
5
- import { Placement } from "../Styling.js";
6
- import { isSelected } from "./MenuFunctions.js";
7
- export let css = "";
4
+ import { Orientation, Placement } from "../Styling.js";
5
+ import ColumnMenu from "./NavigationItems.svelte";
6
+ import { mergedClasses } from "../CssHelper.js";
7
+ export let css = {
8
+ buttonCss: [],
9
+ container: [],
10
+ link: []
11
+ };
8
12
  export let noBorder = false;
9
13
  export let placement = Placement.Start;
10
14
  export let localPages = [];
@@ -14,20 +18,10 @@ const assignDrawerRef = (ev) => {
14
18
  drawer = ev.detail.instance;
15
19
  };
16
20
  afterNavigate((navigation) => drawer?.hide());
17
- const klasses = [
18
- "hamburger-handle",
19
- css ? css : "",
20
- noBorder ? "no-border" : ""
21
- ].filter((c) => c).join(" ");
21
+ const buttonCss = mergedClasses("hamburger-handle", noBorder, css.buttonCss);
22
22
  </script>
23
23
 
24
- <Button
25
- type="button"
26
- data-a11y-dialog-show="hamburger-menu"
27
- mode="primary"
28
- noBorder
29
- css={klasses}
30
- >
24
+ <Button type="button" data-a11y-dialog-show="hamburger-menu" mode="primary" noBorder css={buttonCss}>
31
25
  &#9776;
32
26
  </Button>
33
27
  <Drawer
@@ -37,26 +31,17 @@ const klasses = [
37
31
  on:instance={assignDrawerRef}
38
32
  title="Menu"
39
33
  >
40
- <ul>
41
- {#each localPages as pageItem}
42
- <li aria-current={isSelected(includeSubpagesForSelect, $page, pageItem)}>
43
- <span class="screenreader-only">Navigate to {pageItem.name}</span>
44
- <a on:click={pageItem.action} href={pageItem.path}>
45
- {pageItem.name}
46
- </a>
47
- </li>
48
- {/each}
49
- </ul>
34
+ <ColumnMenu {localPages} orientation={Orientation.Column} {css} />
50
35
  </Drawer>
51
36
 
52
37
  <style>
53
- :global(.hamburger-handle) {
38
+ :global(.hamburger-handle) {
54
39
  background: var(--functional-menu-background) !important;
55
- }
40
+ }
56
41
  :global(#hamburger-menu) {
57
42
  z-index: 10001;
58
43
  }
59
- :global(#hamburger-menu>.dialog-content) {
44
+ :global(#hamburger-menu > .dialog-content) {
60
45
  background: var(--functional-menu-background) !important;
61
46
  }
62
47
  :global(.no-border) {
@@ -3,7 +3,11 @@ import { HeaderNavigationItem } from './Menu.js';
3
3
  import { Placement } from '../Styling.js';
4
4
  declare const __propDef: {
5
5
  props: {
6
- css?: string;
6
+ css?: {
7
+ buttonCss: string[];
8
+ container: string[];
9
+ link: string[];
10
+ };
7
11
  noBorder?: boolean;
8
12
  placement?: Placement;
9
13
  localPages?: Array<HeaderNavigationItem>;
@@ -3,19 +3,23 @@ import { isSelected } from "./MenuFunctions.js";
3
3
  import { Orientation } from "../Styling.js";
4
4
  import Link from "../Link.svelte";
5
5
  import { page } from "$app/stores";
6
- export let css = "";
7
- export let linkCss = "";
6
+ import { mergedClasses } from "../CssHelper.js";
7
+ export let css = {
8
+ container: [],
9
+ link: []
10
+ };
8
11
  export let localPages = [];
9
12
  export let orientation = Orientation.Column;
10
- export let includeSubpagesForSelect = false;
11
- const klasses = ["flex", orientation, css ? css : ""].filter((c) => c).join(" ");
13
+ export let includeSubpagesForSelect = true;
14
+ const containerCss = mergedClasses("flex", css.container, orientation);
15
+ const linkCss = mergedClasses(css.link);
12
16
  </script>
13
17
 
14
- <ul class={klasses}>
18
+ <ul class={containerCss} role="menu" aria-roledescription="">
15
19
  {#each localPages as pageItem}
16
- <li aria-current={isSelected(includeSubpagesForSelect, $page, pageItem)}>
20
+ <li aria-current={isSelected(includeSubpagesForSelect, $page, pageItem)} role="presentation">
17
21
  <span class="screenreader-only">Navigate to {pageItem.name}</span>
18
- <Link href={pageItem.path} css={linkCss}>
22
+ <Link href={pageItem.path} css={linkCss} role="menuItem">
19
23
  {pageItem.name}
20
24
  </Link>
21
25
  </li>
@@ -3,8 +3,10 @@ import { HeaderNavigationItem } from './Menu.js';
3
3
  import { Orientation } from '../Styling.js';
4
4
  declare const __propDef: {
5
5
  props: {
6
- css?: string;
7
- linkCss?: string;
6
+ css?: {
7
+ container: string[];
8
+ link: string[];
9
+ };
8
10
  localPages?: Array<HeaderNavigationItem>;
9
11
  orientation?: Orientation;
10
12
  includeSubpagesForSelect?: boolean;
@@ -16,9 +18,9 @@ declare const __propDef: {
16
18
  exports?: {} | undefined;
17
19
  bindings?: string | undefined;
18
20
  };
19
- export type ColumnMenuProps = typeof __propDef.props;
20
- export type ColumnMenuEvents = typeof __propDef.events;
21
- export type ColumnMenuSlots = typeof __propDef.slots;
22
- export default class ColumnMenu extends SvelteComponent<ColumnMenuProps, ColumnMenuEvents, ColumnMenuSlots> {
21
+ export type NavigationItemsProps = typeof __propDef.props;
22
+ export type NavigationItemsEvents = typeof __propDef.events;
23
+ export type NavigationItemsSlots = typeof __propDef.slots;
24
+ export default class NavigationItems extends SvelteComponent<NavigationItemsProps, NavigationItemsEvents, NavigationItemsSlots> {
23
25
  }
24
26
  export {};
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- export { default as FlatMenu } from './components/menu/FlatMenu.svelte';
2
1
  export { default as HamburgerMenu } from './components/menu/HamburgerMenu.svelte';
3
- export { default as ColumnMenu } from './components/menu/ColumnMenu.svelte';
2
+ export { default as ColumnMenu } from './components/menu/NavigationItems.svelte';
4
3
  export { default as DynamicMenu } from './components/menu/DynamicMenu.svelte';
5
4
  export { default as CollapsibleMenu } from './components/menu/CollapsibleMenu.svelte';
6
5
  export { default as DropDownMenu } from './components/menu/Menu.svelte';
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
- export { default as FlatMenu } from './components/menu/FlatMenu.svelte';
2
1
  export { default as HamburgerMenu } from './components/menu/HamburgerMenu.svelte';
3
- export { default as ColumnMenu } from './components/menu/ColumnMenu.svelte';
2
+ export { default as ColumnMenu } from './components/menu/NavigationItems.svelte';
4
3
  export { default as DynamicMenu } from './components/menu/DynamicMenu.svelte';
5
4
  export { default as CollapsibleMenu } from './components/menu/CollapsibleMenu.svelte';
6
5
  export { default as DropDownMenu } from './components/menu/Menu.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalcms/svelte-components",
3
- "version": "2.36.0",
3
+ "version": "2.37.0",
4
4
  "watch": {
5
5
  "build": {
6
6
  "patterns": [
@@ -1,56 +0,0 @@
1
- <script>import { HeaderNavigationItem } from "./Menu.js";
2
- import ColumnMenu from "./ColumnMenu.svelte";
3
- import { Orientation } from "../Styling.js";
4
- export let css = "";
5
- export let localPages = [];
6
- export let includeSubpagesForSelect = false;
7
- </script>
8
-
9
- <ColumnMenu localPages={localPages} orientation={Orientation.DynamicRow} css={css}/>
10
-
11
- <style>
12
- ul {
13
- background: var(--functional-menu-background);
14
- margin: var(--functional-menu-margin);
15
- padding: var(--functional-menu-padding);
16
- }
17
- li {
18
- }
19
- a {
20
- color: var(--functional-menu-item-color);
21
- margin: var(--functional-menu-item-margin);
22
- padding: var(--functional-menu-item-padding);
23
- background: var(--functional-menu-item-background);
24
- border-top: var(--functional-menu-item-border-top);
25
- border-right: var(--functional-menu-item-border-right);
26
- border-bottom: var(--functional-menu-item-border-bottom);
27
- border-left: var(--functional-menu-item-border-left);
28
- border-radius: var(--functional-menu-item-radius, var(--functional-radius));
29
- text-decoration: none;
30
- display: block;
31
- }
32
- a:hover {
33
- color: var(--functional-menu-item-hover-color);
34
- margin: var(--functional-menu-item-hover-margin);
35
- padding: var(--functional-menu-item-hover-padding);
36
- background: var(--functional-menu-item-hover-background);
37
- border-top: var(--functional-menu-item-hover-border-top);
38
- border-right: var(--functional-menu-item-hover-border-right);
39
- border-bottom: var(--functional-menu-item-hover-border-bottom);
40
- border-left: var(--functional-menu-item-hover-border-left);
41
- border-radius: var(--functional-menu-item-hover-radius, var(--functional-radius));
42
- }
43
- li[aria-current='true'] a {
44
- color: var(--functional-menu-item-selected-color);
45
- margin: var(--functional-menu-item-selected-margin);
46
- padding: var(--functional-menu-item-selected-padding);
47
- background: var(--functional-menu-item-selected-background);
48
- border-top: var(--functional-menu-item-selected-border-top);
49
- border-right: var(--functional-menu-item-selected-border-right);
50
- border-bottom: var(--functional-menu-item-selected-border-bottom);
51
- border-left: var(--functional-menu-item-selected-border-left);
52
- border-radius: var(--functional-menu-item-selected-radius, var(--functional-radius));
53
- }
54
- @media (min-width: 960px) {
55
- }
56
- </style>
@@ -1,21 +0,0 @@
1
- import { SvelteComponent } from "svelte";
2
- import { HeaderNavigationItem } from './Menu.js';
3
- declare const __propDef: {
4
- props: {
5
- css?: string;
6
- localPages?: Array<HeaderNavigationItem>;
7
- includeSubpagesForSelect?: boolean;
8
- };
9
- events: {
10
- [evt: string]: CustomEvent<any>;
11
- };
12
- slots: {};
13
- exports?: {} | undefined;
14
- bindings?: string | undefined;
15
- };
16
- export type FlatMenuProps = typeof __propDef.props;
17
- export type FlatMenuEvents = typeof __propDef.events;
18
- export type FlatMenuSlots = typeof __propDef.slots;
19
- export default class FlatMenu extends SvelteComponent<FlatMenuProps, FlatMenuEvents, FlatMenuSlots> {
20
- }
21
- export {};
@@ -1,15 +0,0 @@
1
- <script>import { Button } from "@functionalcms/svelte-components";
2
- export let css = "";
3
- export let noBorder = false;
4
- const klasses = [css ? css : "", noBorder ? "no-border" : ""].filter((c) => c).join(" ");
5
- </script>
6
-
7
- <Button
8
- type="button"
9
- data-a11y-dialog-show="hamburger-menu"
10
- mode="primary"
11
- noBorder
12
- css={klasses}
13
- >
14
- &#9776;
15
- </Button>
@@ -1,19 +0,0 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- css?: string;
5
- noBorder?: boolean;
6
- };
7
- events: {
8
- [evt: string]: CustomEvent<any>;
9
- };
10
- slots: {};
11
- exports?: {} | undefined;
12
- bindings?: string | undefined;
13
- };
14
- export type HamburgerButtonProps = typeof __propDef.props;
15
- export type HamburgerButtonEvents = typeof __propDef.events;
16
- export type HamburgerButtonSlots = typeof __propDef.slots;
17
- export default class HamburgerButton extends SvelteComponent<HamburgerButtonProps, HamburgerButtonEvents, HamburgerButtonSlots> {
18
- }
19
- export {};