@salesforcedevs/arch-components 1.20.17-alpha13 → 1.20.17-alpha14
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
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @lwc/lwc/no-disallowed-lwc-imports */
|
|
1
2
|
import {
|
|
2
3
|
ContextConsumer,
|
|
3
4
|
createContextProvider,
|
|
@@ -5,9 +6,9 @@ import {
|
|
|
5
6
|
LightningElement,
|
|
6
7
|
wire,
|
|
7
8
|
WireAdapter
|
|
8
|
-
} from
|
|
9
|
+
} from "lwc";
|
|
9
10
|
|
|
10
|
-
import { EffectAdapter } from
|
|
11
|
+
import { EffectAdapter } from "arch/effectAdapter";
|
|
11
12
|
|
|
12
13
|
export interface ContextWireAdapter<Value, Config, Context>
|
|
13
14
|
extends WireAdapter<Value, Config, Context> {
|
|
@@ -86,35 +87,24 @@ export function createContextAdapter<Value, Config, Context>(
|
|
|
86
87
|
function compactConfig<T>(config?: T) {
|
|
87
88
|
return Object.fromEntries(
|
|
88
89
|
Object.entries({ ...config }).filter(
|
|
89
|
-
([
|
|
90
|
+
([, value]) => typeof value !== "undefined" && value !== null
|
|
90
91
|
)
|
|
91
92
|
);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
export function createBaseContextProviderElement<Value, Config, Context>(
|
|
95
|
-
adapterClass: ContextWireAdapterConstructor<Value, Config, Context>
|
|
96
|
-
) {
|
|
97
|
-
const contextualizer = createContextProvider(adapterClass);
|
|
98
|
-
|
|
99
|
-
return class ProviderElement extends BaseProvider<Context> {
|
|
100
|
-
public get contextualizer() {
|
|
101
|
-
return contextualizer;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
95
|
class BaseProvider<Context> extends LightningElement {
|
|
107
96
|
private consumers = new Set<ContextConsumer<Context>>();
|
|
108
97
|
|
|
109
98
|
public get contextualizer(): Contextualizer<Context> {
|
|
110
|
-
throw new Error(
|
|
99
|
+
throw new Error("contextualizer not implenented");
|
|
111
100
|
}
|
|
112
101
|
|
|
102
|
+
// eslint-disable-next-line @lwc/lwc/no-unknown-wire-adapters
|
|
113
103
|
@wire(EffectAdapter, {
|
|
114
|
-
localContext:
|
|
104
|
+
localContext: "$localContext"
|
|
115
105
|
})
|
|
116
106
|
private updateConsumers({ localContext }: { localContext: Context }) {
|
|
117
|
-
for (
|
|
107
|
+
for (const consumer of this.consumers) {
|
|
118
108
|
consumer.provide(localContext);
|
|
119
109
|
}
|
|
120
110
|
}
|
|
@@ -135,3 +125,15 @@ class BaseProvider<Context> extends LightningElement {
|
|
|
135
125
|
});
|
|
136
126
|
}
|
|
137
127
|
}
|
|
128
|
+
|
|
129
|
+
export function createBaseContextProviderElement<Value, Config, Context>(
|
|
130
|
+
adapterClass: ContextWireAdapterConstructor<Value, Config, Context>
|
|
131
|
+
) {
|
|
132
|
+
const contextualizer = createContextProvider(adapterClass);
|
|
133
|
+
|
|
134
|
+
return class ProviderElement extends BaseProvider<Context> {
|
|
135
|
+
public get contextualizer() {
|
|
136
|
+
return contextualizer;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable @lwc/lwc/no-disallowed-lwc-imports */
|
|
2
|
+
import { WireAdapter } from "lwc";
|
|
2
3
|
|
|
3
|
-
export type EffectAdapterConfig
|
|
4
|
+
export type EffectAdapterConfig = {};
|
|
4
5
|
|
|
5
|
-
export class EffectAdapter
|
|
6
|
-
implements
|
|
7
|
-
WireAdapter<EffectAdapterConfig<T>, EffectAdapterConfig<T>, void>
|
|
6
|
+
export class EffectAdapter
|
|
7
|
+
implements WireAdapter<EffectAdapterConfig, EffectAdapterConfig, void>
|
|
8
8
|
{
|
|
9
|
-
|
|
9
|
+
private setValue: (value: EffectAdapterConfig) => void;
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
constructor(setValue: (value: EffectAdapterConfig) => void) {
|
|
12
|
+
this.setValue = setValue;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
connect() {
|
|
16
|
+
// Required by WireAdapter interface
|
|
17
|
+
}
|
|
12
18
|
|
|
13
|
-
disconnect() {
|
|
19
|
+
disconnect() {
|
|
20
|
+
// Required by WireAdapter interface
|
|
21
|
+
}
|
|
14
22
|
|
|
15
|
-
update(config: EffectAdapterConfig
|
|
23
|
+
update(config: EffectAdapterConfig) {
|
|
16
24
|
this.setValue(config);
|
|
17
25
|
}
|
|
18
26
|
}
|
|
@@ -4,18 +4,18 @@
|
|
|
4
4
|
* to the innerHTML of the element (Shadow DOM) returned by
|
|
5
5
|
* contentElement() (which must use the lwc:dom="manual" directive).
|
|
6
6
|
*/
|
|
7
|
-
import { LightningElement } from
|
|
7
|
+
import { LightningElement } from "lwc";
|
|
8
8
|
|
|
9
9
|
export class ReflectedElement extends LightningElement {
|
|
10
10
|
private observer!: MutationObserver;
|
|
11
11
|
private didSetContent = false;
|
|
12
12
|
|
|
13
13
|
get contentElement(): Element {
|
|
14
|
-
throw new Error(
|
|
14
|
+
throw new Error("Not Implemented");
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
connectedCallback() {
|
|
18
|
-
this.observer = new MutationObserver((
|
|
18
|
+
this.observer = new MutationObserver(() => {
|
|
19
19
|
this.setContent();
|
|
20
20
|
});
|
|
21
21
|
this.observer.observe(this.template.host, {
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
export function assignedSlotNames(template: {
|
|
2
2
|
querySelectorAll(selector: string): NodeList;
|
|
3
3
|
}) {
|
|
4
|
-
|
|
5
|
-
template.querySelectorAll(
|
|
4
|
+
const slots = Array.from(
|
|
5
|
+
template.querySelectorAll("slot")
|
|
6
6
|
) as HTMLSlotElement[];
|
|
7
7
|
return slots
|
|
8
8
|
.filter(isSlotAssigned)
|
|
9
|
-
.map((slot) => slot.getAttribute(
|
|
9
|
+
.map((slot) => slot.getAttribute("name") || "default");
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export function isSlotAssigned(slot: HTMLSlotElement): boolean {
|
|
13
|
-
|
|
13
|
+
const [element] = slot.assignedElements();
|
|
14
14
|
if (element) {
|
|
15
|
-
if (element.tagName ===
|
|
15
|
+
if (element.tagName === "SLOT") {
|
|
16
16
|
return isSlotAssigned(element as HTMLSlotElement);
|
|
17
|
+
}
|
|
17
18
|
return true;
|
|
18
19
|
}
|
|
19
20
|
return slot.children.length > 0;
|