-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
dd6eb17
commit ca5b74f
Showing
8 changed files
with
220 additions
and
43 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,100 @@ | ||
<template> | ||
<div> | ||
<input | ||
ref="input" | ||
v-model="val" | ||
@input="updateValue($event.target.value)" | ||
@change="emitChange" | ||
/> | ||
<button @click="fireEvent()">Fire example event!</button> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
/** | ||
* An input field with a button | ||
*/ | ||
export default { | ||
name: 'Input', | ||
model: { | ||
prop: 'value', | ||
}, | ||
props: { | ||
value: { | ||
default: null, | ||
type: [Number, String], | ||
}, | ||
/** | ||
* Using for: String.prototype.replace(regexp, replacement) | ||
*/ | ||
regExp: { | ||
type: RegExp, | ||
default: null, | ||
}, | ||
/** | ||
* Using for: String.prototype.replace(regexp, replacement) | ||
*/ | ||
replacement: { | ||
type: String, | ||
default: '', | ||
}, | ||
}, | ||
data() { | ||
return { | ||
val: '', | ||
}; | ||
}, | ||
watch: { | ||
// watch value prop | ||
value(val) { | ||
this.updateValue(val); | ||
}, | ||
}, | ||
mounted() { | ||
this.updateValue(this.value); | ||
}, | ||
methods: { | ||
// format the value of input | ||
formatValue(val) { | ||
const formattedValue = !val ? '' : val.toString().replace(this.regExp, this.replacement); | ||
return formattedValue; | ||
}, | ||
updateValue(val) { | ||
const formattedValue = this.formatValue(val); | ||
this.val = formattedValue; | ||
this.emitInput(formattedValue); | ||
}, | ||
emitInput(val) { | ||
/** | ||
* Input event | ||
* @event input | ||
* @type {number|string} | ||
* @property {number} called - test called | ||
* @property {boolean} isPacked - Indicates whether the snowball is tightly packed. | ||
*/ | ||
this.$emit('input', val, 1, false); | ||
}, | ||
// emit change event | ||
emitChange() { | ||
/** | ||
* Change event | ||
* @event change | ||
*/ | ||
this.$emit('change', this.val); | ||
}, | ||
fireEvent() { | ||
/** | ||
* Fire event | ||
* @event fire | ||
* @type {string} | ||
*/ | ||
this.$emit('fire', 'hello fire!!'); | ||
}, | ||
}, | ||
}; | ||
</script> |
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,11 +1,33 @@ | ||
<template> | ||
<h3>Events</h3> | ||
<table> | ||
<tr> | ||
<td>Events</td> | ||
</tr> | ||
<thead> | ||
<th>Name</th> | ||
<th>Description</th> | ||
<th>Properties</th> | ||
</thead> | ||
<tbody> | ||
<tr v-for="event in events" :key="event.name"> | ||
<td>{{ event.name }}</td> | ||
<td>{{ event.description }}</td> | ||
<td> | ||
<li v-for="property in event.properties"> | ||
<strong>{{ property.name }}</strong> {{ property.type.names.join('|') }} - | ||
{{ property.description }} | ||
</li> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</template> | ||
|
||
<script> | ||
export default {}; | ||
export default { | ||
props: { | ||
events: { | ||
type: Array, | ||
required: true, | ||
}, | ||
}, | ||
}; | ||
</script> |
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,11 +1,28 @@ | ||
<template> | ||
<h3>Props</h3> | ||
<table> | ||
<tr> | ||
<td>Props</td> | ||
</tr> | ||
<thead> | ||
<th>Name</th> | ||
<th>Description</th> | ||
<th>Type</th> | ||
</thead> | ||
<tbody> | ||
<tr v-for="prop in props" :key="prop.name"> | ||
<td>{{ prop.name }}</td> | ||
<td>{{ prop.description }}</td> | ||
<td>{{ prop.type.name }}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</template> | ||
|
||
<script> | ||
export default {}; | ||
export default { | ||
props: { | ||
props: { | ||
type: Array, | ||
required: true, | ||
}, | ||
}, | ||
}; | ||
</script> |
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,11 +1,26 @@ | ||
<template> | ||
<h3>Slots</h3> | ||
<table> | ||
<tr> | ||
<td>Slots</td> | ||
</tr> | ||
<thead> | ||
<th>Name</th> | ||
<th>Description</th> | ||
</thead> | ||
<tbody> | ||
<tr v-for="slot in slots" :key="slot.name"> | ||
<td>{{ slot.name }}</td> | ||
<td>{{ slot.description }}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</template> | ||
|
||
<script> | ||
export default {}; | ||
export default { | ||
props: { | ||
slots: { | ||
type: Array, | ||
required: true, | ||
}, | ||
}, | ||
}; | ||
</script> |