@webiny/app 6.3.0 → 6.4.0-beta.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.
- package/App.js +70 -77
- package/App.js.map +1 -1
- package/AppContainer.js +3 -6
- package/AppContainer.js.map +1 -1
- package/apollo-client/InMemoryCache.js +11 -13
- package/apollo-client/InMemoryCache.js.map +1 -1
- package/apollo-client/IntrospectionFragmentMatcher.js +26 -38
- package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -1
- package/components/Image.js +11 -17
- package/components/Image.js.map +1 -1
- package/components/index.js +0 -2
- package/config/RouterConfig/Route.js +23 -28
- package/config/RouterConfig/Route.js.map +1 -1
- package/config/RouterConfig.js +11 -10
- package/config/RouterConfig.js.map +1 -1
- package/config.js +19 -20
- package/config.js.map +1 -1
- package/contexts/Ui/index.js +26 -28
- package/contexts/Ui/index.js.map +1 -1
- package/core/Plugin.js +7 -9
- package/core/Plugin.js.map +1 -1
- package/core/Plugins.js +15 -34
- package/core/Plugins.js.map +1 -1
- package/core/Provider.js +5 -13
- package/core/Provider.js.map +1 -1
- package/core/createProvider.js +3 -6
- package/core/createProvider.js.map +1 -1
- package/core/createProviderPlugin.js +8 -13
- package/core/createProviderPlugin.js.map +1 -1
- package/errors/AuthenticationErrorEvent.js +8 -5
- package/errors/AuthenticationErrorEvent.js.map +1 -1
- package/errors/NetworkErrorEvent.js +8 -5
- package/errors/NetworkErrorEvent.js.map +1 -1
- package/errors/abstractions.js +3 -2
- package/errors/abstractions.js.map +1 -1
- package/errors/index.js +1 -4
- package/exports/admin/env-config.js +0 -2
- package/exports/admin/graphql-client.js +0 -2
- package/exports/admin/local-storage.js +0 -2
- package/exports/admin/router.js +0 -2
- package/exports/admin/security.js +0 -2
- package/exports/admin.js +0 -2
- package/features/envConfig/EnvConfig.js +12 -13
- package/features/envConfig/EnvConfig.js.map +1 -1
- package/features/envConfig/abstractions.js +2 -1
- package/features/envConfig/abstractions.js.map +1 -1
- package/features/envConfig/feature.js +9 -8
- package/features/envConfig/feature.js.map +1 -1
- package/features/envConfig/index.js +0 -2
- package/features/eventPublisher/EventPublisher.js +13 -21
- package/features/eventPublisher/EventPublisher.js.map +1 -1
- package/features/eventPublisher/abstractions.js +7 -9
- package/features/eventPublisher/abstractions.js.map +1 -1
- package/features/eventPublisher/feature.js +13 -12
- package/features/eventPublisher/feature.js.map +1 -1
- package/features/eventPublisher/index.js +1 -3
- package/features/graphqlClient/AuthenticationErrorPublishing.js +26 -26
- package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -1
- package/features/graphqlClient/BatchingGraphQLClient.js +104 -149
- package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -1
- package/features/graphqlClient/FetchGraphQLClient.js +41 -48
- package/features/graphqlClient/FetchGraphQLClient.js.map +1 -1
- package/features/graphqlClient/NetworkErrorPublishing.js +35 -42
- package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -1
- package/features/graphqlClient/RequestValue.js +42 -41
- package/features/graphqlClient/RequestValue.js.map +1 -1
- package/features/graphqlClient/RetryGraphQLClient.js +36 -45
- package/features/graphqlClient/RetryGraphQLClient.js.map +1 -1
- package/features/graphqlClient/__tests__/GraphQLClient.test.js +383 -356
- package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -1
- package/features/graphqlClient/abstractions.js +2 -1
- package/features/graphqlClient/abstractions.js.map +1 -1
- package/features/graphqlClient/feature.js +14 -20
- package/features/graphqlClient/feature.js.map +1 -1
- package/features/graphqlClient/index.js +0 -2
- package/features/graphqlClient/types.js +0 -3
- package/features/localStorage/BrowserLocalStorageGateway.js +56 -63
- package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -1
- package/features/localStorage/LocalStorage.js +27 -24
- package/features/localStorage/LocalStorage.js.map +1 -1
- package/features/localStorage/LocalStorageRepository.js +75 -88
- package/features/localStorage/LocalStorageRepository.js.map +1 -1
- package/features/localStorage/abstractions.js +5 -16
- package/features/localStorage/abstractions.js.map +1 -1
- package/features/localStorage/feature.js +17 -28
- package/features/localStorage/feature.js.map +1 -1
- package/features/localStorage/index.js +1 -3
- package/features/mainGraphQLClient/MainGraphQLClient.js +18 -14
- package/features/mainGraphQLClient/MainGraphQLClient.js.map +1 -1
- package/features/mainGraphQLClient/abstractions.js +2 -1
- package/features/mainGraphQLClient/abstractions.js.map +1 -1
- package/features/mainGraphQLClient/feature.js +11 -10
- package/features/mainGraphQLClient/feature.js.map +1 -1
- package/features/mainGraphQLClient/index.js +0 -2
- package/features/router/HistoryRouterGateway.js +75 -105
- package/features/router/HistoryRouterGateway.js.map +1 -1
- package/features/router/HistoryRouterGateway.test.js +184 -193
- package/features/router/HistoryRouterGateway.test.js.map +1 -1
- package/features/router/Route.js +38 -54
- package/features/router/Route.js.map +1 -1
- package/features/router/RouteUrl.js +84 -217
- package/features/router/RouteUrl.js.map +1 -1
- package/features/router/Router.js +67 -124
- package/features/router/Router.js.map +1 -1
- package/features/router/RouterPresenter.js +44 -49
- package/features/router/RouterPresenter.js.map +1 -1
- package/features/router/RouterRepository.js +103 -111
- package/features/router/RouterRepository.js.map +1 -1
- package/features/router/RouterRepository.test.js +119 -150
- package/features/router/RouterRepository.test.js.map +1 -1
- package/features/router/abstractions.js +4 -14
- package/features/router/abstractions.js.map +1 -1
- package/features/router/feature.js +13 -12
- package/features/router/feature.js.map +1 -1
- package/features/router/index.js +1 -3
- package/helpers/InterfaceGenerator/date.js +0 -3
- package/helpers/InterfaceGenerator/id.js +0 -3
- package/helpers/InterfaceGenerator/identity.js +0 -3
- package/helpers/InterfaceGenerator/index.js +0 -3
- package/helpers/InterfaceGenerator/numeric.js +0 -3
- package/helpers/InterfaceGenerator/truthful.js +0 -3
- package/hooks/useAutocomplete/index.js +0 -2
- package/hooks/useAutocomplete/useAutocomplete.js +12 -15
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
- package/hooks/useDataList/functions/getData.js +2 -1
- package/hooks/useDataList/functions/getData.js.map +1 -1
- package/hooks/useDataList/functions/getError.js +2 -1
- package/hooks/useDataList/functions/getError.js.map +1 -1
- package/hooks/useDataList/functions/getMeta.js +2 -1
- package/hooks/useDataList/functions/getMeta.js.map +1 -1
- package/hooks/useDataList/functions/index.js +0 -2
- package/hooks/useDataList/functions/searchDataByKey.js +9 -14
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
- package/hooks/useDataList/index.js +0 -2
- package/hooks/useDataList/useDataList.js +131 -152
- package/hooks/useDataList/useDataList.js.map +1 -1
- package/hooks/useDataList/utils/index.js +0 -2
- package/hooks/useDataList/utils/prepareLoadListParams.js +25 -34
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
- package/hooks/useHandler.js +12 -16
- package/hooks/useHandler.js.map +1 -1
- package/hooks/useHandlers.js +18 -20
- package/hooks/useHandlers.js.map +1 -1
- package/hooks/useRegisterLegacyPlugin.js +7 -6
- package/hooks/useRegisterLegacyPlugin.js.map +1 -1
- package/hooks/useUi.js +2 -3
- package/hooks/useUi.js.map +1 -1
- package/i18n/i18n.js +8 -4
- package/i18n/i18n.js.map +1 -1
- package/i18n/index.js +0 -2
- package/index.js +6 -11
- package/package.json +14 -16
- package/plugins/AddQuerySelectionPlugin.js +36 -61
- package/plugins/AddQuerySelectionPlugin.js.map +1 -1
- package/plugins/ApolloCacheObjectIdPlugin.js +12 -11
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
- package/plugins/ApolloDynamicLink.js +20 -22
- package/plugins/ApolloDynamicLink.js.map +1 -1
- package/plugins/ApolloLinkPlugin.js +16 -15
- package/plugins/ApolloLinkPlugin.js.map +1 -1
- package/plugins/ConsoleLinkPlugin.js +19 -21
- package/plugins/ConsoleLinkPlugin.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +39 -45
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +18 -22
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +21 -29
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +6 -15
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/Typography.js +9 -14
- package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js +19 -0
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +11 -18
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin.js +41 -58
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
- package/plugins/OmitTypenameLinkPlugin.js +9 -14
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
- package/plugins/TenantHeaderLinkPlugin.js +23 -32
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
- package/plugins/components/Image.js +8 -15
- package/plugins/components/Image.js.map +1 -1
- package/plugins/image.js +94 -133
- package/plugins/image.js.map +1 -1
- package/plugins/index.js +35 -59
- package/plugins/index.js.map +1 -1
- package/presentation/envConfig/useEnvConfig.js +4 -8
- package/presentation/envConfig/useEnvConfig.js.map +1 -1
- package/presentation/localStorage/index.js +0 -2
- package/presentation/localStorage/useLocalStorage.js +10 -16
- package/presentation/localStorage/useLocalStorage.js.map +1 -1
- package/presentation/localStorage/useLocalStorageValue.js +15 -13
- package/presentation/localStorage/useLocalStorageValue.js.map +1 -1
- package/presentation/localStorage/useLocalStorageValues.js +23 -30
- package/presentation/localStorage/useLocalStorageValues.js.map +1 -1
- package/presentation/router/RouteElementRegistry.js +22 -25
- package/presentation/router/RouteElementRegistry.js.map +1 -1
- package/presentation/router/abstractions.js +2 -1
- package/presentation/router/abstractions.js.map +1 -1
- package/presentation/router/components/Redirect.js +8 -10
- package/presentation/router/components/Redirect.js.map +1 -1
- package/presentation/router/components/RouteContent.js +14 -17
- package/presentation/router/components/RouteContent.js.map +1 -1
- package/presentation/router/components/RouteLink.js +11 -16
- package/presentation/router/components/RouteLink.js.map +1 -1
- package/presentation/router/components/SimpleLink.js +18 -24
- package/presentation/router/components/SimpleLink.js.map +1 -1
- package/presentation/router/hooks/useRoute.js +15 -23
- package/presentation/router/hooks/useRoute.js.map +1 -1
- package/presentation/router/hooks/useRouter.js +22 -23
- package/presentation/router/hooks/useRouter.js.map +1 -1
- package/presentation/router/index.js +0 -2
- package/presentation/router/types.js +0 -3
- package/renderApp.js +7 -6
- package/renderApp.js.map +1 -1
- package/router.js +0 -3
- package/rslib-runtime.js +14 -0
- package/rslib-runtime.js.map +1 -0
- package/shared/di/DiContainerProvider.js +8 -12
- package/shared/di/DiContainerProvider.js.map +1 -1
- package/shared/di/createFeature.js +7 -8
- package/shared/di/createFeature.js.map +1 -1
- package/shared/di/useFeature.js +7 -3
- package/shared/di/useFeature.js.map +1 -1
- package/static/svg/close_24px.33adaadc.svg +1 -0
- package/types.js +0 -3
- package/utils/createGenericContext.js +17 -21
- package/utils/createGenericContext.js.map +1 -1
- package/utils/createHashing.js +13 -16
- package/utils/createHashing.js.map +1 -1
- package/utils/index.js +0 -2
- package/utils/legacyPluginToReactComponent.js +11 -10
- package/utils/legacyPluginToReactComponent.js.map +1 -1
- package/components/index.js.map +0 -1
- package/errors/index.js.map +0 -1
- package/exports/admin/env-config.js.map +0 -1
- package/exports/admin/graphql-client.js.map +0 -1
- package/exports/admin/local-storage.js.map +0 -1
- package/exports/admin/router.js.map +0 -1
- package/exports/admin/security.js.map +0 -1
- package/exports/admin.js.map +0 -1
- package/features/envConfig/index.js.map +0 -1
- package/features/eventPublisher/index.js.map +0 -1
- package/features/graphqlClient/index.js.map +0 -1
- package/features/graphqlClient/types.js.map +0 -1
- package/features/localStorage/index.js.map +0 -1
- package/features/mainGraphQLClient/index.js.map +0 -1
- package/features/router/index.js.map +0 -1
- package/helpers/InterfaceGenerator/date.js.map +0 -1
- package/helpers/InterfaceGenerator/id.js.map +0 -1
- package/helpers/InterfaceGenerator/identity.js.map +0 -1
- package/helpers/InterfaceGenerator/index.js.map +0 -1
- package/helpers/InterfaceGenerator/numeric.js.map +0 -1
- package/helpers/InterfaceGenerator/truthful.js.map +0 -1
- package/hooks/useAutocomplete/index.js.map +0 -1
- package/hooks/useDataList/functions/index.js.map +0 -1
- package/hooks/useDataList/index.js.map +0 -1
- package/hooks/useDataList/utils/index.js.map +0 -1
- package/i18n/index.js.map +0 -1
- package/index.js.map +0 -1
- package/presentation/localStorage/index.js.map +0 -1
- package/presentation/router/index.js.map +0 -1
- package/presentation/router/types.js.map +0 -1
- package/react-butterfiles/Files.d.ts +0 -69
- package/react-butterfiles/Files.js +0 -227
- package/react-butterfiles/Files.js.map +0 -1
- package/react-butterfiles/file.todo +0 -1
- package/react-butterfiles/index.d.ts +0 -2
- package/react-butterfiles/index.js +0 -4
- package/react-butterfiles/index.js.map +0 -1
- package/react-butterfiles/utils/generateId.d.ts +0 -1
- package/react-butterfiles/utils/generateId.js +0 -5
- package/react-butterfiles/utils/generateId.js.map +0 -1
- package/react-butterfiles/utils/readFileContent.d.ts +0 -1
- package/react-butterfiles/utils/readFileContent.js +0 -15
- package/react-butterfiles/utils/readFileContent.js.map +0 -1
- package/router.js.map +0 -1
- package/types.js.map +0 -1
- package/utils/index.js.map +0 -1
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import bytes from "bytes";
|
|
3
|
-
import { minimatch } from "minimatch";
|
|
4
|
-
import { readFileContent } from "./utils/readFileContent.js";
|
|
5
|
-
import { generateId } from "./utils/generateId.js";
|
|
6
|
-
export class Files extends React.Component {
|
|
7
|
-
static defaultProps = {
|
|
8
|
-
accept: [],
|
|
9
|
-
multiple: false,
|
|
10
|
-
maxSize: "2mb",
|
|
11
|
-
multipleMaxSize: "10mb",
|
|
12
|
-
multipleMaxCount: null,
|
|
13
|
-
convertToBase64: false
|
|
14
|
-
};
|
|
15
|
-
input = null;
|
|
16
|
-
browseFilesPassedParams = null;
|
|
17
|
-
id = generateId();
|
|
18
|
-
validateFiles = files => {
|
|
19
|
-
const {
|
|
20
|
-
multiple,
|
|
21
|
-
multipleMaxSize,
|
|
22
|
-
multipleMaxCount,
|
|
23
|
-
accept,
|
|
24
|
-
maxSize
|
|
25
|
-
} = this.props;
|
|
26
|
-
const errors = [];
|
|
27
|
-
let multipleFileSize = 0;
|
|
28
|
-
if (!multiple && files.length > 1) {
|
|
29
|
-
errors.push({
|
|
30
|
-
id: generateId(),
|
|
31
|
-
type: "multipleNotAllowed"
|
|
32
|
-
});
|
|
33
|
-
return errors;
|
|
34
|
-
}
|
|
35
|
-
for (let index = 0; index < files.length; index++) {
|
|
36
|
-
const file = files[index];
|
|
37
|
-
if (Array.isArray(accept) && accept.length && !accept.some(type => minimatch(file.type, type))) {
|
|
38
|
-
errors.push({
|
|
39
|
-
id: generateId(),
|
|
40
|
-
index,
|
|
41
|
-
file,
|
|
42
|
-
type: "unsupportedFileType"
|
|
43
|
-
});
|
|
44
|
-
} else if (maxSize) {
|
|
45
|
-
const sizeAsBytes = bytes(maxSize);
|
|
46
|
-
if (sizeAsBytes && file.size > sizeAsBytes) {
|
|
47
|
-
errors.push({
|
|
48
|
-
id: generateId(),
|
|
49
|
-
index,
|
|
50
|
-
file,
|
|
51
|
-
type: "maxSizeExceeded"
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (multiple) {
|
|
56
|
-
multipleFileSize += file.size;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (multiple) {
|
|
60
|
-
const maxMultipleMaxSize = bytes(multipleMaxSize);
|
|
61
|
-
if (maxMultipleMaxSize && multipleMaxSize && multipleFileSize > maxMultipleMaxSize) {
|
|
62
|
-
errors.push({
|
|
63
|
-
id: generateId(),
|
|
64
|
-
type: "multipleMaxSizeExceeded",
|
|
65
|
-
multipleFileSize,
|
|
66
|
-
multipleMaxSize: maxMultipleMaxSize
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
if (multipleMaxCount && files.length > multipleMaxCount) {
|
|
70
|
-
errors.push({
|
|
71
|
-
id: generateId(),
|
|
72
|
-
type: "multipleMaxCountExceeded",
|
|
73
|
-
multipleCount: files.length,
|
|
74
|
-
multipleMaxCount
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return errors;
|
|
79
|
-
};
|
|
80
|
-
processSelectedFiles = async eventFiles => {
|
|
81
|
-
if (eventFiles.length === 0) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const {
|
|
85
|
-
convertToBase64,
|
|
86
|
-
onSuccess,
|
|
87
|
-
onError
|
|
88
|
-
} = this.props;
|
|
89
|
-
const {
|
|
90
|
-
browseFilesPassedParams
|
|
91
|
-
} = this;
|
|
92
|
-
const callbacks = {
|
|
93
|
-
onSuccess,
|
|
94
|
-
onError
|
|
95
|
-
};
|
|
96
|
-
if (browseFilesPassedParams && browseFilesPassedParams.onSuccess) {
|
|
97
|
-
callbacks.onSuccess = browseFilesPassedParams.onSuccess;
|
|
98
|
-
}
|
|
99
|
-
if (browseFilesPassedParams && browseFilesPassedParams.onError) {
|
|
100
|
-
callbacks.onError = browseFilesPassedParams.onError;
|
|
101
|
-
}
|
|
102
|
-
const files = [...eventFiles].map(file => {
|
|
103
|
-
return {
|
|
104
|
-
id: generateId(),
|
|
105
|
-
name: file.name,
|
|
106
|
-
type: file.type,
|
|
107
|
-
size: file.size,
|
|
108
|
-
src: {
|
|
109
|
-
file,
|
|
110
|
-
base64: null
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
});
|
|
114
|
-
const errors = this.validateFiles(files);
|
|
115
|
-
if (errors.length) {
|
|
116
|
-
callbacks.onError && callbacks.onError(errors, files);
|
|
117
|
-
} else {
|
|
118
|
-
if (convertToBase64) {
|
|
119
|
-
for (let i = 0; i < files.length; i++) {
|
|
120
|
-
const file = files[i].src.file;
|
|
121
|
-
files[i].src.base64 = await readFileContent(file);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
callbacks.onSuccess && callbacks.onSuccess(files);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Reset the browseFiles arguments.
|
|
128
|
-
if (this.input) {
|
|
129
|
-
this.input.value = "";
|
|
130
|
-
}
|
|
131
|
-
this.browseFilesPassedParams = null;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Extracted into a separate method just for testing purposes.
|
|
136
|
-
*/
|
|
137
|
-
onDropFilesHandler = async ({
|
|
138
|
-
e,
|
|
139
|
-
onSuccess,
|
|
140
|
-
onError
|
|
141
|
-
}) => {
|
|
142
|
-
this.browseFilesPassedParams = {
|
|
143
|
-
onSuccess,
|
|
144
|
-
onError
|
|
145
|
-
};
|
|
146
|
-
e.dataTransfer && e.dataTransfer.files && (await this.processSelectedFiles(e.dataTransfer.files));
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Extracted into a separate method just for testing purposes.
|
|
151
|
-
*/
|
|
152
|
-
browseFilesHandler = ({
|
|
153
|
-
onSuccess,
|
|
154
|
-
onError
|
|
155
|
-
}) => {
|
|
156
|
-
this.browseFilesPassedParams = {
|
|
157
|
-
onSuccess,
|
|
158
|
-
onError
|
|
159
|
-
};
|
|
160
|
-
this.input && this.input.click();
|
|
161
|
-
};
|
|
162
|
-
render() {
|
|
163
|
-
const {
|
|
164
|
-
multiple,
|
|
165
|
-
accept,
|
|
166
|
-
id
|
|
167
|
-
} = this.props;
|
|
168
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, this.props.children({
|
|
169
|
-
getLabelProps: props => {
|
|
170
|
-
return {
|
|
171
|
-
...props,
|
|
172
|
-
htmlFor: id || this.id
|
|
173
|
-
};
|
|
174
|
-
},
|
|
175
|
-
validateFiles: this.validateFiles,
|
|
176
|
-
browseFiles: ({
|
|
177
|
-
onSuccess,
|
|
178
|
-
onError
|
|
179
|
-
} = {}) => {
|
|
180
|
-
this.browseFilesHandler({
|
|
181
|
-
onSuccess,
|
|
182
|
-
onError
|
|
183
|
-
});
|
|
184
|
-
},
|
|
185
|
-
getDropZoneProps: ({
|
|
186
|
-
onSuccess,
|
|
187
|
-
onError,
|
|
188
|
-
onDragOver,
|
|
189
|
-
onDrop,
|
|
190
|
-
...rest
|
|
191
|
-
} = {}) => {
|
|
192
|
-
return {
|
|
193
|
-
...rest,
|
|
194
|
-
onDragOver: e => {
|
|
195
|
-
e.preventDefault();
|
|
196
|
-
typeof onDragOver === "function" && onDragOver();
|
|
197
|
-
},
|
|
198
|
-
onDrop: async e => {
|
|
199
|
-
e.preventDefault();
|
|
200
|
-
typeof onDrop === "function" && onDrop();
|
|
201
|
-
this.onDropFilesHandler({
|
|
202
|
-
e,
|
|
203
|
-
onSuccess,
|
|
204
|
-
onError
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
}), /*#__PURE__*/React.createElement("input", {
|
|
210
|
-
id: id || this.id,
|
|
211
|
-
ref: ref => {
|
|
212
|
-
if (ref) {
|
|
213
|
-
this.input = ref;
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
accept: accept.join(","),
|
|
217
|
-
style: {
|
|
218
|
-
display: "none"
|
|
219
|
-
},
|
|
220
|
-
type: "file",
|
|
221
|
-
multiple: multiple,
|
|
222
|
-
onChange: e => this.processSelectedFiles(e.target.files ?? [])
|
|
223
|
-
}));
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
//# sourceMappingURL=Files.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","bytes","minimatch","readFileContent","generateId","Files","Component","defaultProps","accept","multiple","maxSize","multipleMaxSize","multipleMaxCount","convertToBase64","input","browseFilesPassedParams","id","validateFiles","files","props","errors","multipleFileSize","length","push","type","index","file","Array","isArray","some","sizeAsBytes","size","maxMultipleMaxSize","multipleCount","processSelectedFiles","eventFiles","onSuccess","onError","callbacks","map","name","src","base64","i","value","onDropFilesHandler","e","dataTransfer","browseFilesHandler","click","render","createElement","Fragment","children","getLabelProps","htmlFor","browseFiles","getDropZoneProps","onDragOver","onDrop","rest","preventDefault","ref","join","style","display","onChange","target"],"sources":["Files.tsx"],"sourcesContent":["import React from \"react\";\nimport bytes from \"bytes\";\nimport { minimatch } from \"minimatch\";\nimport { readFileContent } from \"./utils/readFileContent.js\";\nimport { generateId } from \"./utils/generateId.js\";\n\nexport type SelectedFile = {\n id: string;\n name: string;\n type: string;\n size: number;\n src: {\n file: File;\n base64: string | null;\n };\n};\n\nexport type FileError = {\n id: string;\n type:\n | \"unsupportedFileType\"\n | \"maxSizeExceeded\"\n | \"multipleMaxSizeExceeded\"\n | \"multipleMaxCountExceeded\"\n | \"multipleNotAllowed\";\n index?: number;\n file?: SelectedFile | File;\n multipleFileSize?: number;\n multipleMaxSize?: number;\n multipleMaxCount?: number;\n multipleCount?: number;\n};\n\nexport type BrowseFilesParams = {\n onSuccess?: (files: SelectedFile[]) => void;\n onError?: (errors: FileError[], files: SelectedFile[]) => void;\n};\n\nexport type RenderPropParams = {\n browseFiles: (params: BrowseFilesParams) => void;\n getDropZoneProps: (additionalProps: any) => any;\n getLabelProps: (additionalProps: any) => any;\n validateFiles: (files: SelectedFile[] | File[]) => FileError[];\n};\n\nexport type FilesRules = {\n accept: string[];\n multiple: boolean;\n maxSize: string;\n multipleMaxSize: string;\n multipleMaxCount: number | null;\n convertToBase64: boolean;\n onSuccess?: (files: SelectedFile[]) => void;\n onError?: (errors: FileError[], files: SelectedFile[]) => void;\n};\n\nexport type Props = FilesRules & {\n children: (params: RenderPropParams) => React.ReactNode;\n id?: string;\n};\n\nexport class Files extends React.Component<Props> {\n static defaultProps = {\n accept: [],\n multiple: false,\n maxSize: \"2mb\",\n multipleMaxSize: \"10mb\",\n multipleMaxCount: null,\n convertToBase64: false\n };\n\n input: HTMLInputElement | null = null;\n browseFilesPassedParams: BrowseFilesParams | null = null;\n id: string = generateId();\n\n validateFiles = (files: SelectedFile[] | File[]): FileError[] => {\n const { multiple, multipleMaxSize, multipleMaxCount, accept, maxSize } = this.props;\n\n const errors: FileError[] = [];\n let multipleFileSize = 0;\n\n if (!multiple && files.length > 1) {\n errors.push({\n id: generateId(),\n type: \"multipleNotAllowed\"\n });\n\n return errors;\n }\n\n for (let index = 0; index < files.length; index++) {\n const file = files[index];\n\n if (\n Array.isArray(accept) &&\n accept.length &&\n !accept.some(type => minimatch(file.type, type))\n ) {\n errors.push({\n id: generateId(),\n index,\n file,\n type: \"unsupportedFileType\"\n });\n } else if (maxSize) {\n const sizeAsBytes = bytes(maxSize);\n if (sizeAsBytes && file.size > sizeAsBytes) {\n errors.push({\n id: generateId(),\n index,\n file,\n type: \"maxSizeExceeded\"\n });\n }\n }\n\n if (multiple) {\n multipleFileSize += file.size;\n }\n }\n\n if (multiple) {\n const maxMultipleMaxSize = bytes(multipleMaxSize);\n\n if (maxMultipleMaxSize && multipleMaxSize && multipleFileSize > maxMultipleMaxSize) {\n errors.push({\n id: generateId(),\n type: \"multipleMaxSizeExceeded\",\n multipleFileSize,\n multipleMaxSize: maxMultipleMaxSize\n });\n }\n\n if (multipleMaxCount && files.length > multipleMaxCount) {\n errors.push({\n id: generateId(),\n type: \"multipleMaxCountExceeded\",\n multipleCount: files.length,\n multipleMaxCount\n });\n }\n }\n\n return errors;\n };\n\n processSelectedFiles = async (eventFiles: Array<File>) => {\n if (eventFiles.length === 0) {\n return;\n }\n\n const { convertToBase64, onSuccess, onError } = this.props;\n const { browseFilesPassedParams } = this;\n const callbacks = {\n onSuccess,\n onError\n };\n\n if (browseFilesPassedParams && browseFilesPassedParams.onSuccess) {\n callbacks.onSuccess = browseFilesPassedParams.onSuccess;\n }\n\n if (browseFilesPassedParams && browseFilesPassedParams.onError) {\n callbacks.onError = browseFilesPassedParams.onError;\n }\n\n const files: SelectedFile[] = [...eventFiles].map(file => {\n return {\n id: generateId(),\n name: file.name,\n type: file.type,\n size: file.size,\n src: {\n file,\n base64: null\n }\n };\n });\n\n const errors = this.validateFiles(files);\n\n if (errors.length) {\n callbacks.onError && callbacks.onError(errors, files);\n } else {\n if (convertToBase64) {\n for (let i = 0; i < files.length; i++) {\n const file = files[i].src.file;\n files[i].src.base64 = await readFileContent(file);\n }\n }\n\n callbacks.onSuccess && callbacks.onSuccess(files);\n }\n\n // Reset the browseFiles arguments.\n if (this.input) {\n this.input.value = \"\";\n }\n this.browseFilesPassedParams = null;\n };\n\n /**\n * Extracted into a separate method just for testing purposes.\n */\n onDropFilesHandler = async ({ e, onSuccess, onError }: any) => {\n this.browseFilesPassedParams = { onSuccess, onError };\n e.dataTransfer &&\n e.dataTransfer.files &&\n (await this.processSelectedFiles(e.dataTransfer.files));\n };\n\n /**\n * Extracted into a separate method just for testing purposes.\n */\n browseFilesHandler = ({ onSuccess, onError }: any) => {\n this.browseFilesPassedParams = { onSuccess, onError };\n this.input && this.input.click();\n };\n\n override render() {\n const { multiple, accept, id } = this.props;\n return (\n <React.Fragment>\n {this.props.children({\n getLabelProps: (props: any) => {\n return {\n ...props,\n htmlFor: id || this.id\n };\n },\n validateFiles: this.validateFiles,\n browseFiles: ({ onSuccess, onError }: BrowseFilesParams = {}) => {\n this.browseFilesHandler({ onSuccess, onError });\n },\n getDropZoneProps: ({\n onSuccess,\n onError,\n onDragOver,\n onDrop,\n ...rest\n }: any = {}) => {\n return {\n ...rest,\n onDragOver: (e: DragEvent) => {\n e.preventDefault();\n typeof onDragOver === \"function\" && onDragOver();\n },\n onDrop: async (e: DragEvent) => {\n e.preventDefault();\n typeof onDrop === \"function\" && onDrop();\n this.onDropFilesHandler({ e, onSuccess, onError });\n }\n };\n }\n })}\n\n <input\n id={id || this.id}\n ref={ref => {\n if (ref) {\n this.input = ref;\n }\n }}\n accept={accept.join(\",\")}\n style={{ display: \"none\" }}\n type=\"file\"\n multiple={multiple}\n onChange={e =>\n this.processSelectedFiles((e.target.files as any as Array<File>) ?? [])\n }\n />\n </React.Fragment>\n );\n }\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,QAAQ,WAAW;AACrC,SAASC,eAAe;AACxB,SAASC,UAAU;AAyDnB,OAAO,MAAMC,KAAK,SAASL,KAAK,CAACM,SAAS,CAAQ;EAC9C,OAAOC,YAAY,GAAG;IAClBC,MAAM,EAAE,EAAE;IACVC,QAAQ,EAAE,KAAK;IACfC,OAAO,EAAE,KAAK;IACdC,eAAe,EAAE,MAAM;IACvBC,gBAAgB,EAAE,IAAI;IACtBC,eAAe,EAAE;EACrB,CAAC;EAEDC,KAAK,GAA4B,IAAI;EACrCC,uBAAuB,GAA6B,IAAI;EACxDC,EAAE,GAAWZ,UAAU,CAAC,CAAC;EAEzBa,aAAa,GAAIC,KAA8B,IAAkB;IAC7D,MAAM;MAAET,QAAQ;MAAEE,eAAe;MAAEC,gBAAgB;MAAEJ,MAAM;MAAEE;IAAQ,CAAC,GAAG,IAAI,CAACS,KAAK;IAEnF,MAAMC,MAAmB,GAAG,EAAE;IAC9B,IAAIC,gBAAgB,GAAG,CAAC;IAExB,IAAI,CAACZ,QAAQ,IAAIS,KAAK,CAACI,MAAM,GAAG,CAAC,EAAE;MAC/BF,MAAM,CAACG,IAAI,CAAC;QACRP,EAAE,EAAEZ,UAAU,CAAC,CAAC;QAChBoB,IAAI,EAAE;MACV,CAAC,CAAC;MAEF,OAAOJ,MAAM;IACjB;IAEA,KAAK,IAAIK,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGP,KAAK,CAACI,MAAM,EAAEG,KAAK,EAAE,EAAE;MAC/C,MAAMC,IAAI,GAAGR,KAAK,CAACO,KAAK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QAAQ,EAAEA,QAAS;MACnByD,QAAQ,EAAEpB,CAAC,IACP,IAAI,CAACZ,oBAAoB,CAAEY,CAAC,CAACqB,MAAM,CAACjD,KAAK,IAA2B,EAAE;IACzE,CACJ,CACW,CAAC;EAEzB;AACJ","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
delete this folder?
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Files"],"sources":["index.ts"],"sourcesContent":["import { Files } from \"./Files.js\";\n\nexport default Files;\n"],"mappings":"AAAA,SAASA,KAAK;AAEd,eAAeA,KAAK","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const generateId: () => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["generateId","Math","random","toString","substr"],"sources":["generateId.ts"],"sourcesContent":["export const generateId = () => {\n return \"_\" + Math.random().toString(36).substr(2, 9);\n};\n"],"mappings":"AAAA,OAAO,MAAMA,UAAU,GAAGA,CAAA,KAAM;EAC5B,OAAO,GAAG,GAAGC,IAAI,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;AACxD,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const readFileContent: (file: File) => Promise<string>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export const readFileContent = async file => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
const reader = new window.FileReader();
|
|
4
|
-
reader.onload = function (e) {
|
|
5
|
-
if (e.target) {
|
|
6
|
-
resolve(e.target.result);
|
|
7
|
-
} else {
|
|
8
|
-
reject(`Unable to read file contents!`);
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
reader.readAsDataURL(file);
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=readFileContent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["readFileContent","file","Promise","resolve","reject","reader","window","FileReader","onload","e","target","result","readAsDataURL"],"sources":["readFileContent.ts"],"sourcesContent":["export const readFileContent = async (file: File) => {\n return new Promise<string>((resolve, reject) => {\n const reader = new window.FileReader();\n reader.onload = function (e) {\n if (e.target) {\n resolve(e.target.result as string);\n } else {\n reject(`Unable to read file contents!`);\n }\n };\n\n reader.readAsDataURL(file);\n });\n};\n"],"mappings":"AAAA,OAAO,MAAMA,eAAe,GAAG,MAAOC,IAAU,IAAK;EACjD,OAAO,IAAIC,OAAO,CAAS,CAACC,OAAO,EAAEC,MAAM,KAAK;IAC5C,MAAMC,MAAM,GAAG,IAAIC,MAAM,CAACC,UAAU,CAAC,CAAC;IACtCF,MAAM,CAACG,MAAM,GAAG,UAAUC,CAAC,EAAE;MACzB,IAAIA,CAAC,CAACC,MAAM,EAAE;QACVP,OAAO,CAACM,CAAC,CAACC,MAAM,CAACC,MAAgB,CAAC;MACtC,CAAC,MAAM;QACHP,MAAM,CAAC,+BAA+B,CAAC;MAC3C;IACJ,CAAC;IAEDC,MAAM,CAACO,aAAa,CAACX,IAAI,CAAC;EAC9B,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
package/router.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Route","useRouter","useRoute","RouteLink","SimpleLink"],"sources":["router.ts"],"sourcesContent":["// Router\nexport { Route } from \"./features/router/Route.js\";\nexport { useRouter } from \"./presentation/router/hooks/useRouter.js\";\nexport { useRoute } from \"./presentation/router/hooks/useRoute.js\";\nexport { RouteLink, type RouteLinkProps } from \"./presentation/router/components/RouteLink.js\";\nexport { SimpleLink, type SimpleLinkProps } from \"./presentation/router/components/SimpleLink.js\";\n"],"mappings":"AAAA;AACA,SAASA,KAAK;AACd,SAASC,SAAS;AAClB,SAASC,QAAQ;AACjB,SAASC,SAAS;AAClB,SAASC,UAAU","ignoreList":[]}
|
package/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type * as React from \"react\";\nimport type { CSSProperties } from \"react\";\nimport { Plugin } from \"@webiny/plugins/types.js\";\nimport type { ApolloClient } from \"apollo-client\";\n\nexport type GenericRecordKey = string | number | symbol;\n\nexport type GenericRecord<K extends GenericRecordKey = GenericRecordKey, V = any> = Record<K, V>;\n\nexport type NonEmptyArray<T> = [T, ...T[]];\n\nexport type UploadOptions = {\n apolloClient: ApolloClient<object>;\n onProgress?: (params: { sent: number; total: number; percentage: number }) => void;\n};\n\nexport type UiStatePlugin = Plugin & {\n type: \"ui-state\";\n render(): React.ReactElement;\n};\n\nexport interface UploadedFile {\n id: string;\n name: string;\n type: string;\n size: number;\n key: string;\n}\n\nexport type FileUploaderPlugin = Plugin & {\n type: \"file-uploader\";\n name: \"file-uploader\";\n upload(file: File, options: UploadOptions): Promise<UploadedFile>;\n};\n\nexport type { Plugin };\n\nexport interface ImageProps {\n src: string;\n preset?: string;\n transform?: {\n [key: string]: any;\n };\n // \"auto\" is a special keyword - if present, plugins insert their own srcSet.\n srcSet?: { [key: string]: any } | \"auto\";\n className?: string;\n title?: string;\n alt?: string;\n style?: CSSProperties;\n width?: string | number;\n height?: string | number;\n}\n\n/**\n * \"getImageSrc\" has to be defined as a separate property, so its functionality can be reused outside of\n * the Image component. This is ideal in cases where manual creation of image src is needed.\n */\nexport type ImageComponentPlugin = Plugin & {\n type: \"image-component\";\n render: (props: ImageProps) => React.ReactElement;\n getImageSrc: (props?: Record<string, any>) => string;\n presets: { [key: string]: any };\n};\n\n/**\n * Enables registering new routes.\n * @see https://docs.webiny.com/docs/webiny-apps/admin/development/plugins-reference/app#route\n */\nexport type RoutePlugin = Plugin & {\n type: \"route\";\n route: React.ReactElement<{ path: string }>;\n};\n"],"mappings":"","ignoreList":[]}
|
package/utils/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./createHashing.js\";\nexport * from \"./legacyPluginToReactComponent.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|