@schukai/monster 4.137.9 → 4.139.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/package.json +1 -1
- package/source/components/form/button-bar.mjs +7 -1056
- package/source/components/form/control-bar.mjs +1437 -0
- package/source/components/form/style/button.pcss +10 -2
- package/source/components/form/style/control-bar.pcss +146 -0
- package/source/components/form/style/input-group.pcss +5 -0
- package/source/components/form/style/select.pcss +10 -5
- package/source/components/form/stylesheet/button.mjs +1 -1
- package/source/components/form/stylesheet/control-bar.mjs +38 -0
- package/source/components/form/stylesheet/input-group.mjs +1 -1
- package/source/components/form/stylesheet/select.mjs +1 -1
- package/source/monster.mjs +1 -0
- package/test/cases/components/form/button-bar.mjs +14 -0
- package/test/cases/components/form/button.mjs +11 -1
- package/test/cases/components/form/control-bar.mjs +410 -0
- package/test/cases/components/form/input-group.mjs +37 -0
- package/test/cases/components/form/select.mjs +12 -0
package/source/monster.mjs
CHANGED
|
@@ -92,6 +92,7 @@ export * from "./components/form/context-success.mjs";
|
|
|
92
92
|
export * from "./components/form/types/state.mjs";
|
|
93
93
|
export * from "./components/form/template.mjs";
|
|
94
94
|
export * from "./components/form/constants.mjs";
|
|
95
|
+
export * from "./components/form/control-bar.mjs";
|
|
95
96
|
export * from "./components/notify/monitor-attribute-errors.mjs";
|
|
96
97
|
export * from "./components/notify/message.mjs";
|
|
97
98
|
export * from "./components/notify/notify.mjs";
|
|
@@ -17,6 +17,7 @@ const html = `
|
|
|
17
17
|
`;
|
|
18
18
|
|
|
19
19
|
let ButtonBar;
|
|
20
|
+
let ControlBar;
|
|
20
21
|
|
|
21
22
|
describe("ButtonBar", function () {
|
|
22
23
|
before(function (done) {
|
|
@@ -26,6 +27,10 @@ describe("ButtonBar", function () {
|
|
|
26
27
|
import("../../../../source/components/form/button-bar.mjs")
|
|
27
28
|
.then((m) => {
|
|
28
29
|
ButtonBar = m.ButtonBar;
|
|
30
|
+
return import("../../../../source/components/form/control-bar.mjs");
|
|
31
|
+
})
|
|
32
|
+
.then((m) => {
|
|
33
|
+
ControlBar = m.ControlBar;
|
|
29
34
|
done();
|
|
30
35
|
})
|
|
31
36
|
.catch((e) => done(e));
|
|
@@ -48,6 +53,15 @@ describe("ButtonBar", function () {
|
|
|
48
53
|
expect(bar).to.be.instanceof(ButtonBar);
|
|
49
54
|
});
|
|
50
55
|
|
|
56
|
+
it("should inherit the generic control bar behavior", function () {
|
|
57
|
+
const bar = document.getElementById("bar");
|
|
58
|
+
|
|
59
|
+
expect(bar).to.be.instanceof(ControlBar);
|
|
60
|
+
expect(bar.hideDialog).to.be.a("function");
|
|
61
|
+
expect(bar.showDialog).to.be.a("function");
|
|
62
|
+
expect(bar.toggleDialog).to.be.a("function");
|
|
63
|
+
});
|
|
64
|
+
|
|
51
65
|
it("should keep the popper switch hidden when no buttons are slotted", function (done) {
|
|
52
66
|
const bar = document.getElementById("bar");
|
|
53
67
|
|
|
@@ -117,7 +117,17 @@ describe('Button', function () {
|
|
|
117
117
|
|
|
118
118
|
|
|
119
119
|
});
|
|
120
|
+
|
|
121
|
+
it('should allow the internal button to stretch to the host height', function () {
|
|
122
|
+
const cssText = Button.getCSSStyleSheet()
|
|
123
|
+
.flatMap((styleSheet) => Array.from(styleSheet.cssRules))
|
|
124
|
+
.map((rule) => rule.cssText)
|
|
125
|
+
.join("\n");
|
|
126
|
+
|
|
127
|
+
expect(cssText).to.contain("height: 100%");
|
|
128
|
+
expect(cssText).to.contain("box-sizing: border-box");
|
|
129
|
+
});
|
|
120
130
|
});
|
|
121
131
|
|
|
122
132
|
|
|
123
|
-
});
|
|
133
|
+
});
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
import * as chai from "chai";
|
|
2
|
+
import { chaiDom } from "../../../util/chai-dom.mjs";
|
|
3
|
+
import { initJSDOM } from "../../../util/jsdom.mjs";
|
|
4
|
+
import { ResizeObserverMock } from "../../../util/resize-observer.mjs";
|
|
5
|
+
|
|
6
|
+
let expect = chai.expect;
|
|
7
|
+
chai.use(chaiDom);
|
|
8
|
+
|
|
9
|
+
const html = `
|
|
10
|
+
<div id="test1">
|
|
11
|
+
<monster-control-bar id="bar">
|
|
12
|
+
<input id="query" type="search">
|
|
13
|
+
<select id="mode"><option>All</option></select>
|
|
14
|
+
<button id="apply">Apply</button>
|
|
15
|
+
</monster-control-bar>
|
|
16
|
+
<monster-control-bar
|
|
17
|
+
id="bar-right"
|
|
18
|
+
data-monster-option-layout-alignment="right"
|
|
19
|
+
></monster-control-bar>
|
|
20
|
+
</div>
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
let ControlBar;
|
|
24
|
+
|
|
25
|
+
describe("ControlBar", function () {
|
|
26
|
+
before(function (done) {
|
|
27
|
+
this.timeout(5000);
|
|
28
|
+
initJSDOM()
|
|
29
|
+
.then(() => {
|
|
30
|
+
import("../../../../source/components/form/control-bar.mjs")
|
|
31
|
+
.then((m) => {
|
|
32
|
+
ControlBar = m.ControlBar;
|
|
33
|
+
done();
|
|
34
|
+
})
|
|
35
|
+
.catch((e) => done(e));
|
|
36
|
+
})
|
|
37
|
+
.catch((e) => done(e));
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
const mocks = document.getElementById("mocks");
|
|
42
|
+
mocks.innerHTML = html;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
const mocks = document.getElementById("mocks");
|
|
47
|
+
mocks.innerHTML = "";
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("should create a control bar element", function () {
|
|
51
|
+
const bar = document.getElementById("bar");
|
|
52
|
+
expect(bar).to.be.instanceof(ControlBar);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("should keep the popper switch hidden when no controls are slotted", function (done) {
|
|
56
|
+
const bar = document.getElementById("bar-right");
|
|
57
|
+
|
|
58
|
+
setTimeout(() => {
|
|
59
|
+
try {
|
|
60
|
+
const switchButton = bar.shadowRoot.querySelector(
|
|
61
|
+
'[data-monster-role="switch"]',
|
|
62
|
+
);
|
|
63
|
+
expect(switchButton).to.be.instanceof(HTMLButtonElement);
|
|
64
|
+
expect(switchButton.hasAttribute("hidden")).to.be.true;
|
|
65
|
+
expect(switchButton.classList.contains("hidden")).to.be.true;
|
|
66
|
+
done();
|
|
67
|
+
} catch (e) {
|
|
68
|
+
done(e);
|
|
69
|
+
}
|
|
70
|
+
}, 50);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("should default the control bar layout alignment to left", function () {
|
|
74
|
+
const bar = document.getElementById("bar");
|
|
75
|
+
const controlBar = bar.shadowRoot.querySelector(
|
|
76
|
+
'[data-monster-role="control-bar"]',
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
expect(controlBar.getAttribute("data-monster-layout-alignment")).to.equal(
|
|
80
|
+
"left",
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("should allow configuring the control bar layout alignment to right", function (done) {
|
|
85
|
+
const bar = document.getElementById("bar-right");
|
|
86
|
+
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
try {
|
|
89
|
+
const controlBar = bar.shadowRoot.querySelector(
|
|
90
|
+
'[data-monster-role="control-bar"]',
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
expect(
|
|
94
|
+
controlBar.getAttribute("data-monster-layout-alignment"),
|
|
95
|
+
).to.equal("right");
|
|
96
|
+
done();
|
|
97
|
+
} catch (e) {
|
|
98
|
+
done(e);
|
|
99
|
+
}
|
|
100
|
+
}, 50);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("should map popper position attributes to the popper placement option", function () {
|
|
104
|
+
const bar = document.getElementById("bar");
|
|
105
|
+
|
|
106
|
+
bar.setAttribute("data-monster-popper-position", "bottom");
|
|
107
|
+
|
|
108
|
+
expect(bar.getOption("popper.placement")).to.equal("bottom");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("should render mixed controls with joined heights and popper layout styles", function () {
|
|
112
|
+
const cssText = ControlBar.getCSSStyleSheet()
|
|
113
|
+
.flatMap((styleSheet) => Array.from(styleSheet.cssRules))
|
|
114
|
+
.map((rule) => rule.cssText)
|
|
115
|
+
.join("\n");
|
|
116
|
+
|
|
117
|
+
expect(cssText).to.contain("--monster-control-bar-height");
|
|
118
|
+
expect(cssText).to.contain("slot[name=popper]");
|
|
119
|
+
expect(cssText).to.contain("align-items: stretch");
|
|
120
|
+
expect(cssText).to.contain("::slotted(*) { display: flex");
|
|
121
|
+
expect(cssText).to.contain("::slotted(form)");
|
|
122
|
+
expect(cssText).to.contain("height: var(--monster-control-bar-height)");
|
|
123
|
+
expect(cssText).to.contain(
|
|
124
|
+
"border-width: var(--monster-theme-control-border-width",
|
|
125
|
+
);
|
|
126
|
+
expect(cssText).to.contain("appearance: none");
|
|
127
|
+
expect(cssText).to.contain("--monster-select-container-overflow: hidden");
|
|
128
|
+
expect(cssText).to.contain("::slotted(monster-input-group)");
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("should join adjacent borders using the smaller computed border width", async function () {
|
|
132
|
+
const originalRequestAnimationFrame = window.requestAnimationFrame;
|
|
133
|
+
const originalGlobalRequestAnimationFrame = globalThis.requestAnimationFrame;
|
|
134
|
+
|
|
135
|
+
const scheduledCallbacks = [];
|
|
136
|
+
const flushFrames = async () => {
|
|
137
|
+
while (scheduledCallbacks.length > 0) {
|
|
138
|
+
scheduledCallbacks.shift()();
|
|
139
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
try {
|
|
144
|
+
window.requestAnimationFrame = (callback) => {
|
|
145
|
+
scheduledCallbacks.push(callback);
|
|
146
|
+
return scheduledCallbacks.length;
|
|
147
|
+
};
|
|
148
|
+
globalThis.requestAnimationFrame = window.requestAnimationFrame;
|
|
149
|
+
|
|
150
|
+
const mocks = document.getElementById("mocks");
|
|
151
|
+
mocks.innerHTML = `
|
|
152
|
+
<div id="border-bar-wrapper">
|
|
153
|
+
<monster-control-bar id="border-bar">
|
|
154
|
+
<button id="wide-small-a">A</button>
|
|
155
|
+
<input id="wide-small-b">
|
|
156
|
+
<select id="small-small-c"><option>C</option></select>
|
|
157
|
+
<button id="wide-wide-d">D</button>
|
|
158
|
+
</monster-control-bar>
|
|
159
|
+
</div>
|
|
160
|
+
`;
|
|
161
|
+
|
|
162
|
+
const wrapper = document.getElementById("border-bar-wrapper");
|
|
163
|
+
const controls = [
|
|
164
|
+
document.getElementById("wide-small-a"),
|
|
165
|
+
document.getElementById("wide-small-b"),
|
|
166
|
+
document.getElementById("small-small-c"),
|
|
167
|
+
document.getElementById("wide-wide-d"),
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
wrapper.style.boxSizing = "border-box";
|
|
171
|
+
wrapper.style.width = "300px";
|
|
172
|
+
Object.defineProperty(wrapper, "clientWidth", {
|
|
173
|
+
configurable: true,
|
|
174
|
+
value: 300,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
for (const control of controls) {
|
|
178
|
+
Object.defineProperty(control, "offsetWidth", {
|
|
179
|
+
configurable: true,
|
|
180
|
+
value: 40,
|
|
181
|
+
});
|
|
182
|
+
Object.defineProperty(control, "offsetHeight", {
|
|
183
|
+
configurable: true,
|
|
184
|
+
value: 30,
|
|
185
|
+
});
|
|
186
|
+
control.getBoundingClientRect = () => ({
|
|
187
|
+
width: 40,
|
|
188
|
+
height: 30,
|
|
189
|
+
top: 0,
|
|
190
|
+
right: 40,
|
|
191
|
+
bottom: 30,
|
|
192
|
+
left: 0,
|
|
193
|
+
x: 0,
|
|
194
|
+
y: 0,
|
|
195
|
+
toJSON: () => {},
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
controls[0].style.borderRightWidth = "3px";
|
|
200
|
+
controls[1].style.borderLeftWidth = "2px";
|
|
201
|
+
controls[1].style.borderRightWidth = "2px";
|
|
202
|
+
controls[2].style.borderLeftWidth = "2px";
|
|
203
|
+
controls[2].style.borderRightWidth = "3px";
|
|
204
|
+
controls[3].style.borderLeftWidth = "3px";
|
|
205
|
+
|
|
206
|
+
await flushFrames();
|
|
207
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
208
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
209
|
+
|
|
210
|
+
expect(controls[1].style.marginLeft).to.equal("-2px");
|
|
211
|
+
expect(controls[2].style.marginLeft).to.equal("-2px");
|
|
212
|
+
expect(controls[3].style.marginLeft).to.equal("-3px");
|
|
213
|
+
} finally {
|
|
214
|
+
window.requestAnimationFrame = originalRequestAnimationFrame;
|
|
215
|
+
globalThis.requestAnimationFrame = originalGlobalRequestAnimationFrame;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it("should join borders against visible controls inside wrapper elements", async function () {
|
|
220
|
+
const originalRequestAnimationFrame = window.requestAnimationFrame;
|
|
221
|
+
const originalGlobalRequestAnimationFrame = globalThis.requestAnimationFrame;
|
|
222
|
+
|
|
223
|
+
const scheduledCallbacks = [];
|
|
224
|
+
const flushFrames = async () => {
|
|
225
|
+
while (scheduledCallbacks.length > 0) {
|
|
226
|
+
scheduledCallbacks.shift()();
|
|
227
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
try {
|
|
232
|
+
window.requestAnimationFrame = (callback) => {
|
|
233
|
+
scheduledCallbacks.push(callback);
|
|
234
|
+
return scheduledCallbacks.length;
|
|
235
|
+
};
|
|
236
|
+
globalThis.requestAnimationFrame = window.requestAnimationFrame;
|
|
237
|
+
|
|
238
|
+
const mocks = document.getElementById("mocks");
|
|
239
|
+
mocks.innerHTML = `
|
|
240
|
+
<div id="wrapped-border-bar-wrapper">
|
|
241
|
+
<monster-control-bar id="wrapped-border-bar">
|
|
242
|
+
<button id="wrapped-border-a">A</button>
|
|
243
|
+
<form id="wrapped-border-form">
|
|
244
|
+
<div id="wrapped-border-b" data-monster-role="control"></div>
|
|
245
|
+
<monster-input-group id="wrapped-input-group"></monster-input-group>
|
|
246
|
+
</form>
|
|
247
|
+
</monster-control-bar>
|
|
248
|
+
</div>
|
|
249
|
+
`;
|
|
250
|
+
|
|
251
|
+
const wrapper = document.getElementById("wrapped-border-bar-wrapper");
|
|
252
|
+
const button = document.getElementById("wrapped-border-a");
|
|
253
|
+
const form = document.getElementById("wrapped-border-form");
|
|
254
|
+
const innerControl = document.getElementById("wrapped-border-b");
|
|
255
|
+
const inputGroup = document.getElementById("wrapped-input-group");
|
|
256
|
+
|
|
257
|
+
wrapper.style.boxSizing = "border-box";
|
|
258
|
+
wrapper.style.width = "300px";
|
|
259
|
+
Object.defineProperty(wrapper, "clientWidth", {
|
|
260
|
+
configurable: true,
|
|
261
|
+
value: 300,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
for (const control of [button, form]) {
|
|
265
|
+
Object.defineProperty(control, "offsetWidth", {
|
|
266
|
+
configurable: true,
|
|
267
|
+
value: 40,
|
|
268
|
+
});
|
|
269
|
+
Object.defineProperty(control, "offsetHeight", {
|
|
270
|
+
configurable: true,
|
|
271
|
+
value: 30,
|
|
272
|
+
});
|
|
273
|
+
control.getBoundingClientRect = () => ({
|
|
274
|
+
width: 40,
|
|
275
|
+
height: 30,
|
|
276
|
+
top: 0,
|
|
277
|
+
right: 40,
|
|
278
|
+
bottom: 30,
|
|
279
|
+
left: 0,
|
|
280
|
+
x: 0,
|
|
281
|
+
y: 0,
|
|
282
|
+
toJSON: () => {},
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
button.style.borderRightWidth = "3px";
|
|
287
|
+
innerControl.style.borderLeftWidth = "2px";
|
|
288
|
+
|
|
289
|
+
await flushFrames();
|
|
290
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
291
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
292
|
+
|
|
293
|
+
expect(form.style.marginLeft).to.equal("-2px");
|
|
294
|
+
expect(form.style.display).to.equal("flex");
|
|
295
|
+
expect(inputGroup.style.height).to.equal("100%");
|
|
296
|
+
expect(inputGroup.style.boxSizing).to.equal("border-box");
|
|
297
|
+
expect(inputGroup.style.flex).to.equal("1 1 auto");
|
|
298
|
+
} finally {
|
|
299
|
+
window.requestAnimationFrame = originalRequestAnimationFrame;
|
|
300
|
+
globalThis.requestAnimationFrame = originalGlobalRequestAnimationFrame;
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it("should move overflowing mixed controls into the popper", async function () {
|
|
305
|
+
const OriginalResizeObserver = window.ResizeObserver;
|
|
306
|
+
const originalGlobalResizeObserver = globalThis.ResizeObserver;
|
|
307
|
+
const originalRequestAnimationFrame = window.requestAnimationFrame;
|
|
308
|
+
const originalGlobalRequestAnimationFrame = globalThis.requestAnimationFrame;
|
|
309
|
+
|
|
310
|
+
class TrackingResizeObserver extends ResizeObserverMock {
|
|
311
|
+
static instances = [];
|
|
312
|
+
|
|
313
|
+
constructor(callback) {
|
|
314
|
+
super(callback);
|
|
315
|
+
TrackingResizeObserver.instances.push(this);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const scheduledCallbacks = [];
|
|
320
|
+
const flushFrames = async () => {
|
|
321
|
+
while (scheduledCallbacks.length > 0) {
|
|
322
|
+
scheduledCallbacks.shift()();
|
|
323
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
try {
|
|
328
|
+
window.ResizeObserver = TrackingResizeObserver;
|
|
329
|
+
globalThis.ResizeObserver = TrackingResizeObserver;
|
|
330
|
+
window.requestAnimationFrame = (callback) => {
|
|
331
|
+
scheduledCallbacks.push(callback);
|
|
332
|
+
return scheduledCallbacks.length;
|
|
333
|
+
};
|
|
334
|
+
globalThis.requestAnimationFrame = window.requestAnimationFrame;
|
|
335
|
+
|
|
336
|
+
const mocks = document.getElementById("mocks");
|
|
337
|
+
mocks.innerHTML = `
|
|
338
|
+
<div id="control-bar-wrapper">
|
|
339
|
+
<monster-control-bar id="overflow-bar">
|
|
340
|
+
<input id="overflow-input" type="search">
|
|
341
|
+
<select id="overflow-select"><option>One</option></select>
|
|
342
|
+
<button id="overflow-button">Run</button>
|
|
343
|
+
</monster-control-bar>
|
|
344
|
+
</div>
|
|
345
|
+
`;
|
|
346
|
+
|
|
347
|
+
const wrapper = document.getElementById("control-bar-wrapper");
|
|
348
|
+
const bar = document.getElementById("overflow-bar");
|
|
349
|
+
const controls = [
|
|
350
|
+
document.getElementById("overflow-input"),
|
|
351
|
+
document.getElementById("overflow-select"),
|
|
352
|
+
document.getElementById("overflow-button"),
|
|
353
|
+
];
|
|
354
|
+
|
|
355
|
+
wrapper.style.boxSizing = "border-box";
|
|
356
|
+
wrapper.style.width = "90px";
|
|
357
|
+
Object.defineProperty(wrapper, "clientWidth", {
|
|
358
|
+
configurable: true,
|
|
359
|
+
value: 90,
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
for (const control of controls) {
|
|
363
|
+
Object.defineProperty(control, "offsetWidth", {
|
|
364
|
+
configurable: true,
|
|
365
|
+
value: 50,
|
|
366
|
+
});
|
|
367
|
+
Object.defineProperty(control, "offsetHeight", {
|
|
368
|
+
configurable: true,
|
|
369
|
+
value: 30,
|
|
370
|
+
});
|
|
371
|
+
control.getBoundingClientRect = () => ({
|
|
372
|
+
width: 50,
|
|
373
|
+
height: 30,
|
|
374
|
+
top: 0,
|
|
375
|
+
right: 50,
|
|
376
|
+
bottom: 30,
|
|
377
|
+
left: 0,
|
|
378
|
+
x: 0,
|
|
379
|
+
y: 0,
|
|
380
|
+
toJSON: () => {},
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const switchButton = bar.shadowRoot.querySelector(
|
|
385
|
+
'[data-monster-role="switch"]',
|
|
386
|
+
);
|
|
387
|
+
Object.defineProperty(switchButton, "offsetWidth", {
|
|
388
|
+
configurable: true,
|
|
389
|
+
value: 20,
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
await flushFrames();
|
|
393
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
394
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
395
|
+
|
|
396
|
+
expect(switchButton.hasAttribute("hidden")).to.be.false;
|
|
397
|
+
expect(document.getElementById("overflow-input").hasAttribute("slot")).to
|
|
398
|
+
.be.false;
|
|
399
|
+
expect(document.getElementById("overflow-select").getAttribute("slot")).to
|
|
400
|
+
.equal("popper");
|
|
401
|
+
expect(document.getElementById("overflow-button").getAttribute("slot")).to
|
|
402
|
+
.equal("popper");
|
|
403
|
+
} finally {
|
|
404
|
+
window.ResizeObserver = OriginalResizeObserver;
|
|
405
|
+
globalThis.ResizeObserver = originalGlobalResizeObserver;
|
|
406
|
+
window.requestAnimationFrame = originalRequestAnimationFrame;
|
|
407
|
+
globalThis.requestAnimationFrame = originalGlobalRequestAnimationFrame;
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as chai from "chai";
|
|
2
|
+
import { chaiDom } from "../../../util/chai-dom.mjs";
|
|
3
|
+
import { initJSDOM } from "../../../util/jsdom.mjs";
|
|
4
|
+
|
|
5
|
+
let expect = chai.expect;
|
|
6
|
+
chai.use(chaiDom);
|
|
7
|
+
|
|
8
|
+
let InputGroup;
|
|
9
|
+
|
|
10
|
+
describe("InputGroup", function () {
|
|
11
|
+
before(function (done) {
|
|
12
|
+
initJSDOM()
|
|
13
|
+
.then(() => import("../../../../source/components/form/input-group.mjs"))
|
|
14
|
+
.then((m) => {
|
|
15
|
+
InputGroup = m.InputGroup;
|
|
16
|
+
done();
|
|
17
|
+
})
|
|
18
|
+
.catch((e) => done(e));
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should create an input group element", function () {
|
|
22
|
+
const inputGroup = document.createElement("monster-input-group");
|
|
23
|
+
|
|
24
|
+
expect(inputGroup).to.be.instanceof(InputGroup);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should allow the input group to stretch within constrained controls", function () {
|
|
28
|
+
const cssText = InputGroup.getCSSStyleSheet()
|
|
29
|
+
.flatMap((styleSheet) => Array.from(styleSheet.cssRules))
|
|
30
|
+
.map((rule) => rule.cssText)
|
|
31
|
+
.join("\n");
|
|
32
|
+
|
|
33
|
+
expect(cssText).to.contain("display: flex");
|
|
34
|
+
expect(cssText).to.contain("box-sizing: border-box");
|
|
35
|
+
expect(cssText).to.contain("height: 100%");
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -129,6 +129,18 @@ describe('Select', function () {
|
|
|
129
129
|
});
|
|
130
130
|
})
|
|
131
131
|
|
|
132
|
+
it('should expose compact layout variables for constrained control contexts', function () {
|
|
133
|
+
const cssText = SelectStyleSheet
|
|
134
|
+
.cssRules
|
|
135
|
+
? Array.from(SelectStyleSheet.cssRules).map((rule) => rule.cssText).join("\n")
|
|
136
|
+
: "";
|
|
137
|
+
|
|
138
|
+
expect(cssText).to.contain("--monster-select-container-overflow");
|
|
139
|
+
expect(cssText).to.contain("--monster-select-control-padding");
|
|
140
|
+
expect(cssText).to.contain("--monster-select-selection-margin");
|
|
141
|
+
expect(cssText).to.contain("--monster-select-selection-flex-wrap");
|
|
142
|
+
});
|
|
143
|
+
|
|
132
144
|
describe('With fetch', function () {
|
|
133
145
|
|
|
134
146
|
beforeEach((done) => {
|