chore: run prettier
This commit is contained in:
parent
e19a0f483c
commit
4719a1e6cd
5 changed files with 26 additions and 99 deletions
|
|
@ -132,9 +132,7 @@ export class OverlayController {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.manager.add(this);
|
this.manager.add(this);
|
||||||
this._contentId = `overlay-content--${Math.random()
|
this._contentId = `overlay-content--${Math.random().toString(36).substr(2, 10)}`;
|
||||||
.toString(36)
|
|
||||||
.substr(2, 10)}`;
|
|
||||||
|
|
||||||
if (this._defaultConfig.contentNode) {
|
if (this._defaultConfig.contentNode) {
|
||||||
this.__isContentNodeProjected = Boolean(this._defaultConfig.contentNode.assignedSlot);
|
this.__isContentNodeProjected = Boolean(this._defaultConfig.contentNode.assignedSlot);
|
||||||
|
|
|
||||||
|
|
@ -18,16 +18,12 @@ import { overlays } from '../src/overlays.js';
|
||||||
|
|
||||||
const withGlobalTestConfig = () => ({
|
const withGlobalTestConfig = () => ({
|
||||||
placementMode: 'global',
|
placementMode: 'global',
|
||||||
contentNode: fixtureSync(html`
|
contentNode: fixtureSync(html` <div>my content</div> `),
|
||||||
<div>my content</div>
|
|
||||||
`),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const withLocalTestConfig = () => ({
|
const withLocalTestConfig = () => ({
|
||||||
placementMode: 'local',
|
placementMode: 'local',
|
||||||
contentNode: fixtureSync(html`
|
contentNode: fixtureSync(html` <div>my content</div> `),
|
||||||
<div>my content</div>
|
|
||||||
`),
|
|
||||||
invokerNode: fixtureSync(html`
|
invokerNode: fixtureSync(html`
|
||||||
<div role="button" style="width: 100px; height: 20px;">Invoker</div>
|
<div role="button" style="width: 100px; height: 20px;">Invoker</div>
|
||||||
`),
|
`),
|
||||||
|
|
@ -138,9 +134,7 @@ describe('OverlayController', () => {
|
||||||
it.skip('creates local target next to sibling for placement mode "local"', async () => {
|
it.skip('creates local target next to sibling for placement mode "local"', async () => {
|
||||||
const ctrl = new OverlayController({
|
const ctrl = new OverlayController({
|
||||||
...withLocalTestConfig(),
|
...withLocalTestConfig(),
|
||||||
invokerNode: await fixture(html`
|
invokerNode: await fixture(html` <button>Invoker</button> `),
|
||||||
<button>Invoker</button>
|
|
||||||
`),
|
|
||||||
});
|
});
|
||||||
expect(ctrl._renderTarget).to.be.undefined;
|
expect(ctrl._renderTarget).to.be.undefined;
|
||||||
expect(ctrl.content).to.equal(ctrl.invokerNode.nextElementSibling);
|
expect(ctrl.content).to.equal(ctrl.invokerNode.nextElementSibling);
|
||||||
|
|
@ -272,9 +266,7 @@ describe('OverlayController', () => {
|
||||||
});
|
});
|
||||||
await ctrl.show();
|
await ctrl.show();
|
||||||
|
|
||||||
const elOutside = await fixture(html`
|
const elOutside = await fixture(html` <button>click me</button> `);
|
||||||
<button>click me</button>
|
|
||||||
`);
|
|
||||||
const input1 = ctrl.contentNode.querySelectorAll('input')[0];
|
const input1 = ctrl.contentNode.querySelectorAll('input')[0];
|
||||||
const input2 = ctrl.contentNode.querySelectorAll('input')[1];
|
const input2 = ctrl.contentNode.querySelectorAll('input')[1];
|
||||||
|
|
||||||
|
|
@ -289,9 +281,7 @@ describe('OverlayController', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows to move the focus outside of the overlay if trapsKeyboardFocus is disabled', async () => {
|
it('allows to move the focus outside of the overlay if trapsKeyboardFocus is disabled', async () => {
|
||||||
const contentNode = await fixture(html`
|
const contentNode = await fixture(html` <div><input /></div> `);
|
||||||
<div><input /></div>
|
|
||||||
`);
|
|
||||||
|
|
||||||
const ctrl = new OverlayController({
|
const ctrl = new OverlayController({
|
||||||
...withGlobalTestConfig(),
|
...withGlobalTestConfig(),
|
||||||
|
|
@ -299,14 +289,10 @@ describe('OverlayController', () => {
|
||||||
trapsKeyboardFocus: true,
|
trapsKeyboardFocus: true,
|
||||||
});
|
});
|
||||||
// add element to dom to allow focus
|
// add element to dom to allow focus
|
||||||
await fixture(html`
|
await fixture(html` ${ctrl.content} `);
|
||||||
${ctrl.content}
|
|
||||||
`);
|
|
||||||
await ctrl.show();
|
await ctrl.show();
|
||||||
|
|
||||||
const elOutside = await fixture(html`
|
const elOutside = await fixture(html` <input /> `);
|
||||||
<input />
|
|
||||||
`);
|
|
||||||
const input = ctrl.contentNode.querySelector('input');
|
const input = ctrl.contentNode.querySelector('input');
|
||||||
|
|
||||||
input.focus();
|
input.focus();
|
||||||
|
|
@ -462,10 +448,7 @@ describe('OverlayController', () => {
|
||||||
await ctrl.show();
|
await ctrl.show();
|
||||||
|
|
||||||
// Don't hide on inside shadowDom click
|
// Don't hide on inside shadowDom click
|
||||||
ctrl.contentNode
|
ctrl.contentNode.querySelector(tagString).shadowRoot.querySelector('button').click();
|
||||||
.querySelector(tagString)
|
|
||||||
.shadowRoot.querySelector('button')
|
|
||||||
.click();
|
|
||||||
|
|
||||||
await aTimeout();
|
await aTimeout();
|
||||||
expect(ctrl.isShown).to.be.true;
|
expect(ctrl.isShown).to.be.true;
|
||||||
|
|
@ -514,9 +497,7 @@ describe('OverlayController', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with 3rd party code using "event.stopPropagation()" on capture phase', async () => {
|
it('works with 3rd party code using "event.stopPropagation()" on capture phase', async () => {
|
||||||
const invokerNode = await fixture(html`
|
const invokerNode = await fixture(html` <div role="button">Invoker</div> `);
|
||||||
<div role="button">Invoker</div>
|
|
||||||
`);
|
|
||||||
const contentNode = await fixture('<div>Content</div>');
|
const contentNode = await fixture('<div>Content</div>');
|
||||||
const ctrl = new OverlayController({
|
const ctrl = new OverlayController({
|
||||||
...withLocalTestConfig(),
|
...withLocalTestConfig(),
|
||||||
|
|
@ -1003,11 +984,7 @@ describe('OverlayController', () => {
|
||||||
it('reinitializes content', async () => {
|
it('reinitializes content', async () => {
|
||||||
const ctrl = new OverlayController({
|
const ctrl = new OverlayController({
|
||||||
...withLocalTestConfig(),
|
...withLocalTestConfig(),
|
||||||
contentNode: await fixture(
|
contentNode: await fixture(html` <div>content1</div> `),
|
||||||
html`
|
|
||||||
<div>content1</div>
|
|
||||||
`,
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
await ctrl.show(); // Popper adds inline styles
|
await ctrl.show(); // Popper adds inline styles
|
||||||
expect(ctrl.content.style.transform).not.to.be.undefined;
|
expect(ctrl.content.style.transform).not.to.be.undefined;
|
||||||
|
|
@ -1015,19 +992,13 @@ describe('OverlayController', () => {
|
||||||
|
|
||||||
ctrl.updateConfig({
|
ctrl.updateConfig({
|
||||||
placementMode: 'local',
|
placementMode: 'local',
|
||||||
contentNode: await fixture(
|
contentNode: await fixture(html` <div>content2</div> `),
|
||||||
html`
|
|
||||||
<div>content2</div>
|
|
||||||
`,
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
expect(ctrl.contentNode.textContent).to.include('content2');
|
expect(ctrl.contentNode.textContent).to.include('content2');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('respects the initial config provided to new OverlayController(initialConfig)', async () => {
|
it('respects the initial config provided to new OverlayController(initialConfig)', async () => {
|
||||||
const contentNode = fixtureSync(html`
|
const contentNode = fixtureSync(html` <div>my content</div> `);
|
||||||
<div>my content</div>
|
|
||||||
`);
|
|
||||||
|
|
||||||
const ctrl = new OverlayController({
|
const ctrl = new OverlayController({
|
||||||
// This is the shared config
|
// This is the shared config
|
||||||
|
|
@ -1047,9 +1018,7 @@ describe('OverlayController', () => {
|
||||||
|
|
||||||
// Currently not working, enable again when we fix updateConfig
|
// Currently not working, enable again when we fix updateConfig
|
||||||
it.skip('allows for updating viewport config placement only, while keeping the content shown', async () => {
|
it.skip('allows for updating viewport config placement only, while keeping the content shown', async () => {
|
||||||
const contentNode = fixtureSync(html`
|
const contentNode = fixtureSync(html` <div>my content</div> `);
|
||||||
<div>my content</div>
|
|
||||||
`);
|
|
||||||
|
|
||||||
const ctrl = new OverlayController({
|
const ctrl = new OverlayController({
|
||||||
// This is the shared config
|
// This is the shared config
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,7 @@ import { normalizeTransformStyle } from './utils-tests/local-positioning-helpers
|
||||||
|
|
||||||
const withLocalTestConfig = () => ({
|
const withLocalTestConfig = () => ({
|
||||||
placementMode: 'local',
|
placementMode: 'local',
|
||||||
contentNode: fixtureSync(
|
contentNode: fixtureSync(html` <div>my content</div> `),
|
||||||
html`
|
|
||||||
<div>my content</div>
|
|
||||||
`,
|
|
||||||
),
|
|
||||||
invokerNode: fixtureSync(html`
|
invokerNode: fixtureSync(html`
|
||||||
<div role="button" style="width: 100px; height: 20px;">Invoker</div>
|
<div role="button" style="width: 100px; height: 20px;">Invoker</div>
|
||||||
`),
|
`),
|
||||||
|
|
@ -58,11 +54,7 @@ describe('Local Positioning', () => {
|
||||||
it('uses top as the default placement', async () => {
|
it('uses top as the default placement', async () => {
|
||||||
const ctrl = new OverlayController({
|
const ctrl = new OverlayController({
|
||||||
...withLocalTestConfig(),
|
...withLocalTestConfig(),
|
||||||
contentNode: fixtureSync(
|
contentNode: fixtureSync(html` <div style="width: 80px; height: 20px;"></div> `),
|
||||||
html`
|
|
||||||
<div style="width: 80px; height: 20px;"></div>
|
|
||||||
`,
|
|
||||||
),
|
|
||||||
invokerNode: fixtureSync(html`
|
invokerNode: fixtureSync(html`
|
||||||
<div role="button" style="width: 100px; height: 20px;" @click=${() => ctrl.show()}></div>
|
<div role="button" style="width: 100px; height: 20px;" @click=${() => ctrl.show()}></div>
|
||||||
`),
|
`),
|
||||||
|
|
@ -79,11 +71,7 @@ describe('Local Positioning', () => {
|
||||||
it('positions to preferred place if placement is set and space is available', async () => {
|
it('positions to preferred place if placement is set and space is available', async () => {
|
||||||
const ctrl = new OverlayController({
|
const ctrl = new OverlayController({
|
||||||
...withLocalTestConfig(),
|
...withLocalTestConfig(),
|
||||||
contentNode: fixtureSync(
|
contentNode: fixtureSync(html` <div style="width: 80px; height: 20px;"></div> `),
|
||||||
html`
|
|
||||||
<div style="width: 80px; height: 20px;"></div>
|
|
||||||
`,
|
|
||||||
),
|
|
||||||
invokerNode: fixtureSync(html`
|
invokerNode: fixtureSync(html`
|
||||||
<div role="button" style="width: 100px; height: 20px;" @click=${() => ctrl.show()}></div>
|
<div role="button" style="width: 100px; height: 20px;" @click=${() => ctrl.show()}></div>
|
||||||
`),
|
`),
|
||||||
|
|
@ -104,11 +92,7 @@ describe('Local Positioning', () => {
|
||||||
it('positions to different place if placement is set and no space is available', async () => {
|
it('positions to different place if placement is set and no space is available', async () => {
|
||||||
const ctrl = new OverlayController({
|
const ctrl = new OverlayController({
|
||||||
...withLocalTestConfig(),
|
...withLocalTestConfig(),
|
||||||
contentNode: fixtureSync(
|
contentNode: fixtureSync(html` <div style="width: 80px; height: 20px;">invoker</div> `),
|
||||||
html`
|
|
||||||
<div style="width: 80px; height: 20px;">invoker</div>
|
|
||||||
`,
|
|
||||||
),
|
|
||||||
invokerNode: fixtureSync(html`
|
invokerNode: fixtureSync(html`
|
||||||
<div role="button" style="width: 100px; height: 20px;" @click=${() => ctrl.show()}>
|
<div role="button" style="width: 100px; height: 20px;" @click=${() => ctrl.show()}>
|
||||||
content
|
content
|
||||||
|
|
@ -131,11 +115,7 @@ describe('Local Positioning', () => {
|
||||||
it('allows the user to override default Popper modifiers', async () => {
|
it('allows the user to override default Popper modifiers', async () => {
|
||||||
const ctrl = new OverlayController({
|
const ctrl = new OverlayController({
|
||||||
...withLocalTestConfig(),
|
...withLocalTestConfig(),
|
||||||
contentNode: fixtureSync(
|
contentNode: fixtureSync(html` <div style="width: 80px; height: 20px;"></div> `),
|
||||||
html`
|
|
||||||
<div style="width: 80px; height: 20px;"></div>
|
|
||||||
`,
|
|
||||||
),
|
|
||||||
invokerNode: fixtureSync(html`
|
invokerNode: fixtureSync(html`
|
||||||
<div role="button" style="width: 100px; height: 20px;" @click=${() => ctrl.show()}></div>
|
<div role="button" style="width: 100px; height: 20px;" @click=${() => ctrl.show()}></div>
|
||||||
`),
|
`),
|
||||||
|
|
@ -168,11 +148,7 @@ describe('Local Positioning', () => {
|
||||||
it('positions the Popper element correctly on show', async () => {
|
it('positions the Popper element correctly on show', async () => {
|
||||||
const ctrl = new OverlayController({
|
const ctrl = new OverlayController({
|
||||||
...withLocalTestConfig(),
|
...withLocalTestConfig(),
|
||||||
contentNode: fixtureSync(
|
contentNode: fixtureSync(html` <div style="width: 80px; height: 20px;"></div> `),
|
||||||
html`
|
|
||||||
<div style="width: 80px; height: 20px;"></div>
|
|
||||||
`,
|
|
||||||
),
|
|
||||||
invokerNode: fixtureSync(html`
|
invokerNode: fixtureSync(html`
|
||||||
<div role="button" style="width: 100px; height: 20px;" @click=${() => ctrl.show()}></div>
|
<div role="button" style="width: 100px; height: 20px;" @click=${() => ctrl.show()}></div>
|
||||||
`),
|
`),
|
||||||
|
|
@ -203,11 +179,7 @@ describe('Local Positioning', () => {
|
||||||
it.skip('updates placement properly even during hidden state', async () => {
|
it.skip('updates placement properly even during hidden state', async () => {
|
||||||
const ctrl = new OverlayController({
|
const ctrl = new OverlayController({
|
||||||
...withLocalTestConfig(),
|
...withLocalTestConfig(),
|
||||||
contentNode: fixtureSync(
|
contentNode: fixtureSync(html` <div style="width: 80px; height: 20px;"></div> `),
|
||||||
html`
|
|
||||||
<div style="width: 80px; height: 20px;"></div>
|
|
||||||
`,
|
|
||||||
),
|
|
||||||
invokerNode: fixtureSync(html`
|
invokerNode: fixtureSync(html`
|
||||||
<div role="button" style="width: 100px; height: 20px;" @click=${() => ctrl.show()}></div>
|
<div role="button" style="width: 100px; height: 20px;" @click=${() => ctrl.show()}></div>
|
||||||
`),
|
`),
|
||||||
|
|
@ -256,11 +228,7 @@ describe('Local Positioning', () => {
|
||||||
it.skip('updates positioning correctly during shown state when config gets updated', async () => {
|
it.skip('updates positioning correctly during shown state when config gets updated', async () => {
|
||||||
const ctrl = new OverlayController({
|
const ctrl = new OverlayController({
|
||||||
...withLocalTestConfig(),
|
...withLocalTestConfig(),
|
||||||
contentNode: fixtureSync(
|
contentNode: fixtureSync(html` <div style="width: 80px; height: 20px;"></div> `),
|
||||||
html`
|
|
||||||
<div style="width: 80px; height: 20px;"></div>
|
|
||||||
`,
|
|
||||||
),
|
|
||||||
invokerNode: fixtureSync(html`
|
invokerNode: fixtureSync(html`
|
||||||
<div role="button" style="width: 100px; height: 20px;" @click=${() => ctrl.show()}>
|
<div role="button" style="width: 100px; height: 20px;" @click=${() => ctrl.show()}>
|
||||||
Invoker
|
Invoker
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,7 @@ import './differentKeyNamesShimIE.js';
|
||||||
import { LionSelectInvoker } from './LionSelectInvoker.js';
|
import { LionSelectInvoker } from './LionSelectInvoker.js';
|
||||||
|
|
||||||
function uuid() {
|
function uuid() {
|
||||||
return Math.random()
|
return Math.random().toString(36).substr(2, 10);
|
||||||
.toString(36)
|
|
||||||
.substr(2, 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function detectInteractionMode() {
|
function detectInteractionMode() {
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,7 @@ describe('lion-select-rich', () => {
|
||||||
expect(el.formElements[0].name).to.equal('foo');
|
expect(el.formElements[0].name).to.equal('foo');
|
||||||
expect(el.formElements[1].name).to.equal('foo');
|
expect(el.formElements[1].name).to.equal('foo');
|
||||||
|
|
||||||
const validChild = await fixture(html`
|
const validChild = await fixture(html` <lion-option .choiceValue=${30}>Item 3</lion-option> `);
|
||||||
<lion-option .choiceValue=${30}>Item 3</lion-option>
|
|
||||||
`);
|
|
||||||
el.appendChild(validChild);
|
el.appendChild(validChild);
|
||||||
|
|
||||||
expect(el.formElements[2].name).to.equal('foo');
|
expect(el.formElements[2].name).to.equal('foo');
|
||||||
|
|
@ -56,9 +54,7 @@ describe('lion-select-rich', () => {
|
||||||
`);
|
`);
|
||||||
await nextFrame();
|
await nextFrame();
|
||||||
|
|
||||||
const invalidChild = await fixture(html`
|
const invalidChild = await fixture(html` <lion-option .modelValue=${'Lara'}></lion-option> `);
|
||||||
<lion-option .modelValue=${'Lara'}></lion-option>
|
|
||||||
`);
|
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
el.addFormElement(invalidChild);
|
el.addFormElement(invalidChild);
|
||||||
|
|
@ -805,9 +801,7 @@ describe('lion-select-rich', () => {
|
||||||
const invokerTagName = defineCE(
|
const invokerTagName = defineCE(
|
||||||
class extends LionSelectInvoker {
|
class extends LionSelectInvoker {
|
||||||
_noSelectionTemplate() {
|
_noSelectionTemplate() {
|
||||||
return html`
|
return html` Please select an option.. `;
|
||||||
Please select an option..
|
|
||||||
`;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue