@salesforcedevs/arch-components 1.20.17-alpha10 → 1.20.17-alpha11
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/lwc.config.json +3 -1
- package/package.json +1 -1
- package/src/common/effectAdapter/__tests__/effectAdapter.test.ts +0 -12
- package/src/common/effectAdapter/effectAdapter.html +0 -1
- package/src/common/effectAdapter/effectAdapter.ts +0 -18
- package/src/common/reflectedElement/__tests__/modules/test/select/select.html +0 -3
- package/src/common/reflectedElement/__tests__/modules/test/select/select.ts +0 -7
- package/src/common/reflectedElement/__tests__/modules/test/selectTransform/selectTransform.html +0 -3
- package/src/common/reflectedElement/__tests__/modules/test/selectTransform/selectTransform.ts +0 -18
- package/src/common/reflectedElement/__tests__/reflectedElement.test.ts +0 -75
- package/src/common/reflectedElement/reflectedElement.ts +0 -50
- package/src/common/slot/__tests__/slot.test.ts +0 -96
- package/src/common/slot/slot.ts +0 -20
- /package/src/{common → modules/arch}/context/context.html +0 -0
- /package/src/{common → modules/arch}/context/context.ts +0 -0
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { EffectAdapter } from '../effectAdapter';
|
|
2
|
-
|
|
3
|
-
describe('EffectAdapter', () => {
|
|
4
|
-
it('calls the handler', async () => {
|
|
5
|
-
let value = Symbol();
|
|
6
|
-
let setValue = jest.fn();
|
|
7
|
-
let adapter = new EffectAdapter(setValue);
|
|
8
|
-
let config = { value: value };
|
|
9
|
-
adapter.update(config);
|
|
10
|
-
expect(setValue).toHaveBeenCalledWith(config);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<template></template>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { WireAdapter } from 'lwc';
|
|
2
|
-
|
|
3
|
-
export type EffectAdapterConfig<T> = {};
|
|
4
|
-
|
|
5
|
-
export class EffectAdapter<T>
|
|
6
|
-
implements
|
|
7
|
-
WireAdapter<EffectAdapterConfig<T>, EffectAdapterConfig<T>, void>
|
|
8
|
-
{
|
|
9
|
-
constructor(private setValue: (value: EffectAdapterConfig<T>) => void) {}
|
|
10
|
-
|
|
11
|
-
connect() {}
|
|
12
|
-
|
|
13
|
-
disconnect() {}
|
|
14
|
-
|
|
15
|
-
update(config: EffectAdapterConfig<T>) {
|
|
16
|
-
this.setValue(config);
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/common/reflectedElement/__tests__/modules/test/selectTransform/selectTransform.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ReflectedElement } from '../../../../reflectedElement';
|
|
2
|
-
|
|
3
|
-
export default class extends ReflectedElement {
|
|
4
|
-
get contentElement() {
|
|
5
|
-
return this.template.querySelector('select') as HTMLSelectElement;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
innerHTMLSetCallback() {
|
|
9
|
-
this.contentElement.setAttribute(
|
|
10
|
-
'data-count',
|
|
11
|
-
String(this.contentElement.querySelectorAll('option').length)
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
transformHTML(html: string) {
|
|
16
|
-
return `${html} <option value="last">Last</option>`;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { html, renderIntoBody } from 'shared/testutils';
|
|
2
|
-
|
|
3
|
-
import Select from './modules/test/select/select';
|
|
4
|
-
import SelectTransform from './modules/test/selectTransform/selectTransform';
|
|
5
|
-
|
|
6
|
-
customElements.define('test-select', Select.CustomElementConstructor);
|
|
7
|
-
customElements.define(
|
|
8
|
-
'test-select-transform',
|
|
9
|
-
SelectTransform.CustomElementConstructor
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
describe('reflected-element', () => {
|
|
13
|
-
afterEach(() => {
|
|
14
|
-
document.body.innerHTML = '';
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
// Skip these snapshot tests as LWC slot content doesn't render consistently in tests
|
|
18
|
-
it.skip('reflects the innerHTML', async () => {
|
|
19
|
-
let element = renderIntoBody(
|
|
20
|
-
html`
|
|
21
|
-
<test-select>
|
|
22
|
-
<option value="a">A</option>
|
|
23
|
-
<option value="b">B</option>
|
|
24
|
-
</test-select>
|
|
25
|
-
`
|
|
26
|
-
);
|
|
27
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
28
|
-
expect(
|
|
29
|
-
element.shadowRoot!.querySelector('select')!.innerHTML
|
|
30
|
-
).toMatchHTMLSnapshot();
|
|
31
|
-
}, 10000);
|
|
32
|
-
|
|
33
|
-
it.skip('transforms the innerHTML', async () => {
|
|
34
|
-
let element = renderIntoBody(
|
|
35
|
-
html`
|
|
36
|
-
<test-select-transform>
|
|
37
|
-
<option value="a">A</option>
|
|
38
|
-
<option value="b">B</option>
|
|
39
|
-
</test-select-transform>
|
|
40
|
-
`
|
|
41
|
-
);
|
|
42
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
43
|
-
expect(
|
|
44
|
-
element.shadowRoot!.querySelector('select')!.innerHTML
|
|
45
|
-
).toMatchHTMLSnapshot();
|
|
46
|
-
}, 10000);
|
|
47
|
-
|
|
48
|
-
it('renders components with reflected innerHTML', async () => {
|
|
49
|
-
let element = renderIntoBody(html`<test-select></test-select>`);
|
|
50
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
51
|
-
expect(element).toBeTruthy();
|
|
52
|
-
expect(element.shadowRoot!.querySelector('select')).toBeTruthy();
|
|
53
|
-
}, 10000);
|
|
54
|
-
|
|
55
|
-
it('calls innerHTMLSetCallback', async () => {
|
|
56
|
-
let element = renderIntoBody(
|
|
57
|
-
html`
|
|
58
|
-
<test-select-transform>
|
|
59
|
-
<option value="a">A</option>
|
|
60
|
-
<option value="b">B</option>
|
|
61
|
-
<option value="b">C</option>
|
|
62
|
-
</test-select-transform>
|
|
63
|
-
`
|
|
64
|
-
);
|
|
65
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
66
|
-
|
|
67
|
-
const select = element.shadowRoot!.querySelector('select')!;
|
|
68
|
-
const count = select.getAttribute('data-count');
|
|
69
|
-
|
|
70
|
-
// Due to LWC slot limitations, the count might be 1 or 4
|
|
71
|
-
// Just verify the callback was called (count attribute exists)
|
|
72
|
-
expect(select).toHaveAttribute('data-count');
|
|
73
|
-
expect(parseInt(count!)).toBeGreaterThan(0);
|
|
74
|
-
}, 10000);
|
|
75
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
* This element copies the innerHTML of the host (Light DOM)
|
|
4
|
-
* to the innerHTML of the element (Shadow DOM) returned by
|
|
5
|
-
* contentElement() (which must use the lwc:dom="manual" directive).
|
|
6
|
-
*/
|
|
7
|
-
import { LightningElement } from 'lwc';
|
|
8
|
-
|
|
9
|
-
export class ReflectedElement extends LightningElement {
|
|
10
|
-
private observer!: MutationObserver;
|
|
11
|
-
private didSetContent = false;
|
|
12
|
-
|
|
13
|
-
get contentElement(): Element {
|
|
14
|
-
throw new Error('Not Implemented');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
connectedCallback() {
|
|
18
|
-
this.observer = new MutationObserver((e) => {
|
|
19
|
-
this.setContent();
|
|
20
|
-
});
|
|
21
|
-
this.observer.observe(this.template.host, {
|
|
22
|
-
characterData: true,
|
|
23
|
-
childList: true,
|
|
24
|
-
subtree: true
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
disconnectedCallback() {
|
|
29
|
-
this.observer.disconnect();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
innerHTMLSetCallback() {}
|
|
33
|
-
|
|
34
|
-
renderedCallback() {
|
|
35
|
-
if (!this.didSetContent) {
|
|
36
|
-
this.didSetContent = true;
|
|
37
|
-
this.setContent();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
transformHTML(html: string): string {
|
|
42
|
-
return html;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private setContent() {
|
|
46
|
-
const element = this.contentElement;
|
|
47
|
-
element.innerHTML = this.transformHTML(this.template.host.innerHTML);
|
|
48
|
-
this.innerHTMLSetCallback();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { html, renderIntoBody } from 'shared/testutils';
|
|
2
|
-
|
|
3
|
-
import { assignedSlotNames, isSlotAssigned } from '../slot';
|
|
4
|
-
|
|
5
|
-
customElements.define(
|
|
6
|
-
'test-a',
|
|
7
|
-
class extends HTMLElement {
|
|
8
|
-
connectedCallback() {
|
|
9
|
-
this.attachShadow({ mode: 'open' });
|
|
10
|
-
this.shadowRoot!.innerHTML = `
|
|
11
|
-
<test-b>
|
|
12
|
-
<slot></slot>
|
|
13
|
-
<slot name="header" slot="header"></slot>
|
|
14
|
-
<slot name="footer" slot="footer"></slot>
|
|
15
|
-
</test-b>
|
|
16
|
-
`;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
customElements.define(
|
|
22
|
-
'test-b',
|
|
23
|
-
class extends HTMLElement {
|
|
24
|
-
connectedCallback() {
|
|
25
|
-
this.attachShadow({ mode: 'open' });
|
|
26
|
-
this.shadowRoot!.innerHTML = `
|
|
27
|
-
<slot></slot>
|
|
28
|
-
<slot name="header"></slot>
|
|
29
|
-
<slot name="footer"></slot>
|
|
30
|
-
`;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
describe('isSlotAssigned', () => {
|
|
36
|
-
describe('false', () => {
|
|
37
|
-
it('test-a', () => {
|
|
38
|
-
let element = renderIntoBody(html` <test-a></test-a> `);
|
|
39
|
-
let slot = element.shadowRoot!.querySelector('slot')!;
|
|
40
|
-
expect(isSlotAssigned(slot)).toBe(false);
|
|
41
|
-
});
|
|
42
|
-
it('test-b', () => {
|
|
43
|
-
let element = renderIntoBody(html` <test-a></test-a> `);
|
|
44
|
-
let slot = element
|
|
45
|
-
.shadowRoot!.querySelector('test-b')!
|
|
46
|
-
.shadowRoot!.querySelector('slot')!;
|
|
47
|
-
expect(isSlotAssigned(slot)).toBe(false);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
describe('true', () => {
|
|
51
|
-
it('test-a', () => {
|
|
52
|
-
let element = renderIntoBody(html`
|
|
53
|
-
<test-a>
|
|
54
|
-
<h1>Hello</h1>
|
|
55
|
-
</test-a>
|
|
56
|
-
`);
|
|
57
|
-
let slot = element.shadowRoot!.querySelector('slot')!;
|
|
58
|
-
expect(isSlotAssigned(slot)).toBe(true);
|
|
59
|
-
});
|
|
60
|
-
it('test-b', () => {
|
|
61
|
-
let element = renderIntoBody(html`
|
|
62
|
-
<test-a>
|
|
63
|
-
<h1>Hello</h1>
|
|
64
|
-
</test-a>
|
|
65
|
-
`);
|
|
66
|
-
let slot = element
|
|
67
|
-
.shadowRoot!.querySelector('test-b')!
|
|
68
|
-
.shadowRoot!.querySelector('slot')!;
|
|
69
|
-
expect(isSlotAssigned(slot)).toBe(true);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
describe('assignedSlotNames', () => {
|
|
75
|
-
it('test-a', () => {
|
|
76
|
-
let element = renderIntoBody(html`
|
|
77
|
-
<test-a>
|
|
78
|
-
<h1>Hello</h1>
|
|
79
|
-
<header slot="header"></header>
|
|
80
|
-
</test-a>
|
|
81
|
-
`);
|
|
82
|
-
let shadowRoot = element.shadowRoot!;
|
|
83
|
-
expect(assignedSlotNames(shadowRoot)).toEqual(['default', 'header']);
|
|
84
|
-
});
|
|
85
|
-
it('test-b', () => {
|
|
86
|
-
let element = renderIntoBody(html`
|
|
87
|
-
<test-a>
|
|
88
|
-
<h1>Hello</h1>
|
|
89
|
-
<header slot="header"></header>
|
|
90
|
-
</test-a>
|
|
91
|
-
`);
|
|
92
|
-
let shadowRoot =
|
|
93
|
-
element.shadowRoot!.querySelector('test-b')!.shadowRoot!;
|
|
94
|
-
expect(assignedSlotNames(shadowRoot)).toEqual(['default', 'header']);
|
|
95
|
-
});
|
|
96
|
-
});
|
package/src/common/slot/slot.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export function assignedSlotNames(template: {
|
|
2
|
-
querySelectorAll(selector: string): NodeList;
|
|
3
|
-
}) {
|
|
4
|
-
let slots = Array.from(
|
|
5
|
-
template.querySelectorAll('slot')
|
|
6
|
-
) as HTMLSlotElement[];
|
|
7
|
-
return slots
|
|
8
|
-
.filter(isSlotAssigned)
|
|
9
|
-
.map((slot) => slot.getAttribute('name') || 'default');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function isSlotAssigned(slot: HTMLSlotElement): boolean {
|
|
13
|
-
let [element] = slot.assignedElements();
|
|
14
|
-
if (element) {
|
|
15
|
-
if (element.tagName === 'SLOT')
|
|
16
|
-
return isSlotAssigned(element as HTMLSlotElement);
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
return slot.children.length > 0;
|
|
20
|
-
}
|
|
File without changes
|
|
File without changes
|