@1024pix/pix-ui 46.4.2 → 46.4.3
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/addon/components/pix-filterable-and-searchable-select.hbs +0 -1
- package/addon/components/pix-filterable-and-searchable-select.js +28 -22
- package/addon/components/pix-pagination.hbs +1 -1
- package/addon/components/pix-pagination.js +0 -9
- package/addon/components/pix-select.hbs +0 -2
- package/addon/components/pix-select.js +24 -34
- package/app/services/element-helper.js +32 -0
- package/package.json +2 -3
- package/addon/common/add-dynamic-style-tag.js +0 -8
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
|
+
import { inject as service } from '@ember/service';
|
|
2
3
|
import { tracked } from '@glimmer/tracking';
|
|
3
4
|
import { action } from '@ember/object';
|
|
4
5
|
import { guidFor } from '@ember/object/internals';
|
|
5
|
-
import { createClass } from '../common/add-dynamic-style-tag';
|
|
6
6
|
|
|
7
7
|
export default class PixFilterableAndSearchableSelect extends Component {
|
|
8
|
+
@service elementHelper;
|
|
8
9
|
@tracked selectedCategories = [];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
constructor(...args) {
|
|
12
|
+
super(...args);
|
|
13
|
+
this.mainId = 'pix-pfass-' + guidFor(this);
|
|
14
|
+
this.pixSelectId = 'pix-pfass-select-' + guidFor(this);
|
|
15
|
+
this.pixMultiSelectId = 'pix-pfass-multi-select-' + guidFor(this);
|
|
16
|
+
|
|
17
|
+
this.elementHelper.waitForElement(this.pixSelectId).then(() => {
|
|
18
|
+
const baseFontRemRatio = Number(
|
|
19
|
+
getComputedStyle(document.querySelector('html')).fontSize.match(/\d+(\.\d+)?/)[0],
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const multiSelectWidth = document
|
|
23
|
+
.getElementById(this.pixMultiSelectId)
|
|
24
|
+
.getBoundingClientRect().width;
|
|
25
|
+
|
|
26
|
+
const selectWidth = Math.ceil(multiSelectWidth / baseFontRemRatio);
|
|
27
|
+
|
|
28
|
+
const className = `sizing-select-${this.pixSelectId}`;
|
|
29
|
+
this.elementHelper.createClass(`.${className}`, `width: calc(100% - ${selectWidth}rem);`);
|
|
30
|
+
|
|
31
|
+
const element = document.getElementById(`container-${this.pixSelectId}`);
|
|
32
|
+
|
|
33
|
+
element.className = element.className + ' ' + className;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
12
36
|
|
|
13
37
|
@action
|
|
14
38
|
selectCategories(categories) {
|
|
@@ -47,22 +71,4 @@ export default class PixFilterableAndSearchableSelect extends Component {
|
|
|
47
71
|
|
|
48
72
|
return selectableOptions;
|
|
49
73
|
}
|
|
50
|
-
|
|
51
|
-
@action
|
|
52
|
-
setSelectWidth(element) {
|
|
53
|
-
const baseFontRemRatio = Number(
|
|
54
|
-
getComputedStyle(document.querySelector('html')).fontSize.match(/\d+(\.\d+)?/)[0],
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const multiSelectWidth = document
|
|
58
|
-
.getElementById(this.pixMultiSelectId)
|
|
59
|
-
.getBoundingClientRect().width;
|
|
60
|
-
|
|
61
|
-
const selectWidth = Math.ceil(multiSelectWidth / baseFontRemRatio);
|
|
62
|
-
|
|
63
|
-
const className = `sizing-select-${this.pixSelectId}`;
|
|
64
|
-
createClass(`.${className}`, `width: calc(100% - ${selectWidth}rem);`);
|
|
65
|
-
|
|
66
|
-
element.className = element.className + ' ' + className;
|
|
67
|
-
}
|
|
68
74
|
}
|
|
@@ -118,13 +118,4 @@ export default class PixPagination extends Component {
|
|
|
118
118
|
goToPreviousPage() {
|
|
119
119
|
this.router.replaceWith({ queryParams: { pageNumber: this.previousPage } });
|
|
120
120
|
}
|
|
121
|
-
|
|
122
|
-
@action
|
|
123
|
-
checkCurrentPageAgainstPageCount() {
|
|
124
|
-
const pageCount = this.args.pagination.pageCount;
|
|
125
|
-
if (pageCount === 0) return;
|
|
126
|
-
if (this.currentPage > pageCount) {
|
|
127
|
-
this.router.replaceWith({ queryParams: { pageNumber: pageCount } });
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
121
|
}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
{{on-click-outside this.hideDropdown}}
|
|
5
5
|
{{on-arrow-down-up-action this.listId this.showDropdown this.isExpanded}}
|
|
6
6
|
{{on-escape-action this.hideDropdown this.selectId}}
|
|
7
|
-
{{did-insert this.setSelectWidth}}
|
|
8
7
|
{{on "keydown" this.lockTab}}
|
|
9
8
|
...attributes
|
|
10
9
|
>
|
|
@@ -47,7 +46,6 @@
|
|
|
47
46
|
<div
|
|
48
47
|
{{popover}}
|
|
49
48
|
class="pix-select__dropdown{{unless this.isExpanded ' pix-select__dropdown--closed'}}"
|
|
50
|
-
id={{this.dropDownId}}
|
|
51
49
|
{{on "transitionend" this.focus}}
|
|
52
50
|
>
|
|
53
51
|
{{#if @isSearchable}}
|
|
@@ -1,30 +1,47 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { inject as service } from '@ember/service';
|
|
3
4
|
import { action } from '@ember/object';
|
|
4
5
|
import { guidFor } from '@ember/object/internals';
|
|
5
|
-
import { createClass } from '../common/add-dynamic-style-tag';
|
|
6
6
|
|
|
7
7
|
export default class PixSelect extends Component {
|
|
8
|
+
@service elementHelper;
|
|
8
9
|
@tracked isExpanded = false;
|
|
9
10
|
@tracked searchValue = null;
|
|
10
|
-
searchId = 'search-input-' + guidFor(this);
|
|
11
11
|
|
|
12
12
|
constructor(...args) {
|
|
13
13
|
super(...args);
|
|
14
14
|
|
|
15
15
|
const categories = [];
|
|
16
|
+
|
|
17
|
+
this.searchId = 'search-input-' + guidFor(this);
|
|
18
|
+
this.selectId = this.args.id ? this.args.id : 'select-' + guidFor(this);
|
|
19
|
+
this.listId = `listbox-${this.selectId}`;
|
|
20
|
+
|
|
16
21
|
this.args.options.forEach((element) => {
|
|
17
22
|
if (!categories.includes(element.category) && element.category !== undefined) {
|
|
18
23
|
categories.push(element.category);
|
|
19
24
|
}
|
|
20
25
|
});
|
|
21
|
-
|
|
22
26
|
this.displayCategory = categories.length > 0;
|
|
23
|
-
}
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
if (!this.args.isComputeWidthDisabled) {
|
|
29
|
+
this.elementHelper.waitForElement(this.selectId).then((elementList) => {
|
|
30
|
+
const baseFontRemRatio = Number(
|
|
31
|
+
getComputedStyle(document.querySelector('html')).fontSize.match(/\d+(\.\d+)?/)[0],
|
|
32
|
+
);
|
|
33
|
+
const checkIconWidth = 1.125 * baseFontRemRatio;
|
|
34
|
+
const listWidth = elementList.getBoundingClientRect().width;
|
|
35
|
+
const selectWidth = (listWidth + checkIconWidth) / baseFontRemRatio;
|
|
36
|
+
|
|
37
|
+
const className = `sizing-select-${this.selectId}`;
|
|
38
|
+
this.elementHelper.createClass(`.${className}`, `width: ${selectWidth}rem;`);
|
|
39
|
+
|
|
40
|
+
const element = document.getElementById(`container-${this.selectId}`);
|
|
41
|
+
|
|
42
|
+
element.className = element.className + ' ' + className;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
28
45
|
}
|
|
29
46
|
|
|
30
47
|
get displayDefaultOption() {
|
|
@@ -51,14 +68,6 @@ export default class PixSelect extends Component {
|
|
|
51
68
|
return this.isExpanded ? 'true' : 'false';
|
|
52
69
|
}
|
|
53
70
|
|
|
54
|
-
get listId() {
|
|
55
|
-
return `listbox-${this.selectId}`;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
get dropDownId() {
|
|
59
|
-
return `dropdown-${this.selectId}`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
71
|
get placeholder() {
|
|
63
72
|
if (!this.args.value) return this.args.placeholder;
|
|
64
73
|
const option = this.args.options.find((option) => option.value === this.args.value);
|
|
@@ -155,23 +164,4 @@ export default class PixSelect extends Component {
|
|
|
155
164
|
}
|
|
156
165
|
}
|
|
157
166
|
}
|
|
158
|
-
|
|
159
|
-
@action
|
|
160
|
-
setSelectWidth() {
|
|
161
|
-
if (!this.args.isComputeWidthDisabled) {
|
|
162
|
-
const baseFontRemRatio = Number(
|
|
163
|
-
getComputedStyle(document.querySelector('html')).fontSize.match(/\d+(\.\d+)?/)[0],
|
|
164
|
-
);
|
|
165
|
-
const checkIconWidth = 1.125 * baseFontRemRatio;
|
|
166
|
-
const listWidth = document.getElementById(this.listId).getBoundingClientRect().width;
|
|
167
|
-
const selectWidth = (listWidth + checkIconWidth) / baseFontRemRatio;
|
|
168
|
-
|
|
169
|
-
const className = `sizing-select-${this.selectId}`;
|
|
170
|
-
createClass(`.${className}`, `width: ${selectWidth}rem;`);
|
|
171
|
-
|
|
172
|
-
const element = document.getElementById(`container-${this.selectId}`);
|
|
173
|
-
|
|
174
|
-
element.className = element.className + ' ' + className;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
167
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import Service from '@ember/service';
|
|
2
|
+
|
|
3
|
+
export default class ElementService extends Service {
|
|
4
|
+
waitForElement(id) {
|
|
5
|
+
return new Promise((resolve) => {
|
|
6
|
+
if (document.getElementById(id)) {
|
|
7
|
+
return resolve(document.getElementById(id));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const observer = new MutationObserver(() => {
|
|
11
|
+
if (document.getElementById(id)) {
|
|
12
|
+
resolve(document.getElementById(id));
|
|
13
|
+
observer.disconnect();
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
observer.observe(document.body, {
|
|
18
|
+
childList: true,
|
|
19
|
+
subtree: true,
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
createClass(name, rules) {
|
|
25
|
+
var style = document.createElement('style');
|
|
26
|
+
style.type = 'text/css';
|
|
27
|
+
document.getElementsByTagName('head')[0].appendChild(style);
|
|
28
|
+
|
|
29
|
+
if (!(style.sheet || {}).insertRule) (style.styleSheet || style.sheet).addRule(name, rules);
|
|
30
|
+
else style.sheet.insertRule(name + '{' + rules + '}', 0);
|
|
31
|
+
}
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1024pix/pix-ui",
|
|
3
|
-
"version": "46.4.
|
|
3
|
+
"version": "46.4.3",
|
|
4
4
|
"description": "Pix-UI is the implementation of Pix design principles and guidelines for its products.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
"@babel/eslint-parser": "^7.19.1",
|
|
65
65
|
"@babel/plugin-proposal-decorators": "^7.20.5",
|
|
66
66
|
"@ember/optional-features": "^2.0.0",
|
|
67
|
-
"@ember/render-modifiers": "^2.0.5",
|
|
68
67
|
"@ember/string": "^3.0.1",
|
|
69
68
|
"@ember/test-helpers": "^3.0.0",
|
|
70
69
|
"@embroider/macros": "^1.11.0",
|
|
@@ -106,7 +105,7 @@
|
|
|
106
105
|
"ember-sinon": "^5.0.0",
|
|
107
106
|
"ember-source": "^4.0.1",
|
|
108
107
|
"ember-source-channel-url": "^3.0.0",
|
|
109
|
-
"ember-template-lint": "^
|
|
108
|
+
"ember-template-lint": "^6.0.0",
|
|
110
109
|
"ember-template-lint-plugin-prettier": "^5.0.0",
|
|
111
110
|
"ember-try": "^3.0.0-beta",
|
|
112
111
|
"eslint": "^8.28.0",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export function createClass(name, rules) {
|
|
2
|
-
var style = document.createElement('style');
|
|
3
|
-
style.type = 'text/css';
|
|
4
|
-
document.getElementsByTagName('head')[0].appendChild(style);
|
|
5
|
-
|
|
6
|
-
if (!(style.sheet || {}).insertRule) (style.styleSheet || style.sheet).addRule(name, rules);
|
|
7
|
-
else style.sheet.insertRule(name + '{' + rules + '}', 0);
|
|
8
|
-
}
|