mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
32 lines
669 B
JavaScript
32 lines
669 B
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Helper from '@ember/component/helper';
|
|
import { inject as service } from '@ember/service';
|
|
|
|
/**
|
|
`{{keyboard-commands}}` helper used to initialize and tear down contextual keynav commands
|
|
@public
|
|
@method keyboard-commands
|
|
*/
|
|
export default class keyboardCommands extends Helper {
|
|
@service keyboard;
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
}
|
|
|
|
compute([commands]) {
|
|
if (commands) {
|
|
this.commands = commands;
|
|
this.keyboard.addCommands(commands);
|
|
}
|
|
}
|
|
willDestroy() {
|
|
super.willDestroy();
|
|
this.keyboard.removeCommands(this.commands);
|
|
}
|
|
}
|