p-elements-core 1.2.27 → 1.2.29

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.
Files changed (46) hide show
  1. package/.gitlab-ci.yml +1 -0
  2. package/demo/sample.js +1 -1
  3. package/dist/p-elements-core-modern.js +1 -1
  4. package/dist/p-elements-core.js +1 -1
  5. package/docs/.eleventy.js +4 -1
  6. package/docs/package-lock.json +27 -4
  7. package/docs/package.json +2 -1
  8. package/docs/src/_data/demos/hello-world/hello-world.tsx +1 -1
  9. package/docs/src/_data/demos/timer/demo-timer.tsx +120 -0
  10. package/docs/src/_data/demos/timer/icons.tsx +62 -0
  11. package/docs/src/_data/demos/timer/index.html +5 -3
  12. package/docs/src/_data/demos/timer/project.json +3 -3
  13. package/docs/src/_includes/layouts/base.njk +22 -17
  14. package/docs/src/_includes/layouts/playground.njk +11 -6
  15. package/docs/src/_includes/partials/{page-header.njk → app-header.njk} +3 -2
  16. package/docs/src/_includes/partials/head.njk +4 -2
  17. package/docs/src/_includes/partials/nav.njk +15 -7
  18. package/docs/src/_includes/partials/top-nav.njk +52 -14
  19. package/docs/src/assets/favicon.png +0 -0
  20. package/docs/src/documentation/custom-element.md +221 -0
  21. package/docs/src/documentation/decorators/bind.md +71 -0
  22. package/docs/src/documentation/decorators/custom-element-config.md +63 -0
  23. package/docs/src/documentation/decorators/property.md +83 -0
  24. package/docs/src/documentation/decorators/query.md +66 -0
  25. package/docs/src/documentation/decorators/render-property-on-set.md +60 -0
  26. package/docs/src/documentation/decorators.md +9 -0
  27. package/docs/src/documentation/getting-started.md +49 -6
  28. package/docs/src/documentation/index.md +19 -17
  29. package/docs/src/documentation/reactive-properties.md +54 -0
  30. package/docs/src/index.d.ts +5 -3
  31. package/docs/src/playground/index.njk +10 -0
  32. package/docs/src/playground/timer.njk +10 -0
  33. package/docs/src/scripts/components/app-mobile-menu/app-mobile-menu.css +48 -0
  34. package/docs/src/scripts/components/app-mobile-menu/app-mobile-menu.tsx +112 -0
  35. package/docs/src/scripts/components/app-mode-switch/app-mode-switch.css +78 -0
  36. package/docs/src/scripts/components/app-mode-switch/app-mode-switch.tsx +166 -0
  37. package/docs/src/scripts/components/app-playground/app-playground.tsx +77 -54
  38. package/docs/src/scripts/components/app-split-panel/app-split-panel.css +33 -0
  39. package/docs/src/scripts/components/app-split-panel/app-split-panel.tsx +73 -0
  40. package/docs/src/scripts/components/app-split-panel/resize-bar.tsx +155 -0
  41. package/docs/src/scripts/index.ts +3 -0
  42. package/docs/src/styles/main.css +565 -85
  43. package/p-elements-core.d.ts +9 -2
  44. package/package.json +3 -2
  45. package/docs/src/_data/demos/timer/timer.tsx +0 -22
  46. package/docs/src/playground/index.md +0 -47
@@ -0,0 +1,155 @@
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,3 +1,6 @@
1
1
  import "./components/lazy-svg/lazy-svg";
2
2
  import "./components/app-playground/app-playground";
3
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";