aefis-core-ui 2.2.3-rc6 → 2.3.0-rc10
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/dist/index.modern.js +355 -354
- package/dist/index.modern.js.map +1 -1
- package/package.json +3 -2
package/dist/index.modern.js
CHANGED
|
@@ -42,7 +42,7 @@ import { AnimatePresence, motion } from 'framer-motion';
|
|
|
42
42
|
import CircularProgress$1 from '@mui/material/CircularProgress';
|
|
43
43
|
import { useQuery, useInfiniteQuery, useQueryClient, useMutation, QueryClient, QueryClientProvider } from 'react-query';
|
|
44
44
|
import axios from 'axios';
|
|
45
|
-
import _ from 'lodash';
|
|
45
|
+
import _, { merge } from 'lodash';
|
|
46
46
|
import qs from 'query-string';
|
|
47
47
|
import SortIcon from '@mui/icons-material/Sort';
|
|
48
48
|
import { useSnackbar, SnackbarProvider } from 'notistack';
|
|
@@ -84,6 +84,7 @@ import FilePondPluginImageExifOrientation from 'filepond-plugin-image-exif-orien
|
|
|
84
84
|
import FilePondPluginImagePreview from 'filepond-plugin-image-preview';
|
|
85
85
|
import { registerPlugin, FilePond } from 'react-filepond';
|
|
86
86
|
import FilePondPluginGetFile from 'filepond-plugin-get-file';
|
|
87
|
+
import FilePondPluginFileValidateSize from 'filepond-plugin-file-validate-size';
|
|
87
88
|
import MaskedInput from 'react-text-mask';
|
|
88
89
|
import StylesProvider from '@mui/styles/StylesProvider';
|
|
89
90
|
|
|
@@ -1952,28 +1953,22 @@ const titleProps = {
|
|
|
1952
1953
|
color: "textPrimary",
|
|
1953
1954
|
variant: "h3",
|
|
1954
1955
|
style: {
|
|
1955
|
-
fontSize: "1.
|
|
1956
|
+
fontSize: "1.1rem",
|
|
1956
1957
|
fontWeight: 500,
|
|
1957
1958
|
lineHeight: 1.3,
|
|
1958
|
-
letterSpacing: 0.5
|
|
1959
|
-
whiteSpace: "nowrap",
|
|
1960
|
-
overflow: "hidden",
|
|
1961
|
-
textOverflow: "ellipsis"
|
|
1959
|
+
letterSpacing: 0.5
|
|
1962
1960
|
}
|
|
1963
1961
|
};
|
|
1964
1962
|
const subtitleProps = {
|
|
1965
1963
|
color: "textSecondary",
|
|
1966
1964
|
style: {
|
|
1967
|
-
fontSize: "0.
|
|
1968
|
-
fontWeight:
|
|
1965
|
+
fontSize: "0.775rem",
|
|
1966
|
+
fontWeight: "bolder",
|
|
1969
1967
|
lineHeight: 1.4,
|
|
1970
1968
|
letterSpacing: 0,
|
|
1971
1969
|
display: "inline-flex",
|
|
1972
1970
|
verticalAlign: "middle",
|
|
1973
|
-
alignItems: "center"
|
|
1974
|
-
whiteSpace: "nowrap",
|
|
1975
|
-
overflow: "hidden",
|
|
1976
|
-
textOverflow: "ellipsis"
|
|
1971
|
+
alignItems: "center"
|
|
1977
1972
|
}
|
|
1978
1973
|
};
|
|
1979
1974
|
const getGradientBackgroundColorArray = arrayIndex => {
|
|
@@ -2001,6 +1996,20 @@ const ContentBox = props => {
|
|
|
2001
1996
|
return props.children ? /*#__PURE__*/React.cloneElement(props.children) : "";
|
|
2002
1997
|
};
|
|
2003
1998
|
titleProps.component = props.titleComponent;
|
|
1999
|
+
if (props.wrapTitle) {
|
|
2000
|
+
titleProps["style"] = _extends({}, titleProps.style, {
|
|
2001
|
+
whiteSpace: "nowrap",
|
|
2002
|
+
overflow: "hidden",
|
|
2003
|
+
textOverflow: "ellipsis"
|
|
2004
|
+
});
|
|
2005
|
+
}
|
|
2006
|
+
if (props.wrapSubtitle) {
|
|
2007
|
+
titleProps["style"] = _extends({}, titleProps.style, {
|
|
2008
|
+
whiteSpace: "nowrap",
|
|
2009
|
+
overflow: "hidden",
|
|
2010
|
+
textOverflow: "ellipsis"
|
|
2011
|
+
});
|
|
2012
|
+
}
|
|
2004
2013
|
const headerProps = {
|
|
2005
2014
|
title: props.title,
|
|
2006
2015
|
disableTypography: false,
|
|
@@ -2030,7 +2039,7 @@ const ContentBox = props => {
|
|
|
2030
2039
|
headerProps.subheader = props.subtitle;
|
|
2031
2040
|
}
|
|
2032
2041
|
if (props.titleBadge) {
|
|
2033
|
-
headerProps.title = /*#__PURE__*/jsx(
|
|
2042
|
+
headerProps.title = /*#__PURE__*/jsx(Box$1, {
|
|
2034
2043
|
children: /*#__PURE__*/jsx(StyledBadge$1, {
|
|
2035
2044
|
badgeContent: props.titleBadge,
|
|
2036
2045
|
invisible: invisible,
|
|
@@ -2054,12 +2063,9 @@ const ContentBox = props => {
|
|
|
2054
2063
|
};
|
|
2055
2064
|
if (props.subtitle) {
|
|
2056
2065
|
headerProps.subheader = /*#__PURE__*/jsx(Typography, {
|
|
2057
|
-
variant: "
|
|
2066
|
+
variant: "subtitle1",
|
|
2058
2067
|
component: "span",
|
|
2059
2068
|
noWrap: true,
|
|
2060
|
-
sx: {
|
|
2061
|
-
color: "text.secondary"
|
|
2062
|
-
},
|
|
2063
2069
|
style: {
|
|
2064
2070
|
fontSize: "0.875rem",
|
|
2065
2071
|
letterSpacing: 0
|
|
@@ -2074,6 +2080,7 @@ const ContentBox = props => {
|
|
|
2074
2080
|
const cardStyle = _extends({
|
|
2075
2081
|
marginBottom: props.hasGutter ? 8 : 0,
|
|
2076
2082
|
borderRadius: 16,
|
|
2083
|
+
transition: "border 100ms ease-out",
|
|
2077
2084
|
boxShadow: props.displayType === "outlined" ? "none" : "rgb(58 53 65 / 10%) 0px 2px 10px 0px"
|
|
2078
2085
|
}, props.cardStyle);
|
|
2079
2086
|
if (props.displayType === "outlined") {
|
|
@@ -2091,7 +2098,7 @@ const ContentBox = props => {
|
|
|
2091
2098
|
return /*#__PURE__*/jsxs(Box$1, {
|
|
2092
2099
|
sx: props.sx,
|
|
2093
2100
|
style: props.containerStyle,
|
|
2094
|
-
children: [props.header && /*#__PURE__*/jsx(
|
|
2101
|
+
children: [props.header && /*#__PURE__*/jsx(Box$1, {
|
|
2095
2102
|
className: classes.sectionHeader,
|
|
2096
2103
|
children: /*#__PURE__*/jsx(Typography, {
|
|
2097
2104
|
variant: "h6",
|
|
@@ -2101,7 +2108,7 @@ const ContentBox = props => {
|
|
|
2101
2108
|
}), /*#__PURE__*/jsxs(Card, {
|
|
2102
2109
|
style: cardStyle,
|
|
2103
2110
|
className: tag.tag,
|
|
2104
|
-
children: [useHeaderImage && /*#__PURE__*/jsx(
|
|
2111
|
+
children: [useHeaderImage && /*#__PURE__*/jsx(Box$1, {
|
|
2105
2112
|
style: imageDivStyle,
|
|
2106
2113
|
className: classes.imageContainer,
|
|
2107
2114
|
title: props.title,
|
|
@@ -2147,7 +2154,9 @@ ContentBox.defaultProps = {
|
|
|
2147
2154
|
imageHeight: 150,
|
|
2148
2155
|
hasGutter: true,
|
|
2149
2156
|
imageBackgroundColor: "transparent",
|
|
2150
|
-
titleComponent: "div"
|
|
2157
|
+
titleComponent: "div",
|
|
2158
|
+
wrapTitle: false,
|
|
2159
|
+
wrapSubtitle: false
|
|
2151
2160
|
};
|
|
2152
2161
|
ContentBox.propTypes = {
|
|
2153
2162
|
/** Content of the content box */
|
|
@@ -2162,6 +2171,10 @@ ContentBox.propTypes = {
|
|
|
2162
2171
|
subtitle: PropTypes.any,
|
|
2163
2172
|
/** Main title of the content box. Can be a string or any component. */
|
|
2164
2173
|
title: PropTypes.any,
|
|
2174
|
+
/** Wrap the title? */
|
|
2175
|
+
wrapTitle: PropTypes.bool,
|
|
2176
|
+
/** Wrap the subtitle? */
|
|
2177
|
+
wrapSubtitle: PropTypes.bool,
|
|
2165
2178
|
/** Add a badge to the title of the content box. */
|
|
2166
2179
|
titleBadge: PropTypes.number,
|
|
2167
2180
|
/** The component to use to render the title. */
|
|
@@ -3296,12 +3309,12 @@ const outcomeConfiguration = {
|
|
|
3296
3309
|
// about solution: https://stackoverflow.com/questions/22820162/mustache-js-escaping
|
|
3297
3310
|
mustache.escape = _ => _;
|
|
3298
3311
|
function compile() {}
|
|
3299
|
-
function render$
|
|
3312
|
+
function render$1(template, data, defaultValue) {
|
|
3300
3313
|
return template ? mustache.render(template, data) : defaultValue;
|
|
3301
3314
|
}
|
|
3302
3315
|
var template = {
|
|
3303
3316
|
compile,
|
|
3304
|
-
render: render$
|
|
3317
|
+
render: render$1
|
|
3305
3318
|
};
|
|
3306
3319
|
|
|
3307
3320
|
// Copyright (c) 2020 AEFIS, all rights reserved.
|
|
@@ -4339,6 +4352,9 @@ const RenderCard = props => {
|
|
|
4339
4352
|
configuration: props.actionsConfiguration,
|
|
4340
4353
|
data: props.data
|
|
4341
4354
|
}) : undefined,
|
|
4355
|
+
cardStyle: props.cardStyle || undefined,
|
|
4356
|
+
containerStyle: props.containerStyle || undefined,
|
|
4357
|
+
sx: props.sx || undefined,
|
|
4342
4358
|
children: /*#__PURE__*/jsxs(Fragment, {
|
|
4343
4359
|
children: [props.description && /*#__PURE__*/jsx(CardSection, {
|
|
4344
4360
|
sx: descriptionContainerStyle,
|
|
@@ -4372,7 +4388,10 @@ RenderCard.propTypes = {
|
|
|
4372
4388
|
avatarIconColor: PropTypes.string,
|
|
4373
4389
|
gradientColorHeaderImageId: PropTypes.any,
|
|
4374
4390
|
autoTruncateDescription: PropTypes.bool,
|
|
4375
|
-
avatar: PropTypes.any
|
|
4391
|
+
avatar: PropTypes.any,
|
|
4392
|
+
cardStyle: PropTypes.any,
|
|
4393
|
+
containerStyle: PropTypes.any,
|
|
4394
|
+
sx: PropTypes.object
|
|
4376
4395
|
};
|
|
4377
4396
|
const BusinessObjectCard = props => {
|
|
4378
4397
|
return props.displayType === "skeleton" ? /*#__PURE__*/jsx(RenderSkeleton, {
|
|
@@ -4417,7 +4436,13 @@ BusinessObjectCard.propTypes = {
|
|
|
4417
4436
|
/** Override the avatar with provided avatar object. */
|
|
4418
4437
|
avatar: PropTypes.any,
|
|
4419
4438
|
/** Automatically truncate the description. For consistency, this should nearly always be set to "true" */
|
|
4420
|
-
autoTruncateDescription: PropTypes.bool
|
|
4439
|
+
autoTruncateDescription: PropTypes.bool,
|
|
4440
|
+
/** Additional styles for the card */
|
|
4441
|
+
cardStyle: PropTypes.any,
|
|
4442
|
+
/** Additional styles for the content box container */
|
|
4443
|
+
containerStyle: PropTypes.any,
|
|
4444
|
+
/** Additional styles to apply */
|
|
4445
|
+
sx: PropTypes.object
|
|
4421
4446
|
};
|
|
4422
4447
|
|
|
4423
4448
|
const _excluded$f = ["enableScrollTop", "containerProps"];
|
|
@@ -6882,12 +6907,9 @@ const sanitizedEval = (code, context, options) => {
|
|
|
6882
6907
|
}
|
|
6883
6908
|
};
|
|
6884
6909
|
|
|
6910
|
+
// TODO: move this to a state
|
|
6885
6911
|
let token = "";
|
|
6886
|
-
const apiClient = axios.create({
|
|
6887
|
-
validateStatus: false
|
|
6888
|
-
//baseURL: process.env.NODE_ENV === "development" ? "" : "/ui"
|
|
6889
|
-
});
|
|
6890
|
-
|
|
6912
|
+
const apiClient = axios.create({});
|
|
6891
6913
|
const parseQueryParam = url => {
|
|
6892
6914
|
const hashIndex = url.indexOf("#");
|
|
6893
6915
|
const noHashExists = hashIndex === -1;
|
|
@@ -6934,44 +6956,11 @@ apiClient.interceptors.request.use(config => {
|
|
|
6934
6956
|
for (const key in queryParams) {
|
|
6935
6957
|
queryParams[key] = objectParse(queryParams[key]);
|
|
6936
6958
|
}
|
|
6937
|
-
config.params =
|
|
6959
|
+
config.params = merge(queryParams, config.params);
|
|
6938
6960
|
config.url = urlOrigin;
|
|
6939
6961
|
}
|
|
6940
6962
|
return config;
|
|
6941
6963
|
});
|
|
6942
|
-
const getLoggerErrorMessage = error => {
|
|
6943
|
-
if (error.response) {
|
|
6944
|
-
var _error$response, _error$request, _error$response2, _error$response2$conf, _error$response2$conf2;
|
|
6945
|
-
const status = (_error$response = error.response) == null ? void 0 : _error$response.status;
|
|
6946
|
-
const URL = (_error$request = error.request) == null ? void 0 : _error$request.responseURL;
|
|
6947
|
-
const method = (_error$response2 = error.response) == null ? void 0 : (_error$response2$conf = _error$response2.config) == null ? void 0 : (_error$response2$conf2 = _error$response2$conf.method) == null ? void 0 : _error$response2$conf2.toUpperCase();
|
|
6948
|
-
const message = `RequestError: [${method}] ${status} ${URL}`;
|
|
6949
|
-
return message;
|
|
6950
|
-
} else if (error.request) {
|
|
6951
|
-
return "RequestError: No Response";
|
|
6952
|
-
} else {
|
|
6953
|
-
return `RequestError: ${error.message.toString()}`;
|
|
6954
|
-
}
|
|
6955
|
-
};
|
|
6956
|
-
|
|
6957
|
-
// Error is formatted to react query and reporting is handled by react-query
|
|
6958
|
-
// This prevent re-tried queries to trigger logger request
|
|
6959
|
-
const loggerForwardError = promise => (...args) => {
|
|
6960
|
-
return promise(...args).catch(error => {
|
|
6961
|
-
if (window.logger) {
|
|
6962
|
-
var _error$response3, _error$response3$conf, _window$logger;
|
|
6963
|
-
const message = getLoggerErrorMessage(error);
|
|
6964
|
-
const requestBody = ((_error$response3 = error.response) == null ? void 0 : (_error$response3$conf = _error$response3.config) == null ? void 0 : _error$response3$conf.data) || null;
|
|
6965
|
-
(_window$logger = window.logger) == null ? void 0 : _window$logger.logELKEvent == null ? void 0 : _window$logger.logELKEvent({
|
|
6966
|
-
name: message,
|
|
6967
|
-
data: requestBody
|
|
6968
|
-
});
|
|
6969
|
-
throw message;
|
|
6970
|
-
} else {
|
|
6971
|
-
throw error;
|
|
6972
|
-
}
|
|
6973
|
-
});
|
|
6974
|
-
};
|
|
6975
6964
|
function download(url) {
|
|
6976
6965
|
apiClient.request({
|
|
6977
6966
|
url: url,
|
|
@@ -6992,33 +6981,32 @@ function download(url) {
|
|
|
6992
6981
|
link.remove();
|
|
6993
6982
|
});
|
|
6994
6983
|
}
|
|
6995
|
-
function get() {
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
Authorization:
|
|
7000
|
-
}
|
|
7001
|
-
}
|
|
7002
|
-
return apiClient.get(...args);
|
|
6984
|
+
function get(endPoint, config = {}) {
|
|
6985
|
+
const isGateway = endPoint.includes("http://gateway") || endPoint.includes("https://gateway");
|
|
6986
|
+
return apiClient.get(endPoint, _extends({}, config, {
|
|
6987
|
+
headers: _extends({}, config.headers, isGateway && {
|
|
6988
|
+
Authorization: `Bearer ${token}`
|
|
6989
|
+
})
|
|
6990
|
+
}));
|
|
7003
6991
|
}
|
|
7004
|
-
function post() {
|
|
7005
|
-
return apiClient.post(...
|
|
6992
|
+
function post(...args) {
|
|
6993
|
+
return apiClient.post(...args);
|
|
7006
6994
|
}
|
|
7007
|
-
function put() {
|
|
7008
|
-
return apiClient.put(...
|
|
6995
|
+
function put(...args) {
|
|
6996
|
+
return apiClient.put(...args);
|
|
7009
6997
|
}
|
|
7010
|
-
function destroy() {
|
|
7011
|
-
return apiClient.
|
|
6998
|
+
function destroy(...args) {
|
|
6999
|
+
return apiClient.delete(...args);
|
|
7012
7000
|
}
|
|
7013
7001
|
async function setUserToken(t) {
|
|
7014
7002
|
token = t;
|
|
7015
7003
|
}
|
|
7016
7004
|
var http = {
|
|
7017
|
-
get
|
|
7018
|
-
post
|
|
7019
|
-
put
|
|
7020
|
-
download
|
|
7021
|
-
delete:
|
|
7005
|
+
get,
|
|
7006
|
+
post,
|
|
7007
|
+
put,
|
|
7008
|
+
download,
|
|
7009
|
+
delete: destroy,
|
|
7022
7010
|
setUserToken
|
|
7023
7011
|
};
|
|
7024
7012
|
|
|
@@ -7200,6 +7188,23 @@ let dataSourceConfiguration = {
|
|
|
7200
7188
|
}
|
|
7201
7189
|
};
|
|
7202
7190
|
|
|
7191
|
+
// TODO: move this function to logger
|
|
7192
|
+
const getLoggerErrorMessage = error => {
|
|
7193
|
+
if (!error.isAxiosError) return (error == null ? void 0 : error.toString()) || "Undefined error";
|
|
7194
|
+
if (error.response) {
|
|
7195
|
+
var _error$response, _error$request, _error$response2, _error$response2$conf, _error$response2$conf2;
|
|
7196
|
+
const status = (_error$response = error.response) == null ? void 0 : _error$response.status;
|
|
7197
|
+
const URL = (_error$request = error.request) == null ? void 0 : _error$request.responseURL;
|
|
7198
|
+
const method = (_error$response2 = error.response) == null ? void 0 : (_error$response2$conf = _error$response2.config) == null ? void 0 : (_error$response2$conf2 = _error$response2$conf.method) == null ? void 0 : _error$response2$conf2.toUpperCase();
|
|
7199
|
+
const message = `RequestError: [${method}] ${status} ${URL}`;
|
|
7200
|
+
return message;
|
|
7201
|
+
} else if (error.request) {
|
|
7202
|
+
return "RequestError: No Response";
|
|
7203
|
+
} else {
|
|
7204
|
+
return `RequestError: ${error.message.toString()}`;
|
|
7205
|
+
}
|
|
7206
|
+
};
|
|
7207
|
+
|
|
7203
7208
|
/**
|
|
7204
7209
|
* wraps function and reports (fire request) to Logger
|
|
7205
7210
|
* @param {function} onError
|
|
@@ -7208,11 +7213,29 @@ let dataSourceConfiguration = {
|
|
|
7208
7213
|
const logger = onError => (error, ...rest) => {
|
|
7209
7214
|
var _window$logger;
|
|
7210
7215
|
onError == null ? void 0 : onError(error, ...rest);
|
|
7211
|
-
|
|
7212
|
-
name: (error
|
|
7213
|
-
|
|
7214
|
-
|
|
7216
|
+
(_window$logger = window.logger) == null ? void 0 : _window$logger.sendLog({
|
|
7217
|
+
name: getLoggerErrorMessage(error),
|
|
7218
|
+
data: error
|
|
7219
|
+
});
|
|
7215
7220
|
};
|
|
7221
|
+
|
|
7222
|
+
/**
|
|
7223
|
+
* Promisify fetch, this is required for useQuery to handle error properly.
|
|
7224
|
+
* @param {Promise} fetch
|
|
7225
|
+
* @returns Promise
|
|
7226
|
+
*/
|
|
7227
|
+
const promisifyRequest = fetch => (...args) => new Promise(async (resolve, reject) => {
|
|
7228
|
+
try {
|
|
7229
|
+
const res = await fetch(...args);
|
|
7230
|
+
resolve(res);
|
|
7231
|
+
} catch (error) {
|
|
7232
|
+
var _window$logger2;
|
|
7233
|
+
reject(error);
|
|
7234
|
+
(_window$logger2 = window.logger) == null ? void 0 : _window$logger2.logEvent({
|
|
7235
|
+
name: getLoggerErrorMessage(error)
|
|
7236
|
+
});
|
|
7237
|
+
}
|
|
7238
|
+
});
|
|
7216
7239
|
const getGenericBusinessObjectAction = source => {
|
|
7217
7240
|
var typeAction = source.split("_");
|
|
7218
7241
|
return typeAction.length === 2 ? `businessObject_${typeAction[1]}` : source;
|
|
@@ -7368,7 +7391,7 @@ const useDataSourceQuery = (dataSource, parameters, options, templateContext) =>
|
|
|
7368
7391
|
return runQuery(dataSource, parameters, templateContext);
|
|
7369
7392
|
};
|
|
7370
7393
|
const fetchStrategy = configuration && typeof configuration.endPoint === "function" ? configuration.endPoint : fetch;
|
|
7371
|
-
return useQuery([dataSource, parameters], fetchStrategy, _extends({}, (configuration == null ? void 0 : configuration.options) || {}, options, {
|
|
7394
|
+
return useQuery([dataSource, parameters], promisifyRequest(fetchStrategy), _extends({}, (configuration == null ? void 0 : configuration.options) || {}, options, {
|
|
7372
7395
|
onError: logger(options == null ? void 0 : options.onError)
|
|
7373
7396
|
}));
|
|
7374
7397
|
};
|
|
@@ -7391,12 +7414,11 @@ const useDataSourceInfiniteQuery = (dataSource, parameters, initialParameters, o
|
|
|
7391
7414
|
const configuration = getConfiguration(dataSource);
|
|
7392
7415
|
const fetch = ({
|
|
7393
7416
|
pageParam: _pageParam = initialParameters
|
|
7394
|
-
}) => {
|
|
7395
|
-
return runQuery(dataSource, _extends({}, parameters, _pageParam));
|
|
7396
|
-
};
|
|
7417
|
+
}) => runQuery(dataSource, _extends({}, parameters, _pageParam));
|
|
7397
7418
|
const fetchStrategy = configuration && typeof configuration.endPoint === "function" ? configuration.endPoint : fetch;
|
|
7398
|
-
return useInfiniteQuery([dataSource, parameters], fetchStrategy, _extends({}, configuration ? configuration.options : {}, options, {
|
|
7399
|
-
onError: logger(options == null ? void 0 : options.onError)
|
|
7419
|
+
return useInfiniteQuery([dataSource, parameters], promisifyRequest(fetchStrategy), _extends({}, configuration ? configuration.options : {}, options, {
|
|
7420
|
+
onError: logger(options == null ? void 0 : options.onError),
|
|
7421
|
+
retry: false
|
|
7400
7422
|
}));
|
|
7401
7423
|
};
|
|
7402
7424
|
|
|
@@ -7415,7 +7437,6 @@ const useDataSourceMutation = (dataSource, baseParameters, options, invalidateQu
|
|
|
7415
7437
|
var _mutationOptions;
|
|
7416
7438
|
const queryClient = useQueryClient();
|
|
7417
7439
|
const configuration = getConfiguration(dataSource);
|
|
7418
|
-
getEndpoint(dataSource, configuration);
|
|
7419
7440
|
const invalidateFunction = () => {
|
|
7420
7441
|
if (invalidateQueries) {
|
|
7421
7442
|
for (let q of invalidateQueries) {
|
|
@@ -7442,11 +7463,11 @@ const useDataSourceMutation = (dataSource, baseParameters, options, invalidateQu
|
|
|
7442
7463
|
};
|
|
7443
7464
|
}
|
|
7444
7465
|
function requestCall(requestBody) {
|
|
7445
|
-
const request =
|
|
7466
|
+
const request = http[httpMethodType];
|
|
7446
7467
|
const endPoint = getEndpoint(dataSource, configuration); //?
|
|
7447
7468
|
if (httpMethodType === "get" || httpMethodType === "delete") {
|
|
7448
7469
|
// INFO (Caveat!): requestBody is used as query param in case of
|
|
7449
|
-
// httpMethodType is
|
|
7470
|
+
// httpMethodType is GET or DELETE
|
|
7450
7471
|
const params = _extends({}, baseParameters, requestBody);
|
|
7451
7472
|
return request(endPoint, {
|
|
7452
7473
|
params
|
|
@@ -7454,7 +7475,7 @@ const useDataSourceMutation = (dataSource, baseParameters, options, invalidateQu
|
|
|
7454
7475
|
}
|
|
7455
7476
|
return request(endPoint, requestBody);
|
|
7456
7477
|
}
|
|
7457
|
-
return useMutation(requestCall, _extends({}, mutationOptions, {
|
|
7478
|
+
return useMutation(promisifyRequest(requestCall), _extends({}, mutationOptions, {
|
|
7458
7479
|
onError: logger((_mutationOptions = mutationOptions) == null ? void 0 : _mutationOptions.onError)
|
|
7459
7480
|
}));
|
|
7460
7481
|
};
|
|
@@ -7663,69 +7684,6 @@ TextSearch.propTypes = {
|
|
|
7663
7684
|
bottomGutter: PropTypes.number
|
|
7664
7685
|
};
|
|
7665
7686
|
|
|
7666
|
-
const {
|
|
7667
|
-
render: render$1
|
|
7668
|
-
} = template;
|
|
7669
|
-
|
|
7670
|
-
/**
|
|
7671
|
-
* This function returns unique field inside filter item using render.
|
|
7672
|
-
*
|
|
7673
|
-
* @param {object} item
|
|
7674
|
-
* @param {object} filter
|
|
7675
|
-
* @returns {string}
|
|
7676
|
-
*/
|
|
7677
|
-
const getFilterItemId = (item, configItem = {}) => {
|
|
7678
|
-
var _item$data;
|
|
7679
|
-
if (item.id) {
|
|
7680
|
-
return item.id;
|
|
7681
|
-
}
|
|
7682
|
-
const template = configItem.idTemplate || configItem.template || configItem.optionTemplate;
|
|
7683
|
-
if (template) {
|
|
7684
|
-
return render$1(template, item.data || item);
|
|
7685
|
-
}
|
|
7686
|
-
if ((_item$data = item.data) != null && _item$data.id) {
|
|
7687
|
-
return item.data.id;
|
|
7688
|
-
}
|
|
7689
|
-
};
|
|
7690
|
-
|
|
7691
|
-
/**
|
|
7692
|
-
* This function checks filter items; if index and id fields are missing then
|
|
7693
|
-
* try to sets them with possible ways.
|
|
7694
|
-
*
|
|
7695
|
-
* @param {array} filters
|
|
7696
|
-
* @param {array} configuration
|
|
7697
|
-
* @returns {array}
|
|
7698
|
-
*/
|
|
7699
|
-
const formatFilters = (filters = [], configuration = []) => filters.map(filter => {
|
|
7700
|
-
var _ref, _filter$index, _filter$id, _configuration$index, _configuration$index2, _configuration$index3, _configuration$index4, _configuration$index5;
|
|
7701
|
-
// TODO: index should be defined on filters. There should not be need of
|
|
7702
|
-
// search of index value throught type or map values.
|
|
7703
|
-
const index = (_ref = (_filter$index = filter == null ? void 0 : filter.index) != null ? _filter$index : findIndexByType(filter, configuration)) != null ? _ref : findIndexByMap(filter, configuration);
|
|
7704
|
-
const id = (_filter$id = filter == null ? void 0 : filter.id) != null ? _filter$id : getFilterItemId(filter, configuration[index]);
|
|
7705
|
-
|
|
7706
|
-
// TODO: These properties should ONLY be defined either in configuration
|
|
7707
|
-
// or filters; currently data can be defined from both sources. Filter
|
|
7708
|
-
// data prioritised over configuratuon.
|
|
7709
|
-
const {
|
|
7710
|
-
map = (_configuration$index = configuration[index]) == null ? void 0 : _configuration$index.map,
|
|
7711
|
-
type = (_configuration$index2 = configuration[index]) == null ? void 0 : _configuration$index2.type,
|
|
7712
|
-
template = (_configuration$index3 = configuration[index]) == null ? void 0 : _configuration$index3.template,
|
|
7713
|
-
idTemplate = (_configuration$index4 = configuration[index]) == null ? void 0 : _configuration$index4.idTemplate,
|
|
7714
|
-
optionTemplate = (_configuration$index5 = configuration[index]) == null ? void 0 : _configuration$index5.optionTemplate
|
|
7715
|
-
} = filter;
|
|
7716
|
-
return _extends({}, filter, {
|
|
7717
|
-
template,
|
|
7718
|
-
idTemplate,
|
|
7719
|
-
optionTemplate,
|
|
7720
|
-
type,
|
|
7721
|
-
map,
|
|
7722
|
-
index,
|
|
7723
|
-
id
|
|
7724
|
-
});
|
|
7725
|
-
});
|
|
7726
|
-
const findIndexByType = (filter, configuration) => filter.type !== undefined ? configuration.findIndex(config => config.type === filter.type) : undefined;
|
|
7727
|
-
const findIndexByMap = (filter, configuration) => filter.map !== undefined ? configuration.findIndex(config => config.map === filter.map) : undefined;
|
|
7728
|
-
|
|
7729
7687
|
const mapFilters = newFilters => {
|
|
7730
7688
|
const mappedFilters = {};
|
|
7731
7689
|
newFilters.map(filter => {
|
|
@@ -8100,7 +8058,8 @@ const FilterChips = ({
|
|
|
8100
8058
|
const Filters = useMemo(() => {
|
|
8101
8059
|
return /*#__PURE__*/jsx(Box$1, {
|
|
8102
8060
|
sx: {
|
|
8103
|
-
display: "flex"
|
|
8061
|
+
display: "flex",
|
|
8062
|
+
flexFlow: "wrap"
|
|
8104
8063
|
},
|
|
8105
8064
|
children: _filters.map(filter => /*#__PURE__*/jsx(Grow, {
|
|
8106
8065
|
in: true,
|
|
@@ -8115,7 +8074,7 @@ const FilterChips = ({
|
|
|
8115
8074
|
displayOptions: {
|
|
8116
8075
|
hasIcon: filter.type !== "keyword"
|
|
8117
8076
|
},
|
|
8118
|
-
type: "businessObject",
|
|
8077
|
+
type: filter.type || "businessObject",
|
|
8119
8078
|
template: filter.template,
|
|
8120
8079
|
data: filter.data,
|
|
8121
8080
|
onDelete: () => {
|
|
@@ -8126,7 +8085,11 @@ const FilterChips = ({
|
|
|
8126
8085
|
}, `filterPanelFilter-${filter.index}-${filter.id}`))
|
|
8127
8086
|
});
|
|
8128
8087
|
}, [_filters]);
|
|
8129
|
-
const SortItems = useMemo(() => /*#__PURE__*/jsx(
|
|
8088
|
+
const SortItems = useMemo(() => /*#__PURE__*/jsx(Box$1, {
|
|
8089
|
+
sx: {
|
|
8090
|
+
display: "flex",
|
|
8091
|
+
flexFlow: "wrap"
|
|
8092
|
+
},
|
|
8130
8093
|
children: _sort.map(sortItem => /*#__PURE__*/jsx(Grow, {
|
|
8131
8094
|
in: true,
|
|
8132
8095
|
children: /*#__PURE__*/jsx("div", {
|
|
@@ -8364,6 +8327,36 @@ PanelDisplay.propTypes = {
|
|
|
8364
8327
|
renderFilterSelection: PropTypes.bool
|
|
8365
8328
|
};
|
|
8366
8329
|
|
|
8330
|
+
const usePrevState = (callback, current) => {
|
|
8331
|
+
const [prev, setPrev] = useState(current);
|
|
8332
|
+
if (prev !== current) {
|
|
8333
|
+
callback(prev, current);
|
|
8334
|
+
setPrev(current);
|
|
8335
|
+
}
|
|
8336
|
+
};
|
|
8337
|
+
|
|
8338
|
+
const useFilterState = filtersProp => {
|
|
8339
|
+
const [filters, _setFilters] = useState(filtersProp);
|
|
8340
|
+
const setFilters = useCallback((filters = []) => {
|
|
8341
|
+
const sorted = filters.sort((a, b) => a.index - b.index);
|
|
8342
|
+
_setFilters(sorted);
|
|
8343
|
+
}, []);
|
|
8344
|
+
usePrevState(() => {
|
|
8345
|
+
setFilters(filtersProp);
|
|
8346
|
+
}, filtersProp);
|
|
8347
|
+
return [filters, setFilters];
|
|
8348
|
+
};
|
|
8349
|
+
|
|
8350
|
+
const getItemId = (item, filter) => item.id || template.render(filter.idTemplate || filter.optionTemplate, item);
|
|
8351
|
+
const formatFilterItem = (index, filter, data) => ({
|
|
8352
|
+
index: index,
|
|
8353
|
+
id: getItemId(data, filter),
|
|
8354
|
+
type: filter.type,
|
|
8355
|
+
template: filter.optionTemplate,
|
|
8356
|
+
idTemplate: filter.idTemplate,
|
|
8357
|
+
map: filter.map,
|
|
8358
|
+
data
|
|
8359
|
+
});
|
|
8367
8360
|
const mapSort = value => value.map(i => i.map);
|
|
8368
8361
|
const getSearchFilter = newFilters => (newFilters == null ? void 0 : newFilters.filter(filter => (filter == null ? void 0 : filter.type) === "keyword").map(item => item.data.id)) || [];
|
|
8369
8362
|
|
|
@@ -8382,7 +8375,7 @@ const FilterPanel = props => {
|
|
|
8382
8375
|
searchTooltip,
|
|
8383
8376
|
searchPlaceHolderText,
|
|
8384
8377
|
configuration,
|
|
8385
|
-
filters: filtersProp,
|
|
8378
|
+
filters: filtersProp = [],
|
|
8386
8379
|
displayType,
|
|
8387
8380
|
limitTags,
|
|
8388
8381
|
bottomGutter,
|
|
@@ -8392,14 +8385,10 @@ const FilterPanel = props => {
|
|
|
8392
8385
|
sort: sortProp
|
|
8393
8386
|
} = props;
|
|
8394
8387
|
const [menuPosition, setMenuPosition] = useState(null);
|
|
8395
|
-
const [filters, setFilters] =
|
|
8388
|
+
const [filters, setFilters] = useFilterState(filtersProp);
|
|
8396
8389
|
const [sort, setSort] = useState(sortProp || []);
|
|
8397
8390
|
const [panelSearch, setPanelSearch] = useState([]);
|
|
8398
8391
|
const [pickerFilters, setPickerFilters] = useState([]);
|
|
8399
|
-
useEffect(() => {
|
|
8400
|
-
const formattedFilters = formatFilters(filtersProp, configuration);
|
|
8401
|
-
setFilters(formattedFilters);
|
|
8402
|
-
}, [filtersProp]);
|
|
8403
8392
|
|
|
8404
8393
|
// TODO: replace it with useMemo
|
|
8405
8394
|
useEffect(() => {
|
|
@@ -8425,9 +8414,8 @@ const FilterPanel = props => {
|
|
|
8425
8414
|
onDataChange(filteredData, filterParameters, filters);
|
|
8426
8415
|
}
|
|
8427
8416
|
}, [filters, sort]);
|
|
8428
|
-
const removeFilter = filter => {
|
|
8429
|
-
|
|
8430
|
-
const newFilterArray = filters == null ? void 0 : filters.filter(i => i.index !== filter.index || filter.id !== i.id);
|
|
8417
|
+
const removeFilter = (filter = []) => {
|
|
8418
|
+
const newFilterArray = filters.filter(i => i.index !== filter.index || filter.id !== i.id);
|
|
8431
8419
|
setFilters(newFilterArray);
|
|
8432
8420
|
if (!onApplyFilters) {
|
|
8433
8421
|
if ((filter == null ? void 0 : filter.type) === "keyword" && onSearchChange) {
|
|
@@ -8464,69 +8452,14 @@ const FilterPanel = props => {
|
|
|
8464
8452
|
onChange(mapFilters(newFilterArray), newFilterArray);
|
|
8465
8453
|
}
|
|
8466
8454
|
};
|
|
8467
|
-
/** Had to revert this function as filters were not working properly
|
|
8468
|
-
const handleSetFilterType = (inputIndex, configItem, data = []) => {
|
|
8469
|
-
const newFiltersByUpdatedIndex = data.map((filterItem) => {
|
|
8470
|
-
return {
|
|
8471
|
-
index: inputIndex,
|
|
8472
|
-
id: filterItem.id || getFilterItemId(configItem, filterItem),
|
|
8473
|
-
type: configItem.type,
|
|
8474
|
-
template: configItem.optionTemplate,
|
|
8475
|
-
idTemplate: configItem.idTemplate,
|
|
8476
|
-
map: configItem.map,
|
|
8477
|
-
data: filterItem
|
|
8478
|
-
};
|
|
8479
|
-
});
|
|
8480
|
-
const filtersByUnupdatedIndex = filters.filter((i) => i.index !== inputIndex);
|
|
8481
|
-
const newFilters = [...filtersByUnupdatedIndex, ...newFiltersByUpdatedIndex];
|
|
8482
|
-
setFilters(newFilters);
|
|
8483
|
-
if (onChange) {
|
|
8484
|
-
// TO-CHECK: what does mapFilters do?
|
|
8485
|
-
onChange(mapFilters(newFilters), newFilters);
|
|
8486
|
-
}
|
|
8487
|
-
}; */
|
|
8488
|
-
|
|
8489
8455
|
const handleSetFilterType = (index, filter, data) => {
|
|
8490
|
-
|
|
8491
|
-
if (!Array.isArray(data))
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
id: newItemId,
|
|
8498
|
-
type: filter.type,
|
|
8499
|
-
template: filter.optionTemplate,
|
|
8500
|
-
idTemplate: filter.idTemplate,
|
|
8501
|
-
map: filter.map,
|
|
8502
|
-
data: data
|
|
8503
|
-
});
|
|
8504
|
-
}
|
|
8505
|
-
setFilters(_newFilterArray);
|
|
8506
|
-
if (onChange && !onApplyFilters) {
|
|
8507
|
-
onChange(mapFilters(_newFilterArray), _newFilterArray);
|
|
8508
|
-
}
|
|
8509
|
-
return;
|
|
8510
|
-
}
|
|
8511
|
-
data.map(item => {
|
|
8512
|
-
const newItemId = getItemId(item);
|
|
8513
|
-
if (!filters.find(i => i.index === index && i.id === newItemId)) {
|
|
8514
|
-
filters.push({
|
|
8515
|
-
index: index,
|
|
8516
|
-
id: newItemId,
|
|
8517
|
-
type: filter.type,
|
|
8518
|
-
template: filter.optionTemplate,
|
|
8519
|
-
idTemplate: filter.idTemplate,
|
|
8520
|
-
map: filter.map,
|
|
8521
|
-
data: item
|
|
8522
|
-
});
|
|
8523
|
-
}
|
|
8524
|
-
});
|
|
8525
|
-
const newFilterArray = filters.filter(i => index !== i.index || index === i.index && data.find(d => i.data.id === d.id));
|
|
8526
|
-
setFilters(newFilterArray);
|
|
8527
|
-
if (onChange && !onApplyFilters) {
|
|
8528
|
-
onChange(mapFilters(newFilterArray), newFilterArray);
|
|
8529
|
-
}
|
|
8456
|
+
let _data = data;
|
|
8457
|
+
if (!Array.isArray(data)) _data = data ? [data] : [];
|
|
8458
|
+
const filtersWithoutUpdatedField = filters.filter(filter => index !== filter.index);
|
|
8459
|
+
const newUpdatedFilters = _data.map(d => formatFilterItem(index, filter, d));
|
|
8460
|
+
const newFilters = filtersWithoutUpdatedField.concat(newUpdatedFilters);
|
|
8461
|
+
setFilters(newFilters);
|
|
8462
|
+
if (!onApplyFilters) onChange == null ? void 0 : onChange(mapFilters(newFilters), newFilters);
|
|
8530
8463
|
};
|
|
8531
8464
|
const handleSortChange = value => {
|
|
8532
8465
|
setSort(value);
|
|
@@ -10753,7 +10686,7 @@ const RichDataTable = /*#__PURE__*/forwardRef(function RichDatatable(props, ref)
|
|
|
10753
10686
|
exportOptions: props.exportOptions,
|
|
10754
10687
|
actions: props.actions && props.actions.length > 0 || props.addAction ? updateActions(props.actions, handleDrawerOpen, enableTableRowAction, selectedRowCount, Add) : undefined,
|
|
10755
10688
|
onFilterClick: isFilterPanelEnabled ? handleFilterClick : undefined,
|
|
10756
|
-
hasFilters: filterPanelState.filterCount > 0 || filterPanelState.sortCount > 0 || filterPanelState.searchText,
|
|
10689
|
+
hasFilters: filterPanelState.filterCount > 0 || filterPanelState.sortCount > 0 || !!filterPanelState.searchText,
|
|
10757
10690
|
disableFilterButton: isFetching
|
|
10758
10691
|
}, props.titleAndActionHeaderProps)), /*#__PURE__*/jsx(DataTable, _extends({}, props, {
|
|
10759
10692
|
tableRef: DataTableRef,
|
|
@@ -16658,14 +16591,6 @@ const render = (value, formState) => {
|
|
|
16658
16591
|
}
|
|
16659
16592
|
return mustache.render(value, formState);
|
|
16660
16593
|
};
|
|
16661
|
-
const renderUrl = (value, formState) => {
|
|
16662
|
-
if (value === undefined || value === null) {
|
|
16663
|
-
return value;
|
|
16664
|
-
}
|
|
16665
|
-
return decodeHtml$2(mustache.render(value, formState));
|
|
16666
|
-
};
|
|
16667
|
-
const useRenderUrl = template => useSelectFormState(state => renderUrl(template, state));
|
|
16668
|
-
const useRender = template => useSelectFormState(state => render(template, state));
|
|
16669
16594
|
|
|
16670
16595
|
const useQueryTemplateParam = queryTemplate => {
|
|
16671
16596
|
const selector = useCallback(state => {
|
|
@@ -17161,49 +17086,6 @@ const DisableWrapper = ({
|
|
|
17161
17086
|
}));
|
|
17162
17087
|
};
|
|
17163
17088
|
|
|
17164
|
-
const ImageUploadReadOnly = ({
|
|
17165
|
-
formData,
|
|
17166
|
-
schema,
|
|
17167
|
-
uiSchema: _uiSchema = {
|
|
17168
|
-
"ui:options": {}
|
|
17169
|
-
}
|
|
17170
|
-
}) => {
|
|
17171
|
-
const {
|
|
17172
|
-
downloadUrl: downloadUrlTemplate,
|
|
17173
|
-
extension: extensionTemplate
|
|
17174
|
-
} = _uiSchema["ui:options"];
|
|
17175
|
-
const downloadUrl = useRenderUrl(downloadUrlTemplate);
|
|
17176
|
-
const extension = useRender(extensionTemplate);
|
|
17177
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
17178
|
-
children: [/*#__PURE__*/jsx(Typography, {
|
|
17179
|
-
gutterBottom: true,
|
|
17180
|
-
variant: "subtitle2",
|
|
17181
|
-
children: schema.title
|
|
17182
|
-
}), /*#__PURE__*/jsx(Paper, {
|
|
17183
|
-
sx: {
|
|
17184
|
-
height: 185,
|
|
17185
|
-
justifyContent: "center",
|
|
17186
|
-
display: "flex",
|
|
17187
|
-
padding: 2,
|
|
17188
|
-
overflow: "hidden"
|
|
17189
|
-
},
|
|
17190
|
-
variant: "outlined",
|
|
17191
|
-
children: /*#__PURE__*/jsx(Image, {
|
|
17192
|
-
src: downloadUrl,
|
|
17193
|
-
style: {
|
|
17194
|
-
height: "100%",
|
|
17195
|
-
width: "auto"
|
|
17196
|
-
},
|
|
17197
|
-
extension: extension
|
|
17198
|
-
})
|
|
17199
|
-
})]
|
|
17200
|
-
});
|
|
17201
|
-
};
|
|
17202
|
-
ImageUploadReadOnly.propTypes = {
|
|
17203
|
-
schema: PropTypes.any,
|
|
17204
|
-
renderedValues: PropTypes.any
|
|
17205
|
-
};
|
|
17206
|
-
|
|
17207
17089
|
const FieldContainer = props => {
|
|
17208
17090
|
return /*#__PURE__*/jsx(Box$2, _extends({}, props, {
|
|
17209
17091
|
sx: _extends({}, props.sx, {
|
|
@@ -17215,7 +17097,30 @@ const FieldContainer = props => {
|
|
|
17215
17097
|
};
|
|
17216
17098
|
FieldContainer.propTypes = Box$2.propTypes;
|
|
17217
17099
|
|
|
17218
|
-
registerPlugin(FilePondPluginFileValidateType, FilePondPluginImageExifOrientation, FilePondPluginImagePreview, FilePondPluginGetFile);
|
|
17100
|
+
registerPlugin(FilePondPluginFileValidateType, FilePondPluginFileValidateSize, FilePondPluginImageExifOrientation, FilePondPluginImagePreview, FilePondPluginGetFile);
|
|
17101
|
+
|
|
17102
|
+
// Check enums below
|
|
17103
|
+
// source:https://github.com/pqina/filepond-docs/blob/master/content/patterns/API/filepond-object.md#filepond-status
|
|
17104
|
+
const FILE_STATUS = {
|
|
17105
|
+
INIT: 1,
|
|
17106
|
+
IDLE: 2,
|
|
17107
|
+
PROCESSING_QUEUED: 9,
|
|
17108
|
+
PROCESSING: 3,
|
|
17109
|
+
PROCESSING_COMPLETE: 5,
|
|
17110
|
+
// upload complete
|
|
17111
|
+
PROCESSING_ERROR: 6,
|
|
17112
|
+
PROCESSING_REVERT_ERROR: 10,
|
|
17113
|
+
LOADING: 7,
|
|
17114
|
+
LOAD_ERROR: 8
|
|
17115
|
+
};
|
|
17116
|
+
const FILE_ORIGIN = {
|
|
17117
|
+
INPUT: 1,
|
|
17118
|
+
// add by user
|
|
17119
|
+
LIMBO: 2,
|
|
17120
|
+
// temp file
|
|
17121
|
+
LOCAL: 3 // pre-loaded files
|
|
17122
|
+
};
|
|
17123
|
+
|
|
17219
17124
|
const Upload = props => {
|
|
17220
17125
|
const {
|
|
17221
17126
|
schema,
|
|
@@ -17224,106 +17129,202 @@ const Upload = props => {
|
|
|
17224
17129
|
"ui:options": {}
|
|
17225
17130
|
},
|
|
17226
17131
|
onChange,
|
|
17227
|
-
disabled
|
|
17228
|
-
required
|
|
17132
|
+
disabled
|
|
17229
17133
|
} = props;
|
|
17134
|
+
const emptyValue = uiSchema["ui:emptyValue"] || null;
|
|
17230
17135
|
const isReadOnly = useReadOnly();
|
|
17231
17136
|
const {
|
|
17232
|
-
documentName: documentNameTemplate,
|
|
17233
|
-
downloadUrl: downloadUrlTemplate,
|
|
17234
|
-
extension: extensionTemplate,
|
|
17235
17137
|
uploadDataSource,
|
|
17236
|
-
mapUploadResponse,
|
|
17237
17138
|
acceptedFileTypes,
|
|
17238
17139
|
message,
|
|
17239
|
-
|
|
17240
|
-
|
|
17241
|
-
|
|
17242
|
-
const documentName = useRender(documentNameTemplate);
|
|
17243
|
-
const downloadUrl = useRenderUrl(downloadUrlTemplate);
|
|
17244
|
-
useRender(extensionTemplate);
|
|
17245
|
-
const [files, setFiles] = useState([]);
|
|
17246
|
-
const uploadUrl = useMemo(() => getDataSourceUrl(uploadDataSource), [uploadDataSource]);
|
|
17140
|
+
// TODO: can be handled generic way with HOC
|
|
17141
|
+
isImage = true,
|
|
17142
|
+
// multiple = true, // change to false
|
|
17247
17143
|
|
|
17248
|
-
|
|
17249
|
-
|
|
17144
|
+
isPreviewHidden = false,
|
|
17145
|
+
idTemplate,
|
|
17146
|
+
downloadUrlTemplate,
|
|
17147
|
+
nameTemplate,
|
|
17148
|
+
mapUploadResponseToIdTemplate,
|
|
17149
|
+
maxFiles = 1,
|
|
17150
|
+
maxFileSize = null,
|
|
17151
|
+
maxTotalFileSize = null
|
|
17152
|
+
} = uiSchema["ui:options"];
|
|
17250
17153
|
|
|
17251
|
-
// TODO:
|
|
17252
|
-
|
|
17253
|
-
|
|
17254
|
-
|
|
17255
|
-
|
|
17256
|
-
|
|
17257
|
-
|
|
17258
|
-
|
|
17259
|
-
|
|
17154
|
+
// TODO: implement single vs multipe mode, currently only multiple is active
|
|
17155
|
+
// let _formData = formData; if (multiple && (formData === null ||
|
|
17156
|
+
// formData === undefined)) { _formData = [];
|
|
17157
|
+
// }
|
|
17158
|
+
const _formData = formData || [];
|
|
17159
|
+
const initialFiles = useMemo(() => {
|
|
17160
|
+
return _formData.map(({
|
|
17161
|
+
data
|
|
17162
|
+
}) => {
|
|
17163
|
+
const id = mustache.render(idTemplate, data);
|
|
17164
|
+
const downloadUrl = downloadUrlTemplate ? decodeHtml$2(mustache.render(downloadUrlTemplate, data)) : downloadUrlTemplate;
|
|
17165
|
+
const name = mustache.render(nameTemplate, data);
|
|
17166
|
+
return {
|
|
17167
|
+
// INFO: source appears in preview but also needed to identify
|
|
17168
|
+
// the download URL. Check issue:
|
|
17169
|
+
// https://github.com/pqina/filepond/issues/284
|
|
17170
|
+
source: `${name} id:${id}`,
|
|
17171
|
+
options: {
|
|
17172
|
+
type: "local",
|
|
17173
|
+
origin: downloadUrl,
|
|
17174
|
+
// INFO: id is used in getFileIds function
|
|
17175
|
+
metadata: {
|
|
17176
|
+
url: downloadUrl,
|
|
17177
|
+
id
|
|
17178
|
+
}
|
|
17260
17179
|
}
|
|
17261
|
-
}
|
|
17262
|
-
}
|
|
17263
|
-
|
|
17264
|
-
|
|
17265
|
-
const
|
|
17266
|
-
|
|
17180
|
+
};
|
|
17181
|
+
});
|
|
17182
|
+
}, []);
|
|
17183
|
+
const inputProps = uiSchema == null ? void 0 : uiSchema["ui:props"];
|
|
17184
|
+
const filePondRef = useRef();
|
|
17185
|
+
const getFileIds = () => {
|
|
17186
|
+
var _filePondRef$current;
|
|
17187
|
+
return ((_filePondRef$current = filePondRef.current) == null ? void 0 : _filePondRef$current.getFiles().filter(file => {
|
|
17188
|
+
const {
|
|
17189
|
+
origin,
|
|
17190
|
+
status
|
|
17191
|
+
} = file;
|
|
17192
|
+
if (origin === FILE_ORIGIN.LOCAL) return true;
|
|
17193
|
+
if (origin === FILE_ORIGIN.INPUT && status === FILE_STATUS.PROCESSING_COMPLETE) return true;
|
|
17194
|
+
}).map(file => {
|
|
17195
|
+
if (file.origin === FILE_ORIGIN.LOCAL) return file.getMetadata().id;
|
|
17196
|
+
return file.serverId;
|
|
17197
|
+
}).map(i => i.toString())) || [];
|
|
17198
|
+
};
|
|
17199
|
+
const uploadUrl = useMemo(() => getDataSourceUrl(uploadDataSource), [uploadDataSource]);
|
|
17200
|
+
const handleLoad = (source, load, error, progress, abort, headers) => {
|
|
17201
|
+
// INFO: source appears in preview but also needed to identify
|
|
17202
|
+
// the download URL. Check issue:
|
|
17203
|
+
// https://github.com/pqina/filepond/issues/284
|
|
17204
|
+
const file = initialFiles.find(item => item.source === source);
|
|
17205
|
+
const loadUrl = file.options.origin;
|
|
17206
|
+
fetch(loadUrl).then(res => res.blob()).then(res => {
|
|
17267
17207
|
const file = res.type === "jpeg/jfif" || !res.type ? new Blob([res], {
|
|
17268
17208
|
type: "image/jpeg"
|
|
17269
17209
|
}) : res;
|
|
17270
|
-
|
|
17210
|
+
const preview = isPreviewHidden ? res : file;
|
|
17211
|
+
load(preview);
|
|
17271
17212
|
}).catch(error);
|
|
17213
|
+
|
|
17214
|
+
// Should expose an abort method so the request can be cancelled
|
|
17215
|
+
return {
|
|
17216
|
+
abort: () => abort()
|
|
17217
|
+
};
|
|
17272
17218
|
};
|
|
17273
17219
|
const handleUploadResponse = res => {
|
|
17274
17220
|
try {
|
|
17275
17221
|
const jsonRes = JSON.parse(res);
|
|
17276
|
-
const
|
|
17277
|
-
|
|
17278
|
-
onChange(fileUuid);
|
|
17222
|
+
const id = mustache.render(mapUploadResponseToIdTemplate, jsonRes);
|
|
17223
|
+
return id;
|
|
17279
17224
|
} catch (err) {
|
|
17280
|
-
|
|
17225
|
+
var _window$logger;
|
|
17226
|
+
(_window$logger = window.logger) == null ? void 0 : _window$logger.sendLog({
|
|
17227
|
+
name: `Upload response could not be parsed. ${err}`,
|
|
17228
|
+
data: res
|
|
17229
|
+
});
|
|
17281
17230
|
}
|
|
17282
17231
|
};
|
|
17283
|
-
|
|
17284
|
-
|
|
17285
|
-
setFiles([]);
|
|
17286
|
-
onChange();
|
|
17287
|
-
};
|
|
17232
|
+
|
|
17233
|
+
// TODO: move to message HOC
|
|
17288
17234
|
const messageProps = {
|
|
17289
17235
|
title: (message == null ? void 0 : message.title) || undefined,
|
|
17290
17236
|
description: (message == null ? void 0 : message.description) || undefined,
|
|
17291
17237
|
type: (message == null ? void 0 : message.type) || "info",
|
|
17292
17238
|
canDismiss: (message == null ? void 0 : message.canDismiss) || true
|
|
17293
17239
|
};
|
|
17294
|
-
const
|
|
17295
|
-
|
|
17296
|
-
|
|
17297
|
-
|
|
17298
|
-
|
|
17299
|
-
|
|
17300
|
-
|
|
17301
|
-
|
|
17302
|
-
|
|
17303
|
-
|
|
17304
|
-
|
|
17305
|
-
|
|
17240
|
+
const {
|
|
17241
|
+
error
|
|
17242
|
+
} = useNotify();
|
|
17243
|
+
const handleFileChange = () => {
|
|
17244
|
+
const ids = getFileIds();
|
|
17245
|
+
|
|
17246
|
+
// TODO: fill the data
|
|
17247
|
+
const value = ids.map(id => ({
|
|
17248
|
+
value: id,
|
|
17249
|
+
data: {}
|
|
17250
|
+
}));
|
|
17251
|
+
if (value.length === 0) onChange(emptyValue);else onChange(value);
|
|
17252
|
+
};
|
|
17253
|
+
|
|
17254
|
+
// TODO: move to memo component
|
|
17255
|
+
const FileUpload = useMemo(() => {
|
|
17256
|
+
const styles = isReadOnly ? {
|
|
17257
|
+
// INFO: hide drop panel and drop panel
|
|
17258
|
+
"div>div>div.filepond--drop-label": {
|
|
17259
|
+
display: "none"
|
|
17306
17260
|
},
|
|
17307
|
-
|
|
17308
|
-
|
|
17309
|
-
},
|
|
17310
|
-
onupdatefiles: files => {
|
|
17311
|
-
if (files.length === 0) {
|
|
17312
|
-
onChange(undefined);
|
|
17261
|
+
"button.filepond--action-remove-item": {
|
|
17262
|
+
display: "none"
|
|
17313
17263
|
}
|
|
17314
|
-
|
|
17315
|
-
|
|
17316
|
-
|
|
17317
|
-
|
|
17318
|
-
|
|
17319
|
-
|
|
17320
|
-
|
|
17264
|
+
} : null;
|
|
17265
|
+
const getAcceptedFileTypes = () => {
|
|
17266
|
+
if (acceptedFileTypes) return acceptedFileTypes;
|
|
17267
|
+
if (isImage) return ["image/*"];
|
|
17268
|
+
return null;
|
|
17269
|
+
};
|
|
17270
|
+
const filePondProps = {
|
|
17271
|
+
acceptedFileTypes: getAcceptedFileTypes(),
|
|
17272
|
+
files: initialFiles,
|
|
17273
|
+
// files: undefined,
|
|
17274
|
+
allowMultiple: true,
|
|
17275
|
+
server: {
|
|
17276
|
+
url: uploadUrl,
|
|
17277
|
+
process: {
|
|
17278
|
+
method: "POST",
|
|
17279
|
+
headers: {
|
|
17280
|
+
Methods: "POST"
|
|
17281
|
+
},
|
|
17282
|
+
onload: handleUploadResponse,
|
|
17283
|
+
onerror: e => {
|
|
17284
|
+
var _window$logger2;
|
|
17285
|
+
const message = `The image could not be uploaded.`;
|
|
17286
|
+
error(message);
|
|
17287
|
+
(_window$logger2 = window.logger) == null ? void 0 : _window$logger2.sendLog({
|
|
17288
|
+
name: message,
|
|
17289
|
+
data: e
|
|
17290
|
+
});
|
|
17291
|
+
}
|
|
17292
|
+
},
|
|
17293
|
+
load: handleLoad
|
|
17294
|
+
},
|
|
17295
|
+
onprocessfile: () => handleFileChange(),
|
|
17296
|
+
onremovefile: () => handleFileChange(),
|
|
17297
|
+
maxParallelUploads: 3,
|
|
17298
|
+
allowProcess: false,
|
|
17299
|
+
disabled: isReadOnly,
|
|
17300
|
+
allowDownloadByUrl: true,
|
|
17301
|
+
maxFiles: maxFiles,
|
|
17302
|
+
maxFileSize,
|
|
17303
|
+
maxTotalFileSize,
|
|
17304
|
+
// INFO: allowDrop create problem on file type validation //
|
|
17305
|
+
// (check badge form), for preview image allowDrop: false, //
|
|
17306
|
+
// labelIdle: "Click Here to Browse File(s)" //
|
|
17307
|
+
allowFileTypeValidation: false
|
|
17308
|
+
};
|
|
17309
|
+
const overrideProps = typeof inputProps === "function" ? inputProps(filePondProps) : inputProps;
|
|
17310
|
+
return /*#__PURE__*/jsx(Box$1, {
|
|
17311
|
+
sx: styles,
|
|
17312
|
+
children: /*#__PURE__*/jsx(FilePond, _extends({
|
|
17313
|
+
ref: filePondRef
|
|
17314
|
+
}, filePondProps, overrideProps))
|
|
17315
|
+
});
|
|
17316
|
+
}, []);
|
|
17317
|
+
|
|
17318
|
+
// TODO: better implementation
|
|
17321
17319
|
if (isReadOnly) {
|
|
17322
17320
|
if (formData == undefined) return /*#__PURE__*/jsx(ReadOnlyView, {
|
|
17323
17321
|
label: schema.title,
|
|
17324
17322
|
emptyViewText: "No file uploaded"
|
|
17325
17323
|
});
|
|
17326
|
-
|
|
17324
|
+
return /*#__PURE__*/jsx(ReadOnlyView, {
|
|
17325
|
+
label: schema.title,
|
|
17326
|
+
renderValue: () => FileUpload
|
|
17327
|
+
});
|
|
17327
17328
|
}
|
|
17328
17329
|
return /*#__PURE__*/jsxs(FieldContainer, {
|
|
17329
17330
|
children: [/*#__PURE__*/jsxs(DisableWrapper, {
|
|
@@ -17340,7 +17341,7 @@ const Upload = props => {
|
|
|
17340
17341
|
sx: {
|
|
17341
17342
|
marginTop: 1
|
|
17342
17343
|
},
|
|
17343
|
-
children:
|
|
17344
|
+
children: FileUpload
|
|
17344
17345
|
})]
|
|
17345
17346
|
}), message && /*#__PURE__*/jsx(Alert, _extends({}, messageProps))]
|
|
17346
17347
|
});
|