Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Smart a lightweight web component library that provides capabilities for web components, such as data binding, using es6 native class inheritance. This library is focused for providing the developer the ability to write robust and native web components without the need of dependencies and an overhead of a framework.

License

NotificationsYou must be signed in to change notification settings

HTMLElements/smart-custom-element

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SlackPricenpmGitHub package versionLicense: APACHE

JavaScript library that wraps the W3C standard Web Components family of APIs to provide a compact, feature-rich interface forCustom Elements development.

Smart Custom Element provides a set of useful API, Data Binding, Templates, Device Agnostic Event Handling, Resize handling, Style Change Notifications, Property and Attribute Change Notifications, Property Value and Type validation, Localization, Lifecycle callback functions and much more. Our framework allows you to easily build Custom HTML Elements. Custom Elements are the web platform's native solution for component-based development. With Custom Elements, you get reusable HTML tags that can be used just like the browser’s built-in native html elements, or break your app up into small pieces, making your code cleaner and easier to maintain.

Installation

  • npm install smart-custom-element --save

In your web page, include

<script src="source/smart.element.js"></script>

Optional polyfill for browsers without custom elements support:webcomponents-lite.js

Version and Deployment

Browser Support and Compatibility

Requires ES2015 classes. Edge, Chrome, Safari and Firefox. Requires Webcomponents polyfill for Edge and Safari

How to Use?

Include HTML tag (e.g.<my-button id='button'></my-button>) in any time of document lifecycle. You can use your elements in e.g. SPA application just by including HTML tag. Custom Elements will auto initialize when added into document. You can include them in e.g. Vue, Angular or React projects and browser will take care of detecting it and initialization. You use it just like a native HTML Element, by changing attributes withbutton.setAttribute(attributeName, attributeValue);, setting properties withbutton.disabled = true; or listening to events withbutton.addEventListener('click', function(event) { });.You also take advantage of features like lazy-loading, that allows for loading components on demand, only when user add them to document

Introduction

A basic element definition looks like this:

<!DOCTYPEhtml><htmllang="en"><head><scripttype="text/javascript"src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.0.22/webcomponents-lite.js"></script><scripttype="text/javascript"src="source/smart.element.js"></script><script>Smart('smart-test', class TestElement extends Smart.BaseElement{// properties.staticgetproperties(){return{'content':{type:'string'}};}/** Element's template. */template(){return'<div inner-h-t-m-l=\'[[content]]\'></div>';}ready(){super.ready();}propertyChangedHandler(propertyName,oldValue,newValue){super.propertyChangedHandler(propertyName,oldValue,newValue);}});</script><style>.smart-container{box-sizing:border-box;font-family:inherit;font-size:inherit;display:block;width:100%;height:100%;outline:none;margin:0;padding:0;}.smart-container *{box-sizing:border-box;}smart-test{background: #ddd;color: #333;display:inline-block;border-radius:5px;border:1pxsolid #aaa;width:100px;text-align:center;}</style></head><body><smart-testcontent="Test Element"></smart-test></body></html>

An extended element definition looks like this:

