aefis-core-ui 2.3.0-rc3 → 2.3.0-rc5
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 +57 -143
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -3296,12 +3296,12 @@ const outcomeConfiguration = {
|
|
|
3296
3296
|
// about solution: https://stackoverflow.com/questions/22820162/mustache-js-escaping
|
|
3297
3297
|
mustache.escape = _ => _;
|
|
3298
3298
|
function compile() {}
|
|
3299
|
-
function render$
|
|
3299
|
+
function render$1(template, data, defaultValue) {
|
|
3300
3300
|
return template ? mustache.render(template, data) : defaultValue;
|
|
3301
3301
|
}
|
|
3302
3302
|
var template = {
|
|
3303
3303
|
compile,
|
|
3304
|
-
render: render$
|
|
3304
|
+
render: render$1
|
|
3305
3305
|
};
|
|
3306
3306
|
|
|
3307
3307
|
// Copyright (c) 2020 AEFIS, all rights reserved.
|
|
@@ -7659,69 +7659,6 @@ TextSearch.propTypes = {
|
|
|
7659
7659
|
bottomGutter: PropTypes.number
|
|
7660
7660
|
};
|
|
7661
7661
|
|
|
7662
|
-
const {
|
|
7663
|
-
render: render$1
|
|
7664
|
-
} = template;
|
|
7665
|
-
|
|
7666
|
-
/**
|
|
7667
|
-
* This function returns unique field inside filter item using render.
|
|
7668
|
-
*
|
|
7669
|
-
* @param {object} item
|
|
7670
|
-
* @param {object} filter
|
|
7671
|
-
* @returns {string}
|
|
7672
|
-
*/
|
|
7673
|
-
const getFilterItemId = (item, configItem = {}) => {
|
|
7674
|
-
var _item$data;
|
|
7675
|
-
if (item.id) {
|
|
7676
|
-
return item.id;
|
|
7677
|
-
}
|
|
7678
|
-
const template = configItem.idTemplate || configItem.template || configItem.optionTemplate;
|
|
7679
|
-
if (template) {
|
|
7680
|
-
return render$1(template, item.data || item);
|
|
7681
|
-
}
|
|
7682
|
-
if ((_item$data = item.data) != null && _item$data.id) {
|
|
7683
|
-
return item.data.id;
|
|
7684
|
-
}
|
|
7685
|
-
};
|
|
7686
|
-
|
|
7687
|
-
/**
|
|
7688
|
-
* This function checks filter items; if index and id fields are missing then
|
|
7689
|
-
* try to sets them with possible ways.
|
|
7690
|
-
*
|
|
7691
|
-
* @param {array} filters
|
|
7692
|
-
* @param {array} configuration
|
|
7693
|
-
* @returns {array}
|
|
7694
|
-
*/
|
|
7695
|
-
const formatFilters = (filters = [], configuration = []) => filters.map(filter => {
|
|
7696
|
-
var _ref, _filter$index, _filter$id, _configuration$index, _configuration$index2, _configuration$index3, _configuration$index4, _configuration$index5;
|
|
7697
|
-
// TODO: index should be defined on filters. There should not be need of
|
|
7698
|
-
// search of index value throught type or map values.
|
|
7699
|
-
const index = (_ref = (_filter$index = filter == null ? void 0 : filter.index) != null ? _filter$index : findIndexByType(filter, configuration)) != null ? _ref : findIndexByMap(filter, configuration);
|
|
7700
|
-
const id = (_filter$id = filter == null ? void 0 : filter.id) != null ? _filter$id : getFilterItemId(filter, configuration[index]);
|
|
7701
|
-
|
|
7702
|
-
// TODO: These properties should ONLY be defined either in configuration
|
|
7703
|
-
// or filters; currently data can be defined from both sources. Filter
|
|
7704
|
-
// data prioritised over configuratuon.
|
|
7705
|
-
const {
|
|
7706
|
-
map = (_configuration$index = configuration[index]) == null ? void 0 : _configuration$index.map,
|
|
7707
|
-
type = (_configuration$index2 = configuration[index]) == null ? void 0 : _configuration$index2.type,
|
|
7708
|
-
template = (_configuration$index3 = configuration[index]) == null ? void 0 : _configuration$index3.template,
|
|
7709
|
-
idTemplate = (_configuration$index4 = configuration[index]) == null ? void 0 : _configuration$index4.idTemplate,
|
|
7710
|
-
optionTemplate = (_configuration$index5 = configuration[index]) == null ? void 0 : _configuration$index5.optionTemplate
|
|
7711
|
-
} = filter;
|
|
7712
|
-
return _extends({}, filter, {
|
|
7713
|
-
template,
|
|
7714
|
-
idTemplate,
|
|
7715
|
-
optionTemplate,
|
|
7716
|
-
type,
|
|
7717
|
-
map,
|
|
7718
|
-
index,
|
|
7719
|
-
id
|
|
7720
|
-
});
|
|
7721
|
-
});
|
|
7722
|
-
const findIndexByType = (filter, configuration) => filter.type !== undefined ? configuration.findIndex(config => config.type === filter.type) : undefined;
|
|
7723
|
-
const findIndexByMap = (filter, configuration) => filter.map !== undefined ? configuration.findIndex(config => config.map === filter.map) : undefined;
|
|
7724
|
-
|
|
7725
7662
|
const mapFilters = newFilters => {
|
|
7726
7663
|
const mappedFilters = {};
|
|
7727
7664
|
newFilters.map(filter => {
|
|
@@ -8096,7 +8033,8 @@ const FilterChips = ({
|
|
|
8096
8033
|
const Filters = useMemo(() => {
|
|
8097
8034
|
return /*#__PURE__*/jsx(Box$1, {
|
|
8098
8035
|
sx: {
|
|
8099
|
-
display: "flex"
|
|
8036
|
+
display: "flex",
|
|
8037
|
+
flexFlow: "wrap"
|
|
8100
8038
|
},
|
|
8101
8039
|
children: _filters.map(filter => /*#__PURE__*/jsx(Grow, {
|
|
8102
8040
|
in: true,
|
|
@@ -8111,7 +8049,7 @@ const FilterChips = ({
|
|
|
8111
8049
|
displayOptions: {
|
|
8112
8050
|
hasIcon: filter.type !== "keyword"
|
|
8113
8051
|
},
|
|
8114
|
-
type: "businessObject",
|
|
8052
|
+
type: filter.type || "businessObject",
|
|
8115
8053
|
template: filter.template,
|
|
8116
8054
|
data: filter.data,
|
|
8117
8055
|
onDelete: () => {
|
|
@@ -8122,7 +8060,11 @@ const FilterChips = ({
|
|
|
8122
8060
|
}, `filterPanelFilter-${filter.index}-${filter.id}`))
|
|
8123
8061
|
});
|
|
8124
8062
|
}, [_filters]);
|
|
8125
|
-
const SortItems = useMemo(() => /*#__PURE__*/jsx(
|
|
8063
|
+
const SortItems = useMemo(() => /*#__PURE__*/jsx(Box$1, {
|
|
8064
|
+
sx: {
|
|
8065
|
+
display: "flex",
|
|
8066
|
+
flexFlow: "wrap"
|
|
8067
|
+
},
|
|
8126
8068
|
children: _sort.map(sortItem => /*#__PURE__*/jsx(Grow, {
|
|
8127
8069
|
in: true,
|
|
8128
8070
|
children: /*#__PURE__*/jsx("div", {
|
|
@@ -8360,6 +8302,36 @@ PanelDisplay.propTypes = {
|
|
|
8360
8302
|
renderFilterSelection: PropTypes.bool
|
|
8361
8303
|
};
|
|
8362
8304
|
|
|
8305
|
+
const usePrevState = (callback, current) => {
|
|
8306
|
+
const [prev, setPrev] = useState(current);
|
|
8307
|
+
if (prev !== current) {
|
|
8308
|
+
callback(prev, current);
|
|
8309
|
+
setPrev(current);
|
|
8310
|
+
}
|
|
8311
|
+
};
|
|
8312
|
+
|
|
8313
|
+
const useFilterState = filtersProp => {
|
|
8314
|
+
const [filters, _setFilters] = useState(filtersProp);
|
|
8315
|
+
const setFilters = useCallback((filters = []) => {
|
|
8316
|
+
const sorted = filters.sort((a, b) => a.index - b.index);
|
|
8317
|
+
_setFilters(sorted);
|
|
8318
|
+
}, []);
|
|
8319
|
+
usePrevState(() => {
|
|
8320
|
+
setFilters(filtersProp);
|
|
8321
|
+
}, filtersProp);
|
|
8322
|
+
return [filters, setFilters];
|
|
8323
|
+
};
|
|
8324
|
+
|
|
8325
|
+
const getItemId = (item, filter) => item.id || template.render(filter.idTemplate || filter.optionTemplate, item);
|
|
8326
|
+
const formatFilterItem = (index, filter, data) => ({
|
|
8327
|
+
index: index,
|
|
8328
|
+
id: getItemId(data, filter),
|
|
8329
|
+
type: filter.type,
|
|
8330
|
+
template: filter.optionTemplate,
|
|
8331
|
+
idTemplate: filter.idTemplate,
|
|
8332
|
+
map: filter.map,
|
|
8333
|
+
data
|
|
8334
|
+
});
|
|
8363
8335
|
const mapSort = value => value.map(i => i.map);
|
|
8364
8336
|
const getSearchFilter = newFilters => (newFilters == null ? void 0 : newFilters.filter(filter => (filter == null ? void 0 : filter.type) === "keyword").map(item => item.data.id)) || [];
|
|
8365
8337
|
|
|
@@ -8378,7 +8350,7 @@ const FilterPanel = props => {
|
|
|
8378
8350
|
searchTooltip,
|
|
8379
8351
|
searchPlaceHolderText,
|
|
8380
8352
|
configuration,
|
|
8381
|
-
filters: filtersProp,
|
|
8353
|
+
filters: filtersProp = [],
|
|
8382
8354
|
displayType,
|
|
8383
8355
|
limitTags,
|
|
8384
8356
|
bottomGutter,
|
|
@@ -8388,14 +8360,10 @@ const FilterPanel = props => {
|
|
|
8388
8360
|
sort: sortProp
|
|
8389
8361
|
} = props;
|
|
8390
8362
|
const [menuPosition, setMenuPosition] = useState(null);
|
|
8391
|
-
const [filters, setFilters] =
|
|
8363
|
+
const [filters, setFilters] = useFilterState(filtersProp);
|
|
8392
8364
|
const [sort, setSort] = useState(sortProp || []);
|
|
8393
8365
|
const [panelSearch, setPanelSearch] = useState([]);
|
|
8394
8366
|
const [pickerFilters, setPickerFilters] = useState([]);
|
|
8395
|
-
useEffect(() => {
|
|
8396
|
-
const formattedFilters = formatFilters(filtersProp, configuration);
|
|
8397
|
-
setFilters(formattedFilters);
|
|
8398
|
-
}, [filtersProp]);
|
|
8399
8367
|
|
|
8400
8368
|
// TODO: replace it with useMemo
|
|
8401
8369
|
useEffect(() => {
|
|
@@ -8421,9 +8389,8 @@ const FilterPanel = props => {
|
|
|
8421
8389
|
onDataChange(filteredData, filterParameters, filters);
|
|
8422
8390
|
}
|
|
8423
8391
|
}, [filters, sort]);
|
|
8424
|
-
const removeFilter = filter => {
|
|
8425
|
-
|
|
8426
|
-
const newFilterArray = filters == null ? void 0 : filters.filter(i => i.index !== filter.index || filter.id !== i.id);
|
|
8392
|
+
const removeFilter = (filter = []) => {
|
|
8393
|
+
const newFilterArray = filters.filter(i => i.index !== filter.index || filter.id !== i.id);
|
|
8427
8394
|
setFilters(newFilterArray);
|
|
8428
8395
|
if (!onApplyFilters) {
|
|
8429
8396
|
if ((filter == null ? void 0 : filter.type) === "keyword" && onSearchChange) {
|
|
@@ -8460,69 +8427,14 @@ const FilterPanel = props => {
|
|
|
8460
8427
|
onChange(mapFilters(newFilterArray), newFilterArray);
|
|
8461
8428
|
}
|
|
8462
8429
|
};
|
|
8463
|
-
/** Had to revert this function as filters were not working properly
|
|
8464
|
-
const handleSetFilterType = (inputIndex, configItem, data = []) => {
|
|
8465
|
-
const newFiltersByUpdatedIndex = data.map((filterItem) => {
|
|
8466
|
-
return {
|
|
8467
|
-
index: inputIndex,
|
|
8468
|
-
id: filterItem.id || getFilterItemId(configItem, filterItem),
|
|
8469
|
-
type: configItem.type,
|
|
8470
|
-
template: configItem.optionTemplate,
|
|
8471
|
-
idTemplate: configItem.idTemplate,
|
|
8472
|
-
map: configItem.map,
|
|
8473
|
-
data: filterItem
|
|
8474
|
-
};
|
|
8475
|
-
});
|
|
8476
|
-
const filtersByUnupdatedIndex = filters.filter((i) => i.index !== inputIndex);
|
|
8477
|
-
const newFilters = [...filtersByUnupdatedIndex, ...newFiltersByUpdatedIndex];
|
|
8478
|
-
setFilters(newFilters);
|
|
8479
|
-
if (onChange) {
|
|
8480
|
-
// TO-CHECK: what does mapFilters do?
|
|
8481
|
-
onChange(mapFilters(newFilters), newFilters);
|
|
8482
|
-
}
|
|
8483
|
-
}; */
|
|
8484
|
-
|
|
8485
8430
|
const handleSetFilterType = (index, filter, data) => {
|
|
8486
|
-
|
|
8487
|
-
if (!Array.isArray(data))
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
id: newItemId,
|
|
8494
|
-
type: filter.type,
|
|
8495
|
-
template: filter.optionTemplate,
|
|
8496
|
-
idTemplate: filter.idTemplate,
|
|
8497
|
-
map: filter.map,
|
|
8498
|
-
data: data
|
|
8499
|
-
});
|
|
8500
|
-
}
|
|
8501
|
-
setFilters(_newFilterArray);
|
|
8502
|
-
if (onChange && !onApplyFilters) {
|
|
8503
|
-
onChange(mapFilters(_newFilterArray), _newFilterArray);
|
|
8504
|
-
}
|
|
8505
|
-
return;
|
|
8506
|
-
}
|
|
8507
|
-
data.map(item => {
|
|
8508
|
-
const newItemId = getItemId(item);
|
|
8509
|
-
if (!filters.find(i => i.index === index && i.id === newItemId)) {
|
|
8510
|
-
filters.push({
|
|
8511
|
-
index: index,
|
|
8512
|
-
id: newItemId,
|
|
8513
|
-
type: filter.type,
|
|
8514
|
-
template: filter.optionTemplate,
|
|
8515
|
-
idTemplate: filter.idTemplate,
|
|
8516
|
-
map: filter.map,
|
|
8517
|
-
data: item
|
|
8518
|
-
});
|
|
8519
|
-
}
|
|
8520
|
-
});
|
|
8521
|
-
const newFilterArray = filters.filter(i => index !== i.index || index === i.index && data.find(d => i.data.id === d.id));
|
|
8522
|
-
setFilters(newFilterArray);
|
|
8523
|
-
if (onChange && !onApplyFilters) {
|
|
8524
|
-
onChange(mapFilters(newFilterArray), newFilterArray);
|
|
8525
|
-
}
|
|
8431
|
+
let _data = data;
|
|
8432
|
+
if (!Array.isArray(data)) _data = data ? [data] : [];
|
|
8433
|
+
const filtersWithoutUpdatedField = filters.filter(filter => index !== filter.index);
|
|
8434
|
+
const newUpdatedFilters = _data.map(d => formatFilterItem(index, filter, d));
|
|
8435
|
+
const newFilters = filtersWithoutUpdatedField.concat(newUpdatedFilters);
|
|
8436
|
+
setFilters(newFilters);
|
|
8437
|
+
if (!onApplyFilters) onChange == null ? void 0 : onChange(mapFilters(newFilters), newFilters);
|
|
8526
8438
|
};
|
|
8527
8439
|
const handleSortChange = value => {
|
|
8528
8440
|
setSort(value);
|
|
@@ -9958,13 +9870,13 @@ const Drawer = props => {
|
|
|
9958
9870
|
};
|
|
9959
9871
|
const theme = useTheme$1();
|
|
9960
9872
|
const appBarStyle = {
|
|
9961
|
-
primary: {
|
|
9873
|
+
primary: _extends({
|
|
9962
9874
|
color: "#ffffff"
|
|
9963
|
-
},
|
|
9964
|
-
secondary: {
|
|
9875
|
+
}, props.appBarStyle),
|
|
9876
|
+
secondary: _extends({
|
|
9965
9877
|
backgroundColor: "#ffffff",
|
|
9966
9878
|
color: "#333333"
|
|
9967
|
-
}
|
|
9879
|
+
}, props.appBarStyle)
|
|
9968
9880
|
};
|
|
9969
9881
|
const closeDrawerIconStyle = {
|
|
9970
9882
|
color: props.headerColor === "secondary" ? "rgba(0, 0, 0, 0.54)" : "#ffffff",
|
|
@@ -10172,6 +10084,8 @@ Drawer.propTypes = {
|
|
|
10172
10084
|
menuPositionOffset: PropTypes.oneOf(["none", "primaryMenu", "secondaryMenu"]),
|
|
10173
10085
|
/** Additional styles to apply to the drawer paper. */
|
|
10174
10086
|
paperStyle: PropTypes.any,
|
|
10087
|
+
/** Additional styles to apply to the appbar. */
|
|
10088
|
+
appBarStyle: PropTypes.any,
|
|
10175
10089
|
/** Whether or not to show the header divider */
|
|
10176
10090
|
headerDivider: PropTypes.bool,
|
|
10177
10091
|
/** The component to use while rendering the drawer title */
|