@rainbow-oh/yee-c 0.4.2 → 0.4.3
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/cjs/Form/form-store.js +3 -0
- package/dist/cjs/Form/hooks/useWatch.js +4 -2
- package/dist/cjs/TextArea/textarea.js +0 -1
- package/dist/cjs/style/themes.css +1 -1
- package/dist/cjs/style/variables.css +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Form/form-store.js +4 -0
- package/dist/esm/Form/hooks/useWatch.js +7 -2
- package/dist/esm/TextArea/textarea.js +0 -1
- package/dist/esm/style/themes.css +1 -1
- package/dist/esm/style/variables.css +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/yee-c.min.js +1 -1
- package/package.json +1 -1
- package/src/Form/form-store.ts +4 -0
- package/src/Form/hooks/useWatch.ts +9 -2
- package/src/TextArea/textarea.tsx +0 -2
- package/src/version.ts +1 -1
|
@@ -420,6 +420,9 @@ var FormStore = class {
|
|
|
420
420
|
} else {
|
|
421
421
|
this.store = __spreadProps(__spreadValues({}, this.store), { [normalizedName]: value });
|
|
422
422
|
}
|
|
423
|
+
if (value !== void 0) {
|
|
424
|
+
this.notifyWatchers(normalizedName);
|
|
425
|
+
}
|
|
423
426
|
}
|
|
424
427
|
}
|
|
425
428
|
(_b = entity.onStoreChange) == null ? void 0 : _b.call(entity);
|
|
@@ -46,10 +46,12 @@ function useWatch(namePath, form) {
|
|
|
46
46
|
const getWatchedValue = () => isWatchAll ? formInstance.getFieldsValue() : formInstance.getFieldValue(
|
|
47
47
|
Array.isArray(namePath) ? namePath.join(".") : namePath
|
|
48
48
|
);
|
|
49
|
-
const
|
|
49
|
+
const update = () => {
|
|
50
50
|
const newValue = getWatchedValue();
|
|
51
51
|
setValue((prev) => prev === newValue ? prev : newValue);
|
|
52
|
-
}
|
|
52
|
+
};
|
|
53
|
+
const unsubscribe = formInstance.subscribe(namePath, update);
|
|
54
|
+
update();
|
|
53
55
|
return unsubscribe;
|
|
54
56
|
}, [formInstance, namePath]);
|
|
55
57
|
return value;
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
|
@@ -445,6 +445,10 @@ export var FormStore = /*#__PURE__*/function () {
|
|
|
445
445
|
} else {
|
|
446
446
|
_this.store = _objectSpread(_objectSpread({}, _this.store), {}, _defineProperty({}, normalizedName, value));
|
|
447
447
|
}
|
|
448
|
+
// When value is not undefined, notify watchers to trigger re-rendering of useWatch
|
|
449
|
+
if (value !== undefined) {
|
|
450
|
+
_this.notifyWatchers(normalizedName);
|
|
451
|
+
}
|
|
448
452
|
}
|
|
449
453
|
}
|
|
450
454
|
(_entity$onStoreChange = entity.onStoreChange) === null || _entity$onStoreChange === void 0 || _entity$onStoreChange.call(entity);
|
|
@@ -20,12 +20,17 @@ function useWatch(namePath, form) {
|
|
|
20
20
|
var getWatchedValue = function getWatchedValue() {
|
|
21
21
|
return isWatchAll ? formInstance.getFieldsValue() : formInstance.getFieldValue(Array.isArray(namePath) ? namePath.join('.') : namePath);
|
|
22
22
|
};
|
|
23
|
-
var
|
|
23
|
+
var update = function update() {
|
|
24
24
|
var newValue = getWatchedValue();
|
|
25
25
|
setValue(function (prev) {
|
|
26
26
|
return prev === newValue ? prev : newValue;
|
|
27
27
|
});
|
|
28
|
-
}
|
|
28
|
+
};
|
|
29
|
+
var unsubscribe = formInstance.subscribe(namePath, update);
|
|
30
|
+
// Re-read immediately after subscribing: the parent's useWatch captured its
|
|
31
|
+
// initial snapshot before child Form.Field wrote its initialValue, and the
|
|
32
|
+
// subscription may not yet exist when that write happens. This covers the gap.
|
|
33
|
+
update();
|
|
29
34
|
return unsubscribe;
|
|
30
35
|
}, [formInstance, namePath]);
|
|
31
36
|
return value;
|
|
@@ -47,7 +47,6 @@ var TextArea = /*#__PURE__*/forwardRef(function (baseprops, ref) {
|
|
|
47
47
|
_useMergedState2 = _slicedToArray(_useMergedState, 2),
|
|
48
48
|
mergedValue = _useMergedState2[0],
|
|
49
49
|
setMergedValue = _useMergedState2[1];
|
|
50
|
-
console.log('mergedValue: ', mergedValue, value);
|
|
51
50
|
useEffect(function () {
|
|
52
51
|
var ele = componentRef.current;
|
|
53
52
|
if (ele && autoSize) {
|
package/dist/esm/version.d.ts
CHANGED
package/dist/esm/version.js
CHANGED