celerichain-ember-uii
Version:
Fleetbase UI provides all the interface components, helpers, services and utilities for building a Fleetbase extension into the Console.
62 lines (50 loc) • 1.93 kB
JavaScript
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class DropdownButtonComponent extends Component {
type = 'default';
buttonSize = 'md';
buttonComponentArgs = {};
_onInsertFired = false;
_onTriggerInsertFired = false;
_onButtonInsertFired = false;
/**
* Creates an instance of DropdownButtonComponent.
* @param {ApplicationInstance} owner
* @param {Object} { type = 'default', size = 'md', buttonComponentArgs = {}}
* @memberof DropdownButtonComponent
*/
constructor(owner, { type = 'default', size = 'md', buttonComponentArgs = {} }) {
super(...arguments);
this.type = type;
this.buttonSize = size;
this.buttonComponentArgs = buttonComponentArgs;
}
onRegisterAPI() {
if (typeof this.args.registerAPI === 'function') {
this.args.registerAPI(...arguments);
}
}
onTriggerInsert() {
if (typeof this.args.onTriggerInsert === 'function') {
this.args.onTriggerInsert(...arguments);
}
this._onTriggerInsertFired = true;
// Fallback for insert, when `renderInPlace=false` Trigger becomes whole node
if (this.args.renderInPlace === true || this._onInsertFired === false) {
this.onInsert(...arguments);
}
}
onButtonInsert() {
if (typeof this.args.onButtonInsert === 'function') {
this.args.onButtonInsert(...arguments);
}
this._onButtonInsertFired = true;
}
onInsert() {
if (typeof this.args.onInsert === 'function') {
this.args.onInsert(...arguments);
}
this._onInsertFired = true;
}
}