p-elements-core 1.2.0-rc7 → 1.2.0
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/.babelrc +29 -0
- package/demo/sample.js +20 -0
- package/{screen.css → demo/screen.css} +0 -0
- package/{theme.css → demo/theme.css} +0 -0
- package/dist/p-elements-core-modern.js +3 -4
- package/dist/p-elements-core.js +3 -14
- package/index.html +9 -9
- package/older-browsers-webpack.config.js +60 -0
- package/p-elements-core.d.ts +70 -20
- package/package.json +22 -46
- package/src/cache.ts +34 -0
- package/src/custom-element.ts +303 -0
- package/src/custom-style-element.ts +38 -20
- package/src/dom.ts +133 -0
- package/src/h.ts +86 -0
- package/src/index.ts +40 -0
- package/src/interfaces.ts +15 -0
- package/src/mapping.ts +79 -0
- package/src/projection.ts +730 -0
- package/src/projector.ts +110 -0
- package/src/sample.tsx +112 -50
- package/tsconfig.json +1 -1
- package/webpack.config.js +52 -162
- package/dist/sample.js +0 -2
- package/global.js +0 -1
- package/karma.conf.js +0 -32
- package/src/commonjs.js +0 -182
- package/src/custom-event-polyfill.js +0 -78
- package/src/index.tsx +0 -23
- package/src/sample.css +0 -20
- package/src/sample.spec.ts +0 -112
- package/src/utils/custom-element.ts +0 -241
- package/src/utils/maquette.ts +0 -1328
- package/types/custom-style-element.d.ts +0 -3
- package/types/index.d.ts +0 -1
- package/types/sample.d.ts +0 -1
- package/types/utils/custom-element.d.ts +0 -29
- package/types/utils/maquette.d.ts +0 -521
- package/webpack.config.karma.js +0 -35
package/src/projector.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { applyDefaultProjectionOptions, dom } from "./dom";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a [[Projector]] instance using the provided projectionOptions.
|
|
5
|
+
*
|
|
6
|
+
* For more information, see [[Projector]].
|
|
7
|
+
*
|
|
8
|
+
* @param projectorOptions Options that influence how the DOM is rendered and updated.
|
|
9
|
+
*/
|
|
10
|
+
export let createProjector = (
|
|
11
|
+
projectorOptions?: ProjectorOptions
|
|
12
|
+
): Projector => {
|
|
13
|
+
let projector: Projector;
|
|
14
|
+
let projectionOptions = applyDefaultProjectionOptions(projectorOptions);
|
|
15
|
+
projectionOptions.eventHandlerInterceptor = function (
|
|
16
|
+
propertyName: string,
|
|
17
|
+
eventHandler: Function,
|
|
18
|
+
domNode: Node,
|
|
19
|
+
properties: VNodeProperties
|
|
20
|
+
) {
|
|
21
|
+
return function (this: Node) {
|
|
22
|
+
// intercept function calls (event handlers) to do a render afterwards.
|
|
23
|
+
projector.scheduleRender();
|
|
24
|
+
return eventHandler.apply(properties.bind || this, arguments);
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
let renderCompleted = true;
|
|
28
|
+
let scheduled: number | undefined;
|
|
29
|
+
let stopped = false;
|
|
30
|
+
let projections = [] as Projection[];
|
|
31
|
+
let renderFunctions = [] as (() => VNode)[]; // matches the projections array
|
|
32
|
+
|
|
33
|
+
let doRender = function () {
|
|
34
|
+
scheduled = undefined;
|
|
35
|
+
if (!renderCompleted) {
|
|
36
|
+
return; // The last render threw an error, it should be logged in the browser console.
|
|
37
|
+
}
|
|
38
|
+
renderCompleted = false;
|
|
39
|
+
for (let i = 0; i < projections.length; i++) {
|
|
40
|
+
let updatedVnode = renderFunctions[i]();
|
|
41
|
+
projections[i].update(updatedVnode);
|
|
42
|
+
}
|
|
43
|
+
renderCompleted = true;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
projector = {
|
|
47
|
+
renderNow: doRender,
|
|
48
|
+
scheduleRender: () => {
|
|
49
|
+
if (!scheduled && !stopped) {
|
|
50
|
+
scheduled = requestAnimationFrame(doRender);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
stop: () => {
|
|
54
|
+
if (scheduled) {
|
|
55
|
+
cancelAnimationFrame(scheduled);
|
|
56
|
+
scheduled = undefined;
|
|
57
|
+
}
|
|
58
|
+
stopped = true;
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
resume: () => {
|
|
62
|
+
stopped = false;
|
|
63
|
+
renderCompleted = true;
|
|
64
|
+
projector.scheduleRender();
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
append: (parentNode, renderMaquetteFunction) => {
|
|
68
|
+
projections.push(
|
|
69
|
+
dom.append(parentNode, renderMaquetteFunction(), projectionOptions)
|
|
70
|
+
);
|
|
71
|
+
renderFunctions.push(renderMaquetteFunction);
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
insertBefore: (beforeNode, renderMaquetteFunction) => {
|
|
75
|
+
projections.push(
|
|
76
|
+
dom.insertBefore(
|
|
77
|
+
beforeNode,
|
|
78
|
+
renderMaquetteFunction(),
|
|
79
|
+
projectionOptions
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
renderFunctions.push(renderMaquetteFunction);
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
merge: (domNode, renderMaquetteFunction) => {
|
|
86
|
+
projections.push(
|
|
87
|
+
dom.merge(domNode, renderMaquetteFunction(), projectionOptions)
|
|
88
|
+
);
|
|
89
|
+
renderFunctions.push(renderMaquetteFunction);
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
replace: (domNode, renderMaquetteFunction) => {
|
|
93
|
+
projections.push(
|
|
94
|
+
dom.replace(domNode, renderMaquetteFunction(), projectionOptions)
|
|
95
|
+
);
|
|
96
|
+
renderFunctions.push(renderMaquetteFunction);
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
detach: (renderMaquetteFunction) => {
|
|
100
|
+
for (let i = 0; i < renderFunctions.length; i++) {
|
|
101
|
+
if (renderFunctions[i] === renderMaquetteFunction) {
|
|
102
|
+
renderFunctions.splice(i, 1);
|
|
103
|
+
return projections.splice(i, 1)[0];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
throw new Error("renderMaquetteFunction was not found");
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
return projector;
|
|
110
|
+
};
|
package/src/sample.tsx
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
PropertyRenderOnSet,
|
|
3
|
+
CustomElement,
|
|
4
|
+
CustomElementConfig,
|
|
5
|
+
Bind,
|
|
6
|
+
} from "./custom-element";
|
|
2
7
|
import * as anime from "animejs";
|
|
3
8
|
|
|
4
|
-
|
|
5
9
|
@CustomElementConfig({
|
|
6
10
|
tagName: "my-greetings",
|
|
7
11
|
})
|
|
8
12
|
class MyGreetings extends CustomElement {
|
|
9
|
-
|
|
10
13
|
private count: number = 1;
|
|
11
14
|
|
|
12
15
|
@PropertyRenderOnSet
|
|
@@ -15,20 +18,20 @@ class MyGreetings extends CustomElement {
|
|
|
15
18
|
@PropertyRenderOnSet
|
|
16
19
|
public foo: string = "foo";
|
|
17
20
|
|
|
18
|
-
private onInput = (e)
|
|
21
|
+
private onInput = (e) => {
|
|
19
22
|
this.name = e.target.value;
|
|
20
|
-
}
|
|
23
|
+
};
|
|
21
24
|
|
|
22
25
|
private enterAnimation(domNode, properties) {
|
|
23
26
|
anime({
|
|
24
27
|
targets: domNode,
|
|
25
28
|
translateX: [
|
|
26
29
|
{ value: 100, duration: 1200 },
|
|
27
|
-
{ value: 0, duration: 800 }
|
|
30
|
+
{ value: 0, duration: 800 },
|
|
28
31
|
],
|
|
29
|
-
rotate:
|
|
32
|
+
rotate: "2turn",
|
|
30
33
|
duration: 3000,
|
|
31
|
-
loop: false
|
|
34
|
+
loop: false,
|
|
32
35
|
});
|
|
33
36
|
}
|
|
34
37
|
|
|
@@ -37,56 +40,96 @@ class MyGreetings extends CustomElement {
|
|
|
37
40
|
targets: domNode,
|
|
38
41
|
translateX: [
|
|
39
42
|
{ value: 100, duration: 1200 },
|
|
40
|
-
{ value: 0, duration: 800 }
|
|
43
|
+
{ value: 0, duration: 800 },
|
|
41
44
|
],
|
|
42
45
|
duration: 3000,
|
|
43
46
|
opacity: 0,
|
|
44
47
|
loop: false,
|
|
45
48
|
complete: () => {
|
|
46
49
|
removeDomNodeFunction(domNode);
|
|
47
|
-
}
|
|
50
|
+
},
|
|
48
51
|
});
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
private countUpdateAnimation(domNode, properties, previousProperties) {
|
|
52
55
|
const basicTimeline = anime.timeline();
|
|
53
|
-
basicTimeline.add([
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
basicTimeline.add([
|
|
57
|
+
{
|
|
58
|
+
duration: 300,
|
|
59
|
+
targets: domNode,
|
|
60
|
+
translateX: 200,
|
|
61
|
+
scale: 1.9,
|
|
62
|
+
easing: "easeOutExpo",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
duration: 300,
|
|
66
|
+
targets: domNode,
|
|
67
|
+
translateX: 0,
|
|
68
|
+
scale: 1,
|
|
69
|
+
easing: "easeInExpo",
|
|
70
|
+
},
|
|
71
|
+
]);
|
|
66
72
|
}
|
|
67
73
|
|
|
74
|
+
private onPeterClick = (e) => {
|
|
75
|
+
console.log({ e, p: this });
|
|
76
|
+
};
|
|
77
|
+
|
|
68
78
|
private render = () => {
|
|
69
|
-
return
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
return (
|
|
80
|
+
<div>
|
|
81
|
+
<h1 eventListeners={[["click", (e) => console.log(e)]]} id="Foo">
|
|
82
|
+
Hallo
|
|
83
|
+
</h1>
|
|
84
|
+
|
|
85
|
+
<h1
|
|
86
|
+
data-title={this.name && this.name.toLocaleUpperCase()}
|
|
87
|
+
class="title"
|
|
88
|
+
>
|
|
89
|
+
{this.foo} {this.name}
|
|
90
|
+
</h1>
|
|
91
|
+
<p data-count={this.count} updateAnimation={this.countUpdateAnimation}>
|
|
92
|
+
{this.count}
|
|
93
|
+
</p>
|
|
94
|
+
<div id="SlotContainer">
|
|
95
|
+
<slot></slot>
|
|
96
|
+
</div>
|
|
97
|
+
<p>
|
|
98
|
+
Please enter your name (hint type{" "}
|
|
99
|
+
<em>
|
|
100
|
+
<strong>Peter</strong>
|
|
101
|
+
</em>
|
|
102
|
+
)<br />
|
|
103
|
+
<input type="text" value={this.name} oninput={this.onInput} />
|
|
104
|
+
</p>
|
|
105
|
+
<p>
|
|
106
|
+
<a is="super-a">Super a</a>
|
|
107
|
+
</p>
|
|
108
|
+
{this.name &&
|
|
109
|
+
this.name.toLowerCase &&
|
|
110
|
+
this.name.toLowerCase().indexOf("peter") > -1 ? (
|
|
111
|
+
<div
|
|
112
|
+
key="peter"
|
|
113
|
+
afterRemoved={this.peterRemoved}
|
|
114
|
+
afterCreate={this.peterCreate}
|
|
81
115
|
class="is-peter"
|
|
116
|
+
eventListeners={[["click", this.onPeterClick]]}
|
|
82
117
|
enterAnimation={this.enterAnimation}
|
|
83
|
-
exitAnimation={this.exitAnimation}
|
|
118
|
+
exitAnimation={this.exitAnimation}
|
|
119
|
+
>
|
|
84
120
|
<p>Hello Peter</p>
|
|
85
|
-
<img
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
121
|
+
<img
|
|
122
|
+
class="is-peter--image"
|
|
123
|
+
src="https://s-media-cache-ak0.pinimg.com/474x/ce/1d/07/ce1d07011c0afb8e0614a0ae42a8c861.jpg"
|
|
124
|
+
height="140"
|
|
125
|
+
/>
|
|
126
|
+
</div>
|
|
127
|
+
) : (
|
|
128
|
+
""
|
|
129
|
+
)}
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
};
|
|
90
133
|
|
|
91
134
|
private peterRemoved() {
|
|
92
135
|
console.log("removed");
|
|
@@ -97,10 +140,31 @@ class MyGreetings extends CustomElement {
|
|
|
97
140
|
}
|
|
98
141
|
|
|
99
142
|
connectedCallback() {
|
|
100
|
-
|
|
101
|
-
let css = require("./sample.css");
|
|
102
143
|
let template = this.templateFromString(`
|
|
103
|
-
<style
|
|
144
|
+
<style>
|
|
145
|
+
|
|
146
|
+
:host{
|
|
147
|
+
/* display: none; */
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.root {
|
|
151
|
+
display: flex;
|
|
152
|
+
padding: 10px;
|
|
153
|
+
flex-direction: row;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
#Foo {
|
|
157
|
+
@apply --mixin-sample;
|
|
158
|
+
text-decoration: underline;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
#SlotContainer ::slotted(*) {
|
|
162
|
+
font-weight: bold;
|
|
163
|
+
color: green;
|
|
164
|
+
font-size: 1.5em;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
</style>
|
|
104
168
|
<div class="root"></div>
|
|
105
169
|
`);
|
|
106
170
|
|
|
@@ -114,12 +178,11 @@ class MyGreetings extends CustomElement {
|
|
|
114
178
|
}, 5000);
|
|
115
179
|
|
|
116
180
|
window.addEventListener("foo", this.onFooEvent);
|
|
117
|
-
|
|
118
181
|
}
|
|
119
182
|
|
|
120
183
|
private onFooEvent = (e: CustomEvent) => {
|
|
121
184
|
this.foo = e.detail.foo;
|
|
122
|
-
}
|
|
185
|
+
};
|
|
123
186
|
|
|
124
187
|
static get observedAttributes() {
|
|
125
188
|
return ["name"];
|
|
@@ -137,8 +200,9 @@ class MyGreetings extends CustomElement {
|
|
|
137
200
|
})
|
|
138
201
|
class PFoo extends CustomElement {
|
|
139
202
|
private connectedCallback() {
|
|
140
|
-
|
|
141
|
-
|
|
203
|
+
const template = this.templateFromString(
|
|
204
|
+
`<style>:host{color: red}</style><div class="root"></div>`
|
|
205
|
+
);
|
|
142
206
|
this.shadowRoot.appendChild(template);
|
|
143
207
|
|
|
144
208
|
this.shadowRoot.querySelector(".root").innerHTML = `
|
|
@@ -148,12 +212,10 @@ class PFoo extends CustomElement {
|
|
|
148
212
|
}
|
|
149
213
|
|
|
150
214
|
class SuperAnchorElement extends HTMLAnchorElement {
|
|
151
|
-
|
|
152
215
|
public connectedCallback() {
|
|
153
216
|
this.classList.add("super");
|
|
154
217
|
this.style.color = "red";
|
|
155
218
|
}
|
|
156
|
-
|
|
157
219
|
}
|
|
158
220
|
|
|
159
221
|
window.customElements.define("super-a", SuperAnchorElement, { extends: "a" });
|
package/tsconfig.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
16
16
|
// "composite": true, /* Enable project compilation */
|
|
17
17
|
// "removeComments": true, /* Do not emit comments to output. */
|
|
18
|
-
"noEmit": true, /* Do not emit outputs. */
|
|
18
|
+
// "noEmit": true, /* Do not emit outputs. */
|
|
19
19
|
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
20
20
|
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
21
21
|
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
package/webpack.config.js
CHANGED
|
@@ -1,167 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const path = require("path");
|
|
3
2
|
const webpack = require('webpack');
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}]
|
|
3
|
+
const TerserPlugin = require("terser-webpack-plugin")
|
|
4
|
+
const package = require('./package.json');
|
|
5
|
+
const banner = `P-ELEMENTS ${package.version} - ${new Date()}`;
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
optimization: {
|
|
9
|
+
minimize: true,
|
|
10
|
+
minimizer: [
|
|
11
|
+
new TerserPlugin({
|
|
12
|
+
terserOptions: {
|
|
13
|
+
format: {
|
|
14
|
+
comments: /^\**!/i,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
extractComments: false,
|
|
18
|
+
}),
|
|
21
19
|
],
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
'underscore',
|
|
43
|
-
'./index.tsx',
|
|
44
|
-
];
|
|
45
|
-
filename = 'p-elements-core-modern.js';
|
|
46
|
-
} else {
|
|
47
|
-
entries = [
|
|
48
|
-
'element-closest',
|
|
49
|
-
'@webcomponents/template/template.js',
|
|
50
|
-
'@babel/polyfill',
|
|
51
|
-
'whatwg-fetch',
|
|
52
|
-
'./custom-event-polyfill.js',
|
|
53
|
-
'@webcomponents/shadydom/shadydom.min.js',
|
|
54
|
-
'@webcomponents/shadycss/scoping-shim.min.js',
|
|
55
|
-
'@webcomponents/shadycss/apply-shim.min.js',
|
|
56
|
-
'@webcomponents/shadycss/custom-style-interface.min.js',
|
|
57
|
-
'document-register-element/build/document-register-element.js',
|
|
58
|
-
'underscore',
|
|
59
|
-
'./index.tsx']
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// entries = [
|
|
63
|
-
// '@webcomponents/shadydom/shadydom.min.js',
|
|
64
|
-
// '@webcomponents/shadycss/scoping-shim.min.js',
|
|
65
|
-
// '@webcomponents/shadycss/apply-shim.min.js',
|
|
66
|
-
// '@webcomponents/shadycss/custom-style-interface.min.js',
|
|
67
|
-
// 'document-register-element/build/document-register-element.js',
|
|
68
|
-
// 'underscore',
|
|
69
|
-
// './index.tsx',
|
|
70
|
-
// ];
|
|
71
|
-
// filename = 'p-elements-core-modern.js';
|
|
72
|
-
|
|
73
|
-
let plugins = [
|
|
74
|
-
new webpack.ProvidePlugin({
|
|
75
|
-
global: require.resolve('./global.js')
|
|
76
|
-
}),
|
|
77
|
-
new webpack.optimize.CommonsChunkPlugin({
|
|
78
|
-
name: 'p-elements-core',
|
|
79
|
-
minChunks: Infinity,
|
|
80
|
-
filename: filename
|
|
81
|
-
}),
|
|
82
|
-
new webpack.NamedModulesPlugin(),
|
|
83
|
-
];
|
|
84
|
-
|
|
85
|
-
if (env && !env.dev) {
|
|
86
|
-
plugins.push(new UglifyJSPlugin());
|
|
87
|
-
plugins.push(new WebpackAutoInject({
|
|
88
|
-
// specify the name of the tag in the outputed files eg
|
|
89
|
-
// bundle.js: [SHORT] Version: 0.13.36 ...
|
|
90
|
-
SHORT: 'P-ELEMENTS',
|
|
91
|
-
SILENT: false,
|
|
92
|
-
PACKAGE_JSON_PATH: './package.json',
|
|
93
|
-
components: {
|
|
94
|
-
AutoIncreaseVersion: true,
|
|
95
|
-
InjectAsComment: true,
|
|
96
|
-
InjectByTag: true
|
|
20
|
+
},
|
|
21
|
+
plugins: [
|
|
22
|
+
new webpack.BannerPlugin({banner}),
|
|
23
|
+
],
|
|
24
|
+
entry: {
|
|
25
|
+
"dist/p-elements-core-modern": [
|
|
26
|
+
"@webcomponents/shadycss/apply-shim.min.js",
|
|
27
|
+
"@webcomponents/shadycss/custom-style-interface.min.js",
|
|
28
|
+
"document-register-element/build/document-register-element.js",
|
|
29
|
+
"underscore",
|
|
30
|
+
"./src/index.ts",
|
|
31
|
+
],
|
|
32
|
+
"demo/sample": ["./src/sample.tsx"],
|
|
33
|
+
},
|
|
34
|
+
module: {
|
|
35
|
+
rules: [
|
|
36
|
+
{
|
|
37
|
+
test: /\.tsx?$/,
|
|
38
|
+
use: ["babel-loader", "ts-loader"],
|
|
39
|
+
exclude: /node_modules/,
|
|
97
40
|
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
'p-elements-core': entries,
|
|
112
|
-
'sample': [
|
|
113
|
-
'./sample.tsx'
|
|
114
|
-
]
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
node: {
|
|
119
|
-
global: false
|
|
120
|
-
},
|
|
121
|
-
cache: true,
|
|
122
|
-
context: path.resolve(__dirname, './src'),
|
|
123
|
-
entry,
|
|
124
|
-
devtool: 'source-map',
|
|
125
|
-
output: {
|
|
126
|
-
path: path.resolve(__dirname, './dist'),
|
|
127
|
-
filename: '[name]' + '.js',
|
|
128
|
-
chunkFilename: '[chunkhash]' + '.js'
|
|
129
|
-
},
|
|
130
|
-
module: {
|
|
131
|
-
rules: [
|
|
132
|
-
{
|
|
133
|
-
test: /\.ts(x?)$/,
|
|
134
|
-
exclude: /node_modules/,
|
|
135
|
-
use: [
|
|
136
|
-
{
|
|
137
|
-
loader: 'babel-loader',
|
|
138
|
-
options: babelOptions
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
loader: 'awesome-typescript-loader'
|
|
142
|
-
}
|
|
143
|
-
]
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
test: /\.css$/,
|
|
147
|
-
use: [
|
|
148
|
-
{ loader: 'to-string-loader' },
|
|
149
|
-
{ loader: 'css-loader' },
|
|
150
|
-
{
|
|
151
|
-
loader: 'postcss-loader',
|
|
152
|
-
options: {
|
|
153
|
-
plugins: function () {
|
|
154
|
-
return [require('autoprefixer'), require('cssnano')]
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
]
|
|
159
|
-
}
|
|
160
|
-
]
|
|
161
|
-
},
|
|
162
|
-
plugins: plugins,
|
|
163
|
-
resolve: {
|
|
164
|
-
extensions: ['.ts', '.tsx', '.js'],
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
resolve: {
|
|
44
|
+
extensions: [".tsx", ".ts", ".js"],
|
|
45
|
+
},
|
|
46
|
+
output: {
|
|
47
|
+
path: path.resolve(__dirname),
|
|
48
|
+
filename: "[name]" + ".js",
|
|
49
|
+
chunkFilename: "[chunkhash]" + ".js",
|
|
50
|
+
},
|
|
51
|
+
devServer: {
|
|
52
|
+
static: {
|
|
53
|
+
directory: __dirname,
|
|
165
54
|
},
|
|
166
|
-
|
|
55
|
+
port: 5001,
|
|
56
|
+
},
|
|
167
57
|
};
|
package/dist/sample.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// [P-ELEMENTS] p-elements-core@1.2.0-rc6 - December 23rd, 2021, 7:49
|
|
2
|
-
webpackJsonp([0],{"../node_modules/css-loader/index.js!../node_modules/postcss-loader/index.js?{}!./sample.css":function(e,t,n){(e.exports=n("../node_modules/css-loader/lib/css-base.js")(!1)).push([e.i,".root{display:-ms-flexbox;display:flex;padding:10px;-ms-flex-direction:row;flex-direction:row}#Foo{@apply --mixin-sample;text-decoration:underline}#SlotContainer ::slotted(*){font-weight:700;color:green;font-size:1.5em}",""])},"../node_modules/css-loader/lib/css-base.js":function(e,t){e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n=function(e,t){var n=e[1]||"",o=e[3];if(!o)return n;if(t&&"function"==typeof btoa){var r=function(e){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e))))+" */"}(o),i=o.sources.map(function(e){return"/*# sourceURL="+o.sourceRoot+e+" */"});return[n].concat(i).concat([r]).join("\n")}return[n].join("\n")}(t,e);return t[2]?"@media "+t[2]+"{"+n+"}":n}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var o={},r=0;r<this.length;r++){var i=this[r][0];"number"==typeof i&&(o[i]=!0)}for(r=0;r<e.length;r++){var a=e[r];"number"==typeof a[0]&&o[a[0]]||(n&&!a[2]?a[2]=n:n&&(a[2]="("+a[2]+") and ("+n+")"),t.push(a))}},t}},"./sample.css":function(e,t,n){var o=n("../node_modules/css-loader/index.js!../node_modules/postcss-loader/index.js?{}!./sample.css");e.exports="string"==typeof o?o:o.toString()},"./sample.tsx":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n("./utils/custom-element.ts"),r=n("../node_modules/animejs/anime.min.js");n.n(r);function i(e){var t="function"==typeof Map?new Map:void 0;return(i=function(e){if(null===e||!function(e){return-1!==Function.toString.call(e).indexOf("[native code]")}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return a(e,arguments,y(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),f(n,e)})(e)}function a(e,t,n){return(a=d()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);var r=new(Function.bind.apply(e,o));return n&&f(r,n.prototype),r}).apply(null,arguments)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function s(e,t,n){return t&&c(e.prototype,t),n&&c(e,n),e}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&f(e,t)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(e){var t=d();return function(){var n,o=y(e);if(t){var r=y(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===m(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function d(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e){"@babel/helpers - typeof";return(m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var v=this&&this.__decorate||function(e,t,n,o){var r,i=arguments.length,a=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"===("undefined"==typeof Reflect?"undefined":m(Reflect))&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,o);else for(var u=e.length-1;u>=0;u--)(r=e[u])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},b=function(e){l(i,o["a"]);var t=p(i);function i(){var e;return u(this,i),(e=t.apply(this,arguments)).count=1,e.name="",e.foo="foo",e.onInput=function(t){e.name=t.target.value},e.render=function(){return h("div",{key:"1"},h("h1",{id:"Foo",key:"2"},"Hallo"),h("h1",{"data-title":e.name&&e.name.toLocaleUpperCase(),class:"title",key:"3"},e.foo," ",e.name),h("p",{"data-count":e.count,updateAnimation:e.countUpdateAnimation,key:"4"},e.count),h("div",{id:"SlotContainer",key:"5"},h("slot",{key:"6"})),h("p",{key:"7"},"Please enter your name (hint type ",h("em",{key:"8"},h("strong",{key:"9"},"Peter")),")",h("br",{key:"10"}),h("input",{type:"text",value:e.name,oninput:e.onInput,key:"11"})),h("p",{key:"12"},h("a",{is:"super-a",key:"13"},"Super a")),e.name&&e.name.toLowerCase&&e.name.toLowerCase().indexOf("peter")>-1?h("div",{key:"peter",afterRemoved:e.peterRemoved,afterCreate:e.peterCreate,class:"is-peter",enterAnimation:e.enterAnimation,exitAnimation:e.exitAnimation},h("p",{key:"14"},"Hello Peter"),h("img",{class:"is-peter--image",src:"https://s-media-cache-ak0.pinimg.com/474x/ce/1d/07/ce1d07011c0afb8e0614a0ae42a8c861.jpg",height:"140",key:"15"})):"")},e.onFooEvent=function(t){e.foo=t.detail.foo},e}return s(i,[{key:"enterAnimation",value:function(e,t){r({targets:e,translateX:[{value:100,duration:1200},{value:0,duration:800}],rotate:"1turn",duration:3e3,loop:!1})}},{key:"exitAnimation",value:function(e,t,n){r({targets:e,translateX:[{value:100,duration:1200},{value:0,duration:800}],duration:3e3,opacity:0,loop:!1,complete:function(){t(e)}})}},{key:"countUpdateAnimation",value:function(e,t,n){r.timeline().add([{duration:300,targets:e,translateX:200,scale:1.9,easing:"easeOutExpo"},{duration:300,targets:e,translateX:0,scale:1,easing:"easeInExpo"}])}},{key:"peterRemoved",value:function(){console.log("removed")}},{key:"peterCreate",value:function(){console.log("create")}},{key:"connectedCallback",value:function(){var e=this,t=n("./sample.css"),o=this.templateFromString("\n <style>".concat(t,'</style>\n <div class="root"></div>\n '));this.shadowRoot.appendChild(o),this.createProjector(this.shadowRoot.querySelector(".root"),this.render),setInterval(function(){e.count++,e.renderNow()},5e3),window.addEventListener("foo",this.onFooEvent)}},{key:"attributeChangedCallback",value:function(e,t,n){"name"===e&&(this.name=n)}}],[{key:"observedAttributes",get:function(){return["name"]}}]),i}();v([o.b],b.prototype,"name",void 0),v([o.b],b.prototype,"foo",void 0),b=v([n.i(o.c)({tagName:"my-greetings"})],b);var g=function(e){l(r,o["a"]);var t=p(r);function r(){return u(this,r),t.apply(this,arguments)}return s(r,[{key:"connectedCallback",value:function(){n("./sample.css");var e=this.templateFromString('<style>:host{color: red}</style><div class="root"></div>');this.shadowRoot.appendChild(e),this.shadowRoot.querySelector(".root").innerHTML="\n <div>P-FOO</div>\n "}}]),r}();g=v([n.i(o.c)({tagName:"p-foo"})],g);var k=function(e){l(n,i(HTMLAnchorElement));var t=p(n);function n(){return u(this,n),t.apply(this,arguments)}return s(n,[{key:"connectedCallback",value:function(){this.classList.add("super"),this.style.color="red"}}]),n}();window.customElements.define("super-a",k,{extends:"a"})},0:function(e,t,n){e.exports=n("./sample.tsx")}},[0]);
|
package/global.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = window
|
package/karma.conf.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module.exports = function (config) {
|
|
2
|
-
|
|
3
|
-
const webpackConfig = require('./webpack.config.karma.js');
|
|
4
|
-
config.set({
|
|
5
|
-
basePath: '',
|
|
6
|
-
frameworks: ['jasmine'],
|
|
7
|
-
files: [{
|
|
8
|
-
pattern: './dist/p-elements-core.js',
|
|
9
|
-
included: true,
|
|
10
|
-
watched: false,
|
|
11
|
-
served: true
|
|
12
|
-
},
|
|
13
|
-
'./dist/**/*.*',
|
|
14
|
-
'./**/*.spec.ts'
|
|
15
|
-
],
|
|
16
|
-
preprocessors: {
|
|
17
|
-
'src/**/*.spec.ts': ['webpack']
|
|
18
|
-
},
|
|
19
|
-
mime: {
|
|
20
|
-
'text/x-typescript': ['ts', 'tsx']
|
|
21
|
-
},
|
|
22
|
-
webpack: webpackConfig,
|
|
23
|
-
reporters: ['dots'],
|
|
24
|
-
port: 9876,
|
|
25
|
-
runnerPort: 9100,
|
|
26
|
-
colors: true,
|
|
27
|
-
logLevel: config.LOG_INFO,
|
|
28
|
-
autoWatch: true,
|
|
29
|
-
browsers: ['Chrome'],
|
|
30
|
-
singleRun: true
|
|
31
|
-
});
|
|
32
|
-
};
|