@functionalcms/svelte-components 2.29.0 → 2.33.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/css/functional.css +1 -2220
- package/css/functional.css.map +1 -1
- package/dist/auth/authorizationHandle.d.ts +1 -1
- package/dist/auth/authorizationHandle.js +6 -7
- package/dist/components/files/Dropzone.svelte +366 -0
- package/dist/components/files/Dropzone.svelte.d.ts +81 -0
- package/dist/components/files/attr-accept.d.ts +1 -0
- package/dist/components/files/attr-accept.js +22 -0
- package/dist/components/files/utils.d.ts +47 -0
- package/dist/components/files/utils.js +146 -0
- package/dist/components/layouts/DefaultLayout.svelte +1 -1
- package/dist/components/menu/CollapsibleMenu.svelte +10 -8
- package/dist/components/menu/CollapsibleMenu.svelte.d.ts +2 -2
- package/dist/components/menu/ColumnMenu.svelte +3 -6
- package/dist/components/menu/FlatMenu.svelte +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import accepts from "./attr-accept";
|
|
2
|
+
|
|
3
|
+
// Error codes
|
|
4
|
+
export const FILE_INVALID_TYPE = "file-invalid-type";
|
|
5
|
+
export const FILE_TOO_LARGE = "file-too-large";
|
|
6
|
+
export const FILE_TOO_SMALL = "file-too-small";
|
|
7
|
+
export const TOO_MANY_FILES = "too-many-files";
|
|
8
|
+
|
|
9
|
+
// File Errors
|
|
10
|
+
export const getInvalidTypeRejectionErr = (accept) => {
|
|
11
|
+
accept = Array.isArray(accept) && accept.length === 1 ? accept[0] : accept;
|
|
12
|
+
const messageSuffix = Array.isArray(accept)
|
|
13
|
+
? `one of ${accept.join(", ")}`
|
|
14
|
+
: accept;
|
|
15
|
+
return {
|
|
16
|
+
code: FILE_INVALID_TYPE,
|
|
17
|
+
message: `File type must be ${messageSuffix}`,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const getTooLargeRejectionErr = (maxSize) => {
|
|
22
|
+
return {
|
|
23
|
+
code: FILE_TOO_LARGE,
|
|
24
|
+
message: `File is larger than ${maxSize} bytes`,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const getTooSmallRejectionErr = (minSize) => {
|
|
29
|
+
return {
|
|
30
|
+
code: FILE_TOO_SMALL,
|
|
31
|
+
message: `File is smaller than ${minSize} bytes`,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const TOO_MANY_FILES_REJECTION = {
|
|
36
|
+
code: TOO_MANY_FILES,
|
|
37
|
+
message: "Too many files",
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Firefox versions prior to 53 return a bogus MIME type for every file drag, so dragovers with
|
|
41
|
+
// that MIME type will always be accepted
|
|
42
|
+
export function fileAccepted(file, accept) {
|
|
43
|
+
const isAcceptable =
|
|
44
|
+
file.type === "application/x-moz-file" || accepts(file, accept);
|
|
45
|
+
return [
|
|
46
|
+
isAcceptable,
|
|
47
|
+
isAcceptable ? null : getInvalidTypeRejectionErr(accept),
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function fileMatchSize(file, minSize, maxSize) {
|
|
52
|
+
if (isDefined(file.size)) {
|
|
53
|
+
if (isDefined(minSize) && isDefined(maxSize)) {
|
|
54
|
+
if (file.size > maxSize) return [false, getTooLargeRejectionErr(maxSize)];
|
|
55
|
+
if (file.size < minSize) return [false, getTooSmallRejectionErr(minSize)];
|
|
56
|
+
} else if (isDefined(minSize) && file.size < minSize)
|
|
57
|
+
return [false, getTooSmallRejectionErr(minSize)];
|
|
58
|
+
else if (isDefined(maxSize) && file.size > maxSize)
|
|
59
|
+
return [false, getTooLargeRejectionErr(maxSize)];
|
|
60
|
+
}
|
|
61
|
+
return [true, null];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function isDefined(value) {
|
|
65
|
+
return value !== undefined && value !== null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function allFilesAccepted({
|
|
69
|
+
files,
|
|
70
|
+
accept,
|
|
71
|
+
minSize,
|
|
72
|
+
maxSize,
|
|
73
|
+
multiple,
|
|
74
|
+
}) {
|
|
75
|
+
if (!multiple && files.length > 1) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return files.every((file) => {
|
|
80
|
+
const [accepted] = fileAccepted(file, accept);
|
|
81
|
+
const [sizeMatch] = fileMatchSize(file, minSize, maxSize);
|
|
82
|
+
return accepted && sizeMatch;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// React's synthetic events has event.isPropagationStopped,
|
|
87
|
+
// but to remain compatibility with other libs (Preact) fall back
|
|
88
|
+
// to check event.cancelBubble
|
|
89
|
+
export function isPropagationStopped(event) {
|
|
90
|
+
if (typeof event.isPropagationStopped === "function") {
|
|
91
|
+
return event.isPropagationStopped();
|
|
92
|
+
} else if (typeof event.cancelBubble !== "undefined") {
|
|
93
|
+
return event.cancelBubble;
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function isEvtWithFiles(event) {
|
|
99
|
+
if (!event.dataTransfer) {
|
|
100
|
+
return !!event.target && !!event.target.files;
|
|
101
|
+
}
|
|
102
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/types
|
|
103
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#file
|
|
104
|
+
return Array.prototype.some.call(
|
|
105
|
+
event.dataTransfer.types,
|
|
106
|
+
(type) => type === "Files" || type === "application/x-moz-file"
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function isKindFile(item) {
|
|
111
|
+
return typeof item === "object" && item !== null && item.kind === "file";
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function isIe(userAgent) {
|
|
115
|
+
return (
|
|
116
|
+
userAgent.indexOf("MSIE") !== -1 || userAgent.indexOf("Trident/") !== -1
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function isEdge(userAgent) {
|
|
121
|
+
return userAgent.indexOf("Edge/") !== -1;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function isIeOrEdge(userAgent = window.navigator.userAgent) {
|
|
125
|
+
return isIe(userAgent) || isEdge(userAgent);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* This is intended to be used to compose event handlers
|
|
130
|
+
* They are executed in order until one of them calls `event.isPropagationStopped()`.
|
|
131
|
+
* Note that the check is done on the first invoke too,
|
|
132
|
+
* meaning that if propagation was stopped before invoking the fns,
|
|
133
|
+
* no handlers will be executed.
|
|
134
|
+
*
|
|
135
|
+
* @param {Function} fns the event hanlder functions
|
|
136
|
+
* @return {Function} the event handler to add to an element
|
|
137
|
+
*/
|
|
138
|
+
export function composeEventHandlers(...fns) {
|
|
139
|
+
return (event, ...args) =>
|
|
140
|
+
fns.some((fn) => {
|
|
141
|
+
if (!isPropagationStopped(event) && fn) {
|
|
142
|
+
fn(event, ...args);
|
|
143
|
+
}
|
|
144
|
+
return isPropagationStopped(event);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
@@ -9,20 +9,22 @@ export let orientation = Orientation.Column;
|
|
|
9
9
|
export let localPages = [];
|
|
10
10
|
$: showContent = false;
|
|
11
11
|
$: showContentBeforeButton = contentPosition == Placement.Start;
|
|
12
|
-
const contentKlasses = [contentCss].filter((c) => c).join(" ");
|
|
13
12
|
</script>
|
|
14
13
|
|
|
15
14
|
{#if showContent && showContentBeforeButton}
|
|
16
|
-
<ColumnMenu {localPages} {orientation} css={
|
|
15
|
+
<ColumnMenu {localPages} {orientation} css={contentCss} />
|
|
17
16
|
{/if}
|
|
18
|
-
|
|
19
|
-
<Button css={buttonCss} on:click={() => (showContent = !showContent)}>
|
|
20
|
-
|
|
21
|
-
</Button>
|
|
22
|
-
|
|
17
|
+
<div>
|
|
18
|
+
<Button css={buttonCss} on:click={() => (showContent = !showContent)}>
|
|
19
|
+
<slot name="handle">☰</slot>
|
|
20
|
+
</Button>
|
|
21
|
+
</div>
|
|
23
22
|
{#if showContent && !showContentBeforeButton}
|
|
24
|
-
<ColumnMenu {localPages} {orientation} css={
|
|
23
|
+
<ColumnMenu {localPages} {orientation} css={contentCss} />
|
|
25
24
|
{/if}
|
|
26
25
|
|
|
27
26
|
<style>
|
|
27
|
+
div {
|
|
28
|
+
margin: var(--fluid-8);
|
|
29
|
+
}
|
|
28
30
|
</style>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import { Orientation, Placement } from
|
|
3
|
-
import { HeaderNavigationItem } from
|
|
2
|
+
import { Orientation, Placement } from '../Styling.js';
|
|
3
|
+
import { HeaderNavigationItem } from './Menu.js';
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
|
6
6
|
buttonCss?: string;
|
|
@@ -18,9 +18,6 @@ const klasses = ["flex", orientation, css ? css : ""].filter((c) => c).join(" ")
|
|
|
18
18
|
<Link href={pageItem.path} css={linkCss}>
|
|
19
19
|
{pageItem.name}
|
|
20
20
|
</Link>
|
|
21
|
-
<!-- <a on:click={pageItem.action} href={pageItem.path}>
|
|
22
|
-
{pageItem.name}
|
|
23
|
-
</a> -->
|
|
24
21
|
</li>
|
|
25
22
|
{/each}
|
|
26
23
|
</ul>
|
|
@@ -42,7 +39,7 @@ const klasses = ["flex", orientation, css ? css : ""].filter((c) => c).join(" ")
|
|
|
42
39
|
border-right: var(--functional-menu-item-border-right);
|
|
43
40
|
border-bottom: var(--functional-menu-item-border-bottom);
|
|
44
41
|
border-left: var(--functional-menu-item-border-left);
|
|
45
|
-
border-radius: var(--functional-menu-item-radius, var(--
|
|
42
|
+
border-radius: var(--functional-menu-item-radius, var(--functional-radius));
|
|
46
43
|
text-decoration: none;
|
|
47
44
|
display: block;
|
|
48
45
|
}
|
|
@@ -55,7 +52,7 @@ const klasses = ["flex", orientation, css ? css : ""].filter((c) => c).join(" ")
|
|
|
55
52
|
border-right: var(--functional-menu-item-hover-border-right);
|
|
56
53
|
border-bottom: var(--functional-menu-item-hover-border-bottom);
|
|
57
54
|
border-left: var(--functional-menu-item-hover-border-left);
|
|
58
|
-
border-radius: var(--functional-menu-item-hover-radius, var(--
|
|
55
|
+
border-radius: var(--functional-menu-item-hover-radius, var(--functional-radius));
|
|
59
56
|
}
|
|
60
57
|
li[aria-current='true'] a {
|
|
61
58
|
color: var(--functional-menu-item-selected-color);
|
|
@@ -66,6 +63,6 @@ const klasses = ["flex", orientation, css ? css : ""].filter((c) => c).join(" ")
|
|
|
66
63
|
border-right: var(--functional-menu-item-selected-border-right);
|
|
67
64
|
border-bottom: var(--functional-menu-item-selected-border-bottom);
|
|
68
65
|
border-left: var(--functional-menu-item-selected-border-left);
|
|
69
|
-
border-radius: var(--functional-menu-item-selected-radius, var(--
|
|
66
|
+
border-radius: var(--functional-menu-item-selected-radius, var(--functional-radius));
|
|
70
67
|
}
|
|
71
68
|
</style>
|
|
@@ -35,7 +35,7 @@ const klasses = ["flex", "flex-dynamic-row", css ? css : ""].filter((c) => c).jo
|
|
|
35
35
|
border-right: var(--functional-menu-item-border-right);
|
|
36
36
|
border-bottom: var(--functional-menu-item-border-bottom);
|
|
37
37
|
border-left: var(--functional-menu-item-border-left);
|
|
38
|
-
border-radius: var(--functional-menu-item-radius, var(--
|
|
38
|
+
border-radius: var(--functional-menu-item-radius, var(--functional-radius));
|
|
39
39
|
text-decoration: none;
|
|
40
40
|
display: block;
|
|
41
41
|
}
|
|
@@ -48,7 +48,7 @@ const klasses = ["flex", "flex-dynamic-row", css ? css : ""].filter((c) => c).jo
|
|
|
48
48
|
border-right: var(--functional-menu-item-hover-border-right);
|
|
49
49
|
border-bottom: var(--functional-menu-item-hover-border-bottom);
|
|
50
50
|
border-left: var(--functional-menu-item-hover-border-left);
|
|
51
|
-
border-radius: var(--functional-menu-item-hover-radius, var(--
|
|
51
|
+
border-radius: var(--functional-menu-item-hover-radius, var(--functional-radius));
|
|
52
52
|
}
|
|
53
53
|
li[aria-current='true'] a {
|
|
54
54
|
color: var(--functional-menu-item-selected-color);
|
|
@@ -59,7 +59,7 @@ const klasses = ["flex", "flex-dynamic-row", css ? css : ""].filter((c) => c).jo
|
|
|
59
59
|
border-right: var(--functional-menu-item-selected-border-right);
|
|
60
60
|
border-bottom: var(--functional-menu-item-selected-border-bottom);
|
|
61
61
|
border-left: var(--functional-menu-item-selected-border-left);
|
|
62
|
-
border-radius: var(--functional-menu-item-selected-radius, var(--
|
|
62
|
+
border-radius: var(--functional-menu-item-selected-radius, var(--functional-radius));
|
|
63
63
|
}
|
|
64
64
|
@media (min-width: 960px) {
|
|
65
65
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { default as Link } from './components/Link.svelte';
|
|
|
15
15
|
export { default as Gallery } from './components/presentation/Gallery.svelte';
|
|
16
16
|
export { default as Carusel } from './components/presentation/Carusel.svelte';
|
|
17
17
|
export { CaruseleItem } from './components/presentation/Carusele.js';
|
|
18
|
+
export { default as DropZone } from './components/files/Dropzone.svelte';
|
|
18
19
|
export { default as BlogDescription } from './components/blog/BlogDescription.svelte';
|
|
19
20
|
export { default as BlogTitle } from './components/blog/BlogTitle.svelte';
|
|
20
21
|
export type { BlogPost } from './components/blog/BlogPost.js';
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export { default as Link } from './components/Link.svelte';
|
|
|
15
15
|
export { default as Gallery } from './components/presentation/Gallery.svelte';
|
|
16
16
|
export { default as Carusel } from './components/presentation/Carusel.svelte';
|
|
17
17
|
export { CaruseleItem } from './components/presentation/Carusele.js';
|
|
18
|
+
export { default as DropZone } from './components/files/Dropzone.svelte';
|
|
18
19
|
export { default as BlogDescription } from './components/blog/BlogDescription.svelte';
|
|
19
20
|
export { default as BlogTitle } from './components/blog/BlogTitle.svelte';
|
|
20
21
|
export { importPost, listAllPosts } from './components/blog/blog.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@functionalcms/svelte-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.33.0",
|
|
4
4
|
"watch": {
|
|
5
5
|
"build": {
|
|
6
6
|
"patterns": [
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
14
|
"dev": "vite dev",
|
|
15
|
-
"build-css": "sass ./src/lib/css/
|
|
15
|
+
"build-css": "sass ./src/lib/css/functional.scss ./css/functional.css --style compressed",
|
|
16
16
|
"build": "vite build && npm run package",
|
|
17
17
|
"preview": "vite preview",
|
|
18
18
|
"package": "npm run build-css && svelte-kit sync && svelte-package && publint",
|