@schukai/monster 4.138.0 → 4.139.1
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/control-bar.mjs +275 -0
- package/source/components/form/select.mjs +15 -0
- package/source/components/form/style/button.pcss +10 -2
- package/source/components/form/style/control-bar.pcss +59 -4
- 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 +1 -1
- package/source/components/form/stylesheet/input-group.mjs +1 -1
- package/source/components/form/stylesheet/select.mjs +1 -1
- package/test/cases/components/form/button.mjs +11 -1
- package/test/cases/components/form/control-bar.mjs +182 -2
- package/test/cases/components/form/input-group.mjs +37 -0
- package/test/cases/components/form/select.mjs +60 -0
|
@@ -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
|
+
});
|
|
@@ -110,6 +110,8 @@ describe('Select', function () {
|
|
|
110
110
|
|
|
111
111
|
import("../../../../source/components/host/host.mjs").then(() => {
|
|
112
112
|
return import("../../../../source/components/form/popper-button.mjs");
|
|
113
|
+
}).then(() => {
|
|
114
|
+
return import("../../../../source/components/form/control-bar.mjs");
|
|
113
115
|
}).then(() => {
|
|
114
116
|
return import("../../../../source/components/form/select.mjs");
|
|
115
117
|
}).then((m) => {
|
|
@@ -129,6 +131,18 @@ describe('Select', function () {
|
|
|
129
131
|
});
|
|
130
132
|
})
|
|
131
133
|
|
|
134
|
+
it('should expose compact layout variables for constrained control contexts', function () {
|
|
135
|
+
const cssText = SelectStyleSheet
|
|
136
|
+
.cssRules
|
|
137
|
+
? Array.from(SelectStyleSheet.cssRules).map((rule) => rule.cssText).join("\n")
|
|
138
|
+
: "";
|
|
139
|
+
|
|
140
|
+
expect(cssText).to.contain("--monster-select-container-overflow");
|
|
141
|
+
expect(cssText).to.contain("--monster-select-control-padding");
|
|
142
|
+
expect(cssText).to.contain("--monster-select-selection-margin");
|
|
143
|
+
expect(cssText).to.contain("--monster-select-selection-flex-wrap");
|
|
144
|
+
});
|
|
145
|
+
|
|
132
146
|
describe('With fetch', function () {
|
|
133
147
|
|
|
134
148
|
beforeEach((done) => {
|
|
@@ -310,6 +324,52 @@ describe('Select', function () {
|
|
|
310
324
|
}, 20);
|
|
311
325
|
});
|
|
312
326
|
|
|
327
|
+
it('should use fixed positioning inside a control bar', function (done) {
|
|
328
|
+
const mocks = document.getElementById('mocks');
|
|
329
|
+
mocks.innerHTML = '<monster-control-bar id="select-bar"></monster-control-bar>';
|
|
330
|
+
|
|
331
|
+
const bar = document.getElementById('select-bar');
|
|
332
|
+
const select = document.createElement('monster-select');
|
|
333
|
+
|
|
334
|
+
select.setOption('options', [
|
|
335
|
+
{label: 'Alpha', value: 'alpha'},
|
|
336
|
+
{label: 'Beta', value: 'beta'}
|
|
337
|
+
]);
|
|
338
|
+
|
|
339
|
+
bar.appendChild(select);
|
|
340
|
+
|
|
341
|
+
const shadowRoot = select.shadowRoot;
|
|
342
|
+
const control = shadowRoot.querySelector('[data-monster-role=control]');
|
|
343
|
+
const popper = shadowRoot.querySelector('[data-monster-role=popper]');
|
|
344
|
+
|
|
345
|
+
control.getBoundingClientRect = () => ({
|
|
346
|
+
width: 120,
|
|
347
|
+
height: 40,
|
|
348
|
+
top: 100,
|
|
349
|
+
left: 40,
|
|
350
|
+
right: 160,
|
|
351
|
+
bottom: 140,
|
|
352
|
+
x: 40,
|
|
353
|
+
y: 100
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
setTimeout(() => {
|
|
357
|
+
try {
|
|
358
|
+
shadowRoot.querySelector('[data-monster-role=container]').click();
|
|
359
|
+
setTimeout(() => {
|
|
360
|
+
try {
|
|
361
|
+
expect(popper.style.position).to.equal('fixed');
|
|
362
|
+
done();
|
|
363
|
+
} catch (e) {
|
|
364
|
+
done(e);
|
|
365
|
+
}
|
|
366
|
+
}, 80);
|
|
367
|
+
} catch (e) {
|
|
368
|
+
done(e);
|
|
369
|
+
}
|
|
370
|
+
}, 100);
|
|
371
|
+
});
|
|
372
|
+
|
|
313
373
|
it('should keep the option list height tight for short lists', function () {
|
|
314
374
|
const result = resolveSelectListDimension({
|
|
315
375
|
visibleOptionHeights: [28, 28],
|