├── LICENSE ├── README.md ├── bower.json ├── index.htm ├── package.json └── source ├── smart.element.js └── smart.element.min.js /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License and Custom License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | 10. INTELLECTUAL PROPERTY 177 | 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. 178 | 179 | 11. NON-COMPETE 180 | 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. 181 | 182 | 183 | END OF TERMS AND CONDITIONS 184 | 185 | APPENDIX: How to apply the Apache License to your work. 186 | 187 | To apply the Apache License to your work, attach the following 188 | boilerplate notice, with the fields enclosed by brackets "[]" 189 | replaced with your own identifying information. (Don't include 190 | the brackets!) The text should be enclosed in the appropriate 191 | comment syntax for the file format. We also recommend that a 192 | file or class name and description of purpose be included on the 193 | same "printed page" as the copyright notice for easier 194 | identification within third-party archives. 195 | 196 | Copyright [yyyy] [name of copyright owner] 197 | 198 | Licensed under the Apache License, Version 2.0 (the "License"); 199 | you may not use this file except in compliance with the License. 200 | You may obtain a copy of the License at 201 | 202 | http://www.apache.org/licenses/LICENSE-2.0 203 | 204 | Unless required by applicable law or agreed to in writing, software 205 | distributed under the License is distributed on an "AS IS" BASIS, 206 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 207 | See the License for the specific language governing permissions and 208 | limitations under the License. 209 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [Smart Custom Element](https://www.htmlelements.com) [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Get%20over%2020%20free%20custom%20elements%20based%20on%20SmartHTMLElements%20&url=https://www.htmlelements.com/&via=htmlelements&hashtags=bootstrap,design,templates,blocks,developers,webcomponents,customelements,polymer,material) 2 | 3 | [![Slack](https://smarthtmlelements-slack.herokuapp.com/badge.svg)](https://smarthtmlelements.slack.com/) 4 | [![Price](https://img.shields.io/badge/price-FREE-0098f7.svg)](https://github.com/HTMLElements/smart-custom-element/blob/master/LICENSE) 5 | [![npm](https://img.shields.io/npm/v/froala-design-blocks.svg?colorB=brightgreen)](https://www.npmjs.com/package/@smarthtmlelements/smart-custom-element) 6 | [![GitHub package version](https://img.shields.io/github/package-json/v/HTMLElements/smart-custom-element.svg)](https://github.com/HTMLElements/smart-custom-element) 7 | [![License: APACHE](https://img.shields.io/badge/license-APACHE-blue.svg)](https://github.com/HTMLElements/smart-custom-element/blob/master/LICENSE) 8 | [![](https://img.shields.io/website-up-down-green-red/https/shields.io.svg?label=www.htmlelements.com)](https://www.htmlelements.com) 9 | [![](https://img.shields.io/github/release-date/HTMLElements/smart-custom-element.svg)](https://www.htmlelements.com) 10 | 11 | JavaScript library that wraps the W3C standard Web Components family of APIs to provide a compact, feature-rich interface for `Custom Elements` development. 12 | 13 | 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. 14 | 15 | ## Installation 16 | - `npm install smart-custom-element --save` 17 | 18 | In your web page, include 19 | 20 | ``` 21 | 22 | 23 | ``` 24 | 25 | Optional polyfill for browsers without custom elements support: `webcomponents-lite.js` 26 | 27 | 28 | ## Version and Deployment 29 | - This package is version according to [semantic versioning](http://semver.org). 30 | 31 | ## Browser Support and Compatibility 32 | 33 | **[Requires ES2015 classes](https://caniuse.com/es6-class). Edge, Chrome, Safari and Firefox. Requires Webcomponents polyfill for Edge and Safari** 34 | 35 | - **If targeting browsers that natively support ES2015, but not native Web Components:** 36 | 37 | You will also need the [Shady DOM + Custom Elements polyfill](https://github.com/webcomponents/webcomponentsjs). 38 | 39 | See caniuse.com for support on [Custom Elements v1](https://caniuse.com/#feat=custom-elementsv1) and [Shadow DOM v1](https://caniuse.com/#feat=shadowdomv1).. 40 | 41 | ## How to Use? 42 | 43 | Include HTML tag (e.g. ```)``` 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 with ```button.setAttribute(attributeName, attributeValue);```, setting properties with ```button.disabled = true;``` or listening to events with ```button.addEventListener('click', function(event) { });```. 44 | You also take advantage of features like lazy-loading, that allows for loading components on demand, only when user add them to document 45 | 46 | ## Introduction 47 | 48 | A basic element definition looks like this: 49 | 50 | ```javascript 51 | 52 | 53 | 54 | 55 | 56 | 81 | 107 | 108 | 109 | 110 | 111 | 112 | ``` 113 | 114 | An extended element definition looks like this: 115 | 116 | ```javascript 117 | Smart('smart-button', class Button extends Smart.ContentElement { 118 | // Button's properties. 119 | static get properties() { 120 | return { 121 | 'value': { 122 | type: 'string' 123 | }, 124 | 'name': { 125 | type: 'string' 126 | }, 127 | 'type': { 128 | type: 'string' 129 | }, 130 | 'clickMode': { 131 | allowedValues: ['hover', 'press', 'release'], 132 | type: 'string', 133 | value: 'release' 134 | } 135 | }; 136 | } 137 | 138 | /** Button's template. */ 139 | template() { 140 | return ''; 141 | } 142 | 143 | static get listeners() { 144 | return { 145 | 'button.mousedown': '_mouseDownHandler', 146 | 'button.mouseenter': '_mouseEnterHandler', 147 | 'button.click': '_clickHandler' 148 | }; 149 | } 150 | 151 | _clickHandler(event) { 152 | const that = this; 153 | 154 | if (that.clickMode !== 'release') { 155 | event.preventDefault(); 156 | event.stopPropagation(); 157 | } 158 | } 159 | 160 | _mouseDownHandler() { 161 | const that = this; 162 | 163 | if (that.clickMode === 'press') { 164 | that.$.fireEvent('click'); 165 | } 166 | } 167 | 168 | _mouseEnterHandler() { 169 | const that = this; 170 | 171 | if (that.clickMode === 'hover') { 172 | that.$.fireEvent('click'); 173 | } 174 | } 175 | }); 176 | ``` 177 | 178 | The base custom element class is called `BaseElement` and is accessible through `Smart.BaseElement`. Most elements derive from `Smart.BaseElement`. `Smart.ContentElement` extends the `Smart.BaseElement` by adding `content` and `innerHTML` properties to it. It is useful when you need to append a child element by setting a single property. 179 | 180 | ## Register a Custom Element 181 | 182 | To register a custom element, use the `Smart` 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 as `webcomponentsjs`. 183 | 184 | Resources: 185 | 186 | * https://developer.mozilla.org/en-US/docs/Web/Web_Components 187 | * https://developers.google.com/web/fundamentals/getting-started/primers/customelements 188 | * http://webcomponents.org/ 189 | * **webcomponentsjs** polyfill: 190 | * https://github.com/webcomponents/webcomponentsjs 191 | * https://www.npmjs.com/package/@webcomponents/webcomponentsjs 192 | * The files **webcomponents-lite.js** and **webcomponents-loader.js** have to be referenced (in this order). 193 | 194 | 195 | ## Lifecycle callbacks 196 | 197 | * created - Called when the element has been created, but before property values are set and local DOM is initialized. 198 | Use for one-time set-up before property values are set. 199 | * attached - Called after the element is attached to the document. Can be called multiple times during the lifetime of an element. 200 | * ready - Called when the element is ready. Use for one-time configuration of your element. 201 | * detached - Called after the element is detached from the document. Can be called multiple times during the lifetime of an element. 202 | * completed - Called after the element and any custom elements in its template are ready, rendered and attached to the DOM. Completed is called once. 203 | 204 | ## Properties 205 | 206 | To add properties on your custom element, you can use the `properties` object. All properties part of the `properties` 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: 207 | 208 | * reflectToAttribute - Type: Boolean. Set to `true` to cause the corresponding attribute to be set on the host node when the property value changes. If the property value is `Boolean`, 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 is `true`. 209 | * defaultReflectToAttribute - Type: Boolean. Set to `true` when we want a default attribute value to be set on the host node. 210 | * readOnly - Type: Boolean. Determines whether the property is readyonly. if `true` the property can't be set by the user. 211 | * type - Type: String. Used for deserializing from an attribute. 212 | * any - allows assigning any value to a property. 213 | * string - allows assigning a `String` to a property. 214 | * string? - allows assigning a 'String' or null to a property. 215 | * boolean or bool - allows assigning a `Boolean` to a property. 216 | * boolean? or bool? - allows assigning a 'Boolean' or null to a property. 217 | * number or float - allows assigning a 'Number' to a property. 218 | * number? or float? - allows assigning a 'Number' or null to a property. 219 | * int or integer - allows assigning an 'Integer' to a property. 220 | * int? or integer? - allows assigning an 'Integer' or null to a property. 221 | * date - allows assigning a 'Date' to a property. 222 | * date? - allows assigning a 'Date' or null to a property. 223 | * array - allows assigning an 'Array' to a property. 224 | * object - allows assigning an 'Object' to a property. 225 | * allowedValues - Type: Array. Used for defining a set of values which are allowed to be set. For other values, an exception is thrown. 226 | * 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'. 227 | Example: 228 | ```javascript 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 308 | 309 | 310 | 311 |
312 | Enable/Disable 313 |
314 | 315 | 316 | ``` 317 | * value - Default value for the property. 318 | * 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's `oldValue` and `newValue`. 319 | * 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's `oldValue` and `newValue`. The function `returns` the updated value. If it `returns undefined`, the newValue remains unchanged. 320 | 321 | `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. 322 | 323 | The user may watch for property changes by using the element's instance. `watch(propertiesArray, propertyChangedCallback)`. The arguments passed to the `propertyChangedCallback` function are `propertyName, oldValue, newValue`. 324 | ## Template 325 | 326 | The `template` 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. 327 | 328 | ```javascript 329 | template() { 330 | return ''; 331 | } 332 | ```` 333 | 334 | Text surrounded by double curly bracket ({{ }}) or double square bracket ([[ ]]) delimiters. Identifies the host element's property being bound. 335 | 336 | * Double-curly brackets (}) is used for two-way data flow. 337 | * Double square brackets ([[ ]]) is used for one-way downward from host element to target element data flow. 338 | 339 | Two-way binding to a Native HTML element. 340 | ```javascript 341 | nativeElementProperty="{{hostElementProperty::nativeElementEvent}}" 342 | ``` 343 | 344 | ```javascript 345 | Smart('my-element', class MyElement extends Smart.BaseElement { 346 | static get properties() { 347 | return { 348 | 'check': { 349 | type: 'boolean' 350 | } 351 | }; 352 | } 353 | 354 | template() { 355 | return '
'; 356 | } 357 | }); 358 | ``` 359 | ```HTML 360 | 361 | 362 | 363 | 364 | 365 | 366 | 374 | 375 | 376 | 377 | 378 | 379 | ``` 380 | 381 | 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 a `content` tag within the template's structure as in the below example: 382 | 383 | ```javascript 384 | template() { 385 | return `
386 | 387 | 388 | 389 |
390 |
`; 391 | } 392 | ``` 393 | 394 | 395 | After the template is parsed, each element of the HTML Structure is accessible via its `id` and the `$` symbol. Note the `checkboxInput` element in the below example: 396 | 397 | ```javascript 398 | /** 399 | * CheckBox custom element. 400 | */ 401 | Smart('smart-checkbox', class CheckBox extends Smart.ToggleButton { 402 | // CheckBox's properties. 403 | static get properties() { 404 | return { 405 | 'enableContainerClick': { 406 | value: true, 407 | type: 'boolean' 408 | } 409 | }; 410 | } 411 | 412 | /** Checkbox's Html template. */ 413 | template() { 414 | return `
415 |
416 | 417 | 418 |
`; 419 | } 420 | 421 | static get listeners() { 422 | return { 423 | 'click': '_clickHandler' 424 | }; 425 | } 426 | 427 | /** Called when the element is ready. Used for one-time configuration of the Checkbox. */ 428 | ready() { 429 | } 430 | 431 | /** Changes the check state wneh widget container is clicked. */ 432 | _clickHandler(event) { 433 | const that = this; 434 | 435 | if (that.disabled) { 436 | return; 437 | } 438 | 439 | const isInputClicked = event.target === that.$.checkboxInput; 440 | 441 | if ((that.enableContainerClick === true && !isInputClicked) || isInputClicked) { 442 | that._changeCheckState('pointer'); 443 | that.focus(); 444 | } 445 | } 446 | }); 447 | 448 | ``` 449 | A set of utility functions is accessible throught the `$` symbol. The syntax is `element.$`.The utilify functions are: 450 | * addClass(className) - adds a class or classes to the element separated by space. 451 | * removeClass(className) - removes a class or classes separated by space. 452 | * isNativeElement - returns `true` if the element is native HTML Element. Otherwise returns `false`. 453 | * fireEvent(eventType, detail, options) - fires a Custom Event. 454 | * eventType - String. Determines the event's type. 455 | * detail - Object. Determines custom event object passed to the user. 456 | * options - Object. Determines the event's options like `cancelable` or `bubbles`. Read more on: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent 457 | * 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 the `resize` event, you will be notified whenever the element's boundaries are changed. 458 | * unlisten(eventType) - removes event listener by type. 459 | * getAttributeValue(attributeName, type) - gets the attribute's typed value. 460 | * setAttributeValue(attributeName, value, type) - sets the attribute's value by using a typed value. 461 | 462 | By invoking `Smart.Utilities.Extend(element)` you can extend any element with the above utility functions. 463 | 464 | In order to add a custom utility class, you can use `Smart.Utilities.Assign(classDefinition)`. 465 | 466 | ```javascript 467 | Smart.Utilities.Assign('defaultNumericProcessor', class defaultNumericProcessor { 468 | } 469 | ``` 470 | 471 | To access that class, you can use `Smart.Utilities.defaultNumericProcessor`. 472 | 473 | ```*if and *items template directives.``` 474 | 475 | If in the Template's definition, we have a HTMLTemplateElement, we can use these directives to insert HTML. 476 | 477 | * *if - Conditionally includes a template defaultd on the value of a property. 478 | * *items - Repeating a template by using each item of an iterable as that template's context. 479 | * templateAttached - function called when the HTMLTemplateElement is attahed to the DOM. 480 | * templateDetached - function called when the HTMLTemplateElement is detached from the DOM. 481 | * refreshTemplate - you can use this function to re-evaluate and refresh the HTMLTemplateElement. 482 | 483 | The below example creates a custom element called ```smart-test```. Within its template, the *if and *items directives are used. When the value of a property called ```condition``` is set to true, we render all items contained in the ```source``` property. When the value is set to false, we render again all items, but by using INPUT tags. 484 | 485 | ``` 486 | 487 | 488 | 489 | 490 | 491 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | ``` 590 | ## Events 591 | 592 | The `listeners` object allows you to add and map events to event handlers. 593 | 594 | In the below example, the `listeners` 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 use `nodeId.eventName` like `checkboxInput.click:_clickHandler`. 595 | 596 | ```javascript 597 | /** 598 | * CheckBox custom element. 599 | */ 600 | Smart('smart-checkbox', class CheckBox extends Smart.ToggleButton { 601 | // CheckBox's properties. 602 | static get properties() { 603 | return { 604 | 'enableContainerClick': { 605 | value: true, 606 | type: 'boolean' 607 | } 608 | }; 609 | } 610 | 611 | /** Checkbox's Html template. */ 612 | template() { 613 | return `
614 |
615 | 616 | 617 |
`; 618 | } 619 | 620 | static get listeners() { 621 | return { 622 | 'click': '_clickHandler' 623 | }; 624 | } 625 | 626 | /** Called when the element is ready. Used for one-time configuration of the Checkbox. */ 627 | ready() { 628 | } 629 | 630 | /** Changes the check state wneh widget container is clicked. */ 631 | _clickHandler(event) { 632 | const that = this; 633 | 634 | if (that.disabled) { 635 | return; 636 | } 637 | 638 | const isInputClicked = event.target === that.$.checkboxInput; 639 | 640 | if ((that.enableContainerClick === true && !isInputClicked) || isInputClicked) { 641 | that._changeCheckState('pointer'); 642 | that.focus(); 643 | } 644 | } 645 | }); 646 | 647 | ``` 648 | Binding to events within the Element's template. 649 | ```javascript 650 | Smart('my-element', class MyElement extends Smart.BaseElement { 651 | static get properties() { 652 | return { 653 | 'check': { 654 | type: 'boolean' 655 | } 656 | }; 657 | } 658 | 659 | template() { 660 | return '
'; 661 | } 662 | 663 | _changeHandler() { 664 | alert('Checkbox State Changed'); 665 | } 666 | }); 667 | ``` 668 | 669 | By using the utility functions described in the previous section, you can dynamically add and remove event listeners. 670 | 671 | ## Data Context 672 | 673 | The Data Context functionality of Smart Custom Element enables: 674 | 675 | * Dependency tracking - automatically updates parts of UI whenever a data model changes. 676 | * Declarative bindings - a way to connect parts of UI to a data model. 677 | 678 | The DataContext can be applied in two ways - by calling a method called ```applyDataContext``` or by setting a ```data-context``` attribute in the element's definition pointing to a DataModel object. 679 | 680 | The following example demonstrates how to use the ```DataContext``` feature. 681 | 682 | ```html 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 773 | 774 | 775 | 776 | 777 | 778 | 779 |
780 | Add 781 |
782 | 783 | 784 | ``` 785 | 786 | By using double-curly braces, we declare the property bindings. By using braces, we define the event bindings. The ```dataSource``` property is bound to the ```SimpleListModel```'s ```items``` property. When the property is changed, the UI is automatically updated. The button's ```click``` event is bound to the ```SimpleListModel```'s ```addItem``` function. When the button is clicked, the function is called. The ```value``` of the TextBox updates the ```SimpleListModel```'s ```itemToAdd``` property and vice versa. 787 | 788 | ## Modules 789 | 790 | 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 its `properties` 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 the `addModule` function. The owner element is accessible through a property called `ownerElement`. 791 | 792 | ```javascript 793 | window.Smart.Elements.whenRegistered('smart-button', function (proto) { 794 | proto.addModule(ColorModule); 795 | }); 796 | ``` 797 | 798 | Custom Module which adds a new `color` property to the `smart-button` custom element. 799 | ```HTML 800 | 801 | 802 | 803 | 804 | 805 | 806 | 843 | 844 | 850 | 851 | 852 | Click Me 853 | 854 | 855 | ``` 856 | 857 | It is a good practise to implement the 'moduleName' property when you create a custom module. 858 | 859 | ```javascript 860 | static get moduleName() { 861 | return 'MyModule'; 862 | } 863 | ``` 864 | 865 | ## Inheritance 866 | 867 | You can create a new Custom Element which extends an existing one. When you call the `Smart` function, pass a class as a second argument which determines which element should be extended. All elements are registered within the `Smart` global namespace and are accessible through their class name. 868 | 869 | The below example demonstrates how to create a new element called `smart-repeat-button` which extends the `smart-button` element. 870 | ```javascript 871 | /** 872 | * Repeat Button. 873 | */ 874 | Smart('smart-repeat-button', class RepeatButton extends Smart.Button { 875 | // button's properties. 876 | static get properties() { 877 | return { 878 | 'delay': { 879 | value: 50, 880 | type: 'number' 881 | }, 882 | 'initialDelay': { 883 | value: 150, 884 | type: 'number' 885 | } 886 | }; 887 | } 888 | 889 | static get listeners() { 890 | return { 891 | 'button.mousedown': '_startRepeat', 892 | 'button.mouseenter': '_updateInBoundsFlag', 893 | 'button.mouseleave': '_updateInBoundsFlag', 894 | 'document.mouseup': '_stopRepeat' 895 | }; 896 | } 897 | 898 | _updateInBoundsFlag(event) { 899 | const that = this; 900 | 901 | that._isPointerInBounds = true; 902 | 903 | if (event.type === 'mouseleave') { 904 | that._isPointerInBounds = false; 905 | } 906 | } 907 | 908 | _startRepeat(event) { 909 | const that = this; 910 | 911 | if (!that._initialTimer) { 912 | that._initialTimer = setTimeout(function () { 913 | that._repeatTimer = setInterval(() => { 914 | if (that._isPointerInBounds) { 915 | const buttons = ('buttons' in event) ? event.buttons : event.which; 916 | that.$.fireEvent('click', { buttons: buttons }); 917 | } 918 | }, that.delay); 919 | that._initialTimer = null; 920 | }, that.initialDelay); 921 | } 922 | } 923 | 924 | _stopRepeat() { 925 | const that = this; 926 | 927 | if (that._repeatTimer) { 928 | clearInterval(that._repeatTimer); 929 | that._repeatTimer = null; 930 | } 931 | 932 | if (that._initialTimer) { 933 | clearTimeout(that._initialTimer); 934 | that._initialTimer = null; 935 | } 936 | } 937 | }); 938 | ``` 939 | 940 | ## Comparison with Polymer Framework 941 | 942 | 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. 943 | 944 | Similar things: 945 | 946 | Elements are instantiated using a constructor or document.createElement. Elements are instantiated when the tag is written in the DOM. 947 | Configured using attributes or properties 948 | Populated with internal DOM inside each instance 949 | Responsive to property and attribute changes 950 | Styled with internal defaults or externally 951 | Responsive to methods that manipulate its internal state 952 | 953 | Different things: 954 | 955 | Property types can be nullable and more strict - validation for Integer. Support for Int64. 956 | Properties can define `allowedValues` array. If a property is set to a value which is not in that array, an exception is thrown. 957 | Property invalid value and invalid type validation. 958 | Complex Nested Properties. Smart supports property nesting. 959 | 960 | Example: 961 | 962 | ```javascript 963 | 'paging': { 964 | value: { 965 | 'enabled': { 966 | value: false, 967 | type: 'boolean' 968 | }, 969 | 'pageSize': { 970 | value: 10, 971 | type: 'int', 972 | validator: 'pageSizeValidator' 973 | }, 974 | 'pageIndex': { 975 | value: 0, 976 | type: 'int', 977 | validator: 'pageIndexValidator' 978 | } 979 | }, 980 | type: 'object' 981 | } 982 | ``` 983 | 984 | For setting ```pageSize```, this could be used: grid.paging.pageSize = 15; 985 | 986 | 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. 987 | 988 | 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. 989 | 990 | Method Arguments and Return Type. Smart validates Methods for Invalid return type, Arguments Count, Arguments Types. 991 | 992 | Agnostic Events - Smart exposes custom events for 'down', 'up', 'move' and 'swipe'. These events are Device agnostic and are raised for 993 | 994 | Touch and Desktop devices when the Cursor/Pointer is down, up, moved or swiped left, right, up or down. 995 | 996 | Multiple Element Versions on the same web page is supported. 997 | 998 | Localization - Built-in localization support. 999 | 1000 | Error Logs - Error logs with different error levels. 1001 | 1002 | `completed` lifecycle callback which is called when the local DOM is ready and all elements are rendered. 1003 | 1004 | `resize` notifications when the element's size is changed. 1005 | 1006 | Style changed notifications - when the element's CSS is changed. 1007 | 1008 | Using Shadow DOM is optional and is user preference. When disabled, the element's local DOM is part of the document's DOM. 1009 | 1010 | View-Model Binding. An Element or Multiple Elements can be bound to the same Model object. 1011 | 1012 | ## License 1013 | 1014 | See LICENSE.md and Intellectual property and non-compete terms. 1015 | 1016 | ### INTELLECTUAL PROPERTY 1017 | 1018 | 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. 1019 | 1020 | ### NON-COMPETE 1021 | 1022 | 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. 1023 | 1024 | 1025 | 1026 | 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "smart-custom-element", 3 | "authors": [ 4 | "jQWidgets Ltd" 5 | ], 6 | "description": "Smart Custom Element is a Javascript library for Custom Elements development", 7 | "license": "Apache-2.0", 8 | "keywords": [ 9 | "smart element", 10 | "custom elements", 11 | "web components", 12 | "html elements" 13 | ], 14 | "main": "", 15 | "ignore": [ 16 | "**/.*", 17 | "**/node_modules", 18 | "**/bower_components", 19 | "**/tests" 20 | ], 21 | "dependencies": { 22 | "webcomponentsjs": "^1.0.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /index.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 46 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@smarthtmlelements/smart-custom-element", 3 | "version": "2.0.1", 4 | "description": "Smart Custom Element", 5 | "scripts": { 6 | }, 7 | "repository": { 8 | "type": "git", 9 | "url": "git+https://github.com/HTMLElements/smart-custom-element.git" 10 | }, 11 | "author": "Smart HTML Elements", 12 | "license": "SEE LICENSE IN https://www.htmlelements.com/pricing/", 13 | "bugs": { 14 | "url": "https://github.com/HTMLElements/smart-custom-element" 15 | }, 16 | "homepage": "https://github.com/HTMLElements/smart-custom-element#readme", 17 | "devDependencies": { 18 | 19 | }, 20 | "dependencies": { 21 | "@webcomponents/webcomponentsjs": "^1.0.22" 22 | }, 23 | "main": "index.js", 24 | "directories": {}, 25 | "keywords": [ 26 | "custom", 27 | "element", 28 | "custom element", 29 | "html element", 30 | "web components", 31 | "javascript", 32 | "html elements", 33 | "html tags", 34 | "custom elements", 35 | "custom elements v1", 36 | "smart custom element", 37 | "custom-elements", 38 | "webcomponents", 39 | "custom elements framework", 40 | "html templates", 41 | "shadow dom", 42 | "event handling", 43 | "data binding", 44 | "property change notifications", 45 | "localization", 46 | "javascript framework", 47 | "agnostic events handling", 48 | "declarative data binding", 49 | "user interface components" 50 | ] 51 | } 52 | -------------------------------------------------------------------------------- /source/smart.element.min.js: -------------------------------------------------------------------------------- 1 | 2 | /* Smart HTML Elements v2.0.0 (2018-Dec) 3 | Copyright (c) 2011-2018 jQWidgets. 4 | License: https://htmlelements.com/license/ */ 5 | 6 | (function(){"use strict";function e(e,t){const n=t.properties;t._properties=[];const r=function(n,a){const o=Object.keys(n);for(let l=0;l{if(e instanceof HTMLElement)return t.parseAttributes(e);else{let n=t.parseProperty(e.data,"textContent",e);if(n)return e.parentNode===t.ownerElement.$.content&&(n.value=""===t.ownerElement.$.html?void 0:t.ownerElement.$.html,t.ownerElement.innerHTML=""),{textContent:n}}})(e);a&&(r.data=a),e.getAttribute&&(r.nodeId=e.getAttribute("smart-id")),r.node=e,e.firstChild&&(r.children={});for(let a=e.firstChild;a;a=a.nextSibling)r.children[n++]=t.getBindings(a);return r}_addRemovePropertyBinding(e,t,n,r){if(!e||!t||!n)return;const a=this,i=a.ownerElement.bindings,o=n.getAttribute("smart-id"),l=0<=e.indexOf("{{");e=e.replace("{{","").replace("}}","").replace("[[","").replace("]]","");let s=!1;0<=e.indexOf("!")&&(e=e.replace("!",""),s=!0);const d=a.ownerElement._properties[e],p={name:e,reflectToAttribute:d.reflectToAttribute,twoWay:l,type:d.type,not:s},c=function(e){for(let i in e){const l=e[i];if(l.nodeId===o){l.data||(l.data={}),r?(l.data[t]=null,delete l.data[t]):l.data[t]=p;break}if(l.children)c(l.children);else if(l.node&&l.node.children&&l.node===n.parentElement){const e=l.node;if(e.firstChild)l.children={};else continue;let t=0;for(let n=e.firstChild;n;n=n.nextSibling)l.children[t++]=a.getBindings(n);c(l.children)}}};c(i.children),r?delete a.ownerElement.boundProperties[e]:a.ownerElement.boundProperties[e]=!0,a.updateBoundNodes(e)}addPropertyBinding(e,t,n){const r=this;r._addRemovePropertyBinding(e,t,n)}removePropertyBinding(e,t,n){const r=this;r._addRemovePropertyBinding(e,t,n,!0)}parseAttributes(e){const t=this;let n;for(let r=0;ra||ta?-1:e.indexOf(r,a+2),0>o)return;n=n||{};let s=e.slice(a+2,o).trim();n.name=s,i=o+2}const s=n.name,d=t.ownerElement._properties[s];return n.twoWay=l,n.ready=!1,t.ownerElement.boundProperties[s]=!0,d?(n.type=d.type,n.reflectToAttribute=d.reflectToAttribute):(n.type="string",n.reflectToAttribute=!0),n}updateTextNodes(){const e=this;e.updateTextNode(e.ownerElement.shadowRoot||e.ownerElement,e.ownerElement.bindings,e.ownerElement)}updateTextNode(e,t,n){const r=this;if(!t)return;let a=0;for(let i=e.firstChild;i&&!!t.children;i=i.nextSibling)r.updateTextNode(i,t.children[a++],n);if(t&&t.data)for(let e in t.data){const r=t.data[e],a=r.name;"textContent"==e&&r.twoWay&&!r.updating&&void 0!==r.value&&(n[a]=r.value)}}updateBoundProperty(e,t){if(t.updating)return;const n=this,r=n.ownerElement;t.updating=!0,r[e]=t.value,t.updating=!1}updateBoundNodes(e){const t=this;if(t.updateBoundNode(t.ownerElement.shadowRoot||t.ownerElement,t.ownerElement.bindings,t.ownerElement,e),0{if(t["is"+n](e))return n});return n?n.toLowerCase():void 0}}class Ripple{static animate(e,n,r,a){const o=e;if(!o||!1==o instanceof HTMLElement)return;if(0===o.getElementsByClassName("smart-ripple").length){const e=document.createElement("span");e.classList.add("smart-ripple");let t=!0,n=null;if(window[d].EnableShadowDOM&&o.enableShadowDOM){for(let e=0;e(e/=a/2)?r/2*e*e+n:-r/2*(--e*(e-2)-1)+n}static easeInCubic(e,n,r,a){return r*(e/=a)*e*e+n}static easeOutCubic(e,n,r,a){return r*((e=e/a-1)*e*e+1)+n}static easeInOutCubic(e,n,r,a){return 1>(e/=a/2)?r/2*e*e*e+n:r/2*((e-=2)*e*e+2)+n}static easeInQuart(e,n,r,a){return r*(e/=a)*e*e*e+n}static easeOutQuart(e,n,r,a){return-r*((e=e/a-1)*e*e*e-1)+n}static easeInOutQuart(e,n,r,a){return 1>(e/=a/2)?r/2*e*e*e*e+n:-r/2*((e-=2)*e*e*e-2)+n}static easeInQuint(e,n,r,a){return r*(e/=a)*e*e*e*e+n}static easeOutQuint(e,n,r,a){return r*((e=e/a-1)*e*e*e*e+1)+n}static easeInOutQuint(e,n,r,a){return 1>(e/=a/2)?r/2*e*e*e*e*e+n:r/2*((e-=2)*e*e*e*e+2)+n}static easeInSine(e,t,n,r){return-n*l(e/r*(m/2))+n+t}static easeOutSine(e,t,n,r){return n*o(e/r*(m/2))+t}static easeInOutSine(e,t,n,r){return-n/2*(l(m*e/r)-1)+t}static easeInExpo(e,t,n,r){return 0===e?t:n*i(2,10*(e/r-1))+t}static easeOutExpo(e,t,n,r){return e===r?t+n:n*(-i(2,-10*e/r)+1)+t}static easeInOutExpo(e,n,r,a){return 0===e?n:e===a?n+r:1>(e/=a/2)?r/2*i(2,10*(e-1))+n:r/2*(-i(2,-10*--e)+2)+n}static easeInCirc(e,n,r,i){return-r*(a(1-(e/=i)*e)-1)+n}static easeOutCirc(e,n,r,i){return r*a(1-(e=e/i-1)*e)+n}static easeInOutCirc(e,n,r,i){return 1>(e/=i/2)?-r/2*(a(1-e*e)-1)+n:r/2*(a(1-(e-=2)*e)+1)+n}static easeInElastic(e,l,u,c){let d=1.70158,h=0,y=u;return 0===e?l:1===(e/=c)?l+u:(h||(h=.3*c),ye?-.5*(y*i(2,10*(e-=1))*o((e*c-d)*(2*m)/h))+l:.5*(y*i(2,-10*(e-=1))*o((e*c-d)*(2*m)/h))+u+l)}static easeInBack(e,n,r,a,i){return void 0===i&&(i=1.70158),r*(e/=a)*e*((i+1)*e-i)+n}static easeOutBack(e,n,r,a,i){return void 0===i&&(i=1.70158),r*((e=e/a-1)*e*((i+1)*e+i)+1)+n}static easeInOutBack(e,n,r,a,i){return void 0===i&&(i=1.70158),1>(e/=a/2)?r/2*(e*e*(((i*=1.525)+1)*e-i))+n:r/2*((e-=2)*e*(((i*=1.525)+1)*e+i)+2)+n}static easeInBounce(e,t,n,r){return n-this.easeOutBounce(r-e,0,n,r)+t}static easeOutBounce(e,n,r,a){return(e/=a)<1/2.75?r*(7.5625*e*e)+n:e<2/2.75?r*(7.5625*(e-=1.5/2.75)*e+.75)+n:e<2.5/2.75?r*(7.5625*(e-=2.25/2.75)*e+.9375)+n:r*(7.5625*(e-=2.625/2.75)*e+.984375)+n}static easeInOutBounce(e,t,n,r){return e":">",'"':""","'":"'","/":"/","`":"`","=":"="};return(e+"").replace(/[&<>"'`=\/]/g,e=>t[e])}static getScriptLocation(){let e=null;const t=function(t,n){return e=n};try{0()}catch(e){e["stack"].replace(/at.*?\(?(\S+):\d+:\d+\)?$/g,t)}return e=e.replace("smart.element.js",""),e+window[d].StyleBaseUrl}static CSSVariablesSupport(){return window.CSS&&window.CSS.supports&&window.CSS.supports("(--fake-var: 0)")}static assign(e,t){const n=e=>e&&"object"==typeof e&&!Array.isArray(e)&&null!==e;let r=Object.assign({},e);return n(e)&&n(t)&&Object.keys(t).forEach(a=>{n(t[a])?a in e?r[a]=this.assign(e[a],t[a]):Object.assign(r,{[a]:t[a]}):Object.assign(r,{[a]:t[a]})}),r}static html(e,t){const n=this;let r="",a=e.childNodes;if(t){const n=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi;return void(e.innerHTML=t.replace(n,"<$1>"))}for(let o,s=0,i=a.length;s";["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"][e]&&(r+=a),r=r+a+n.html(o)+""}else r+=o.textContent.replace(/[&\u00A0<>]/g,Utilities.Core.escapeHTML)}return r}}let p=[];class StyleObserver{static watch(e){p.push(e),StyleObserver.interval&&clearInterval(StyleObserver.interval),StyleObserver.interval=setInterval(function(){StyleObserver.observe()},100)}static observeElement(e){const t=e;let n=document.defaultView.getComputedStyle(t,null),r=!0;const a=["paddingLeft","paddingRight","paddingTop","paddingBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth","display","visibility","font-size","font-family","font-style","font-weight","max-height","min-height","max-width","min-width","overflow","overflow-x","overflow-y"];if(!t._styleInfo){t._styleInfo=[];for(let e=0;e{n[e]=t=>{n.handlers[e]=t},t[e]=e=>{if(!n.handlers[e.type]){if(("mousemove"===e.type||"pointermove"===e.type||"touchmove"===e.type)&&n.handlers.move){const r=t.createEvent(e,"move");n.handlers.move(r)}return!0}return n.handlers[e.type](e)}}),t.listen(),t.handlers=n.handlers,n}listen(e){const t=this;if("resize"===e&&!t.target.resizeTrigger&&t.target!==document&&t.target!==window){const e=document.createElement("div");e.className="smart-resize-trigger-container",e.innerHTML="
",t.target.appendChild(e),t.target.resizeTrigger=e;const n=e.childNodes[0],r=n.childNodes[0],a=e.childNodes[1],i=function(){r.style.width="100000px",r.style.height="100000px",n.scrollLeft=1e5,n.scrollTop=1e5,a.scrollLeft=1e5,a.scrollTop=1e5};let o,l,s,d,p=t.target.offsetWidth,c=t.target.offsetHeight;if(0===p||0===c){const e=function(){i(),t.target.removeEventListener("resize",e)};t.target.addEventListener("resize",e),i()}else i();t.target.resizeHandler=function(){l||(l=requestAnimationFrame(function(){if(l=0,s=t.target.offsetWidth,d=t.target.offsetHeight,o=s!==p||d!==c,t.target.requiresLayout&&(o=!0),!!o){p=s,c=d;const e=new CustomEvent("resize",{bubbles:!1,cancelable:!0});t.resize(e),t.target.requiresLayout=!1}})),i()},n.addEventListener("scroll",t.target.resizeHandler),a.addEventListener("scroll",t.target.resizeHandler)}if(!t.isListening){if(t.isListening=!0,t.isPressed=!1,t.isReleased=!1,t.isInBounds=!1,window.PointerEvent)t.$target.listen("pointerdown.inputEvents"+t.id,t.pointerDown.bind(t)),t.$target.listen("pointerup.inputEvents"+t.id,t.pointerUp.bind(t)),t.$target.listen("pointermove.inputEvents"+t.id,t.pointerMove.bind(t)),t.$target.listen("pointercancel.inputEvents"+t.id,t.pointerCancel.bind(t));else{const e="ontouchstart"in window;e&&(t.$target.listen("touchmove.inputEvents"+t.id,t.touchMove.bind(t)),t.$target.listen("touchstart.inputEvents"+t.id,t.touchStart.bind(t)),t.$target.listen("touchend.inputEvents"+t.id,t.touchEnd.bind(t)),t.$target.listen("touchcancel.inputEvents"+t.id,t.touchCancel.bind(t))),t.$target.listen("mousedown.inputEvents"+t.id,t.mouseDown.bind(t)),t.$target.listen("mouseup.inputEvents"+t.id,t.mouseUp.bind(t)),t.$target.listen("mousemove.inputEvents"+t.id,t.mouseMove.bind(t)),t.$target.listen("mouseleave.inputEvents"+t.id,t.mouseLeave.bind(t))}t.$document.listen("mouseup.inputEvents"+t.id,t.handleDocumentUp.bind(t))}}unlisten(e){const t=this;if(t.isListening=!1,window.PointerEvent)t.$target.unlisten("pointerdown.inputEvents"+t.id),t.$target.unlisten("pointerup.inputEvents"+t.id),t.$target.unlisten("pointermove.inputEvents"+t.id),t.$target.unlisten("pointercancel.inputEvents"+t.id);else{const e="ontouchstart"in window;e&&(t.$target.unlisten("touchstart.inputEvents"+t.id),t.$target.unlisten("touchmove.inputEvents"+t.id),t.$target.unlisten("touchend.inputEvents"+t.id),t.$target.unlisten("touchcancel.inputEvents"+t.id)),t.$target.unlisten("mousedown.inputEvents"+t.id),t.$target.unlisten("mouseup.inputEvents"+t.id),t.$target.unlisten("mousemove.inputEvents"+t.id),t.$target.unlisten("mouseleave.inputEvents"+t.id)}if(t.$document.unlisten("mouseup.inputEvents"+t.id,t.handleDocumentUp),"resize"===e&&t.target.resizeTrigger){const e=t.target.resizeTrigger,n=e.childNodes[0],r=e.childNodes[1];n.removeEventListener("scroll",t.target.resizeHandler),r.removeEventListener("scroll",t.target.resizeHandler),t.target.resizeHandler=null,t.target.removeChild(e),delete t.target.resizeTrigger}}handleDocumentUp(e){const t=this;t.isPressed=!1,t.isReleased=!1,t.resetSwipe(e)}createEvent(e,t){const n=this,r=e.touches,a=e.changedTouches,i=r&&r.length?r[0]:a&&a.length?a[0]:void 0,o=new CustomEvent(t,{bubbles:!0,cancelable:!0});if(o.originalEvent=e,i){for(let e=0;enew Date-t.touchStartTime?void 0:t.handleDown(e)}touchStart(e){const t=this;return t.touchStartTime=new Date,t.isTouchMoved=!0,t.handleDown(e)}mouseUp(e){const t=this;return t.isReleased||t.touchEndTime&&500>new Date-t.touchEndTime?void 0:t.handleUp(e)}handleDown(e){const t=this;t.isReleased=!1,t.isPressed=!0;const n=t.createEvent(e,"down");return(t.handlers.tap||t.handlers.taphold)&&t.initTap(n),(t.handlers.swipeleft||t.handlers.swiperight||t.handlers.swipetop||t.handlers.swipebottom)&&t.initSwipe(n),t.down(n)}handleUp(e){const t=this;t.isReleased=!0,t.isPressed=!1;const n=t.createEvent(e,"up"),r=t.up(n);return(t.handlers.tap||t.handlers.taphold)&&t.fireTap(n),t.resetSwipe(n),r}handleMove(e){const n=this;let a=n.move(e);return n.isPressed&&(n._maxSwipeVerticalDistance=t(n._maxSwipeVerticalDistance,r(n._startY-e.pageY)),n._maxSwipeHorizontalDistance=t(n._maxSwipeHorizontalDistance,r(n._startX-e.pageX)),a=n.handleSwipeEvents(e)),a}touchEnd(e){const t=this;return t.touchEndTime=new Date,t.handleUp(e)}pointerUp(e){const t=this;return t.handleUp(e)}pointerCancel(e){const t=this;t.pointerUp(e)}touchCancel(e){const t=this;t.touchEnd(e)}mouseLeave(){const e=this;e.isInBounds=!1}mouseMove(e){const t=this;return t.isTouchMoved?void 0:t.handleMove(e)}pointerMove(e){const t=this;return t.handleMove(e)}touchMove(e){const t=this,n=e.touches,r=e.changedTouches,a=n&&n.length?n[0]:r&&r.length?r[0]:void 0;for(let n=0;n=a.swipeMin&&!a._swipeEvent&&!a._swipeLocked){let i=0>t?"swipeleft":"swiperight";if("horizontal"===n?a._swipeEvent=a.createEvent(e,i):(i=0>t?"swipetop":"swipebottom",a._swipeEvent=a.createEvent(e,0>t?"swipetop":"swipebottom")),a[i]&&(a[i](this._swipeEvent),r(t)<=this.swipeMax))return e.stopImmediatePropagation(),!1}return!0}resetSwipe(){const e=this;e._swipeEvent=null,clearTimeout(this._swipeTimeout)}initSwipe(e){const t=this;t._maxSwipeVerticalDistance=0,t._maxSwipeHorizontalDistance=0,t._startX=e.pageX,t._startY=e.pageY,t._swipeLocked=!1,t._swipeEvent=null,t._swipeTimeout=setTimeout(function(){t._swipeLocked=!0},t.swipeDelay)}}class Scroll{get scrollWidth(){const e=this;return e.horizontalScrollBar?e.horizontalScrollBar.max:-1}set scrollWidth(e){const t=this;0>e&&(e=0),t.horizontalScrollBar&&(t.horizontalScrollBar.max=e)}get scrollHeight(){const e=this;return e.verticalScrollBar?e.verticalScrollBar.max:-1}set scrollHeight(e){const t=this;0>e&&(e=0),t.verticalScrollBar&&(t.verticalScrollBar.max=e)}get scrollLeft(){const e=this;return e.horizontalScrollBar?e.horizontalScrollBar.value:-1}set scrollLeft(e){const t=this;0>e&&(e=0),t.horizontalScrollBar&&(t.horizontalScrollBar.value=e)}get scrollTop(){const e=this;return e.verticalScrollBar?e.verticalScrollBar.value:-1}set scrollTop(e){const t=this;0>e&&(e=0),t.verticalScrollBar&&(t.verticalScrollBar.value=e)}get vScrollBar(){const e=this;return e.verticalScrollBar}get hScrollBar(){const e=this;return e.horizontalScrollBar}constructor(e,t,n){const r=this;r.container=e,r.horizontalScrollBar=t,r.verticalScrollBar=n,r.disableSwipeScroll=!1,r.listen()}listen(){function e(){let r,a;h.amplitude&&(n.container.$.fireEvent("kineticScroll"),r=Date.now()-p,a=-h.amplitude*t(-r/y),5a?(w(h.targetValue+a),cancelAnimationFrame(s),s=0,s=requestAnimationFrame(e)):w(h.targetValue))}var t=Math.exp;const n=this,a=Core.isMobile,i=n.horizontalScrollBar,o=n.verticalScrollBar;n.inputEvents=new InputEvents(n.container);let l,s,d,p,c,m,u,h,y=500;const g=function(e){return{amplitude:0,delta:0,initialValue:0,min:0,max:e.max,previousValue:0,pointerPosition:0,targetValue:0,scrollBar:e,value:0,velocity:0}},v=g(i),b=g(o),f=function(){m=Date.now(),u=m-p,p=m;const e=function(e){e.delta=e.value-e.previousValue,e.previousValue=e.value;let t=1e3*e.delta/(1+u);e.velocity=.8*t+.2*e.velocity};e(b),e(v)},w=function(e){return h.value=e>h.max?h.max:eh.max?"max":eb.velocity?t(b):(10v.velocity)&&t(v),d=!1}),n.inputEvents.move(function(e){if(!d)return!0;if(n.disableSwipeScroll)return;if(l&&(e.originalEvent.preventDefault(),e.originalEvent.stopPropagation()),v.visible=0e.delta?(h=e,t=e.initialValue+e.delta>h.max?"max":e.initialValue+e.delta=i.max&&(e=i.max),i.targetValue=e;const l=e;let d=i.value;i.velocity=100*i.delta/(1+i.max),i.from=d;const c=function(e){return i.value=e>i.max?i.max:ei.max?"max":ey&&i.value<=e?y=0:0=e&&(y=0),(i.value+y<=i.min||i.value+y>=i.max)&&(y=0),.5y?(c(i.value+y),cancelAnimationFrame(s),s=0,s=requestAnimationFrame(m)):c(i.targetValue);else{if(u>=a)return cancelAnimationFrame(s),n.container.$.fireEvent("kineticScroll"),void(s=0);r=Utilities.Animation.Easings.easeInSine(u,d,l-d,a),c(r),cancelAnimationFrame(s),s=0,s=requestAnimationFrame(m)}};cancelAnimationFrame(s),s=requestAnimationFrame(m)},n.inputEvents.listen()}unlisten(){const e=this;e.inputEvents&&e.inputEvents.unlisten(),delete e.inputEvents}}class Extend{constructor(e){this.events={},this.handlers={},this.element=e}hasClass(e){const t=this,n=e.split(" ");for(let r=0;rr?1:0});for(let r=0;re.namespace===r);o.splice(e,1);break}else o=[];0===o.length&&(t.element.removeEventListener(a,t.handlers[a]),t.events[a]=[],delete t.handlers[a])}}getAttributeValue(e,t){const n=this,r=n.element.getAttribute(e);if(n.isNativeElement)return n.deserialize(r,t);const a=n.element.propertyByAttributeName[e],i=a.deserialize===void 0?n.deserialize(r,t,a.nullable):n.element[a.deserialize](r);return i}setAttributeValue(e,t,n){const r=this;let a,i=!1;if(!r.isNativeElement){const o=r.element.propertyByAttributeName[e];i=!o||o.nullable,a=o&&o.serialize?r.element[o.serialize](t):r.serialize(t,n,i)}else if(a=r.serialize(t,n),"boolean"===n){if(0<=["checked","selected","async","autofocus","autoplay","controls","defer","disabled","hidden","ismap","loop","multiple","open","readonly","required","scoped"].indexOf(e))return void(t?r.element.setAttribute(e,""):r.element.removeAttribute(e))}return("array"===n||"object"===n)&&("[]"===a||"{}"===a)?void r.element.removeAttribute(e):void(void 0===a?r.element.removeAttribute(e):r.element.setAttribute(e,a))}serialize(e,t,n){if(void 0===t&&(t=Utilities.Types.getType(e)),void 0!==e&&(n||null!==e)){if(n&&null===e)return"null";if("string"===t)return e;if("boolean"===t||"bool"===t){if(!0===e||"true"===e||1===e||"1"===e)return"";if(!1===e||"false"===e||0===e||"0"===e)return}if("array"===t)return JSON.stringify(e);return 0<=["string","number","int","integer","float","date","any","function"].indexOf(t)?e.toString():"object"===t?JSON.stringify(e):void 0}}deserialize(e,t,n){const r="null"===e;if(void 0!==e&&(!r||n)){if(r&&n)return null;if("boolean"===t||"bool"===t)return null!==e;if("number"===t||"float"===t)return"NaN"===e?NaN:"Infinity"===e?1/0:"-Infinity"===e?-Infinity:parseFloat(e);if("int"===t||"integer"===t)return"NaN"===e?NaN:"Infinity"===e?1/0:"-Infinity"===e?-Infinity:parseInt(e);if("string"===t)return e;if("any"===t)return e;if("date"===t)return new Date(e);if("function"===t){if("function"==typeof window[e])return window[e];}else if("array"===t||"object"===t)try{const t=JSON.parse(e);if(t)return t}catch(n){if(window[e]&&"object"==typeof window[e])return window[e];if("array"===t&&0<=e.indexOf("[")){const t=e.replace("[","").replace("]","").replace(/'/ig,"").replace(/"/ig,"").trim().split(",");return t}}}}}class Animation{static get Ripple(){return Ripple}static get Easings(){return Easings}}class Utilities{static get Types(){return Types}static get Core(){return Core}static get Animation(){return Animation}static get Scroll(){return Scroll}static get InputEvents(){return InputEvents}static Extend(e){return new Extend(e)}static Assign(e,t){Utilities[e]=t}}const y=Utilities.Extend(document);BindingModule.cache={};class BaseElement extends HTMLElement{static get properties(){return{animation:{value:"advanced",type:"string",allowedValues:["none","simple","advanced"]},unfocusable:{value:!1,type:"boolean"},disabled:{value:!1,type:"boolean"},dataContext:{value:null,reflectToAttribute:!1,type:"any"},messages:{value:{en:{propertyUnknownType:"'{{name}}' property is with undefined 'type' member!",propertyInvalidValue:"Invalid '{{name}}' property value! Actual value: '{{actualValue}}', Expected value: '{{value}}'!",propertyInvalidValueType:"Invalid '{{name}}' property value type! Actual type: '{{actualType}}', Expected type: '{{type}}'!",methodInvalidValueType:"Invalid '{{name}}' method argument value type! Actual type: '{{actualType}}', Expected type: '{{type}}' for argument with index: '{{argumentIndex}}'!",methodInvalidArgumentsCount:"Invalid '{{name}}' method arguments count! Actual arguments count: '{{actualArgumentsCount}}', Expected at least: '{{argumentsCount}}' argument(s)!",methodInvalidReturnType:"Invalid '{{name}}' method return type! Actual type: '{{actualType}}', Expected type: '{{type}}'!",elementNotInDOM:"Element does not exist in DOM! Please, add the element to the DOM, before invoking a method.",moduleUndefined:"Module is undefined.",missingReference:"{{elementType}}: Missing reference to '{{files}}'.",htmlTemplateNotSuported:"{{elementType}}: Web Browser doesn't support HTMLTemplate elements.",invalidTemplate:"{{elementType}}: '{{property}}' property accepts a string that must match the id of an HTMLTemplate element from the DOM."}},reflectToAttribute:!1,type:"object"},readonly:{value:!1,type:"boolean"},rightToLeft:{value:!1,type:"boolean"},theme:{value:window[d].Theme,type:"string"}}}static get requires(){return{}}static get listeners(){return{"theme-changed":function(e){this.theme=e.detail.newValue}}}static get methods(){return{}}get classNamesMap(){return{animation:"smart-animate",rippleAnimation:"smart-ripple"}}get hasAnimation(){const e=this;return"none"!==e.animation}get hasRippleAnimation(){const e=this;return"none"!==e.animation&&!("advanced"!==e.animation)}static get modules(){return window[d].Modules}get properties(){const e=this;return e._properties||(e._properties=[]),e._properties}get parents(){const e=this;let t=[],n=e.parentNode;for(;n&&9!==n.nodeType;)!0==n instanceof HTMLElement&&t.push(n),n=n.parentNode;return t}get focused(){return this.contains(document.activeElement)}template(){return"
"}registered(){const e=this;e.onRegistered&&e.onRegistered()}created(){const e=this;e.isReady=!1,e._initElement(e),e._setModuleState("created"),e.onCreated&&e.onCreated()}completed(){const e=this;e.isCompleted=!0,e._onCompleted&&e._onCompleted(),e.onCompleted&&e.onCompleted()}whenReady(e){const t=this;return t.isCompleted?void e():void(!t.whenReadyCallbacks&&(t.whenReadyCallbacks=[]),t.whenReadyCallbacks.push(e))}ready(){const e=this;""!==e.theme&&e.classList.add("smart-"+e.theme);const t=()=>{let t=[];const n=e.getStaticMember("requires");for(let e in n){const r=e.split(".");2{e.templateBindingsReady||(e.templateBindingsReady=!0,e.updateTextNodes(),e.updateBoundNodes())};if(!e.ownerElement)t(e);else{let n=e.ownerElement,r=[];for(;n;)r.push(n),n=n.ownerElement;for(let e=r.length-1;0<=e;e--)t(r[e]);t(e)}}if(e._setModuleState("ready"),e.ready(),e.isAttached=!0,e._setModuleState("attached"),e.attached(),e._handleListeners("listen"),(0===e.offsetWidth||0===e.offsetHeight)&&(e.isHidden=!0),e.completed(),e.context=document,e.whenReadyCallbacks){for(let t=0;t{for(let a in r){const i=a.split(".");let o=i[0],l=t.$;if(!i[1])t.smartId&&(o=o+"."+t.smartId);else if(o=i[1],l=t["$"+i[0]],"document"===i[0]){let e=t.smartId;""===e&&(e=Utilities.Core.toCamelCase(n)),o=o+"."+e}else t.smartId&&(o=o+"."+t.smartId+"_"+t.parents.length);const s=r[a];l&&l[e](o,function(e){const n=t.context;t.context=t,t[s]&&t[s].apply(t,[e]),t.context=n})}};a(r),a(t.templateListeners),Smart(t._selector)&&Smart(t._selector).properties&&a(Smart(t._selector).listeners)}parseTemplate(){const e=this,t=e.template(),n=document.createDocumentFragment();if(""===t)return null;let r=document.createElement("div");n.appendChild(r),r.innerHTML=t;let a=r.childNodes;r.parentNode.removeChild(r);for(let e=0;e{e["$"+t]=n.$=Utilities.Extend(n),e.$[t]=n,n.ownerElement=e};let i=r;if(0e.moduleName===t.moduleName)&&n.push(e),t.defineModule(e),t.defineElementMethods(r.methodNames,r),t.defineElementProperties(e.properties);const a=t.constructor.prototype;a.modules=n}defineModule(e){if(e.isDefined)return;e.prototype._initModule=function(e){const t=this;t.ownerElement=e};const t=e.properties||{},n=Object.keys(t),r=Object.getOwnPropertyNames(e.prototype);e.prototype.methodNames=r;for(let r=0;re===i.type);if(0<=e)continue}const t=e.localize("propertyInvalidValueType",{name:a,actualType:l,type:i.type});e.log(t)}}e.defineElementHierarchicalProperties(e._properties,e),e.isCreated=!0},t.registered()}defineElementMethods(e,t){const n=this,r=n.constructor.prototype,a=function(e,t){const n=Array.prototype.slice.call(arguments,2),r=function(){if(!this.isReady&&"localize"!==t&&"log"!==t&&"parseAttributes"!==t){const e=this.localize("elementNotInDOM");this.log(e)}let r=this;for(let e,n=0;nparseInt(e)):[],u=0===e.length?new Date:new Date(e[0],e[1],e[2]);break}case"bool":case"boolean":u="true"===u||"1"===u;break;case"int":case"integer":u=parseInt(u);break;case"float":case"number":u=parseFloat(u);break;case"any":case"object":u=0<=u.indexOf("{")?JSON.parse(u):u;}i.push(u)}else s&&p--;if(c!==h&&h){let n=!0;for(let e=0;ee===o)||!r.extendedProperties[o]&&Utilities.Types.isFunction(t[o])&&(r[o]=a(t[o],o))}}defineElementProperties(e){if(!e)return;const t=this,n=t.constructor.prototype,r=Object.keys(e),a=t.getStaticMember("properties");Object.assign(n.extendedProperties,e),t.updateProperty=function(e,t,n){const r=e;if(t.readOnly)return;if(t.allowedValues){let e=!1;for(let r=0;re===t.type);0<=n&&(e=!1)}if(e){const e=r.localize("propertyInvalidValueType",{name:a,actualType:Utilities.Types.getType(n),type:t.type});return void r.error(e)}}t.isUpdating=!0,r._properties[a].value=n,!t.isUpdatingFromAttribute&&t.reflectToAttribute&&r.$.setAttributeValue(t.attributeName,n,t.type);const e=r.isReady&&(!r.ownerElement||r.ownerElement&&r.ownerElement.isReady);if(e){if(r.context!==r){const e=r.context;r.context=r,r.propertyChangedHandler(a,i,n),r.context=e,t.observer&&r[t.observer]&&(r.context=r,r[t.observer](i,n),r.context=document),r._watch&&0<=r._watch.properties.indexOf(a)&&r._watch.propertyChangedCallback(a,i,n)}const e=t.notify||r.boundProperties[a];e&&(r.$.fireEvent(t.attributeName+"-changed",{context:r.context,oldValue:i,value:r[a]}),r.boundProperties[a]&&r.updateBoundNodes(a)),e&&r.templateProperties&&r.templateProperties[a]&&r.refreshTemplate(),r.dataContextProperties&&("dataContext"===a?r.applyDataContext():r.dataContextProperties[a]&&r.updateDataContextProperty(a))}t.isUpdating=!1}}};for(let t=0;t=e&&(f=!0)}const x="customElements"in window,C=function(){if("complete"===document.readyState){b.sort(function(e,t){let n=e.element.parents.length,r=t.element.parents.length;return nr?1:0});for(let e=0;er.array.length&&r.push.apply(r,Array(t-r.array.length));else throw new RangeError("Invalid array length");return e}}),Object.getOwnPropertyNames(Array.prototype).forEach(function(e){if(!(e in r)){Object.defineProperty(r,e,{configurable:!1,enumerable:!0,writeable:!1,value:function(){const t=r.observing;r.observing=!1;const n=r.array[e],a=n.apply(r.array,arguments);return r.observing=t,a}})}}),Array.isArray(e)&&r.push.apply(r,e),r.observeFunction=t}observe(e){const t=this;t.observing=!0,e&&(t.observeFunction=e)}unobserve(){const e=this;e.observing=!1}toArray(){const e=this;return e.array.slice(0)}defineIndexProperty(e){const t=this;if(!(e in t)){const n=function(e,n,r,a){if(e instanceof HTMLElement||e.ownerDocument)return;if(n.startsWith("_"))return;let i=e[n],o=i;const l=function(){return o},s=function(e){if(i=e,o!==i){let e=o;if(o=i,"function"==typeof t.notifier){let r="";const o=t.array.indexOf(a),l=function(e,t){Object.getOwnPropertyNames(e).forEach(function(a){let i=!1;e[a]instanceof HTMLElement&&(i=!0);let o=Smart.Utilities.Types.getType(e[a]);i&&(o="HTMLElement"),"array"===o||"object"===o?l(e[a],t+"."+a):n===a&&(r=t+"."+a)})};l(a,o),t.notifier({object:t,type:"update",item:t[o],path:r,index:o,name:n,newValue:i,oldValue:e})}}return o=i,i};e[n]!==void 0&&"length"!==n&&(Object.defineProperty(e,n,{get:l,set:s}),e.isDefined=!0)},r=function(e,t,a){const i=this,o=Smart.Utilities.Types.getType(e);/(number|float|int|integer|string|boolean)/.test(o)||void 0===e||e instanceof HTMLElement||e.ownerDocument||e.isDefined||Object.getOwnPropertyNames(e).forEach(function(o){let l=Smart.Utilities.Types.getType(e[o]);if(!o.startsWith("_"))if("array"===l||"object"===l){if(e[o]===i)return;if(e[o]instanceof HTMLElement||e[o].ownerDocument)return;n(e,o,t+"."+o,a),r(e[o],t+"."+o,a)}else n(e,o,t+"."+o,a)})};Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get:function(){return t.array[e]},set:function(n){function a(e,t){return e.startsWith("_")?void 0:t}let i=t.array[e];JSON.stringify(i,a)!==JSON.stringify(n,a)&&(t.array[e]=n,t.notifier({object:t,type:"update",item:t[e],path:e.toString(),index:e,name:"index",newValue:n,oldValue:i}),r(n,e,n))}}),r(t[e],e,t[e])}}push(){const e=this;let t;for(let n=0,r=arguments.length;ne||e>=t.length)throw new Error("Invalid index : "+e);if(t.hasOwnProperty(e)){let n=t[e];return t[e]=void 0,t.array[e]=void 0,t.notifier({object:t,type:"delete",item:t[e],index:e,name:"index",newValue:void 0,oldValue:n}),!0}return!1}concat(e,t){const n=this,r=n.array.concat(e),a=new Smart.ObservableArray(r,t);return a}set(e,t){const n=this;if("string"===Smart.Utilities.Types.getType(e)&&1=n.length)throw new Error("Invalid Index: "+e);o=n.length?n.push(t):n[e]=t,!0}get(e){const t=this;return t[e]}notifier(){const e=this;e.observing&&(arguments&&arguments[0]&&e.changes.push(arguments[0]),e.observeFunction&&e.observeFunction.apply(e,arguments))}}let E={};window[d]&&(E=window[d]),window[d]=function(t,n){let r=t;if(t){if(0<=t.indexOf("#")||0<=t.indexOf("."))return u[t]?u[t]:void(n&&(u[t]=new n,e(t,u[t])));if(n){if(ElementRegistry.tagNames[t]=n,ElementRegistry.lazyRegister){ElementRegistry.toRegister||(ElementRegistry.toRegister=[]);const e=Core.toCamelCase(r).replace(/[a-z]+/,"");return window[d][e]=n,void ElementRegistry.toRegister.push({tagName:r,element:n})}ElementRegistry.register(r,n)}}},window.addEventListener("load",function(){const e=window[d].Elements.tagNames;for(let t in e){const n=e[t];let r=document.querySelectorAll("["+t+"]");for(let e=0;e"}ready(){super.ready();const e=this;e.applyContent()}clearContent(){for(const e=this;e.$.content.firstChild;)e.$.content.removeChild(e.$.content.firstChild)}applyContent(){const e=this;if(void 0===e.content)return void(e.content=e.$.content);if(""===e.content||null===e.content)return void e.clearContent();if(e.content instanceof HTMLElement)return e.clearContent(),void e.$.content.appendChild(e.content);const t=document.createDocumentFragment();let n=document.createElement("div");t.appendChild(n),e.content instanceof HTMLElement?n.appendChild(e.content):n.innerHTML=e.content;let r=Array.from(n.childNodes);n.parentNode.removeChild(n);for(let e=0;e 7 |
8 |
9 | 10 |
11 |
12 | 13 | 14 | `}_horizontalScrollbarHandler(e){const t=this;t.$.scrollViewerContentContainer.style.left=-t.scrollLeft+"px",e.stopPropagation()}_verticalScrollbarHandler(e){const t=this;t.$.scrollViewerContentContainer.style.top=-t.scrollTop+"px",e.stopPropagation()}_mouseWheelHandler(e){const t=this;(t.computedHorizontalScrollBarVisibility||t.computedVerticalScrollBarVisibility)&&(t.disabled||!t.computedVerticalScrollBarVisibility||(e.stopPropagation(),0e.deltaY?-t.offsetHeight:t.offsetHeight))))}applyContent(){const e=this;super.applyContent(),e.refresh()}get computedHorizontalScrollBarVisibility(){const e=this;return e._scrollView&&e._scrollView.hScrollBar?!e._scrollView.hScrollBar.$.hasClass("smart-hidden"):null}get computedVerticalScrollBarVisibility(){const e=this;return e._scrollView&&e._scrollView.vScrollBar?!e._scrollView.vScrollBar.$.hasClass("smart-hidden"):null}scrollTo(e,t){const n=this;n._scrollView&&(e!==void 0&&n._scrollView.scrollTo(e),t!==void 0&&n._scrollView.scrollTo(t,!1))}refreshScrollBarsVisibility(){const e=this;e._scrollView&&(e._scrollView.hScrollBar.disabled=e.disabled,e._scrollView.vScrollBar.disabled=e.disabled,"disabled"===e.horizontalScrollBarVisibility&&(e._scrollView.hScrollBar.disabled=!0),"disabled"===e.verticalScrollBarVisibility&&(e._scrollView.vScrollBar.disabled=!0),0=e.scrollHeight)),e.computedHorizontalScrollBarVisibility&&e.computedVerticalScrollBarVisibility?(e._scrollView.hScrollBar.$.addClass("bottom-corner"),e._scrollView.vScrollBar.$.addClass("bottom-corner")):(e._scrollView.hScrollBar.$.removeClass("bottom-corner"),e._scrollView.vScrollBar.$.removeClass("bottom-corner")))}ready(){super.ready();const e=this;e._scrollView=new Smart.Utilities.Scroll(e,e.$.horizontalScrollBar,e.$.verticalScrollBar),e.refresh()}refresh(){const e=this;if(!e.$.scrollViewerContentContainer)return;let t=e.$.scrollViewerContentContainer.offsetWidth-e.$.scrollViewerContainer.offsetWidth,n=e.$.scrollViewerContentContainer.offsetHeight-e.$.scrollViewerContainer.offsetHeight;0e&&(e=0),t._scrollView&&t._scrollView.hScrollBar&&(t._scrollView.hScrollBar.max=0===e&&"visible"===t.horizontalScrollBarVisibility?0:e,t.refreshScrollBarsVisibility())}get scrollHeight(){const e=this;return e._scrollView&&e._scrollView.vScrollBar?1===e._scrollView.vScrollBar.max&&"visible"===e.verticalScrollBarVisibility?0:e._scrollView.vScrollBar.max:0}set scrollHeight(e){const t=this;0>e&&(e=0),t._scrollView&&t._scrollView.vScrollBar&&(t._scrollView.vScrollBar.max=0===e&&"visible"===t.verticalScrollBarVisibility?1:e,t.refreshScrollBarsVisibility())}get scrollLeft(){const e=this;return e._scrollView&&e._scrollView.hScrollBar?e._scrollView.hScrollBar.value:0}set scrollLeft(e){const t=this;0>e&&(e=0),t._scrollView&&t._scrollView.hScrollBar&&(t._scrollView.hScrollBar.value=e)}get scrollTop(){const e=this;return e._scrollView&&e._scrollView.vScrollBar?e._scrollView.vScrollBar.value:0}set scrollTop(e){const t=this;0>e&&(e=0),t._scrollView&&t._scrollView.vScrollBar&&(t._scrollView.vScrollBar.value=e)}propertyChangedHandler(){const e=this;e.refresh()}}),window[d].Utilities.Assign("PositionDetection",class{constructor(e,t,n,r){const a=this;a.context=e,a.dropDown=t,a.defaultParent=n,a.closeMethod=r}handleAutoPositioning(){function e(){a=r(e),("auto"!==n.dropDownPosition||n.disabled||null===n.parentElement)&&cancelAnimationFrame(a);const o=Date.now();200<=o-i&&(t.scrollHandler(),i=Date.now())}const t=this,n=t.context;if("auto"!==n.dropDownPosition||n.disabled)return;const r=(()=>window.requestAnimationFrame)();let a,i=Date.now();return a=r(e)}checkBrowserBounds(e){const t=this.context;"auto"!==t.dropDownPosition||t.disabled||("vertically"===e?this.checkBrowserBoundsVertically():"horizontally"===e?this.checkBrowserBoundsHorizontally():(this.checkBrowserBoundsVertically(),this.checkBrowserBoundsHorizontally()))}checkBrowserBoundsHorizontally(){const e=this.context,t=this.dropDown;let n,a=0;null===e._dropDownParent?t.style.left="":(n=!0,window.innerWidth!==document.documentElement.clientWidth&&(a=window.innerWidth-document.documentElement.clientWidth));let i=e.getBoundingClientRect().left;if(0>i&&(t.style.left=(n?0:r(i))+"px",i=parseFloat(t.style.left)),i+t.offsetWidth>document.documentElement.clientWidth){const e=i-r(document.documentElement.clientWidth-i-t.offsetWidth);t.style.left=(n?e:e-i)+"px",window.innerWidth===document.documentElement.clientWidth&&(t.style.left=parseFloat(t.style.left)+a+"px"),n&&window.innerHeight===document.documentElement.clientHeight&&this.positionDropDown(!0)}}checkBrowserBoundsVertically(e){const t=this.context,n=this.dropDown,a=t._dropDownListPosition;e||(e=t.getBoundingClientRect()),t._dropDownListPosition=0<=document.documentElement.clientHeight-r(e.top+e.height+n.offsetHeight)?"bottom":0<=e.top-n.offsetHeight?"top":"overlay-bottom",this.updatePositionAttribute(a,t._dropDownListPosition)}scrollHandler(){const e=this.context;if(e.parentElement){const t=e.getBoundingClientRect();if(t.top!==e._positionTop){const n=e._dropDownListPosition;this.checkBrowserBoundsVertically(t),e._dropDownListPosition!==n&&this.positionDropDown(),e._positionTop=t.top}}}getDropDownParent(e){const t=this.context,n=this.dropDown;let r=t.dropDownAppendTo;t._positionedParent=null,null===r?t._dropDownParent=null:"body"===r||r===document.body?t._dropDownParent=document.body:r instanceof HTMLElement?t._dropDownParent=r:"string"==typeof r?(r=document.getElementById(r),r instanceof HTMLElement?t._dropDownParent=r:(t.dropDownAppendTo=null,t._dropDownParent=null)):(t.dropDownAppendTo=null,t._dropDownParent=null);let a=t._dropDownParent;if(null!==a){for(;"static"===window.getComputedStyle(a).position&&a!==document.body;)a=a.parentElement;t._positionedParent=a===document.body?null:a,n&&(n.setAttribute("animation",t.animation),""!==t.theme&&n.$.addClass(t.theme),e&&(t._dropDownParent.appendChild(n),n.$.addClass("smart-drop-down-repositioned")),-1===t.detachedChildren.indexOf(n)&&t.detachedChildren.push(n))}}dropDownAppendToChangedHandler(){const e=this.context,t=this.dropDown,n=e._dropDownParent;this.getDropDownParent();e._dropDownParent===n||(e[this.closeMethod](),["left","top","font-size","font-family","font-style","font-weight"].forEach(e=>t.style[e]=null),null===e._dropDownParent?(this.defaultParent.appendChild(t),t.$.removeClass("smart-drop-down-repositioned")):(e._dropDownParent.appendChild(t),t.$.addClass("smart-drop-down-repositioned")))}dropDownPositionChangedHandler(){const e=this;e.dropDown.style.transition="none",e.context[e.closeMethod](),e.setDropDownPosition(),e.handleAutoPositioning()}dropDownAttached(e){const t=this.context;null===t._dropDownParent||(t._dropDownParent.appendChild(this.dropDown),this.handleAutoPositioning(),e&&t[e]())}dropDownDetached(){const e=this.context;null!==e._dropDownParent&&e._dropDownParent.removeChild(this.dropDown)}setDropDownPosition(){const e=this.context,t=e.dropDownPosition,n=e._dropDownListPosition;"auto"===t?this.checkBrowserBounds():e._dropDownListPosition=t,this.updatePositionAttribute(n,e._dropDownListPosition)}updatePositionAttribute(e,t){const n=this.context,r=this.dropDown;n.$.dropDownButton&&!n.$.dropDownButton.hasAttribute(t)&&(n.$.dropDownButton.removeAttribute(e),n.$.dropDownButton.setAttribute(t,"")),r.hasAttribute(t)||(r.style.transition="none",r.removeAttribute(e),r.setAttribute(t,""),requestAnimationFrame(function(){r.style.transition=null}))}positionDropDown(e){const t=this.context,n=this.dropDown;if(!t.opened||null===t._dropDownParent)return;const r=t.getBoundingClientRect();let a,i;if(this.customPositionDropDown){const e=this.customPositionDropDown(r);a=e.left,i=e.top}else switch(a=r.left,i=r.top,t._dropDownListPosition){case"bottom":i+=t.$.container.offsetHeight-1;break;case"center-bottom":i+=t.$.container.offsetHeight-1,a+=t.offsetWidth-n.offsetWidth/2;break;case"center-top":i-=n.offsetHeight-1,a+=t.offsetWidth-n.offsetWidth/2;break;case"top":i-=n.offsetHeight-1;break;case"overlay-bottom":break;case"overlay-center":i-=n.offsetHeight/2-t.offsetHeight/2;break;case"overlay-top":i-=n.offsetHeight-t.offsetHeight;}const o=this.getDropDownOffset();n.style.top=i+o.y+"px";e||(n.style.left=a+o.x+"px")}getDropDownOffset(){const e=this.context._positionedParent;let t,n;if(e){const r=e.getBoundingClientRect();t=-r.left,n=-r.top}else t=window.pageXOffset,n=window.pageYOffset;return{x:t,y:n}}placeOverlay(){const e=this.context;if(e.dropDownOverlay&&!e._overlay){const t=document.createElement("div");t.classList.add("smart-drop-down-overlay"),t.style.width=document.documentElement.scrollWidth+"px",t.style.height=document.documentElement.scrollHeight+"px",document.body.appendChild(t),e._overlay=t}}removeOverlay(e){function t(){0