-
Notifications
You must be signed in to change notification settings - Fork 278
Expand file tree
/
Copy pathSearchFieldTemplate.tsx
More file actions
106 lines (101 loc) · 3.46 KB
/
SearchFieldTemplate.tsx
File metadata and controls
106 lines (101 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import Button from "@ui5/webcomponents/dist/Button.js";
import Icon from "@ui5/webcomponents/dist/Icon.js";
import Option from "@ui5/webcomponents/dist/Option.js";
import Select from "@ui5/webcomponents/dist/Select.js";
import type SearchField from "./SearchField.js";
import decline from "@ui5/webcomponents-icons/dist/decline.js";
import search from "@ui5/webcomponents-icons/dist/search.js";
import ButtonDesign from "@ui5/webcomponents/dist/types/ButtonDesign.js";
import BusyIndicator from "@ui5/webcomponents/dist/BusyIndicator.js";
export type SearchFieldTemplateOptions = {
/**
* If set to true, the search field will be expanded.
*/
forceExpanded?: boolean;
};
export default function SearchFieldTemplate(this: SearchField, options?: SearchFieldTemplateOptions) {
return (
!options?.forceExpanded && this.collapsed ? (
<Button
class="ui5-shell-search-field-button"
icon={search}
design={ButtonDesign.Transparent}
data-sap-focus-ref
loading={this.fieldLoading}
onClick={this._handleSearchIconPress}
tooltip={this._effectiveIconTooltip}
accessibleName={this._effectiveIconTooltip}
accessibilityAttributes={this._searchButtonAccessibilityAttributes}
></Button>
) : (
<BusyIndicator class="ui5-search-field-busy-indicator" active={this.fieldLoading}>
<div class="ui5-search-field-root" role="search" onFocusOut={this._onFocusOutSearch}>
<div class="ui5-search-field-content">
{this.scopes?.length ? (
<>
<Select
onChange={this._handleScopeChange}
class="sapUiSizeCompact ui5-search-field-select"
accessibleName={this._translations.scope}
tooltip={this._translations.scope}
value={this.scopeValue}
>
{this.scopes.map(scopeOption => (
<Option
value={scopeOption.value}
data-ui5-stable={scopeOption.stableDomRef}
ref={this.captureRef.bind(scopeOption)}
>{scopeOption.text}
</Option>
))}
</Select>
<div class="ui5-search-field-separator"></div>
</>
) : this.filterButton?.length ? (
<>
<div class="ui5-filter-wrapper" style="display: contents">
<slot name="filterButton"></slot>
</div>
<div class="ui5-search-field-separator"></div>
</>
) : null}
<input
class="ui5-search-field-inner-input"
role="searchbox"
aria-description={this.accessibleDescription}
aria-label={this.accessibleName || this._translations.searchFieldAriaLabel}
aria-autocomplete="both"
aria-controls="ui5-search-list"
value={this.value}
placeholder={this.placeholder}
data-sap-focus-ref
onInput={this._handleInput}
onFocusIn={this._onfocusin}
onFocusOut={this._onfocusout}
onKeyDown={this._onkeydown}
onClick={this._handleInnerClick} />
{this._effectiveShowClearIcon &&
<Icon
class="ui5-shell-search-field-icon"
name={decline}
showTooltip={true}
accessibleName={this._translations.clearIcon}
onClick={this._handleClear}
></Icon>
}
<Icon
class={{
"ui5-shell-search-field-icon": true,
"ui5-shell-search-field-search-icon": this._isSearchIcon,
}}
name={search}
showTooltip={true}
accessibleName={this._effectiveIconTooltip}
onClick={this._handleSearchIconPress}
></Icon>
</div>
</div>
</BusyIndicator>
)
);
}