web-component-wrapper 0.0.391 → 0.0.393

Sign up to get free protection for your applications and to get access to all the features.
package/React.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Mapping } from 'clientnode/type';
2
- import React, { HTMLAttributes } from 'react';
2
+ import React from 'react';
3
3
  import { Root as ReactRoot } from 'react-dom/client';
4
4
  import Web from './Web';
5
- import { ComponentAdapter, ComponentType, ReactRenderItemFactory, ReactRenderItemsFactory, ReactRenderItems, WebComponentAPI } from './type';
5
+ import { ComponentType, ReactComponentBaseProperties, ReactRenderItemFactory, ReactRenderItemsFactory, ReactRenderItems, WebComponentAPI } from './type';
6
6
  /**
7
7
  * Adapter for exposing a react component as web-component.
8
8
  * @property static:attachWebComponentAdapterIfNotExists - Indicates whether to
@@ -19,14 +19,7 @@ import { ComponentAdapter, ComponentType, ReactRenderItemFactory, ReactRenderIte
19
19
  * reacts memorizing wrapper to cache component render results.
20
20
  * @property isWrapped - Indicates whether react component is wrapped already.
21
21
  */
22
- export declare class ReactWeb<TElement = HTMLElement, ExternalProperties extends Mapping<unknown> = Mapping<unknown>, InternalProperties extends Mapping<unknown> & {
23
- children?: Array<React.ReactNode> | React.ReactNode;
24
- dangerouslySetInnerHTML?: HTMLAttributes<TElement>['dangerouslySetInnerHTML'];
25
- key?: string;
26
- ref?: null | {
27
- current?: ComponentAdapter;
28
- };
29
- } = Mapping<unknown>> extends Web<TElement, ExternalProperties, InternalProperties> {
22
+ export declare class ReactWeb<TElement = HTMLElement, ExternalProperties extends Mapping<unknown> = Mapping<unknown>, InternalProperties extends ReactComponentBaseProperties<TElement> = Mapping<unknown>> extends Web<TElement, ExternalProperties, InternalProperties> {
30
23
  static attachWebComponentAdapterIfNotExists: boolean;
31
24
  static content: ComponentType | string;
32
25
  static react: typeof React;
@@ -193,5 +186,5 @@ export declare class ReactWeb<TElement = HTMLElement, ExternalProperties extends
193
186
  */
194
187
  static removeKnownUnwantedPropertyKeys(target: typeof ReactWeb, properties: Mapping<unknown>): void;
195
188
  }
196
- export declare const api: WebComponentAPI<typeof ReactWeb>;
189
+ export declare const api: WebComponentAPI<HTMLElement, Mapping<unknown>, ReactComponentBaseProperties, typeof ReactWeb>;
197
190
  export default ReactWeb;
package/Web.d.ts CHANGED
@@ -474,5 +474,5 @@ export declare class Web<TElement = HTMLElement, ExternalProperties extends Mapp
474
474
  */
475
475
  render(reason?: string): void;
476
476
  }
477
- export declare const api: WebComponentAPI<typeof Web>;
477
+ export declare const api: WebComponentAPI<HTMLElement, Mapping<unknown>, Mapping<unknown>, typeof Web>;
478
478
  export default Web;
package/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
+ /// <reference types="react" />
1
2
  import { Mapping } from 'clientnode/type';
2
3
  import ReactWebImport from './React';
3
4
  import WebImport from './Web';
4
- import { ComponentType, WebComponentAPI, WebComponentConfiguration } from './type';
5
+ import { AttributesReflectionConfiguration, ComponentType, EventToPropertyMapping, PropertiesConfiguration, WebComponentAPI, WebComponentConfiguration } from './type';
5
6
  export declare const ReactWeb: typeof ReactWebImport;
6
- export declare const reactWebAPI: WebComponentAPI<typeof ReactWebImport>;
7
- export declare const webAPI: WebComponentAPI<typeof WebImport>;
7
+ export declare const reactWebAPI: WebComponentAPI<HTMLElement, Mapping<unknown>, import("./type").ReactComponentBaseProperties<HTMLElement>, typeof ReactWebImport>;
8
+ export declare const webAPI: WebComponentAPI<HTMLElement, Mapping<unknown>, Mapping<unknown>, typeof WebImport>;
8
9
  export declare const Web: typeof WebImport;
9
10
  /**
10
11
  * Wraps given react component as web component.
@@ -15,5 +16,37 @@ export declare const Web: typeof WebImport;
15
16
  *
16
17
  * @returns Generated object to register and retrieve generated web component.
17
18
  */
