@functionalcms/svelte-components 4.35.4 → 4.36.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.
- package/dist/components/layouts/MenuLayout.svelte +39 -45
- package/dist/components/layouts/MenuLayout.svelte.d.ts +3 -3
- package/dist/server-side/getServices.d.ts +2 -1
- package/dist/server-side/getServices.js +7 -1
- package/package.json +2 -2
- package/dist/components/icons.d.ts +0 -2
- package/dist/components/icons.js +0 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { Snippet } from
|
|
3
|
-
import type { MenuSection } from
|
|
4
|
-
import Accordion from
|
|
5
|
-
import Icon from
|
|
6
|
-
import { IconsSet, getIcon } from
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { MenuItem, MenuSection } from './menuLayout.js';
|
|
4
|
+
import Accordion from '../presentation/Accordion.svelte';
|
|
5
|
+
import Icon from '@iconify/svelte';
|
|
6
|
+
import { IconsSet, getIcon } from '../MaterialIconSet.js';
|
|
7
7
|
|
|
8
8
|
interface TwoColumnLayoutProps {
|
|
9
9
|
rightRender: Snippet;
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
collapsedWidthPx: number;
|
|
15
15
|
minWidthPercent: number;
|
|
16
16
|
maxWidthPercent: number;
|
|
17
|
-
menuItems: MenuSection
|
|
17
|
+
menuItems: Array<MenuSection | MenuItem>;
|
|
18
18
|
buttonCss: string;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
let {
|
|
22
22
|
rightRender,
|
|
23
|
-
containerCss =
|
|
23
|
+
containerCss = '',
|
|
24
24
|
spitPercentage = 15,
|
|
25
25
|
isResizable = true,
|
|
26
26
|
isCollapsible = true,
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
minWidthPercent = 10,
|
|
29
29
|
maxWidthPercent = 80,
|
|
30
30
|
menuItems = [],
|
|
31
|
-
buttonCss =
|
|
31
|
+
buttonCss = ''
|
|
32
32
|
}: Partial<TwoColumnLayoutProps> = $props();
|
|
33
33
|
|
|
34
34
|
let container: HTMLElement | undefined = undefined;
|
|
35
35
|
let leftWidthPx = $state(0);
|
|
36
36
|
let isCollapsed = $state(false);
|
|
37
37
|
let isDragging = $state(false);
|
|
38
|
-
let iconStyleWidth = $derived(isCollapsed ?
|
|
38
|
+
let iconStyleWidth = $derived(isCollapsed ? '2.25rem' : '1.5rem');
|
|
39
39
|
|
|
40
40
|
$effect(() => {
|
|
41
41
|
if (container) {
|
|
@@ -79,64 +79,58 @@
|
|
|
79
79
|
|
|
80
80
|
$effect(() => {
|
|
81
81
|
if (isDragging) {
|
|
82
|
-
document.addEventListener(
|
|
83
|
-
document.addEventListener(
|
|
82
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
83
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
84
84
|
|
|
85
85
|
return () => {
|
|
86
|
-
document.removeEventListener(
|
|
87
|
-
document.removeEventListener(
|
|
86
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
87
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
</script>
|
|
92
92
|
|
|
93
|
+
{#snippet itemRender(item: { icon: any; title: any; href: any })}
|
|
94
|
+
<a href={item.href} class="{buttonCss} button">
|
|
95
|
+
{#if item.icon}
|
|
96
|
+
<Icon icon={item.icon} width={iconStyleWidth} />
|
|
97
|
+
{/if}
|
|
98
|
+
{#if !isCollapsed}
|
|
99
|
+
{item.title}
|
|
100
|
+
{/if}
|
|
101
|
+
</a>
|
|
102
|
+
{/snippet}
|
|
103
|
+
|
|
93
104
|
<section class="layout {containerCss}" bind:this={container}>
|
|
94
|
-
<div
|
|
95
|
-
class="menu"
|
|
96
|
-
style:width={isCollapsed ? `${collapsedWidthPx}px` : `${leftWidthPx}px`}
|
|
97
|
-
>
|
|
105
|
+
<div class="menu" style:width={isCollapsed ? `${collapsedWidthPx}px` : `${leftWidthPx}px`}>
|
|
98
106
|
{#if isCollapsible}
|
|
99
107
|
<div class="toggle-button-container">
|
|
100
108
|
<button
|
|
101
109
|
class="toggle-button"
|
|
102
110
|
onclick={toggleCollapse}
|
|
103
|
-
aria-label={isCollapsed ?
|
|
111
|
+
aria-label={isCollapsed ? 'Expand' : 'Collapse'}
|
|
104
112
|
>
|
|
105
113
|
{#if isCollapsed}
|
|
106
|
-
<Icon
|
|
107
|
-
icon={getIcon(IconsSet.arrow_menu_close)}
|
|
108
|
-
width="48"
|
|
109
|
-
height="48"
|
|
110
|
-
/>
|
|
114
|
+
<Icon icon={getIcon(IconsSet.arrow_menu_close)} width="48" height="48" />
|
|
111
115
|
{:else}
|
|
112
|
-
<Icon
|
|
113
|
-
icon={getIcon(IconsSet.arrow_menu_open)}
|
|
114
|
-
width="48"
|
|
115
|
-
height="48"
|
|
116
|
-
/>
|
|
116
|
+
<Icon icon={getIcon(IconsSet.arrow_menu_open)} width="48" height="48" />
|
|
117
117
|
{/if}
|
|
118
118
|
</button>
|
|
119
119
|
</div>
|
|
120
120
|
{/if}
|
|
121
121
|
<section>
|
|
122
122
|
{#each menuItems as section}
|
|
123
|
-
|
|
124
|
-
<
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
{item.title}
|
|
135
|
-
{/if}
|
|
136
|
-
</a>
|
|
137
|
-
{/each}
|
|
138
|
-
</div>
|
|
139
|
-
</Accordion>
|
|
123
|
+
{#if section?.items}
|
|
124
|
+
<Accordion title={section.title} css="section">
|
|
125
|
+
<div class="menu-section">
|
|
126
|
+
{#each section.items as item}
|
|
127
|
+
{@render itemRender(item)}
|
|
128
|
+
{/each}
|
|
129
|
+
</div>
|
|
130
|
+
</Accordion>
|
|
131
|
+
{:else}
|
|
132
|
+
{@render itemRender(section)}
|
|
133
|
+
{/if}
|
|
140
134
|
{/each}
|
|
141
135
|
</section>
|
|
142
136
|
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Snippet } from
|
|
2
|
-
import type { MenuSection } from
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { MenuItem, MenuSection } from './menuLayout.js';
|
|
3
3
|
declare const MenuLayout: import("svelte").Component<Partial<{
|
|
4
4
|
rightRender: Snippet;
|
|
5
5
|
containerCss: string;
|
|
@@ -9,7 +9,7 @@ declare const MenuLayout: import("svelte").Component<Partial<{
|
|
|
9
9
|
collapsedWidthPx: number;
|
|
10
10
|
minWidthPercent: number;
|
|
11
11
|
maxWidthPercent: number;
|
|
12
|
-
menuItems: MenuSection
|
|
12
|
+
menuItems: Array<MenuSection | MenuItem>;
|
|
13
13
|
buttonCss: string;
|
|
14
14
|
}>, {}, "">;
|
|
15
15
|
type MenuLayout = ReturnType<typeof MenuLayout>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommunicationService, DataService, TemplateService, WebsitesService, BlobService, AiService, AuthService } from "@functionalcms/services";
|
|
1
|
+
import { CommunicationService, DataService, TemplateService, WebsitesService, BlobService, AiService, AuthService, FilesService } from "@functionalcms/services";
|
|
2
2
|
import type { Locals } from "./types.js";
|
|
3
3
|
export declare const getDataService: (locals: Locals, endpoint?: string | undefined) => DataService;
|
|
4
4
|
export declare const getCommunicationService: (locals: Locals, endpoint?: string | undefined) => CommunicationService;
|
|
@@ -7,3 +7,4 @@ export declare const getTemplateService: (locals: Locals, endpoint?: string | un
|
|
|
7
7
|
export declare const getBlobService: (locals: Locals, endpoint?: string | undefined) => BlobService;
|
|
8
8
|
export declare const getAIService: (locals: Locals, endpoint?: string | undefined) => AiService;
|
|
9
9
|
export declare const getAuthService: (locals: Locals, endpoint?: string | undefined) => AuthService;
|
|
10
|
+
export declare const getFileService: (locals: Locals, endpoint?: string | undefined) => FilesService;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DOMAIN, ENDPOINT } from "$env/static/private";
|
|
2
|
-
import { CommunicationService, DataService, TemplateService, WebsitesService, BlobService, AiService, AuthService, } from "@functionalcms/services";
|
|
2
|
+
import { CommunicationService, DataService, TemplateService, WebsitesService, BlobService, AiService, AuthService, FilesService, } from "@functionalcms/services";
|
|
3
3
|
const getAccessToken = (locals) => {
|
|
4
4
|
return locals.token.access_token;
|
|
5
5
|
};
|
|
@@ -45,3 +45,9 @@ export const getAuthService = (locals, endpoint = undefined) => {
|
|
|
45
45
|
const service = new AuthService(accessToken, serviceEndopint);
|
|
46
46
|
return service;
|
|
47
47
|
};
|
|
48
|
+
export const getFileService = (locals, endpoint = undefined) => {
|
|
49
|
+
const accessToken = getAccessToken(locals);
|
|
50
|
+
const serviceEndopint = endpoint ?? ENDPOINT;
|
|
51
|
+
const service = new FilesService(accessToken, serviceEndopint);
|
|
52
|
+
return service;
|
|
53
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@functionalcms/svelte-components",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.36.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"watch": {
|
|
6
6
|
"build": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@eslint/compat": "^1.2.9",
|
|
48
48
|
"@eslint/js": "^9.26.0",
|
|
49
|
-
"@functionalcms/services": "
|
|
49
|
+
"@functionalcms/services": "latest",
|
|
50
50
|
"@iconify/json": "^2.2.429",
|
|
51
51
|
"@iconify/svelte": "^5.2.1",
|
|
52
52
|
"@sveltejs/adapter-auto": "^4.0.0",
|
package/dist/components/icons.js
DELETED