web-component-wrapper 0.0.599 → 0.0.601
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/dist/ReactWeb.d.ts +174 -0
- package/dist/Web.d.ts +463 -0
- package/dist/bundle/compatible/test.js +1 -1
- package/dist/bundle/test.js +1 -1
- package/dist/compatible/test.js +1 -1
- package/dist/decorator.d.ts +23 -0
- package/dist/index.d.ts +20 -0
- package/dist/test.d.ts +1 -0
- package/dist/test.js +1 -1
- package/dist/type.d.ts +100 -0
- package/package.json +19 -4
- package/polyfill.html.ejs +74 -0
- package/readme.md +28 -2
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { Logger, Mapping } from 'clientnode';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Root as ReactRoot } from 'react-dom/client';
|
|
4
|
+
import Web from './Web';
|
|
5
|
+
import { ComponentType, ReactComponentBaseProperties, ReactRenderItemFactory, ReactRenderItemsFactory, ReactRenderItems, WebComponentAPI } from './type';
|
|
6
|
+
export declare const log: Logger;
|
|
7
|
+
/**
|
|
8
|
+
* Adapter for exposing a React component as a web-component.
|
|
9
|
+
* @property attachWebComponentAdapterIfNotExists - Indicates whether to wrap
|
|
10
|
+
* with a reference wrapper to get updated about internal state changes.
|
|
11
|
+
* @property content - React component to wrap.
|
|
12
|
+
* @property react - React namespace.
|
|
13
|
+
* @property compiledSlots - Cache of yet pre-compiled slot elements.
|
|
14
|
+
* @property preparedSlots - Cache of yet evaluated slot react elements.
|
|
15
|
+
* @property rootReactInstance - Saves determined root react instance.
|
|
16
|
+
* @property self - Back-reference to this class.
|
|
17
|
+
* @property wrapMemorizingWrapper - Determines whether to wrap component with
|
|
18
|
+
* React's memorizing wrapper to cache component render results.
|
|
19
|
+
* @property isWrapped - Indicates whether a React component is wrapped
|
|
20
|
+
* already.
|
|
21
|
+
*/
|
|
22
|
+
export declare class ReactWeb<TElement = HTMLElement, ExternalProperties extends Mapping<unknown> = Mapping<unknown>, InternalProperties extends ReactComponentBaseProperties<TElement> = Mapping<unknown>> extends Web<TElement, ExternalProperties, InternalProperties> {
|
|
23
|
+
static attachWebComponentAdapterIfNotExists: boolean;
|
|
24
|
+
static content: ComponentType | string;
|
|
25
|
+
static react: typeof React;
|
|
26
|
+
static _name: string;
|
|
27
|
+
unmountOnDisconnect: boolean;
|
|
28
|
+
compiledSlots: (Mapping<ReactRenderItemsFactory> & {
|
|
29
|
+
children?: ReactRenderItemsFactory;
|
|
30
|
+
});
|
|
31
|
+
preparedSlots: Mapping<ReactRenderItems> & {
|
|
32
|
+
children?: ReactRenderItems;
|
|
33
|
+
};
|
|
34
|
+
reactRoot: null | ReactRoot;
|
|
35
|
+
rootReactInstance: null | ReactWeb;
|
|
36
|
+
readonly self: typeof ReactWeb;
|
|
37
|
+
wrapMemorizingWrapper: boolean | null;
|
|
38
|
+
isWrapped: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Triggered when this component is mounted into the document. Event
|
|
41
|
+
* handlers will be attached and the final render proceeds.
|
|
42
|
+
*/
|
|
43
|
+
connectedCallback(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Triggered when this component is unmounted from the document. Event
|
|
46
|
+
* handlers will be removed and state updated accordingly.
|
|
47
|
+
*/
|
|
48
|
+
disconnectedCallback(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Reflects wrapped component state back to web-component's attributes.
|
|
51
|
+
* @param properties - Properties to update in reflected attribute state.
|
|
52
|
+
*/
|
|
53
|
+
reflectExternalProperties(properties: Partial<ExternalProperties>): void;
|
|
54
|
+
/**
|
|
55
|
+
* Method that does the rendering job. Should be called when ever state
|
|
56
|
+
* changes should be projected to the hosts dom content.
|
|
57
|
+
* @param reason - Description why rendering is necessary.
|
|
58
|
+
* @param resolveRendering - Indicates whether rendering should be resolved
|
|
59
|
+
* finally. Should be set to "false" via super calls in inherited render
|
|
60
|
+
* methods which do further dom manipulations afterward and resolve the
|
|
61
|
+
* rendering process by their own.
|
|
62
|
+
* @returns A promise resolving when rendering has finished. A promise may
|
|
63
|
+
* be needed for classes inheriting from this class.
|
|
64
|
+
*/
|
|
65
|
+
render(reason?: string, resolveRendering?: boolean): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Generic property setter. Forwards field writes into internal and
|
|
68
|
+
* external property representations.
|
|
69
|
+
*
|
|
70
|
+
* In general, it is a bad idea to write properties which shadow state
|
|
71
|
+
* properties (move to a controlled component instance) and re-set the
|
|
72
|
+
* property to "undefined" later to lose control.
|
|
73
|
+
*
|
|
74
|
+
* The reason causes in avoiding this scenario:
|
|
75
|
+
*
|
|
76
|
+
* 1. Property overwrites the state.
|
|
77
|
+
* 2. State changes but is shadowed by recent changes in property.
|
|
78
|
+
*
|
|
79
|
+
* So the following will be ensured:
|
|
80
|
+
*
|
|
81
|
+
* 1. Property overwrites the state.
|
|
82
|
+
* 2. Property is overwritten to "undefined" to lose control over the
|
|
83
|
+
* state.
|
|
84
|
+
* 3. Now a state change can be represented back after property adaptions.
|
|
85
|
+
* (Converts reacts declarative nature into an imperative web-component
|
|
86
|
+
* style).
|
|
87
|
+
* 4. Further state changes should be communicated back via output events.
|
|
88
|
+
* @param name - Property name to write.
|
|
89
|
+
* @param value - New value to write.
|
|
90
|
+
*/
|
|
91
|
+
setPropertyValue(name: string, value: unknown): void;
|
|
92
|
+
/**
|
|
93
|
+
* Internal property setter. Respects configured aliases.
|
|
94
|
+
* @param name - Property name to write.
|
|
95
|
+
* @param value - New value to write.
|
|
96
|
+
*/
|
|
97
|
+
setInternalPropertyValue(name: string, value: unknown): void;
|
|
98
|
+
/**
|
|
99
|
+
* Converts given html dom nodes into a compiled function to generate a
|
|
100
|
+
* react-element or a react-element list.
|
|
101
|
+
* @param domNodes - Nodes to convert.
|
|
102
|
+
* @param scope - Additional scope to render subcomponents against.
|
|
103
|
+
* Necessary to bound necessary environment variables into compiled context.
|
|
104
|
+
* @param isFunction - Indicates whether a given render result should be
|
|
105
|
+
* provided as function (render property) with bound parameters environment
|
|
106
|
+
* variable name.
|
|
107
|
+
* @returns Transformed react elements.
|
|
108
|
+
*/
|
|
109
|
+
preCompileDomNodes(domNodes: Array<Node>, scope?: Mapping<unknown>, isFunction?: boolean): ReactRenderItemsFactory;
|
|
110
|
+
/**
|
|
111
|
+
* Converts a given html dom node into a react-element.
|
|
112
|
+
* @param domNode - Node to convert.
|
|
113
|
+
* @param scope - Additional scope to render subcomponents against.
|
|
114
|
+
* @param isFunction - Indicates whether given nodes should be provided as
|
|
115
|
+
* function (render property).
|
|
116
|
+
* @param key - Optional key to add to component properties.
|
|
117
|
+
* @returns Transformed react element.
|
|
118
|
+
*/
|
|
119
|
+
preCompileDomNode(domNode: Node, scope?: Mapping<unknown>, isFunction?: boolean, key?: string): ReactRenderItemFactory;
|
|
120
|
+
/**
|
|
121
|
+
* Evaluates given pre-compiled nodes into a single react element or a
|
|
122
|
+
* React element list.
|
|
123
|
+
* @param nodes - Pre-compiled nodes.
|
|
124
|
+
* @param scope - Additional scope to render subcomponents against.
|
|
125
|
+
* @returns Transformed react elements.
|
|
126
|
+
*/
|
|
127
|
+
evaluatePreCompiledDomNodes(nodes: ReactRenderItemsFactory, scope?: Mapping<unknown>): ReactRenderItems;
|
|
128
|
+
/**
|
|
129
|
+
* Pre compiles and caches determined slots.
|
|
130
|
+
*/
|
|
131
|
+
preCompileSlots(): void;
|
|
132
|
+
/**
|
|
133
|
+
* Evaluates pre-compiled slots.
|
|
134
|
+
* @param scope - To render again.
|
|
135
|
+
*/
|
|
136
|
+
evaluateSlots(scope: Mapping<unknown>): void;
|
|
137
|
+
/**
|
|
138
|
+
* Determines if the given element type is a react-wrapped component.
|
|
139
|
+
* @param domNode - Node to determine from.
|
|
140
|
+
* @returns Boolean indicator.
|
|
141
|
+
*/
|
|
142
|
+
static isReactComponent(domNode: Node): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Determines initial root and react root who initializes their rendering
|
|
145
|
+
* digests.
|
|
146
|
+
*/
|
|
147
|
+
determineRootBinding(): void;
|
|
148
|
+
/**
|
|
149
|
+
* Applies missing forward ref and or memorizing wrapper to a current react
|
|
150
|
+
* component.
|
|
151
|
+
*/
|
|
152
|
+
applyComponentWrapper(): void;
|
|
153
|
+
/**
|
|
154
|
+
* Prepares a given properties object to render against the current
|
|
155
|
+
* component. Creates a reference for being recognized of reacts internal
|
|
156
|
+
* state updates.
|
|
157
|
+
* @param properties - Properties to prepare.
|
|
158
|
+
*/
|
|
159
|
+
prepareProperties(properties: InternalProperties): void;
|
|
160
|
+
/**
|
|
161
|
+
* Updates the current component instance and reflects newly determined
|
|
162
|
+
* properties.
|
|
163
|
+
*/
|
|
164
|
+
reflectInstanceProperties: () => void;
|
|
165
|
+
/**
|
|
166
|
+
* Removes unwanted known and not specified properties from a given
|
|
167
|
+
* properties object (usually added by dev-tools).
|
|
168
|
+
* @param target - ReactElement where properties belong to.
|
|
169
|
+
* @param properties - Properties object to trim.
|
|
170
|
+
*/
|
|
171
|
+
static removeKnownUnwantedPropertyKeys(target: typeof ReactWeb, properties: Mapping<unknown>): void;
|
|
172
|
+
}
|
|
173
|
+
export declare const api: WebComponentAPI<HTMLElement, Mapping<unknown>, ReactComponentBaseProperties, typeof ReactWeb>;
|
|
174
|
+
export default ReactWeb;
|
package/dist/Web.d.ts
ADDED
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
import { KnownEventName, KnownWindowEventMap, Logger, Mapping } from 'clientnode';
|
|
2
|
+
import { AttributesReflectionConfiguration, CompiledDomNodeTemplateItem, CompilerOptions, ComponentAdapter, DomNodeToCompiledTemplateMap, EventCallbackMapping, EventToPropertyMapping, NormalizedAttributesReflectionConfiguration, PropertiesConfiguration, RenderState, ScopeDeclaration, WebComponentAPI } from './type';
|
|
3
|
+
export declare const log: Logger;
|
|
4
|
+
export declare const GenericHTMLElement: typeof HTMLElement;
|
|
5
|
+
/**
|
|
6
|
+
* Generic web component to render a content against instance-specific values.
|
|
7
|
+
* @property applyRootBinding - If determined itself as root declarative event
|
|
8
|
+
* and property bindings will be applied to itself.
|
|
9
|
+
* @property content - Content to render when changes happened.
|
|
10
|
+
* @property determineRootBinding - If checked this component determines if it
|
|
11
|
+
* is a root component (not wrapped by another web-component).
|
|
12
|
+
* @property shadowDOM - Configures if a shadow dom should be used during
|
|
13
|
+
* web-component instantiation. Can hold initialize configuration.
|
|
14
|
+
* @property observedAttributes - Attribute names to observe for changes.
|
|
15
|
+
* @property controllableProperties - A list of controllable property names.
|
|
16
|
+
* @property eventToPropertyMapping - Explicitly defined output events (a
|
|
17
|
+
* mapping of event names to a potential parameter to properties-transformer).
|
|
18
|
+
* @property propertyAliases - A mapping of property names to be treated as
|
|
19
|
+
* equal.
|
|
20
|
+
* @property propertyTypes - Configuration defining how to convert attributes
|
|
21
|
+
* into properties and reflect property changes back to attributes.
|
|
22
|
+
* @property propertiesToReflectAsAttributes - An Item, List, or Mapping of
|
|
23
|
+
* properties to reflect as attributes.
|
|
24
|
+
* @property renderProperties - List of known render properties.
|
|
25
|
+
* @property cloneSlots - Indicates whether to clone slot before to transclude
|
|
26
|
+
* content into them. If a slot should be used multiple times (for example,
|
|
27
|
+
* when it works as a template node.) they should be copied to avoid unexpected
|
|
28
|
+
* mutations.
|
|
29
|
+
* @property doRender - Configures whether this component instance should
|
|
30
|
+
* evaluate its given body content.
|
|
31
|
+
* @property evaluateSlots - Indicates whether to evaluate slot content when
|
|
32
|
+
* before rendering them.
|
|
33
|
+
* @property renderSlots - Indicates whether determined slots should be
|
|
34
|
+
* rendered into root node.
|
|
35
|
+
* @property trimSlots - Ignore empty text nodes while applying slots.
|
|
36
|
+
* @property renderUnsafe - Defines default render behavior.
|
|
37
|
+
* @property _name - Name to access instance-evaluated content or used
|
|
38
|
+
* to derive default component name. This is also useful for logging.
|
|
39
|
+
* @property _propertyAliasIndex - Internal alias index to quickly match
|
|
40
|
+
* properties in both directions.
|
|
41
|
+
* @property _propertiesToReflectAsAttributes - A mapping of property names to
|
|
42
|
+
* set as attributes when they are set/updated. Uses a map to hold order and
|
|
43
|
+
* determine if a property exists in constant runtime.
|
|
44
|
+
* @property renderState - Holds data about currently running render state.
|
|
45
|
+
* @property renderState.promise - Promise resolving when next rendering has
|
|
46
|
+
* been finished.
|
|
47
|
+
* @property renderState.pending - Indicates whether a rendering task is
|
|
48
|
+
* performing.
|
|
49
|
+
* @property renderState.resolve - Callback to trigger when rendering has been
|
|
50
|
+
* finished.
|
|
51
|
+
* @property childComponentInstances - List of direct child components (needed
|
|
52
|
+
* to wait for them to finish dom manipulation).
|
|
53
|
+
* @property batchAttributeUpdates - Indicates whether to directly update dom
|
|
54
|
+
* after each attribute mutation or to wait and batch mutations after current
|
|
55
|
+
* queue has been finished.
|
|
56
|
+
* @property batchPropertyUpdates - Indicates whether to directly update dom
|
|
57
|
+
* after each property mutation or to wait and batch mutations after current
|
|
58
|
+
* queue has been finished.
|
|
59
|
+
* @property batchUpdates - Indicates whether to directly perform a
|
|
60
|
+
* re-rendering after changes on properties have been made.
|
|
61
|
+
* @property batchedAttributeUpdateRunning - A boolean indicator to identify if
|
|
62
|
+
* an attribute update is currently batched.
|
|
63
|
+
* @property batchedPropertyUpdateRunning - A boolean indicator to identify if
|
|
64
|
+
* a property update is currently batched.
|
|
65
|
+
* @property batchedUpdateRunning - Indicates whether a batched render update
|
|
66
|
+
* is currently running.
|
|
67
|
+
* @param connectionRegistered - Indicates whether this component is connected
|
|
68
|
+
* to DOM and could run its connectedCallback.
|
|
69
|
+
* @param pendingAttributeUpdates - Holds pending attribute updates which
|
|
70
|
+
* should be performed when the component is connected to DOM.
|
|
71
|
+
* @property parentInstance - Parent component instance.
|
|
72
|
+
* @property rootInstance - Root component instance.
|
|
73
|
+
* @property scope - Render scope.
|
|
74
|
+
* @property domNodeEventBindings - Holds a mapping from nodes with registered
|
|
75
|
+
* event handlers mapped to their deregistration function.
|
|
76
|
+
* @property domNodeTemplateCache - Caches template compilation results.
|
|
77
|
+
* @property externalProperties - Holds currently evaluated or seen properties.
|
|
78
|
+
* @property ignoreAttributeUpdateObservations - Indicates whether attribute
|
|
79
|
+
* updates should be considered (usually only needed internally).
|
|
80
|
+
* @property internalProperties - Holds currently evaluated properties which
|
|
81
|
+
* are owned by this instance and should always be delegated.
|
|
82
|
+
* @property outputEventNames - Set of determined output event names.
|
|
83
|
+
* @property instance - Wrapped component instance.
|
|
84
|
+
* @property isRoot - Indicates whether their exists another web-derived
|
|
85
|
+
* component up the tree or not.
|
|
86
|
+
* @property root - Hosting dom node.
|
|
87
|
+
* @property runDomConnectionAndRenderingInSameEventQueue - Indicates whether
|
|
88
|
+
* we should render initial dom immediately after the component is connected to
|
|
89
|
+
* dom. Deactivating this allows wrapped components to detect their parents
|
|
90
|
+
* since their parent-connected callback will be called before the children's
|
|
91
|
+
* render method.
|
|
92
|
+
* @property self - Back-reference to this class.
|
|
93
|
+
* @property slots - Grabbed slots that where present in the connecting phase.
|
|
94
|
+
*/
|
|
95
|
+
export declare class Web<TElement = HTMLElement, ExternalProperties extends Mapping<unknown> = Mapping<unknown>, InternalProperties extends Mapping<unknown> = Mapping<unknown>> extends GenericHTMLElement {
|
|
96
|
+
static applyRootBinding: boolean;
|
|
97
|
+
static pendingRenderPromises: Array<Promise<string>>;
|
|
98
|
+
static content: unknown;
|
|
99
|
+
static determineRootBinding: boolean;
|
|
100
|
+
static shadowDOM: (boolean | null | {
|
|
101
|
+
delegateFocus?: boolean;
|
|
102
|
+
mode: 'closed' | 'open';
|
|
103
|
+
});
|
|
104
|
+
static observedAttributes: Array<string>;
|
|
105
|
+
static controllableProperties: Array<string>;
|
|
106
|
+
static eventToPropertyMapping: EventToPropertyMapping | null;
|
|
107
|
+
static propertyAliases: Mapping;
|
|
108
|
+
static propertyTypes: PropertiesConfiguration;
|
|
109
|
+
static propertiesToReflectAsAttributes: AttributesReflectionConfiguration;
|
|
110
|
+
static renderProperties: Array<string>;
|
|
111
|
+
static doRender: boolean;
|
|
112
|
+
static cloneSlots: boolean;
|
|
113
|
+
static evaluateSlots: boolean;
|
|
114
|
+
static renderSlots: boolean;
|
|
115
|
+
static trimSlots: boolean;
|
|
116
|
+
static renderUnsafe: boolean;
|
|
117
|
+
static _name: string;
|
|
118
|
+
static _propertyAliasIndex?: Mapping;
|
|
119
|
+
static _propertiesToReflectAsAttributes?: NormalizedAttributesReflectionConfiguration;
|
|
120
|
+
renderState: RenderState;
|
|
121
|
+
childComponentInstances: Array<Web> | undefined;
|
|
122
|
+
batchAttributeUpdates: boolean;
|
|
123
|
+
batchPropertyUpdates: boolean;
|
|
124
|
+
batchUpdates: boolean;
|
|
125
|
+
batchedAttributeUpdateRunning: boolean;
|
|
126
|
+
batchedPropertyUpdateRunning: boolean;
|
|
127
|
+
batchedUpdateRunning: boolean;
|
|
128
|
+
connectionRegistered: boolean;
|
|
129
|
+
pendingAttributeUpdates: Array<() => void>;
|
|
130
|
+
parentInstance: null | Web;
|
|
131
|
+
rootInstance: Web;
|
|
132
|
+
hostDomNode: ShadowRoot | Web<TElement, ExternalProperties, InternalProperties>;
|
|
133
|
+
scope: Mapping<unknown>;
|
|
134
|
+
domNodeEventBindings: Map<Node | Window, EventCallbackMapping>;
|
|
135
|
+
domNodeTemplateCache: DomNodeToCompiledTemplateMap;
|
|
136
|
+
externalProperties: ExternalProperties;
|
|
137
|
+
ignoreAttributeUpdateObservations: boolean;
|
|
138
|
+
internalProperties: InternalProperties;
|
|
139
|
+
outputEventNames: Set<string>;
|
|
140
|
+
instance: null | {
|
|
141
|
+
current?: ComponentAdapter;
|
|
142
|
+
};
|
|
143
|
+
isRoot: boolean;
|
|
144
|
+
runDomConnectionAndRenderingInSameEventQueue: boolean;
|
|
145
|
+
readonly self: typeof Web;
|
|
146
|
+
slots: Mapping<HTMLElement | undefined> & {
|
|
147
|
+
default?: Array<Node>;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Initializes host dom content and properties.
|
|
151
|
+
* @returns Nothing.
|
|
152
|
+
*/
|
|
153
|
+
constructor();
|
|
154
|
+
/**
|
|
155
|
+
* Triggered when ever a given attribute has changed and triggers to update
|
|
156
|
+
* configured dom content.
|
|
157
|
+
* @param name - Attribute name which was updates.
|
|
158
|
+
* @param oldValue - Old attribute value.
|
|
159
|
+
* @param newValue - New updated value.
|
|
160
|
+
*/
|
|
161
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
162
|
+
/**
|
|
163
|
+
* Updates given attribute representation.
|
|
164
|
+
* @param name - Attribute name which was updates.
|
|
165
|
+
* @param newValue - New updated value.
|
|
166
|
+
* @returns Promise resolving when attribute has been updated.
|
|
167
|
+
*/
|
|
168
|
+
onUpdateAttribute(name: string, newValue: string): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Triggered when this component is mounted into the document.
|
|
171
|
+
* Attaches event handler, grabs given slots, reflects external properties,
|
|
172
|
+
* and enqueues first rendering.
|
|
173
|
+
*/
|
|
174
|
+
connectedCallback(): void;
|
|
175
|
+
/**
|
|
176
|
+
* Triggered when this component is unmounted from the document. Event
|
|
177
|
+
* handlers will be removed and state updated accordingly.
|
|
178
|
+
*/
|
|
179
|
+
disconnectedCallback(): void;
|
|
180
|
+
/**
|
|
181
|
+
* Registers needed getter and setter to get notified about changes and
|
|
182
|
+
* reflect them.
|
|
183
|
+
*/
|
|
184
|
+
defineGetterAndSetterInterface(): void;
|
|
185
|
+
/**
|
|
186
|
+
* Creates an index to match alias source and target against each other on
|
|
187
|
+
* constant runtime.
|
|
188
|
+
* @param name - Name to search an alternate name for.
|
|
189
|
+
* @returns Found alias or "null".
|
|
190
|
+
*/
|
|
191
|
+
getPropertyAlias(name: string): null | string;
|
|
192
|
+
/**
|
|
193
|
+
* Generic property getter. Forwards properties from the "properties"
|
|
194
|
+
* field.
|
|
195
|
+
* @param name - Property name to retrieve.
|
|
196
|
+
* @returns Retrieved property value.
|
|
197
|
+
*/
|
|
198
|
+
getPropertyValue(name: string): unknown;
|
|
199
|
+
/**
|
|
200
|
+
* External property setter. Respects configured aliases.
|
|
201
|
+
* @param name - Property name to write.
|
|
202
|
+
* @param value - New value to write.
|
|
203
|
+
*/
|
|
204
|
+
setExternalPropertyValue(name: string, value: unknown): void;
|
|
205
|
+
/**
|
|
206
|
+
* Internal property setter. Respects configured aliases.
|
|
207
|
+
* @param name - Property name to write.
|
|
208
|
+
* @param value - New value to write.
|
|
209
|
+
*/
|
|
210
|
+
setInternalPropertyValue(name: string, value: unknown): void;
|
|
211
|
+
/**
|
|
212
|
+
* Generic property setter. Forwards field writes into internal and
|
|
213
|
+
* external property representations.
|
|
214
|
+
* @param name - Property name to write.
|
|
215
|
+
* @param value - New value to write.
|
|
216
|
+
*/
|
|
217
|
+
setPropertyValue(name: string, value: unknown): void;
|
|
218
|
+
/**
|
|
219
|
+
* Triggers a new rendering cycle and respects property-specific state
|
|
220
|
+
* connection.
|
|
221
|
+
* @param name - Property name to write.
|
|
222
|
+
* @param value - New value to write.
|
|
223
|
+
*/
|
|
224
|
+
triggerPropertySpecificRendering(name: string, value: unknown): void;
|
|
225
|
+
unregisterConnectionState(): void;
|
|
226
|
+
unregisterDomNodeEventBindings(): void;
|
|
227
|
+
/**
|
|
228
|
+
* Binds properties and event handler to the given dom node.
|
|
229
|
+
* @param domNode - Node to start traversing from.
|
|
230
|
+
* @param scope - Scope to render property value again.
|
|
231
|
+
*/
|
|
232
|
+
applyBinding(domNode: Node, scope: Mapping<unknown>): void;
|
|
233
|
+
/**
|
|
234
|
+
* Binds properties and event handler to given, sibling, and nested nodes.
|
|
235
|
+
* @param domNode - Node to start traversing from.
|
|
236
|
+
* @param scope - Scope to render property value again.
|
|
237
|
+
* @param renderSlots - Indicates whether to render nested elements of
|
|
238
|
+
* slots (determined by an existing corresponding attribute).
|
|
239
|
+
*/
|
|
240
|
+
applyBindings(domNode: Node | null, scope: Mapping<unknown>, renderSlots?: boolean): void;
|
|
241
|
+
/**
|
|
242
|
+
* Compiles given node content and their children. Provides a corresponding
|
|
243
|
+
* map of compiled template functions connected to their (sub) nodes and
|
|
244
|
+
* expected scope names.
|
|
245
|
+
* @param domNode - Node to compile.
|
|
246
|
+
* @param scope - Scope to extract names from.
|
|
247
|
+
* @param options - Additional compile options.
|
|
248
|
+
* @param options.filter - Callback to exclude some node from being
|
|
249
|
+
* compiled.
|
|
250
|
+
* @param options.ignoreComponents - Indicates if component properties
|
|
251
|
+
* should be traversed or not.
|
|
252
|
+
* @param options.ignoreNestedComponents - Indicates if nested components
|
|
253
|
+
* should be traversed or not.
|
|
254
|
+
* @param options.unsafe - Indicates if full HTML generation should be
|
|
255
|
+
* allowed.
|
|
256
|
+
* @returns Map of compiled templates.
|
|
257
|
+
*/
|
|
258
|
+
compileDomNodeTemplate<NodeType extends Node = Node>(domNode: NodeType, scope?: ScopeDeclaration, options?: CompilerOptions): CompiledDomNodeTemplateItem | null;
|
|
259
|
+
/**
|
|
260
|
+
* @param options - Evaluation options.
|
|
261
|
+
* @param scope - Scope to evaluate against.
|
|
262
|
+
* @returns Evaluated string result or null.
|
|
263
|
+
*/
|
|
264
|
+
evaluateCompiledDomNodeTemplate(options: CompiledDomNodeTemplateItem, scope: Mapping<unknown>): null | string;
|
|
265
|
+
/**
|
|
266
|
+
* Compiles and evaluates given node content and their children. Replaces
|
|
267
|
+
* each node content with their evaluated representation.
|
|
268
|
+
* @param domNode - Node to evaluate.
|
|
269
|
+
* @param scope - Scope to render against.
|
|
270
|
+
* @param options - Compile options.
|
|
271
|
+
* @param options.applyBindings - Indicates whether to apply bindings to
|
|
272
|
+
* given dom nodes.
|
|
273
|
+
* @param options.filter - Callback to exclude some node from being
|
|
274
|
+
* compiled.
|
|
275
|
+
* @param options.ignoreComponents - Indicates if component properties
|
|
276
|
+
* should be traversed or not.
|
|
277
|
+
* @param options.ignoreNestedComponents - Indicates if nested components
|
|
278
|
+
* should be traversed or not.
|
|
279
|
+
* @param options.domNodeTemplateCache - Yet compiled dom nodes to just
|
|
280
|
+
* reference instead of recompiling.
|
|
281
|
+
* @param options.unsafe - Indicates if full HTML generation should be
|
|
282
|
+
* allowed.
|
|
283
|
+
*/
|
|
284
|
+
evaluateDomNodeTemplate<NodeType extends Node = Node>(domNode: NodeType, scope?: Mapping<unknown>, options?: {
|
|
285
|
+
applyBindings?: boolean;
|
|
286
|
+
domNodeTemplateCache?: DomNodeToCompiledTemplateMap;
|
|
287
|
+
filter?: (domNode: Node) => boolean;
|
|
288
|
+
ignoreComponents?: boolean;
|
|
289
|
+
ignoreNestedComponents?: boolean;
|
|
290
|
+
unsafe?: boolean;
|
|
291
|
+
}): void;
|
|
292
|
+
/**
|
|
293
|
+
* Adds an event listener to the given dom node so that it will be
|
|
294
|
+
* deregistered when the component instance is destroyed.
|
|
295
|
+
* @param domNode - Node to assign event handler to.
|
|
296
|
+
* @param name - Event name.
|
|
297
|
+
* @param handler - Callback to trigger when given event occurs.
|
|
298
|
+
* @param options - Add event listener options.
|
|
299
|
+
* @param removeOptions - Remove event listener options.
|
|
300
|
+
* @returns Deregister function.
|
|
301
|
+
*/
|
|
302
|
+
addSecureEventListener<EventName extends KnownEventName>(domNode: Node | Window, name: EventName, handler: (this: Window, event: KnownWindowEventMap[EventName]) => void, options?: boolean | AddEventListenerOptions, removeOptions?: EventListenerOptions): () => void;
|
|
303
|
+
/**
|
|
304
|
+
* Determines initial root which initializes rendering digest.
|
|
305
|
+
*/
|
|
306
|
+
determineRootBinding(): void;
|
|
307
|
+
/**
|
|
308
|
+
* Checks if given content hast code (to compile and render).
|
|
309
|
+
* @param content - Potential string with code inside.
|
|
310
|
+
* @returns A boolean indicating whether given content has code.
|
|
311
|
+
*/
|
|
312
|
+
static hasCode(content: unknown): boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Converts given the list, item, or map to a map (with ordering).
|
|
315
|
+
* @param value - Attribute reflection configuration.
|
|
316
|
+
* @returns Generated map.
|
|
317
|
+
*/
|
|
318
|
+
static normalizePropertyTypeList(value: AttributesReflectionConfiguration): NormalizedAttributesReflectionConfiguration;
|
|
319
|
+
/**
|
|
320
|
+
* Attaches event handler to keep in sync with nested components properties
|
|
321
|
+
* states.
|
|
322
|
+
*/
|
|
323
|
+
attachEventHandler(): void;
|
|
324
|
+
/**
|
|
325
|
+
* Attach explicitly defined event handler to synchronize internal and
|
|
326
|
+
* external property states.
|
|
327
|
+
* @returns Returns "true" if there are some defined and "false" otherwise.
|
|
328
|
+
*/
|
|
329
|
+
attachExplicitDefinedOutputEventHandler(): boolean;
|
|
330
|
+
/**
|
|
331
|
+
* Attach implicitly defined event handler to synchronize internal and
|
|
332
|
+
* external property states.
|
|
333
|
+
* @param reflectProperties - Indicates whether implicitly determined
|
|
334
|
+
* properties should be reflected.
|
|
335
|
+
*/
|
|
336
|
+
attachImplicitDefinedOutputEventHandler(reflectProperties?: boolean): void;
|
|
337
|
+
/**
|
|
338
|
+
* Triggers all identified events to communicate internal property / state
|
|
339
|
+
* changes.
|
|
340
|
+
*/
|
|
341
|
+
triggerOutputEvents(): void;
|
|
342
|
+
/**
|
|
343
|
+
* Forwards given event as the native web event.
|
|
344
|
+
* @param name - Event name.
|
|
345
|
+
* @param parameters - Event parameters.
|
|
346
|
+
* @returns False if event is cancelable, and at least one of the event
|
|
347
|
+
* handlers which received event called "Event.preventDefault()",
|
|
348
|
+
* otherwise true will be returned.
|
|
349
|
+
*/
|
|
350
|
+
forwardEvent(name: string, parameters: Array<unknown>): boolean;
|
|
351
|
+
/**
|
|
352
|
+
* Renders component given slot contents into the given dom node. If
|
|
353
|
+
* expected slots are not given but a fallback is specified, they will be
|
|
354
|
+
* loaded into internal slot mapping.
|
|
355
|
+
* @param targetDomNode - Target dom node to render slots into.
|
|
356
|
+
* @param scope - Environment to render slots again if specified.
|
|
357
|
+
*/
|
|
358
|
+
applySlots(targetDomNode: HTMLElement, scope: Mapping<unknown>): void;
|
|
359
|
+
/**
|
|
360
|
+
* Determines slot content from the given node.
|
|
361
|
+
* @param slot - Node to grab slot content from.
|
|
362
|
+
* @returns Determined slot.
|
|
363
|
+
*/
|
|
364
|
+
grabSlotContent(slot: Node): Node;
|
|
365
|
+
/**
|
|
366
|
+
* Saves given slots.
|
|
367
|
+
*/
|
|
368
|
+
grabGivenSlots(): void;
|
|
369
|
+
/**
|
|
370
|
+
* Determines if a given property name exists in wrapped component state.
|
|
371
|
+
* @param name - Property name to check if exists in state.
|
|
372
|
+
* @returns Boolean result.
|
|
373
|
+
*/
|
|
374
|
+
isStateProperty(name: string): boolean;
|
|
375
|
+
/**
|
|
376
|
+
* Generates an alias to name and the other way around mapping if not
|
|
377
|
+
* exists.
|
|
378
|
+
*/
|
|
379
|
+
generateAliasIndex(): void;
|
|
380
|
+
/**
|
|
381
|
+
* Reflects wrapped component state back to web-component's attributes.
|
|
382
|
+
* @param properties - Properties to update in reflected attribute state.
|
|
383
|
+
*/
|
|
384
|
+
reflectExternalProperties(properties: Partial<ExternalProperties>): void;
|
|
385
|
+
/**
|
|
386
|
+
* Reflects wrapped component state back to web-component's attributes and
|
|
387
|
+
* properties.
|
|
388
|
+
* @param properties - Properties to update in reflected property state.
|
|
389
|
+
*/
|
|
390
|
+
reflectProperties(properties: Partial<ExternalProperties>): void;
|
|
391
|
+
/**
|
|
392
|
+
* Reflect the given event handler call with the given parameter back to
|
|
393
|
+
* current properties state.
|
|
394
|
+
* @param name - Event name.
|
|
395
|
+
* @param parameters - List of parameter to given event handler call.
|
|
396
|
+
* @returns Mapped properties or null if nothing could be mapped.
|
|
397
|
+
*/
|
|
398
|
+
reflectEventToProperties(name: string, parameters: Array<unknown>): Promise<Partial<ExternalProperties> | null>;
|
|
399
|
+
/**
|
|
400
|
+
* Evaluates the given property value depending on its property definition
|
|
401
|
+
* and registers in a property mapping object.
|
|
402
|
+
* @param attributeName - Name of given value.
|
|
403
|
+
* @param value - Value to evaluate.
|
|
404
|
+
*/
|
|
405
|
+
evaluateStringOrNullAndSetAsProperty(attributeName: string, value: null | string): void;
|
|
406
|
+
/**
|
|
407
|
+
* Produces a promise resolving when all nested rendering promises have
|
|
408
|
+
* been resolved. This only waits for registered nested components. That
|
|
409
|
+
* means that nested components which where connected before the parent
|
|
410
|
+
* component got initialized will not be waited for. That might happen
|
|
411
|
+
* when nested component types got registered before the parent ones.
|
|
412
|
+
*/
|
|
413
|
+
waitForNestedComponentRendering(): Promise<void>;
|
|
414
|
+
/**
|
|
415
|
+
* Resolves the rendering promise.
|
|
416
|
+
* @param reason - Rendering reason description.
|
|
417
|
+
* @param resolveRendering - Indicates whether to resolve the rendering or
|
|
418
|
+
* just return a resolving promise directly.
|
|
419
|
+
* @returns A promise resolving when all nested render promises have been
|
|
420
|
+
* resolved.
|
|
421
|
+
*/
|
|
422
|
+
resolveRenderingPromiseIfSet(reason: string, resolveRendering: boolean): Promise<void>;
|
|
423
|
+
/**
|
|
424
|
+
* Sets up a new rendering cycle representing promise.
|
|
425
|
+
*/
|
|
426
|
+
prepareNewRenderingPromise(): void;
|
|
427
|
+
/**
|
|
428
|
+
* Triggers a new rendering cycle by respecting batch configuration.
|
|
429
|
+
* @param reason - A description why rendering should be triggered.
|
|
430
|
+
*/
|
|
431
|
+
triggerRender(reason: string): void;
|
|
432
|
+
/**
|
|
433
|
+
* Creates shadow root if not created yet and assigns to the current root
|
|
434
|
+
* property.
|
|
435
|
+
*/
|
|
436
|
+
applyShadowRootIfNotExisting(): void;
|
|
437
|
+
/**
|
|
438
|
+
* Determines a new scope object with a useful default set of environment
|
|
439
|
+
* values.
|
|
440
|
+
* @param scope - To apply to generated scope.
|
|
441
|
+
*/
|
|
442
|
+
determineRenderScope(scope?: Mapping<unknown>): void;
|
|
443
|
+
/**
|
|
444
|
+
* Does the rendering job. Should be called when ever state changes should
|
|
445
|
+
* be projected to the hosts dom content.
|
|
446
|
+
* @param reason - Description why rendering is necessary.
|
|
447
|
+
* @param resolveRendering - Indicates whether rendering should be resolved
|
|
448
|
+
* finally. Should be set to "false" via super calls in inherited render
|
|
449
|
+
* methods which do further dom manipulations afterward and resolve the
|
|
450
|
+
* rendering process by their own.
|
|
451
|
+
* @returns A promise resolving when rendering has been finished. A promise
|
|
452
|
+
* may be needed for classes inheriting from this class.
|
|
453
|
+
*/
|
|
454
|
+
render(reason?: string, resolveRendering?: boolean): Promise<void>;
|
|
455
|
+
/**
|
|
456
|
+
* Should free up memory listeners related to deprecated HTML.
|
|
457
|
+
* @param _reason - Description why rendering is necessary.
|
|
458
|
+
* @param _reRenderReason - Description why a re-rendering is necessary.
|
|
459
|
+
*/
|
|
460
|
+
unRender(_reason?: string, _reRenderReason?: string): void;
|
|
461
|
+
}
|
|
462
|
+
export declare const api: WebComponentAPI<HTMLElement, Mapping<unknown>, Mapping<unknown>, typeof Web>;
|
|
463
|
+
export default Web;
|