@webtides/element-js 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,58 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
6
+
7
+ <!--
8
+ PRs should document their user-visible changes (if any) in the
9
+ Unreleased section, uncommenting the header as necessary.
10
+ -->
11
+
12
+ <!-- ## Unreleased -->
13
+ <!-- ### Added -->
14
+ <!-- ### Changed -->
15
+ <!-- ### Removed -->
16
+ <!-- ### Fixed -->
17
+
18
+ ## [0.3.3] - 2021-09-22
19
+
20
+ ### Added
21
+ * optional complex event callback notation to support addEventListener options (i.E. for passive Event Listeners )
22
+ * Example: {listener: () => {}, options: { passive: true } }
23
+ * docs
24
+ * tests
25
+
26
+
27
+ ## [0.3.2] - 2021-03-09
28
+
29
+ ### Added
30
+ * bundled version of `element-js` to use from a CDN and be able to prototype in tools like CodePen etc.
31
+
32
+ ## [0.3.1] - 2020-12-08
33
+
34
+ ### Fixed
35
+ * i18n fallback values
36
+
37
+ ### Added
38
+ * i18n tests
39
+
40
+ ## [0.3.0] - 2020-07-27
41
+
42
+ ### Added
43
+ * first batch/draft of the documentation
44
+ * property/attribute reflection via constructor options (see the [Documentation](/docs/README.md#propertyoptions) for more info)
45
+ * mutationObserverOptions to enable observing subtree mutations (see the [Documentation](/docs/README.md#mutationobserveroptions) for more info)
46
+
47
+ ### Removed
48
+ * `childListUpdate` constructor option has been deprecated and will be removed before `1.0`
49
+
50
+ ## [0.2.0] - 2020-07-01
51
+
52
+ ### Changed
53
+ * uses shady-render instead of render from `lit-html` for rendering templates to be compatible with the shady-css polyfill
54
+ * refactored and simplified `StyledElement`s handling/loading of style sheets
55
+
56
+ ## [0.1.0] - 2020-06-26
57
+
58
+ * initial release
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Eddy Löwen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # element-js
2
+
3
+ Simple and lightweight base classes for web components with a beautiful API
4
+
5
+ ## Introduction
6
+
7
+ `element-js` lets you write simple, declarative and beautiful web components without the boilerplate. It uses `lit-html` for rendering.
8
+
9
+ ## How to use
10
+
11
+ #### Installation
12
+
13
+ install `element-js`
14
+
15
+ ```sh
16
+ npm install --save @webtides/element-js
17
+ ```
18
+
19
+ #### Use / Example Element
20
+
21
+ `element-js` elements are plain ES6 classes (vanilla JS) with some nice mappings (eg. properties, watch, etc.).
22
+
23
+ ```javascript
24
+ // Import from a CDN
25
+ // import { BaseElement, defineElement } from 'https://unpkg.com/@webtides/element-js';
26
+ // import { BaseElement, defineElement } from 'https://cdn.skypack.dev/@webtides/element-js';
27
+ // or when installed via npm
28
+ import { BaseElement, defineElement } from '@webtides/element-js';
29
+
30
+ class ExampleElement extends BaseElement {
31
+ // normal public properties
32
+ greeting = 'Hello';
33
+ name = 'John';
34
+
35
+ // lifecycle hook
36
+ connected() {
37
+ this.greet();
38
+ }
39
+
40
+ // reactive attributes/properties
41
+ properties() {
42
+ return {
43
+ familyName: 'Doe'
44
+ };
45
+ }
46
+
47
+ // watchers for property changes
48
+ watch() {
49
+ return {
50
+ familyName: (newValue, oldValue) => {
51
+ console.log('familyName changed', newValue, oldValue);
52
+ }
53
+ };
54
+ }
55
+
56
+ // computed property
57
+ get computedMsg() {
58
+ return `${this.greeting} ${this.name} ${this.familyName}`;
59
+ }
60
+
61
+ // method
62
+ greet() {
63
+ alert('greeting: ' + this.computedMsg);
64
+ }
65
+ }
66
+ defineElement('example-element', ExampleElement);
67
+ ```
68
+
69
+ To use this element, just import it and use it like any other HTML element
70
+
71
+ ```html
72
+ <script type="module" src="example-element.js" />
73
+ <example-element family-name="Smith"></example-element>
74
+ ```
75
+
76
+ ## Documentation
77
+
78
+ For detailed documentation see the [Docs](docs/README.md).
79
+
80
+ ## Contributing & Development
81
+
82
+ For contributions and development see [contributing docs](.github/CONTRIBUTING.md)
83
+
84
+ ## License
85
+
86
+ `element-js` is open-sourced software licensed under the MIT [license](LICENSE).