@contentful/field-editor-shared 1.5.0 → 1.5.1
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.
|
@@ -121,6 +121,7 @@ class FieldConnector extends (_React_Component = _react.Component) {
|
|
|
121
121
|
_define_property(this, "unsubscribeErrors", null);
|
|
122
122
|
_define_property(this, "unsubscribeDisabled", null);
|
|
123
123
|
_define_property(this, "unsubscribeValue", null);
|
|
124
|
+
_define_property(this, "getDebounceDuration", ()=>'debounce' in this.props ? this.props.debounce : this.props.throttle);
|
|
124
125
|
_define_property(this, "setValue", async (value)=>{
|
|
125
126
|
if (this.props.isEmptyValue(value ?? null)) {
|
|
126
127
|
this.setState({
|
|
@@ -131,7 +132,7 @@ class FieldConnector extends (_React_Component = _react.Component) {
|
|
|
131
132
|
value
|
|
132
133
|
});
|
|
133
134
|
}
|
|
134
|
-
if (this.
|
|
135
|
+
if (this.getDebounceDuration() === 0) {
|
|
135
136
|
await this.triggerSetValueCallbacks(value);
|
|
136
137
|
} else {
|
|
137
138
|
await this.debouncedTriggerSetValueCallbacks(value);
|
|
@@ -146,7 +147,7 @@ class FieldConnector extends (_React_Component = _react.Component) {
|
|
|
146
147
|
}
|
|
147
148
|
});
|
|
148
149
|
});
|
|
149
|
-
_define_property(this, "debouncedTriggerSetValueCallbacks", (0, _debounce.default)(this.triggerSetValueCallbacks, this.
|
|
150
|
+
_define_property(this, "debouncedTriggerSetValueCallbacks", (0, _debounce.default)(this.triggerSetValueCallbacks, this.getDebounceDuration()));
|
|
150
151
|
const initialValue = props.field.getValue();
|
|
151
152
|
this.state = {
|
|
152
153
|
isLocalValueChange: false,
|
|
@@ -65,6 +65,7 @@ export class FieldConnector extends (_React_Component = React.Component) {
|
|
|
65
65
|
_define_property(this, "unsubscribeErrors", null);
|
|
66
66
|
_define_property(this, "unsubscribeDisabled", null);
|
|
67
67
|
_define_property(this, "unsubscribeValue", null);
|
|
68
|
+
_define_property(this, "getDebounceDuration", ()=>'debounce' in this.props ? this.props.debounce : this.props.throttle);
|
|
68
69
|
_define_property(this, "setValue", async (value)=>{
|
|
69
70
|
if (this.props.isEmptyValue(value ?? null)) {
|
|
70
71
|
this.setState({
|
|
@@ -75,7 +76,7 @@ export class FieldConnector extends (_React_Component = React.Component) {
|
|
|
75
76
|
value
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
|
-
if (this.
|
|
79
|
+
if (this.getDebounceDuration() === 0) {
|
|
79
80
|
await this.triggerSetValueCallbacks(value);
|
|
80
81
|
} else {
|
|
81
82
|
await this.debouncedTriggerSetValueCallbacks(value);
|
|
@@ -90,7 +91,7 @@ export class FieldConnector extends (_React_Component = React.Component) {
|
|
|
90
91
|
}
|
|
91
92
|
});
|
|
92
93
|
});
|
|
93
|
-
_define_property(this, "debouncedTriggerSetValueCallbacks", debounce(this.triggerSetValueCallbacks, this.
|
|
94
|
+
_define_property(this, "debouncedTriggerSetValueCallbacks", debounce(this.triggerSetValueCallbacks, this.getDebounceDuration()));
|
|
94
95
|
const initialValue = props.field.getValue();
|
|
95
96
|
this.state = {
|
|
96
97
|
isLocalValueChange: false,
|
|
@@ -19,15 +19,19 @@ interface FieldConnectorState<ValueType> {
|
|
|
19
19
|
disabled: boolean;
|
|
20
20
|
errors: ValidationError[];
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
type FieldConnectorProps<ValueType> = {
|
|
23
23
|
field: FieldAPI;
|
|
24
24
|
isInitiallyDisabled: boolean;
|
|
25
25
|
isDisabled?: boolean;
|
|
26
26
|
children: (state: FieldConnectorChildProps<ValueType>) => React.ReactNode;
|
|
27
27
|
isEmptyValue: (value: ValueType | null) => boolean;
|
|
28
28
|
isEqualValues: (value1: ValueType | Nullable, value2: ValueType | Nullable) => boolean;
|
|
29
|
+
} & ({
|
|
29
30
|
debounce: number;
|
|
30
|
-
}
|
|
31
|
+
} | {
|
|
32
|
+
/** @deprecated: Please use `debounce` instead */
|
|
33
|
+
throttle: number;
|
|
34
|
+
});
|
|
31
35
|
export declare class FieldConnector<ValueType> extends React.Component<FieldConnectorProps<ValueType>, FieldConnectorState<ValueType>> {
|
|
32
36
|
static defaultProps: {
|
|
33
37
|
children: () => null;
|
|
@@ -39,6 +43,7 @@ export declare class FieldConnector<ValueType> extends React.Component<FieldConn
|
|
|
39
43
|
unsubscribeErrors: Function | null;
|
|
40
44
|
unsubscribeDisabled: Function | null;
|
|
41
45
|
unsubscribeValue: Function | null;
|
|
46
|
+
getDebounceDuration: () => number;
|
|
42
47
|
setValue: (value: ValueType | Nullable) => Promise<void>;
|
|
43
48
|
triggerSetValueCallbacks: (value: ValueType | Nullable) => Promise<unknown>;
|
|
44
49
|
debouncedTriggerSetValueCallbacks: import("lodash").DebouncedFunc<(value: ValueType | Nullable) => Promise<unknown>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-shared",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"registry": "https://npm.pkg.github.com/"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "60fd3c2f5a58f4d42886b5f952ce3cc1aec71833"
|
|
55
55
|
}
|