@react-native-ohos/react-native-text-input-mask 3.1.6-rc.1 → 3.1.6-rc.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.
Files changed (40) hide show
  1. package/LICENSE +21 -21
  2. package/README.OpenSource +10 -10
  3. package/README.md +15 -134
  4. package/dist/tsconfig.tsbuildinfo +1 -1
  5. package/harmony/text_input_mask/BuildProfile.ets +16 -16
  6. package/harmony/text_input_mask/Index.ets +7 -7
  7. package/harmony/text_input_mask/build-profile.json5 +31 -31
  8. package/harmony/text_input_mask/hvigorfile.ts +6 -6
  9. package/harmony/text_input_mask/obfuscation-rules.txt +22 -22
  10. package/harmony/text_input_mask/oh-package.json5 +11 -11
  11. package/harmony/text_input_mask/src/main/cpp/CMakeLists.txt +9 -9
  12. package/harmony/text_input_mask/src/main/cpp/RNTextInputMask.cpp +421 -415
  13. package/harmony/text_input_mask/src/main/cpp/RNTextInputMask.h +93 -93
  14. package/harmony/text_input_mask/src/main/cpp/RNTextInputMaskPackage.h +31 -31
  15. package/harmony/text_input_mask/src/main/cpp/common/Compiler.h +174 -174
  16. package/harmony/text_input_mask/src/main/cpp/common/FormatError.h +22 -22
  17. package/harmony/text_input_mask/src/main/cpp/common/FormatSanitizer.h +230 -230
  18. package/harmony/text_input_mask/src/main/cpp/common/Mask.h +377 -377
  19. package/harmony/text_input_mask/src/main/cpp/common/RTLMask.h +78 -78
  20. package/harmony/text_input_mask/src/main/cpp/common/model/AffinityCalculationStrategy.h +57 -57
  21. package/harmony/text_input_mask/src/main/cpp/common/model/CaretString.h +75 -75
  22. package/harmony/text_input_mask/src/main/cpp/common/model/CaretStringIterator.h +58 -58
  23. package/harmony/text_input_mask/src/main/cpp/common/model/Next.h +24 -24
  24. package/harmony/text_input_mask/src/main/cpp/common/model/Notation.h +24 -24
  25. package/harmony/text_input_mask/src/main/cpp/common/model/RTLCaretStringIterator.h +22 -22
  26. package/harmony/text_input_mask/src/main/cpp/common/model/State.h +302 -302
  27. package/harmony/text_input_mask/src/main/cpp/common/model/common.h +94 -94
  28. package/harmony/text_input_mask/src/main/ets/RNTextInputMaskPackage.ts +28 -28
  29. package/harmony/text_input_mask/src/main/ets/RNTextInputMaskTurboModle.ts +32 -32
  30. package/harmony/text_input_mask/src/main/module.json5 +11 -11
  31. package/harmony/text_input_mask/src/main/resources/base/element/string.json +8 -8
  32. package/harmony/text_input_mask/src/main/resources/en_US/element/string.json +8 -8
  33. package/harmony/text_input_mask/src/main/resources/zh_CN/element/string.json +8 -8
  34. package/harmony/text_input_mask/ts.ts +8 -8
  35. package/harmony/text_input_mask.har +0 -0
  36. package/index.tsx +258 -258
  37. package/package.json +48 -50
  38. package/src/RNNativeTextInputMask.ts +142 -142
  39. package/src/index.harmony.ts +147 -147
  40. package/src/index.ts +36 -36
