p-elements-core 1.2.32-rc8 → 1.2.32
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/.editorconfig +17 -17
- package/.gitlab-ci.yml +18 -18
- package/CHANGELOG.md +201 -201
- package/demo/sample.js +1 -1
- package/demo/screen.css +16 -16
- package/dist/p-elements-core-modern.js +1 -1
- package/dist/p-elements-core.js +1 -1
- package/docs/package-lock.json +6897 -6897
- package/docs/package.json +27 -27
- package/docs/src/404.md +8 -8
- package/docs/src/_data/demos/hello-world/hello-world.tsx +35 -35
- package/docs/src/_data/demos/hello-world/index.html +10 -10
- package/docs/src/_data/demos/hello-world/project.json +7 -7
- package/docs/src/_data/demos/timer/demo-timer.tsx +120 -120
- package/docs/src/_data/demos/timer/icons.tsx +62 -62
- package/docs/src/_data/demos/timer/index.html +12 -12
- package/docs/src/_data/demos/timer/project.json +8 -8
- package/docs/src/_data/global.js +13 -13
- package/docs/src/_data/helpers.js +19 -19
- package/docs/src/_includes/layouts/base.njk +30 -30
- package/docs/src/_includes/layouts/playground.njk +40 -40
- package/docs/src/_includes/partials/app-header.njk +8 -8
- package/docs/src/_includes/partials/head.njk +14 -14
- package/docs/src/_includes/partials/nav.njk +19 -19
- package/docs/src/_includes/partials/top-nav.njk +51 -51
- package/docs/src/documentation/custom-element.md +221 -221
- package/docs/src/documentation/decorators/bind.md +71 -71
- package/docs/src/documentation/decorators/custom-element-config.md +63 -63
- package/docs/src/documentation/decorators/property.md +83 -83
- package/docs/src/documentation/decorators/query.md +66 -66
- package/docs/src/documentation/decorators/render-property-on-set.md +60 -60
- package/docs/src/documentation/decorators.md +9 -9
- package/docs/src/documentation/reactive-properties.md +53 -53
- package/docs/src/index.d.ts +25 -25
- package/docs/src/index.md +3 -3
- package/docs/src/scripts/components/app-mode-switch/app-mode-switch.css +78 -78
- package/docs/src/scripts/components/app-mode-switch/app-mode-switch.tsx +166 -166
- package/docs/src/scripts/components/app-playground/app-playground.tsx +189 -189
- package/docs/tsconfig.json +22 -22
- package/index.html +10 -2
- package/package.json +1 -1
- package/readme.md +206 -206
- package/src/custom-element-controller.ts +31 -31
- package/src/custom-element.test.ts +906 -906
- package/src/custom-element.ts +3 -8
- package/src/decorators/bind.test.ts +163 -163
- package/src/decorators/bind.ts +46 -46
- package/src/decorators/custom-element-config.ts +17 -17
- package/src/decorators/property.test.ts +279 -279
- package/src/decorators/query.test.ts +146 -146
- package/src/decorators/query.ts +12 -12
- package/src/decorators/render-property-on-set.ts +3 -3
- package/src/helpers/css.ts +71 -71
- package/src/maquette/cache.ts +35 -35
- package/src/maquette/dom.ts +115 -115
- package/src/maquette/h.ts +100 -100
- package/src/maquette/index.ts +12 -12
- package/src/maquette/interfaces.ts +536 -536
- package/src/maquette/jsx.ts +61 -61
- package/src/maquette/mapping.ts +56 -56
- package/src/maquette/projection.ts +666 -666
- package/src/maquette/projector.ts +205 -205
- package/src/sample/mixin/highlight.tsx +33 -33
- package/src/sample/sample.tsx +98 -0
|
@@ -1,190 +1,190 @@
|
|
|
1
|
-
@CustomElementConfig({
|
|
2
|
-
tagName: "app-playground",
|
|
3
|
-
})
|
|
4
|
-
export class AppPlaygroundElement extends CustomElement {
|
|
5
|
-
|
|
6
|
-
static style = `
|
|
7
|
-
:host{
|
|
8
|
-
display: block;
|
|
9
|
-
height: 100%;
|
|
10
|
-
}
|
|
11
|
-
.app-playground{
|
|
12
|
-
height: 100%;
|
|
13
|
-
}
|
|
14
|
-
.app-playground-split-panel{
|
|
15
|
-
height: 100%;
|
|
16
|
-
}
|
|
17
|
-
playground-preview{
|
|
18
|
-
height: 100%;
|
|
19
|
-
position: unset;
|
|
20
|
-
}
|
|
21
|
-
.app-playground-editor-container{
|
|
22
|
-
height: 100%;
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-direction: column;
|
|
25
|
-
}
|
|
26
|
-
.app-playground-editor{
|
|
27
|
-
height: 100%;
|
|
28
|
-
flex: 1;
|
|
29
|
-
}
|
|
30
|
-
`;
|
|
31
|
-
|
|
32
|
-
constructor() {
|
|
33
|
-
super();
|
|
34
|
-
if (!this.id) {
|
|
35
|
-
this.id = "app-playground-" + Math.floor(Math.random() * 1000);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
#initDone = false;
|
|
40
|
-
|
|
41
|
-
static readonly projectorMode = "replace";
|
|
42
|
-
|
|
43
|
-
#_playgroundLoaded = false;
|
|
44
|
-
|
|
45
|
-
get #playgroundLoaded() {
|
|
46
|
-
return this.#_playgroundLoaded;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
set #playgroundLoaded(value: boolean) {
|
|
50
|
-
this.#_playgroundLoaded = value;
|
|
51
|
-
this.scheduleRender();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@Property({ type: "string", attribute: "playground-src", reflect: true })
|
|
55
|
-
playgroundSrc: string = null;
|
|
56
|
-
|
|
57
|
-
@Property({ type: "string", attribute: "project-src", reflect: true })
|
|
58
|
-
projectSrc: string = null;
|
|
59
|
-
|
|
60
|
-
@Property({ type: "object" })
|
|
61
|
-
files: any = null;
|
|
62
|
-
|
|
63
|
-
@Property({ type: "string", attribute: "cdn-base-url", reflect: true })
|
|
64
|
-
cdnBaseUrl: string = null;
|
|
65
|
-
|
|
66
|
-
updated(propertyName: string, oldValue: any, newValue: any): void {
|
|
67
|
-
if (propertyName === "projectSrc" && newValue) {
|
|
68
|
-
this.#loadProject(newValue);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async #loadProject(projectSrc: string) {
|
|
73
|
-
const response = await fetch(projectSrc).catch((e) => e);
|
|
74
|
-
if (response instanceof Error || !response.ok) {
|
|
75
|
-
console.error("Failed to load project:", response);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const data = await response.json();
|
|
79
|
-
if (!data) {
|
|
80
|
-
console.error("Failed to load project: no data");
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const configuredFiles: string[] = [];
|
|
84
|
-
for (const key in data.files) {
|
|
85
|
-
configuredFiles.push(key);
|
|
86
|
-
}
|
|
87
|
-
const url = new URL(projectSrc, window.location.href);
|
|
88
|
-
const projectPath = url.pathname.substring(
|
|
89
|
-
0,
|
|
90
|
-
url.pathname.lastIndexOf("/") + 1
|
|
91
|
-
);
|
|
92
|
-
const fileResponses = await Promise.all(
|
|
93
|
-
configuredFiles.map((file: string) => {
|
|
94
|
-
const filePath = projectPath + file;
|
|
95
|
-
return fetch(filePath)
|
|
96
|
-
.then((response) =>
|
|
97
|
-
response.ok
|
|
98
|
-
? response.text()
|
|
99
|
-
: Promise.reject(Error(response.statusText))
|
|
100
|
-
)
|
|
101
|
-
.catch((e) => e);
|
|
102
|
-
})
|
|
103
|
-
);
|
|
104
|
-
const files: any = [];
|
|
105
|
-
fileResponses.forEach((fileResponse: string | Error, index) => {
|
|
106
|
-
if (!(fileResponse instanceof Error)) {
|
|
107
|
-
const file = configuredFiles[index];
|
|
108
|
-
files.push({
|
|
109
|
-
name: file,
|
|
110
|
-
content: fileResponse,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
this.files = files;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
#afterCreate = (e: HTMLDivElement) => {
|
|
118
|
-
const esm = this.playgroundSrc;
|
|
119
|
-
if (!esm) return;
|
|
120
|
-
import(esm)
|
|
121
|
-
.then(() => {
|
|
122
|
-
this.#playgroundLoaded = true;
|
|
123
|
-
})
|
|
124
|
-
.catch((error) => {
|
|
125
|
-
console.error("Failed to load module:", error);
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
#getType = (file: string) => {
|
|
130
|
-
if (file.endsWith(".html")) {
|
|
131
|
-
return "sample/html";
|
|
132
|
-
} else if (file.endsWith(".tsx") || file.endsWith(".ts")) {
|
|
133
|
-
return "sample/ts";
|
|
134
|
-
}
|
|
135
|
-
return "sample/unknown";
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
render = () => {
|
|
139
|
-
return (
|
|
140
|
-
<div afterCreate={this.#afterCreate} class="app-playground">
|
|
141
|
-
|
|
142
|
-
<app-split-panel class="app-playground-split-panel">
|
|
143
|
-
{this.#playgroundLoaded && (
|
|
144
|
-
[
|
|
145
|
-
<playground-project
|
|
146
|
-
class="app-playground-project"
|
|
147
|
-
cdn-base-url={
|
|
148
|
-
this.cdnBaseUrl ? this.cdnBaseUrl : "https://cdn.jsdelivr.net/npm"
|
|
149
|
-
}
|
|
150
|
-
id={"project" + this.id}
|
|
151
|
-
>
|
|
152
|
-
{this.files?.map((file: any) => {
|
|
153
|
-
return (
|
|
154
|
-
<script
|
|
155
|
-
key={file.name}
|
|
156
|
-
type={this.#getType(file.name)}
|
|
157
|
-
filename={file.name}
|
|
158
|
-
innerHTML={file.content}
|
|
159
|
-
></script>
|
|
160
|
-
);
|
|
161
|
-
})}
|
|
162
|
-
</playground-project>,<playground-preview
|
|
163
|
-
slot="primary"
|
|
164
|
-
class="app-playground-preview"
|
|
165
|
-
project={"project" + this.id}
|
|
166
|
-
></playground-preview>]
|
|
167
|
-
)}
|
|
168
|
-
<div slot="secondary" class="app-playground-editor-container">
|
|
169
|
-
{this.#playgroundLoaded && (
|
|
170
|
-
<playground-tab-bar
|
|
171
|
-
class="app-playground-tab-bar"
|
|
172
|
-
id={"tab-bar" + this.id}
|
|
173
|
-
project={"project" + this.id}
|
|
174
|
-
editor={"editor" + this.id}
|
|
175
|
-
></playground-tab-bar>
|
|
176
|
-
)}
|
|
177
|
-
{this.#playgroundLoaded && (
|
|
178
|
-
<playground-file-editor
|
|
179
|
-
class="app-playground-editor"
|
|
180
|
-
id={"editor" + this.id}
|
|
181
|
-
project={"project" + this.id}
|
|
182
|
-
></playground-file-editor>
|
|
183
|
-
)}
|
|
184
|
-
</div>
|
|
185
|
-
|
|
186
|
-
</app-split-panel>
|
|
187
|
-
</div>
|
|
188
|
-
);
|
|
189
|
-
};
|
|
1
|
+
@CustomElementConfig({
|
|
2
|
+
tagName: "app-playground",
|
|
3
|
+
})
|
|
4
|
+
export class AppPlaygroundElement extends CustomElement {
|
|
5
|
+
|
|
6
|
+
static style = `
|
|
7
|
+
:host{
|
|
8
|
+
display: block;
|
|
9
|
+
height: 100%;
|
|
10
|
+
}
|
|
11
|
+
.app-playground{
|
|
12
|
+
height: 100%;
|
|
13
|
+
}
|
|
14
|
+
.app-playground-split-panel{
|
|
15
|
+
height: 100%;
|
|
16
|
+
}
|
|
17
|
+
playground-preview{
|
|
18
|
+
height: 100%;
|
|
19
|
+
position: unset;
|
|
20
|
+
}
|
|
21
|
+
.app-playground-editor-container{
|
|
22
|
+
height: 100%;
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
}
|
|
26
|
+
.app-playground-editor{
|
|
27
|
+
height: 100%;
|
|
28
|
+
flex: 1;
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
constructor() {
|
|
33
|
+
super();
|
|
34
|
+
if (!this.id) {
|
|
35
|
+
this.id = "app-playground-" + Math.floor(Math.random() * 1000);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#initDone = false;
|
|
40
|
+
|
|
41
|
+
static readonly projectorMode = "replace";
|
|
42
|
+
|
|
43
|
+
#_playgroundLoaded = false;
|
|
44
|
+
|
|
45
|
+
get #playgroundLoaded() {
|
|
46
|
+
return this.#_playgroundLoaded;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
set #playgroundLoaded(value: boolean) {
|
|
50
|
+
this.#_playgroundLoaded = value;
|
|
51
|
+
this.scheduleRender();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Property({ type: "string", attribute: "playground-src", reflect: true })
|
|
55
|
+
playgroundSrc: string = null;
|
|
56
|
+
|
|
57
|
+
@Property({ type: "string", attribute: "project-src", reflect: true })
|
|
58
|
+
projectSrc: string = null;
|
|
59
|
+
|
|
60
|
+
@Property({ type: "object" })
|
|
61
|
+
files: any = null;
|
|
62
|
+
|
|
63
|
+
@Property({ type: "string", attribute: "cdn-base-url", reflect: true })
|
|
64
|
+
cdnBaseUrl: string = null;
|
|
65
|
+
|
|
66
|
+
updated(propertyName: string, oldValue: any, newValue: any): void {
|
|
67
|
+
if (propertyName === "projectSrc" && newValue) {
|
|
68
|
+
this.#loadProject(newValue);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async #loadProject(projectSrc: string) {
|
|
73
|
+
const response = await fetch(projectSrc).catch((e) => e);
|
|
74
|
+
if (response instanceof Error || !response.ok) {
|
|
75
|
+
console.error("Failed to load project:", response);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const data = await response.json();
|
|
79
|
+
if (!data) {
|
|
80
|
+
console.error("Failed to load project: no data");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const configuredFiles: string[] = [];
|
|
84
|
+
for (const key in data.files) {
|
|
85
|
+
configuredFiles.push(key);
|
|
86
|
+
}
|
|
87
|
+
const url = new URL(projectSrc, window.location.href);
|
|
88
|
+
const projectPath = url.pathname.substring(
|
|
89
|
+
0,
|
|
90
|
+
url.pathname.lastIndexOf("/") + 1
|
|
91
|
+
);
|
|
92
|
+
const fileResponses = await Promise.all(
|
|
93
|
+
configuredFiles.map((file: string) => {
|
|
94
|
+
const filePath = projectPath + file;
|
|
95
|
+
return fetch(filePath)
|
|
96
|
+
.then((response) =>
|
|
97
|
+
response.ok
|
|
98
|
+
? response.text()
|
|
99
|
+
: Promise.reject(Error(response.statusText))
|
|
100
|
+
)
|
|
101
|
+
.catch((e) => e);
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
const files: any = [];
|
|
105
|
+
fileResponses.forEach((fileResponse: string | Error, index) => {
|
|
106
|
+
if (!(fileResponse instanceof Error)) {
|
|
107
|
+
const file = configuredFiles[index];
|
|
108
|
+
files.push({
|
|
109
|
+
name: file,
|
|
110
|
+
content: fileResponse,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
this.files = files;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
#afterCreate = (e: HTMLDivElement) => {
|
|
118
|
+
const esm = this.playgroundSrc;
|
|
119
|
+
if (!esm) return;
|
|
120
|
+
import(esm)
|
|
121
|
+
.then(() => {
|
|
122
|
+
this.#playgroundLoaded = true;
|
|
123
|
+
})
|
|
124
|
+
.catch((error) => {
|
|
125
|
+
console.error("Failed to load module:", error);
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
#getType = (file: string) => {
|
|
130
|
+
if (file.endsWith(".html")) {
|
|
131
|
+
return "sample/html";
|
|
132
|
+
} else if (file.endsWith(".tsx") || file.endsWith(".ts")) {
|
|
133
|
+
return "sample/ts";
|
|
134
|
+
}
|
|
135
|
+
return "sample/unknown";
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
render = () => {
|
|
139
|
+
return (
|
|
140
|
+
<div afterCreate={this.#afterCreate} class="app-playground">
|
|
141
|
+
|
|
142
|
+
<app-split-panel class="app-playground-split-panel">
|
|
143
|
+
{this.#playgroundLoaded && (
|
|
144
|
+
[
|
|
145
|
+
<playground-project
|
|
146
|
+
class="app-playground-project"
|
|
147
|
+
cdn-base-url={
|
|
148
|
+
this.cdnBaseUrl ? this.cdnBaseUrl : "https://cdn.jsdelivr.net/npm"
|
|
149
|
+
}
|
|
150
|
+
id={"project" + this.id}
|
|
151
|
+
>
|
|
152
|
+
{this.files?.map((file: any) => {
|
|
153
|
+
return (
|
|
154
|
+
<script
|
|
155
|
+
key={file.name}
|
|
156
|
+
type={this.#getType(file.name)}
|
|
157
|
+
filename={file.name}
|
|
158
|
+
innerHTML={file.content}
|
|
159
|
+
></script>
|
|
160
|
+
);
|
|
161
|
+
})}
|
|
162
|
+
</playground-project>,<playground-preview
|
|
163
|
+
slot="primary"
|
|
164
|
+
class="app-playground-preview"
|
|
165
|
+
project={"project" + this.id}
|
|
166
|
+
></playground-preview>]
|
|
167
|
+
)}
|
|
168
|
+
<div slot="secondary" class="app-playground-editor-container">
|
|
169
|
+
{this.#playgroundLoaded && (
|
|
170
|
+
<playground-tab-bar
|
|
171
|
+
class="app-playground-tab-bar"
|
|
172
|
+
id={"tab-bar" + this.id}
|
|
173
|
+
project={"project" + this.id}
|
|
174
|
+
editor={"editor" + this.id}
|
|
175
|
+
></playground-tab-bar>
|
|
176
|
+
)}
|
|
177
|
+
{this.#playgroundLoaded && (
|
|
178
|
+
<playground-file-editor
|
|
179
|
+
class="app-playground-editor"
|
|
180
|
+
id={"editor" + this.id}
|
|
181
|
+
project={"project" + this.id}
|
|
182
|
+
></playground-file-editor>
|
|
183
|
+
)}
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
</app-split-panel>
|
|
187
|
+
</div>
|
|
188
|
+
);
|
|
189
|
+
};
|
|
190
190
|
}
|
package/docs/tsconfig.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"experimentalDecorators": true,
|
|
4
|
-
"target": "ES6",
|
|
5
|
-
"useDefineForClassFields": false,
|
|
6
|
-
"module": "ES2020",
|
|
7
|
-
"lib": ["ES2020", "DOM", "dom.iterable"],
|
|
8
|
-
"jsx": "react",
|
|
9
|
-
"jsxFactory": "Maquette.h",
|
|
10
|
-
"moduleResolution": "Node",
|
|
11
|
-
"strict": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"isolatedModules": true,
|
|
14
|
-
"esModuleInterop": true,
|
|
15
|
-
"noUnusedLocals": false,
|
|
16
|
-
"noUnusedParameters": false,
|
|
17
|
-
"noImplicitReturns": true,
|
|
18
|
-
"skipLibCheck": true,
|
|
19
|
-
"strictNullChecks": false
|
|
20
|
-
},
|
|
21
|
-
"include": ["src"]
|
|
22
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"experimentalDecorators": true,
|
|
4
|
+
"target": "ES6",
|
|
5
|
+
"useDefineForClassFields": false,
|
|
6
|
+
"module": "ES2020",
|
|
7
|
+
"lib": ["ES2020", "DOM", "dom.iterable"],
|
|
8
|
+
"jsx": "react",
|
|
9
|
+
"jsxFactory": "Maquette.h",
|
|
10
|
+
"moduleResolution": "Node",
|
|
11
|
+
"strict": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"noUnusedLocals": false,
|
|
16
|
+
"noUnusedParameters": false,
|
|
17
|
+
"noImplicitReturns": true,
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"strictNullChecks": false
|
|
20
|
+
},
|
|
21
|
+
"include": ["src"]
|
|
22
|
+
}
|
package/index.html
CHANGED
|
@@ -10,12 +10,20 @@
|
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
12
12
|
|
|
13
|
+
<bring-your-own-projector></bring-your-own-projector>
|
|
14
|
+
|
|
15
|
+
<hr />
|
|
16
|
+
|
|
17
|
+
<bring-your-own-projector-in-shadow-root></bring-your-own-projector-in-shadow-root>
|
|
18
|
+
|
|
19
|
+
<hr />
|
|
20
|
+
|
|
13
21
|
<render-on-set></render-on-set>
|
|
14
22
|
|
|
15
23
|
<hr />
|
|
16
|
-
|
|
24
|
+
|
|
17
25
|
<p-bugs-03></p-bugs-03>
|
|
18
|
-
|
|
26
|
+
|
|
19
27
|
<hr />
|
|
20
28
|
|
|
21
29
|
<p-foo id="X1" name="Fred" age="64"></p-foo>
|