composite-select 1.0.9 → 1.0.10

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 (43) hide show
  1. package/dist/cjs/CenterAndHeightResizer.cjs +268 -0
  2. package/dist/cjs/CenterResizer.cjs +195 -0
  3. package/dist/cjs/composite-select/ContainerManager.html.cjs +650 -0
  4. package/dist/cjs/composite-select/composite-select.html.cjs +651 -0
  5. package/dist/cjs/options-section/OptionsSectionManager.html.cjs +362 -0
  6. package/dist/cjs/options-section/OptionsSectionManagerWebComponent.attributes.html.cjs +346 -0
  7. package/dist/cjs/options-section/OptionsSectionManagerWebComponent.html.cjs +354 -0
  8. package/dist/cjs/options-section/OptionsSectionManagerWebComponent.nocssrequest.html.cjs +345 -0
  9. package/dist/cjs/selected-section/SelectedSectionManager.html.cjs +336 -0
  10. package/dist/cjs/selected-section/SelectedSectionManager.templates.html.cjs +353 -0
  11. package/dist/cjs/selected-section/SelectedSectionManagerWebComponent.attributes.html.cjs +353 -0
  12. package/dist/cjs/selected-section/SelectedSectionManagerWebComponent.html.cjs +335 -0
  13. package/dist/cjs/selected-section/SelectedSectionManagerWebComponent.nocssrequest.html.cjs +341 -0
  14. package/dist/esm/CenterAndHeightResizer.js +268 -0
  15. package/dist/esm/CenterResizer.js +195 -0
  16. package/dist/types/CenterAndHeightResizer.d.ts +18 -0
  17. package/dist/types/CenterResizer.d.ts +16 -0
  18. package/dist/types/composite-select/ContainerManager.html.d.ts +1 -1
  19. package/dist/types/composite-select/composite-select.html.d.ts +1 -1
  20. package/dist/types/options-section/OptionsSectionManager.html.d.ts +1 -1
  21. package/dist/types/options-section/OptionsSectionManagerWebComponent.attributes.html.d.ts +1 -1
  22. package/dist/types/options-section/OptionsSectionManagerWebComponent.html.d.ts +1 -1
  23. package/dist/types/options-section/OptionsSectionManagerWebComponent.nocssrequest.html.d.ts +1 -1
  24. package/dist/types/selected-section/SelectedSectionManager.html.d.ts +1 -1
  25. package/dist/types/selected-section/SelectedSectionManager.templates.html.d.ts +1 -1
  26. package/dist/types/selected-section/SelectedSectionManagerWebComponent.attributes.html.d.ts +1 -1
  27. package/dist/types/selected-section/SelectedSectionManagerWebComponent.html.d.ts +1 -1
  28. package/package.json +1 -1
  29. package/js/CenterAndHeightResizer.js +0 -263
  30. package/js/CenterResizer.js +0 -190
  31. /package/dist/cjs/composite-select/{CompositeManager.js → CompositeManager.cjs} +0 -0
  32. /package/dist/cjs/composite-select/{composite-select.js → composite-select.cjs} +0 -0
  33. /package/dist/cjs/composite-select/{debounce.js → debounce.cjs} +0 -0
  34. /package/dist/cjs/composite-select/{helpers.js → helpers.cjs} +0 -0
  35. /package/dist/cjs/composite-select/{react.js → react.cjs} +0 -0
  36. /package/dist/cjs/container/{ContainerManager.js → ContainerManager.cjs} +0 -0
  37. /package/dist/cjs/options-section/{OptionsSectionManager.js → OptionsSectionManager.cjs} +0 -0
  38. /package/dist/cjs/options-section/{options-section.js → options-section.cjs} +0 -0
  39. /package/dist/cjs/options-section/{react.js → react.cjs} +0 -0
  40. /package/dist/cjs/selected-section/{SelectedSectionManager.js → SelectedSectionManager.cjs} +0 -0
  41. /package/dist/cjs/selected-section/{react.js → react.cjs} +0 -0
  42. /package/dist/cjs/selected-section/{selected-section.js → selected-section.cjs} +0 -0
  43. /package/dist/cjs/unbind/{clickOutside.js → clickOutside.cjs} +0 -0
