-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from fleetbase/dev-v0.2.11
v0.2.11
- Loading branch information
Showing
5 changed files
with
65 additions
and
38 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 |
---|---|---|
@@ -1,46 +1,61 @@ | ||
import Component from '@glimmer/component'; | ||
import { computed, action } from '@ember/object'; | ||
import { isBlank } from '@ember/utils'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class DropdownButtonComponent extends Component { | ||
@tracked type = 'default'; | ||
@tracked buttonSize = 'md'; | ||
@tracked buttonComponentArgs = {}; | ||
@tracked _onInsertFired = false; | ||
@tracked _onTriggerInsertFired = false; | ||
@tracked _onButtonInsertFired = false; | ||
|
||
/** | ||
* Default button type | ||
* | ||
* @var {String} | ||
* Creates an instance of DropdownButtonComponent. | ||
* @param {ApplicationInstance} owner | ||
* @param {Object} { type = 'default', size = 'md', buttonComponentArgs = {}} | ||
* @memberof DropdownButtonComponent | ||
*/ | ||
@computed('args.type') get type() { | ||
return this.args.type ?? 'default'; | ||
constructor(owner, { type = 'default', size = 'md', buttonComponentArgs = {} }) { | ||
super(...arguments); | ||
|
||
this.type = type; | ||
this.buttonSize = size; | ||
this.buttonComponentArgs = buttonComponentArgs; | ||
} | ||
|
||
/** | ||
* Default button size | ||
* | ||
* @var {String} | ||
*/ | ||
@computed('args.size') get buttonSize() { | ||
return this.args.size ?? 'md'; | ||
@action onRegisterAPI() { | ||
if (typeof this.args.registerAPI === 'function') { | ||
this.args.registerAPI(...arguments); | ||
} | ||
} | ||
|
||
/** | ||
* Additional arguments for a passed buttonComponent | ||
* | ||
* @readonly | ||
* @memberof DropdownButtonComponent | ||
*/ | ||
@computed('args.buttonComponentArgs') get buttonComponentArgs() { | ||
const { buttonComponentArgs } = this.args; | ||
@action onTriggerInsert() { | ||
if (typeof this.args.onTriggerInsert === 'function') { | ||
this.args.onTriggerInsert(...arguments); | ||
} | ||
|
||
return isBlank(buttonComponentArgs) || typeof buttonComponentArgs !== 'object' ? {} : buttonComponentArgs; | ||
this._onTriggerInsertFired = true; | ||
|
||
// Fallback for insert, when `renderInPlace=false` Trigger becomes whole node | ||
if (this.args.renderInPlace === true || this._onInsertFired === false) { | ||
this.onInsert(...arguments); | ||
} | ||
} | ||
|
||
@action onButtonInsert() { | ||
if (typeof this.args.onButtonInsert === 'function') { | ||
this.args.onButtonInsert(...arguments); | ||
} | ||
|
||
this._onButtonInsertFired = true; | ||
} | ||
|
||
/** | ||
* Trigger callback when dropdown button node is inserted to dom. | ||
* | ||
* @memberof DropdownButtonComponent | ||
*/ | ||
@action onInsert() { | ||
if (typeof this.args.onInsert === 'function') { | ||
this.args.onInsert(...arguments); | ||
} | ||
|
||
this._onInsertFired = true; | ||
} | ||
} |
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
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