Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
236 additions
and
138 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ | |
coverage | ||
dist | ||
docs/dist | ||
doc | ||
node_modules | ||
npm-debug.log |
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,9 @@ | ||
{ | ||
"source": { | ||
"include": ["./README.md", "./src"] | ||
}, | ||
"opts": { | ||
"destination": "doc", | ||
"recurse": 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
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,3 +1,20 @@ | ||
export const ACTION_BASE = 'ACTION_BASE'; | ||
export const ACTION_INPUT = 'ACTION_INPUT'; | ||
export const ACTION_COMBO = 'ACTION_COMBO'; | ||
|
||
/** | ||
* Enum Action types. | ||
* @readonly | ||
* @name ACTION_TYPE | ||
* @enum {string} | ||
*/ | ||
const ACTION_TYPE = { | ||
/** Action base */ | ||
ACTION_BASE: 'ACTION_BASE', | ||
/** Action input */ | ||
ACTION_INPUT: 'ACTION_INPUT', | ||
/** Action combo */ | ||
ACTION_COMBO: 'ACTION_COMBO', | ||
}; | ||
|
||
export default ACTION_TYPE; |
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,16 +1,39 @@ | ||
import { ACTION_BASE } from './ACTION_TYPE'; | ||
|
||
export default class Action { | ||
/** | ||
* Action to interact with | ||
* | ||
* @property {string} name Name | ||
* @property {string} description Description | ||
* @property {ACTION_TYPE} type Type | ||
*/ | ||
class Action { | ||
/** | ||
* Creates an instance of Action. | ||
* @param {string} [name=''] Name | ||
* @param {string} [description=''] Description | ||
* | ||
* @memberOf Action | ||
*/ | ||
constructor(name = '', description = '') { | ||
this.name = name; | ||
this.description = description; | ||
this.type = ACTION_BASE; | ||
} | ||
|
||
/** | ||
* Test if action is valid | ||
* | ||
* @returns {boolean} | ||
* | ||
* @memberOf Action | ||
*/ | ||
isValid() { | ||
if (this.name) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
|
||
export default Action; |
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,22 +1,57 @@ | ||
import Action from './Action'; | ||
import { ACTION_INPUT } from './ACTION_TYPE'; | ||
|
||
export default class ActionInput extends Action { | ||
constructor(name, description, required = false, defaultValue = '') { | ||
/** | ||
* Action which take an input | ||
* | ||
* @extends {Action} | ||
* @property {boolean} [required=false] Required | ||
* @property {string} [value=''] Value | ||
* @property {string} [defaultValue=''] DefaultValue | ||
* @deprecated Property defaultValue | ||
*/ | ||
class ActionInput extends Action { | ||
/** | ||
* Creates an instance of ActionInput. | ||
* @param {string} name | ||
* @param {string} description | ||
* @param {boolean} [required=false] | ||
* @param {string} [value=''] | ||
* | ||
* @memberOf ActionInput | ||
*/ | ||
constructor(name, description, required = false, value = '') { | ||
super(name, description); | ||
this.type = ACTION_INPUT; | ||
this.required = required; | ||
this.defaultValue = defaultValue; | ||
this.value = defaultValue; | ||
this.defaultValue = value; | ||
this.value = value; | ||
} | ||
|
||
/** | ||
* Set value | ||
* | ||
* @param {string} value | ||
* @returns {boolean} | ||
* | ||
* @memberOf ActionInput | ||
*/ | ||
setValue(value) { | ||
this.value = value; | ||
return true; | ||
} | ||
|
||
/** | ||
* Test if valid | ||
* | ||
* @returns {boolean} | ||
* | ||
* @memberOf ActionInput | ||
*/ | ||
isValid() { | ||
if (this.required && !this.value) return false; | ||
return true; | ||
} | ||
} | ||
|
||
export default ActionInput; |
Oops, something went wrong.