@@ -18,23 +18,36 @@ public struct TypeaheadCatalog: View {
18
18
19
19
private var assetsUsers = Mocks . assetesMultipleUsers
20
20
@State private var searchTextUsers : String = " "
21
- @State private var selectedUsers : [ PBTypeahead . Option ] = [ Mocks . assetesMultipleUsers [ 0 ] , Mocks . assetesMultipleUsers [ 1 ] ]
21
+ @State private var selectedUsers : [ PBTypeahead . Option ] = [
22
+ Mocks . assetesMultipleUsers [ 0 ] ,
23
+ Mocks . assetesMultipleUsers [ 1 ]
24
+ ]
22
25
@FocusState private var isFocusedUsers
23
26
24
27
@State private var searchTextDeselectedUsers : String = " "
25
- @State private var selectedUsersDeselected : [ PBTypeahead . Option ] = [ Mocks . assetesMultipleUsers [ 0 ] , Mocks . assetesMultipleUsers [ 1 ] ]
28
+ @State private var selectedUsersDeselected : [ PBTypeahead . Option ] = [
29
+ Mocks . assetesMultipleUsers [ 0 ] ,
30
+ Mocks . assetesMultipleUsers [ 1 ]
31
+ ]
26
32
@State private var deselectedUsers : [ PBTypeahead . Option ] = [ ]
27
33
@FocusState private var isFocusedDeselectedUsers
28
34
29
35
@State private var searchTextHeight : String = " "
30
- @State private var selectedHeight : [ PBTypeahead . Option ] = [ Mocks . assetesMultipleUsers [ 3 ] , Mocks . assetesMultipleUsers [ 2 ] ]
36
+ @State private var selectedHeight : [ PBTypeahead . Option ] = [
37
+ Mocks . assetesMultipleUsers [ 3 ] ,
38
+ Mocks . assetesMultipleUsers [ 2 ]
39
+ ]
31
40
@FocusState private var isFocusedHeight
32
41
33
42
private var assetsSection : [ PBTypeahead . OptionType ] = Mocks . assetsSectionUsers
34
43
@State private var searchTextSections : String = " "
35
44
@State private var selectedSections : [ PBTypeahead . Option ] = [ ]
36
45
@FocusState private var isFocusedSection
37
46
47
+ @State private var searchTextNoOptions : String = " "
48
+ @State private var selectedNoOptions : [ PBTypeahead . Option ] = [ ]
49
+ @FocusState private var isFocusedNoOptions
50
+
38
51
@State private var presentDialog : Bool = false
39
52
private var popoverManager = PopoverManager . shared
40
53
@@ -48,6 +61,7 @@ public struct TypeaheadCatalog: View {
48
61
#endif
49
62
PBDoc ( title: " Height Adjusted Dropdown " , spacing: Spacing . small) { heightAdjusted }
50
63
PBDoc ( title: " Sections " , spacing: Spacing . small) { sections }
64
+ PBDoc ( title: " No Options " , spacing: Spacing . small) { noOptions }
51
65
. padding ( . bottom, 500 )
52
66
}
53
67
. scrollDismissesKeyboard ( . immediately)
@@ -136,6 +150,40 @@ extension TypeaheadCatalog {
136
150
)
137
151
}
138
152
153
+ var noOptions : some View {
154
+ PBTypeahead (
155
+ id: 5 ,
156
+ title: " Users " ,
157
+ placeholder: " type the name of a user " ,
158
+ searchText: $searchTextNoOptions,
159
+ options: assetsUsers,
160
+ selection: . multiple( variant: . pill) ,
161
+ isFocused: $isFocusedNoOptions,
162
+ selectedOptions: $selectedNoOptions,
163
+ noOptionsView: {
164
+ customNoOptionsText
165
+ }
166
+ )
167
+ }
168
+
169
+ var customNoOptionsText : some View {
170
+ #if os(macOS)
171
+ HStack ( spacing: Spacing . none) {
172
+ Text ( " No results found. Review user name for accuracy or " )
173
+ PBButton ( variant: . link, title: " add user name. " )
174
+ }
175
+ . frame ( maxWidth: . infinity, alignment: . center)
176
+ . pbFont ( . detail( false ) , color: . text( . light) )
177
+ #elseif os(iOS)
178
+ VStack {
179
+ Text ( " No results found. Review user name for accuracy or " )
180
+ PBButton ( variant: . link, title: " add user name. " )
181
+ }
182
+ . fixedSize ( horizontal: true , vertical: false )
183
+ . pbFont ( . detail( false ) , color: . text( . light) )
184
+ #endif
185
+ }
186
+
139
187
var dialog : some View {
140
188
PBButton ( title: " Simple " ) {
141
189
DialogCatalog . disableAnimation ( )
@@ -144,9 +192,9 @@ extension TypeaheadCatalog {
144
192
. presentationMode ( isPresented: $presentDialog) {
145
193
DialogView ( isPresented: $presentDialog)
146
194
. popoverHandler ( id: 6 )
147
- #if os(macOS)
195
+ #if os(macOS)
148
196
. frame( minWidth: 500 , minHeight: 390 )
149
- #endif
197
+ #endif
150
198
}
151
199
}
152
200
0 commit comments