@schukai/monster 4.129.7 → 4.129.9
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/context-base.mjs +3 -0
- package/source/components/form/context-error.mjs +4 -0
- package/source/components/form/util/floating-ui.mjs +168 -21
- package/source/components/layout/popper.mjs +1 -1
- package/source/components/layout/stylesheet/popper.mjs +1 -1
- package/source/components/style/floating-ui.css +1 -57
- package/source/components/style/floating-ui.pcss +7 -0
- package/source/components/stylesheet/floating-ui.mjs +7 -14
- package/test/cases/components/form/context-error.mjs +48 -0
- package/test/cases/components/form/context-help.mjs +91 -0
- package/test/cases/components/form/popper-button.mjs +56 -0
- package/test/cases/components/form/select.mjs +32 -78
- package/test/cases/dom/util/init-options-from-attributes.mjs +14 -0
- package/test/web/tests.js +5800 -6811
|
@@ -254,87 +254,41 @@ describe('Select', function () {
|
|
|
254
254
|
|
|
255
255
|
const pagination = () => select.shadowRoot.querySelector('[data-monster-role=pagination]');
|
|
256
256
|
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
filterInput.value = value;
|
|
260
|
-
filterInput.dispatchEvent(new InputEvent('input', {
|
|
261
|
-
bubbles: true,
|
|
262
|
-
composed: true,
|
|
263
|
-
data: value
|
|
264
|
-
}));
|
|
265
|
-
filterInput.dispatchEvent(new KeyboardEvent('keydown', {
|
|
266
|
-
code: 'KeyA',
|
|
267
|
-
key: 'a',
|
|
268
|
-
bubbles: true,
|
|
269
|
-
composed: true
|
|
270
|
-
}));
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
const startedAt = Date.now();
|
|
274
|
-
const pollLoadedState = () => {
|
|
275
|
-
try {
|
|
276
|
-
const options = select.getOption('options');
|
|
277
|
-
const pager = pagination();
|
|
278
|
-
|
|
279
|
-
if (
|
|
280
|
-
options?.length !== 1 ||
|
|
281
|
-
!pager ||
|
|
282
|
-
pager.getOption('currentPage') !== 1 ||
|
|
283
|
-
pager.getOption('pages') !== 2 ||
|
|
284
|
-
pager.getOption('objectsPerPage') !== 1
|
|
285
|
-
) {
|
|
286
|
-
if (Date.now() - startedAt < 3000) {
|
|
287
|
-
return setTimeout(pollLoadedState, 50);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
expect(options.length).to.equal(1);
|
|
292
|
-
expect(pager.getOption('currentPage')).to.equal(1);
|
|
293
|
-
expect(pager.getOption('pages')).to.equal(2);
|
|
294
|
-
expect(pager.getOption('objectsPerPage')).to.equal(1);
|
|
295
|
-
|
|
296
|
-
triggerFilter('b');
|
|
297
|
-
setTimeout(pollErrorState, 50);
|
|
298
|
-
} catch (e) {
|
|
299
|
-
done(e);
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
const pollErrorState = () => {
|
|
304
|
-
try {
|
|
305
|
-
const optionsAfterError = select.getOption('options');
|
|
306
|
-
const pager = pagination();
|
|
307
|
-
|
|
308
|
-
if (
|
|
309
|
-
optionsAfterError?.length !== 0 ||
|
|
310
|
-
!pager ||
|
|
311
|
-
pager.getOption('currentPage') !== null ||
|
|
312
|
-
pager.getOption('pages') !== null ||
|
|
313
|
-
pager.getOption('objectsPerPage') !== null ||
|
|
314
|
-
select.getOption('total') !== null ||
|
|
315
|
-
select.getOption('messages.total') !== ""
|
|
316
|
-
) {
|
|
317
|
-
if (Date.now() - startedAt < 4500) {
|
|
318
|
-
return setTimeout(pollErrorState, 50);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
expect(optionsAfterError.length).to.equal(0);
|
|
323
|
-
expect(pager.getOption('currentPage')).to.equal(null);
|
|
324
|
-
expect(pager.getOption('pages')).to.equal(null);
|
|
325
|
-
expect(pager.getOption('objectsPerPage')).to.equal(null);
|
|
326
|
-
expect(select.getOption('total')).to.equal(null);
|
|
327
|
-
expect(select.getOption('messages.total')).to.equal("");
|
|
328
|
-
} catch (e) {
|
|
329
|
-
return done(e);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
done();
|
|
257
|
+
const fetchRemotePage = (value) => {
|
|
258
|
+
return select.fetch(`https://example.com/items?filter=${encodeURIComponent(value)}&page=1`);
|
|
333
259
|
};
|
|
334
260
|
|
|
335
261
|
setTimeout(() => {
|
|
336
|
-
|
|
337
|
-
|
|
262
|
+
fetchRemotePage('a')
|
|
263
|
+
.then(() => {
|
|
264
|
+
const options = select.getOption('options');
|
|
265
|
+
const pager = pagination();
|
|
266
|
+
|
|
267
|
+
expect(options.length).to.equal(1);
|
|
268
|
+
expect(pager.getOption('currentPage')).to.equal(1);
|
|
269
|
+
expect(pager.getOption('pages')).to.equal(2);
|
|
270
|
+
expect(pager.getOption('objectsPerPage')).to.equal(1);
|
|
271
|
+
|
|
272
|
+
return fetchRemotePage('b')
|
|
273
|
+
.then(() => Promise.reject(new Error('Expected remote fetch to fail')))
|
|
274
|
+
.catch((e) => {
|
|
275
|
+
if (e.message === 'Expected remote fetch to fail') {
|
|
276
|
+
throw e;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const optionsAfterError = select.getOption('options');
|
|
280
|
+
const pager = pagination();
|
|
281
|
+
|
|
282
|
+
expect(optionsAfterError.length).to.equal(0);
|
|
283
|
+
expect(pager.getOption('currentPage')).to.equal(null);
|
|
284
|
+
expect(pager.getOption('pages')).to.equal(null);
|
|
285
|
+
expect(pager.getOption('objectsPerPage')).to.equal(null);
|
|
286
|
+
expect(select.getOption('total')).to.equal(null);
|
|
287
|
+
expect(select.getOption('messages.total')).to.equal("");
|
|
288
|
+
});
|
|
289
|
+
})
|
|
290
|
+
.then(() => done())
|
|
291
|
+
.catch((e) => done(e));
|
|
338
292
|
}, 50);
|
|
339
293
|
});
|
|
340
294
|
});
|
|
@@ -185,4 +185,18 @@ describe('initOptionsFromAttributes', () => {
|
|
|
185
185
|
expect(result.message.width.viewportRatio).to.equal(0.9);
|
|
186
186
|
});
|
|
187
187
|
|
|
188
|
+
it('should preserve visible for popper content overflow attributes', () => {
|
|
189
|
+
options = {
|
|
190
|
+
popper: {
|
|
191
|
+
contentOverflow: 'both',
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
element.setAttribute('data-monster-option-popper-content-overflow', 'visible');
|
|
196
|
+
|
|
197
|
+
const result = initOptionsFromAttributes(element, options);
|
|
198
|
+
|
|
199
|
+
expect(result.popper.contentOverflow).to.equal('visible');
|
|
200
|
+
});
|
|
201
|
+
|
|
188
202
|
});
|