@functionalcms/svelte-components 4.6.2 → 4.7.1

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.
@@ -23,17 +23,18 @@
23
23
  items,
24
24
  perPage = 1,
25
25
  slideGaps = '20px;',
26
- disableDrag = false
26
+ disableDrag = false,
27
+ css = {slide: "", container: ""}
27
28
  }: Props = $props();
28
29
 
29
30
  let options: EmblaOptionsType = {
30
- loop: false
31
+ loop: false,
31
32
  };
32
33
  if(disableDrag) {
33
34
  options.watchDrag = false;
34
35
  }
35
- let slideStyle = $derived('flex: 0 0 ' + 100 / perPage + '%;');
36
- let containerCss = cn('flex', 'fw');
36
+ let slideStyle = cn('flex: 0 0 ' + 100 / perPage + '%;', css.slide);
37
+ let containerCss = cn('flex', 'fw', css.container);
37
38
 
38
39
  let embla = {
39
40
  scrollPrev: () => console.log('prev'),
@@ -1,178 +1,180 @@
1
- <script>
2
- let hideOnSlide = true,
3
- imgOffset = null,
4
- sliding = false,
5
- contain = false,
6
- overlay = true,
7
- offset = 0.5,
8
- before = "",
9
- after = "",
10
- lazyLoad = false,
11
- img;
12
-
13
- function resize(e) {
14
- imgOffset = (
15
- e.type === "load" ? e.target : img
16
- ).getBoundingClientRect();
17
- }
1
+ <script lang="ts">
2
+ import { type Snippet } from "svelte";
18
3
 
19
- function move(e) {
20
- if (sliding && imgOffset) {
21
- let x = (e.touches ? e.touches[0].pageX : e.pageX) - imgOffset.left;
22
- x = x < 0 ? 0 : x > w ? w : x;
23
- offset = x / w;
24
- }
4
+ interface Props {
5
+ imageLeftSrc: string;
6
+ imageLeftAlt: string;
7
+ imageRightSrc: string;
8
+ imageRightAlt: string;
9
+ slidertLabel: Snippet;
25
10
  }
26
11
 
27
- function start(e) {
28
- sliding = true;
29
- move(e);
30
- }
12
+ let {
13
+ imageLeftSrc = "",
14
+ imageLeftAlt = "",
15
+ imageRightSrc = "",
16
+ imageRightAlt = "",
17
+ slidertLabel,
18
+ }: Partial<Props> = $props();
31
19
 
32
- function end() {
33
- sliding = false;
34
- }
20
+ let sliderPosition: number = $state(50);
21
+ let animationFrame: number | null = $state(null);
35
22
 
36
- $: w = imgOffset && imgOffset.width;
37
- $: h = imgOffset && imgOffset.height;
38
- $: x = w * offset;
39
- $: opacity = hideOnSlide && sliding ? 0 : 1;
40
- $: style = contain
41
- ? `width:100%;height:100%;`
42
- : `width:${w}px;height:${h}px;`;
43
- $: imageLoading = lazyLoad ? "lazy" : "eager";
23
+ function handleInput(e: Event) {
24
+ if (animationFrame) cancelAnimationFrame(animationFrame);
44
25
 
45
- export { before, after, offset, overlay, contain, lazyLoad, hideOnSlide };
26
+ animationFrame = requestAnimationFrame(() => {
27
+ sliderPosition = (e.target as HTMLInputElement).valueAsNumber;
28
+ });
29
+ }
30
+
31
+ function handleClick(e: Event) {
32
+ (e.target as HTMLInputElement).focus();
33
+ }
46
34
  </script>
47
35
 
48
- <svelte:window
49
- on:touchmove={move}
50
- on:touchend={end}
51
- on:mousemove={move}
52
- on:mouseup={end}
53
- on:resize={resize}
54
- />
55
-
56
- <div class="container" {style} on:touchstart={start} on:mousedown={start} role="img" aria-roledescription="image slider">
57
- <img
58
- bind:this={img}
59
- loading={imageLoading}
60
- src={after}
61
- alt="after"
62
- on:mousedown|preventDefault
63
- on:load={resize}
64
- {style}
65
- />
66
- <img
67
- loading={imageLoading}
68
- src={before}
69
- alt="before"
70
- on:mousedown|preventDefault
71
- style="{style}clip:rect(0, {x}px, {h}px, 0);"
72
- />
73
- {#if overlay}
74
- <div class="overlay" style="opacity:{opacity}"></div>
75
- {/if}
76
- <div class="before-label" style="opacity:{opacity}">
77
- <slot name="before"></slot>
78
- </div>
79
- <div class="after-label" style="opacity:{opacity}">
80
- <slot name="after"></slot>
81
- </div>
82
- <div class="handle" style="left: calc({offset * 100}% - 20px)">
83
- <div class="arrow-left"></div>
84
- <div class="arrow-right"></div>
85
- </div>
36
+ <div
37
+ class="svelte-compare-image-container"
38
+ style="--slider-position: {sliderPosition}%;"
39
+ >
40
+ <img src={imageLeftSrc} alt={imageLeftAlt} class="left-img" />
41
+ <img src={imageRightSrc} alt={imageRightAlt} class="right-img" />
42
+
43
+ <label>
44
+ <input
45
+ type="range"
46
+ min="0"
47
+ max="100"
48
+ value={sliderPosition}
49
+ oninput={handleInput}
50
+ onchange={handleInput}
51
+ onclick={handleClick}
52
+ />
53
+ </label>
86
54
  </div>
87
55
 
88
56
  <style>
89
- .container {
90
- overflow: hidden;
57
+ .svelte-compare-image-container {
58
+ box-sizing: border-box;
91
59
  position: relative;
92
- box-sizing: content-box;
60
+ overflow: hidden;
93
61
  }
94
- .container img {
95
- top: 0;
96
- left: 0;
97
- z-index: 20;
98
- display: block;
99
- max-width: 100%;
100
- user-select: none;
101
- object-fit: cover;
102
- position: absolute;
62
+
63
+ .svelte-compare-image-container:focus-within {
64
+ outline: auto 4px rgba(59, 153, 252, 0.7);
65
+ outline: auto 4px Highlight;
66
+ outline: auto 4px -moz-mac-focusring;
67
+ outline: auto 4px -webkit-focus-ring-color;
103
68
  }
104
- .overlay {
105
- top: 0;
106
- opacity: 0;
107
- z-index: 25;
69
+
70
+ img {
71
+ display: block;
72
+ height: auto;
108
73
  width: 100%;
109
- height: 100%;
110
- position: absolute;
111
- transition: opacity 0.5s;
112
- background: rgba(0, 0, 0, 0.5);
74
+ margin: 0;
113
75
  }
114
- .before-label,
115
- .after-label {
116
- top: 0;
117
- bottom: 0;
118
- z-index: 25;
119
- user-select: none;
76
+
77
+ .left-img {
78
+ clip-path: polygon(
79
+ 0 0,
80
+ var(--slider-position) 0,
81
+ var(--slider-position) 100%,
82
+ 0 100%
83
+ );
84
+ }
85
+
86
+ .right-img {
120
87
  position: absolute;
88
+ top: 0;
89
+ clip-path: polygon(
90
+ var(--slider-position) 0,
91
+ 100% 0,
92
+ 100% 100%,
93
+ var(--slider-position) 100%
94
+ );
121
95
  }
122
- .before-label {
96
+
97
+ label {
98
+ position: absolute;
99
+ display: flex;
100
+ align-items: stretch;
101
+ top: 0;
123
102
  left: 0;
124
- }
125
- .after-label {
103
+ bottom: 0;
126
104
  right: 0;
105
+ background: transparent;
127
106
  }
128
- .container:hover > .overlay {
129
- opacity: 1;
130
- }
131
- .handle {
132
- z-index: 30;
133
- width: 40px;
134
- height: 40px;
135
- cursor: move;
136
- background: none;
137
- margin-top: -4px;
138
- margin-left: -4px;
139
- user-select: none;
140
- position: absolute;
141
- border-radius: 50px;
142
- top: calc(50% - 20px);
143
- border: 4px solid white;
144
- }
145
- .handle:before,
146
- .handle:after {
107
+
108
+ label::before {
147
109
  content: "";
148
- height: 9999px;
149
110
  position: absolute;
150
- left: calc(50% - 2px);
151
- border: 2px solid white;
152
- }
153
- .handle:before {
154
- top: 40px;
155
- }
156
- .handle:after {
157
- bottom: 40px;
111
+ top: 0;
112
+ bottom: 0;
113
+ left: calc(var(--slider-position) - var(--slider-width, 0.125rem) / 2);
114
+ width: var(--slider-width, 0.125rem);
115
+ background: var(--slider-color, #ffffff);
116
+ pointer-events: none;
158
117
  }
159
- .arrow-right,
160
- .arrow-left {
161
- width: 0;
162
- height: 0;
163
- user-select: none;
118
+
119
+ input[type="range"] {
164
120
  position: relative;
165
- border-top: 10px solid transparent;
166
- border-bottom: 10px solid transparent;
121
+ cursor: col-resize;
122
+ margin: 0 calc(var(--handle-size, 2.5rem) / -2);
123
+ width: calc(100% + var(--handle-size, 2.5rem));
124
+ padding: 0;
125
+ border-radius: 0;
126
+ appearance: none;
127
+ -webkit-appearance: none;
128
+ background: none;
129
+ border: none;
167
130
  }
168
- .arrow-right {
169
- left: 23px;
170
- bottom: 10px;
171
- border-left: 10px solid white;
131
+
132
+ input[type="range"]::-moz-range-thumb {
133
+ display: flex;
134
+ justify-content: center;
135
+ align-items: center;
136
+ background-color: var(--handle-background-color, rgba(0, 0, 0, 0.6));
137
+ background-image: var(
138
+ --handle-background-image,
139
+ url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M3 12H21M3 12L7 8M3 12L7 16M21 12L17 16M21 12L17 8" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>')
140
+ );
141
+ background-size: 80%;
142
+ background-position: center center;
143
+ background-repeat: no-repeat;
144
+ border: var(--handle-border-width, 0.125rem) solid
145
+ var(--slider-color, #ffffff);
146
+ border-radius: 100%;
147
+ box-shadow:
148
+ 0 3px 1px -2px rgba(0, 0, 0, 0.2),
149
+ 0 2px 2px 0 rgba(0, 0, 0, 0.14),
150
+ 0 1px 5px 0 rgba(0, 0, 0, 0.12);
151
+ color: var(--slider-color, #ffffff);
152
+ width: var(--handle-size, 2.5rem);
153
+ height: var(--handle-size, 2.5rem);
172
154
  }
173
- .arrow-left {
174
- left: 7px;
175
- top: 10px;
176
- border-right: 10px solid white;
155
+
156
+ input[type="range"]::-webkit-slider-thumb {
157
+ -webkit-appearance: none;
158
+ display: flex;
159
+ justify-content: center;
160
+ align-items: center;
161
+ background-color: var(--handle-background-color, rgba(0, 0, 0, 0.6));
162
+ background-image: var(
163
+ --handle-background-image,
164
+ url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M3 12H21M3 12L7 8M3 12L7 16M21 12L17 16M21 12L17 8" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>')
165
+ );
166
+ background-size: 80%;
167
+ background-position: center center;
168
+ background-repeat: no-repeat;
169
+ border: var(--handle-border-width, 0.125rem) solid
170
+ var(--slider-color, #ffffff);
171
+ border-radius: 100%;
172
+ box-shadow:
173
+ 0 3px 1px -2px rgba(0, 0, 0, 0.2),
174
+ 0 2px 2px 0 rgba(0, 0, 0, 0.14),
175
+ 0 1px 5px 0 rgba(0, 0, 0, 0.12);
176
+ color: var(--slider-color, #ffffff);
177
+ width: var(--handle-size, 2.5rem);
178
+ height: var(--handle-size, 2.5rem);
177
179
  }
178
180
  </style>
@@ -1,48 +1,10 @@
1
+ import { type Snippet } from "svelte";
2
+ declare const ImageCompare: import("svelte").Component<Partial<{
3
+ imageLeftSrc: string;
4
+ imageLeftAlt: string;
5
+ imageRightSrc: string;
6
+ imageRightAlt: string;
7
+ slidertLabel: Snippet;
8
+ }>, {}, "">;
9
+ type ImageCompare = ReturnType<typeof ImageCompare>;
1
10
  export default ImageCompare;
2
- type ImageCompare = SvelteComponent<{
3
- overlay?: boolean | undefined;
4
- before?: string | undefined;
5
- after?: string | undefined;
6
- offset?: number | undefined;
7
- contain?: boolean | undefined;
8
- lazyLoad?: boolean | undefined;
9
- hideOnSlide?: boolean | undefined;
10
- }, {
11
- mousedown: MouseEvent;
12
- } & {
13
- [evt: string]: CustomEvent<any>;
14
- }, {
15
- before: {};
16
- after: {};
17
- }> & {
18
- $$bindings?: string | undefined;
19
- };
20
- declare const ImageCompare: $$__sveltets_2_IsomorphicComponent<{
21
- overlay?: boolean | undefined;
22
- before?: string | undefined;
23
- after?: string | undefined;
24
- offset?: number | undefined;
25
- contain?: boolean | undefined;
26
- lazyLoad?: boolean | undefined;
27
- hideOnSlide?: boolean | undefined;
28
- }, {
29
- mousedown: MouseEvent;
30
- } & {
31
- [evt: string]: CustomEvent<any>;
32
- }, {
33
- before: {};
34
- after: {};
35
- }, {}, string>;
36
- interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
37
- new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
38
- $$bindings?: Bindings;
39
- } & Exports;
40
- (internal: unknown, props: Props & {
41
- $$events?: Events;
42
- $$slots?: Slots;
43
- }): Exports & {
44
- $set?: any;
45
- $on?: any;
46
- };
47
- z_$$bindings?: Bindings;
48
- }
@@ -4,7 +4,7 @@ export { default as errorHandler } from './auth/errorHandle.js';
4
4
  export { redisSessionProvider } from './auth/redisSessionProvider.js';
5
5
  export { machineAuthenticationProvider } from './auth/machineAuthenticationProvider.js';
6
6
  export { userAuthenticationProvider } from './auth/userAuthenticationProvider.js';
7
- export { getBlobService, getCommunicationService, getDataService, getTemplateService, getWebsiteService, getAIService } from './server-side/getServices.js';
7
+ export { getBlobService, getCommunicationService, getDataService, getTemplateService, getWebsiteService, getAIService, getAuthService, } from './server-side/getServices.js';
8
8
  export type { RedirectResponse } from './auth/RedirectResponse.js';
9
9
  export { createMachineTokenApprovedLocals } from './auth/getMachineAccessToken.js';
10
- export { isHuman } from './components/form/AntiBot.js';
10
+ export { isHuman } from './components/form/AntiBot.ts';
@@ -4,6 +4,6 @@ export { default as errorHandler } from './auth/errorHandle.js';
4
4
  export { redisSessionProvider } from './auth/redisSessionProvider.js';
5
5
  export { machineAuthenticationProvider } from './auth/machineAuthenticationProvider.js';
6
6
  export { userAuthenticationProvider } from './auth/userAuthenticationProvider.js';
7
- export { getBlobService, getCommunicationService, getDataService, getTemplateService, getWebsiteService, getAIService } from './server-side/getServices.js';
7
+ export { getBlobService, getCommunicationService, getDataService, getTemplateService, getWebsiteService, getAIService, getAuthService, } from './server-side/getServices.js';
8
8
  export { createMachineTokenApprovedLocals } from './auth/getMachineAccessToken.js';
9
- export { isHuman } from './components/form/AntiBot.js';
9
+ export { isHuman } from './components/form/AntiBot.ts';
package/dist/index.d.ts CHANGED
@@ -6,13 +6,13 @@ export { default as Well } from './components/layouts/Well.svelte';
6
6
  export { default as Banner } from './components/layouts/Banner.svelte';
7
7
  export { default as SimpleFooter } from './components/layouts/SimpleFooter.svelte';
8
8
  export { default as Tabs } from './components/layouts/Tabs.svelte';
9
- export type { Tab, TabSizes, NavigationDirection } from './components/layouts/tabs.js';
10
- export { Justify, AlignItmes, Placement, Orientation, Position, Sizes, ComponentSize } from './components/Styling.js';
9
+ export type { Tab, TabSizes, NavigationDirection } from './components/layouts/tabs.ts';
10
+ export { Justify, AlignItmes, Placement, Orientation, Position, Sizes, ComponentSize } from './components/Styling.ts';
11
11
  export { default as Link } from './components/presentation/Link.svelte';
12
12
  export { default as Logo } from './components/presentation/Logo.svelte';
13
13
  export { default as Card } from './components/presentation/Card.svelte';
14
14
  export { default as Gallery } from './components/presentation/Gallery.svelte';
15
- export type { CarouselItem } from './components/presentation/Carousel.js';
15
+ export type { CarouselItem } from './components/presentation/Carousel.ts';
16
16
  export { default as Carousel } from './components/presentation/Carousel.svelte';
17
17
  export { default as Drawer } from './components/presentation/Drawer.svelte';
18
18
  export { default as Disclose } from './components/presentation/Disclose.svelte';
@@ -22,8 +22,8 @@ export { default as ListMenu } from './components/menu/ListMenu.svelte';
22
22
  export { default as DynamicMenu } from './components/menu/DynamicMenu.svelte';
23
23
  export { default as HamburgerMenu } from './components/menu/HamburgerMenu.svelte';
24
24
  export { default as CollapsibleMenu } from './components/menu/CollapsibleMenu.svelte';
25
- export { isAuthenticated, selectVisible } from './components/menu/types.js';
26
- export { HeaderNavigationItem, Visiblity } from './components/menu/types.js';
25
+ export { isAuthenticated, selectVisible } from './components/menu/types.ts';
26
+ export { HeaderNavigationItem, Visiblity } from './components/menu/types.ts';
27
27
  export { default as Button } from './components/form/Button.svelte';
28
28
  export { default as Input } from './components/form/Input.svelte';
29
29
  export { default as Switch } from './components/form/Switch.svelte';
@@ -31,5 +31,5 @@ export { default as ChoiceInput } from './components/form/ChoiceInput.svelte';
31
31
  export type { ChoiceInputOption } from './components/form/utils.ts';
32
32
  export { default as AntiBot } from './components/form/AntiBot.svelte';
33
33
  export { default as Markdown } from './components/content/Markdown.svelte';
34
- export { type BlogPost, listAllPosts, importPost } from './components/blog/blog.js';
34
+ export { type BlogPost, listAllPosts, importPost } from './components/blog/blog.ts';
35
35
  export { default as EasyTools } from './components/integrations/EasyTools.svelte';
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ export { default as Tabs } from './components/layouts/Tabs.svelte';
12
12
  /*
13
13
  * Styling
14
14
  */
15
- export { Justify, AlignItmes, Placement, Orientation, Position, Sizes, ComponentSize } from './components/Styling.js';
15
+ export { Justify, AlignItmes, Placement, Orientation, Position, Sizes, ComponentSize } from './components/Styling.ts';
16
16
  /*
17
17
  * Presentation
18
18
  */
@@ -32,8 +32,8 @@ export { default as ListMenu } from './components/menu/ListMenu.svelte';
32
32
  export { default as DynamicMenu } from './components/menu/DynamicMenu.svelte';
33
33
  export { default as HamburgerMenu } from './components/menu/HamburgerMenu.svelte';
34
34
  export { default as CollapsibleMenu } from './components/menu/CollapsibleMenu.svelte';
35
- export { isAuthenticated, selectVisible } from './components/menu/types.js';
36
- export { HeaderNavigationItem, Visiblity } from './components/menu/types.js';
35
+ export { isAuthenticated, selectVisible } from './components/menu/types.ts';
36
+ export { HeaderNavigationItem, Visiblity } from './components/menu/types.ts';
37
37
  /*
38
38
  * Form
39
39
  */
@@ -49,7 +49,7 @@ export { default as Markdown } from './components/content/Markdown.svelte';
49
49
  /*
50
50
  * Blog
51
51
  */
52
- export { listAllPosts, importPost } from './components/blog/blog.js';
52
+ export { listAllPosts, importPost } from './components/blog/blog.ts';
53
53
  /*
54
54
  * Integrations
55
55
  */
@@ -1,4 +1,4 @@
1
- import { CommunicationService, DataService, TemplateService, WebsitesService, BlobService, AiService } from "@functionalcms/services";
1
+ import { CommunicationService, DataService, TemplateService, WebsitesService, BlobService, AiService, AuthService } from "@functionalcms/services";
2
2
  import type { Locals } from "./types.js";
3
3
  export declare const getDataService: (locals: Locals) => DataService;
4
4
  export declare const getCommunicationService: (locals: Locals) => CommunicationService;
@@ -6,3 +6,4 @@ export declare const getWebsiteService: (locals: Locals) => WebsitesService;
6
6
  export declare const getTemplateService: (locals: Locals) => TemplateService;
7
7
  export declare const getBlobService: (locals: Locals) => BlobService;
8
8
  export declare const getAIService: (locals: Locals) => AiService;
9
+ export declare const getAuthService: (locals: Locals) => AuthService;
@@ -1,5 +1,5 @@
1
1
  import { DOMAIN, ENDPOINT } from "$env/static/private";
2
- import { CommunicationService, DataService, TemplateService, WebsitesService, BlobService, AiService } from "@functionalcms/services";
2
+ import { CommunicationService, DataService, TemplateService, WebsitesService, BlobService, AiService, AuthService, } from "@functionalcms/services";
3
3
  const getAccessToken = (locals) => {
4
4
  return locals.token.access_token;
5
5
  };
@@ -33,3 +33,8 @@ export const getAIService = (locals) => {
33
33
  const service = new AiService(accessToken, DOMAIN, ENDPOINT);
34
34
  return service;
35
35
  };
36
+ export const getAuthService = (locals) => {
37
+ const accessToken = getAccessToken(locals);
38
+ const service = new AuthService(accessToken, ENDPOINT);
39
+ return service;
40
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalcms/svelte-components",
3
- "version": "4.6.2",
3
+ "version": "4.7.1",
4
4
  "watch": {
5
5
  "build": {
6
6
  "patterns": [
@@ -45,7 +45,7 @@
45
45
  "devDependencies": {
46
46
  "@eslint/compat": "^1.2.3",
47
47
  "@eslint/js": "^9.17.0",
48
- "@functionalcms/services": "^0.9.3",
48
+ "@functionalcms/services": "^0.12.0",
49
49
  "@sveltejs/adapter-auto": "^3.0.0",
50
50
  "@sveltejs/package": "^2.0.0",
51
51
  "@sveltejs/vite-plugin-svelte": "^4.0.0",
@@ -55,7 +55,7 @@
55
55
  "eslint-plugin-svelte": "^2.36.0",
56
56
  "prettier": "^3.3.2",
57
57
  "prettier-plugin-svelte": "^3.2.6",
58
- "publint": "^0.2.0",
58
+ "publint": "^0.3.8",
59
59
  "sass": "^1.83.4",
60
60
  "svelte": "^5.0.0",
61
61
  "svelte-check": "^4.0.0",