@@ -1,263 +0,0 @@
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
- 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) return;
136
- if (!this.leftDiv) return;
137
- // Not connected yet
138
- switch (name) {
139
- case "left":
140
- this.leftDiv.style.width = newValue;
141
- break;
142
- case "center":
143
- this.centerDiv.style.width = newValue;
144
- break;
145
- case "height":
146
- this.centerDiv.style.height = newValue;
147
- break;
148
- case "style":
149
- this.centerDiv.style.cssText = newValue;
150
- this._applyInternalStylesToCenterDiv();
151
- break;
152
- }
153
- }
154
- connectedCallback() {
155
- this.leftDiv = this.shadowRoot.getElementById("left-div");
156
- this.rightDiv = this.shadowRoot.getElementById("right-div");
157
- this.centerDiv = this.shadowRoot.getElementById("center-div");
158
- this.resizerLeft = this.shadowRoot.getElementById("resizer-left");
159
- this.resizerRight = this.shadowRoot.getElementById("resizer-right");
160
- this.resizerBottom = this.shadowRoot.getElementById("resizer-bottom");
161
- const attrLeft = this.getAttribute("left");
162
- const attrCenter = this.getAttribute("center");
163
- const attrHeight = this.getAttribute("height");
164
- if (attrLeft) {
165
- this.leftDiv.style.width = attrLeft;
166
- }
167
- if (attrCenter) {
168
- this.centerDiv.style.width = attrCenter;
169
- }
170
- if (attrHeight) {
171
- this.centerDiv.style.height = attrHeight;
172
- }
173
- this.setupResizer(this.resizerLeft, this.leftDiv, "left", false);
174
- this.setupResizer(this.resizerRight, this.centerDiv, "center", false);
175
- this.setupHeightResizer(this.resizerBottom, this.centerDiv);
176
- this._initForwarding();
177
- }
178
- _applyInternalStylesToCenterDiv() {
179
- const center = this.getAttribute("center");
180
- if (center) this.centerDiv.style.width = center;
181
- const height = this.getAttribute("height");
182
- if (height) this.centerDiv.style.height = height;
183
- }
184
- _initForwarding() {
185
- const observer = new MutationObserver((mutations) => {
186
- let syncNeeded = false;
187
- for (const mutation of mutations) {
188
- if (mutation.type === "attributes") {
189
- if (!SKIP_ATTRIBUTES.includes(mutation.attributeName)) {
190
- syncNeeded = true;
191
- break;
192
- }
193
- }
194
- }
195
- if (syncNeeded) this._syncAttributes();
196
- });
197
- observer.observe(this, { attributes: true });
198
- this._syncAttributes();
199
- }
200
- _syncAttributes() {
201
- for (const attr of Array.from(this.attributes)) {
202
- if (SKIP_ATTRIBUTES.includes(attr.name)) continue;
203
- this.centerDiv.setAttribute(attr.name, attr.value);
204
- }
205
- if (this.hasAttribute("style")) {
206
- this.centerDiv.style.cssText = this.getAttribute("style") || "";
207
- this._applyInternalStylesToCenterDiv();
208
- }
209
- }
210
- getContentRoot() {
211
- return this.centerDiv || this.shadowRoot.getElementById("center-div");
212
- }
213
- setupResizer(handle, target, attrName, invert) {
214
- handle.addEventListener("mousedown", (e) => {
215
- e.preventDefault();
216
- handle.classList.add("active");
217
- const startX = e.clientX;
218
- const startWidth = target.offsetWidth;
219
- const onMouseMove = (moveEvent) => {
220
- let diff = moveEvent.clientX - startX;
221
- if (invert) diff = -diff;
222
- let newWidth = startWidth + diff;
223
- newWidth = Math.max(0, newWidth);
224
- target.style.width = newWidth + "px";
225
- this.setAttribute(attrName, newWidth + "px");
226
- const eventName = attrName === "left" ? "onLeft" : "onCenter";
227
- this.dispatchEvent(new CustomEvent(eventName, { detail: { width: newWidth } }));
228
- };
229
- const onMouseUp = () => {
230
- handle.classList.remove("active");
231
- document.removeEventListener("mousemove", onMouseMove);
232
- document.removeEventListener("mouseup", onMouseUp);
233
- };
234
- document.addEventListener("mousemove", onMouseMove);
235
- document.addEventListener("mouseup", onMouseUp);
236
- });
237
- }
238
- setupHeightResizer(handle, target) {
239
- handle.addEventListener("mousedown", (e) => {
240
- e.preventDefault();
241
- handle.classList.add("active");
242
- const startY = e.clientY;
243
- const startHeight = target.offsetHeight;
244
- const onMouseMove = (moveEvent) => {
245
- const diff = moveEvent.clientY - startY;
246
- let newHeight = startHeight + diff;
247
- newHeight = Math.max(0, newHeight);
248
- target.style.height = newHeight + "px";
249
- this.setAttribute("height", newHeight + "px");
250
- this.dispatchEvent(new CustomEvent("onHeight", { detail: { height: newHeight } }));
251
- };
252
- const onMouseUp = () => {
253
- handle.classList.remove("active");
254
- document.removeEventListener("mousemove", onMouseMove);
255
- document.removeEventListener("mouseup", onMouseUp);
256
- };
257
- document.addEventListener("mousemove", onMouseMove);
258
- document.addEventListener("mouseup", onMouseUp);
259
- });
260
- }
261
- }
262
- customElements.define("center-and-height-resizer", CenterAndHeightResizer);
263
- export { CenterAndHeightResizer };
@@ -1,190 +0,0 @@
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
- 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) return;
95
- if (!this.centerDiv) return;
96
- switch (name) {
97
- case "left":
98
- this.leftDiv.style.width = newValue;
99
- break;
100
- case "center":
101
- this.centerDiv.style.width = newValue;
102
- break;
103
- case "style":
104
- this.centerDiv.style.cssText = newValue;
105
- this._applyInternalStylesToCenterDiv();
106
- break;
107
- }
108
- }
109
- connectedCallback() {
110
- this.leftDiv = this.shadowRoot.getElementById("left-div");
111
- this.centerDiv = this.shadowRoot.getElementById("center-div");
112
- this.rightDiv = this.shadowRoot.getElementById("right-div");
113
- this.resizerLeft = this.shadowRoot.getElementById("resizer-left");
114
- this.resizerRight = this.shadowRoot.getElementById("resizer-right");
115
- const attrLeft = this.getAttribute("left");
116
- const attrCenter = this.getAttribute("center");
117
- if (attrLeft) {
118
- this.leftDiv.style.width = attrLeft;
119
- }
120
- if (attrCenter) {
121
- this.centerDiv.style.width = attrCenter;
122
- }
123
- this.setupResizer(this.resizerLeft, this.leftDiv, "left");
124
- this.setupResizer(this.resizerRight, this.centerDiv, "center");
125
- this._initForwarding();
126
- }
127
- _applyInternalStylesToCenterDiv() {
128
- const center = this.getAttribute("center");
129
- if (center) this.centerDiv.style.width = center;
130
- }
131
- _initForwarding() {
132
- const observer = new MutationObserver((mutations) => {
133
- let syncNeeded = false;
134
- for (const mutation of mutations) {
135
- if (mutation.type === "attributes") {
136
- if (!SKIP_ATTRIBUTES.includes(mutation.attributeName)) {
137
- syncNeeded = true;
138
- break;
139
- }
140
- }
141
- }
142
- if (syncNeeded) this._syncAttributes();
143
- });
144
- observer.observe(this, { attributes: true });
145
- this._syncAttributes();
146
- }
147
- _syncAttributes() {
148
- for (const attr of Array.from(this.attributes)) {
149
- if (SKIP_ATTRIBUTES.includes(attr.name)) continue;
150
- this.centerDiv.setAttribute(attr.name, attr.value);
151
- }
152
- if (this.hasAttribute("style")) {
153
- this.centerDiv.style.cssText = this.getAttribute("style") || "";
154
- this._applyInternalStylesToCenterDiv();
155
- }
156
- }
157
- getContentRoot() {
158
- return this.centerDiv || this.shadowRoot.getElementById("center-div");
159
- }
160
- setupResizer(handle, target, attributeName) {
161
- handle.addEventListener("mousedown", (e) => {
162
- e.preventDefault();
163
- handle.classList.add("active");
164
- const startX = e.clientX;
165
- const startWidth = target.offsetWidth;
166
- const onMouseMove = (moveEvent) => {
167
- let diff = moveEvent.clientX - startX;
168
- let newWidth = startWidth + diff;
169
- newWidth = Math.max(0, newWidth);
170
- target.style.width = newWidth + "px";
171
- if (attributeName === "center") {
172
- this.setAttribute("center", newWidth + "px");
173
- this.dispatchEvent(new CustomEvent("onCenter", { detail: { width: newWidth } }));
174
- } else {
175
- this.setAttribute("left", newWidth + "px");
176
- this.dispatchEvent(new CustomEvent("onLeft", { detail: { width: newWidth } }));
177
- }
178
- };
179
- const onMouseUp = () => {
180
- handle.classList.remove("active");
181
- document.removeEventListener("mousemove", onMouseMove);
182
- document.removeEventListener("mouseup", onMouseUp);
183
- };
184
- document.addEventListener("mousemove", onMouseMove);
185
- document.addEventListener("mouseup", onMouseUp);
186
- });
187
- }
188
- }
189
- customElements.define("center-resizer", CenterResizer);
190
- export { CenterResizer };