aefis-core-ui 2.3.0-rc1 → 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.
@@ -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.2rem",
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.875rem",
1968
- fontWeight: 400,
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("div", {
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: "body1",
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("div", {
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("div", {
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$2(template, data, defaultValue) {
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$2
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"];
@@ -5296,7 +5321,8 @@ const useStyles$y = makeStyles(theme => ({
5296
5321
  root: {
5297
5322
  margin: 0,
5298
5323
  padding: theme.spacing(2),
5299
- position: "relative"
5324
+ position: "relative",
5325
+ minHeight: 60
5300
5326
  },
5301
5327
  closeButton: {
5302
5328
  position: "absolute",
@@ -6828,7 +6854,7 @@ DataTable.propTypes = {
6828
6854
  };
6829
6855
 
6830
6856
  const options = {
6831
- arrayFormat: "index"
6857
+ arrayFormat: "bracket"
6832
6858
  };
6833
6859
  const setQueryStringWithoutPageReload = qsValue => {
6834
6860
  const {
@@ -7658,69 +7684,6 @@ TextSearch.propTypes = {
7658
7684
  bottomGutter: PropTypes.number
7659
7685
  };
7660
7686
 
7661
- const {
7662
- render: render$1
7663
- } = template;
7664
-
7665
- /**
7666
- * This function returns unique field inside filter item using render.
7667
- *
7668
- * @param {object} item
7669
- * @param {object} filter
7670
- * @returns {string}
7671
- */
7672
- const getFilterItemId = (item, configItem = {}) => {
7673
- var _item$data;
7674
- if (item.id) {
7675
- return item.id;
7676
- }
7677
- const template = configItem.idTemplate || configItem.template || configItem.optionTemplate;
7678
- if (template) {
7679
- return render$1(template, item.data || item);
7680
- }
7681
- if ((_item$data = item.data) != null && _item$data.id) {
7682
- return item.data.id;
7683
- }
7684
- };
7685
-
7686
- /**
7687
- * This function checks filter items; if index and id fields are missing then
7688
- * try to sets them with possible ways.
7689
- *
7690
- * @param {array} filters
7691
- * @param {array} configuration
7692
- * @returns {array}
7693
- */
7694
- const formatFilters = (filters = [], configuration = []) => filters.map(filter => {
7695
- var _ref, _filter$index, _filter$id, _configuration$index, _configuration$index2, _configuration$index3, _configuration$index4, _configuration$index5;
7696
- // TODO: index should be defined on filters. There should not be need of
7697
- // search of index value throught type or map values.
7698
- const index = (_ref = (_filter$index = filter == null ? void 0 : filter.index) != null ? _filter$index : findIndexByType(filter, configuration)) != null ? _ref : findIndexByMap(filter, configuration);
7699
- const id = (_filter$id = filter == null ? void 0 : filter.id) != null ? _filter$id : getFilterItemId(filter, configuration[index]);
7700
-
7701
- // TODO: These properties should ONLY be defined either in configuration
7702
- // or filters; currently data can be defined from both sources. Filter
7703
- // data prioritised over configuratuon.
7704
- const {
7705
- map = (_configuration$index = configuration[index]) == null ? void 0 : _configuration$index.map,
7706
- type = (_configuration$index2 = configuration[index]) == null ? void 0 : _configuration$index2.type,
7707
- template = (_configuration$index3 = configuration[index]) == null ? void 0 : _configuration$index3.template,
7708
- idTemplate = (_configuration$index4 = configuration[index]) == null ? void 0 : _configuration$index4.idTemplate,
7709
- optionTemplate = (_configuration$index5 = configuration[index]) == null ? void 0 : _configuration$index5.optionTemplate
7710
- } = filter;
7711
- return _extends({}, filter, {
7712
- template,
7713
- idTemplate,
7714
- optionTemplate,
7715
- type,
7716
- map,
7717
- index,
7718
- id
7719
- });
7720
- });
7721
- const findIndexByType = (filter, configuration) => filter.type !== undefined ? configuration.findIndex(config => config.type === filter.type) : undefined;
7722
- const findIndexByMap = (filter, configuration) => filter.map !== undefined ? configuration.findIndex(config => config.map === filter.map) : undefined;
7723
-
7724
7687
  const mapFilters = newFilters => {
7725
7688
  const mappedFilters = {};
7726
7689
  newFilters.map(filter => {
@@ -8095,7 +8058,8 @@ const FilterChips = ({
8095
8058
  const Filters = useMemo(() => {
8096
8059
  return /*#__PURE__*/jsx(Box$1, {
8097
8060
  sx: {
8098
- display: "flex"
8061
+ display: "flex",
8062
+ flexFlow: "wrap"
8099
8063
  },
8100
8064
  children: _filters.map(filter => /*#__PURE__*/jsx(Grow, {
8101
8065
  in: true,
@@ -8110,7 +8074,7 @@ const FilterChips = ({
8110
8074
  displayOptions: {
8111
8075
  hasIcon: filter.type !== "keyword"
8112
8076
  },
8113
- type: "businessObject",
8077
+ type: filter.type || "businessObject",
8114
8078
  template: filter.template,
8115
8079
  data: filter.data,
8116
8080
  onDelete: () => {
@@ -8121,7 +8085,11 @@ const FilterChips = ({
8121
8085
  }, `filterPanelFilter-${filter.index}-${filter.id}`))
8122
8086
  });
8123
8087
  }, [_filters]);
8124
- const SortItems = useMemo(() => /*#__PURE__*/jsx(Fragment, {
8088
+ const SortItems = useMemo(() => /*#__PURE__*/jsx(Box$1, {
8089
+ sx: {
8090
+ display: "flex",
8091
+ flexFlow: "wrap"
8092
+ },
8125
8093
  children: _sort.map(sortItem => /*#__PURE__*/jsx(Grow, {
8126
8094
  in: true,
8127
8095
  children: /*#__PURE__*/jsx("div", {
@@ -8359,6 +8327,36 @@ PanelDisplay.propTypes = {
8359
8327
  renderFilterSelection: PropTypes.bool
8360
8328
  };
8361
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
+ });
8362
8360
  const mapSort = value => value.map(i => i.map);
8363
8361
  const getSearchFilter = newFilters => (newFilters == null ? void 0 : newFilters.filter(filter => (filter == null ? void 0 : filter.type) === "keyword").map(item => item.data.id)) || [];
8364
8362
 
@@ -8377,7 +8375,7 @@ const FilterPanel = props => {
8377
8375
  searchTooltip,
8378
8376
  searchPlaceHolderText,
8379
8377
  configuration,
8380
- filters: filtersProp,
8378
+ filters: filtersProp = [],
8381
8379
  displayType,
8382
8380
  limitTags,
8383
8381
  bottomGutter,
@@ -8387,14 +8385,10 @@ const FilterPanel = props => {
8387
8385
  sort: sortProp
8388
8386
  } = props;
8389
8387
  const [menuPosition, setMenuPosition] = useState(null);
8390
- const [filters, setFilters] = useState([]);
8388
+ const [filters, setFilters] = useFilterState(filtersProp);
8391
8389
  const [sort, setSort] = useState(sortProp || []);
8392
8390
  const [panelSearch, setPanelSearch] = useState([]);
8393
8391
  const [pickerFilters, setPickerFilters] = useState([]);
8394
- useEffect(() => {
8395
- const formattedFilters = formatFilters(filtersProp, configuration);
8396
- setFilters(formattedFilters);
8397
- }, [filtersProp]);
8398
8392
 
8399
8393
  // TODO: replace it with useMemo
8400
8394
  useEffect(() => {
@@ -8420,9 +8414,8 @@ const FilterPanel = props => {
8420
8414
  onDataChange(filteredData, filterParameters, filters);
8421
8415
  }
8422
8416
  }, [filters, sort]);
8423
- const removeFilter = filter => {
8424
- console.log("remove filter ", filter);
8425
- 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);
8426
8419
  setFilters(newFilterArray);
8427
8420
  if (!onApplyFilters) {
8428
8421
  if ((filter == null ? void 0 : filter.type) === "keyword" && onSearchChange) {
@@ -8459,69 +8452,14 @@ const FilterPanel = props => {
8459
8452
  onChange(mapFilters(newFilterArray), newFilterArray);
8460
8453
  }
8461
8454
  };
8462
- /** Had to revert this function as filters were not working properly
8463
- const handleSetFilterType = (inputIndex, configItem, data = []) => {
8464
- const newFiltersByUpdatedIndex = data.map((filterItem) => {
8465
- return {
8466
- index: inputIndex,
8467
- id: filterItem.id || getFilterItemId(configItem, filterItem),
8468
- type: configItem.type,
8469
- template: configItem.optionTemplate,
8470
- idTemplate: configItem.idTemplate,
8471
- map: configItem.map,
8472
- data: filterItem
8473
- };
8474
- });
8475
- const filtersByUnupdatedIndex = filters.filter((i) => i.index !== inputIndex);
8476
- const newFilters = [...filtersByUnupdatedIndex, ...newFiltersByUpdatedIndex];
8477
- setFilters(newFilters);
8478
- if (onChange) {
8479
- // TO-CHECK: what does mapFilters do?
8480
- onChange(mapFilters(newFilters), newFilters);
8481
- }
8482
- }; */
8483
-
8484
8455
  const handleSetFilterType = (index, filter, data) => {
8485
- const getItemId = item => item.id || template.render(filter.idTemplate || filter.optionTemplate, item);
8486
- if (!Array.isArray(data)) {
8487
- const _newFilterArray = filters.filter(i => index !== i.index);
8488
- if (data) {
8489
- const newItemId = getItemId(data);
8490
- _newFilterArray.push({
8491
- index: index,
8492
- id: newItemId,
8493
- type: filter.type,
8494
- template: filter.optionTemplate,
8495
- idTemplate: filter.idTemplate,
8496
- map: filter.map,
8497
- data: data
8498
- });
8499
- }
8500
- setFilters(_newFilterArray);
8501
- if (onChange && !onApplyFilters) {
8502
- onChange(mapFilters(_newFilterArray), _newFilterArray);
8503
- }
8504
- return;
8505
- }
8506
- data.map(item => {
8507
- const newItemId = getItemId(item);
8508
- if (!filters.find(i => i.index === index && i.id === newItemId)) {
8509
- filters.push({
8510
- index: index,
8511
- id: newItemId,
8512
- type: filter.type,
8513
- template: filter.optionTemplate,
8514
- idTemplate: filter.idTemplate,
8515
- map: filter.map,
8516
- data: item
8517
- });
8518
- }
8519
- });
8520
- const newFilterArray = filters.filter(i => index !== i.index || index === i.index && data.find(d => i.data.id === d.id));
8521
- setFilters(newFilterArray);
8522
- if (onChange && !onApplyFilters) {
8523
- onChange(mapFilters(newFilterArray), newFilterArray);
8524
- }
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);
8525
8463
  };
8526
8464
  const handleSortChange = value => {
8527
8465
  setSort(value);
@@ -9957,13 +9895,13 @@ const Drawer = props => {
9957
9895
  };
9958
9896
  const theme = useTheme$1();
9959
9897
  const appBarStyle = {
9960
- primary: {
9898
+ primary: _extends({
9961
9899
  color: "#ffffff"
9962
- },
9963
- secondary: {
9900
+ }, props.appBarStyle),
9901
+ secondary: _extends({
9964
9902
  backgroundColor: "#ffffff",
9965
9903
  color: "#333333"
9966
- }
9904
+ }, props.appBarStyle)
9967
9905
  };
9968
9906
  const closeDrawerIconStyle = {
9969
9907
  color: props.headerColor === "secondary" ? "rgba(0, 0, 0, 0.54)" : "#ffffff",
@@ -10171,6 +10109,8 @@ Drawer.propTypes = {
10171
10109
  menuPositionOffset: PropTypes.oneOf(["none", "primaryMenu", "secondaryMenu"]),
10172
10110
  /** Additional styles to apply to the drawer paper. */
10173
10111
  paperStyle: PropTypes.any,
10112
+ /** Additional styles to apply to the appbar. */
10113
+ appBarStyle: PropTypes.any,
10174
10114
  /** Whether or not to show the header divider */
10175
10115
  headerDivider: PropTypes.bool,
10176
10116
  /** The component to use while rendering the drawer title */
@@ -14654,36 +14594,7 @@ Header.propTypes = {
14654
14594
  allStepsCompleted: PropTypes.bool
14655
14595
  };
14656
14596
 
14657
- // Copyright (c) 2022 HelioCampus Inc., all rights reserved.
14658
14597
  const useStyles$5 = makeStyles(theme => ({
14659
- container: {
14660
- position: "absolute",
14661
- overflowY: "auto",
14662
- left: 0,
14663
- right: 0,
14664
- bottom: 64,
14665
- top: 178
14666
- },
14667
- tabBar: {
14668
- borderBottom: "1px solid rgba(0, 0, 0, 0.12)",
14669
- zIndex: 1,
14670
- background: "#ffffff",
14671
- padding: theme.spacing(2)
14672
- },
14673
- scrolledTabBar: {
14674
- zIndex: 1,
14675
- borderBottom: "none",
14676
- background: "#ffffff",
14677
- padding: theme.spacing(2),
14678
- boxShadow: "0px 2px 4px -4px rgba(0,0,0,0.2), 0px 4px 5px 0px rgba(0,0,0,0.14), 0px 1px 10px -10px rgba(0,0,0,0.12)"
14679
- },
14680
- bottomBar: {
14681
- borderTop: "1px solid rgba(0, 0, 0, 0.12)"
14682
- },
14683
- scrolledBottomBar: {
14684
- borderTop: "none",
14685
- boxShadow: "0px -4px 8px -4px rgba(0,0,0,0.12)"
14686
- },
14687
14598
  buttonContainer: {
14688
14599
  marginLeft: "auto",
14689
14600
  display: "flex"
@@ -14696,7 +14607,7 @@ const useStyles$5 = makeStyles(theme => ({
14696
14607
  marginRight: 8
14697
14608
  }
14698
14609
  }));
14699
- const bottomBarStyle = {
14610
+ const bottomBarDefaultStyle = {
14700
14611
  background: "#ffffff",
14701
14612
  display: "flex",
14702
14613
  minHeight: 64,
@@ -14712,7 +14623,7 @@ const bottomBarStyle = {
14712
14623
  right: 0
14713
14624
  };
14714
14625
 
14715
- /** Component to display a "stepper" wizard panel for multiple step proceses with swipeable tabs. Designed to be display within a Drawer component. */
14626
+ /** Component to display a "stepper" wizard panel for multiple step processes with swipeable tabs. Designed to be display within a Drawer component. */
14716
14627
 
14717
14628
  const WizardPanel = props => {
14718
14629
  var _props$panels;
@@ -14744,9 +14655,34 @@ const WizardPanel = props => {
14744
14655
  props.onComplete && props.onComplete();
14745
14656
  };
14746
14657
  const theme = useTheme$1();
14658
+ const stepsContainer = {
14659
+ position: "absolute",
14660
+ overflowY: "auto",
14661
+ left: 0,
14662
+ right: 0,
14663
+ bottom: 64,
14664
+ top: 178
14665
+ };
14747
14666
  const containerStyle = {
14748
14667
  backgroundColor: props.cardContent ? "rgb(239, 242, 246)" : "rgb(255,255,255)"
14749
14668
  };
14669
+ const tabBarStyle = {
14670
+ borderBottom: "1px solid rgba(0, 0, 0, 0.12)",
14671
+ zIndex: 1,
14672
+ background: "#ffffff",
14673
+ padding: props.display === "drawer" ? 2 : "0px 0px 16px 0px"
14674
+ };
14675
+ const scrolledTabBarStyle = {
14676
+ zIndex: 1,
14677
+ borderBottom: "none",
14678
+ background: "#ffffff",
14679
+ padding: props.display === "drawer" ? 2 : "0px 0px 16px 0px",
14680
+ boxShadow: "0px 2px 4px -4px rgba(0,0,0,0.2), 0px 4px 5px 0px rgba(0,0,0,0.14), 0px 1px 10px -10px rgba(0,0,0,0.12)"
14681
+ };
14682
+ const bottomBarStyle = _extends({}, bottomBarDefaultStyle, {
14683
+ borderTop: "none",
14684
+ boxShadow: props.display === "drawer" ? "0px -4px 8px -4px rgba(0,0,0,0.12)" : "none"
14685
+ });
14750
14686
  useEffect(() => {
14751
14687
  var _containerRef$current;
14752
14688
  (_containerRef$current = containerRef.current) == null ? void 0 : _containerRef$current.scrollTo == null ? void 0 : _containerRef$current.scrollTo({
@@ -14760,9 +14696,9 @@ const WizardPanel = props => {
14760
14696
  }, [props.completed]);
14761
14697
  return /*#__PURE__*/jsxs(Fragment, {
14762
14698
  children: [/*#__PURE__*/jsx(AppBar$1, {
14763
- position: "sticky",
14699
+ position: props.display === "drawer" ? "sticky" : "relative",
14764
14700
  component: "div",
14765
- className: scrollTrigger ? classes.scrolledTabBar : classes.tabBar,
14701
+ sx: scrollTrigger ? scrolledTabBarStyle : tabBarStyle,
14766
14702
  elevation: 0,
14767
14703
  color: "default",
14768
14704
  children: /*#__PURE__*/jsx(Header, {
@@ -14773,7 +14709,7 @@ const WizardPanel = props => {
14773
14709
  }), /*#__PURE__*/jsx(Box$1, {
14774
14710
  ref: containerRef,
14775
14711
  sx: containerStyle,
14776
- className: classes.container,
14712
+ style: props.display === "drawer" ? stepsContainer : undefined,
14777
14713
  children: /*#__PURE__*/jsx(SwipeableViews, {
14778
14714
  axis: theme.direction === "rtl" ? "x-reverse" : "x",
14779
14715
  index: activeStep,
@@ -14790,7 +14726,6 @@ const WizardPanel = props => {
14790
14726
  })
14791
14727
  }), /*#__PURE__*/jsx(Box$1, {
14792
14728
  style: bottomBarStyle,
14793
- className: classes.scrolledBottomBar,
14794
14729
  children: /*#__PURE__*/jsxs(Box$1, {
14795
14730
  className: classes.buttonContainer,
14796
14731
  children: [/*#__PURE__*/jsx(Button, {
@@ -14851,9 +14786,12 @@ WizardPanel.defaultProps = {
14851
14786
  completed: false,
14852
14787
  completeButtonText: "Finish",
14853
14788
  disableComplete: false,
14854
- completing: false
14789
+ completing: false,
14790
+ display: "drawer"
14855
14791
  };
14856
14792
  WizardPanel.propTypes = {
14793
+ /** Where to display the panel, a dialog or drawer. */
14794
+ display: PropTypes.oneOf(["drawer"], ["dialog"]),
14857
14795
  /** The data defining the wizard steps and content. */
14858
14796
  panels: PropTypes.arrayOf(PropTypes.shape({
14859
14797
  id: PropTypes.any.isRequired,
@@ -16653,14 +16591,6 @@ const render = (value, formState) => {
16653
16591
  }
16654
16592
  return mustache.render(value, formState);
16655
16593
  };
16656
- const renderUrl = (value, formState) => {
16657
- if (value === undefined || value === null) {
16658
- return value;
16659
- }
16660
- return decodeHtml$2(mustache.render(value, formState));
16661
- };
16662
- const useRenderUrl = template => useSelectFormState(state => renderUrl(template, state));
16663
- const useRender = template => useSelectFormState(state => render(template, state));
16664
16594
 
16665
16595
  const useQueryTemplateParam = queryTemplate => {
16666
16596
  const selector = useCallback(state => {
@@ -17156,49 +17086,6 @@ const DisableWrapper = ({
17156
17086
  }));
17157
17087
  };
17158
17088
 
17159
- const ImageUploadReadOnly = ({
17160
- formData,
17161
- schema,
17162
- uiSchema: _uiSchema = {
17163
- "ui:options": {}
17164
- }
17165
- }) => {
17166
- const {
17167
- downloadUrl: downloadUrlTemplate,
17168
- extension: extensionTemplate
17169
- } = _uiSchema["ui:options"];
17170
- const downloadUrl = useRenderUrl(downloadUrlTemplate);
17171
- const extension = useRender(extensionTemplate);
17172
- return /*#__PURE__*/jsxs(Fragment, {
17173
- children: [/*#__PURE__*/jsx(Typography, {
17174
- gutterBottom: true,
17175
- variant: "subtitle2",
17176
- children: schema.title
17177
- }), /*#__PURE__*/jsx(Paper, {
17178
- sx: {
17179
- height: 185,
17180
- justifyContent: "center",
17181
- display: "flex",
17182
- padding: 2,
17183
- overflow: "hidden"
17184
- },
17185
- variant: "outlined",
17186
- children: /*#__PURE__*/jsx(Image, {
17187
- src: downloadUrl,
17188
- style: {
17189
- height: "100%",
17190
- width: "auto"
17191
- },
17192
- extension: extension
17193
- })
17194
- })]
17195
- });
17196
- };
17197
- ImageUploadReadOnly.propTypes = {
17198
- schema: PropTypes.any,
17199
- renderedValues: PropTypes.any
17200
- };
17201
-
17202
17089
  const FieldContainer = props => {
17203
17090
  return /*#__PURE__*/jsx(Box$2, _extends({}, props, {
17204
17091
  sx: _extends({}, props.sx, {
@@ -17210,7 +17097,30 @@ const FieldContainer = props => {
17210
17097
  };
17211
17098
  FieldContainer.propTypes = Box$2.propTypes;
17212
17099
 
17213
- 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
+
17214
17124
  const Upload = props => {
17215
17125
  const {
17216
17126
  schema,
@@ -17219,67 +17129,108 @@ const Upload = props => {
17219
17129
  "ui:options": {}
17220
17130
  },
17221
17131
  onChange,
17222
- disabled,
17223
- required
17132
+ disabled
17224
17133
  } = props;
17134
+ const emptyValue = uiSchema["ui:emptyValue"] || null;
17225
17135
  const isReadOnly = useReadOnly();
17226
17136
  const {
17227
- documentName: documentNameTemplate,
17228
- downloadUrl: downloadUrlTemplate,
17229
- extension: extensionTemplate,
17230
17137
  uploadDataSource,
17231
- mapUploadResponse,
17232
17138
  acceptedFileTypes,
17233
17139
  message,
17234
- isImage
17235
- } = uiSchema["ui:options"];
17236
- const inputProps = uiSchema == null ? void 0 : uiSchema["ui:props"];
17237
- const documentName = useRender(documentNameTemplate);
17238
- const downloadUrl = useRenderUrl(downloadUrlTemplate);
17239
- useRender(extensionTemplate);
17240
- const [files, setFiles] = useState([]);
17241
- const uploadUrl = useMemo(() => getDataSourceUrl(uploadDataSource), [uploadDataSource]);
17140
+ // TODO: can be handled generic way with HOC
17141
+ isImage = true,
17142
+ // multiple = true, // change to false
17242
17143
 
17243
- // INFO: this state is needed to prevent re-load of file during submit
17244
- const [currentFileId, setCurrentFileId] = useState();
17144
+ isPreviewHidden = false,
17145
+ idTemplate,
17146
+ downloadUrlTemplate,
17147
+ nameTemplate,
17148
+ mapUploadResponseToIdTemplate,
17149
+ maxFiles = 1,
17150
+ maxFileSize = null,
17151
+ maxTotalFileSize = null
17152
+ } = uiSchema["ui:options"];
17245
17153
 
17246
- // TODO: change this to useMemo with help of useLastestDeps
17247
- useEffect(() => {
17248
- if (formData === currentFileId) return;
17249
- const files = [{
17250
- source: documentName || "File",
17251
- options: {
17252
- type: "local",
17253
- metadata: {
17254
- url: downloadUrl
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
+ }
17255
17179
  }
17256
- }
17257
- }];
17258
- if (formData != undefined) setFiles(files);
17259
- }, [formData]);
17260
- const handleLoad = (source, load, error) => {
17261
- fetch(downloadUrl).then(res => res.blob()).then(res => {
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 => {
17262
17207
  const file = res.type === "jpeg/jfif" || !res.type ? new Blob([res], {
17263
17208
  type: "image/jpeg"
17264
17209
  }) : res;
17265
- load(file);
17210
+ const preview = isPreviewHidden ? res : file;
17211
+ load(preview);
17266
17212
  }).catch(error);
17213
+
17214
+ // Should expose an abort method so the request can be cancelled
17215
+ return {
17216
+ abort: () => abort()
17217
+ };
17267
17218
  };
17268
17219
  const handleUploadResponse = res => {
17269
17220
  try {
17270
17221
  const jsonRes = JSON.parse(res);
17271
- const fileUuid = mapUploadResponse ? mustache.render(mapUploadResponse.fileUuid, jsonRes) : jsonRes.DATA.fileUuid;
17272
- setCurrentFileId(fileUuid);
17273
- onChange(fileUuid);
17222
+ const id = mustache.render(mapUploadResponseToIdTemplate, jsonRes);
17223
+ return id;
17274
17224
  } catch (err) {
17275
- console.log(err);
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
+ });
17276
17230
  }
17277
17231
  };
17278
- const handleDelete = () => {
17279
- setCurrentFileId();
17280
- setFiles([]);
17281
- onChange();
17282
- };
17232
+
17233
+ // TODO: move to message HOC
17283
17234
  const messageProps = {
17284
17235
  title: (message == null ? void 0 : message.title) || undefined,
17285
17236
  description: (message == null ? void 0 : message.description) || undefined,
@@ -17289,48 +17240,91 @@ const Upload = props => {
17289
17240
  const {
17290
17241
  error
17291
17242
  } = useNotify();
17292
- const filePondProps = {
17293
- acceptedFileTypes: acceptedFileTypes ? acceptedFileTypes : isImage ? ["image/*"] : null,
17294
- files,
17295
- allowMultiple: false,
17296
- server: {
17297
- url: uploadUrl,
17298
- process: {
17299
- method: "POST",
17300
- headers: {
17301
- Methods: "POST"
17302
- },
17303
- onload: handleUploadResponse,
17304
- onerror: e => {
17305
- var _window$logger;
17306
- const message = `The image could not be uploaded.`;
17307
- error(message);
17308
- (_window$logger = window.logger) == null ? void 0 : _window$logger.sendLog({
17309
- name: message,
17310
- data: e
17311
- });
17312
- }
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"
17313
17260
  },
17314
- load: handleLoad,
17315
- revert: handleDelete
17316
- },
17317
- onupdatefiles: files => {
17318
- if (files.length === 0) {
17319
- onChange(undefined);
17261
+ "button.filepond--action-remove-item": {
17262
+ display: "none"
17320
17263
  }
17321
- setFiles(files);
17322
- },
17323
- allowProcess: false,
17324
- disabled: isReadOnly,
17325
- allowDownloadByUrl: true
17326
- };
17327
- const overrideProps = typeof inputProps === "function" ? inputProps(filePondProps) : inputProps;
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
17328
17319
  if (isReadOnly) {
17329
17320
  if (formData == undefined) return /*#__PURE__*/jsx(ReadOnlyView, {
17330
17321
  label: schema.title,
17331
17322
  emptyViewText: "No file uploaded"
17332
17323
  });
17333
- if (isImage) return /*#__PURE__*/jsx(ImageUploadReadOnly, _extends({}, props));
17324
+ return /*#__PURE__*/jsx(ReadOnlyView, {
17325
+ label: schema.title,
17326
+ renderValue: () => FileUpload
17327
+ });
17334
17328
  }
17335
17329
  return /*#__PURE__*/jsxs(FieldContainer, {
17336
17330
  children: [/*#__PURE__*/jsxs(DisableWrapper, {
@@ -17347,7 +17341,7 @@ const Upload = props => {
17347
17341
  sx: {
17348
17342
  marginTop: 1
17349
17343
  },
17350
- children: /*#__PURE__*/jsx(FilePond, _extends({}, filePondProps, overrideProps))
17344
+ children: FileUpload
17351
17345
  })]
17352
17346
  }), message && /*#__PURE__*/jsx(Alert, _extends({}, messageProps))]
17353
17347
  });