@functionalcms/svelte-components 2.30.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.
@@ -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
+ }
@@ -1,6 +1,6 @@
1
1
  <style>
2
2
  :global(.sticky) {
3
- background-color: var( --agnostic-light-modelight);
3
+ background-color: var( --functional-light-modelight);
4
4
  }
5
5
  footer.sticky {
6
6
  flex-shrink: 0;
@@ -39,7 +39,7 @@ const klasses = ["flex", orientation, css ? css : ""].filter((c) => c).join(" ")
39
39
  border-right: var(--functional-menu-item-border-right);
40
40
  border-bottom: var(--functional-menu-item-border-bottom);
41
41
  border-left: var(--functional-menu-item-border-left);
42
- border-radius: var(--functional-menu-item-radius, var(--agnostic-radius));
42
+ border-radius: var(--functional-menu-item-radius, var(--functional-radius));
43
43
  text-decoration: none;
44
44
  display: block;
45
45
  }
@@ -52,7 +52,7 @@ const klasses = ["flex", orientation, css ? css : ""].filter((c) => c).join(" ")
52
52
  border-right: var(--functional-menu-item-hover-border-right);
53
53
  border-bottom: var(--functional-menu-item-hover-border-bottom);
54
54
  border-left: var(--functional-menu-item-hover-border-left);
55
- border-radius: var(--functional-menu-item-hover-radius, var(--agnostic-radius));
55
+ border-radius: var(--functional-menu-item-hover-radius, var(--functional-radius));
56
56
  }
57
57
  li[aria-current='true'] a {
58
58
  color: var(--functional-menu-item-selected-color);
@@ -63,6 +63,6 @@ const klasses = ["flex", orientation, css ? css : ""].filter((c) => c).join(" ")
63
63
  border-right: var(--functional-menu-item-selected-border-right);
64
64
  border-bottom: var(--functional-menu-item-selected-border-bottom);
65
65
  border-left: var(--functional-menu-item-selected-border-left);
66
- border-radius: var(--functional-menu-item-selected-radius, var(--agnostic-radius));
66
+ border-radius: var(--functional-menu-item-selected-radius, var(--functional-radius));
67
67
  }
68
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(--agnostic-radius));
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(--agnostic-radius));
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(--agnostic-radius));
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.30.0",
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/properties.scss ./css/functional.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",