@embeddable.com/sdk-react 0.0.16 → 0.0.17
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/lib/embedControl.d.ts +2 -4
- package/lib/index.cjs.js +5 -4
- package/lib/index.esm.js +5 -4
- package/lib/index.umd.js +5 -4
- package/package.json +1 -1
package/lib/embedControl.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
export type Config<T> = {
|
|
3
3
|
inputs: any;
|
|
4
4
|
events: Record<string, EmbeddableEventHandler<T>>;
|
|
5
|
+
mapProps?: (_: any) => any;
|
|
5
6
|
};
|
|
6
7
|
export type EmbeddableEventHandler<T> = (value: T, setter: Setter<T>) => void;
|
|
7
8
|
export type EmbeddableEvent<T> = {
|
|
@@ -10,10 +11,7 @@ export type EmbeddableEvent<T> = {
|
|
|
10
11
|
};
|
|
11
12
|
type Setter<T> = (value: T) => void;
|
|
12
13
|
export declare function embedControl<T>(InnerComponent: React.ComponentType, config: Config<T>): {
|
|
13
|
-
(
|
|
14
|
-
editorId: any;
|
|
15
|
-
initialValue: any;
|
|
16
|
-
}): React.JSX.Element;
|
|
14
|
+
(props: any): React.JSX.Element;
|
|
17
15
|
displayName: string;
|
|
18
16
|
};
|
|
19
17
|
export {};
|
package/lib/index.cjs.js
CHANGED
|
@@ -90,9 +90,10 @@ function embedComponent(InnerComponent, config) {
|
|
|
90
90
|
var EVENT_NAME = "embeddable:editor:changed";
|
|
91
91
|
function embedControl(InnerComponent, config) {
|
|
92
92
|
var _a;
|
|
93
|
-
function EmbeddableWrapper(
|
|
94
|
-
var
|
|
95
|
-
var
|
|
93
|
+
function EmbeddableWrapper(props) {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
var editorId = props.editorId, initialValue = props.initialValue;
|
|
96
|
+
var _c = React__namespace.useState(initialValue), componentState = _c[0], setComponentState = _c[1];
|
|
96
97
|
var createEvent = function (value) {
|
|
97
98
|
var event = new CustomEvent(EVENT_NAME, {
|
|
98
99
|
bubbles: false,
|
|
@@ -117,7 +118,7 @@ function embedControl(InnerComponent, config) {
|
|
|
117
118
|
for (var event_1 in events) {
|
|
118
119
|
_loop_1(event_1);
|
|
119
120
|
}
|
|
120
|
-
return React__namespace.createElement(InnerComponent, __assign({}, eventProps, config.inputs(componentState)));
|
|
121
|
+
return React__namespace.createElement(InnerComponent, __assign({}, eventProps, config.inputs(componentState), ((_b = (_a = config.mapProps) === null || _a === void 0 ? void 0 : _a.call(config, props)) !== null && _b !== void 0 ? _b : {})));
|
|
121
122
|
}
|
|
122
123
|
EmbeddableWrapper.displayName = "embedded(".concat((_a = InnerComponent.displayName) !== null && _a !== void 0 ? _a : 'Editor', ")");
|
|
123
124
|
return EmbeddableWrapper;
|
package/lib/index.esm.js
CHANGED
|
@@ -69,9 +69,10 @@ function embedComponent(InnerComponent, config) {
|
|
|
69
69
|
var EVENT_NAME = "embeddable:editor:changed";
|
|
70
70
|
function embedControl(InnerComponent, config) {
|
|
71
71
|
var _a;
|
|
72
|
-
function EmbeddableWrapper(
|
|
73
|
-
var
|
|
74
|
-
var
|
|
72
|
+
function EmbeddableWrapper(props) {
|
|
73
|
+
var _a, _b;
|
|
74
|
+
var editorId = props.editorId, initialValue = props.initialValue;
|
|
75
|
+
var _c = React.useState(initialValue), componentState = _c[0], setComponentState = _c[1];
|
|
75
76
|
var createEvent = function (value) {
|
|
76
77
|
var event = new CustomEvent(EVENT_NAME, {
|
|
77
78
|
bubbles: false,
|
|
@@ -96,7 +97,7 @@ function embedControl(InnerComponent, config) {
|
|
|
96
97
|
for (var event_1 in events) {
|
|
97
98
|
_loop_1(event_1);
|
|
98
99
|
}
|
|
99
|
-
return React.createElement(InnerComponent, __assign({}, eventProps, config.inputs(componentState)));
|
|
100
|
+
return React.createElement(InnerComponent, __assign({}, eventProps, config.inputs(componentState), ((_b = (_a = config.mapProps) === null || _a === void 0 ? void 0 : _a.call(config, props)) !== null && _b !== void 0 ? _b : {})));
|
|
100
101
|
}
|
|
101
102
|
EmbeddableWrapper.displayName = "embedded(".concat((_a = InnerComponent.displayName) !== null && _a !== void 0 ? _a : 'Editor', ")");
|
|
102
103
|
return EmbeddableWrapper;
|
package/lib/index.umd.js
CHANGED
|
@@ -110,9 +110,10 @@
|
|
|
110
110
|
var EVENT_NAME = "embeddable:editor:changed";
|
|
111
111
|
function embedControl(InnerComponent, config) {
|
|
112
112
|
var _a;
|
|
113
|
-
function EmbeddableWrapper(
|
|
114
|
-
var
|
|
115
|
-
var
|
|
113
|
+
function EmbeddableWrapper(props) {
|
|
114
|
+
var _a, _b;
|
|
115
|
+
var editorId = props.editorId, initialValue = props.initialValue;
|
|
116
|
+
var _c = reactExports.useState(initialValue), componentState = _c[0], setComponentState = _c[1];
|
|
116
117
|
var createEvent = function (value) {
|
|
117
118
|
var event = new CustomEvent(EVENT_NAME, {
|
|
118
119
|
bubbles: false,
|
|
@@ -137,7 +138,7 @@
|
|
|
137
138
|
for (var event_1 in events) {
|
|
138
139
|
_loop_1(event_1);
|
|
139
140
|
}
|
|
140
|
-
return reactExports.createElement(InnerComponent, __assign({}, eventProps, config.inputs(componentState)));
|
|
141
|
+
return reactExports.createElement(InnerComponent, __assign({}, eventProps, config.inputs(componentState), ((_b = (_a = config.mapProps) === null || _a === void 0 ? void 0 : _a.call(config, props)) !== null && _b !== void 0 ? _b : {})));
|
|
141
142
|
}
|
|
142
143
|
EmbeddableWrapper.displayName = "embedded(".concat((_a = InnerComponent.displayName) !== null && _a !== void 0 ? _a : 'Editor', ")");
|
|
143
144
|
return EmbeddableWrapper;
|