@1024pix/pix-ui 55.21.1 → 55.22.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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { warn } from '@ember/debug';
|
|
1
2
|
import { action } from '@ember/object';
|
|
2
3
|
import { guidFor } from '@ember/object/internals';
|
|
3
4
|
import Component from '@glimmer/component';
|
|
@@ -21,12 +22,37 @@ export default class PixMultiSelect extends Component {
|
|
|
21
22
|
@tracked isExpanded = false;
|
|
22
23
|
@tracked searchData;
|
|
23
24
|
|
|
24
|
-
@tracked options = [];
|
|
25
|
-
|
|
26
25
|
constructor(...args) {
|
|
27
26
|
super(...args);
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
warn(
|
|
29
|
+
`PixMultiSelect: @strictSearch is deprecated in favour of @onSearch`,
|
|
30
|
+
!this.args.strictSearch,
|
|
31
|
+
{
|
|
32
|
+
id: 'pix-ui.pix-multi-select.strictSearch.deprecated',
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get options() {
|
|
38
|
+
return [...(this.args.options || [])];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get hasValues() {
|
|
42
|
+
return this.args.values && Array.isArray(this.args.values);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get displayedOptions() {
|
|
46
|
+
const optionsWithCheckedStatus = this.options.map((option) => ({
|
|
47
|
+
...option,
|
|
48
|
+
checked: this.hasValues ? this.args.values.includes(option.value) : false,
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
if (this.args.isSearchable) {
|
|
52
|
+
return [...optionsWithCheckedStatus.sort(sortOptionsByCheckedFirst)];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return optionsWithCheckedStatus;
|
|
30
56
|
}
|
|
31
57
|
|
|
32
58
|
get mainInputClassName() {
|
|
@@ -57,9 +83,9 @@ export default class PixMultiSelect extends Component {
|
|
|
57
83
|
|
|
58
84
|
get results() {
|
|
59
85
|
if (this.args.isSearchable && this.searchData) {
|
|
60
|
-
return this.
|
|
86
|
+
return this.displayedOptions.filter(({ label }) => this._search(label));
|
|
61
87
|
}
|
|
62
|
-
return this.
|
|
88
|
+
return this.displayedOptions;
|
|
63
89
|
}
|
|
64
90
|
|
|
65
91
|
get placeholder() {
|
|
@@ -77,19 +103,6 @@ export default class PixMultiSelect extends Component {
|
|
|
77
103
|
return placeholder;
|
|
78
104
|
}
|
|
79
105
|
|
|
80
|
-
_setDisplayedOptions(selected, shouldSort) {
|
|
81
|
-
const options = this.options.map((option) => ({
|
|
82
|
-
...option,
|
|
83
|
-
checked: selected ? selected.includes(option.value) : false,
|
|
84
|
-
}));
|
|
85
|
-
|
|
86
|
-
if (shouldSort && this.args.isSearchable) {
|
|
87
|
-
options.sort(sortOptionsByCheckedFirst);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
this.options = options;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
106
|
_search(label) {
|
|
94
107
|
if (this.args.strictSearch) {
|
|
95
108
|
return label.includes(this.searchData);
|
|
@@ -124,7 +137,6 @@ export default class PixMultiSelect extends Component {
|
|
|
124
137
|
showDropDown() {
|
|
125
138
|
if (this.isExpanded) return;
|
|
126
139
|
this.isExpanded = true;
|
|
127
|
-
this._setDisplayedOptions(this.args.values, true);
|
|
128
140
|
}
|
|
129
141
|
|
|
130
142
|
@action
|
|
@@ -140,13 +152,14 @@ export default class PixMultiSelect extends Component {
|
|
|
140
152
|
|
|
141
153
|
@action
|
|
142
154
|
updateSearch(event) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
155
|
+
if (this.args.onSearch) {
|
|
156
|
+
this.args.onSearch(event.target.value);
|
|
157
|
+
} else {
|
|
158
|
+
this.searchData = this.args.strictSearch
|
|
159
|
+
? event.target.value
|
|
160
|
+
: removeCapitalizeAndDiacritics(event.target.value);
|
|
149
161
|
}
|
|
162
|
+
this.isExpanded = true;
|
|
150
163
|
}
|
|
151
164
|
|
|
152
165
|
get className() {
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
|
|
3
3
|
export default class PixSelectList extends Component {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
get categories() {
|
|
5
|
+
const uniqueCategories = new Set(
|
|
6
|
+
...this.args.options.map((option) => option.category).filter(Boolean),
|
|
7
|
+
);
|
|
8
|
+
return Array.from(uniqueCategories.values());
|
|
9
|
+
}
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
categories.push(element.category);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
this.displayCategory = categories.length > 0;
|
|
11
|
+
get displayCategory() {
|
|
12
|
+
return this.categories.length > 0;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
get isDefaultOptionHidden() {
|
|
18
16
|
return !this.args.isExpanded || this.args.hideDefaultOption;
|
|
19
17
|
}
|
|
18
|
+
|
|
20
19
|
get results() {
|
|
21
20
|
const results = [];
|
|
22
21
|
let options = this.args.options;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1024pix/pix-ui",
|
|
3
|
-
"version": "55.
|
|
3
|
+
"version": "55.22.0",
|
|
4
4
|
"description": "Pix-UI is the implementation of Pix design principles and guidelines for its products.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"ember-source": {
|
|
29
29
|
"@glimmer/component": "^2.0.0"
|
|
30
|
-
}
|
|
30
|
+
},
|
|
31
|
+
"glob": "^9.0.0"
|
|
31
32
|
},
|
|
32
33
|
"scripts": {
|
|
33
34
|
"build": "./scripts/build.sh",
|
|
@@ -67,7 +68,6 @@
|
|
|
67
68
|
"ember-cli-babel": "^8.2.0",
|
|
68
69
|
"ember-cli-htmlbars": "^6.3.0",
|
|
69
70
|
"ember-cli-sass": "^11.0.1",
|
|
70
|
-
"ember-cli-update": "^2.0.1",
|
|
71
71
|
"ember-click-outside": "^6.1.1",
|
|
72
72
|
"ember-lifeline": "^7.0.0",
|
|
73
73
|
"ember-modifier": "^4.2.0",
|