18
- export declare const wrapAsWebComponent: <Type extends ComponentType<Mapping<unknown>> = ComponentType<Mapping<unknown>>, ExternalProperties extends Mapping<unknown> = Mapping<unknown>, InternalProperties extends Mapping<unknown> = Mapping<unknown>, EventParameters extends unknown[] = unknown[]>(component: Type, nameHint?: string, configuration?: WebComponentConfiguration<ExternalProperties, InternalProperties, EventParameters>) => WebComponentAPI<typeof ReactWeb>;
19
+ export declare const wrapAsWebComponent: <Type extends ComponentType<Mapping<unknown>> = ComponentType<Mapping<unknown>>, ExternalProperties extends Mapping<unknown> = Mapping<unknown>, InternalProperties extends Mapping<unknown> = Mapping<unknown>, EventParameters extends unknown[] = unknown[]>(component: Type, nameHint?: string, configuration?: WebComponentConfiguration<ExternalProperties, InternalProperties, EventParameters>) => WebComponentAPI<Type, ExternalProperties, InternalProperties, {
20
+ new (): ReactWebImport<Type, ExternalProperties, InternalProperties>;
21
+ attachWebComponentAdapterIfNotExists: boolean;
22
+ content: string | ComponentType<Mapping<unknown>>;
23
+ react: typeof import("react");
24
+ _name: string;
25
+ isReactComponent(domNode: Node): boolean;
26
+ removeKnownUnwantedPropertyKeys(target: typeof ReactWebImport, properties: Mapping<unknown>): void;
27
+ applyRootBinding: boolean;
28
+ determineRootBinding: boolean;
29
+ shadowDOM: boolean | {
30
+ delegateFocus?: boolean | undefined;
31
+ mode: "closed" | "open";
32
+ } | null;
33
+ observedAttributes: string[];
34
+ controllableProperties: string[];
35
+ eventToPropertyMapping: EventToPropertyMapping<Mapping<unknown>, Mapping<unknown>, unknown[]> | null;
36
+ propertyAliases: Mapping<string>;
37
+ propertyTypes: PropertiesConfiguration;
38
+ propertiesToReflectAsAttributes: AttributesReflectionConfiguration;
39
+ renderProperties: string[];
40
+ cloneSlots: boolean;
41
+ evaluateSlots: boolean;
42
+ renderSlots: boolean;
43
+ trimSlots: boolean;
44
+ renderUnsafe: boolean;
45
+ _propertyAliasIndex: Mapping<string> | undefined;
46
+ _propertiesToReflectAsAttributes: import("./type").NormalizedAttributesReflectionConfiguration;
47
+ replaceDomNodes(domNode: HTMLElement, children: Node | Node[]): void;
48
+ unwrapDomNode(domNode: HTMLElement): ChildNode[];
49
+ hasCode(content: unknown): boolean;
50
+ normalizePropertyTypeList(value: AttributesReflectionConfiguration): import("./type").NormalizedAttributesReflectionConfiguration;
51
+ }>;
19
52
  export default wrapAsWebComponent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-component-wrapper",
3
- "version": "0.0.391",
3
+ "version": "0.0.393",
4
4
  "description": "Generic web-component base class and framework specific wrapper.",
5
5
  "keywords": [
6
6
  "component",
package/type.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import PropertyTypes, { ValidationMap } from 'clientnode/property-types';
2
2
  import { Mapping, TemplateFunction, ValueOf } from 'clientnode/type';
3
- import { ComponentType as ReactComponentType, ReactElement } from 'react';
3
+ import React, { ComponentType as ReactComponentType, HTMLAttributes, ReactElement } from 'react';
4
4
  import Web from './Web';
5
5
  export declare type CompiledDomNodeTemplateItem = {
6
6
  children: Array<CompiledDomNodeTemplate>;
@@ -28,6 +28,14 @@ export declare type PreCompiledItem = {
28
28
  originalScopeNames: Array<string>;
29
29
  templateFunction: TemplateFunction;
30
30
  };
31
+ export declare type ReactComponentBaseProperties<TElement = HTMLElement> = Mapping<unknown> & {
32
+ children?: Array<React.ReactNode> | React.ReactNode;
33
+ dangerouslySetInnerHTML?: HTMLAttributes<TElement>['dangerouslySetInnerHTML'];
34
+ key?: string;
35
+ ref?: null | {
36
+ current?: ComponentAdapter;
37
+ };
38
+ };
31
39
  export declare type ReactRenderBaseItemFactory = (_scope: Mapping<unknown>) => ReactRenderBaseItem;
32
40
  export declare type ReactRenderItemFactory = (_scope: Mapping<unknown>) => ReactRenderItem;
33
41
  export declare type ReactRenderItemsFactory = Array<ReactRenderItemFactory> | ReactRenderItemFactory;
@@ -44,9 +52,9 @@ export interface WebComponentConfiguration<ExternalProperties extends Mapping<un
44
52
  propTypes?: PropertiesConfiguration;
45
53
  renderProperties?: Array<string>;
46
54
  }
47
- export interface StaticWebComponent extends WebComponentConfiguration {
55
+ export interface StaticWebComponent<ComponentType = unknown, ExternalProperties extends Mapping<unknown> = Mapping<unknown>, InternalProperties extends Mapping<unknown> = Mapping<unknown>, EventParameters extends Array<unknown> = Array<unknown>> extends WebComponentConfiguration<ExternalProperties, InternalProperties, EventParameters> {
48
56
  webComponentAdapterWrapped?: string;
49
- wrapped?: unknown;
57
+ wrapped?: ComponentType;
50
58
  _name?: string;
51
59
  ___types?: {
52
60
  name?: {
@@ -59,7 +67,7 @@ export interface ComponentAdapter<Properties = Mapping<unknown>, State = Mapping
59
67
  properties?: Properties;
60
68
  state?: State;
61
69
  }
62
- export declare type WebComponentAPI<WebComponent extends typeof Web = typeof Web> = {
63
- component: WebComponent;
64
- register: (_tagName?: string) => void;
70
+ export declare type WebComponentAPI<TElement = HTMLElement, ExternalProperties extends Mapping<unknown> = Mapping<unknown>, InternalProperties extends Mapping<unknown> = Mapping<unknown>, Type extends typeof Web<TElement, ExternalProperties, InternalProperties> = typeof Web<TElement, ExternalProperties, InternalProperties>> = {
71
+ component: Type;
72
+ register: (tagName?: string) => void;
65
73
  };