This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dependency ember-power-select to v4 (#1528)
* Update dependency ember-power-select to v4 * Fixed trigger component override collision when building - move the "override" into our own namespace - update all `<PowerSelect>` usage to explicitly reference our customised trigger component * Bumped ember-power-datepicker - bumps `ember-basic-dropdown` sub-dependency - resolves "Error: Could not find module `ember-compatibility-helpers` imported from `@glimmer/component/index`" - cibernox/ember-basic-dropdown#551 * Updated trigger to use class syntax - it's not possible to use `.extend()` on an imported class * Updated <GhBasicDropdown> - match updated ember-basic-dropdown code * Added `autofocus` modifier - added `ember-modifier` dependency so that we can create our own render modifiers * Updated <GhSearchInputTrigger> to a glimmer component * Updated gh-token-input components * Fixed tests - wrap `<PowerSelect>` with `<div>` to maintain test selectors - fixed `<GhBasicDropdown>` not rendering anything due to not having a local template Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
- Loading branch information
1 parent
7e195b2
commit cc80214
Showing
22 changed files
with
300 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import PowerSelectTrigger from 'ember-power-select/components/power-select/trigger'; | ||
import templateLayout from '../../templates/components/gh-power-select/trigger'; | ||
import {layout} from '@ember-decorators/component'; | ||
|
||
@layout(templateLayout) | ||
export default class Trigger extends PowerSelectTrigger { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,59 @@ | ||
/* global key */ | ||
import Component from '@ember/component'; | ||
import Component from '@glimmer/component'; | ||
import {action} from '@ember/object'; | ||
import {isBlank} from '@ember/utils'; | ||
|
||
export default Component.extend({ | ||
actions: { | ||
captureMouseDown(e) { | ||
e.stopPropagation(); | ||
}, | ||
|
||
search(term) { | ||
// open dropdown if not open and term is present | ||
// close dropdown if open and term is blank | ||
if (isBlank(term) === this.select.isOpen) { | ||
isBlank(term) ? this.close() : this.open(); | ||
|
||
// ensure focus isn't lost when dropdown is closed | ||
if (isBlank(term)) { | ||
this._focusInput(); | ||
} | ||
} | ||
export default class GhSearchInputTrigger extends Component { | ||
@action | ||
registerInput(elem) { | ||
this.inputElem = elem; | ||
} | ||
|
||
this.select.actions.search(term); | ||
}, | ||
@action | ||
captureMousedown(e) { | ||
e.stopPropagation(); | ||
} | ||
|
||
focusInput() { | ||
this._focusInput(); | ||
}, | ||
@action | ||
search(event) { | ||
let term = event.target.value; | ||
|
||
// hacky workaround to let Escape clear the input if there's text, | ||
// but still allow it to close the search modal if there's no text | ||
handleKeydown(e) { | ||
if ((e.key === 'Escape' && e.target.value) || e.key === 'Enter') { | ||
this._previousKeyScope = key.getScope(); | ||
key.setScope('ignore'); | ||
} | ||
}, | ||
// open dropdown if not open and term is present | ||
// close dropdown if open and term is blank | ||
if (isBlank(term) === this.args.select.isOpen) { | ||
isBlank(term) ? this.close() : this.open(); | ||
|
||
handleKeyup() { | ||
if (key.getScope() === 'ignore') { | ||
key.setScope(this._previousKeyScope); | ||
// ensure focus isn't lost when dropdown is closed | ||
if (isBlank(term) && this.inputElem) { | ||
this.inputElem.focus(); | ||
} | ||
} | ||
}, | ||
|
||
open() { | ||
this.select.actions.open(); | ||
}, | ||
this.args.select.actions.search(term); | ||
} | ||
|
||
close() { | ||
this.select.actions.close(); | ||
}, | ||
// hacky workaround to let Escape clear the input if there's text, | ||
// but still allow it to close the search modal if there's no text | ||
@action | ||
handleKeydown(e) { | ||
if ((e.key === 'Escape' && e.target.value) || e.key === 'Enter') { | ||
this._previousKeyScope = key.getScope(); | ||
key.setScope('ignore'); | ||
} | ||
} | ||
|
||
_focusInput() { | ||
let input = this.element && this.element.querySelector('input'); | ||
if (input) { | ||
input.focus(); | ||
@action | ||
handleKeyup() { | ||
if (key.getScope() === 'ignore') { | ||
key.setScope(this._previousKeyScope); | ||
} | ||
} | ||
}); | ||
|
||
open() { | ||
this.args.select.actions.open(); | ||
} | ||
|
||
close() { | ||
this.args.select.actions.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import OptionsComponent from 'ember-power-select/components/power-select/options'; | ||
import layout from '../templates/components/power-select-vertical-collection-options'; | ||
import templateLayout from '../templates/components/power-select-vertical-collection-options'; | ||
import {layout} from '@ember-decorators/component'; | ||
|
||
export default OptionsComponent.extend({ | ||
layout | ||
}); | ||
@layout(templateLayout) | ||
export default class PowerSelectVerticalCollectionOptions extends OptionsComponent {} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import {modifier} from 'ember-modifier'; | ||
|
||
export default modifier(element => element.focus()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{{!-- no changes from upstream --}} | ||
{{#with | ||
(hash | ||
uniqueId=this.publicAPI.uniqueId | ||
isOpen=this.publicAPI.isOpen | ||
disabled=this.publicAPI.disabled | ||
actions=this.publicAPI.actions | ||
Trigger=(component | ||
(or @triggerComponent "basic-dropdown-trigger") | ||
dropdown=(readonly this.publicAPI) | ||
hPosition=(readonly this.hPosition) | ||
renderInPlace=(readonly this.renderInPlace) | ||
vPosition=(readonly this.vPosition) | ||
) | ||
Content=(component | ||
(or @contentComponent "basic-dropdown-content") | ||
dropdown=(readonly this.publicAPI) | ||
hPosition=(readonly this.hPosition) | ||
renderInPlace=(readonly this.renderInPlace) | ||
preventScroll=(readonly @preventScroll) | ||
rootEventType=(or @rootEventType "click") | ||
vPosition=(readonly this.vPosition) | ||
destination=(readonly this.destination) | ||
top=(readonly this.top) | ||
left=(readonly this.left) | ||
right=(readonly this.right) | ||
width=(readonly this.width) | ||
height=(readonly this.height) | ||
otherStyles=(readonly this.otherStyles) | ||
) | ||
) | ||
as |api| | ||
}} | ||
{{#if this.renderInPlace}} | ||
<div class="ember-basic-dropdown" ...attributes>{{yield api}}</div> | ||
{{else}} | ||
{{yield api}} | ||
{{/if}} | ||
{{/with}} |
Oops, something went wrong.