ng-jvx-multiselect 19.0.37 → 20.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/README.md CHANGED
@@ -1,359 +1,359 @@
1
- # NgJvxMultiselect
2
-
3
- ng-jvx-multiselect is a select based on angular. It handles both single and multiple selections and allows to
4
- retrieves the options via asynchronous calls.
5
-
6
- <h2 style="color:red">IMPORTANT</h2>
7
- ng-jvx-multiselect now follows the standalone components paradigm.
8
- You must import NgJvxMultiselectComponent and any related directives directly within the consuming component.
9
-
10
- ## Install ng-jvx-multiselect
11
-
12
- ```
13
- npm install ng-jvx-multiselect --save
14
- ```
15
-
16
-
17
- In <b>styles.scss</b>
18
-
19
- ```scss
20
- @use 'index' as ng-jvx-multiselect;
21
-
22
- :root {
23
- --jvx-multiselect-primary: #008000;
24
- --jvx-multiselect-accent: #0000FF;
25
- --jvx-multiselect-warn: #FF0000;
26
- --jvx-multiselect-on-primary: #ffffff;
27
- --jvx-multiselect-on-accent: currentcolor;
28
- --jvx-multiselect-on-warn: currentcolor;
29
- --jvx-multiselect-panel-bg: #FFFFFF
30
- }
31
- ```
32
- In <b>example.component.html</b>
33
-
34
- ```angular2html
35
- <ng-jvx-multiselect style="width: 100%" [options]="options">
36
- <ng-container placeholder>
37
- this is a placeholder
38
- </ng-container>
39
- </ng-jvx-multiselect>
40
- ```
41
- In <b>example.component.ts</b>
42
-
43
- ```typescript
44
- public options = [
45
- {value: 1, text: 'text 1'},
46
- {value: 2, text: 'text 2'},
47
- {value: 3, text: 'text 3'},
48
- {value: 4, text: 'text 4'},
49
- {value: 5, text: 'text 5'},
50
- {value: 6, text: 'text 6'},
51
- {value: 7, text: 'text 7'},
52
- {value: 8, text: 'text 8'},
53
- {value: 9, text: 'text 9'},
54
- {value: 10, text: 'text 10'}];
55
- ```
56
- ![result](https://github.com/giovanni-venturelli/ng-jvx-multiselect/blob/main/blob/basic_usage.gif)
57
-
58
- ## API
59
-
60
- ### Slots
61
-
62
- | Name | Description |
63
- |---------------|------------------------------------------------------------------------------------------------------------|
64
- | `default` | Using the default slot is one way of defining the options via the component `<ng-jvx-option>`. |
65
- | `placeholder` | This slot allows the user to define a placeholder which will be displayed when no selection has been made. |
66
-
67
- ### Inputs
68
-
69
- | Name | Type | Default | Description |
70
- |------------------|----------------------------------------------------------|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
71
- | `clearable` | `Boolean` | `false` | True to enable the empty selection. |
72
- | `closeButton` | `Boolean` | `false` | True to show the button that closes the menu. |
73
- | `disabled` | `Boolean` | `false` | True to disable the select. |
74
- | `itemText` | `String` | `'text'` | The name of the property of the option object that will be displayed as description of the options. |
75
- | `itemValue` | `String` | `'value'` | The name of the property of the option object that will be treated as value of the options. |
76
- | `multi` | `Boolean` | `false` | True if it's a multiselect. |
77
- | `options` | `Array` | `[]` | Array of option objects. |
78
- | `requestHeaders` | `Object` | `{...}` | The headers of the HTTP request. |
79
- | `requestType` | <code>'GET'&#124;'POST'</code> | `'GET'` | The type of the HTTP request. |
80
- | `postPayload` | `Object` | {} | Sets the payload for the post request. |
81
- | `searchInput` | `Boolean` | `false` | True to enable the search input for the options list. |
82
- | `searchMode` | <code>'client'&#124;'server'</code> | `server` | `'client'` if the search is only client side, `'server'` if it's server side. |
83
- | `searchLabel` | `String` | `'search'` | The label of the search input. |
84
- | `searchProp` | `String` | `'search'` | The name of the search property of the HTTP request. |
85
- | `listProp` | `String` | `''` | Name of the property in response.data where the list is stored. |
86
- | `url` | `String` | `''` | The url to get the options. |
87
- | `value` | `Array` | `[]` | The current value of the selection. |
88
- | `mapper` | `NgJvxOptionMapper` | `*` | The object that will map the response of the async call. |
89
- | `searchMapper` | `NgJvxSearchMapper` | `*` | The object that will map the client search result. |
90
- | `pageSize` | `number` | `15` | The size of a page for pagination purposes. |
91
- | `groupBy` | <code>NgJvxGroupMapper<any>&#124;string&#124;null</code> | `null` | If it's a `string` it defines the the property of each option by which group them in the list. If it's a `NgJvxGroupMapper` it offers a method that groups the options (useful for nested properties). |
92
-
93
- ### Methods
94
-
95
- *None*
96
-
97
- ### Events
98
-
99
- | Event Name | Detail | Description |
100
- |---------------|---------|-----------------------------------------------------------------------------------------------------|
101
- | `valueChange` | `Array` | Fired when the user changes the value of the input. The detail contains the value of the selection. |
102
- | `scrollEnd` | *None* | Fired when the scrollbar in the options menu reaches the bottom. |
103
- | `open` | *None* | Fired when the the menu starts opening. |
104
- | `opened` | *None* | Fired when the the menu is opened. |
105
- | `close` | *None* | Fired when the the menu starts closing. |
106
- | `closed` | *None* | Fired when the the menu is closed. |
107
-
108
- ### Groups
109
-
110
- It is possible to collect the options in groups. To do so the user can set the property `groupBy` with the name of the property they want to group the options by.
111
- If the property is nested or the user wants to implement a more complex grouping algorithm, they set the property `groupBy` with an object that implements the interface `NgJvxGroupMapper<T>`.
112
- This object offers the method
113
- ```typescript
114
- mapGroup(option: T): Observable<NgJvxGroup<T>>
115
- ```
116
- with
117
- ```typescript
118
- interface NgJvxGroup<T> {
119
- group: string;
120
- option: T;
121
- }
122
- ```
123
- The `mapGroup` method hence takes the option and wraps it in an object that defines the name of the group it belongs to.
124
- It is possible to define the look of the headers of the groups with the directive [*ngJvxGroupHeaderTemplate](#ngjvxgroupheadertemplate)
125
- ### HTTP Request
126
-
127
- #### Request
128
-
129
- The HTTP request can be either a GET or a POST request. The user can set the type using the property `requestType` which
130
- is set to `'GET'` by default.
131
-
132
- ##### Headers
133
-
134
- The headers can be set in the property `requestHeaders`. By default the ng-jvx-multiselect uses the property `trusted`
135
- stored in the sessionStorage. The default headers are:
136
-
137
- ```javascript
138
- var requestHeaders = {
139
- 'Accept': 'application/json',
140
- 'Access-Control-Allow-Origin': '*',
141
- 'Access-Control-Allow-Methods': 'GET, PUT, POST, DELETE, OPTIONS',
142
- 'Content-Type': 'application/json',
143
- 'Authorization': window.sessionStorage.getItem('trusted')
144
- }
145
- ```
146
-
147
- #### Response
148
-
149
- The response must contain an array of elements.
150
-
151
- The property `listProp` defines the path of the array in the response object (i.e. if `listProp` is set to `list` the
152
- ng-jvx-multiselect will get the options in the array stored in the path `response.list`).
153
-
154
- #### Mapper
155
-
156
- The `mapper` property will be an object implementing the interface `NgJvxOptionMapper<T>`. It will expose a
157
- method `mapOption` which accepts the option to be mapped in the form of an Object and returns an Observable of type `T`.
158
- For example if the request returns an array of objects like this:
159
-
160
- ```javascript
161
- {
162
- id: number;
163
- description: string;
164
- }
165
- ```
166
-
167
- it is possible to write a mapper like this:
168
-
169
- ```javascript
170
- const mapper: NgJvxOptionMapper<{value: number, text: string}> = {
171
- mapOption(source: {
172
- id: number,
173
- description: string
174
- }): Observable<any> {
175
- return of({value: source.id, text: source.description});
176
- }
177
- }
178
- ```
179
-
180
- The `multiMapper` property works like the `mapper` property, it implements the interface `NgJvxOptionsMapper<T>`.
181
- It will expose a method `mapOptions` which accepts all the options to be mapped in the form of an Object and returns an Observable of type `T[]`.
182
- For example if the request returns an array of objects like this:
183
-
184
- ```javascript
185
- {
186
- id: number;
187
- description: string;
188
- }
189
- ```
190
-
191
- it is possible to write a mapper like this:
192
-
193
- ```javascript
194
- const mapper: NgJvxOptionMultiMapper<{value: number, text: string}> = {
195
- mapOption(source: {
196
- id: number,
197
- description: string
198
- }[]): Observable<any> {
199
- return of(source.map(s=>{value: s.id, text: s.description}));
200
- }
201
- }
202
- ```
203
-
204
- It's useful if the user wants to add any custom option to a server call
205
- #### Search
206
-
207
- If the property `searchInput` is `true`, the user will be able to search a value amongst the options.
208
- `searchProp` defines the name of the property for the HTTP call.
209
-
210
- ##### searchMapper
211
-
212
- The `searchMapper` property is an object implementing the interface `NgJvxSearchMapper<T>`. It exposes the
213
- method `mapSearch` which accepts the value of the search (a string) and an array of the selectable options.
214
- The method returns an Observable of type `T[]`.
215
- The value of the returned Observable will then be used as the new option list.
216
- This property is only useful for a client side search.
217
-
218
- For example:
219
- ```typescript
220
- const searchMapper: NgJvxSearchMapper<{text: string, value: number}> = {
221
- mapSearch: (source: string, options: {text: string, value: number}[]): Observable<{text: string, value: number}[]> => {
222
- return of(options.filter(o => o.text.toLowerCase().includes(source.toLowerCase())));
223
- }
224
- }
225
- ```
226
-
227
- ### Slots
228
-
229
- #### default
230
-
231
- The default slot allows to define the options directly via html. It's not compatible with the `url` parameter. The
232
- options shall be wrapped in the `<ng-jvx-option>` component. The slot shall not be wrapped in the `<ng-jvx-option>`
233
- component if it's decorated with one of the available directives, since it will have different purposes.
234
-
235
- #### placeholder
236
-
237
- The slot `placeholder` will define the placeholder. It's shown only when the selection's value is empty.
238
-
239
- ### Directives
240
-
241
- #### ngJvxOptionsTemplate
242
-
243
- When an element inside the `ng-jvx-multiselect` is decorated with this directive it becomes the template for the options
244
- of the select. The directive provides a context. i.e.: Let's say we have the following structure:
245
-
246
- ```javascript
247
- var options = [{
248
- value: 1,
249
- text: 'Lorem ipsum',
250
- color: 'blue',
251
- preview: 'path/to/first-image.jpg'
252
- },
253
- {
254
- value: 2,
255
- text: 'dolor sit amet',
256
- color: 'red',
257
- preview: 'path/to/second-image.jpg'
258
- }];
259
- ```
260
-
261
- and we want our options to have in the text field both the property color and the property text. We can write the
262
- template like so:
263
-
264
- ```angular2html
265
- <div *ngJvxOptionsTemplate="let option">{{option.color}} {{option.text}}</div>
266
- ```
267
-
268
- It's possible to use the context inside attributes too. i.e.
269
-
270
- ```angular2html
271
- <div *ngJvxOptionsTemplate="let option">
272
- <span>{{option.text}}</span>
273
- <span>
274
- <img src="{{option.preview}}"/>
275
- </span>
276
- </div>
277
- ```
278
-
279
- #### *ngJvxSelectionTemplate
280
-
281
- This directive works exactly as the `ngJvxOptionsTemplate` except it defines the selection template.
282
- In case of a multiple selection the context is the array of the selected options, for the non-multiple selection the
283
- context is the selected option.
284
-
285
- #### *ngJvxGroupHeaderTemplate
286
-
287
- When an element inside the `ng-jvx-multiselect` is decorated with this directive it becomes the template for the header
288
- of the groups by which the options are devided. The directive provides a context which describes the group with its
289
- options in the following form:
290
-
291
- ```typescript
292
- {
293
- group: any;
294
- options: any[];
295
- }
296
- ```
297
-
298
- i.e.: with the following structure:
299
-
300
- ```typescript
301
- const options = [{
302
- value: 'dog',
303
- text: 'the dog',
304
- type: 'mammal'
305
- }, {
306
- value: 'lizard',
307
- text: 'the lizard',
308
- type: 'reptile'
309
- }, {
310
- value: 'cat',
311
- text: 'the cat',
312
- type: 'mammal'
313
- }];
314
- ```
315
-
316
- and we want the header of each group be in the form of 'Type of animal: [mammal | reptile]'. We'll do as follows:
317
-
318
- ```angular2html
319
-
320
- <div *ngJvxGroupHeaderTemplate="let g">Type of animal: {{g.group}}</div>
321
- ```
322
-
323
- #### *ngJvxDisabledOption
324
-
325
- This directive disables the selection of the host option. i.e.
326
-
327
- ```angular2html
328
-
329
- <div *ngJvxOptionsTemplate="let option" [ngJvxDisabledOption]="option.text === 'text of the disabled option'">
330
- <span>{{option.text}}</span>
331
- <span>
332
- <img src="{{option.preview}}"/>
333
- </span>
334
- </div>
335
- ```
336
-
337
- ## NgJvxMultiselectChipComponent
338
-
339
- This component is used by `ng-jvx-multiselect` to render each selected item as a removable “chip” when `multi` is enabled. Chips provide a compact visual representation of the current selection and offer a quick way to remove individual items.
340
-
341
- It is created and managed internally by the multiselect; typical applications do not need to instantiate it directly.
342
-
343
- ### Inputs
344
-
345
- *None*
346
-
347
- ### Methods
348
-
349
- *None*
350
-
351
- ### Events
352
-
353
- | Event Name | Detail | Description |
354
- |------------|--------|-----------------------------------------------------------------------------|
355
- | `removed` | `any` | Fired when the user clicks the chip’s remove action. The detail is the option represented by the chip. |
356
-
357
- Notes:
358
- - When a chip emits `removed`, the multiselect removes the corresponding item from the selection.
359
- - The event is handled internally by the multiselect component; consumers usually interact with selection changes via the parent’s `valueChange` event.
1
+ # NgJvxMultiselect
2
+
3
+ ng-jvx-multiselect is a select based on angular. It handles both single and multiple selections and allows to
4
+ retrieves the options via asynchronous calls.
5
+
6
+ <h2 style="color:red">IMPORTANT</h2>
7
+ ng-jvx-multiselect now follows the standalone components paradigm.
8
+ You must import NgJvxMultiselectComponent and any related directives directly within the consuming component.
9
+
10
+ ## Install ng-jvx-multiselect
11
+
12
+ ```
13
+ npm install ng-jvx-multiselect --save
14
+ ```
15
+
16
+
17
+ In <b>styles.scss</b>
18
+
19
+ ```scss
20
+ @use 'index' as ng-jvx-multiselect;
21
+
22
+ :root {
23
+ --jvx-multiselect-primary: #008000;
24
+ --jvx-multiselect-accent: #0000FF;
25
+ --jvx-multiselect-warn: #FF0000;
26
+ --jvx-multiselect-on-primary: #ffffff;
27
+ --jvx-multiselect-on-accent: currentcolor;
28
+ --jvx-multiselect-on-warn: currentcolor;
29
+ --jvx-multiselect-panel-bg: #FFFFFF
30
+ }
31
+ ```
32
+ In <b>example.component.html</b>
33
+
34
+ ```angular2html
35
+ <ng-jvx-multiselect style="width: 100%" [options]="options">
36
+ <ng-container placeholder>
37
+ this is a placeholder
38
+ </ng-container>
39
+ </ng-jvx-multiselect>
40
+ ```
41
+ In <b>example.component.ts</b>
42
+
43
+ ```typescript
44
+ public options = [
45
+ {value: 1, text: 'text 1'},
46
+ {value: 2, text: 'text 2'},
47
+ {value: 3, text: 'text 3'},
48
+ {value: 4, text: 'text 4'},
49
+ {value: 5, text: 'text 5'},
50
+ {value: 6, text: 'text 6'},
51
+ {value: 7, text: 'text 7'},
52
+ {value: 8, text: 'text 8'},
53
+ {value: 9, text: 'text 9'},
54
+ {value: 10, text: 'text 10'}];
55
+ ```
56
+ ![result](https://github.com/giovanni-venturelli/ng-jvx-multiselect/blob/main/blob/basic_usage.gif)
57
+
58
+ ## API
59
+
60
+ ### Slots
61
+
62
+ | Name | Description |
63
+ |---------------|------------------------------------------------------------------------------------------------------------|
64
+ | `default` | Using the default slot is one way of defining the options via the component `<ng-jvx-option>`. |
65
+ | `placeholder` | This slot allows the user to define a placeholder which will be displayed when no selection has been made. |
66
+
67
+ ### Inputs
68
+
69
+ | Name | Type | Default | Description |
70
+ |------------------|----------------------------------------------------------|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
71
+ | `clearable` | `Boolean` | `false` | True to enable the empty selection. |
72
+ | `closeButton` | `Boolean` | `false` | True to show the button that closes the menu. |
73
+ | `disabled` | `Boolean` | `false` | True to disable the select. |
74
+ | `itemText` | `String` | `'text'` | The name of the property of the option object that will be displayed as description of the options. |
75
+ | `itemValue` | `String` | `'value'` | The name of the property of the option object that will be treated as value of the options. |
76
+ | `multi` | `Boolean` | `false` | True if it's a multiselect. |
77
+ | `options` | `Array` | `[]` | Array of option objects. |
78
+ | `requestHeaders` | `Object` | `{...}` | The headers of the HTTP request. |
79
+ | `requestType` | <code>'GET'&#124;'POST'</code> | `'GET'` | The type of the HTTP request. |
80
+ | `postPayload` | `Object` | {} | Sets the payload for the post request. |
81
+ | `searchInput` | `Boolean` | `false` | True to enable the search input for the options list. |
82
+ | `searchMode` | <code>'client'&#124;'server'</code> | `server` | `'client'` if the search is only client side, `'server'` if it's server side. |
83
+ | `searchLabel` | `String` | `'search'` | The label of the search input. |
84
+ | `searchProp` | `String` | `'search'` | The name of the search property of the HTTP request. |
85
+ | `listProp` | `String` | `''` | Name of the property in response.data where the list is stored. |
86
+ | `url` | `String` | `''` | The url to get the options. |
87
+ | `value` | `Array` | `[]` | The current value of the selection. |
88
+ | `mapper` | `NgJvxOptionMapper` | `*` | The object that will map the response of the async call. |
89
+ | `searchMapper` | `NgJvxSearchMapper` | `*` | The object that will map the client search result. |
90
+ | `pageSize` | `number` | `15` | The size of a page for pagination purposes. |
91
+ | `groupBy` | <code>NgJvxGroupMapper<any>&#124;string&#124;null</code> | `null` | If it's a `string` it defines the the property of each option by which group them in the list. If it's a `NgJvxGroupMapper` it offers a method that groups the options (useful for nested properties). |
92
+
93
+ ### Methods
94
+
95
+ *None*
96
+
97
+ ### Events
98
+
99
+ | Event Name | Detail | Description |
100
+ |---------------|---------|-----------------------------------------------------------------------------------------------------|
101
+ | `valueChange` | `Array` | Fired when the user changes the value of the input. The detail contains the value of the selection. |
102
+ | `scrollEnd` | *None* | Fired when the scrollbar in the options menu reaches the bottom. |
103
+ | `open` | *None* | Fired when the the menu starts opening. |
104
+ | `opened` | *None* | Fired when the the menu is opened. |
105
+ | `close` | *None* | Fired when the the menu starts closing. |
106
+ | `closed` | *None* | Fired when the the menu is closed. |
107
+
108
+ ### Groups
109
+
110
+ It is possible to collect the options in groups. To do so the user can set the property `groupBy` with the name of the property they want to group the options by.
111
+ If the property is nested or the user wants to implement a more complex grouping algorithm, they set the property `groupBy` with an object that implements the interface `NgJvxGroupMapper<T>`.
112
+ This object offers the method
113
+ ```typescript
114
+ mapGroup(option: T): Observable<NgJvxGroup<T>>
115
+ ```
116
+ with
117
+ ```typescript
118
+ interface NgJvxGroup<T> {
119
+ group: string;
120
+ option: T;
121
+ }
122
+ ```
123
+ The `mapGroup` method hence takes the option and wraps it in an object that defines the name of the group it belongs to.
124
+ It is possible to define the look of the headers of the groups with the directive [*ngJvxGroupHeaderTemplate](#ngjvxgroupheadertemplate)
125
+ ### HTTP Request
126
+
127
+ #### Request
128
+
129
+ The HTTP request can be either a GET or a POST request. The user can set the type using the property `requestType` which
130
+ is set to `'GET'` by default.
131
+
132
+ ##### Headers
133
+
134
+ The headers can be set in the property `requestHeaders`. By default the ng-jvx-multiselect uses the property `trusted`
135
+ stored in the sessionStorage. The default headers are:
136
+
137
+ ```javascript
138
+ var requestHeaders = {
139
+ 'Accept': 'application/json',
140
+ 'Access-Control-Allow-Origin': '*',
141
+ 'Access-Control-Allow-Methods': 'GET, PUT, POST, DELETE, OPTIONS',
142
+ 'Content-Type': 'application/json',
143
+ 'Authorization': window.sessionStorage.getItem('trusted')
144
+ }
145
+ ```
146
+
147
+ #### Response
148
+
149
+ The response must contain an array of elements.
150
+
151
+ The property `listProp` defines the path of the array in the response object (i.e. if `listProp` is set to `list` the
152
+ ng-jvx-multiselect will get the options in the array stored in the path `response.list`).
153
+
154
+ #### Mapper
155
+
156
+ The `mapper` property will be an object implementing the interface `NgJvxOptionMapper<T>`. It will expose a
157
+ method `mapOption` which accepts the option to be mapped in the form of an Object and returns an Observable of type `T`.
158
+ For example if the request returns an array of objects like this:
159
+
160
+ ```javascript
161
+ {
162
+ id: number;
163
+ description: string;
164
+ }
165
+ ```
166
+
167
+ it is possible to write a mapper like this:
168
+
169
+ ```javascript
170
+ const mapper: NgJvxOptionMapper<{value: number, text: string}> = {
171
+ mapOption(source: {
172
+ id: number,
173
+ description: string
174
+ }): Observable<any> {
175
+ return of({value: source.id, text: source.description});
176
+ }
177
+ }
178
+ ```
179
+
180
+ The `multiMapper` property works like the `mapper` property, it implements the interface `NgJvxOptionsMapper<T>`.
181
+ It will expose a method `mapOptions` which accepts all the options to be mapped in the form of an Object and returns an Observable of type `T[]`.
182
+ For example if the request returns an array of objects like this:
183
+
184
+ ```javascript
185
+ {
186
+ id: number;
187
+ description: string;
188
+ }
189
+ ```
190
+
191
+ it is possible to write a mapper like this:
192
+
193
+ ```javascript
194
+ const mapper: NgJvxOptionMultiMapper<{value: number, text: string}> = {
195
+ mapOption(source: {
196
+ id: number,
197
+ description: string
198
+ }[]): Observable<any> {
199
+ return of(source.map(s=>{value: s.id, text: s.description}));
200
+ }
201
+ }
202
+ ```
203
+
204
+ It's useful if the user wants to add any custom option to a server call
205
+ #### Search
206
+
207
+ If the property `searchInput` is `true`, the user will be able to search a value amongst the options.
208
+ `searchProp` defines the name of the property for the HTTP call.
209
+
210
+ ##### searchMapper
211
+
212
+ The `searchMapper` property is an object implementing the interface `NgJvxSearchMapper<T>`. It exposes the
213
+ method `mapSearch` which accepts the value of the search (a string) and an array of the selectable options.
214
+ The method returns an Observable of type `T[]`.
215
+ The value of the returned Observable will then be used as the new option list.
216
+ This property is only useful for a client side search.
217
+
218
+ For example:
219
+ ```typescript
220
+ const searchMapper: NgJvxSearchMapper<{text: string, value: number}> = {
221
+ mapSearch: (source: string, options: {text: string, value: number}[]): Observable<{text: string, value: number}[]> => {
222
+ return of(options.filter(o => o.text.toLowerCase().includes(source.toLowerCase())));
223
+ }
224
+ }
225
+ ```
226
+
227
+ ### Slots
228
+
229
+ #### default
230
+
231
+ The default slot allows to define the options directly via html. It's not compatible with the `url` parameter. The
232
+ options shall be wrapped in the `<ng-jvx-option>` component. The slot shall not be wrapped in the `<ng-jvx-option>`
233
+ component if it's decorated with one of the available directives, since it will have different purposes.
234
+
235
+ #### placeholder
236
+
237
+ The slot `placeholder` will define the placeholder. It's shown only when the selection's value is empty.
238
+
239
+ ### Directives
240
+
241
+ #### ngJvxOptionsTemplate
242
+
243
+ When an element inside the `ng-jvx-multiselect` is decorated with this directive it becomes the template for the options
244
+ of the select. The directive provides a context. i.e.: Let's say we have the following structure:
245
+
246
+ ```javascript
247
+ var options = [{
248
+ value: 1,
249
+ text: 'Lorem ipsum',
250
+ color: 'blue',
251
+ preview: 'path/to/first-image.jpg'
252
+ },
253
+ {
254
+ value: 2,
255
+ text: 'dolor sit amet',
256
+ color: 'red',
257
+ preview: 'path/to/second-image.jpg'
258
+ }];
259
+ ```
260
+
261
+ and we want our options to have in the text field both the property color and the property text. We can write the
262
+ template like so:
263
+
264
+ ```angular2html
265
+ <div *ngJvxOptionsTemplate="let option">{{option.color}} {{option.text}}</div>
266
+ ```
267
+
268
+ It's possible to use the context inside attributes too. i.e.
269
+
270
+ ```angular2html
271
+ <div *ngJvxOptionsTemplate="let option">
272
+ <span>{{option.text}}</span>
273
+ <span>
274
+ <img src="{{option.preview}}"/>
275
+ </span>
276
+ </div>
277
+ ```
278
+
279
+ #### *ngJvxSelectionTemplate
280
+
281
+ This directive works exactly as the `ngJvxOptionsTemplate` except it defines the selection template.
282
+ In case of a multiple selection the context is the array of the selected options, for the non-multiple selection the
283
+ context is the selected option.
284
+
285
+ #### *ngJvxGroupHeaderTemplate
286
+
287
+ When an element inside the `ng-jvx-multiselect` is decorated with this directive it becomes the template for the header
288
+ of the groups by which the options are devided. The directive provides a context which describes the group with its
289
+ options in the following form:
290
+
291
+ ```typescript
292
+ {
293
+ group: any;
294
+ options: any[];
295
+ }
296
+ ```
297
+
298
+ i.e.: with the following structure:
299
+
300
+ ```typescript
301
+ const options = [{
302
+ value: 'dog',
303
+ text: 'the dog',
304
+ type: 'mammal'
305
+ }, {
306
+ value: 'lizard',
307
+ text: 'the lizard',
308
+ type: 'reptile'
309
+ }, {
310
+ value: 'cat',
311
+ text: 'the cat',
312
+ type: 'mammal'
313
+ }];
314
+ ```
315
+
316
+ and we want the header of each group be in the form of 'Type of animal: [mammal | reptile]'. We'll do as follows:
317
+
318
+ ```angular2html
319
+
320
+ <div *ngJvxGroupHeaderTemplate="let g">Type of animal: {{g.group}}</div>
321
+ ```
322
+
323
+ #### *ngJvxDisabledOption
324
+
325
+ This directive disables the selection of the host option. i.e.
326
+
327
+ ```angular2html
328
+
329
+ <div *ngJvxOptionsTemplate="let option" [ngJvxDisabledOption]="option.text === 'text of the disabled option'">
330
+ <span>{{option.text}}</span>
331
+ <span>
332
+ <img src="{{option.preview}}"/>
333
+ </span>
334
+ </div>
335
+ ```
336
+
337
+ ## NgJvxMultiselectChipComponent
338
+
339
+ This component is used by `ng-jvx-multiselect` to render each selected item as a removable “chip” when `multi` is enabled. Chips provide a compact visual representation of the current selection and offer a quick way to remove individual items.
340
+
341
+ It is created and managed internally by the multiselect; typical applications do not need to instantiate it directly.
342
+
343
+ ### Inputs
344
+
345
+ *None*
346
+
347
+ ### Methods
348
+
349
+ *None*
350
+
351
+ ### Events
352
+
353
+ | Event Name | Detail | Description |
354
+ |------------|--------|-----------------------------------------------------------------------------|
355
+ | `removed` | `any` | Fired when the user clicks the chip’s remove action. The detail is the option represented by the chip. |
356
+
357
+ Notes:
358
+ - When a chip emits `removed`, the multiselect removes the corresponding item from the selection.
359
+ - The event is handled internally by the multiselect component; consumers usually interact with selection changes via the parent’s `valueChange` event.