@react-native-ohos/react-native-text-input-mask 3.1.6-rc.3 → 3.1.6-rc.4

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-ohos/react-native-text-input-mask",
3
- "version": "3.1.6-rc.3",
3
+ "version": "3.1.6-rc.4",
4
4
  "description": "Please describe the basic information.",
5
5
  "main": "Index.ets",
6
6
  "author": "",
@@ -47,7 +47,7 @@ void myEventReceiver(ArkUI_NodeEvent *event) {
47
47
  bool useAutoskip = isDelete ? userData->maskOptions.autoskip.value() : false;
48
48
 
49
49
  // onChange 事件
50
- if (eventId == 110) {
50
+ if (eventId == userData->node) {
51
51
  std::shared_ptr<CaretString::CaretGravity> caretGravity = nullptr;
52
52
  if (isDelete) {
53
53
  caretGravity = std::make_shared<CaretString::Backward>(useAutoskip);
@@ -199,7 +199,7 @@ void RNTextInputMask::setMask(int reactNode, std::string primaryFormat, MaskOpti
199
199
  .node = reactNode,
200
200
  .instance = this});
201
201
  NativeNodeApi::getInstance()->registerNodeEvent(textInputNode->getArkUINodeHandle(), NODE_TEXT_INPUT_ON_CHANGE,
202
- 110, textInputNode);
202
+ reactNode, textInputNode);
203
203
  NativeNodeApi::getInstance()->registerNodeEvent(textInputNode->getArkUINodeHandle(), NODE_ON_FOCUS, 111,
204
204
  textInputNode);
205
205
  this->m_userDatas.insert(userData);
@@ -42,6 +42,9 @@ public:
42
42
  this->initialState = Compiler(this->customNotations).compile(this->format);
43
43
  }
44
44
 
45
+ bool hasSameCustomNotations(const std::vector<Notation>& targetNotations) const {
46
+ return this->customNotations == targetNotations;
47
+ }
45
48
 
46
49
  class MaskFactory {
47
50
  public:
@@ -60,7 +63,7 @@ public:
60
63
  static std::shared_ptr<Mask> getOrCreate(const std::string &format,
61
64
  const std::vector<Notation> &customNotations) {
62
65
  auto cachedMask = maskCache.find(format);
63
- if (cachedMask == maskCache.end()) {
66
+ if (cachedMask == maskCache.end() || !cachedMask->second->hasSameCustomNotations(customNotations)) {
64
67
  auto newMask = std::make_shared<Mask>(format, customNotations);
65
68
  maskCache[format] = newMask;
66
69
  return newMask;
@@ -21,5 +21,10 @@ public:
21
21
  bool isOptional; // 是否可选
22
22
 
23
23
  // 其他方法和成员可以根据需要添加
24
+ bool operator==(const Notation& other) const {
25
+ return (this->character == other.character) &&
26
+ (this->characterSet == other.characterSet) &&
27
+ (this->isOptional == other.isOptional);
28
+ }
24
29
  };
25
30
  } // namespace TinpMask
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-ohos/react-native-text-input-mask",
3
- "version": "3.1.6-rc.3",
3
+ "version": "3.1.6-rc.4",
4
4
  "description": "Text input mask for React Native.",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",