ng-select2-component 8.0.2 → 8.0.6
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/AUTHORS.md +16 -14
- package/CHANGELOG.md +303 -274
- package/LICENSE.md +21 -21
- package/README.md +338 -338
- package/bundles/ng-select2-component.umd.js +2555 -2446
- package/bundles/ng-select2-component.umd.js.map +1 -1
- package/bundles/ng-select2-component.umd.min.js +1 -1
- package/bundles/ng-select2-component.umd.min.js.map +1 -1
- package/esm2015/lib/select2-const.js +57 -57
- package/esm2015/lib/select2-hint.component.js +12 -12
- package/esm2015/lib/select2-interfaces.js +134 -134
- package/esm2015/lib/select2-label.component.js +12 -12
- package/esm2015/lib/select2-utils.js +388 -384
- package/esm2015/lib/select2.component.js +1500 -1385
- package/esm2015/lib/select2.module.js +23 -39
- package/esm2015/ng-select2-component.js +10 -10
- package/esm2015/public_api.js +17 -17
- package/fesm2015/ng-select2-component.js +2103 -2001
- package/fesm2015/ng-select2-component.js.map +1 -1
- package/lib/select2-const.d.ts +7 -7
- package/lib/select2-hint.component.d.ts +2 -2
- package/lib/select2-interfaces.d.ts +54 -54
- package/lib/select2-label.component.d.ts +2 -2
- package/lib/select2-utils.d.ts +20 -20
- package/lib/select2.component.d.ts +216 -207
- package/lib/select2.module.d.ts +2 -2
- package/ng-select2-component.d.ts +4 -4
- package/ng-select2-component.metadata.json +1 -1
- package/package.json +1 -1
- package/public_api.d.ts +8 -8
package/README.md
CHANGED
|
@@ -1,338 +1,338 @@
|
|
|
1
|
-
[](https://badge.fury.io/js/ng-select2-component) [](https://www.npmjs.com/package/ng-select2-component) [](https://raw.githubusercontent.com/Harvest-Dev/ng-select2/master/LICENSE.md)
|
|
2
|
-
|
|
3
|
-
# Select2
|
|
4
|
-
|
|
5
|
-
This Angular CLI module it's a fork of [select2-component](https://github.com/plantain-00/select2-component) without Vue & React. For
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
npm i ng-select2-component --save
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Requirements
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
--select2-
|
|
250
|
-
--select2-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
--select2-selection-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
--select2-selection-
|
|
257
|
-
--select2-selection-
|
|
258
|
-
--select2-selection-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
--select2-
|
|
264
|
-
--select2-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
--select2-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
--select2-
|
|
287
|
-
|
|
288
|
-
/*
|
|
289
|
-
--select2-
|
|
290
|
-
--select2-
|
|
291
|
-
--select2-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
--select2-option-text-color: #
|
|
295
|
-
--select2-option-
|
|
296
|
-
--select2-option-
|
|
297
|
-
--select2-option-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
--select2-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
--select2-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
--select2-material-underline-invalid: red;
|
|
312
|
-
--select2-material-placeholder-color: rgba(0, 0, 0, 0.38);
|
|
313
|
-
--select2-material-selection-background: #ddd;
|
|
314
|
-
--select2-material-option-selected-background: rgba(0, 0, 0, 0.04);
|
|
315
|
-
--select2-material-option-highlighted-text-color: #000;
|
|
316
|
-
--select2-material-option-selected-text-color: #ff5722;
|
|
317
|
-
}
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
For IE11, see [css-vars-ponyfill](https://github.com/jhildenbiddle/css-vars-ponyfill).
|
|
321
|
-
|
|
322
|
-
## Publishing the library
|
|
323
|
-
|
|
324
|
-
```
|
|
325
|
-
npm run build:lib
|
|
326
|
-
cd dist/ng-select2-component
|
|
327
|
-
npm publish
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
## Update Demo
|
|
331
|
-
|
|
332
|
-
```
|
|
333
|
-
npm run build:demo
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
## License
|
|
337
|
-
|
|
338
|
-
Like Angular, this module is released under the permissive MIT license. Your contributions are always welcome.
|
|
1
|
+
[](https://badge.fury.io/js/ng-select2-component) [](https://www.npmjs.com/package/ng-select2-component) [](https://raw.githubusercontent.com/Harvest-Dev/ng-select2/master/LICENSE.md)
|
|
2
|
+
|
|
3
|
+
# Select2
|
|
4
|
+
|
|
5
|
+
This Angular CLI module it's a fork of [select2-component](https://github.com/plantain-00/select2-component) without Vue & React. For Vue or React, please use the original component.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm i ng-select2-component --save
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
- peerDependencies:
|
|
16
|
+
|
|
17
|
+
- `angular` 10.0.0 and more
|
|
18
|
+
- `angular/cdk` 10.0.0 and more
|
|
19
|
+
|
|
20
|
+
- dependencies (include):
|
|
21
|
+
- `ngx-infinite-scroll@^10.0.1`
|
|
22
|
+
|
|
23
|
+
> **Note:**<br>
|
|
24
|
+
> For `angular` 7, 8 and 9 : use version `7.3.1`.
|
|
25
|
+
|
|
26
|
+
## Demo
|
|
27
|
+
|
|
28
|
+
[See a demo](https://harvest-dev.github.io/ng-select2/dist/ng-select2/).
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- select one
|
|
33
|
+
- options or groups
|
|
34
|
+
- scroll
|
|
35
|
+
- local search
|
|
36
|
+
- select by keyboard
|
|
37
|
+
- disabled option
|
|
38
|
+
- disabled component
|
|
39
|
+
- hide search box
|
|
40
|
+
- placeholder
|
|
41
|
+
- multiple selection
|
|
42
|
+
- material style
|
|
43
|
+
- form binding
|
|
44
|
+
- templating
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
### example
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { Select2Module } from 'ng-select2-component';
|
|
52
|
+
|
|
53
|
+
@NgModule({
|
|
54
|
+
imports: [BrowserModule, FormsModule, Select2Module],
|
|
55
|
+
declarations: [MainComponent],
|
|
56
|
+
bootstrap: [MainComponent],
|
|
57
|
+
})
|
|
58
|
+
class MainModule {}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<select2 [data]="data" [value]="value" (update)="update($event)"> </select2>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### properties and events of the component
|
|
66
|
+
|
|
67
|
+
| name | type | status | default | description |
|
|
68
|
+
| ------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | -------- | ----------- | -------------------------------------------------------------------------------------------------- |
|
|
69
|
+
| `data` | [`Select2Data`](#select2-data-structure) | required | | the data of the select2 |
|
|
70
|
+
| `value` | [`Select2Value`](#select2-data-structure) | | | initial value |
|
|
71
|
+
| `minCharForSearch` | `number` | | `0` | start the search when the number of characters is reached (`0` = unlimited) |
|
|
72
|
+
| `minCountForSearch` | `number` | | `6` | hide search box if `options.length < minCountForSearch` |
|
|
73
|
+
| `displaySearchStatus` | `'default'`<br>`'hidden'`<br>`'always'` | | `'default'` | display the search box (`default` : is based on `minCountForSearch`) |
|
|
74
|
+
| `placeholder` | `string` | | | the placeholder string if nothing selected |
|
|
75
|
+
| `noResultMessage` | `string` | | | the message string if no results when using the search field |
|
|
76
|
+
| `customSearchEnabled` | `boolean` | | `false` | will trigger `search` event, and disable inside filter |
|
|
77
|
+
| `multiple` | `boolean` | | `false` | select multiple options |
|
|
78
|
+
| `resettable` | `boolean` | | `false` | add a button to reset value (not with `multiple`) |
|
|
79
|
+
| `limitSelection` | `number` | | `0` | to limit multiple selection (`0` = unlimited) |
|
|
80
|
+
| `hideSelectedItems` | `boolean` | | `false` | for `multiple`, remove selected values |
|
|
81
|
+
| `resultMaxHeight` | `string` | | `'200px'` | change the height size of results |
|
|
82
|
+
| `listPosition` | `'below'`<br>`'above'`<br>`'auto'` \* | | `'below'` | the position for the dropdown list<br> \* `'auto'`: only with `overlay` |
|
|
83
|
+
| `infiniteScroll` | `boolean` | | `false` | active infiniteScroll on dropdown list ( with `ngx-infinite-scroll`) |
|
|
84
|
+
| `infiniteScrollDistance` | `number` | | `1.5` | infiniteScroll distance |
|
|
85
|
+
| `infiniteScrollThrottle` | `number` | | `150` | infiniteScroll throttle |
|
|
86
|
+
| `overlay` | `boolean` | | `false` | active an overlay mode for dropdown list (with angular cdk). (See [Overlay](#overlay)) |
|
|
87
|
+
| `styleMode` | `'default'`<br>`'material'`<br>`'noStyle'` | | `'default'` | change style for material style or remove border and background color |
|
|
88
|
+
| `templates` | `TemplateRef`<br> `{option?: TemplateRef, group?: TemplateRef}`<br> `{templateId1: TemplateRef, ...}` | | | use templates for formatting content (see [Templating](#templating)) |
|
|
89
|
+
| `editPattern` | `(str: string) => string` | | | use it for change the pattern of the filter search |
|
|
90
|
+
| `ngModel`<br>`id`<br>`required`<br>`disabled`<br>`readonly`<br>`tabIndex` | | | | just like a `select` control |
|
|
91
|
+
| `(update)` | `(event: `[`Select2UpdateEvent`](#select2-data-structure)`) => void` | event | | triggered when user select an option |
|
|
92
|
+
| `(open)` | `(event: Select2) => void` | event | | triggered when user open the options |
|
|
93
|
+
| `(close)` | `(event: Select2) => void` | event | | triggered when user close the options |
|
|
94
|
+
| `(focus)` | `(event: Select2) => void` | event | | triggered when user enters the component |
|
|
95
|
+
| `(blur)` | `(event: Select2) => void` | event | | triggered when user leaves the component |
|
|
96
|
+
| `(search)` | `(event: `[`Select2SearchEvent`](#select2-data-structure)`) => void` | event | | triggered when search text changed |
|
|
97
|
+
| `(scroll)` | `(event: `[`Select2ScrollEvent`](#select2-data-structure)`) => void` | event | | triggered when infiniteScroll is on `up` or `down` position |
|
|
98
|
+
| `(removedOption)` | `(event: `[`Select2RemoveEvent`](#select2-data-structure)`) => void` | event | | for `multiple`, triggered when an option is removed from the list of selected options options list |
|
|
99
|
+
|
|
100
|
+
### select2 data structure
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
type Select2Data = (Select2Group | Select2Option)[];
|
|
104
|
+
|
|
105
|
+
export interface Select2Group {
|
|
106
|
+
/** label of group */
|
|
107
|
+
label: string;
|
|
108
|
+
/** options list */
|
|
109
|
+
options: Select2Option[];
|
|
110
|
+
/** add classes */
|
|
111
|
+
classes?: string;
|
|
112
|
+
/** template id */
|
|
113
|
+
templateId?: string;
|
|
114
|
+
/** template data */
|
|
115
|
+
data?: any;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface Select2Option {
|
|
119
|
+
/** value */
|
|
120
|
+
value: Select2Value;
|
|
121
|
+
/** label of option */
|
|
122
|
+
label: string;
|
|
123
|
+
/** no selectable is disabled */
|
|
124
|
+
disabled?: boolean;
|
|
125
|
+
/** for identification */
|
|
126
|
+
id?: string;
|
|
127
|
+
/** add classes */
|
|
128
|
+
classes?: string;
|
|
129
|
+
/** template id */
|
|
130
|
+
templateId?: string;
|
|
131
|
+
/** template data */
|
|
132
|
+
data?: any;
|
|
133
|
+
/** hide this option */
|
|
134
|
+
hide?: boolean;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
type Select2Value = string | number | boolean | object;
|
|
138
|
+
|
|
139
|
+
type Select2UpdateValue = Select2Value | Select2Value[];
|
|
140
|
+
|
|
141
|
+
export interface Select2UpdateEvent<U extends Select2UpdateValue = Select2Value> {
|
|
142
|
+
component: Select2;
|
|
143
|
+
value: U;
|
|
144
|
+
options: Select2Option[];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface Select2SearchEvent<U extends Select2UpdateValue = Select2Value> {
|
|
148
|
+
component: Select2;
|
|
149
|
+
value: U;
|
|
150
|
+
search: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface Select2RemoveEvent<U extends Select2UpdateValue = Select2Value> {
|
|
154
|
+
component: Select2;
|
|
155
|
+
value: U;
|
|
156
|
+
removedOption: Select2Option;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface Select2ScrollEvent {
|
|
160
|
+
component: Select2;
|
|
161
|
+
way: 'up' | 'down';
|
|
162
|
+
search: string;
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Templating
|
|
167
|
+
|
|
168
|
+
#### Unique template
|
|
169
|
+
|
|
170
|
+
```html
|
|
171
|
+
<select2 [data]="data" [templates]="template">
|
|
172
|
+
<ng-template #template let-data="data"><strong>{{data?.color}}</strong>: {{data?.name}}</ng-template>
|
|
173
|
+
</select2>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
const data: Select2Data = [
|
|
178
|
+
{
|
|
179
|
+
value: 'heliotrope',
|
|
180
|
+
label: 'Heliotrope',
|
|
181
|
+
data: { color: 'white', name: 'Heliotrope' },
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
value: 'hibiscus',
|
|
185
|
+
label: 'Hibiscus',
|
|
186
|
+
data: { color: 'red', name: 'Hibiscus' },
|
|
187
|
+
},
|
|
188
|
+
];
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### Template group & option
|
|
192
|
+
|
|
193
|
+
```html
|
|
194
|
+
<select2 [data]="data" [templates]="{option : option, group: group}">
|
|
195
|
+
<ng-template #option let-data="data">{{data?.name}}</ng-template>
|
|
196
|
+
<ng-template #group let-label="label">Group: {{label}}</ng-template>
|
|
197
|
+
</select2>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
No difference in data structure.
|
|
201
|
+
The template is defined by its type, option or group, automatically.
|
|
202
|
+
|
|
203
|
+
#### Template by templateId
|
|
204
|
+
|
|
205
|
+
```html
|
|
206
|
+
<select2 [data]="data" [templates]="{template1 : template1, template2: template2}">
|
|
207
|
+
<ng-template #template1 let-data="data">{{data?.name}}</ng-template>
|
|
208
|
+
<ng-template #template2 let-label="label" let-data="data">{{label}} : {{data?.color}}</ng-template>
|
|
209
|
+
</select2>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
const data: Select2Data = [
|
|
214
|
+
{
|
|
215
|
+
value: 'heliotrope',
|
|
216
|
+
label: 'Heliotrope',
|
|
217
|
+
data: { color: 'white', name: 'Heliotrope' },
|
|
218
|
+
templateId: 'template1',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
value: 'hibiscus',
|
|
222
|
+
label: 'Hibiscus',
|
|
223
|
+
data: { color: 'red', name: 'Hibiscus' },
|
|
224
|
+
templateId: 'template2',
|
|
225
|
+
},
|
|
226
|
+
];
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Overlay
|
|
230
|
+
|
|
231
|
+
If the overlay mode is used / activated, add to the project root in CSS (with `ViewEncapsulation.None`)
|
|
232
|
+
|
|
233
|
+
```css
|
|
234
|
+
@import '~@angular/cdk/overlay-prebuilt.css';
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## CSS variables (doesn't work on IE11)
|
|
238
|
+
|
|
239
|
+
It's possible to change different colors (and more) with CSS variables without having to modify them with `::ng-deep` or other CSS rules :
|
|
240
|
+
|
|
241
|
+
```css
|
|
242
|
+
:root {
|
|
243
|
+
/* label */
|
|
244
|
+
--select2-label-text-color: #000;
|
|
245
|
+
--select2-required-color: red;
|
|
246
|
+
|
|
247
|
+
/* selection */
|
|
248
|
+
--select2-selection-border-radius: 4px;
|
|
249
|
+
--select2-selection-background: #fff;
|
|
250
|
+
--select2-selection-disabled-background: #eee;
|
|
251
|
+
--select2-selection-border-color: #aaa;
|
|
252
|
+
--select2-selection-focus-border-color: #000;
|
|
253
|
+
--select2-selection-text-color: #444;
|
|
254
|
+
|
|
255
|
+
/* selection: choice item (multiple) */
|
|
256
|
+
--select2-selection-choice-background: #e4e4e4;
|
|
257
|
+
--select2-selection-choice-text-color: #000;
|
|
258
|
+
--select2-selection-choice-border-color: #aaa;
|
|
259
|
+
--select2-selection-choice-close-color: #999;
|
|
260
|
+
--select2-selection-choice-hover-close-color: #333;
|
|
261
|
+
|
|
262
|
+
/* placeholder */
|
|
263
|
+
--select2-placeholder-color: #999;
|
|
264
|
+
--select2-placeholder-overflow: ellipsis;
|
|
265
|
+
|
|
266
|
+
/* no result message */
|
|
267
|
+
--select2-no-result-color: #888;
|
|
268
|
+
--select2-font-style-color: italic;
|
|
269
|
+
|
|
270
|
+
/* reset */
|
|
271
|
+
--select2-reset-color: #999;
|
|
272
|
+
|
|
273
|
+
/* arrow */
|
|
274
|
+
--select2-arrow-color: #888;
|
|
275
|
+
|
|
276
|
+
/* dropdown panel */
|
|
277
|
+
--select2-dropdown-background: #fff;
|
|
278
|
+
--select2-dropdown-border-color: #aaa;
|
|
279
|
+
|
|
280
|
+
/* overlay */
|
|
281
|
+
--select2-overlay-backdrop: transparent;
|
|
282
|
+
|
|
283
|
+
/* search field */
|
|
284
|
+
--select2-search-border-color: #aaa;
|
|
285
|
+
--select2-search-background: #fff;
|
|
286
|
+
--select2-search-border-radius: 0px;
|
|
287
|
+
|
|
288
|
+
/* dropdown option */
|
|
289
|
+
--select2-option-text-color: #000;
|
|
290
|
+
--select2-option-disabled-text-color: #999;
|
|
291
|
+
--select2-option-disabled-background: transparent;
|
|
292
|
+
--select2-option-selected-text-color: #000;
|
|
293
|
+
--select2-option-selected-background: #ddd;
|
|
294
|
+
--select2-option-highlighted-text-color: #fff;
|
|
295
|
+
--select2-option-highlighted-background: #5897fb;
|
|
296
|
+
--select2-option-group-text-color: gray;
|
|
297
|
+
--select2-option-group-background: transparent;
|
|
298
|
+
|
|
299
|
+
/* hint */
|
|
300
|
+
--select2-hint-text-color: #888;
|
|
301
|
+
|
|
302
|
+
/* for Material ------------------------------------------*/
|
|
303
|
+
--select2-material-underline: #ddd;
|
|
304
|
+
--select2-material-underline-active: #5a419e;
|
|
305
|
+
--select2-material-underline-disabled: linear-gradient(
|
|
306
|
+
to right,
|
|
307
|
+
rgba(0, 0, 0, 0.26) 0,
|
|
308
|
+
rgba(0, 0, 0, 0.26) 33%,
|
|
309
|
+
transparent 0
|
|
310
|
+
);
|
|
311
|
+
--select2-material-underline-invalid: red;
|
|
312
|
+
--select2-material-placeholder-color: rgba(0, 0, 0, 0.38);
|
|
313
|
+
--select2-material-selection-background: #ddd;
|
|
314
|
+
--select2-material-option-selected-background: rgba(0, 0, 0, 0.04);
|
|
315
|
+
--select2-material-option-highlighted-text-color: #000;
|
|
316
|
+
--select2-material-option-selected-text-color: #ff5722;
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
For IE11, see [css-vars-ponyfill](https://github.com/jhildenbiddle/css-vars-ponyfill).
|
|
321
|
+
|
|
322
|
+
## Publishing the library
|
|
323
|
+
|
|
324
|
+
```
|
|
325
|
+
npm run build:lib
|
|
326
|
+
cd dist/ng-select2-component
|
|
327
|
+
npm publish
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Update Demo
|
|
331
|
+
|
|
332
|
+
```
|
|
333
|
+
npm run build:demo
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## License
|
|
337
|
+
|
|
338
|
+
Like Angular, this module is released under the permissive MIT license. Your contributions are always welcome.
|