Directives for sham-ui-templates
# npm
npm install sham-ui-directives
# yarn
yarn add sham-ui-directives
- disabled
- EventListener
- onclick
- onsubmit
- onload
- onresize
- onscroll
- oninput
- onselect
- ref
- UpdateOnEvent
- onChangeUpdate
- onInputUpdate
Directive for "disabled" attribute
<template>
<input :disabled={{inputDisabled}}/>
</template>
<script>
import { disabled } from 'sham-ui-directives';
function extendContext() {
this.ctx.appendDirectives( { disabled } );
}
function Input( options ) {
options( {
[ $.inputDisabled ]: true
} );
}
export default Component( extendContext, Template, Input );
</script>
Base directive class for event listener
type
import { EventListener } from 'sham-ui-directives';
// directive for 'click' event listener
class onclick extends EventListener {
constructor() {
super( 'click' );
}
}
Extends EventListener
Directive for 'click' listener
<template>
<button :onclick={{() => window.alert( 'Clicked' )}}>Click me!</button>
</template>
<script>
import { onclick } from 'sham-ui-directives';
function extendContext() {
this.ctx.appendDirectives( { onclick } );
}
export default Component( extendContext, Template );
</script>
Extends EventListener
Directive for 'submit' listener
Extends EventListener
Directive for 'load' listener
Extends EventListener
Directive for 'resize' listener
Extends EventListener
Directive for 'scroll' listener
Extends EventListener
Directive for 'input' listener
Extends EventListener
Directive for 'select' listener
Directive for reference to Node
component
<template>
<input :ref={{$.inputField}} value="default value"/>
</template>
<script>
import { ref } from 'sham-ui-directives';
function extendContext() {
this.ctx.appendDirectives( { ref } );
}
function Input( options, didMount ) {
didMount( () => {
alert( this.inputField.value );
} )
}
export default Component( extendContext, Template, Input );
</script>
Base directive class for event listener
component
type
import { UpdateOnEvent } from 'sham-ui-directives';
// directive for update on 'input' event listener
class updateOnEvent extends UpdateOnEvent {
constructor() {
super( 'input' );
}
}
Extends UpdateOnEvent
Update on 'change' event
component
Extends UpdateOnEvent
Update on 'input' event
component