@ember-eui/core 7.1.1 → 7.1.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/eui-combo-box/index.ts +8 -8
- package/addon/components/eui-combo-box/options/index.js +2 -1
- package/addon/components/eui-combo-box/trigger/index.hbs +34 -34
- package/addon/components/eui-combo-box/trigger/index.js +1 -55
- package/addon/components/eui-combo-box/trigger/input/index.hbs +38 -0
- package/addon/components/eui-combo-box/trigger/input/index.ts +63 -0
- package/app/components/eui-combo-box/trigger/input/index.js +1 -0
- package/package.json +2 -2
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { action } from '@ember/object';
|
|
3
3
|
import { tracked, cached } from '@glimmer/tracking';
|
|
4
|
-
//@ts-ignore
|
|
5
4
|
import { emberPowerSelectIsGroup } from 'ember-power-select/helpers/ember-power-select-is-group';
|
|
6
5
|
import { isEqual } from '@ember/utils';
|
|
7
6
|
|
|
@@ -23,16 +22,17 @@ interface Select {
|
|
|
23
22
|
};
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
interface
|
|
27
|
-
|
|
25
|
+
interface Sliceable<T> {
|
|
26
|
+
slice(): T[];
|
|
28
27
|
}
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
|
|
29
|
+
const isSliceable = <T>(coll: any): coll is Sliceable<T> => {
|
|
30
|
+
return typeof coll.slice === 'function' && typeof coll.sort === 'function';
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
const toPlainArray = <T>(collection: T[] |
|
|
34
|
-
if (
|
|
35
|
-
return collection.
|
|
33
|
+
export const toPlainArray = <T>(collection: T[] | Sliceable<T>): T[] => {
|
|
34
|
+
if (isSliceable<T>(collection)) {
|
|
35
|
+
return collection.slice();
|
|
36
36
|
} else {
|
|
37
37
|
return collection;
|
|
38
38
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import EmberPowerSelectOptions from 'ember-power-select/components/power-select/options';
|
|
2
2
|
import { emberPowerSelectIsGroup } from 'ember-power-select/helpers/ember-power-select-is-group';
|
|
3
3
|
import config from 'ember-get-config';
|
|
4
|
+
import { toPlainArray } from '..';
|
|
4
5
|
|
|
5
6
|
export default class EuiComboBoxOptionsComponent extends EmberPowerSelectOptions {
|
|
6
7
|
_optionsCache = [];
|
|
@@ -22,7 +23,7 @@ export default class EuiComboBoxOptionsComponent extends EmberPowerSelectOptions
|
|
|
22
23
|
|
|
23
24
|
_optionFromIndex(index) {
|
|
24
25
|
let parts = index.split('.');
|
|
25
|
-
let option = this.flattedOptions
|
|
26
|
+
let option = toPlainArray(this.flattedOptions).at?.(parseInt(parts[0], 10));
|
|
26
27
|
for (let i = 1; i < parts.length; i++) {
|
|
27
28
|
option = option.options[parseInt(parts[i], 10)];
|
|
28
29
|
}
|
|
@@ -69,44 +69,44 @@
|
|
|
69
69
|
{{/each}}
|
|
70
70
|
{{/if}}
|
|
71
71
|
{{#if @searchEnabled}}
|
|
72
|
-
{{! template-lint-disable }}
|
|
73
72
|
{{#if (and this.maybePlaceholder (not @select.searchText))}}
|
|
74
73
|
<p class="euiComboBoxPlaceholder">
|
|
75
74
|
{{this.maybePlaceholder}}
|
|
76
75
|
</p>
|
|
77
76
|
{{/if}}
|
|
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
|
-
|
|
77
|
+
|
|
78
|
+
{{#let
|
|
79
|
+
(component
|
|
80
|
+
"eui-combo-box/trigger/input"
|
|
81
|
+
select=@select
|
|
82
|
+
ariaActiveDescendant=@ariaActiveDescendant
|
|
83
|
+
ariaLabelledBy=@ariaLabelledBy
|
|
84
|
+
ariaLabel=@ariaLabel
|
|
85
|
+
listboxId=@listboxId
|
|
86
|
+
tabindex=@tabindex
|
|
87
|
+
buildSelection=@buildSelection
|
|
88
|
+
placeholder=@placeholder
|
|
89
|
+
placeholderComponent=@placeholderComponent
|
|
90
|
+
searchField=@searchField
|
|
91
|
+
onFocus=@onFocus
|
|
92
|
+
onBlur=@onBlur
|
|
93
|
+
onKeydown=@onKeydown
|
|
94
|
+
onInput=@onInput
|
|
95
|
+
onCreateOption=@onCreateOption
|
|
96
|
+
)
|
|
97
|
+
as |InputComponent|
|
|
98
|
+
}}
|
|
99
|
+
{{component
|
|
100
|
+
(ensure-safe-component @placeholderComponent)
|
|
101
|
+
select=@select
|
|
102
|
+
placeholder=@placeholder
|
|
103
|
+
isMutlipleWithSearch=true
|
|
104
|
+
inputComponent=InputComponent
|
|
105
|
+
displayPlaceholder=(and
|
|
106
|
+
(not @select.searchText) (not @select.selected)
|
|
107
|
+
)
|
|
108
|
+
}}
|
|
109
|
+
{{/let}}
|
|
110
110
|
{{else}}
|
|
111
111
|
{{! template-lint-disable }}
|
|
112
112
|
<div
|
|
@@ -117,4 +117,4 @@
|
|
|
117
117
|
{{/if}}
|
|
118
118
|
</ul>
|
|
119
119
|
</:field>
|
|
120
|
-
</EuiFormControlLayout>
|
|
120
|
+
</EuiFormControlLayout>
|
|
@@ -1,57 +1,3 @@
|
|
|
1
1
|
import EmberPowerSelectMultipleTrigger from 'ember-power-select/components/power-select-multiple/trigger';
|
|
2
|
-
import { action } from '@ember/object';
|
|
3
|
-
import { isBlank } from '@ember/utils';
|
|
4
|
-
import { scheduleOnce } from '@ember/runloop';
|
|
5
|
-
import { htmlSafe } from '@ember/template';
|
|
6
2
|
|
|
7
|
-
export default class EuiComboBoxTriggerComponent extends EmberPowerSelectMultipleTrigger {
|
|
8
|
-
get triggerMultipleInputStyle() {
|
|
9
|
-
scheduleOnce('actions', null, this.args.select.actions.reposition);
|
|
10
|
-
|
|
11
|
-
let textWidth = 0;
|
|
12
|
-
if (this.inputFont) {
|
|
13
|
-
textWidth = this.textMeasurer.width(
|
|
14
|
-
this.args.select.searchText,
|
|
15
|
-
this.inputFont
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
return htmlSafe(`box-sizing: content-box; width: ${textWidth + 2}px`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@action
|
|
22
|
-
handleKeydown(e) {
|
|
23
|
-
if (e.target === null) return;
|
|
24
|
-
if (this.args.onKeydown && this.args.onKeydown(e) === false) {
|
|
25
|
-
if (
|
|
26
|
-
this.args.onCreateOption && //if user wants to create an option and
|
|
27
|
-
e.keyCode === 13 && //presses [Enter] and
|
|
28
|
-
(this.args.select.options.length === 0 || //If There are no options or
|
|
29
|
-
this.args.select.results.length === 0) && //Last search made returned no results and
|
|
30
|
-
this.args.select.searchText.length >= 1 //There's something in the searchText box
|
|
31
|
-
) {
|
|
32
|
-
this.args.onCreateOption();
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
e.stopPropagation();
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
if (e.keyCode === 8) {
|
|
39
|
-
e.stopPropagation();
|
|
40
|
-
if (isBlank(e.target.value)) {
|
|
41
|
-
let lastSelection =
|
|
42
|
-
this.args.select.selected[this.args.select.selected.length - 1];
|
|
43
|
-
if (lastSelection) {
|
|
44
|
-
this.args.select.actions.select(
|
|
45
|
-
this.args.buildSelection(lastSelection, this.args.select),
|
|
46
|
-
e
|
|
47
|
-
);
|
|
48
|
-
this.args.select.actions.search('');
|
|
49
|
-
this.args.select.actions.open(e);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
} else if ((e.keyCode >= 48 && e.keyCode <= 90) || e.keyCode === 32) {
|
|
53
|
-
// Keys 0-9, a-z or SPACE
|
|
54
|
-
e.stopPropagation();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
3
|
+
export default class EuiComboBoxTriggerComponent extends EmberPowerSelectMultipleTrigger {}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{{!template-lint-disable}}
|
|
2
|
+
{{#if (and this.maybePlaceholder (not @select.searchText))}}
|
|
3
|
+
<p class="euiComboBoxPlaceholder">
|
|
4
|
+
{{this.maybePlaceholder}}
|
|
5
|
+
</p>
|
|
6
|
+
{{/if}}
|
|
7
|
+
<div
|
|
8
|
+
class="euiComboBox__input"
|
|
9
|
+
style="font-size: 14px; display: inline-block; position: relative;"
|
|
10
|
+
>
|
|
11
|
+
<input
|
|
12
|
+
tabindex="-1"
|
|
13
|
+
style="opacity: 0px; width:0px; height:0px; position: absolute; top: 40%; border:solid 1px transparent !important; margin:0px !important;"
|
|
14
|
+
class="fake-input-for-html-form-validity"
|
|
15
|
+
{{validatable-control @isInvalid}}
|
|
16
|
+
/>
|
|
17
|
+
<input
|
|
18
|
+
class="ember-power-select-trigger-multiple-input euiComboBox__input"
|
|
19
|
+
autocomplete="off"
|
|
20
|
+
autocorrect="off"
|
|
21
|
+
autocapitalize="off"
|
|
22
|
+
autofocus={{@autoFocus}}
|
|
23
|
+
spellcheck={{false}}
|
|
24
|
+
id="ember-power-select-trigger-multiple-input-{{@select.uniqueId}}"
|
|
25
|
+
value={{@select.searchText}}
|
|
26
|
+
aria-controls={{@listboxId}}
|
|
27
|
+
style={{this.triggerMultipleInputStyle}}
|
|
28
|
+
disabled={{@select.disabled}}
|
|
29
|
+
tabindex={{@tabindex}}
|
|
30
|
+
form="power-select-fake-form"
|
|
31
|
+
{{on "focus" @onFocus}}
|
|
32
|
+
{{on "blur" @onBlur}}
|
|
33
|
+
{{on "input" this.handleInput}}
|
|
34
|
+
{{on "keydown" this.handleKeydown}}
|
|
35
|
+
{{did-insert this.storeInputStyles}}
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
{{!template-lint-enable}}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import EmberPowerSelectPowerSelectMultipleTriggerInputComponent from 'ember-power-select/components/power-select-multiple/input';
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
import { isBlank } from '@ember/utils';
|
|
4
|
+
|
|
5
|
+
import { htmlSafe } from '@ember/template';
|
|
6
|
+
|
|
7
|
+
import { scheduleOnce } from '@ember/runloop';
|
|
8
|
+
|
|
9
|
+
export default class EuiComboBoxTriggerInputComponent extends EmberPowerSelectPowerSelectMultipleTriggerInputComponent {
|
|
10
|
+
get triggerMultipleInputStyle() {
|
|
11
|
+
scheduleOnce('actions', null, this.args.select.actions.reposition);
|
|
12
|
+
|
|
13
|
+
let textWidth = 0;
|
|
14
|
+
// @ts-expect-error
|
|
15
|
+
if (this.inputFont) {
|
|
16
|
+
textWidth = this.textMeasurer.width(
|
|
17
|
+
this.args.select.searchText,
|
|
18
|
+
// @ts-expect-error
|
|
19
|
+
this.inputFont
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
return htmlSafe(`box-sizing: content-box; width: ${textWidth + 2}px`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@action
|
|
26
|
+
handleKeydown(e: KeyboardEvent): false | void {
|
|
27
|
+
if (e.target === null) return;
|
|
28
|
+
if (this.args.onKeydown && this.args.onKeydown(e) === false) {
|
|
29
|
+
if (
|
|
30
|
+
// @ts-expect-error
|
|
31
|
+
this.args.onCreateOption && //if user wants to create an option and
|
|
32
|
+
e.keyCode === 13 && //presses [Enter] and
|
|
33
|
+
(this.args.select.options.length === 0 || //If There are no options or
|
|
34
|
+
this.args.select.results.length === 0) && //Last search made returned no results and
|
|
35
|
+
this.args.select.searchText.length >= 1 //There's something in the searchText box
|
|
36
|
+
) {
|
|
37
|
+
// @ts-expect-error
|
|
38
|
+
this.args.onCreateOption();
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
if (e.keyCode === 8) {
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
if (isBlank((e.target as HTMLInputElement).value)) {
|
|
47
|
+
let lastSelection =
|
|
48
|
+
this.args.select.selected[this.args.select.selected.length - 1];
|
|
49
|
+
if (lastSelection) {
|
|
50
|
+
this.args.select.actions.select(
|
|
51
|
+
this.args.buildSelection(lastSelection, this.args.select),
|
|
52
|
+
e
|
|
53
|
+
);
|
|
54
|
+
this.args.select.actions.search('');
|
|
55
|
+
this.args.select.actions.open(e);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} else if ((e.keyCode >= 48 && e.keyCode <= 90) || e.keyCode === 32) {
|
|
59
|
+
// Keys 0-9, a-z or SPACE
|
|
60
|
+
e.stopPropagation();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-combo-box/trigger/input';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-eui/core",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.3",
|
|
4
4
|
"description": "Ember Components for Elastic UI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -186,5 +186,5 @@
|
|
|
186
186
|
"volta": {
|
|
187
187
|
"extends": "../../package.json"
|
|
188
188
|
},
|
|
189
|
-
"gitHead": "
|
|
189
|
+
"gitHead": "b31eb2bf6cd5c5c15a271a88b7d7386df271ed4d"
|
|
190
190
|
}
|