Skip to content

Commit 9f3e841

Browse files
committed
fix: remove value expose in favor of formatter
1 parent 2ce545f commit 9f3e841

File tree

5 files changed

+17
-33
lines changed

5 files changed

+17
-33
lines changed

packages/pluggableWidgets/combobox-web/src/Combobox.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { createElement, ReactElement } from "react";
22

33
import { ComboboxContainerProps } from "../typings/ComboboxProps";
44

5+
import { MultiSelection } from "./components/MultiSelection/MultiSelection";
6+
import { Placeholder } from "./components/Placeholder";
7+
import { SingleSelection } from "./components/SingleSelection/SingleSelection";
58
import { SelectionBaseProps } from "./helpers/types";
69
import { useActionEvents } from "./hooks/useActionEvents";
710
import { useGetSelector } from "./hooks/useGetSelector";
8-
import { Placeholder } from "./components/Placeholder";
9-
import { MultiSelection } from "./components/MultiSelection/MultiSelection";
10-
import { SingleSelection } from "./components/SingleSelection/SingleSelection";
1111

1212
import "./ui/Combobox.scss";
1313

packages/pluggableWidgets/combobox-web/src/components/SingleSelection/SingleSelection.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function SingleSelection({
5050
selector.caption,
5151
selector.caption.emptyCaption,
5252
selector.currentId,
53-
selector.caption.value?.value
53+
selector.caption.formatter
5454
]
5555
);
5656

packages/pluggableWidgets/combobox-web/src/helpers/Association/AssociationSimpleCaptionsProvider.tsx

+5-13
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
DynamicValue,
3-
EditableValue,
4-
ListAttributeValue,
5-
ListExpressionValue,
6-
ListWidgetValue,
7-
ObjectItem
8-
} from "mendix";
1+
import { DynamicValue, ListAttributeValue, ListExpressionValue, ListWidgetValue, ObjectItem } from "mendix";
92
import { ReactNode, createElement } from "react";
103
import { OptionsSourceAssociationCustomContentTypeEnum } from "../../../typings/ComboboxProps";
114
import { CaptionPlacement, CaptionsProvider } from "../types";
@@ -20,10 +13,9 @@ interface Props {
2013

2114
export class AssociationSimpleCaptionsProvider implements CaptionsProvider {
2215
private unavailableCaption = "<...>";
23-
private formatter?: ListExpressionValue<string> | ListAttributeValue<string>;
16+
formatter?: ListExpressionValue<string> | ListAttributeValue<string>;
2417
protected customContent?: ListWidgetValue;
2518
protected customContentType: OptionsSourceAssociationCustomContentTypeEnum = "no";
26-
value?: DynamicValue<string> | EditableValue<string>;
2719
emptyCaption = "";
2820

2921
constructor(private optionsMap: Map<string, ObjectItem>) {}
@@ -52,12 +44,12 @@ export class AssociationSimpleCaptionsProvider implements CaptionsProvider {
5244
return this.unavailableCaption;
5345
}
5446

55-
this.value = this.formatter.get(item);
56-
if (!this.value || this.value.status === "unavailable") {
47+
const captionValue = this.formatter.get(item);
48+
if (!captionValue || captionValue.status === "unavailable") {
5749
return this.unavailableCaption;
5850
}
5951

60-
return this.value.value ?? "";
52+
return captionValue.value ?? "";
6153
}
6254

6355
getCustomContent(value: string | null): ReactNode | null {

packages/pluggableWidgets/combobox-web/src/helpers/Database/DatabaseCaptionsProvider.tsx

+5-13
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
DynamicValue,
3-
EditableValue,
4-
ListAttributeValue,
5-
ListExpressionValue,
6-
ListWidgetValue,
7-
ObjectItem
8-
} from "mendix";
1+
import { DynamicValue, ListAttributeValue, ListExpressionValue, ListWidgetValue, ObjectItem } from "mendix";
92
import { ReactNode, createElement } from "react";
103
import { OptionsSourceAssociationCustomContentTypeEnum } from "../../../typings/ComboboxProps";
114
import { CaptionPlacement, CaptionsProvider } from "../types";
@@ -22,11 +15,10 @@ interface Props {
2215

2316
export class DatabaseCaptionsProvider implements CaptionsProvider {
2417
private unavailableCaption = "<...>";
25-
private formatter?: ListExpressionValue<string> | ListAttributeValue<string>;
18+
formatter?: ListExpressionValue<string> | ListAttributeValue<string>;
2619
protected customContent?: ListWidgetValue;
2720
protected customContentType: OptionsSourceAssociationCustomContentTypeEnum = "no";
2821
attribute?: ListAttributeValue<string | Big>;
29-
value?: DynamicValue<string> | EditableValue<string>;
3022
emptyCaption = "";
3123
overrideCaption: string | null | undefined = undefined;
3224

@@ -63,12 +55,12 @@ export class DatabaseCaptionsProvider implements CaptionsProvider {
6355
if (!item) {
6456
return this.unavailableCaption;
6557
}
66-
this.value = this.formatter?.get(item);
67-
if (this.value?.status === "unavailable") {
58+
const captionValue = this.formatter?.get(item);
59+
if (!captionValue || captionValue.status === "unavailable") {
6860
return this.unavailableCaption;
6961
}
7062

71-
return this.value?.value ?? "";
63+
return captionValue?.value ?? "";
7264
}
7365

7466
getCustomContent(value: string | null): ReactNode | null {

packages/pluggableWidgets/combobox-web/src/helpers/types.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ThreeStateCheckBoxEnum } from "@mendix/widget-plugin-component-kit/ThreeStateCheckBox";
2+
import { ListAttributeValue, ListExpressionValue, ListValue } from "mendix";
13
import { ReactNode } from "react";
24
import {
35
ComboboxContainerProps,
@@ -8,8 +10,6 @@ import {
810
SelectedItemsStyleEnum,
911
SelectionMethodEnum
1012
} from "../../typings/ComboboxProps";
11-
import { ThreeStateCheckBoxEnum } from "@mendix/widget-plugin-component-kit/ThreeStateCheckBox";
12-
import { DynamicValue, EditableValue, ListValue } from "mendix";
1313

1414
export type Status = "unavailable" | "loading" | "available";
1515
export type CaptionPlacement = "label" | "options";
@@ -21,7 +21,7 @@ export interface CaptionsProvider {
2121
get(value: string | null): string;
2222
render(value: (string | null) | (number | null), placement?: CaptionPlacement, htmlFor?: string): ReactNode;
2323
emptyCaption: string;
24-
value?: DynamicValue<string> | EditableValue<string>;
24+
formatter?: ListExpressionValue<string> | ListAttributeValue<string>;
2525
}
2626
export interface ValuesProvider<T> {
2727
get(key: string | null): T | undefined;

0 commit comments

Comments
 (0)