Smart('smart-button',classButtonextendsSmart.ContentElement{// Button's properties.staticgetproperties(){return{'value':{type:'string'},'name':{type:'string'},'type':{type:'string'},'clickMode':{allowedValues:['hover','press','release'],type:'string',value:'release'}};}/** Button's template. */template(){return'<button class=\'smart-button\' inner-h-t-m-l=\'[[innerHTML]]\' id=\'button\' type=\'[[type]]\' name=\'[[name]]\' value=\'[[value]]\' disabled=\'[[disabled]]\' role=\'button\'></button>';}staticgetlisteners(){return{'button.mousedown':'_mouseDownHandler','button.mouseenter':'_mouseEnterHandler','button.click':'_clickHandler'};}_clickHandler(event){constthat=this;if(that.clickMode!=='release'){event.preventDefault();event.stopPropagation();}}_mouseDownHandler(){constthat=this;if(that.clickMode==='press'){that.$.fireEvent('click');}}_mouseEnterHandler(){constthat=this;if(that.clickMode==='hover'){that.$.fireEvent('click');}}});

The base custom element class is calledBaseElement and is accessible throughSmart.BaseElement. Most elements derive fromSmart.BaseElement.Smart.ContentElement extends theSmart.BaseElement by addingcontent andinnerHTML properties to it. It is useful when you need to append a child element by setting a single property.

Register a Custom Element

To register a custom element, use theSmart function and pass in the element's tag name and class. By specification, the custom element's name must contain a dash (-). The library internally checks whether Custom Elements v1 is supported and uses its lifecycle callbacks and customElements.define. Otherwise, it uses document.registerElement and the v0 lifecycle callbacks. To use custom elements, you will need a browser which natively supports Custom Elements or you will need to load polyfills such aswebcomponentsjs.

Resources:

Lifecycle callbacks

  • created - Called when the element has been created, but before property values are set and local DOM is initialized.Use for one-time set-up before property values are set.
  • attached - Called after the element is attached to the document. Can be called multiple times during the lifetime of an element.
  • ready - Called when the element is ready. Use for one-time configuration of your element.
  • detached - Called after the element is detached from the document. Can be called multiple times during the lifetime of an element.
  • completed - Called after the element and any custom elements in its template are ready, rendered and attached to the DOM. Completed is called once.

Properties

To add properties on your custom element, you can use theproperties object. All properties part of theproperties object are automatically serialized and deserialized by the element and can also be set through attributes by using the dash(-) syntax in the HTML markup. Each property can have the following members:

  • reflectToAttribute - Type: Boolean. Set totrue to cause the corresponding attribute to be set on the host node when the property value changes. If the property value isBoolean, the attribute is created as a standard HTML boolean attribute (set if true, not set if false). For other property types, the attribute value is a string representation of the property value. The default value of this member istrue.
  • defaultReflectToAttribute - Type: Boolean. Set totrue when we want a default attribute value to be set on the host node.
  • readOnly - Type: Boolean. Determines whether the property is readyonly. iftrue the property can't be set by the user.
  • type - Type: String. Used for deserializing from an attribute.
    • any - allows assigning any value to a property.
    • string - allows assigning aString to a property.
    • string? - allows assigning a 'String' or null to a property.
    • boolean or bool - allows assigning aBoolean to a property.
    • boolean? or bool? - allows assigning a 'Boolean' or null to a property.
    • number or float - allows assigning a 'Number' to a property.
    • number? or float? - allows assigning a 'Number' or null to a property.
    • int or integer - allows assigning an 'Integer' to a property.
    • int? or integer? - allows assigning an 'Integer' or null to a property.
    • date - allows assigning a 'Date' to a property.
    • date? - allows assigning a 'Date' or null to a property.
    • array - allows assigning an 'Array' to a property.
    • object - allows assigning an 'Object' to a property.
  • allowedValues - Type: Array. Used for defining a set of values which are allowed to be set. For other values, an exception is thrown.
  • notify - Type: Boolean. Determines whether an event is raised when a property is changed. The event name is: property's attribute name + - 'changed'. Example: Property's name is 'clickMode', the event's name will be 'click-mode-changed'.Example:
<!DOCTYPEhtml><htmllang="en"><head><metahttp-equiv="X-UA-Compatible"content="IE=edge,chrome=1"/><metaname="viewport"content="width=device-width, initial-scale=1"/><linkrel="stylesheet"href="styles/smart.default.css"type="text/css"/><scripttype="text/javascript"src="smart.elements.js"></script><script>        window.onload = function (){varlist=document.getElementById('list');vardata=[{label:"Andrew",value:1,group:"A"},{label:"Natalia",value:5,group:"B"},{label:"Michael",value:4,group:"B"},{label:"Angel",value:2,group:"A"},{label:"Hristo",value:6,group:"C"},{label:"Peter",value:3,group:"A"},{label:"Albert",value:4,group:"A"},{label:"Boyko",value:8,group:"A"},{label:"Dimitar",value:9,group:"B"},{label:"George",value:10,group:"C"}];list.dataSource=data;list.addEventListener('disabled-changed',function(event){if(event.target===list){alert('disabled changed');}});document.getElementById("disabled").onclick=function(){list.disabled=!list.disabled;}list.properties['disabled'].notify=true;}</script></head><body><smart-list-boxstyle="float:left;"selection-mode="checkBox"id="list"></smart-list-box><divstyle="float: left; margin-left:100px;"><smart-buttonstyle="width:auto;"id="disabled">Enable/Disable</smart-button></div></body></html>
  • value - Default value for the property.
  • observer - Type: String. A name of a function called within the Element when the property is changed. The arguments passed to your observer are the property'soldValue andnewValue.
  • validator - Type: String. A name of a function called within the Element when the property is changing. The arguments passed to your validator are the property'soldValue andnewValue. The functionreturns the updated value. If itreturns undefined, the newValue remains unchanged.

propertyChangedHandler(propertyName, oldValue, newValue) method is called when a property is changed by the user. This method is useful for updating the element when the user makes some changes.

The user may watch for property changes by using the element's instance.watch(propertiesArray, propertyChangedCallback). The arguments passed to thepropertyChangedCallback function arepropertyName, oldValue, newValue.

Template

Thetemplate object determines the internal HTML structure of the Element. Within that structure you can data bind properties by using two-way or one-way data binding.

template(){return'<button class=\'smart-button\' inner-h-t-m-l=\'[[innerHTML]]\' id=\'button\' type=\'[[type]]\' name=\'[[name]]\' value=\'[[value]]\' disabled=\'[[disabled]]\' role=\'button\'></button>';}

Text surrounded by double curly bracket ({{ }}) or double square bracket ([[ ]]) delimiters. Identifies the host element's property being bound.

  • Double-curly brackets (}) is used for two-way data flow.
  • Double square brackets ([[ ]]) is used for one-way downward from host element to target element data flow.

Two-way binding to a Native HTML element.

nativeElementProperty="{{hostElementProperty::nativeElementEvent}}"
Smart('my-element',classMyElementextendsSmart.BaseElement{staticgetproperties(){return{'check':{type:'boolean'}};}template(){return'<div><input type="checkbox" checked="{{check::change}}" /></div>';}});
<!DOCTYPE html><htmllang="en"><head><linkrel="stylesheet"href="styles/smart.default.css"type="text/css"/><scripttype="text/javascript"src="../../source/smart.element.js"></script><scripttype="text/javascript"src="../../source/myelement.js"></script><script>window.onload=function(){varmyElement=document.querySelector('my-element');myElement.onchange=function(){console.log(myElement.check);}}</script></head><body><my-element></my-element></body></html>

Content insertion point determines where the HTML elements which are within the custom element's body during initialization go during the initialization. By default that is the Custom Element itself, but you can specify a custom content insertion point, you can define acontent tag within the template's structure as in the below example:

template(){return`<div>        <svg width="100%" height="100%" viewPort="0 0 100 100" viewBox="0 0 100 100">           <circle class ="smart-value" r="50" cx="50" cy="50" transform="rotate(270 50 50)"></circle>        </svg>        <div><content></content><div></div></div>    </div>`;}

After the template is parsed, each element of the HTML Structure is accessible via itsid and the$ symbol. Note thecheckboxInput element in the below example:

/*** CheckBox custom element.*/Smart('smart-checkbox',classCheckBoxextendsSmart.ToggleButton{// CheckBox's properties.staticgetproperties(){return{'enableContainerClick':{value:true,type:'boolean'}};}/** Checkbox's Html template. */template(){return`<div id='container' class='smart-container'>                 <div id='checkboxAnimation' class ='smart-animation'></div>                 <span id='checkboxInput' class ='smart-input'></span>                 <span id='checkboxLabel' inner-h-t-m-l='[[innerHTML]]' class ='smart-label'><content></content></span>               </div>`;}staticgetlisteners(){return{'click':'_clickHandler'};}/** Called when the element is ready. Used for one-time configuration of the Checkbox. */ready(){}/** Changes the check state wneh widget container is clicked. */_clickHandler(event){constthat=this;if(that.disabled){return;}constisInputClicked=event.target===that.$.checkboxInput;if((that.enableContainerClick===true&&!isInputClicked)||isInputClicked){that._changeCheckState('pointer');that.focus();}}});

A set of utility functions is accessible throught the$ symbol. The syntax iselement.$.The utilify functions are:

  • addClass(className) - adds a class or classes to the element separated by space.
  • removeClass(className) - removes a class or classes separated by space.
  • isNativeElement - returnstrue if the element is native HTML Element. Otherwise returnsfalse.
  • fireEvent(eventType, detail, options) - fires a Custom Event.
  • listen(eventType, handler) - adds an event listener to the element. A set of Mobile-friendly events are supported by default. By passing any of these event types:down, up, move, tap, taphold, swipeleft, swiperight, swipetop, swipebottom, you will be notified when the user taps, swipes or touches with finger or mouse the element. If you listen to theresize event, you will be notified whenever the element's boundaries are changed.
  • unlisten(eventType) - removes event listener by type.
  • getAttributeValue(attributeName, type) - gets the attribute's typed value.
  • setAttributeValue(attributeName, value, type) - sets the attribute's value by using a typed value.

By invokingSmart.Utilities.Extend(element) you can extend any element with the above utility functions.

In order to add a custom utility class, you can useSmart.Utilities.Assign(classDefinition).

Smart.Utilities.Assign('defaultNumericProcessor',classdefaultNumericProcessor{}

To access that class, you can useSmart.Utilities.defaultNumericProcessor.

*if and *items template directives.

If in the Template's definition, we have a HTMLTemplateElement, we can use these directives to insert HTML.

  • *if - Conditionally includes a template defaultd on the value of a property.
  • *items - Repeating a template by using each item of an iterable as that template's context.
  • templateAttached - function called when the HTMLTemplateElement is attahed to the DOM.
  • templateDetached - function called when the HTMLTemplateElement is detached from the DOM.
  • refreshTemplate - you can use this function to re-evaluate and refresh the HTMLTemplateElement.

The below example creates a custom element calledsmart-test. Within its template, the *if and *items directives are used. When the value of a property calledcondition is set to true, we render all items contained in thesource property. When the value is set to false, we render again all items, but by using INPUT tags.

<!DOCTYPE html><html lang="en"><head>    <script type="text/javascript" src="../../source/smart.element.js"></script>    <script>        Smart('smart-test', class Test extends Smart.BaseElement {            // Toggle Button's properties.            static get properties() {                return {                    'name': {                        value: 'test',                        type: 'string'                    },                    'name2': {                        value: 'Atest',                        type: 'string'                    },                    'condition': {                        value: true,                        type: 'boolean'                    },                    'disabled': {                        value: false,                        type: 'boolean'                    },                    'source': {                        value: [],                        type: 'array'                    }                };            }            template() {                return '<div><div>{{name2}}</div><template><div *if={{condition}}><span>{{name}}</span></div><ul  *if={{condition}} *items={{source}}><li>{{item.name}}<input  disabled={{disabled}}  value="{{item.name}}"></input</li></ul></template></div>'            }            templateAttached(template) {                var inputs = template.querySelectorAll('input');                for (let i = 0; i < inputs.length; i++) {                    inputs[i].addEventListener('change', function () {                        alert('test');                    });                }            }            templateDetached(template) {            }            test() {                return this.condition;            }            /**            * Toggle Button's event listeners.            */            static get listeners() {                return {                             };            }            /** Called when the element is ready. Used for one-time configuration of the ToggleButton. */            ready() {                super.ready();            }        });        window.onload = function () {            var test = document.querySelector('smart-test');            test.source = [                { name: "Name 1" },                { name: "Name 2" },                { name: "Name 3" },                { name: "Name 4" },                { name: "Name 5" }            ]            document.querySelector('button').onclick = function () {                test.name2 = "TEST";                        test.source = [                { name: "New Name 1" },                { name: "New Name 2" },                { name: "New Name 3" },                { name: "New Name 4" },                { name: "New Name 5" }                ]                test.disabled = true;                test.condition = true;            }        }    </script></head><body>    <smart-test></smart-test>    <button>Update</button></body></html>

Events

Thelisteners object allows you to add and map events to event handlers.

In the below example, thelisteners object defines that a method called_clickHandler is called when the element is clicked. To listen to an event of an element from the template, you can usenodeId.eventName likecheckboxInput.click:_clickHandler.

/*** CheckBox custom element.*/Smart('smart-checkbox',classCheckBoxextendsSmart.ToggleButton{// CheckBox's properties.staticgetproperties(){return{'enableContainerClick':{value:true,type:'boolean'}};}/** Checkbox's Html template. */template(){return`<div id='container' class='smart-container'>                 <div id='checkboxAnimation' class ='smart-animation'></div>                 <span id='checkboxInput' class ='smart-input'></span>                 <span id='checkboxLabel' inner-h-t-m-l='[[innerHTML]]' class ='smart-label'><content></content></span>               </div>`;}staticgetlisteners(){return{'click':'_clickHandler'};}/** Called when the element is ready. Used for one-time configuration of the Checkbox. */ready(){}/** Changes the check state wneh widget container is clicked. */_clickHandler(event){constthat=this;if(that.disabled){return;}constisInputClicked=event.target===that.$.checkboxInput;if((that.enableContainerClick===true&&!isInputClicked)||isInputClicked){that._changeCheckState('pointer');that.focus();}}});

Binding to events within the Element's template.

Smart('my-element',classMyElementextendsSmart.BaseElement{staticgetproperties(){return{'check':{type:'boolean'}};}template(){return'<div><input (change)="_changeHandler" type="checkbox" checked="{{check::change}}" /></div>';}_changeHandler(){alert('Checkbox State Changed');}});

By using the utility functions described in the previous section, you can dynamically add and remove event listeners.

Data Context

The Data Context functionality of Smart Custom Element enables:

  • Dependency tracking - automatically updates parts of UI whenever a data model changes.
  • Declarative bindings - a way to connect parts of UI to a data model.

The DataContext can be applied in two ways - by calling a method calledapplyDataContext or by setting adata-context attribute in the element's definition pointing to a DataModel object.

The following example demonstrates how to use theDataContext feature.

<!DOCTYPE html><htmllang="en"><head><metahttp-equiv="X-UA-Compatible"content="IE=edge,chrome=1"/><metaname="viewport"content="width=device-width, initial-scale=1"/><linkrel="stylesheet"href="styles/smart.default.css"type="text/css"/><scripttype="text/javascript"src="smart.elements.js"></script><script>window.onload=function(){constdata=[{label:"Andrew",value:1,group:"A"},{label:"Natalia",value:5,group:"B"},{label:"Michael",value:4,group:"B"},{label:"Angel",value:2,group:"A"},{label:"Hristo",value:6,group:"C"},{label:"Peter",value:3,group:"A"},{label:"Albert",value:2,group:"A"},{label:"Boyko",value:8,group:"A"},{label:"Dimitar",value:2,group:"B"},{label:"George",value:10,group:"C"}];window.listBoxSettings={dataSource:data,selectionMode:'checkBox'}constSimpleListModel=function(items){this.items=items;this.itemToAdd="";this.addItem=function(){if(this.itemToAdd!==""){this.items=this.items.concat(this.itemToAdd);this.itemToAdd="";// Clears the text box, because it's bound to the "itemToAdd" observable}}.bind(this);// Ensure that "this" is always this view model};constlistBox=document.querySelector('smart-list-box');consttextBox=document.querySelector('smart-text-box');constbutton=document.querySelector('smart-button');constmodel=newSimpleListModel(["Alpha","Beta","Gamma"]);listBox.applyDataContext(model);textBox.applyDataContext(model);button.applyDataContext(model);}</script></head><body><smart-list-boxstyle="float:left;"data-source="{{items}}"id="list"></smart-list-box><smart-text-boxvalue="{{itemToAdd}}"></smart-text-box><divstyle="float: left; margin-left:100px;"><smart-button(click)="addItem()"id="changeSource">Add</smart-button></div></body></html>

By using double-curly braces, we declare the property bindings. By using braces, we define the event bindings. ThedataSource property is bound to theSimpleListModel'sitems property. When the property is changed, the UI is automatically updated. The button'sclick event is bound to theSimpleListModel'saddItem function. When the button is clicked, the function is called. Thevalue of the TextBox updates theSimpleListModel'sitemToAdd property and vice versa.

Modules

To add a missing feature or override a feature of a Custom Element, you can define a Module. The module represents a javascript class. By defining itsproperties object, you can add new properties or override existing properties of the custom element. Methods defined within that class also extend or override custom element methods. The lifecycle callback functions usage is the same as in the element. To add a module to a custom element, you can use theaddModule function. The owner element is accessible through a property calledownerElement.

window.Smart.Elements.whenRegistered('smart-button',function(proto){proto.addModule(ColorModule);});

Custom Module which adds a newcolor property to thesmart-button custom element.

<!DOCTYPE html><htmllang="en"><head><linkrel="stylesheet"href="../../source/styles/smart.default.css"type="text/css"/><linkrel="stylesheet"href="../styles/demos.css"type="text/css"/><scripttype="text/javascript"src="../../source/smart.elements.js"></script><script>classColorModule{staticgetproperties(){constproperties={'color':{value:'red',type:'string',observer:'setColor'}}returnproperties;}attached(){}detached(){}created(){}ready(){this.ownerElement.$.button.style.color=this.color;}setColor(oldColor,color){this.ownerElement.$.button.style.color=this.color;}}window.Smart.Elements.whenRegistered('smart-button',function(proto){proto.addModule(ColorModule);});</script><script>functionclickMe(event){letbutton=document.getElementById("button");button.color='green';}</script></head><body><smart-buttonid="button"onclick="clickMe(event)">Click Me</smart-button></body></html>

It is a good practise to implement the 'moduleName' property when you create a custom module.

staticgetmoduleName(){return'MyModule';}

Inheritance

You can create a new Custom Element which extends an existing one. When you call theSmart function, pass a class as a second argument which determines which element should be extended. All elements are registered within theSmart global namespace and are accessible through their class name.

The below example demonstrates how to create a new element calledsmart-repeat-button which extends thesmart-button element.

/*** Repeat Button.*/Smart('smart-repeat-button',classRepeatButtonextendsSmart.Button{// button's properties.staticgetproperties(){return{'delay':{value:50,type:'number'},'initialDelay':{value:150,type:'number'}};}staticgetlisteners(){return{'button.mousedown':'_startRepeat','button.mouseenter':'_updateInBoundsFlag','button.mouseleave':'_updateInBoundsFlag','document.mouseup':'_stopRepeat'};}_updateInBoundsFlag(event){constthat=this;that._isPointerInBounds=true;if(event.type==='mouseleave'){that._isPointerInBounds=false;}}_startRepeat(event){constthat=this;if(!that._initialTimer){that._initialTimer=setTimeout(function(){that._repeatTimer=setInterval(()=>{if(that._isPointerInBounds){constbuttons=('buttons'inevent) ?event.buttons :event.which;that.$.fireEvent('click',{buttons:buttons});}},that.delay);that._initialTimer=null;},that.initialDelay);}}_stopRepeat(){constthat=this;if(that._repeatTimer){clearInterval(that._repeatTimer);that._repeatTimer=null;}if(that._initialTimer){clearTimeout(that._initialTimer);that._initialTimer=null;}}});

Comparison with Polymer Framework

Polymer is a Google-sponsored project. With Polymer, you can build custom elements. Smart Custom Elements can be compared to Polymer’s custom elements and both provide a very similar development style.

Similar things:

Elements are instantiated using a constructor or document.createElement. Elements are instantiated when the tag is written in the DOM.Configured using attributes or propertiesPopulated with internal DOM inside each instanceResponsive to property and attribute changesStyled with internal defaults or externallyResponsive to methods that manipulate its internal state

Different things:

Property types can be nullable and more strict - validation for Integer. Support for Int64.Properties can defineallowedValues array. If a property is set to a value which is not in that array, an exception is thrown.Property invalid value and invalid type validation.Complex Nested Properties. Smart supports property nesting.

Example:

'paging':{value:{'enabled':{value:false,type:'boolean'},'pageSize':{value:10,type:'int',validator:'pageSizeValidator'},'pageIndex':{value:0,type:'int',validator:'pageIndexValidator'}},type:'object'}

For settingpageSize, this could be used: grid.paging.pageSize = 15;

Initialization of an element from a JSON object with automatic Dependency Changes handling. When an element is created from a JSON object, the json it two-way bound to the element and any change in the element updates the JSON.

HTMLTemplates support. When in the Custom Element's template, we have HTMLTemplateElement, that template is re-evaluated on property change and can be used for dynamic user updates.

Method Arguments and Return Type. Smart validates Methods for Invalid return type, Arguments Count, Arguments Types.

Agnostic Events - Smart exposes custom events for 'down', 'up', 'move' and 'swipe'. These events are Device agnostic and are raised for

Touch and Desktop devices when the Cursor/Pointer is down, up, moved or swiped left, right, up or down.

Multiple Element Versions on the same web page is supported.

Localization - Built-in localization support.

Error Logs - Error logs with different error levels.

completed lifecycle callback which is called when the local DOM is ready and all elements are rendered.

resize notifications when the element's size is changed.

Style changed notifications - when the element's CSS is changed.

Using Shadow DOM is optional and is user preference. When disabled, the element's local DOM is part of the document's DOM.

View-Model Binding. An Element or Multiple Elements can be bound to the same Model object.

License

See LICENSE.md and Intellectual property and non-compete terms.

INTELLECTUAL PROPERTY

All intellectual property rights such as but not limited to patents, trademarks, copyrights or trade secret rights related to the Software are property of the Author. You shall not modify, translate, reverse engineer, un-minify, decompile or disassemble the Software or any portion of it or attempt to derive source code or create derivative works. You are not allowed to remove, alter or destroy any proprietary, trademark or copyright markings or notices related to the Software. You must not remove copyright headers, links and markings from any files included in the Software. You must obtain a permission by the Author if you need to incorporate the Software or any portions of it in open source projects.

NON-COMPETE

You are not allowed to use any portion of the Software in any products that fully or partially resemble the functionality of the Software or otherwise compete with the Software. You are not allowed to use the Software in any products or solutions offering reusable user interface components to end users, developers and third parties without express written permission by the Author.

About

Smart a lightweight web component library that provides capabilities for web components, such as data binding, using es6 native class inheritance. This library is focused for providing the developer the ability to write robust and native web components without the need of dependencies and an overhead of a framework.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp