@schukai/monster 4.150.1 → 4.150.3
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/datatable/style/datatable.pcss +8 -0
- package/source/components/datatable/stylesheet/datatable.mjs +1 -1
- package/source/components/form/control-bar.mjs +26 -6
- package/source/components/form/style/button-bar.pcss +17 -1
- package/source/components/form/style/control-bar.pcss +6 -0
- package/source/components/form/style/mixin/field-set-layout.pcss +2 -0
- package/source/components/form/style/toggle-switch.pcss +4 -0
- package/source/components/form/stylesheet/button-bar.mjs +5 -3
- package/source/components/form/stylesheet/control-bar.mjs +2 -2
- package/source/components/form/stylesheet/field-set.mjs +1 -1
- package/source/components/form/stylesheet/repeat-field-set-items.mjs +1 -1
- package/source/components/form/stylesheet/toggle-switch.mjs +2 -2
- package/test/cases/components/datatable/mobile-layout.mjs +13 -0
- package/test/cases/components/form/button-bar.mjs +21 -0
- package/test/cases/components/form/control-bar.mjs +123 -0
- package/test/cases/components/form/field-set.mjs +11 -0
- package/test/cases/components/form/toggle-switch.mjs +13 -0
|
@@ -448,6 +448,11 @@ describe("ControlBar", function () {
|
|
|
448
448
|
"--monster-action-menu-item-hover-background-color",
|
|
449
449
|
);
|
|
450
450
|
expect(cssText).to.contain("--monster-action-menu-item-focus-outline-offset");
|
|
451
|
+
expect(cssText).to.contain("--monster-button-bar-flex-direction: column");
|
|
452
|
+
expect(cssText).to.contain("--monster-button-bar-height: auto");
|
|
453
|
+
expect(cssText).to.contain(
|
|
454
|
+
":has(>[data-monster-role=switch][hidden])",
|
|
455
|
+
);
|
|
451
456
|
expect(cssText).to.contain("height: auto !important");
|
|
452
457
|
});
|
|
453
458
|
|
|
@@ -2192,6 +2197,124 @@ describe("ControlBar", function () {
|
|
|
2192
2197
|
}
|
|
2193
2198
|
});
|
|
2194
2199
|
|
|
2200
|
+
it("should restore controls when a hidden parent becomes visible during feedback suppression", async function () {
|
|
2201
|
+
const OriginalResizeObserver = window.ResizeObserver;
|
|
2202
|
+
const originalGlobalResizeObserver = globalThis.ResizeObserver;
|
|
2203
|
+
const originalRequestAnimationFrame = window.requestAnimationFrame;
|
|
2204
|
+
const originalGlobalRequestAnimationFrame = globalThis.requestAnimationFrame;
|
|
2205
|
+
|
|
2206
|
+
class TrackingResizeObserver extends ResizeObserverMock {
|
|
2207
|
+
static instances = [];
|
|
2208
|
+
|
|
2209
|
+
constructor(callback) {
|
|
2210
|
+
super(callback);
|
|
2211
|
+
TrackingResizeObserver.instances.push(this);
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
|
|
2215
|
+
const scheduledCallbacks = [];
|
|
2216
|
+
const flushFrames = async () => {
|
|
2217
|
+
while (scheduledCallbacks.length > 0) {
|
|
2218
|
+
scheduledCallbacks.shift()();
|
|
2219
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
2220
|
+
}
|
|
2221
|
+
};
|
|
2222
|
+
|
|
2223
|
+
try {
|
|
2224
|
+
window.ResizeObserver = TrackingResizeObserver;
|
|
2225
|
+
globalThis.ResizeObserver = TrackingResizeObserver;
|
|
2226
|
+
window.requestAnimationFrame = (callback) => {
|
|
2227
|
+
scheduledCallbacks.push(callback);
|
|
2228
|
+
return scheduledCallbacks.length;
|
|
2229
|
+
};
|
|
2230
|
+
globalThis.requestAnimationFrame = window.requestAnimationFrame;
|
|
2231
|
+
|
|
2232
|
+
const mocks = document.getElementById("mocks");
|
|
2233
|
+
mocks.innerHTML = `
|
|
2234
|
+
<div id="hidden-parent-wrapper">
|
|
2235
|
+
<monster-control-bar id="hidden-parent-bar">
|
|
2236
|
+
<button id="hidden-parent-one">One</button>
|
|
2237
|
+
<button id="hidden-parent-two">Two</button>
|
|
2238
|
+
</monster-control-bar>
|
|
2239
|
+
</div>
|
|
2240
|
+
`;
|
|
2241
|
+
|
|
2242
|
+
const wrapper = document.getElementById("hidden-parent-wrapper");
|
|
2243
|
+
const bar = document.getElementById("hidden-parent-bar");
|
|
2244
|
+
const popperNav = bar.shadowRoot.querySelector(
|
|
2245
|
+
'[data-monster-role="popper-nav"]',
|
|
2246
|
+
);
|
|
2247
|
+
const controls = [
|
|
2248
|
+
document.getElementById("hidden-parent-one"),
|
|
2249
|
+
document.getElementById("hidden-parent-two"),
|
|
2250
|
+
];
|
|
2251
|
+
let wrapperWidth = 120;
|
|
2252
|
+
|
|
2253
|
+
wrapper.style.boxSizing = "border-box";
|
|
2254
|
+
Object.defineProperty(wrapper, "clientWidth", {
|
|
2255
|
+
configurable: true,
|
|
2256
|
+
get: () => wrapperWidth,
|
|
2257
|
+
});
|
|
2258
|
+
|
|
2259
|
+
for (const control of controls) {
|
|
2260
|
+
Object.defineProperty(control, "offsetWidth", {
|
|
2261
|
+
configurable: true,
|
|
2262
|
+
value: 50,
|
|
2263
|
+
});
|
|
2264
|
+
Object.defineProperty(control, "offsetHeight", {
|
|
2265
|
+
configurable: true,
|
|
2266
|
+
value: 30,
|
|
2267
|
+
});
|
|
2268
|
+
control.getBoundingClientRect = () => ({
|
|
2269
|
+
width: 50,
|
|
2270
|
+
height: 30,
|
|
2271
|
+
top: 0,
|
|
2272
|
+
right: 50,
|
|
2273
|
+
bottom: 30,
|
|
2274
|
+
left: 0,
|
|
2275
|
+
x: 0,
|
|
2276
|
+
y: 0,
|
|
2277
|
+
toJSON: () => {},
|
|
2278
|
+
});
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
const switchButton = bar.shadowRoot.querySelector(
|
|
2282
|
+
'[data-monster-role="switch"]',
|
|
2283
|
+
);
|
|
2284
|
+
Object.defineProperty(switchButton, "offsetWidth", {
|
|
2285
|
+
configurable: true,
|
|
2286
|
+
value: 20,
|
|
2287
|
+
});
|
|
2288
|
+
|
|
2289
|
+
await flushFrames();
|
|
2290
|
+
expect(controls.every((control) => control.slot === "")).to.be.true;
|
|
2291
|
+
|
|
2292
|
+
const resizeObserver = TrackingResizeObserver.instances.find((observer) =>
|
|
2293
|
+
observer.elements.includes(wrapper),
|
|
2294
|
+
);
|
|
2295
|
+
expect(resizeObserver).to.exist;
|
|
2296
|
+
|
|
2297
|
+
wrapperWidth = 0;
|
|
2298
|
+
resizeObserver.triggerResize([{ target: wrapper }]);
|
|
2299
|
+
scheduledCallbacks.shift()();
|
|
2300
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
2301
|
+
expect(controls.every((control) => control.slot === "popper")).to.be.true;
|
|
2302
|
+
|
|
2303
|
+
wrapperWidth = 120;
|
|
2304
|
+
resizeObserver.triggerResize([{ target: wrapper }]);
|
|
2305
|
+
await flushFrames();
|
|
2306
|
+
|
|
2307
|
+
expect(controls.every((control) => control.slot === "")).to.be.true;
|
|
2308
|
+
expect(switchButton.hasAttribute("hidden")).to.be.true;
|
|
2309
|
+
expect(popperNav.style.display).to.equal("");
|
|
2310
|
+
} finally {
|
|
2311
|
+
window.ResizeObserver = OriginalResizeObserver;
|
|
2312
|
+
globalThis.ResizeObserver = originalGlobalResizeObserver;
|
|
2313
|
+
window.requestAnimationFrame = originalRequestAnimationFrame;
|
|
2314
|
+
globalThis.requestAnimationFrame = originalGlobalRequestAnimationFrame;
|
|
2315
|
+
}
|
|
2316
|
+
});
|
|
2317
|
+
|
|
2195
2318
|
it("should keep an open overflow menu through inherited hidden positioning", async function () {
|
|
2196
2319
|
const OriginalResizeObserver = window.ResizeObserver;
|
|
2197
2320
|
const originalGlobalResizeObserver = globalThis.ResizeObserver;
|
|
@@ -51,4 +51,15 @@ describe("FieldSet", function () {
|
|
|
51
51
|
expect(cssText).to.contain("justify-content: flex-start");
|
|
52
52
|
expect(cssText).to.contain("--monster-control-min-block-size");
|
|
53
53
|
});
|
|
54
|
+
|
|
55
|
+
it("should size toggle rows from the themed control height", function () {
|
|
56
|
+
const cssText = FieldSet.getCSSStyleSheet()
|
|
57
|
+
.flatMap((styleSheet) => Array.from(styleSheet.cssRules))
|
|
58
|
+
.map((rule) => rule.cssText)
|
|
59
|
+
.join("\n");
|
|
60
|
+
|
|
61
|
+
expect(cssText).to.match(
|
|
62
|
+
/::slotted\(monster-toggle-switch\)[\s\S]*?min-height:\s*var\(--monster-control-min-block-size,\s*1\.8rem\)/u,
|
|
63
|
+
);
|
|
64
|
+
});
|
|
54
65
|
});
|
|
@@ -73,6 +73,19 @@ describe('ToggleSwitch', function () {
|
|
|
73
73
|
it('should instance of monster-toggle-switch', function () {
|
|
74
74
|
expect(document.createElement('monster-toggle-switch')).is.instanceof(ToggleSwitch);
|
|
75
75
|
});
|
|
76
|
+
|
|
77
|
+
it('should center the visual switch within the themed control height', function () {
|
|
78
|
+
const cssText = ToggleSwitch.getCSSStyleSheet()
|
|
79
|
+
.flatMap((styleSheet) => Array.from(styleSheet.cssRules))
|
|
80
|
+
.map((rule) => rule.cssText)
|
|
81
|
+
.join("\n");
|
|
82
|
+
|
|
83
|
+
expect(cssText).to.contain("min-block-size: inherit");
|
|
84
|
+
expect(cssText).to.contain("align-items: center");
|
|
85
|
+
expect(cssText).to.match(
|
|
86
|
+
/:host\s*\{[^}]*min-block-size:\s*var\(--monster-control-min-block-size,\s*1\.8rem\)/u,
|
|
87
|
+
);
|
|
88
|
+
});
|
|
76
89
|
});
|
|
77
90
|
|
|
78
91
|
});
|