composite-select 1.0.9 → 1.0.11
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/cjs/CenterAndHeightResizer.cjs +268 -0
- package/dist/cjs/CenterResizer.cjs +195 -0
- package/dist/cjs/composite-select/ContainerManager.html.cjs +650 -0
- package/dist/cjs/composite-select/composite-select.html.cjs +651 -0
- package/dist/cjs/options-section/OptionsSectionManager.html.cjs +362 -0
- package/dist/cjs/options-section/OptionsSectionManagerWebComponent.attributes.html.cjs +346 -0
- package/dist/cjs/options-section/OptionsSectionManagerWebComponent.html.cjs +354 -0
- package/dist/cjs/options-section/OptionsSectionManagerWebComponent.nocssrequest.html.cjs +345 -0
- package/dist/cjs/selected-section/SelectedSectionManager.html.cjs +336 -0
- package/dist/cjs/selected-section/SelectedSectionManager.templates.html.cjs +353 -0
- package/dist/cjs/selected-section/SelectedSectionManagerWebComponent.attributes.html.cjs +353 -0
- package/dist/cjs/selected-section/SelectedSectionManagerWebComponent.html.cjs +335 -0
- package/dist/cjs/selected-section/SelectedSectionManagerWebComponent.nocssrequest.html.cjs +341 -0
- package/dist/esm/CenterAndHeightResizer.js +268 -0
- package/dist/esm/CenterResizer.js +195 -0
- package/dist/types/CenterAndHeightResizer.d.ts +18 -0
- package/dist/types/CenterResizer.d.ts +16 -0
- package/dist/types/composite-select/ContainerManager.html.d.ts +1 -1
- package/dist/types/composite-select/composite-select.html.d.ts +1 -1
- package/dist/types/options-section/OptionsSectionManager.html.d.ts +1 -1
- package/dist/types/options-section/OptionsSectionManagerWebComponent.attributes.html.d.ts +1 -1
- package/dist/types/options-section/OptionsSectionManagerWebComponent.html.d.ts +1 -1
- package/dist/types/options-section/OptionsSectionManagerWebComponent.nocssrequest.html.d.ts +1 -1
- package/dist/types/selected-section/SelectedSectionManager.html.d.ts +1 -1
- package/dist/types/selected-section/SelectedSectionManager.templates.html.d.ts +1 -1
- package/dist/types/selected-section/SelectedSectionManagerWebComponent.attributes.html.d.ts +1 -1
- package/dist/types/selected-section/SelectedSectionManagerWebComponent.html.d.ts +1 -1
- package/dist/types/selected-section/SelectedSectionManagerWebComponent.nocssrequest.html.d.ts +1 -1
- package/package.json +1 -1
- package/js/CenterAndHeightResizer.js +0 -263
- package/js/CenterResizer.js +0 -190
- /package/dist/cjs/composite-select/{CompositeManager.js → CompositeManager.cjs} +0 -0
- /package/dist/cjs/composite-select/{composite-select.js → composite-select.cjs} +0 -0
- /package/dist/cjs/composite-select/{debounce.js → debounce.cjs} +0 -0
- /package/dist/cjs/composite-select/{helpers.js → helpers.cjs} +0 -0
- /package/dist/cjs/composite-select/{react.js → react.cjs} +0 -0
- /package/dist/cjs/container/{ContainerManager.js → ContainerManager.cjs} +0 -0
- /package/dist/cjs/options-section/{OptionsSectionManager.js → OptionsSectionManager.cjs} +0 -0
- /package/dist/cjs/options-section/{options-section.js → options-section.cjs} +0 -0
- /package/dist/cjs/options-section/{react.js → react.cjs} +0 -0
- /package/dist/cjs/selected-section/{SelectedSectionManager.js → SelectedSectionManager.cjs} +0 -0
- /package/dist/cjs/selected-section/{react.js → react.cjs} +0 -0
- /package/dist/cjs/selected-section/{selected-section.js → selected-section.cjs} +0 -0
- /package/dist/cjs/unbind/{clickOutside.js → clickOutside.cjs} +0 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <center-and-height-resizer
|
|
3
|
+
* left="50px"
|
|
4
|
+
* center="350px"
|
|
5
|
+
* height="200px"
|
|
6
|
+
* style="padding: 12px;"
|
|
7
|
+
* data-test="idfortest"
|
|
8
|
+
* >
|
|
9
|
+
* <div>Content</div>
|
|
10
|
+
* </center-and-height-resizer>
|
|
11
|
+
*
|
|
12
|
+
* const resizer = document.querySelector('center-and-height-resizer');
|
|
13
|
+
* resizer.addEventListener('onLeft', e => console.log(e.detail.width));
|
|
14
|
+
* resizer.addEventListener('onCenter', e => console.log(e.detail.width));
|
|
15
|
+
* resizer.addEventListener('onHeight', e => console.log(e.detail.height));
|
|
16
|
+
*/
|
|
17
|
+
const SKIP_ATTRIBUTES = ["id", "class", "left", "center", "height", "style"];
|
|
18
|
+
export class CenterAndHeightResizer extends HTMLElement {
|
|
19
|
+
leftDiv;
|
|
20
|
+
rightDiv;
|
|
21
|
+
centerDiv;
|
|
22
|
+
resizerLeft;
|
|
23
|
+
resizerRight;
|
|
24
|
+
resizerBottom;
|
|
25
|
+
constructor() {
|
|
26
|
+
super();
|
|
27
|
+
this.attachShadow({ mode: "open" });
|
|
28
|
+
this.shadowRoot.innerHTML = `
|
|
29
|
+
<style>
|
|
30
|
+
:host {
|
|
31
|
+
display: block;
|
|
32
|
+
width: 100%;
|
|
33
|
+
padding: 0 !important;
|
|
34
|
+
}
|
|
35
|
+
.flex {
|
|
36
|
+
display: flex;
|
|
37
|
+
width: 100%;
|
|
38
|
+
align-items: stretch;
|
|
39
|
+
}
|
|
40
|
+
.center-column {
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
min-width: 0;
|
|
44
|
+
}
|
|
45
|
+
.center-div {
|
|
46
|
+
flex-grow: 1;
|
|
47
|
+
min-width: 0;
|
|
48
|
+
box-sizing: border-box;
|
|
49
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 0 1px rgba(0, 0, 0, 0.1);
|
|
50
|
+
background: #fff;
|
|
51
|
+
border-radius: 6px;
|
|
52
|
+
overflow: auto;
|
|
53
|
+
min-height: 50px;
|
|
54
|
+
border: 1px solid #eaeaea;
|
|
55
|
+
}
|
|
56
|
+
.side-div {
|
|
57
|
+
flex-shrink: 0;
|
|
58
|
+
box-sizing: border-box;
|
|
59
|
+
}
|
|
60
|
+
#right-div {
|
|
61
|
+
flex-grow: 1;
|
|
62
|
+
}
|
|
63
|
+
.resizer {
|
|
64
|
+
flex-shrink: 0;
|
|
65
|
+
transition: background 0.2s;
|
|
66
|
+
user-select: none;
|
|
67
|
+
position: relative;
|
|
68
|
+
}
|
|
69
|
+
.resizer.horizontal {
|
|
70
|
+
width: 8px;
|
|
71
|
+
cursor: col-resize;
|
|
72
|
+
}
|
|
73
|
+
.resizer.vertical {
|
|
74
|
+
height: 8px;
|
|
75
|
+
cursor: row-resize;
|
|
76
|
+
width: 100%;
|
|
77
|
+
}
|
|
78
|
+
.resizer:hover,
|
|
79
|
+
.resizer.active {
|
|
80
|
+
background: rgba(26, 115, 232, 0.12);
|
|
81
|
+
}
|
|
82
|
+
.resizer::after {
|
|
83
|
+
content: "";
|
|
84
|
+
position: absolute;
|
|
85
|
+
background: #ccc;
|
|
86
|
+
transition: background 0.2s;
|
|
87
|
+
}
|
|
88
|
+
.resizer.horizontal::after {
|
|
89
|
+
left: 50%;
|
|
90
|
+
top: 0;
|
|
91
|
+
bottom: 0;
|
|
92
|
+
width: 14px;
|
|
93
|
+
transform: translateX(-50%);
|
|
94
|
+
}
|
|
95
|
+
.resizer.vertical::after {
|
|
96
|
+
top: 50%;
|
|
97
|
+
left: 0;
|
|
98
|
+
right: 0;
|
|
99
|
+
height: 14px;
|
|
100
|
+
transform: translateY(-50%);
|
|
101
|
+
}
|
|
102
|
+
.resizer:hover::after,
|
|
103
|
+
.resizer.active::after {
|
|
104
|
+
background: #1a73e8;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
#resizer-left {
|
|
108
|
+
margin-right: 5px;
|
|
109
|
+
}
|
|
110
|
+
#resizer-right {
|
|
111
|
+
margin-left: 5px;
|
|
112
|
+
}
|
|
113
|
+
#resizer-bottom {
|
|
114
|
+
margin-top: 5px;
|
|
115
|
+
}
|
|
116
|
+
</style>
|
|
117
|
+
<div class="flex">
|
|
118
|
+
<div class="side-div" id="left-div"></div>
|
|
119
|
+
<div class="resizer horizontal" id="resizer-left"></div>
|
|
120
|
+
<div class="center-column">
|
|
121
|
+
<div class="center-div" id="center-div">
|
|
122
|
+
<slot></slot>
|
|
123
|
+
</div>
|
|
124
|
+
<div class="resizer vertical" id="resizer-bottom"></div>
|
|
125
|
+
</div>
|
|
126
|
+
<div class="resizer horizontal" id="resizer-right"></div>
|
|
127
|
+
<div class="side-div" id="right-div"></div>
|
|
128
|
+
</div>
|
|
129
|
+
`;
|
|
130
|
+
}
|
|
131
|
+
static get observedAttributes() {
|
|
132
|
+
return SKIP_ATTRIBUTES.filter((attr) => !["id", "class"].includes(attr));
|
|
133
|
+
}
|
|
134
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
135
|
+
if (oldValue === newValue)
|
|
136
|
+
return;
|
|
137
|
+
if (!this.leftDiv)
|
|
138
|
+
return; // Not connected yet
|
|
139
|
+
switch (name) {
|
|
140
|
+
case "left":
|
|
141
|
+
this.leftDiv.style.width = newValue;
|
|
142
|
+
break;
|
|
143
|
+
case "center":
|
|
144
|
+
this.centerDiv.style.width = newValue;
|
|
145
|
+
break;
|
|
146
|
+
case "height":
|
|
147
|
+
this.centerDiv.style.height = newValue;
|
|
148
|
+
break;
|
|
149
|
+
case "style":
|
|
150
|
+
this.centerDiv.style.cssText = newValue;
|
|
151
|
+
this._applyInternalStylesToCenterDiv();
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
connectedCallback() {
|
|
156
|
+
this.leftDiv = this.shadowRoot.getElementById("left-div");
|
|
157
|
+
this.rightDiv = this.shadowRoot.getElementById("right-div");
|
|
158
|
+
this.centerDiv = this.shadowRoot.getElementById("center-div");
|
|
159
|
+
this.resizerLeft = this.shadowRoot.getElementById("resizer-left");
|
|
160
|
+
this.resizerRight = this.shadowRoot.getElementById("resizer-right");
|
|
161
|
+
this.resizerBottom = this.shadowRoot.getElementById("resizer-bottom");
|
|
162
|
+
const attrLeft = this.getAttribute("left");
|
|
163
|
+
const attrCenter = this.getAttribute("center");
|
|
164
|
+
const attrHeight = this.getAttribute("height");
|
|
165
|
+
if (attrLeft) {
|
|
166
|
+
this.leftDiv.style.width = attrLeft;
|
|
167
|
+
}
|
|
168
|
+
if (attrCenter) {
|
|
169
|
+
this.centerDiv.style.width = attrCenter;
|
|
170
|
+
}
|
|
171
|
+
if (attrHeight) {
|
|
172
|
+
this.centerDiv.style.height = attrHeight;
|
|
173
|
+
}
|
|
174
|
+
this.setupResizer(this.resizerLeft, this.leftDiv, "left", false);
|
|
175
|
+
this.setupResizer(this.resizerRight, this.centerDiv, "center", false);
|
|
176
|
+
this.setupHeightResizer(this.resizerBottom, this.centerDiv);
|
|
177
|
+
this._initForwarding();
|
|
178
|
+
}
|
|
179
|
+
_applyInternalStylesToCenterDiv() {
|
|
180
|
+
const center = this.getAttribute("center");
|
|
181
|
+
if (center)
|
|
182
|
+
this.centerDiv.style.width = center;
|
|
183
|
+
const height = this.getAttribute("height");
|
|
184
|
+
if (height)
|
|
185
|
+
this.centerDiv.style.height = height;
|
|
186
|
+
}
|
|
187
|
+
_initForwarding() {
|
|
188
|
+
const observer = new MutationObserver((mutations) => {
|
|
189
|
+
let syncNeeded = false;
|
|
190
|
+
for (const mutation of mutations) {
|
|
191
|
+
if (mutation.type === "attributes") {
|
|
192
|
+
if (!SKIP_ATTRIBUTES.includes(mutation.attributeName)) {
|
|
193
|
+
syncNeeded = true;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (syncNeeded)
|
|
199
|
+
this._syncAttributes();
|
|
200
|
+
});
|
|
201
|
+
observer.observe(this, { attributes: true });
|
|
202
|
+
this._syncAttributes();
|
|
203
|
+
}
|
|
204
|
+
_syncAttributes() {
|
|
205
|
+
for (const attr of Array.from(this.attributes)) {
|
|
206
|
+
if (SKIP_ATTRIBUTES.includes(attr.name))
|
|
207
|
+
continue;
|
|
208
|
+
this.centerDiv.setAttribute(attr.name, attr.value);
|
|
209
|
+
}
|
|
210
|
+
if (this.hasAttribute("style")) {
|
|
211
|
+
this.centerDiv.style.cssText = this.getAttribute("style") || "";
|
|
212
|
+
this._applyInternalStylesToCenterDiv();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
getContentRoot() {
|
|
216
|
+
return this.centerDiv || this.shadowRoot.getElementById("center-div");
|
|
217
|
+
}
|
|
218
|
+
setupResizer(handle, target, attrName, invert) {
|
|
219
|
+
handle.addEventListener("mousedown", (e) => {
|
|
220
|
+
e.preventDefault();
|
|
221
|
+
handle.classList.add("active");
|
|
222
|
+
const startX = e.clientX;
|
|
223
|
+
const startWidth = target.offsetWidth;
|
|
224
|
+
const onMouseMove = (moveEvent) => {
|
|
225
|
+
let diff = moveEvent.clientX - startX;
|
|
226
|
+
if (invert)
|
|
227
|
+
diff = -diff;
|
|
228
|
+
let newWidth = startWidth + diff;
|
|
229
|
+
newWidth = Math.max(0, newWidth);
|
|
230
|
+
target.style.width = newWidth + "px";
|
|
231
|
+
this.setAttribute(attrName, newWidth + "px");
|
|
232
|
+
const eventName = attrName === "left" ? "onLeft" : "onCenter";
|
|
233
|
+
this.dispatchEvent(new CustomEvent(eventName, { detail: { width: newWidth } }));
|
|
234
|
+
};
|
|
235
|
+
const onMouseUp = () => {
|
|
236
|
+
handle.classList.remove("active");
|
|
237
|
+
document.removeEventListener("mousemove", onMouseMove);
|
|
238
|
+
document.removeEventListener("mouseup", onMouseUp);
|
|
239
|
+
};
|
|
240
|
+
document.addEventListener("mousemove", onMouseMove);
|
|
241
|
+
document.addEventListener("mouseup", onMouseUp);
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
setupHeightResizer(handle, target) {
|
|
245
|
+
handle.addEventListener("mousedown", (e) => {
|
|
246
|
+
e.preventDefault();
|
|
247
|
+
handle.classList.add("active");
|
|
248
|
+
const startY = e.clientY;
|
|
249
|
+
const startHeight = target.offsetHeight;
|
|
250
|
+
const onMouseMove = (moveEvent) => {
|
|
251
|
+
const diff = moveEvent.clientY - startY;
|
|
252
|
+
let newHeight = startHeight + diff;
|
|
253
|
+
newHeight = Math.max(0, newHeight);
|
|
254
|
+
target.style.height = newHeight + "px";
|
|
255
|
+
this.setAttribute("height", newHeight + "px");
|
|
256
|
+
this.dispatchEvent(new CustomEvent("onHeight", { detail: { height: newHeight } }));
|
|
257
|
+
};
|
|
258
|
+
const onMouseUp = () => {
|
|
259
|
+
handle.classList.remove("active");
|
|
260
|
+
document.removeEventListener("mousemove", onMouseMove);
|
|
261
|
+
document.removeEventListener("mouseup", onMouseUp);
|
|
262
|
+
};
|
|
263
|
+
document.addEventListener("mousemove", onMouseMove);
|
|
264
|
+
document.addEventListener("mouseup", onMouseUp);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
customElements.define("center-and-height-resizer", CenterAndHeightResizer);
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <center-resizer
|
|
3
|
+
* left="50px"
|
|
4
|
+
* center="350px"
|
|
5
|
+
* style="padding: 12px;"
|
|
6
|
+
* data-test="idfortest"
|
|
7
|
+
* >
|
|
8
|
+
* <div>Content</div>
|
|
9
|
+
* </center-resizer>
|
|
10
|
+
*
|
|
11
|
+
* const resizer = document.querySelector('center-resizer');
|
|
12
|
+
* resizer.addEventListener('onLeft', e => console.log(e.detail.width));
|
|
13
|
+
* resizer.addEventListener('onCenter', e => console.log(e.detail.width));
|
|
14
|
+
*/
|
|
15
|
+
const SKIP_ATTRIBUTES = ["id", "class", "left", "center", "style"];
|
|
16
|
+
export class CenterResizer extends HTMLElement {
|
|
17
|
+
leftDiv;
|
|
18
|
+
centerDiv;
|
|
19
|
+
rightDiv;
|
|
20
|
+
resizerLeft;
|
|
21
|
+
resizerRight;
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.attachShadow({ mode: "open" });
|
|
25
|
+
this.shadowRoot.innerHTML = `
|
|
26
|
+
<style>
|
|
27
|
+
:host {
|
|
28
|
+
display: block;
|
|
29
|
+
width: 100%;
|
|
30
|
+
padding: 0 !important;
|
|
31
|
+
}
|
|
32
|
+
.flex {
|
|
33
|
+
display: flex;
|
|
34
|
+
width: 100%;
|
|
35
|
+
align-items: stretch;
|
|
36
|
+
}
|
|
37
|
+
.center-div {
|
|
38
|
+
flex-shrink: 0;
|
|
39
|
+
min-width: 0;
|
|
40
|
+
padding-left: 15px;
|
|
41
|
+
padding-right: 15px;
|
|
42
|
+
box-sizing: border-box;
|
|
43
|
+
}
|
|
44
|
+
.side-div {
|
|
45
|
+
flex-shrink: 0;
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
}
|
|
48
|
+
#right-div {
|
|
49
|
+
flex-grow: 1;
|
|
50
|
+
}
|
|
51
|
+
.resizer {
|
|
52
|
+
width: 8px;
|
|
53
|
+
cursor: col-resize;
|
|
54
|
+
flex-shrink: 0;
|
|
55
|
+
transition: background 0.2s;
|
|
56
|
+
user-select: none;
|
|
57
|
+
margin: 0 -4px;
|
|
58
|
+
position: relative;
|
|
59
|
+
}
|
|
60
|
+
.resizer:hover,
|
|
61
|
+
.resizer.active {
|
|
62
|
+
background: rgba(26, 115, 232, 0.2);
|
|
63
|
+
}
|
|
64
|
+
.resizer::after {
|
|
65
|
+
content: "";
|
|
66
|
+
position: absolute;
|
|
67
|
+
left: 50%;
|
|
68
|
+
top: 0;
|
|
69
|
+
bottom: 0;
|
|
70
|
+
width: 2px;
|
|
71
|
+
background: #ccc;
|
|
72
|
+
transform: translateX(-50%);
|
|
73
|
+
}
|
|
74
|
+
.resizer:hover::after,
|
|
75
|
+
.resizer.active::after {
|
|
76
|
+
background: #1a73e8;
|
|
77
|
+
}
|
|
78
|
+
</style>
|
|
79
|
+
<div class="flex">
|
|
80
|
+
<div class="side-div" id="left-div"></div>
|
|
81
|
+
<div class="resizer" id="resizer-left"></div>
|
|
82
|
+
<div class="center-div" id="center-div">
|
|
83
|
+
<slot></slot>
|
|
84
|
+
</div>
|
|
85
|
+
<div class="resizer" id="resizer-right"></div>
|
|
86
|
+
<div class="side-div" id="right-div"></div>
|
|
87
|
+
</div>
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
static get observedAttributes() {
|
|
91
|
+
return SKIP_ATTRIBUTES.filter((attr) => !["id", "class"].includes(attr));
|
|
92
|
+
}
|
|
93
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
94
|
+
if (oldValue === newValue)
|
|
95
|
+
return;
|
|
96
|
+
if (!this.centerDiv)
|
|
97
|
+
return;
|
|
98
|
+
switch (name) {
|
|
99
|
+
case "left":
|
|
100
|
+
this.leftDiv.style.width = newValue;
|
|
101
|
+
break;
|
|
102
|
+
case "center":
|
|
103
|
+
this.centerDiv.style.width = newValue;
|
|
104
|
+
break;
|
|
105
|
+
case "style":
|
|
106
|
+
this.centerDiv.style.cssText = newValue;
|
|
107
|
+
this._applyInternalStylesToCenterDiv();
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
connectedCallback() {
|
|
112
|
+
this.leftDiv = this.shadowRoot.getElementById("left-div");
|
|
113
|
+
this.centerDiv = this.shadowRoot.getElementById("center-div");
|
|
114
|
+
this.rightDiv = this.shadowRoot.getElementById("right-div");
|
|
115
|
+
this.resizerLeft = this.shadowRoot.getElementById("resizer-left");
|
|
116
|
+
this.resizerRight = this.shadowRoot.getElementById("resizer-right");
|
|
117
|
+
const attrLeft = this.getAttribute("left");
|
|
118
|
+
const attrCenter = this.getAttribute("center");
|
|
119
|
+
if (attrLeft) {
|
|
120
|
+
this.leftDiv.style.width = attrLeft;
|
|
121
|
+
}
|
|
122
|
+
if (attrCenter) {
|
|
123
|
+
this.centerDiv.style.width = attrCenter;
|
|
124
|
+
}
|
|
125
|
+
this.setupResizer(this.resizerLeft, this.leftDiv, "left");
|
|
126
|
+
this.setupResizer(this.resizerRight, this.centerDiv, "center");
|
|
127
|
+
this._initForwarding();
|
|
128
|
+
}
|
|
129
|
+
_applyInternalStylesToCenterDiv() {
|
|
130
|
+
const center = this.getAttribute("center");
|
|
131
|
+
if (center)
|
|
132
|
+
this.centerDiv.style.width = center;
|
|
133
|
+
}
|
|
134
|
+
_initForwarding() {
|
|
135
|
+
const observer = new MutationObserver((mutations) => {
|
|
136
|
+
let syncNeeded = false;
|
|
137
|
+
for (const mutation of mutations) {
|
|
138
|
+
if (mutation.type === "attributes") {
|
|
139
|
+
if (!SKIP_ATTRIBUTES.includes(mutation.attributeName)) {
|
|
140
|
+
syncNeeded = true;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (syncNeeded)
|
|
146
|
+
this._syncAttributes();
|
|
147
|
+
});
|
|
148
|
+
observer.observe(this, { attributes: true });
|
|
149
|
+
this._syncAttributes();
|
|
150
|
+
}
|
|
151
|
+
_syncAttributes() {
|
|
152
|
+
for (const attr of Array.from(this.attributes)) {
|
|
153
|
+
if (SKIP_ATTRIBUTES.includes(attr.name))
|
|
154
|
+
continue;
|
|
155
|
+
this.centerDiv.setAttribute(attr.name, attr.value);
|
|
156
|
+
}
|
|
157
|
+
if (this.hasAttribute("style")) {
|
|
158
|
+
this.centerDiv.style.cssText = this.getAttribute("style") || "";
|
|
159
|
+
this._applyInternalStylesToCenterDiv();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
getContentRoot() {
|
|
163
|
+
return this.centerDiv || this.shadowRoot.getElementById("center-div");
|
|
164
|
+
}
|
|
165
|
+
setupResizer(handle, target, attributeName) {
|
|
166
|
+
handle.addEventListener("mousedown", (e) => {
|
|
167
|
+
e.preventDefault();
|
|
168
|
+
handle.classList.add("active");
|
|
169
|
+
const startX = e.clientX;
|
|
170
|
+
const startWidth = target.offsetWidth;
|
|
171
|
+
const onMouseMove = (moveEvent) => {
|
|
172
|
+
let diff = moveEvent.clientX - startX;
|
|
173
|
+
let newWidth = startWidth + diff;
|
|
174
|
+
newWidth = Math.max(0, newWidth);
|
|
175
|
+
target.style.width = newWidth + "px";
|
|
176
|
+
if (attributeName === "center") {
|
|
177
|
+
this.setAttribute("center", newWidth + "px");
|
|
178
|
+
this.dispatchEvent(new CustomEvent("onCenter", { detail: { width: newWidth } }));
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
this.setAttribute("left", newWidth + "px");
|
|
182
|
+
this.dispatchEvent(new CustomEvent("onLeft", { detail: { width: newWidth } }));
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const onMouseUp = () => {
|
|
186
|
+
handle.classList.remove("active");
|
|
187
|
+
document.removeEventListener("mousemove", onMouseMove);
|
|
188
|
+
document.removeEventListener("mouseup", onMouseUp);
|
|
189
|
+
};
|
|
190
|
+
document.addEventListener("mousemove", onMouseMove);
|
|
191
|
+
document.addEventListener("mouseup", onMouseUp);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
customElements.define("center-resizer", CenterResizer);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class CenterAndHeightResizer extends HTMLElement {
|
|
2
|
+
leftDiv: HTMLElement;
|
|
3
|
+
rightDiv: HTMLElement;
|
|
4
|
+
centerDiv: HTMLElement;
|
|
5
|
+
resizerLeft: HTMLElement;
|
|
6
|
+
resizerRight: HTMLElement;
|
|
7
|
+
resizerBottom: HTMLElement;
|
|
8
|
+
constructor();
|
|
9
|
+
static get observedAttributes(): string[];
|
|
10
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
11
|
+
connectedCallback(): void;
|
|
12
|
+
_applyInternalStylesToCenterDiv(): void;
|
|
13
|
+
_initForwarding(): void;
|
|
14
|
+
_syncAttributes(): void;
|
|
15
|
+
getContentRoot(): HTMLElement;
|
|
16
|
+
setupResizer(handle: HTMLElement, target: HTMLElement, attrName: string, invert: boolean): void;
|
|
17
|
+
setupHeightResizer(handle: HTMLElement, target: HTMLElement): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class CenterResizer extends HTMLElement {
|
|
2
|
+
leftDiv: HTMLElement;
|
|
3
|
+
centerDiv: HTMLElement;
|
|
4
|
+
rightDiv: HTMLElement;
|
|
5
|
+
resizerLeft: HTMLElement;
|
|
6
|
+
resizerRight: HTMLElement;
|
|
7
|
+
constructor();
|
|
8
|
+
static get observedAttributes(): string[];
|
|
9
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
10
|
+
connectedCallback(): void;
|
|
11
|
+
_applyInternalStylesToCenterDiv(): void;
|
|
12
|
+
_initForwarding(): void;
|
|
13
|
+
_syncAttributes(): void;
|
|
14
|
+
getContentRoot(): HTMLElement;
|
|
15
|
+
setupResizer(handle: HTMLElement, target: HTMLElement, attributeName: "left" | "center"): void;
|
|
16
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../CenterAndHeightResizer.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../CenterAndHeightResizer.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../CenterAndHeightResizer.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../CenterAndHeightResizer.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../CenterAndHeightResizer.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../CenterAndHeightResizer.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../CenterResizer.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../CenterResizer.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../CenterResizer.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../CenterResizer.js";
|
package/dist/types/selected-section/SelectedSectionManagerWebComponent.nocssrequest.html.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../CenterResizer.js";
|