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
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
const ACTIVE_HOVER_MS = 300;
|
|
2
|
-
|
|
3
|
-
@CustomElementConfig({
|
|
4
|
-
tagName: "resize-bar",
|
|
5
|
-
})
|
|
6
|
-
export class ResizeBarElement extends CustomElement {
|
|
7
|
-
static readonly style = `
|
|
8
|
-
:host {
|
|
9
|
-
z-index: 1;
|
|
10
|
-
position: relative;
|
|
11
|
-
touch-action: none;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
:host([dimension='width']) {
|
|
15
|
-
width: 3px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
:host([dimension='height']) {
|
|
19
|
-
height: 3px;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
:host([dimension='width']) > #touchTarget {
|
|
23
|
-
cursor: col-resize;
|
|
24
|
-
position: absolute;
|
|
25
|
-
top: 0;
|
|
26
|
-
left: calc(var(--resize-bar-touch-size, 6px) / -2);
|
|
27
|
-
width: var(--resize-bar-touch-size, 6px);
|
|
28
|
-
height: 100%;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
:host([dimension='height']) > #touchTarget {
|
|
32
|
-
cursor: row-resize;
|
|
33
|
-
position: absolute;
|
|
34
|
-
top: calc(var(--resize-bar-touch-size, 6px) / -2);
|
|
35
|
-
left: 0;
|
|
36
|
-
width: 100%;
|
|
37
|
-
height: var(--resize-bar-touch-size, 6px);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
#touchTarget {
|
|
41
|
-
background: var(--resize-bar-background-color);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
`;
|
|
45
|
-
|
|
46
|
-
@Property({type: "string"})
|
|
47
|
-
dimension?: 'width' | 'height' = 'width';
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
@Property({type: "string", attribute: "property"})
|
|
51
|
-
property?: string;
|
|
52
|
-
|
|
53
|
-
@Property({type: "string", attribute: "target"})
|
|
54
|
-
target?: string;
|
|
55
|
-
|
|
56
|
-
@Property({type: "boolean", reflect: true})
|
|
57
|
-
active = false;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
@Property({type: "boolean", reflect: true})
|
|
61
|
-
resizing = false;
|
|
62
|
-
|
|
63
|
-
@Property({type: "number", attribute: "min"})
|
|
64
|
-
minPropertyValue = 10
|
|
65
|
-
|
|
66
|
-
private _hoverTimer?: ReturnType<typeof setTimeout>;
|
|
67
|
-
private _updateSizeRafId?: ReturnType<typeof requestAnimationFrame>;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
render() {
|
|
71
|
-
return <div id="touchTarget"
|
|
72
|
-
on={{
|
|
73
|
-
pointerover: this._onPointerOver,
|
|
74
|
-
pointerleave: this._onPointerLeave,
|
|
75
|
-
pointerdown: this._onPointerDown,
|
|
76
|
-
}}
|
|
77
|
-
/>;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
private _onPointerOver = () => {
|
|
81
|
-
this._hoverTimer = setTimeout(() => {
|
|
82
|
-
this.active = true;
|
|
83
|
-
this._hoverTimer = undefined;
|
|
84
|
-
}, ACTIVE_HOVER_MS);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
private _onPointerLeave() {
|
|
88
|
-
if (this.active && !this.resizing) {
|
|
89
|
-
this.active = false;
|
|
90
|
-
}
|
|
91
|
-
if (this._hoverTimer !== undefined) {
|
|
92
|
-
clearTimeout(this._hoverTimer);
|
|
93
|
-
this._hoverTimer = undefined;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
private _onPointerDown = ({pointerId}: PointerEvent) => {
|
|
98
|
-
|
|
99
|
-
if (!this.target || !this.property) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const target = (this.getRootNode() as ShadowRoot | Document).getElementById(
|
|
103
|
-
this.target
|
|
104
|
-
);
|
|
105
|
-
if (!target) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
this.active = true;
|
|
109
|
-
this.resizing = true;
|
|
110
|
-
this.setPointerCapture(pointerId);
|
|
111
|
-
const isWidthDimension = this.dimension === 'width';
|
|
112
|
-
const {left, right, top, bottom} = target.getBoundingClientRect();
|
|
113
|
-
const oldSize = isWidthDimension ? right - left : bottom - top;
|
|
114
|
-
|
|
115
|
-
let clientX = 0;
|
|
116
|
-
let clientY = 0;
|
|
117
|
-
|
|
118
|
-
const onPointermove = (event: PointerEvent) => {
|
|
119
|
-
// Only update once per animation frame, but with the latest offsets.
|
|
120
|
-
clientX = event.clientX;
|
|
121
|
-
clientY = event.clientY;
|
|
122
|
-
if (this._updateSizeRafId !== undefined) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
this._updateSizeRafId = requestAnimationFrame(() => {
|
|
126
|
-
this._updateSizeRafId = undefined;
|
|
127
|
-
if (!this.property) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
let newSize = Math.max(
|
|
131
|
-
0,
|
|
132
|
-
isWidthDimension ? oldSize + clientX - right : oldSize - clientY + top
|
|
133
|
-
);
|
|
134
|
-
if (newSize < this.minPropertyValue) {
|
|
135
|
-
newSize = this.minPropertyValue;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
(target.style as any)[this.property] = `${newSize}px`;
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
this.addEventListener('pointermove', onPointermove);
|
|
142
|
-
|
|
143
|
-
this.addEventListener(
|
|
144
|
-
'pointerup',
|
|
145
|
-
() => {
|
|
146
|
-
this.releasePointerCapture(pointerId);
|
|
147
|
-
this.removeEventListener('pointermove', onPointermove);
|
|
148
|
-
this.active = false;
|
|
149
|
-
this.resizing = false;
|
|
150
|
-
},
|
|
151
|
-
{once: true}
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
const LoadingStrategies = ["idle", "visible"] as const;
|
|
2
|
-
export type LoadingStrategy = typeof LoadingStrategies[number];
|
|
3
|
-
|
|
4
|
-
@CustomElementConfig({
|
|
5
|
-
tagName: "lazy-svg",
|
|
6
|
-
})
|
|
7
|
-
export class LayzySvgElement extends CustomElement {
|
|
8
|
-
static style = `
|
|
9
|
-
:host {
|
|
10
|
-
display: contents;
|
|
11
|
-
}
|
|
12
|
-
svg {
|
|
13
|
-
width: inherit;
|
|
14
|
-
height: inherit;
|
|
15
|
-
min-width: inherit;
|
|
16
|
-
min-height: inherit;
|
|
17
|
-
max-width: inherit;
|
|
18
|
-
max-height: inherit;
|
|
19
|
-
}`;
|
|
20
|
-
|
|
21
|
-
@Property({type: "string", attribute:"href", reflect: true})
|
|
22
|
-
href: string = "";
|
|
23
|
-
|
|
24
|
-
@Property({type: "string", attribute:"label", reflect: true})
|
|
25
|
-
label: string = "";
|
|
26
|
-
|
|
27
|
-
@Property({type: "boolean", attribute: 'svg-aria-hidden'})
|
|
28
|
-
svgAriaHidden = false;
|
|
29
|
-
|
|
30
|
-
@Property({type: "string", attribute: 'svg-role'})
|
|
31
|
-
svgRole = "";
|
|
32
|
-
|
|
33
|
-
@Property({type: "string", attribute:"width", reflect: true})
|
|
34
|
-
width: "";
|
|
35
|
-
|
|
36
|
-
@Property({type: "string", attribute:"height", reflect: true})
|
|
37
|
-
height: "";
|
|
38
|
-
|
|
39
|
-
@Property({type: "string"})
|
|
40
|
-
loading: LoadingStrategy = "visible";
|
|
41
|
-
|
|
42
|
-
@Property({type: "string", attribute: 'root-margin'})
|
|
43
|
-
rootMargin = '0px 0px 100px 0px';
|
|
44
|
-
|
|
45
|
-
@PropertyRenderOnSet
|
|
46
|
-
private _shouldLoad = false;
|
|
47
|
-
|
|
48
|
-
@Query("svg")
|
|
49
|
-
private _svgEl!: SVGSVGElement;
|
|
50
|
-
|
|
51
|
-
private _onIdle(){
|
|
52
|
-
this._shouldLoad = true;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
private _visibleLoad(){
|
|
56
|
-
|
|
57
|
-
const observer = new IntersectionObserver(
|
|
58
|
-
([entry]) => {
|
|
59
|
-
if (entry.isIntersecting) {
|
|
60
|
-
this._shouldLoad = true;
|
|
61
|
-
observer.disconnect();
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
rootMargin: this.rootMargin,
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
observer.observe(this._svgEl);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
updated(propertyName: string, oldValue: any, newValue: any): void {
|
|
72
|
-
if (propertyName === "loading") {
|
|
73
|
-
if (newValue === "idle") {
|
|
74
|
-
requestAnimationFrame( () => this._onIdle() );
|
|
75
|
-
} else if (newValue === "visible") {
|
|
76
|
-
requestAnimationFrame( () =>
|
|
77
|
-
requestAnimationFrame( () => this._visibleLoad() )
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
render = () => {
|
|
84
|
-
return <svg width={this.width} height={this.height} part="svg">
|
|
85
|
-
<use href={this._shouldLoad ? this.href : ""} />
|
|
86
|
-
</svg>;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
declare global {
|
|
91
|
-
interface HTMLElementTagNameMap {
|
|
92
|
-
"lazy-svg": LayzySvgElement;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import "./components/lazy-svg/lazy-svg";
|
|
2
|
-
import "./components/app-playground/app-playground";
|
|
3
|
-
import "./components/app-drawer/app-drawer";
|
|
4
|
-
import "./components/app-mode-switch/app-mode-switch";
|
|
5
|
-
import "./components/app-mobile-menu/app-mobile-menu";
|
|
6
|
-
import "./components/app-split-panel/app-split-panel";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "playground-elements";
|