@functionalcms/svelte-components 2.34.9 → 2.34.12

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.
@@ -1,47 +0,0 @@
1
- export function fileAccepted(file: any, accept: any): any[];
2
- export function fileMatchSize(file: any, minSize: any, maxSize: any): (boolean | {
3
- code: string;
4
- message: string;
5
- })[] | (boolean | null)[];
6
- export function allFilesAccepted({ files, accept, minSize, maxSize, multiple, }: {
7
- files: any;
8
- accept: any;
9
- minSize: any;
10
- maxSize: any;
11
- multiple: any;
12
- }): any;
13
- export function isPropagationStopped(event: any): any;
14
- export function isEvtWithFiles(event: any): boolean;
15
- export function isKindFile(item: any): boolean;
16
- export function isIeOrEdge(userAgent?: string): boolean;
17
- /**
18
- * This is intended to be used to compose event handlers
19
- * They are executed in order until one of them calls `event.isPropagationStopped()`.
20
- * Note that the check is done on the first invoke too,
21
- * meaning that if propagation was stopped before invoking the fns,
22
- * no handlers will be executed.
23
- *
24
- * @param {Function} fns the event hanlder functions
25
- * @return {Function} the event handler to add to an element
26
- */
27
- export function composeEventHandlers(...fns: Function): Function;
28
- export const FILE_INVALID_TYPE: "file-invalid-type";
29
- export const FILE_TOO_LARGE: "file-too-large";
30
- export const FILE_TOO_SMALL: "file-too-small";
31
- export const TOO_MANY_FILES: "too-many-files";
32
- export function getInvalidTypeRejectionErr(accept: any): {
33
- code: string;
34
- message: string;
35
- };
36
- export function getTooLargeRejectionErr(maxSize: any): {
37
- code: string;
38
- message: string;
39
- };
40
- export function getTooSmallRejectionErr(minSize: any): {
41
- code: string;
42
- message: string;
43
- };
44
- export namespace TOO_MANY_FILES_REJECTION {
45
- export { TOO_MANY_FILES as code };
46
- export let message: string;
47
- }
@@ -1,146 +0,0 @@
1
- import accepts from "./attr-accept.js";
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
- }