@sourceloop/search-element 9.0.1 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +120 -0
- package/package.json +2 -3
- package/LICENSE +0 -21
- package/README.md +0 -243
- package/search-element.js +0 -3
- package/styles.css +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# [11.0.0](https://github.com/sourcefuse/arc-ng-components/compare/@sourceloop/search-element@10.0.0...@sourceloop/search-element@11.0.0) (2025-12-30)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **deps:** angular version upgrade and converted into workspace ([#65](https://github.com/sourcefuse/arc-ng-components/issues/65)) ([54dfe07](https://github.com/sourcefuse/arc-ng-components/commit/54dfe07c3834b206d4115f7932d9220ce2c73c44)), closes [#64](https://github.com/sourcefuse/arc-ng-components/issues/64)
|
|
11
|
+
|
|
12
|
+
### BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
- **deps:** YES
|
|
15
|
+
|
|
16
|
+
## Description
|
|
17
|
+
|
|
18
|
+
This pull request introduces significant refactoring and modernization
|
|
19
|
+
of the `SearchComponent` in the `search-lib` package, focusing on
|
|
20
|
+
adopting Angular's new signal-based inputs/outputs, streamlining
|
|
21
|
+
configuration management, and improving testability. Additionally, it
|
|
22
|
+
includes workspace and dependency updates at the root level, and some
|
|
23
|
+
cleanup of outdated scripts and files.
|
|
24
|
+
|
|
25
|
+
# [10.0.0](https://github.com/sourcefuse/arc-ng-components/compare/@sourceloop/search-element@9.0.1...@sourceloop/search-element@10.0.0) (2025-12-11)
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
- **search-client:** add support for angular v21 ([#52](https://github.com/sourcefuse/arc-ng-components/issues/52)) ([26486e8](https://github.com/sourcefuse/arc-ng-components/commit/26486e8c683f63e37b29e7a41bb9c806f9ffc90c)), closes [#50](https://github.com/sourcefuse/arc-ng-components/issues/50)
|
|
30
|
+
|
|
31
|
+
### BREAKING CHANGES
|
|
32
|
+
|
|
33
|
+
- **search-client:** YES
|
|
34
|
+
|
|
35
|
+
## Description
|
|
36
|
+
|
|
37
|
+
This pull request upgrades the Angular dependencies for the search
|
|
38
|
+
module and related packages from Angular v20 to Angular v21. It also
|
|
39
|
+
updates the deprecation notice in documentation to reflect this new
|
|
40
|
+
support window.
|
|
41
|
+
|
|
42
|
+
## [9.0.1](https://github.com/sourcefuse/arc-ng-components/compare/@sourceloop/search-element@9.0.0...@sourceloop/search-element@9.0.1) (2025-12-10)
|
|
43
|
+
|
|
44
|
+
**Note:** Version bump only for package @sourceloop/search-element
|
|
45
|
+
|
|
46
|
+
# [9.0.0](https://github.com/sourcefuse/arc-ng-components/compare/@sourceloop/search-element@8.0.1...@sourceloop/search-element@9.0.0) (2025-12-09)
|
|
47
|
+
|
|
48
|
+
### Features
|
|
49
|
+
|
|
50
|
+
- **deps:** add support for angular v20 ([#49](https://github.com/sourcefuse/arc-ng-components/issues/49)) ([3ef0a0f](https://github.com/sourcefuse/arc-ng-components/commit/3ef0a0fdb0e3de05c1645e9e55f2de1069bfc6fe)), closes [#48](https://github.com/sourcefuse/arc-ng-components/issues/48)
|
|
51
|
+
|
|
52
|
+
### BREAKING CHANGES
|
|
53
|
+
|
|
54
|
+
- **deps:** YES
|
|
55
|
+
|
|
56
|
+
## [8.0.1](https://github.com/sourcefuse/arc-ng-components/compare/@sourceloop/search-element@8.0.0...@sourceloop/search-element@8.0.1) (2025-12-09)
|
|
57
|
+
|
|
58
|
+
**Note:** Version bump only for package @sourceloop/search-element
|
|
59
|
+
|
|
60
|
+
# [8.0.0](https://github.com/sourcefuse/arc-ng-components/compare/@sourceloop/search-element@6.1.0...@sourceloop/search-element@8.0.0) (2025-12-09)
|
|
61
|
+
|
|
62
|
+
### Documentation
|
|
63
|
+
|
|
64
|
+
- **search-client:** update readme after upgrading to angular 17 ([#34](https://github.com/sourcefuse/arc-ng-components/issues/34)) ([2471785](https://github.com/sourcefuse/arc-ng-components/commit/247178534a7c5a4561fd54d38f19412e3b58beac)), closes [#30](https://github.com/sourcefuse/arc-ng-components/issues/30) [#30](https://github.com/sourcefuse/arc-ng-components/issues/30)
|
|
65
|
+
|
|
66
|
+
### Features
|
|
67
|
+
|
|
68
|
+
- **deps:** adds support for Angular 19 and migrates the component to a fully standalone structure ([#45](https://github.com/sourcefuse/arc-ng-components/issues/45)) ([8f7f7e3](https://github.com/sourcefuse/arc-ng-components/commit/8f7f7e3f46c3edefd87877bf886db7eb31716435)), closes [#42](https://github.com/sourcefuse/arc-ng-components/issues/42)
|
|
69
|
+
- **sandbox:** add ai-assistant sandbox example in package ([#22](https://github.com/sourcefuse/arc-ng-components/issues/22)) ([cfa4d20](https://github.com/sourcefuse/arc-ng-components/commit/cfa4d20bc9fc4fa93dbaf31b6a68ebe9a9f326ee))
|
|
70
|
+
|
|
71
|
+
### BREAKING CHANGES
|
|
72
|
+
|
|
73
|
+
- **deps:** YES
|
|
74
|
+
|
|
75
|
+
## Description
|
|
76
|
+
|
|
77
|
+
This pull request modernizes the `@sourceloop/search-client` library and
|
|
78
|
+
its example by upgrading to Angular 19, refactoring the search component
|
|
79
|
+
to be standalone, and updating documentation and configuration to
|
|
80
|
+
reflect these changes. The updates simplify integration for consumers
|
|
81
|
+
and leverage Angular's latest features for improved modularity and
|
|
82
|
+
maintainability.
|
|
83
|
+
|
|
84
|
+
- **search-client:**
|
|
85
|
+
|
|
86
|
+
# [7.0.0](https://github.com/sourcefuse/arc-ng-components/compare/@sourceloop/search-element@6.1.0...@sourceloop/search-element@7.0.0) (2025-07-18)
|
|
87
|
+
|
|
88
|
+
### Documentation
|
|
89
|
+
|
|
90
|
+
- **search-client:** update readme after upgrading to angular 17 ([#34](https://github.com/sourcefuse/arc-ng-components/issues/34)) ([2471785](https://github.com/sourcefuse/arc-ng-components/commit/247178534a7c5a4561fd54d38f19412e3b58beac)), closes [#30](https://github.com/sourcefuse/arc-ng-components/issues/30) [#30](https://github.com/sourcefuse/arc-ng-components/issues/30)
|
|
91
|
+
|
|
92
|
+
### Features
|
|
93
|
+
|
|
94
|
+
- **sandbox:** add ai-assistant sandbox example in package ([#22](https://github.com/sourcefuse/arc-ng-components/issues/22)) ([cfa4d20](https://github.com/sourcefuse/arc-ng-components/commit/cfa4d20bc9fc4fa93dbaf31b6a68ebe9a9f326ee))
|
|
95
|
+
|
|
96
|
+
### BREAKING CHANGES
|
|
97
|
+
|
|
98
|
+
- **search-client:**
|
|
99
|
+
|
|
100
|
+
# [6.1.0](https://github.com/sourcefuse/arc-ng-components/compare/@sourceloop/search-element@6.0.1...@sourceloop/search-element@6.1.0) (2024-04-10)
|
|
101
|
+
|
|
102
|
+
### Features
|
|
103
|
+
|
|
104
|
+
- **search-client:** allow custom allLabel ([#15](https://github.com/sourcefuse/arc-ng-components/issues/15)) ([8b45291](https://github.com/sourcefuse/arc-ng-components/commit/8b4529171ea587ff2fd8c733ccd50a819491fe47)), closes [#14](https://github.com/sourcefuse/arc-ng-components/issues/14)
|
|
105
|
+
|
|
106
|
+
## [6.0.1](https://github.com/sourcefuse/arc-ng-components/compare/@sourceloop/search-element@6.0.0...@sourceloop/search-element@6.0.1) (2024-01-12)
|
|
107
|
+
|
|
108
|
+
### Bug Fixes
|
|
109
|
+
|
|
110
|
+
- **search-client:** refactor the SCSS file in the search component to remove 'important' keyword ([#12](https://github.com/sourcefuse/arc-ng-components/issues/12)) ([1324f19](https://github.com/sourcefuse/arc-ng-components/commit/1324f194f3b3405505137d4a5919547195143175))
|
|
111
|
+
|
|
112
|
+
# 6.0.0 (2023-11-28)
|
|
113
|
+
|
|
114
|
+
### Features
|
|
115
|
+
|
|
116
|
+
- **deps:** add support for angular v14 ([#10](https://github.com/sourcefuse/arc-ng-components/issues/10)) ([acdb006](https://github.com/sourcefuse/arc-ng-components/commit/acdb006dc782f04283d0ce7e4335781e2f5360e3)), closes [#9](https://github.com/sourcefuse/arc-ng-components/issues/9) [#9](https://github.com/sourcefuse/arc-ng-components/issues/9)
|
|
117
|
+
|
|
118
|
+
### BREAKING CHANGES
|
|
119
|
+
|
|
120
|
+
- **deps:** search library does not support angular v13
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sourceloop/search-element",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "A global search element for search microservice. ",
|
|
5
5
|
"main": "./search-element.js",
|
|
6
6
|
"private": false,
|
|
@@ -19,6 +19,5 @@
|
|
|
19
19
|
},
|
|
20
20
|
"author": "Sourcefuse",
|
|
21
21
|
"license": "MIT",
|
|
22
|
-
"hash": "
|
|
23
|
-
"gitHead": "3717ce9eaadaae6b78c932d3a9b54a0cd3ea8ef5"
|
|
22
|
+
"hash": "6dd267d252bfc75383c89775926b88227dcc444d771549ac9d72b6871f6577dc"
|
|
24
23
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) [2023] [SourceFuse]
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
# Search Library
|
|
2
|
-
|
|
3
|
-
An Angular module that exports a component that can enable users to search over configured models using the search microservice provided in the sourceloop microservice catalog.
|
|
4
|
-
|
|
5
|
-
### Deprecation Notice
|
|
6
|
-
|
|
7
|
-
Search-client now supports Angular v20, we will provide support for the older version that is based on Angular v19 till 30th June 2026 .
|
|
8
|
-
|
|
9
|
-
## Angular Module
|
|
10
|
-
|
|
11
|
-
### Installation
|
|
12
|
-
|
|
13
|
-
```sh
|
|
14
|
-
npm i @sourceloop/search-client
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### Usage
|
|
18
|
-
|
|
19
|
-
Create a new Application using Angular CLI and import the `SearchComponent` in your application.SearchComponent is now a standalone component, so no NgModule is required.Also create a new service that implements the ISearchService interface exported by the search library. This service will be used by the exported component to make API calls whenever needed. You will have to update the providers section of your module with { provide: SEARCH_SERVICE_TOKEN, useExisting: Your_Service_Name }
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
import { Component } from '@angular/core';
|
|
23
|
-
import { SearchComponent, SEARCH_SERVICE_TOKEN } from '@sourceloop/search-client';
|
|
24
|
-
import { SearchService } from './search.service';
|
|
25
|
-
|
|
26
|
-
@Component({
|
|
27
|
-
selector: 'app-root',
|
|
28
|
-
standalone: true,
|
|
29
|
-
imports: [SearchComponent],
|
|
30
|
-
templateUrl: './app.component.html',
|
|
31
|
-
providers: [{ provide: SEARCH_SERVICE_TOKEN, useClass: SearchService }],
|
|
32
|
-
})
|
|
33
|
-
export class AppComponent {}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Search Service
|
|
37
|
-
|
|
38
|
-
Create a new service using the Angular CLI. This service should implement ISearchService. You will have to implement searchApiRequest method which should return Observable<T[]>. Here T refers to the type of data returned from the search microservice. If you are using the default settings for the search microservice you can use IDefaultReturnType interface, else you need to pass your own return type interface.
|
|
39
|
-
searchApiRequest receives two parameters - requestParameters: ISearchQuery, saveInRecents: boolean,
|
|
40
|
-
|
|
41
|
-
```ts
|
|
42
|
-
export interface ISearchQuery {
|
|
43
|
-
match: string;
|
|
44
|
-
limit: number | null;
|
|
45
|
-
order: string | null;
|
|
46
|
-
limitByType: boolean | null;
|
|
47
|
-
offset: number | null;
|
|
48
|
-
sources: string[] | null;
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Implementing the recentSearchApiRequest method is optional and its implementation depends on if you want recent search functionality as a part of the search suggestions dropdown
|
|
53
|
-
|
|
54
|
-
### Configuration
|
|
55
|
-
|
|
56
|
-
You need to provide some configuration for using the search component using its selector - '<sourceloop-search></sourceloop-search>'
|
|
57
|
-
This can be provided as an Object of Configuration type as input to the component. To do so, create a property/field in your component of type Configuration<IDefaultReturnType> (IDefaultReturnType can be replaced by your own return type interface). In the constructor initialize the Configuration object with the following properties:
|
|
58
|
-
|
|
59
|
-
- **displayPropertyName (keyof IDefaultReturnType/Your_Return_Type) :** This is one of the properties returned by the search microservice. It is the property whose value will be displayed in the search dropdown.
|
|
60
|
-
- **models ( Array<IModel>) :** You need to provide the list of models you used in your search microservice. You also need to provide the displayName for each Model, this will be used in the search dropdown and categorize button dropdown.
|
|
61
|
-
|
|
62
|
-
Apart from these there are some optional properties that you can give:
|
|
63
|
-
|
|
64
|
-
- **limit (number) :** The number of results you want to display. Default value is 20.
|
|
65
|
-
- **limitByType (boolean) :** Option to put limit on basis of model. Default value is false.
|
|
66
|
-
- **order (Array<string>) :** Array of strings that specify the order format for the request sent to search API. Example, you want your results to be sorted on basis of name property first and then description. In this case you can give order = ["name ASC", "description DESC"]. By default order = []
|
|
67
|
-
- **offset (number) :** Number of matched results to skip. Default is 0.
|
|
68
|
-
- **saveInRecents (boolean) :** Option for saving the search results of the user. Default value is true.
|
|
69
|
-
- **categorizeResults (boolean) :** Option for displaying results in search dropdown according to the Model they come from. Default value is true.
|
|
70
|
-
- **hideRecentSearch (boolean) :** Option to provide recent search functionality. Default value is false.
|
|
71
|
-
- **hideCategorizeButton (boolean) :** Option to hide the categorize button on the right of search dropdown. Default is false.
|
|
72
|
-
- **saveInRecentsOnlyOnEnter (boolean) :** Option to save search query in recent searches only when user presses enter key or changes the category he/she is searching on. Default value is false.
|
|
73
|
-
- **searchOnlyOnEnter (boolean) :** Option to call API to display search results only when user presses enter key. Default value is false.
|
|
74
|
-
- **noResultMessage (string) :** Message to display in dropdown incase no matching result found.
|
|
75
|
-
- **searchIconClass (string) :** Can be used to give custom icon for search in search bar.
|
|
76
|
-
- **crossIconClass (string) :** Can be used to give custom icon for clearing text input in search bar.
|
|
77
|
-
- **dropDownButtonIconClass (string) :** Can be used to give custom icon for category drop down button.
|
|
78
|
-
- **recentSearchIconClass (string) :** Can be used to give custom icon for recent searches displayed in the search dropdown.
|
|
79
|
-
|
|
80
|
-
Your component might look something like
|
|
81
|
-
|
|
82
|
-
```ts
|
|
83
|
-
export class XComponent implements OnInit {
|
|
84
|
-
config: Configuration<IDefaultReturnType>;
|
|
85
|
-
|
|
86
|
-
constructor(private fb: FormBuilder) {
|
|
87
|
-
this.config = new Configuration<IDefaultReturnType>({
|
|
88
|
-
displayPropertyName: 'name',
|
|
89
|
-
models: [
|
|
90
|
-
{
|
|
91
|
-
name: 'ToDo',
|
|
92
|
-
displayName: 'List',
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: 'User',
|
|
96
|
-
displayName: 'Users',
|
|
97
|
-
imageUrl: 'https://picsum.photos/id/1/50',
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
order: [`name ASC`, `description DESC`],
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
ngOnInit(): void {}
|
|
105
|
-
}
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
Now in your template you can add the search library component selector like
|
|
109
|
-
|
|
110
|
-
```ts
|
|
111
|
-
<sourceloop-search [config]="config" [(ngModel)]="value"></sourceloop-search>
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
You can access the value in the search input using [(ngModel)]. You can also listen to clicked and searched events.
|
|
115
|
-
Clicked event is of type ItemClickedEvent. It is emitted when user clicks one of the suggested results. Searched event is emitted when request is made to the api when user types and relevant suggestinons are displayed. It is of type RecentSearchEvent.
|
|
116
|
-
|
|
117
|
-
```ts
|
|
118
|
-
type ItemClickedEvent<T> = {
|
|
119
|
-
event: MouseEvent;
|
|
120
|
-
item: T;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
type RecentSearchEvent = {
|
|
124
|
-
event: KeyboardEvent | Event;
|
|
125
|
-
keyword: string;
|
|
126
|
-
category: 'All' | IModel;
|
|
127
|
-
};
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
```html
|
|
131
|
-
<sourceloop-search
|
|
132
|
-
[config]="config"
|
|
133
|
-
[(ngModel)]="value"
|
|
134
|
-
(clicked)="logItemClickedEvent($event)"
|
|
135
|
-
(searched)="logRecentSearchEvent($event)"
|
|
136
|
-
disabled="false"
|
|
137
|
-
></sourceloop-search>
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### Icons
|
|
141
|
-
|
|
142
|
-
To use the default icons you will have to import the following in your styles.scss:
|
|
143
|
-
|
|
144
|
-
```
|
|
145
|
-
@import '../node_modules/@sourceloop/search-client/assets/icomoon/style.css';
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
You can also choose to use your own icons by providing classes for icons in the configuration.
|
|
149
|
-
|
|
150
|
-
## Web Component
|
|
151
|
-
|
|
152
|
-
This library is also available as a [Web Component](https://developer.mozilla.org/en-US/docs/Web/Web_Components) so users of frameworks like React and Vue can also integrate this search element in their application with minimal effort.
|
|
153
|
-
|
|
154
|
-
### Installation
|
|
155
|
-
|
|
156
|
-
```sh
|
|
157
|
-
npm i @sourceloop/search-client
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
In the node modules you can find two files relevant to the element - `element/search-element.js` and `element/style.css`. How you serve and include these files in your non Angular project depend on the framework that you are using. For example, for Vanilla JS and HTML you can simply import the js and styles in your HTML ->
|
|
161
|
-
|
|
162
|
-
```html
|
|
163
|
-
<script type="text/javascript" src="search-element.js"></script>
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### Usage
|
|
167
|
-
|
|
168
|
-
The web component accepts all the same inputs and services as the regular Angular Module, but instead of passing them through bindings and DI, you pass them as properties of the element as shown below.
|
|
169
|
-
|
|
170
|
-
```html
|
|
171
|
-
<!DOCTYPE html>
|
|
172
|
-
<html>
|
|
173
|
-
<head>
|
|
174
|
-
...
|
|
175
|
-
<link rel="stylesheet" href="assets/icomoon/style.css" />
|
|
176
|
-
<link rel="stylesheet" href="styles.css" />
|
|
177
|
-
...
|
|
178
|
-
</head>
|
|
179
|
-
<body>
|
|
180
|
-
<sourceloop-search-element></sourceloop-search-element>
|
|
181
|
-
<script type="text/javascript" src="search-element.js"></script>
|
|
182
|
-
<script>
|
|
183
|
-
document.addEventListener('DOMContentLoaded', () => {
|
|
184
|
-
const element = document.querySelector('sourceloop-search-element');
|
|
185
|
-
// Code to set inputs of the component
|
|
186
|
-
element.searchProvider = {
|
|
187
|
-
searchApiRequestWithPromise: () =>
|
|
188
|
-
Promise.resolve([
|
|
189
|
-
{
|
|
190
|
-
name: 'Test',
|
|
191
|
-
description: 'Test',
|
|
192
|
-
rank: 0.4,
|
|
193
|
-
source: 'ToDo',
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
name: 'Akshat',
|
|
197
|
-
description: 'Dubey',
|
|
198
|
-
rank: 0.4,
|
|
199
|
-
source: 'User',
|
|
200
|
-
},
|
|
201
|
-
]),
|
|
202
|
-
recentSearchApiRequestWithPromise: () => Promise.resolve([]),
|
|
203
|
-
};
|
|
204
|
-
element.config = new SearchConfiguration({
|
|
205
|
-
displayPropertyName: 'name',
|
|
206
|
-
models: [
|
|
207
|
-
{
|
|
208
|
-
name: 'ToDo',
|
|
209
|
-
displayName: 'List',
|
|
210
|
-
imageUrl: 'https://picsum.photos/id/1000/50',
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
name: 'User',
|
|
214
|
-
displayName: 'Users',
|
|
215
|
-
imageUrl: 'https://picsum.photos/id/1/50',
|
|
216
|
-
},
|
|
217
|
-
],
|
|
218
|
-
order: [`name ASC`, `description DESC`],
|
|
219
|
-
hideCategorizeButton: false,
|
|
220
|
-
placeholder: 'Search Programs, Projects or Dashboards',
|
|
221
|
-
categorizeResults: true,
|
|
222
|
-
saveInRecents: true,
|
|
223
|
-
limit: 4,
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
</script>
|
|
227
|
-
</body>
|
|
228
|
-
</html>
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
Note that the instance of `SearchService` passed to the element is following a different interface -
|
|
232
|
-
|
|
233
|
-
```ts
|
|
234
|
-
export interface ISearchServiceWithPromises<T extends IReturnType> {
|
|
235
|
-
searchApiRequestWithPromise(
|
|
236
|
-
requestParameters: ISearchQuery,
|
|
237
|
-
saveInRecents: boolean,
|
|
238
|
-
): Promise<T[]>;
|
|
239
|
-
recentSearchApiRequestWithPromise?(): Promise<ISearchQuery[]>;
|
|
240
|
-
}
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
This facilitates the use of the `Web Component` without relying on [rxjs](https://rxjs.dev/). You can still use the `Observable` based service if you want by importing the rxjs library manually.
|