@@ -1,95 +1,95 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- #pragma once
8
- #include "CaretString.h"
9
- #include <string>
10
- #include <vector>
11
- #include "State.h"
12
- #include "Next.h"
13
-
14
- namespace TinpMask {
15
-
16
- class Result {
17
- public:
18
- // 属性
19
- CaretString formattedText;
20
- std::string extractedValue;
21
- int affinity;
22
- bool complete;
23
- std::string tailPlaceholder;
24
-
25
- // 构造函数
26
- Result(const CaretString &formattedText, const std::string &extractedValue, int affinity, bool complete,
27
- const std::string &tailPlaceholder)
28
- : formattedText(formattedText), extractedValue(extractedValue), affinity(affinity), complete(complete),
29
- tailPlaceholder(tailPlaceholder) {}
30
-
31
- // reversed 方法
32
- Result reversed() const {
33
- return Result(this->formattedText.reversed(), reverseString(this->extractedValue), this->affinity,
34
- this->complete, reverseString(this->tailPlaceholder));
35
- }
36
-
37
- private:
38
- // 辅助函数,用于反转字符串
39
- std::string reverseString(const std::string &str) const { return std::string(str.rbegin(), str.rend()); }
40
- };
41
- /**
42
- * While scanning through the input string in the `.apply(…)` method, the mask builds a graph of
43
- * autocompletion steps.
44
- *
45
- * This graph accumulates the results of `.autocomplete()` calls for each consecutive ``State``,
46
- * acting as a `stack` of ``Next`` object instances.
47
- *
48
- * Each time the ``State`` returns `null` for its `.autocomplete()`, the graph resets empty.
49
- */
50
- class AutocompletionStack {
51
- private:
52
- std::vector<Next> stack;
53
-
54
- public:
55
- // Push 方法
56
- std::optional<Next> push(const std::optional<Next> &item) {
57
- if (item.has_value()) {
58
- stack.push_back(item.value());
59
- return item;
60
- } else {
61
- clear(); // 清空栈
62
- return std::nullopt; // 返回 std::nullopt
63
- }
64
- }
65
-
66
- // 清空栈的方法
67
- void clear() { stack.clear(); }
68
-
69
- // Optional: 获取栈的元素(用于检查或调试)
70
- std::vector<Next> getStack() const {
71
- return stack; // 返回当前栈的拷贝
72
- }
73
-
74
- // Optional: 从栈中弹出一个元素
75
- std::optional<Next> pop() {
76
- if (stack.empty()) {
77
- return std::nullopt; // 栈为空时返回 std::nullopt
78
- }
79
- Next item = stack.back();
80
- stack.pop_back();
81
- return item;
82
- }
83
-
84
- // 检查栈是否为空
85
- bool isEmpty() const { return stack.empty(); }
86
-
87
- // Optional: 获取栈顶元素而不移除它
88
- std::optional<Next> peek() const {
89
- if (stack.empty()) {
90
- return std::nullopt; // 栈为空时返回 std::nullopt
91
- }
92
- return stack.back();
93
- }
94
- };
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #pragma once
8
+ #include "CaretString.h"
9
+ #include <string>
10
+ #include <vector>
11
+ #include "State.h"
12
+ #include "Next.h"
13
+
14
+ namespace TinpMask {
15
+
16
+ class Result {
17
+ public:
18
+ // 属性
19
+ CaretString formattedText;
20
+ std::string extractedValue;
21
+ int affinity;
22
+ bool complete;
23
+ std::string tailPlaceholder;
24
+
25
+ // 构造函数
26
+ Result(const CaretString &formattedText, const std::string &extractedValue, int affinity, bool complete,
27
+ const std::string &tailPlaceholder)
28
+ : formattedText(formattedText), extractedValue(extractedValue), affinity(affinity), complete(complete),
29
+ tailPlaceholder(tailPlaceholder) {}
30
+
31
+ // reversed 方法
32
+ Result reversed() const {
33
+ return Result(this->formattedText.reversed(), reverseString(this->extractedValue), this->affinity,
34
+ this->complete, reverseString(this->tailPlaceholder));
35
+ }
36
+
37
+ private:
38
+ // 辅助函数,用于反转字符串
39
+ std::string reverseString(const std::string &str) const { return std::string(str.rbegin(), str.rend()); }
40
+ };
41
+ /**
42
+ * While scanning through the input string in the `.apply(…)` method, the mask builds a graph of
43
+ * autocompletion steps.
44
+ *
45
+ * This graph accumulates the results of `.autocomplete()` calls for each consecutive ``State``,
46
+ * acting as a `stack` of ``Next`` object instances.
47
+ *
48
+ * Each time the ``State`` returns `null` for its `.autocomplete()`, the graph resets empty.
49
+ */
50
+ class AutocompletionStack {
51
+ private:
52
+ std::vector<Next> stack;
53
+
54
+ public:
55
+ // Push 方法
56
+ std::optional<Next> push(const std::optional<Next> &item) {
57
+ if (item.has_value()) {
58
+ stack.push_back(item.value());
59
+ return item;
60
+ } else {
61
+ clear(); // 清空栈
62
+ return std::nullopt; // 返回 std::nullopt
63
+ }
64
+ }
65
+
66
+ // 清空栈的方法
67
+ void clear() { stack.clear(); }
68
+
69
+ // Optional: 获取栈的元素(用于检查或调试)
70
+ std::vector<Next> getStack() const {
71
+ return stack; // 返回当前栈的拷贝
72
+ }
73
+
74
+ // Optional: 从栈中弹出一个元素
75
+ std::optional<Next> pop() {
76
+ if (stack.empty()) {
77
+ return std::nullopt; // 栈为空时返回 std::nullopt
78
+ }
79
+ Next item = stack.back();
80
+ stack.pop_back();
81
+ return item;
82
+ }
83
+
84
+ // 检查栈是否为空
85
+ bool isEmpty() const { return stack.empty(); }
86
+
87
+ // Optional: 获取栈顶元素而不移除它
88
+ std::optional<Next> peek() const {
89
+ if (stack.empty()) {
90
+ return std::nullopt; // 栈为空时返回 std::nullopt
91
+ }
92
+ return stack.back();
93
+ }
94
+ };
95
95
  } // namespace TinpMask
@@ -1,29 +1,29 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
8
- import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
9
- import { RNTextInputMaskTurboModule } from './RNTextInputMaskTurboModle';
10
-
11
- class RNTextInputMaskTurboModuleFactory extends TurboModulesFactory {
12
- createTurboModule(name: string): TurboModule | null {
13
- globalThis.uiAbilityContext = this.ctx.uiAbilityContext
14
- if (this.hasTurboModule(name)) {
15
- return new RNTextInputMaskTurboModule(this.ctx);
16
- }
17
- return null;
18
- }
19
-
20
- hasTurboModule(name: string): boolean {
21
- return name === "RNTextInputMask";
22
- }
23
- }
24
-
25
- export class RNTextInputMaskPackage extends RNPackage {
26
- createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
27
- return new RNTextInputMaskTurboModuleFactory(ctx);
28
- }
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
8
+ import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
9
+ import { RNTextInputMaskTurboModule } from './RNTextInputMaskTurboModle';
10
+
11
+ class RNTextInputMaskTurboModuleFactory extends TurboModulesFactory {
12
+ createTurboModule(name: string): TurboModule | null {
13
+ globalThis.uiAbilityContext = this.ctx.uiAbilityContext
14
+ if (this.hasTurboModule(name)) {
15
+ return new RNTextInputMaskTurboModule(this.ctx);
16
+ }
17
+ return null;
18
+ }
19
+
20
+ hasTurboModule(name: string): boolean {
21
+ return name === "RNTextInputMask";
22
+ }
23
+ }
24
+
25
+ export class RNTextInputMaskPackage extends RNPackage {
26
+ createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
27
+ return new RNTextInputMaskTurboModuleFactory(ctx);
28
+ }
29
29
  }
