p-elements-core 2.1.0-rc8 → 2.1.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/dist/p-elements-core.js +1 -1
- package/package.json +15 -5
- package/readme.md +13 -13
- package/typings/custom-element-controller.d.ts +18 -0
- package/typings/custom-element-controller.d.ts.map +1 -0
- package/typings/custom-element.d.ts +140 -0
- package/typings/custom-element.d.ts.map +1 -0
- package/typings/decorators/bind.d.ts +6 -0
- package/typings/decorators/bind.d.ts.map +1 -0
- package/typings/decorators/custom-element-config.d.ts +8 -0
- package/typings/decorators/custom-element-config.d.ts.map +1 -0
- package/typings/decorators/property.d.ts +213 -0
- package/typings/decorators/property.d.ts.map +1 -0
- package/typings/decorators/query.d.ts +2 -0
- package/typings/decorators/query.d.ts.map +1 -0
- package/typings/decorators/render-property-on-set.d.ts +2 -0
- package/typings/decorators/render-property-on-set.d.ts.map +1 -0
- package/typings/maquette/cache.d.ts +10 -0
- package/typings/maquette/cache.d.ts.map +1 -0
- package/typings/maquette/dom.d.ts +60 -0
- package/typings/maquette/dom.d.ts.map +1 -0
- package/typings/maquette/h.d.ts +35 -0
- package/typings/maquette/h.d.ts.map +1 -0
- package/{src/maquette/index.ts → typings/maquette/index.d.ts} +1 -1
- package/typings/maquette/index.d.ts.map +1 -0
- package/typings/maquette/interfaces.d.ts +475 -0
- package/typings/maquette/interfaces.d.ts.map +1 -0
- package/typings/maquette/jsx.d.ts +6 -0
- package/typings/maquette/jsx.d.ts.map +1 -0
- package/typings/maquette/mapping.d.ts +14 -0
- package/typings/maquette/mapping.d.ts.map +1 -0
- package/typings/maquette/projection.d.ts +9 -0
- package/typings/maquette/projection.d.ts.map +1 -0
- package/typings/maquette/projector.d.ts +27 -0
- package/typings/maquette/projector.d.ts.map +1 -0
- package/typings/p-elements-core.d.ts +239 -0
- package/typings/p-elements-core.d.ts.map +1 -0
- package/.babelrc +0 -21
- package/.editorconfig +0 -17
- package/.gitlab-ci.yml +0 -18
- package/demo/sample.js +0 -1
- package/demo/screen.css +0 -6
- package/demo/theme.css +0 -14
- package/docs/.eleventy.js +0 -109
- package/docs/package.json +0 -27
- package/docs/src/404.md +0 -8
- package/docs/src/_data/demos/animation/animation.tsx +0 -216
- package/docs/src/_data/demos/animation/index.html +0 -10
- package/docs/src/_data/demos/animation/project.json +0 -7
- package/docs/src/_data/demos/hello-world/hello-world.tsx +0 -35
- package/docs/src/_data/demos/hello-world/index.html +0 -10
- package/docs/src/_data/demos/hello-world/project.json +0 -7
- package/docs/src/_data/demos/timer/demo-timer.tsx +0 -120
- package/docs/src/_data/demos/timer/icons.tsx +0 -62
- package/docs/src/_data/demos/timer/index.html +0 -12
- package/docs/src/_data/demos/timer/project.json +0 -8
- package/docs/src/_data/global.js +0 -14
- package/docs/src/_data/helpers.js +0 -19
- package/docs/src/_includes/layouts/base.njk +0 -31
- package/docs/src/_includes/layouts/playground.njk +0 -40
- package/docs/src/_includes/partials/app-header.njk +0 -9
- package/docs/src/_includes/partials/head.njk +0 -15
- package/docs/src/_includes/partials/nav.njk +0 -20
- package/docs/src/_includes/partials/top-nav.njk +0 -52
- package/docs/src/assets/favicon.png +0 -0
- package/docs/src/assets/logo.svg +0 -9
- package/docs/src/documentation/custom-element-controller.md +0 -294
- package/docs/src/documentation/custom-element.md +0 -221
- package/docs/src/documentation/decorators/bind.md +0 -71
- package/docs/src/documentation/decorators/custom-element-config.md +0 -63
- package/docs/src/documentation/decorators/property.md +0 -83
- package/docs/src/documentation/decorators/query.md +0 -66
- package/docs/src/documentation/decorators/render-property-on-set.md +0 -60
- package/docs/src/documentation/decorators.md +0 -9
- package/docs/src/documentation/getting-started.md +0 -60
- package/docs/src/documentation/index.md +0 -33
- package/docs/src/documentation/reactive-properties.md +0 -54
- package/docs/src/index.d.ts +0 -25
- package/docs/src/index.md +0 -3
- package/docs/src/playground/animation.njk +0 -10
- package/docs/src/playground/index.njk +0 -10
- package/docs/src/playground/timer.njk +0 -10
- package/docs/src/scripts/components/app-drawer/app-drawer.css +0 -92
- package/docs/src/scripts/components/app-drawer/app-drawer.tsx +0 -67
- package/docs/src/scripts/components/app-mobile-menu/app-mobile-menu.css +0 -48
- package/docs/src/scripts/components/app-mobile-menu/app-mobile-menu.tsx +0 -112
- package/docs/src/scripts/components/app-mode-switch/app-mode-switch.css +0 -78
- package/docs/src/scripts/components/app-mode-switch/app-mode-switch.tsx +0 -166
- package/docs/src/scripts/components/app-playground/app-playground.tsx +0 -190
- package/docs/src/scripts/components/app-split-panel/app-split-panel.css +0 -33
- package/docs/src/scripts/components/app-split-panel/app-split-panel.tsx +0 -73
- package/docs/src/scripts/components/app-split-panel/resize-bar.tsx +0 -155
- package/docs/src/scripts/components/lazy-svg/lazy-svg.tsx +0 -94
- package/docs/src/scripts/index.ts +0 -6
- package/docs/src/scripts/playground.ts +0 -1
- package/docs/src/styles/main.css +0 -699
- package/docs/tsconfig.json +0 -22
- package/index.html +0 -49
- package/src/custom-element-controller.ts +0 -31
- package/src/custom-element.ts +0 -588
- package/src/decorators/bind.ts +0 -46
- package/src/decorators/custom-element-config.ts +0 -17
- package/src/decorators/property.ts +0 -684
- package/src/decorators/query.ts +0 -12
- package/src/decorators/render-property-on-set.ts +0 -3
- package/src/maquette/cache.ts +0 -35
- package/src/maquette/dom.ts +0 -115
- package/src/maquette/h.ts +0 -100
- package/src/maquette/interfaces.ts +0 -536
- package/src/maquette/jsx.ts +0 -61
- package/src/maquette/mapping.ts +0 -56
- package/src/maquette/projection.ts +0 -666
- package/src/maquette/projector.ts +0 -200
- package/src/p-elements-core.ts +0 -260
- package/src/sample/animate.tsx +0 -199
- package/src/sample/mixin/highlight.tsx +0 -33
- package/src/sample/sample.tsx +0 -450
- package/storybook/storybook-demo/.storybook/main.ts +0 -30
- package/storybook/storybook-demo/.storybook/preview-head.html +0 -1
- package/storybook/storybook-demo/.storybook/preview.ts +0 -20
- package/storybook/storybook-demo/package.json +0 -23
- package/storybook/storybook-demo/stories/bar.stories.tsx +0 -27
- package/storybook/storybook-demo/stories/baz.stories.tsx +0 -37
- package/storybook/storybook-demo/stories/foo.mdx +0 -11
- package/storybook/storybook-demo/stories/foo.stories.tsx +0 -27
- package/storybook/storybook-demo/stories/foo.tsx +0 -24
- package/storybook/storybook-demo/tsconfig.json +0 -30
- package/storybook/storybook-p-element-vite/README.md +0 -97
- package/storybook/storybook-p-element-vite/package.json +0 -81
- package/storybook/storybook-p-element-vite/preset.js +0 -2
- package/storybook/storybook-p-element-vite/src/docs/index.ts +0 -8
- package/storybook/storybook-p-element-vite/src/docs/source-decorator.ts +0 -55
- package/storybook/storybook-p-element-vite/src/entry-preview-docs.ts +0 -16
- package/storybook/storybook-p-element-vite/src/entry-preview.ts +0 -8
- package/storybook/storybook-p-element-vite/src/index.ts +0 -9
- package/storybook/storybook-p-element-vite/src/node/index.ts +0 -5
- package/storybook/storybook-p-element-vite/src/portable-stories.ts +0 -35
- package/storybook/storybook-p-element-vite/src/preset.ts +0 -69
- package/storybook/storybook-p-element-vite/src/render.ts +0 -96
- package/storybook/storybook-p-element-vite/src/types.ts +0 -99
- package/storybook/storybook-p-element-vite/tsconfig.json +0 -14
- package/storybook/storybook-p-element-vite/tsdown.config.ts +0 -26
- package/tsconfig.json +0 -67
- package/tsconfig.sample.json +0 -20
- package/webpack.config.js +0 -76
package/src/sample/sample.tsx
DELETED
|
@@ -1,450 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import { Highlightable } from "./mixin/highlight";
|
|
3
|
-
import "./animate";
|
|
4
|
-
|
|
5
|
-
import { customElementConfig as CustomElementConfig } from "../decorators/custom-element-config";
|
|
6
|
-
import {
|
|
7
|
-
property as Property,
|
|
8
|
-
AttributeConverter,
|
|
9
|
-
} from "../decorators/property";
|
|
10
|
-
import { propertyRenderOnSet as PropertyRenderOnSet } from "../decorators/render-property-on-set";
|
|
11
|
-
import { query as Query } from "../decorators/query";
|
|
12
|
-
import { CustomElement } from "../custom-element";
|
|
13
|
-
import { CustomElementController } from "../custom-element-controller";
|
|
14
|
-
import { has } from "underscore";
|
|
15
|
-
import { dom } from "../maquette";
|
|
16
|
-
|
|
17
|
-
@CustomElementConfig({
|
|
18
|
-
tagName: "my-button",
|
|
19
|
-
})
|
|
20
|
-
export class MyButton extends CustomElement {
|
|
21
|
-
static style = `.foo{background-color: red; color: white; border: 0px;}`;
|
|
22
|
-
static delegatesFocus = true;
|
|
23
|
-
|
|
24
|
-
render = () => {
|
|
25
|
-
return (
|
|
26
|
-
<button class="foo">
|
|
27
|
-
<slot></slot>
|
|
28
|
-
</button>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
connectedCallback(): void {
|
|
32
|
-
super.connectedCallback();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@CustomElementConfig({
|
|
37
|
-
tagName: "my-greetings",
|
|
38
|
-
})
|
|
39
|
-
export class MyGreetings extends Highlightable(class extends CustomElement {}) {
|
|
40
|
-
static isFormAssociated = true;
|
|
41
|
-
|
|
42
|
-
private count: number = 1;
|
|
43
|
-
|
|
44
|
-
@PropertyRenderOnSet
|
|
45
|
-
private name: string = "";
|
|
46
|
-
|
|
47
|
-
@PropertyRenderOnSet
|
|
48
|
-
public foo: string = "foo";
|
|
49
|
-
|
|
50
|
-
private onInput = (e) => {
|
|
51
|
-
this.name = e.target.value;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
@Query("#SlotContainer")
|
|
55
|
-
private slotContainer: HTMLDivElement;
|
|
56
|
-
|
|
57
|
-
private enterAnimation(domNode, properties) {
|
|
58
|
-
domNode.animate(
|
|
59
|
-
[
|
|
60
|
-
// keyframes
|
|
61
|
-
{ transform: "translateY(800px)" },
|
|
62
|
-
{ transform: "translateY(0px)" },
|
|
63
|
-
],
|
|
64
|
-
{
|
|
65
|
-
// timing options
|
|
66
|
-
duration: 1000,
|
|
67
|
-
iterations: 1,
|
|
68
|
-
},
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
private exitAnimation(domNode, removeDomNodeFunction, properties) {
|
|
73
|
-
console.log("exit animation", { domNode, properties });
|
|
74
|
-
|
|
75
|
-
domNode
|
|
76
|
-
.animate(
|
|
77
|
-
[
|
|
78
|
-
// keyframes
|
|
79
|
-
{ opacity: 1, scale: 1 },
|
|
80
|
-
{ opacity: 0, scale: 0 },
|
|
81
|
-
],
|
|
82
|
-
{
|
|
83
|
-
// timing options
|
|
84
|
-
duration: 1000,
|
|
85
|
-
iterations: 1,
|
|
86
|
-
},
|
|
87
|
-
)
|
|
88
|
-
.finished.then(() => {
|
|
89
|
-
removeDomNodeFunction(domNode);
|
|
90
|
-
console.log("removed");
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
private countUpdateAnimation(domNode, properties, previousProperties) {
|
|
95
|
-
const newspaperSpinning = [
|
|
96
|
-
{ transform: "rotate(0) scale(0)" },
|
|
97
|
-
{ transform: "rotate(360deg) scale(1)" },
|
|
98
|
-
];
|
|
99
|
-
|
|
100
|
-
const newspaperTiming = {
|
|
101
|
-
duration: 1000,
|
|
102
|
-
iterations: 1,
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
domNode.animate(newspaperSpinning, newspaperTiming);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
private onPeterClick = (e) => {
|
|
109
|
-
console.log({ e, p: this });
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
private render = () => {
|
|
113
|
-
return (
|
|
114
|
-
<div >
|
|
115
|
-
<input type="checkbox" checked={this.name === "Peter"} />
|
|
116
|
-
<h1 part="sample" on={{ click: (e) => console.log(e, this.slotContainer) }} id="Foo">
|
|
117
|
-
Hallo:
|
|
118
|
-
</h1>
|
|
119
|
-
|
|
120
|
-
<h1
|
|
121
|
-
data-force-event-handler="true"
|
|
122
|
-
onclick={() => console.log("click " + this.name)}
|
|
123
|
-
data-title={this.name && this.name.toLocaleUpperCase()}
|
|
124
|
-
class="title"
|
|
125
|
-
>
|
|
126
|
-
{this.foo} {this.name}
|
|
127
|
-
</h1>
|
|
128
|
-
<p data-count={this.count} updateAnimation={this.countUpdateAnimation}>
|
|
129
|
-
{this.count}
|
|
130
|
-
</p>
|
|
131
|
-
<div id="SlotContainer">
|
|
132
|
-
<slot></slot>
|
|
133
|
-
</div>
|
|
134
|
-
<p
|
|
135
|
-
eventListeners={[
|
|
136
|
-
["mouseenter", () => console.log("enter"), { once: true }],
|
|
137
|
-
["mouseleave", () => console.log("leave"), { once: true }],
|
|
138
|
-
]}
|
|
139
|
-
>
|
|
140
|
-
Please enter your name (hint type{" "}
|
|
141
|
-
<em>
|
|
142
|
-
<strong>Peter</strong>
|
|
143
|
-
</em>
|
|
144
|
-
)<br />
|
|
145
|
-
<input type="text" value={this.name} oninput={this.onInput} />
|
|
146
|
-
</p>
|
|
147
|
-
<p>
|
|
148
|
-
<a is="super-a">Super a</a>
|
|
149
|
-
</p>
|
|
150
|
-
{this.name &&
|
|
151
|
-
this.name.toLowerCase &&
|
|
152
|
-
this.name.toLowerCase().indexOf("peter") > -1 ? (
|
|
153
|
-
<div
|
|
154
|
-
key="peter"
|
|
155
|
-
afterRemoved={this.peterRemoved}
|
|
156
|
-
afterCreate={this.peterCreate}
|
|
157
|
-
class="is-peter"
|
|
158
|
-
eventListeners={[["click", this.onPeterClick]]}
|
|
159
|
-
enterAnimation={this.enterAnimation}
|
|
160
|
-
exitAnimation={this.exitAnimation}
|
|
161
|
-
>
|
|
162
|
-
<p>Hello Peter</p>
|
|
163
|
-
<img
|
|
164
|
-
class="is-peter--image"
|
|
165
|
-
src="https://s-media-cache-ak0.pinimg.com/474x/ce/1d/07/ce1d07011c0afb8e0614a0ae42a8c861.jpg"
|
|
166
|
-
height="140"
|
|
167
|
-
/>
|
|
168
|
-
</div>
|
|
169
|
-
) : (
|
|
170
|
-
""
|
|
171
|
-
)}
|
|
172
|
-
</div>
|
|
173
|
-
);
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
private peterRemoved() {
|
|
177
|
-
console.log("removed");
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
private peterCreate() {
|
|
181
|
-
console.log("create");
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
#initDone = false;
|
|
185
|
-
|
|
186
|
-
connectedCallback() {
|
|
187
|
-
if (!this.#initDone) {
|
|
188
|
-
this.#initDone = true;
|
|
189
|
-
let template = this.templateFromString(`
|
|
190
|
-
<style>
|
|
191
|
-
|
|
192
|
-
:host{
|
|
193
|
-
/* display: none; */
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
.root {
|
|
197
|
-
display: flex;
|
|
198
|
-
padding: 10px;
|
|
199
|
-
flex-direction: row;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
#Foo {
|
|
203
|
-
text-decoration: underline;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
#SlotContainer ::slotted(*) {
|
|
207
|
-
font-weight: bold;
|
|
208
|
-
color: green;
|
|
209
|
-
font-size: 1.5em;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
</style>
|
|
213
|
-
<div class="root"></div>
|
|
214
|
-
`);
|
|
215
|
-
|
|
216
|
-
this.shadowRoot.appendChild(template);
|
|
217
|
-
|
|
218
|
-
this.createProjector(this.shadowRoot.querySelector(".root"), this.render);
|
|
219
|
-
}
|
|
220
|
-
setInterval(() => {
|
|
221
|
-
this.count++;
|
|
222
|
-
this.renderNow();
|
|
223
|
-
}, 5000);
|
|
224
|
-
|
|
225
|
-
window.addEventListener("foo", this.onFooEvent);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
private onFooEvent = (e: CustomEvent) => {
|
|
229
|
-
this.foo = e.detail.foo;
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
static get observedAttributes() {
|
|
233
|
-
return ["name"];
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
237
|
-
super.attributeChangedCallback(name, oldValue, newValue);
|
|
238
|
-
if (name === "name") {
|
|
239
|
-
this.name = newValue;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
const stringArrayConverter: AttributeConverter<string[]> = {
|
|
245
|
-
fromAttribute: (value) => {
|
|
246
|
-
if (!value) {
|
|
247
|
-
return null;
|
|
248
|
-
}
|
|
249
|
-
return value.split(",").map((v) => v.trim());
|
|
250
|
-
},
|
|
251
|
-
toAttribute: (value) => {
|
|
252
|
-
if (!value.join) {
|
|
253
|
-
return null;
|
|
254
|
-
}
|
|
255
|
-
return value.join(",");
|
|
256
|
-
},
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
class DisabledController extends CustomElementController {
|
|
260
|
-
#connected = false;
|
|
261
|
-
|
|
262
|
-
@Property({ type: "boolean" })
|
|
263
|
-
disabled = false;
|
|
264
|
-
|
|
265
|
-
#updateAttributes() {
|
|
266
|
-
if (!this.#connected) {
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
if (this.disabled === true) {
|
|
270
|
-
this.hostElement.setAttribute("disabled", "!!");
|
|
271
|
-
} else {
|
|
272
|
-
this.hostElement.removeAttribute("disabled");
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
connected() {
|
|
277
|
-
console.log("connected");
|
|
278
|
-
this.#connected = true;
|
|
279
|
-
this.#updateAttributes();
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
disconnected() {
|
|
283
|
-
console.info("disconnected");
|
|
284
|
-
this.#connected = false;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
shouldUpdate(property, oldValue, newValue) {
|
|
288
|
-
console.info("shouldUpdate", { property, oldValue, newValue });
|
|
289
|
-
return true;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
updated(property, oldValue, newValue) {
|
|
293
|
-
console.info("updated", { property, oldValue, newValue });
|
|
294
|
-
this.#updateAttributes();
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
hostRenderStart(isFirstRender) {
|
|
298
|
-
console.info("hostRenderStart", { isFirstRender, controller: this });
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
hostRenderDone(isFirstRender) {
|
|
302
|
-
console.info("hostRenderDone", { isFirstRender, controller: this });
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
@CustomElementConfig({
|
|
307
|
-
tagName: "p-foo",
|
|
308
|
-
})
|
|
309
|
-
class PFoo extends CustomElement {
|
|
310
|
-
static style = `.foo{color: red} .foo__disabled{opacity: 0.5;}`;
|
|
311
|
-
|
|
312
|
-
init() {
|
|
313
|
-
console.info("init!!!!");
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
disabledController: DisabledController = new DisabledController(this);
|
|
317
|
-
|
|
318
|
-
@Property({ type: "string", attribute: "name", reflect: true })
|
|
319
|
-
name: string;
|
|
320
|
-
|
|
321
|
-
@Property({ type: "number", attribute: "age", reflect: true })
|
|
322
|
-
age: number;
|
|
323
|
-
|
|
324
|
-
@Property({ type: "object", attribute: "data", reflect: true })
|
|
325
|
-
data: any;
|
|
326
|
-
|
|
327
|
-
@Property({
|
|
328
|
-
attribute: "items",
|
|
329
|
-
type: "object",
|
|
330
|
-
reflect: true,
|
|
331
|
-
converter: stringArrayConverter,
|
|
332
|
-
})
|
|
333
|
-
items: string[] = ["foo", "bar"];
|
|
334
|
-
|
|
335
|
-
@Property({ type: "string", attribute: "nick-name", readonly: true })
|
|
336
|
-
nickName: string = "de prutser";
|
|
337
|
-
|
|
338
|
-
shouldUpdate(property, oldValue, newValue) {
|
|
339
|
-
if (
|
|
340
|
-
property === "name" &&
|
|
341
|
-
typeof newValue === "string" &&
|
|
342
|
-
newValue.toLocaleLowerCase() === "adolf"
|
|
343
|
-
) {
|
|
344
|
-
return false;
|
|
345
|
-
}
|
|
346
|
-
return true;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
updated(property, oldValue, newValue) {
|
|
350
|
-
console.info("PFoo", { name: property, old: oldValue, newValue });
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
static observedAttributes = ["disabled"];
|
|
354
|
-
|
|
355
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
356
|
-
super.attributeChangedCallback(name, oldValue, newValue);
|
|
357
|
-
if (name === "disabled") {
|
|
358
|
-
this.disabledController.disabled = newValue !== null;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
renderStart(isFirstRender) {
|
|
363
|
-
console.info("renderStart", { isFirstRender, tag: this.tagName });
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
renderDone(isFirstRender) {
|
|
367
|
-
console.info("renderDone", { isFirstRender, tag: this.tagName });
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
render = () => {
|
|
371
|
-
return (
|
|
372
|
-
<div
|
|
373
|
-
classes={{ foo: true, foo__disabled: this.disabledController.disabled }}
|
|
374
|
-
>
|
|
375
|
-
<div>
|
|
376
|
-
Hello {this.name}{" "}
|
|
377
|
-
{this.nickName ? <span> ({this.nickName})</span> : null}
|
|
378
|
-
</div>
|
|
379
|
-
<div>age {this.age}</div>
|
|
380
|
-
{this.data ? <pre>{JSON.stringify(this.data, null, 2)}</pre> : null}
|
|
381
|
-
{this.items?.map((item, i) => (
|
|
382
|
-
<div key={`item${i}`}>{item}</div>
|
|
383
|
-
))}
|
|
384
|
-
</div>
|
|
385
|
-
);
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
class SuperAnchorElement extends HTMLAnchorElement {
|
|
390
|
-
constructor() {
|
|
391
|
-
super();
|
|
392
|
-
this.onclick = (e) => {
|
|
393
|
-
e.preventDefault();
|
|
394
|
-
alert("super");
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
public connectedCallback() {
|
|
398
|
-
this.classList.add("super");
|
|
399
|
-
this.style.color = "red";
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
@CustomElementConfig({
|
|
404
|
-
tagName: "delegate-focus-demo",
|
|
405
|
-
})
|
|
406
|
-
class DelegateFocusDemo extends CustomElement {
|
|
407
|
-
static style = `
|
|
408
|
-
.root {
|
|
409
|
-
display: flex;
|
|
410
|
-
flex-direction: column;
|
|
411
|
-
gap: 10px;
|
|
412
|
-
background-color: #eee;
|
|
413
|
-
padding: 10px;
|
|
414
|
-
}`;
|
|
415
|
-
|
|
416
|
-
@Property({ type: "boolean", attribute: "has-p-foo" })
|
|
417
|
-
hasPFoo = false;
|
|
418
|
-
|
|
419
|
-
static delegatesFocus = true;
|
|
420
|
-
|
|
421
|
-
render = () => {
|
|
422
|
-
return (
|
|
423
|
-
<div class="root">
|
|
424
|
-
<span>
|
|
425
|
-
Delegate focus. The input should be focused when you click on me.
|
|
426
|
-
</span>
|
|
427
|
-
<input type="text" placeholder="I should be focused" />
|
|
428
|
-
<hr />
|
|
429
|
-
<span>Also p-foo should be rendered below when it is defined.</span>
|
|
430
|
-
{this.hasPFoo ? (
|
|
431
|
-
<p-foo
|
|
432
|
-
name="peter"
|
|
433
|
-
nick-name="web component freak"
|
|
434
|
-
age={123}
|
|
435
|
-
items={["baz", "bar"]}
|
|
436
|
-
></p-foo>
|
|
437
|
-
) : null}
|
|
438
|
-
</div>
|
|
439
|
-
);
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
connectedCallback(): void {
|
|
443
|
-
super.connectedCallback();
|
|
444
|
-
customElements.whenDefined("p-foo").then(() => {
|
|
445
|
-
this.hasPFoo = true;
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
window.customElements.define("super-a", SuperAnchorElement, { extends: "a" });
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// This file has been automatically migrated to valid ESM format by Storybook.
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import type { StorybookConfig } from 'storybook-p-element-vite';
|
|
4
|
-
import { join, dirname } from "path";
|
|
5
|
-
|
|
6
|
-
const require = createRequire(import.meta.url);
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* This function is used to resolve the absolute path of a package.
|
|
10
|
-
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
|
|
11
|
-
*/
|
|
12
|
-
function getAbsolutePath(value: string): string {
|
|
13
|
-
return dirname(require.resolve(join(value, 'package.json')));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const config: StorybookConfig = {
|
|
17
|
-
stories: [
|
|
18
|
-
"../stories/**/*.mdx",
|
|
19
|
-
"../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)"
|
|
20
|
-
],
|
|
21
|
-
addons: [
|
|
22
|
-
getAbsolutePath('@storybook/addon-docs')
|
|
23
|
-
],
|
|
24
|
-
framework: getAbsolutePath("storybook-p-element-vite"),
|
|
25
|
-
typescript: {
|
|
26
|
-
check: false,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default config;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/p-elements-core@^1.2.20/dist/p-elements-core-modern.js"></script>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Preview } from 'storybook-p-element-vite'
|
|
2
|
-
|
|
3
|
-
const preview: Preview = {
|
|
4
|
-
parameters: {
|
|
5
|
-
controls: {
|
|
6
|
-
matchers: {
|
|
7
|
-
color: /(background|color)$/i,
|
|
8
|
-
date: /Date$/i,
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
docs: {
|
|
12
|
-
codePanel: true
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export default preview;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "storybook-demo",
|
|
3
|
-
"private": true,
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"description": "",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
-
"storybook": "storybook dev -p 6006",
|
|
10
|
-
"build-storybook": "storybook build"
|
|
11
|
-
},
|
|
12
|
-
"keywords": [],
|
|
13
|
-
"author": "",
|
|
14
|
-
"license": "ISC",
|
|
15
|
-
"type": "module",
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@storybook/addon-docs": "^10.2.7",
|
|
18
|
-
"@storybook/html-vite": "^10.2.7",
|
|
19
|
-
"storybook": "^10.2.7",
|
|
20
|
-
"storybook-p-element-vite": "2.0.0-rc1",
|
|
21
|
-
"p-elements-core": "2.1.0-rc6"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import "./foo";
|
|
2
|
-
import type { Meta, StoryObj } from "storybook-p-element-vite";
|
|
3
|
-
import type { ArgTypes } from "storybook/internal/csf";
|
|
4
|
-
|
|
5
|
-
type Args = {
|
|
6
|
-
name: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const argTypes: ArgTypes = {
|
|
10
|
-
name: {
|
|
11
|
-
control: "text",
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default {
|
|
16
|
-
title: "Bar",
|
|
17
|
-
argTypes,
|
|
18
|
-
render: (args: Args) => `<my-foo name="${args.name}"></my-foo>`,
|
|
19
|
-
} satisfies Meta<Args>;
|
|
20
|
-
|
|
21
|
-
type Story = StoryObj<Args>;
|
|
22
|
-
|
|
23
|
-
export const Default: Story = {
|
|
24
|
-
args: {
|
|
25
|
-
name: "Bar",
|
|
26
|
-
},
|
|
27
|
-
} satisfies { args: Args };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import "./foo";
|
|
2
|
-
import type { Meta, StoryObj } from "storybook-p-element-vite";
|
|
3
|
-
import type { ArgTypes } from "storybook/internal/csf";
|
|
4
|
-
|
|
5
|
-
type Args = {
|
|
6
|
-
name: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const argTypes: ArgTypes = {
|
|
10
|
-
name: {
|
|
11
|
-
control: "text",
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const fooElement = document.createElement("my-foo");
|
|
16
|
-
|
|
17
|
-
const input = document.createElement("input");
|
|
18
|
-
input.type = "text";
|
|
19
|
-
input.value = "Hello";
|
|
20
|
-
fooElement.appendChild(input);
|
|
21
|
-
|
|
22
|
-
export default {
|
|
23
|
-
title: "Baz",
|
|
24
|
-
argTypes,
|
|
25
|
-
render: (args: Args) => {
|
|
26
|
-
fooElement.setAttribute("name", args.name);
|
|
27
|
-
return fooElement;
|
|
28
|
-
},
|
|
29
|
-
} satisfies Meta<Args>;
|
|
30
|
-
|
|
31
|
-
type Story = StoryObj<Args>;
|
|
32
|
-
|
|
33
|
-
export const Default: Story = {
|
|
34
|
-
args: {
|
|
35
|
-
name: "Baz",
|
|
36
|
-
},
|
|
37
|
-
} satisfies { args: Args };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Canvas, Meta } from '@storybook/addon-docs/blocks';
|
|
2
|
-
|
|
3
|
-
import * as FooStories from './foo.stories';
|
|
4
|
-
|
|
5
|
-
<Meta of={FooStories} />
|
|
6
|
-
|
|
7
|
-
# Foo
|
|
8
|
-
|
|
9
|
-
A foo is a customizable component that can be used to display content in a specific way.
|
|
10
|
-
|
|
11
|
-
<Canvas of={FooStories.Default} />
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import "./foo";
|
|
2
|
-
import type { Meta, StoryObj } from "storybook-p-element-vite";
|
|
3
|
-
import type { ArgTypes } from "storybook/internal/csf";
|
|
4
|
-
|
|
5
|
-
type Args = {
|
|
6
|
-
name: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const argTypes: ArgTypes = {
|
|
10
|
-
name: {
|
|
11
|
-
control: "text",
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default {
|
|
16
|
-
title: "Foo",
|
|
17
|
-
argTypes,
|
|
18
|
-
render: (args: Args) => <my-foo afterCreate={(e: HTMLElement)=>e.dataset.foo = "bar" } name={args.name}></my-foo>,
|
|
19
|
-
} satisfies Meta<Args>;
|
|
20
|
-
|
|
21
|
-
type Story = StoryObj<Args>;
|
|
22
|
-
|
|
23
|
-
export const Default: Story = {
|
|
24
|
-
args: {
|
|
25
|
-
name: "Peter",
|
|
26
|
-
},
|
|
27
|
-
} satisfies { args: Args };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
@CustomElementConfig({
|
|
2
|
-
tagName: 'my-foo',
|
|
3
|
-
})
|
|
4
|
-
export class Foo extends CustomElement {
|
|
5
|
-
|
|
6
|
-
static readonly style = `
|
|
7
|
-
:host {
|
|
8
|
-
color: blue;
|
|
9
|
-
font-weight: bold;
|
|
10
|
-
}
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
@Property({type: "string", attribute: "name"})
|
|
14
|
-
name: string = "World";
|
|
15
|
-
|
|
16
|
-
render() :VNode {
|
|
17
|
-
return (
|
|
18
|
-
<div>
|
|
19
|
-
Foo Component Hello {this.name}
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES6",
|
|
4
|
-
"experimentalDecorators": true,
|
|
5
|
-
"useDefineForClassFields": false,
|
|
6
|
-
|
|
7
|
-
"jsx": "preserve",
|
|
8
|
-
"jsxFactory": "Maquette.h",
|
|
9
|
-
|
|
10
|
-
"module": "ESNext",
|
|
11
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
|
|
14
|
-
"moduleResolution": "node",
|
|
15
|
-
"allowImportingTsExtensions": true,
|
|
16
|
-
"verbatimModuleSyntax": true,
|
|
17
|
-
"moduleDetection": "force",
|
|
18
|
-
"noEmit": true,
|
|
19
|
-
|
|
20
|
-
"strict": true,
|
|
21
|
-
"noUnusedLocals": true,
|
|
22
|
-
"noUnusedParameters": true,
|
|
23
|
-
"erasableSyntaxOnly": true,
|
|
24
|
-
"noFallthroughCasesInSwitch": true,
|
|
25
|
-
"noUncheckedSideEffectImports": true,
|
|
26
|
-
"types": ["p-elements-core"]
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
"include": ["src", "**/*.ts", "**/*.tsx"]
|
|
30
|
-
}
|