@ascua/dropdown 0.4.6 → 0.6.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/addon/components/dropdown.js +14 -14
- package/package.json +8 -8
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { tracked } from '@glimmer/tracking';
|
|
3
|
-
import {
|
|
3
|
+
import { service } from '@ember/service';
|
|
4
4
|
import { action } from '@ember/object';
|
|
5
5
|
import { get } from '@ember/object';
|
|
6
6
|
|
|
7
7
|
export default class extends Component {
|
|
8
8
|
|
|
9
|
-
@
|
|
9
|
+
@service('-document') document;
|
|
10
10
|
|
|
11
11
|
@tracked top = 0;
|
|
12
12
|
|
|
@@ -46,20 +46,20 @@ export default class extends Component {
|
|
|
46
46
|
let t = this.element.getBoundingClientRect().top - 5;
|
|
47
47
|
let l = this.element.getBoundingClientRect().left - 5;
|
|
48
48
|
|
|
49
|
-
while (
|
|
50
|
-
while (
|
|
49
|
+
while (l + w > window.innerWidth - 30) l--;
|
|
50
|
+
while (t + h > window.innerHeight - 30) t--;
|
|
51
51
|
|
|
52
52
|
this.left = l; this.top = t;
|
|
53
53
|
|
|
54
|
-
setTimeout(
|
|
54
|
+
setTimeout(() => {
|
|
55
55
|
|
|
56
56
|
let w = element.offsetWidth;
|
|
57
57
|
let h = element.offsetHeight;
|
|
58
58
|
let t = this.element.getBoundingClientRect().top - 5;
|
|
59
59
|
let l = this.element.getBoundingClientRect().left - 5;
|
|
60
60
|
|
|
61
|
-
while (
|
|
62
|
-
while (
|
|
61
|
+
while (l + w > window.innerWidth - 30) l--;
|
|
62
|
+
while (t + h > window.innerHeight - 30) t--;
|
|
63
63
|
|
|
64
64
|
this.left = l; this.top = t;
|
|
65
65
|
|
|
@@ -72,7 +72,7 @@ export default class extends Component {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
@action didValue() {
|
|
75
|
-
if (
|
|
75
|
+
if (Array.isArray(this.args.value)) {
|
|
76
76
|
Promise.all(this.args.value).then(v => {
|
|
77
77
|
this.value = v;
|
|
78
78
|
});
|
|
@@ -84,7 +84,7 @@ export default class extends Component {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
@action register(el, value, label) {
|
|
87
|
-
setTimeout(
|
|
87
|
+
setTimeout(() => {
|
|
88
88
|
Promise.resolve(value).then(value => {
|
|
89
89
|
this.options.addObject({
|
|
90
90
|
el, label, value,
|
|
@@ -94,7 +94,7 @@ export default class extends Component {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
@action unregister(el, value, label) {
|
|
97
|
-
setTimeout(
|
|
97
|
+
setTimeout(() => {
|
|
98
98
|
Promise.resolve(value).then(value => {
|
|
99
99
|
this.options = this.options.filter(opt => {
|
|
100
100
|
return opt.el !== el;
|
|
@@ -104,7 +104,7 @@ export default class extends Component {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
@action reregister(el, value, label) {
|
|
107
|
-
setTimeout(
|
|
107
|
+
setTimeout(() => {
|
|
108
108
|
Promise.resolve(value).then(value => {
|
|
109
109
|
this.options = this.options.map(opt => {
|
|
110
110
|
return opt.el !== el ? opt : {
|
|
@@ -118,7 +118,7 @@ export default class extends Component {
|
|
|
118
118
|
@action async changed(value) {
|
|
119
119
|
|
|
120
120
|
if (this.args.multiple) {
|
|
121
|
-
if (
|
|
121
|
+
if (this.value.includes(value)) {
|
|
122
122
|
value = this.value.removeObject(value);
|
|
123
123
|
} else {
|
|
124
124
|
value = this.value.addObject(value);
|
|
@@ -145,8 +145,8 @@ export default class extends Component {
|
|
|
145
145
|
|
|
146
146
|
} else {
|
|
147
147
|
|
|
148
|
-
let label = this.options.reduce(
|
|
149
|
-
if (
|
|
148
|
+
let label = this.options.reduce((a, o, k) => {
|
|
149
|
+
if (this.value.includes(o.value)) {
|
|
150
150
|
a.push(o.label);
|
|
151
151
|
}
|
|
152
152
|
return a;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ascua/dropdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Small description for @ascua/dropdown goes here",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"url": "https://surrealdb.com"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@ascua/arrays": "^0.
|
|
19
|
-
"@ascua/format": "^0.
|
|
20
|
-
"@ascua/keyboard": "^0.
|
|
21
|
-
"@ascua/logic": "^0.
|
|
22
|
-
"@ascua/modifiers": "^0.
|
|
23
|
-
"@ascua/promise": "^0.
|
|
18
|
+
"@ascua/arrays": "^0.6.0",
|
|
19
|
+
"@ascua/format": "^0.6.0",
|
|
20
|
+
"@ascua/keyboard": "^0.6.0",
|
|
21
|
+
"@ascua/logic": "^0.6.0",
|
|
22
|
+
"@ascua/modifiers": "^0.6.0",
|
|
23
|
+
"@ascua/promise": "^0.6.0",
|
|
24
24
|
"ember-cli-babel": "^8.2.0",
|
|
25
25
|
"ember-cli-htmlbars": "^6.3.0"
|
|
26
26
|
},
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "56b63607322165599c91049cbb91e5241ca8234c"
|
|
35
35
|
}
|