Skip to content

Commit de60c56

Browse files
committed
chore: create new component tree
1 parent 0a38776 commit de60c56

File tree

7 files changed

+127
-634
lines changed

7 files changed

+127
-634
lines changed
Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,48 @@
11
import { createElement, ReactElement } from "react";
22
import { withPreloader } from "@mendix/widget-plugin-platform/hoc/withPreloader";
33
import { DatagridDropdownFilterContainerProps } from "../typings/DatagridDropdownFilterProps";
4-
import { StaticFilterContainer } from "./components/StaticFilterContainer";
5-
import { withSelectFilterAPI, Select_FilterAPIv2 } from "./hocs/withSelectFilterAPI";
6-
import { RefFilterContainer } from "./components/RefFilterContainer";
7-
8-
function Container(props: DatagridDropdownFilterContainerProps & Select_FilterAPIv2): React.ReactElement {
9-
const commonProps = {
10-
ariaLabel: props.ariaLabel?.value,
11-
className: props.class,
12-
tabIndex: props.tabIndex,
13-
styles: props.style,
14-
onChange: props.onChange,
15-
valueAttribute: props.valueAttribute,
16-
parentChannelName: props.parentChannelName,
17-
name: props.name,
18-
multiselect: props.multiSelect,
19-
emptyCaption: props.emptyOptionCaption?.value,
20-
defaultValue: props.defaultValue?.value,
21-
filterable: props.filterable,
22-
selectionMethod: props.selectionMethod,
23-
selectedItemsStyle: props.selectedItemsStyle,
24-
clearable: props.clearable
25-
};
26-
27-
if (props.filterStore.storeType === "refselect") {
28-
return <RefFilterContainer {...commonProps} filterStore={props.filterStore} />;
29-
}
4+
import { AttrFilter } from "./components/AttrFilter";
305

31-
return (
32-
<StaticFilterContainer {...commonProps} filterStore={props.filterStore} filterOptions={props.filterOptions} />
33-
);
34-
}
6+
// function Container(props: DatagridDropdownFilterContainerProps & Select_FilterAPIv2): React.ReactElement {
7+
// const commonProps = {
8+
// ariaLabel: props.ariaLabel?.value,
9+
// className: props.class,
10+
// tabIndex: props.tabIndex,
11+
// styles: props.style,
12+
// onChange: props.onChange,
13+
// valueAttribute: props.valueAttribute,
14+
// parentChannelName: props.parentChannelName,
15+
// name: props.name,
16+
// multiselect: props.multiSelect,
17+
// emptyCaption: props.emptyOptionCaption?.value,
18+
// defaultValue: props.defaultValue?.value,
19+
// filterable: props.filterable,
20+
// selectionMethod: props.selectionMethod,
21+
// selectedItemsStyle: props.selectedItemsStyle,
22+
// clearable: props.clearable
23+
// };
24+
25+
// if (props.filterStore.storeType === "refselect") {
26+
// return <RefFilterContainer {...commonProps} filterStore={props.filterStore} />;
27+
// }
28+
29+
// return (
30+
// <StaticFilterContainer {...commonProps} filterStore={props.filterStore} filterOptions={props.filterOptions} />
31+
// );
32+
// }
3533

36-
const container = withPreloader(Container, props => props.defaultValue?.status === "loading");
34+
const DatagridDropdownFilter = withPreloader(Container, props => props.defaultValue?.status === "loading");
3735

38-
const Widget = withSelectFilterAPI(container);
36+
export default DatagridDropdownFilter;
37+
38+
function Container(props: DatagridDropdownFilterContainerProps): ReactElement {
39+
if (props.baseType === "attr") {
40+
return <AttrFilter {...props} />;
41+
}
42+
43+
return <RefFilter {...props} />;
44+
}
3945

40-
export default function DatagridDropdownFilter(props: DatagridDropdownFilterContainerProps): ReactElement {
41-
return <Widget {...props} />;
46+
function RefFilter(props: DatagridDropdownFilterContainerProps): ReactElement {
47+
return <div key={props.name} />;
4248
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { ReactElement, createElement } from "react";
2+
import {
3+
StaticFilterContainer,
4+
StaticFilterContainerProps
5+
} from "@mendix/widget-plugin-dropdown-filter/containers/StaticFilterContainer";
6+
import {
7+
withParentProvidedStore,
8+
Select_FilterAPIv2
9+
} from "@mendix/widget-plugin-filtering/hocs/withParentProvidedStore";
10+
11+
import { DatagridDropdownFilterContainerProps } from "../../typings/DatagridDropdownFilterProps";
12+
13+
export function AttrFilter(props: DatagridDropdownFilterContainerProps): ReactElement {
14+
return <AutoAttrFilter {...props} />;
15+
}
16+
17+
const AutoAttrFilter = withParentProvidedStore(function AutoAttrFilter(
18+
props: DatagridDropdownFilterContainerProps & Select_FilterAPIv2
19+
): ReactElement {
20+
return <StaticFilterContainer {...mapProps(props)} />;
21+
});
22+
23+
function mapProps(props: DatagridDropdownFilterContainerProps & Select_FilterAPIv2): StaticFilterContainerProps {
24+
return {
25+
...props,
26+
multiselect: props.multiSelect,
27+
ariaLabel: props.ariaLabel?.value,
28+
className: props.class,
29+
styles: props.style,
30+
emptyCaption: props.emptyOptionCaption?.value,
31+
defaultValue: props.defaultValue?.value,
32+
parentChannelName: props.parentChannelName
33+
};
34+
}

0 commit comments

Comments
 (0)