@@ -1,33 +1,33 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- import { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
8
-
9
- export class RNTextInputMaskTurboModule extends TurboModule {
10
- private context: TurboModuleContext;
11
-
12
- constructor(ctx: TurboModuleContext) {
13
- super(ctx)
14
- this.context = ctx
15
- }
16
-
17
- mask(mask: string, value: string, autocomplete: boolean): Promise<string> {
18
- return;
19
- }
20
-
21
- unmask(mask: string, value: string, autocomplete: boolean): Promise<string> {
22
- return;
23
- }
24
-
25
- setMask(reactNode: number, primaryFormat: string, options: object): void {
26
- console.log("==================", "setMask")
27
- }
28
-
29
- unmaskWithRightToLeft(mask: string, value: string, autocomplete: boolean, rightToLeft: boolean): Promise<string> {
30
- return;
31
- }
32
-
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
8
+
9
+ export class RNTextInputMaskTurboModule extends TurboModule {
10
+ private context: TurboModuleContext;
11
+
12
+ constructor(ctx: TurboModuleContext) {
13
+ super(ctx)
14
+ this.context = ctx
15
+ }
16
+
17
+ mask(mask: string, value: string, autocomplete: boolean): Promise<string> {
18
+ return;
19
+ }
20
+
21
+ unmask(mask: string, value: string, autocomplete: boolean): Promise<string> {
22
+ return;
23
+ }
24
+
25
+ setMask(reactNode: number, primaryFormat: string, options: object): void {
26
+ console.log("==================", "setMask")
27
+ }
28
+
29
+ unmaskWithRightToLeft(mask: string, value: string, autocomplete: boolean, rightToLeft: boolean): Promise<string> {
30
+ return;
31
+ }
32
+
33
33
  }
@@ -1,11 +1,11 @@
1
- {
2
- "module": {
3
- "name": "text_input_mask",
4
- "type": "har",
5
- "deviceTypes": [
6
- "default",
7
- "tablet",
8
- "2in1"
9
- ]
10
- }
11
- }
1
+ {
2
+ "module": {
3
+ "name": "text_input_mask",
4
+ "type": "har",
5
+ "deviceTypes": [
6
+ "default",
7
+ "tablet",
8
+ "2in1"
9
+ ]
10
+ }
11
+ }
@@ -1,8 +1,8 @@
1
- {
2
- "string": [
3
- {
4
- "name": "page_show",
5
- "value": "page from package"
6
- }
7
- ]
8
- }
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "page_show",
5
+ "value": "page from package"
6
+ }
7
+ ]
8
+ }
@@ -1,8 +1,8 @@
1
- {
2
- "string": [
3
- {
4
- "name": "page_show",
5
- "value": "page from package"
6
- }
7
- ]
8
- }
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "page_show",
5
+ "value": "page from package"
6
+ }
7
+ ]
8
+ }
@@ -1,8 +1,8 @@
1
- {
2
- "string": [
3
- {
4
- "name": "page_show",
5
- "value": "page from package"
6
- }
7
- ]
8
- }
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "page_show",
5
+ "value": "page from package"
6
+ }
7
+ ]
8
+ }
@@ -1,8 +1,8 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- export * from './src/main/ets/RNTextInputMaskPackage';
8
- export * from "./src/main/ets/RNTextInputMaskTurboModle"
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ export * from './src/main/ets/RNTextInputMaskPackage';
8
+ export * from "./src/main/ets/RNTextInputMaskTurboModle"
Binary file