aefis-core-ui 2.2.1-rc2 → 2.2.1-rc4

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.
@@ -8095,30 +8095,35 @@ const FilterChips = ({
8095
8095
  if (_filters.length === 0 && _sort.length === 0) return /*#__PURE__*/jsx("div", {
8096
8096
  children: "No filters or sorting criteria selected"
8097
8097
  });
8098
- const Filters = useMemo(() => /*#__PURE__*/jsx(Fragment, {
8099
- children: _filters.map(filter => /*#__PURE__*/jsx(Grow, {
8100
- in: true,
8101
- children: /*#__PURE__*/jsx("div", {
8102
- style: {
8103
- margin: 2,
8104
- display: "inline-flex"
8105
- },
8106
- children: /*#__PURE__*/jsx(BusinessObject, {
8107
- variant: "chip",
8108
- size: "small",
8109
- displayOptions: {
8110
- hasIcon: filter.type !== "keyword"
8098
+ const Filters = useMemo(() => {
8099
+ return /*#__PURE__*/jsx(Box$1, {
8100
+ sx: {
8101
+ display: "flex"
8102
+ },
8103
+ children: _filters.map(filter => /*#__PURE__*/jsx(Grow, {
8104
+ in: true,
8105
+ children: /*#__PURE__*/jsx("div", {
8106
+ style: {
8107
+ margin: 2,
8108
+ display: "inline-flex"
8111
8109
  },
8112
- type: filter.type || "businessObject",
8113
- template: filter.template,
8114
- data: filter.data,
8115
- onDelete: () => {
8116
- onFilterDelete(filter);
8117
- }
8118
- }, filter.data.id)
8119
- })
8120
- }, `filterPanelFilter-${filter.index}-${filter.id}`))
8121
- }), [_filters]);
8110
+ children: /*#__PURE__*/jsx(BusinessObject, {
8111
+ variant: "chip",
8112
+ size: "small",
8113
+ displayOptions: {
8114
+ hasIcon: filter.type !== "keyword"
8115
+ },
8116
+ type: "businessObject",
8117
+ template: filter.template,
8118
+ data: filter.data,
8119
+ onDelete: () => {
8120
+ onFilterDelete(filter);
8121
+ }
8122
+ }, filter.data.id)
8123
+ })
8124
+ }, `filterPanelFilter-${filter.index}-${filter.id}`))
8125
+ });
8126
+ }, [_filters]);
8122
8127
  const SortItems = useMemo(() => /*#__PURE__*/jsx(Fragment, {
8123
8128
  children: _sort.map(sortItem => /*#__PURE__*/jsx(Grow, {
8124
8129
  in: true,
@@ -8205,7 +8210,7 @@ const FilterSelection = ({
8205
8210
  children: "Apply All Filters"
8206
8211
  }), /*#__PURE__*/jsx(Button, {
8207
8212
  name: "reset all filters",
8208
- disabled: !(filters.length > 0),
8213
+ disabled: !(filters.length > 0 || sort.length > 0),
8209
8214
  variant: "contained",
8210
8215
  color: "grey",
8211
8216
  onClick: onResetFilters,
@@ -8387,6 +8392,7 @@ const FilterPanel = props => {
8387
8392
  const [menuPosition, setMenuPosition] = useState(null);
8388
8393
  const [filters, setFilters] = useState([]);
8389
8394
  const [sort, setSort] = useState(sortProp || []);
8395
+ const [panelSearch, setPanelSearch] = useState([]);
8390
8396
  const [pickerFilters, setPickerFilters] = useState([]);
8391
8397
  useEffect(() => {
8392
8398
  const formattedFilters = formatFilters(filtersProp, configuration);
@@ -8418,6 +8424,7 @@ const FilterPanel = props => {
8418
8424
  }
8419
8425
  }, [filters, sort]);
8420
8426
  const removeFilter = filter => {
8427
+ console.log("remove filter ", filter);
8421
8428
  const newFilterArray = filters == null ? void 0 : filters.filter(i => i.index !== filter.index || filter.id !== i.id);
8422
8429
  setFilters(newFilterArray);
8423
8430
  if (!onApplyFilters) {
@@ -8538,6 +8545,8 @@ const FilterPanel = props => {
8538
8545
  const handleResetFilters = () => {
8539
8546
  setPickerFilters([]);
8540
8547
  setFilters([]);
8548
+ setSort([]);
8549
+ setPanelSearch([]);
8541
8550
  if (!onChange && onApplyFilters) {
8542
8551
  onApplyFilters({}, []);
8543
8552
  }
@@ -8546,6 +8555,8 @@ const FilterPanel = props => {
8546
8555
  }
8547
8556
  };
8548
8557
  const handleSearchChange = keyword => {
8558
+ if (panelSearch.includes(keyword)) return;
8559
+ setPanelSearch([...panelSearch, keyword]);
8549
8560
  addFilter({
8550
8561
  index: -1,
8551
8562
  type: "keyword",
@@ -10479,6 +10490,15 @@ const useIsError = status => {
10479
10490
  }, [status]);
10480
10491
  return isError;
10481
10492
  };
10493
+ const initialFilterState = {
10494
+ filter: {},
10495
+ searchText: "",
10496
+ filterArray: [],
10497
+ filterCount: 0,
10498
+ sort: [],
10499
+ sortCount: 0,
10500
+ sortQueryParams: null
10501
+ };
10482
10502
  const RichDataTable = /*#__PURE__*/forwardRef(function RichDatatable(props, ref) {
10483
10503
  var _props$filterPanelCon, _props$rowActions, _props$dataTableProps, _props$dataTableProps2;
10484
10504
  const didMount = useDidMount();
@@ -10504,18 +10524,9 @@ const RichDataTable = /*#__PURE__*/forwardRef(function RichDatatable(props, ref)
10504
10524
  const [formatDrawerContent, setFormatDrawerContent] = useState(false);
10505
10525
  const [enableTableRowAction, setEnableTableRowAction] = useState(false);
10506
10526
  const [selectedRowCount, setSelectedRowCount] = useState(0);
10507
- const [filterPanelState, setFilterPanelState] = useState({
10508
- filter: {},
10509
- searchText: "",
10510
- filterArray: [],
10511
- filterCount: 0,
10512
- sort: [],
10513
- sortCount: 0,
10514
- sortQueryParams: null
10515
- });
10527
+ const [filterPanelState, setFilterPanelState] = useState(initialFilterState);
10516
10528
  const {
10517
- info,
10518
- error
10529
+ info
10519
10530
  } = useNotify();
10520
10531
  const queryParams = _extends({}, props.parameters, {
10521
10532
  filter: _extends({}, filterPanelState.filter, props.filterParameters),
@@ -10635,6 +10646,15 @@ const RichDataTable = /*#__PURE__*/forwardRef(function RichDatatable(props, ref)
10635
10646
  };
10636
10647
  const handleFilterChange = (filters, newFilterArray) => {
10637
10648
  props == null ? void 0 : props.onFilterChange == null ? void 0 : props.onFilterChange(filters);
10649
+
10650
+ // TODO: apply better approach by gathering handling of all search and
10651
+ // filter changes with onChange; also send operation type to onChange
10652
+ // events
10653
+ const isReset = newFilterArray.length === 0;
10654
+ if (isReset) {
10655
+ setFilterPanelState(() => _extends({}, initialFilterState));
10656
+ return;
10657
+ }
10638
10658
  setFilterPanelState(prev => _extends({}, prev, {
10639
10659
  filterCount: Object.keys(filters).length,
10640
10660
  filter: filters,
@@ -10729,7 +10749,7 @@ const RichDataTable = /*#__PURE__*/forwardRef(function RichDatatable(props, ref)
10729
10749
  exportOptions: props.exportOptions,
10730
10750
  actions: props.actions && props.actions.length > 0 || props.addAction ? updateActions(props.actions, handleDrawerOpen, enableTableRowAction, selectedRowCount, Add) : undefined,
10731
10751
  onFilterClick: isFilterPanelEnabled ? handleFilterClick : undefined,
10732
- hasFilters: filterPanelState.filterCount > 0 || filterPanelState.sortCount > 0,
10752
+ hasFilters: filterPanelState.filterCount > 0 || filterPanelState.sortCount > 0 || filterPanelState.searchText,
10733
10753
  disableFilterButton: isFetching
10734
10754
  }, props.titleAndActionHeaderProps)), /*#__PURE__*/jsx(DataTable, _extends({}, props, {
10735
10755
  tableRef: DataTableRef,