Skip to content

Commit ad58bbc

Browse files
committed
feat: rework captions
- introduce new options to configure placeholder text and empty caption - show placeholder when widget is not open and empty - split emptySelectionCaption and emptyOptionCaption
1 parent c1d6c14 commit ad58bbc

23 files changed

+62
-29
lines changed

packages/modules/data-widgets/src/themesource/datawidgets/web/_datagrid-dropdown-filter.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ $root: ".widget-dropdown-filter";
281281
width: initial;
282282
}
283283

284-
&:not(:focus-within) {
284+
&:not(:focus-within):not([data-empty]) {
285285
#{$root}-input {
286286
opacity: 0;
287287
flex-shrink: 1;

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/DatagridDropdownFilter.editorConfig.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export function getProperties(values: DatagridDropdownFilterPreviewProps, defaul
2020
if (values.filterable) {
2121
hidePropertyIn(defaultProperties, values, "clearable");
2222
hidePropertyIn(defaultProperties, values, "emptyOptionCaption");
23+
} else {
24+
hidePropertyIn(defaultProperties, values, "filterInputPlaceholderCaption");
2325
}
2426

2527
if (!showSelectedItemsStyle) {
@@ -54,7 +56,7 @@ export const getPreview = (values: DatagridDropdownFilterPreviewProps, isDarkMod
5456
text({
5557
fontColor: palette.text.secondary,
5658
italic: true
57-
})(values.emptyOptionCaption || " ")
59+
})(values.emptySelectionCaption || " ")
5860
],
5961
grow: 1
6062
} as ContainerProps,

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/DatagridDropdownFilter.editorPreview.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ const noop = (): void => {};
2626

2727
function getPreviewValue(props: DatagridDropdownFilterPreviewProps): string {
2828
let value = props.defaultValue;
29-
if (!props.filterable) {
30-
value ||= props.emptyOptionCaption || "Select";
31-
} else {
32-
value ||= "Search";
33-
}
29+
value ||= props.emptySelectionCaption || (props.filterable ? "Search" : "Select");
3430
return value;
3531
}
3632

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/DatagridDropdownFilter.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ function Container(props: DatagridDropdownFilterContainerProps & Select_FilterAP
1616
parentChannelName: props.parentChannelName,
1717
name: props.name,
1818
multiselect: props.multiSelect,
19-
emptyCaption: props.emptyOptionCaption?.value,
19+
emptySelectionCaption: props.emptySelectionCaption?.value ?? "",
20+
emptyOptionCaption: props.emptyOptionCaption?.value ?? "",
21+
placeholder: props.filterInputPlaceholderCaption?.value ?? "",
2022
defaultValue: props.defaultValue?.value,
2123
filterable: props.filterable,
2224
selectionMethod: props.selectionMethod,

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/DatagridDropdownFilter.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,23 @@
8383
</property>
8484
</propertyGroup>
8585
</propertyGroup>
86-
<propertyGroup caption="Accessibility">
86+
<propertyGroup caption="Advanced">
8787
<propertyGroup caption="Accessibility">
8888
<property key="ariaLabel" type="textTemplate" required="false">
8989
<caption>Input caption</caption>
9090
<description>Assistive technology will read this upon reaching the input element.</description>
9191
</property>
9292
</propertyGroup>
93+
<propertyGroup caption="Texts">
94+
<property key="emptySelectionCaption" type="textTemplate" required="false">
95+
<caption>Empty selection caption</caption>
96+
<description>This text is shown if no options are selected. For example 'No options are selected' or 'Select color'.</description>
97+
</property>
98+
<property key="filterInputPlaceholderCaption" type="textTemplate" required="false">
99+
<caption>Filter input placeholder</caption>
100+
<description>This text is shown as placeholder for filterable filters. For example 'type to search'.</description>
101+
</property>
102+
</propertyGroup>
93103
</propertyGroup>
94104
</properties>
95105
</widget>

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/components/RefFilterContainer.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ export interface RefFilterContainerProps {
1818
ariaLabel?: string;
1919
className?: string;
2020
defaultValue?: string;
21-
emptyCaption?: string;
21+
emptyOptionCaption: string;
22+
emptySelectionCaption: string;
23+
placeholder: string;
2224
filterStore: RefFilterStore;
2325
multiselect: boolean;
2426
name: string;
@@ -80,6 +82,7 @@ const ComboboxWidget = observer(function ComboboxWidget(props: RefFilterContaine
8082
<Combobox
8183
options={ctrl2.options}
8284
inputPlaceholder={ctrl2.inputPlaceholder}
85+
emptyCaption={ctrl2.emptyCaption}
8386
useComboboxProps={ctrl2.useComboboxProps}
8487
onClear={ctrl2.handleClear}
8588
onFocus={ctrl2.handleFocus}
@@ -109,6 +112,7 @@ const TagPickerWidget = observer(function TagPickerWidget(props: RefFilterContai
109112
onFocus={ctrl3.handleFocus}
110113
onMenuScroll={handleMenuScroll}
111114
inputPlaceholder={ctrl3.inputPlaceholder}
115+
emptyCaption={ctrl3.emptyCaption}
112116
empty={ctrl3.isEmpty}
113117
showCheckboxes={props.selectionMethod === "checkbox"}
114118
selectedStyle={props.selectedItemsStyle}

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/components/StaticFilterContainer.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export interface StaticFilterContainerProps {
2222
ariaLabel?: string;
2323
className?: string;
2424
defaultValue?: string;
25-
emptyCaption?: string;
25+
emptyOptionCaption: string;
26+
emptySelectionCaption: string;
27+
placeholder: string;
2628
filterOptions: FilterOptionsType[];
2729
filterStore: StaticSelectFilterStore;
2830
multiselect: boolean;
@@ -81,6 +83,7 @@ const ComboboxWidget = observer(function ComboboxWidget(props: StaticFilterConta
8183
<Combobox
8284
options={ctrl2.options}
8385
inputPlaceholder={ctrl2.inputPlaceholder}
86+
emptyCaption={ctrl2.emptyCaption}
8487
useComboboxProps={ctrl2.useComboboxProps}
8588
onClear={ctrl2.handleClear}
8689
onFocus={ctrl2.handleFocus}
@@ -106,6 +109,7 @@ const TagPickerWidget = observer(function TagPickerWidget(props: StaticFilterCon
106109
onClear={ctrl3.handleClear}
107110
onBlur={ctrl3.handleBlur}
108111
inputPlaceholder={ctrl3.inputPlaceholder}
112+
emptyCaption={ctrl3.emptyCaption}
109113
empty={ctrl3.isEmpty}
110114
showCheckboxes={props.selectionMethod === "checkbox"}
111115
selectedStyle={props.selectedItemsStyle}

packages/pluggableWidgets/datagrid-dropdown-filter-web/typings/DatagridDropdownFilterProps.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export interface DatagridDropdownFilterContainerProps {
3737
valueAttribute?: EditableValue<string>;
3838
onChange?: ActionValue;
3939
ariaLabel?: DynamicValue<string>;
40+
emptySelectionCaption?: DynamicValue<string>;
41+
filterInputPlaceholderCaption?: DynamicValue<string>;
4042
}
4143

4244
export interface DatagridDropdownFilterPreviewProps {
@@ -62,4 +64,6 @@ export interface DatagridDropdownFilterPreviewProps {
6264
valueAttribute: string;
6365
onChange: {} | null;
6466
ariaLabel: string;
67+
emptySelectionCaption: string;
68+
filterInputPlaceholderCaption: string;
6569
}

packages/shared/widget-plugin-filtering/src/controllers/picker/PickerBaseController.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@ export interface PickerBaseControllerProps<S extends FilterStore> {
5858
multiselect: boolean;
5959
onChange?: ActionValue;
6060
valueAttribute?: EditableValue<string>;
61-
emptyCaption?: string;
61+
emptyOptionCaption?: string;
62+
emptySelectionCaption?: string;
6263
}

packages/shared/widget-plugin-filtering/src/controllers/picker/RefBaseController.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface RefBaseControllerProps {
3535
multiselect: boolean;
3636
onChange?: ActionValue;
3737
valueAttribute?: EditableValue<string>;
38-
emptyCaption?: string;
39-
placeholder?: string;
38+
emptyOptionCaption: string;
39+
emptySelectionCaption: string;
40+
placeholder: string;
4041
}

0 commit comments

Comments
 (0)