@azsxdc12356/react-native-sync-format-edittext 1.0.0
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/LICENSE +20 -0
- package/README.md +130 -0
- package/SyncFormatEdittext.podspec +20 -0
- package/android/build.gradle +105 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/CMakeLists.txt +28 -0
- package/android/src/main/cpp/FormatHostObject.cpp +117 -0
- package/android/src/main/cpp/FormatHostObject.h +38 -0
- package/android/src/main/cpp/FormatModuleJNI.cpp +80 -0
- package/android/src/main/java/com/syncformatedittext/FormatModuleImpl.kt +77 -0
- package/android/src/main/java/com/syncformatedittext/SyncFormatEdittextView.kt +70 -0
- package/android/src/newarch/java/com/syncformatedittext/FormatModule.kt +19 -0
- package/android/src/newarch/java/com/syncformatedittext/SyncFormatEditTextChangeEvent.kt +22 -0
- package/android/src/newarch/java/com/syncformatedittext/SyncFormatEdittextPackage.kt +37 -0
- package/android/src/newarch/java/com/syncformatedittext/SyncFormatEdittextViewManager.kt +61 -0
- package/android/src/oldarch/java/com/syncformatedittext/FormatModule.kt +23 -0
- package/android/src/oldarch/java/com/syncformatedittext/SyncFormatEditTextChangeEvent.kt +21 -0
- package/android/src/oldarch/java/com/syncformatedittext/SyncFormatEdittextPackage.kt +18 -0
- package/android/src/oldarch/java/com/syncformatedittext/SyncFormatEdittextViewManager.kt +60 -0
- package/ios/SyncFormatEdittextView.h +14 -0
- package/ios/SyncFormatEdittextView.mm +48 -0
- package/lib/module/NativeFormatModule.js +5 -0
- package/lib/module/NativeFormatModule.js.map +1 -0
- package/lib/module/SyncFormatEdittextView.js +14 -0
- package/lib/module/SyncFormatEdittextView.js.map +1 -0
- package/lib/module/SyncFormatEdittextView.native.js +49 -0
- package/lib/module/SyncFormatEdittextView.native.js.map +1 -0
- package/lib/module/SyncFormatEdittextViewNativeComponent.ts +198 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeFormatModule.d.ts +7 -0
- package/lib/typescript/src/NativeFormatModule.d.ts.map +1 -0
- package/lib/typescript/src/SyncFormatEdittextView.d.ts +3 -0
- package/lib/typescript/src/SyncFormatEdittextView.d.ts.map +1 -0
- package/lib/typescript/src/SyncFormatEdittextView.native.d.ts +12 -0
- package/lib/typescript/src/SyncFormatEdittextView.native.d.ts.map +1 -0
- package/lib/typescript/src/SyncFormatEdittextViewNativeComponent.d.ts +139 -0
- package/lib/typescript/src/SyncFormatEdittextViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +181 -0
- package/src/NativeFormatModule.ts +8 -0
- package/src/SyncFormatEdittextView.native.tsx +81 -0
- package/src/SyncFormatEdittextView.tsx +6 -0
- package/src/SyncFormatEdittextViewNativeComponent.ts +198 -0
- package/src/index.tsx +2 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.syncformatedittext
|
|
2
|
+
|
|
3
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReactMethod
|
|
6
|
+
|
|
7
|
+
class FormatModule(reactContext: ReactApplicationContext) :
|
|
8
|
+
NativeFormatModuleSpec(reactContext) {
|
|
9
|
+
|
|
10
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
11
|
+
@DoNotStrip
|
|
12
|
+
override fun install() {
|
|
13
|
+
FormatModuleImpl.instance?.install()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
companion object {
|
|
17
|
+
const val NAME = "FormatModule"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package com.syncformatedittext
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.WritableMap
|
|
5
|
+
import com.facebook.react.uimanager.events.Event
|
|
6
|
+
|
|
7
|
+
class SyncFormatEditTextChangeEvent(
|
|
8
|
+
surfaceId: Int,
|
|
9
|
+
viewTag: Int,
|
|
10
|
+
private val text: String,
|
|
11
|
+
private val cursorPos: Int
|
|
12
|
+
) : Event<SyncFormatEditTextChangeEvent>(surfaceId, viewTag) {
|
|
13
|
+
|
|
14
|
+
override fun getEventName(): String = "topSyncFormatChange"
|
|
15
|
+
|
|
16
|
+
override fun getEventData(): WritableMap {
|
|
17
|
+
return Arguments.createMap().apply {
|
|
18
|
+
putString("text", text)
|
|
19
|
+
putDouble("cursorPos", cursorPos.toDouble())
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
package com.syncformatedittext
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
import com.facebook.react.uimanager.ViewManager
|
|
9
|
+
|
|
10
|
+
class SyncFormatEdittextViewPackage : BaseReactPackage() {
|
|
11
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
12
|
+
return listOf(SyncFormatEdittextViewManager())
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
16
|
+
return when (name) {
|
|
17
|
+
FormatModule.NAME -> {
|
|
18
|
+
FormatModuleImpl.instance = FormatModuleImpl(reactContext)
|
|
19
|
+
FormatModule(reactContext)
|
|
20
|
+
}
|
|
21
|
+
else -> null
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override fun getReactModuleInfoProvider() = ReactModuleInfoProvider {
|
|
26
|
+
mapOf(
|
|
27
|
+
FormatModule.NAME to ReactModuleInfo(
|
|
28
|
+
FormatModule.NAME,
|
|
29
|
+
FormatModule.NAME,
|
|
30
|
+
false, // canOverrideExistingModule
|
|
31
|
+
true, // needsEagerInit
|
|
32
|
+
false, // isCxxModule
|
|
33
|
+
true // isTurboModule
|
|
34
|
+
)
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
package com.syncformatedittext
|
|
2
|
+
|
|
3
|
+
import android.text.SpannableString
|
|
4
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
5
|
+
import com.facebook.react.common.MapBuilder
|
|
6
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
7
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
8
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
9
|
+
import com.facebook.react.views.text.ReactTextUpdate
|
|
10
|
+
import com.facebook.react.views.textinput.ReactEditText
|
|
11
|
+
import com.facebook.react.views.textinput.ReactTextInputManager
|
|
12
|
+
|
|
13
|
+
@ReactModule(name = SyncFormatEdittextViewManager.NAME)
|
|
14
|
+
class SyncFormatEdittextViewManager : ReactTextInputManager() {
|
|
15
|
+
|
|
16
|
+
override fun getName(): String = NAME
|
|
17
|
+
|
|
18
|
+
override fun createViewInstance(context: ThemedReactContext): SyncFormatEdittextView {
|
|
19
|
+
val view = SyncFormatEdittextView(context)
|
|
20
|
+
view.formatModule = FormatModuleImpl.instance
|
|
21
|
+
return view
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
override fun addEventEmitters(context: ThemedReactContext, view: ReactEditText) {
|
|
25
|
+
super.addEventEmitters(context, view)
|
|
26
|
+
val editText = view as SyncFormatEdittextView
|
|
27
|
+
editText.setOnFormatListener { text, cursorPos ->
|
|
28
|
+
val dispatcher = UIManagerHelper.getEventDispatcherForReactTag(context, editText.id)
|
|
29
|
+
dispatcher?.dispatchEvent(
|
|
30
|
+
SyncFormatEditTextChangeEvent(
|
|
31
|
+
UIManagerHelper.getSurfaceId(editText),
|
|
32
|
+
editText.id,
|
|
33
|
+
text,
|
|
34
|
+
cursorPos
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@ReactProp(name = "value")
|
|
41
|
+
fun setValue(view: ReactEditText, value: String?) {
|
|
42
|
+
val text = value ?: ""
|
|
43
|
+
val currentText = view.text.toString()
|
|
44
|
+
if (currentText == text) return
|
|
45
|
+
val spannable = SpannableString(text)
|
|
46
|
+
val eventCount = view.incrementAndGetEventCounter()
|
|
47
|
+
view.maybeSetTextFromJS(
|
|
48
|
+
ReactTextUpdate(spannable, eventCount, false, 0, 0, 0)
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any> {
|
|
53
|
+
val constants = super.getExportedCustomDirectEventTypeConstants().toMutableMap()
|
|
54
|
+
constants["topSyncFormatChange"] = MapBuilder.of("registrationName", "onSyncFormatChange")
|
|
55
|
+
return constants
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
companion object {
|
|
59
|
+
const val NAME = "SyncFormatEdittextView"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package com.syncformatedittext
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
|
+
import com.facebook.react.bridge.ReactMethod
|
|
6
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
7
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule
|
|
8
|
+
|
|
9
|
+
@ReactModule(name = FormatModule.NAME)
|
|
10
|
+
class FormatModule(reactContext: ReactApplicationContext) :
|
|
11
|
+
ReactContextBaseJavaModule(reactContext), TurboModule {
|
|
12
|
+
|
|
13
|
+
override fun getName(): String = NAME
|
|
14
|
+
|
|
15
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
16
|
+
fun install() {
|
|
17
|
+
FormatModuleImpl.instance?.install()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
companion object {
|
|
21
|
+
const val NAME = "FormatModule"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package com.syncformatedittext
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.WritableMap
|
|
5
|
+
import com.facebook.react.uimanager.events.Event
|
|
6
|
+
|
|
7
|
+
class SyncFormatEditTextChangeEvent(
|
|
8
|
+
viewTag: Int,
|
|
9
|
+
private val text: String,
|
|
10
|
+
private val cursorPos: Int
|
|
11
|
+
) : Event<SyncFormatEditTextChangeEvent>(viewTag) {
|
|
12
|
+
|
|
13
|
+
override fun getEventName(): String = "topSyncFormatChange"
|
|
14
|
+
|
|
15
|
+
override fun getEventData(): WritableMap {
|
|
16
|
+
return Arguments.createMap().apply {
|
|
17
|
+
putString("text", text)
|
|
18
|
+
putDouble("cursorPos", cursorPos.toDouble())
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package com.syncformatedittext
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
class SyncFormatEdittextViewPackage : ReactPackage {
|
|
9
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
10
|
+
return listOf(SyncFormatEdittextViewManager())
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
14
|
+
FormatModuleImpl.instance = FormatModuleImpl(reactContext)
|
|
15
|
+
val module = FormatModule(reactContext)
|
|
16
|
+
return listOf(module)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
package com.syncformatedittext
|
|
2
|
+
|
|
3
|
+
import android.text.SpannableString
|
|
4
|
+
import com.facebook.react.common.MapBuilder
|
|
5
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
6
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
7
|
+
import com.facebook.react.uimanager.UIManagerModule
|
|
8
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
9
|
+
import com.facebook.react.views.text.ReactTextUpdate
|
|
10
|
+
import com.facebook.react.views.textinput.ReactEditText
|
|
11
|
+
import com.facebook.react.views.textinput.ReactTextInputManager
|
|
12
|
+
|
|
13
|
+
@ReactModule(name = SyncFormatEdittextViewManager.NAME)
|
|
14
|
+
class SyncFormatEdittextViewManager : ReactTextInputManager() {
|
|
15
|
+
|
|
16
|
+
override fun getName(): String = NAME
|
|
17
|
+
|
|
18
|
+
override fun createViewInstance(context: ThemedReactContext): SyncFormatEdittextView {
|
|
19
|
+
val view = SyncFormatEdittextView(context)
|
|
20
|
+
view.formatModule = FormatModuleImpl.instance
|
|
21
|
+
return view
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
override fun addEventEmitters(context: ThemedReactContext, view: ReactEditText) {
|
|
25
|
+
super.addEventEmitters(context, view)
|
|
26
|
+
val editText = view as SyncFormatEdittextView
|
|
27
|
+
editText.setOnFormatListener { text, cursorPos ->
|
|
28
|
+
val dispatcher = context.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher
|
|
29
|
+
dispatcher.dispatchEvent(
|
|
30
|
+
SyncFormatEditTextChangeEvent(
|
|
31
|
+
editText.id,
|
|
32
|
+
text,
|
|
33
|
+
cursorPos
|
|
34
|
+
)
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@ReactProp(name = "value")
|
|
40
|
+
fun setValue(view: ReactEditText, value: String?) {
|
|
41
|
+
val text = value ?: ""
|
|
42
|
+
val currentText = view.text.toString()
|
|
43
|
+
if (currentText == text) return
|
|
44
|
+
val spannable = SpannableString(text)
|
|
45
|
+
val eventCount = view.incrementAndGetEventCounter()
|
|
46
|
+
view.maybeSetTextFromJS(
|
|
47
|
+
ReactTextUpdate(spannable, eventCount, false, 0, 0, 0)
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any> {
|
|
52
|
+
val constants = super.getExportedCustomDirectEventTypeConstants().toMutableMap()
|
|
53
|
+
constants["topSyncFormatChange"] = MapBuilder.of("registrationName", "onSyncFormatChange")
|
|
54
|
+
return constants
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
companion object {
|
|
58
|
+
const val NAME = "SyncFormatEdittextView"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#import <React/RCTViewComponentView.h>
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
|
|
4
|
+
#ifndef SyncFormatEdittextViewNativeComponent_h
|
|
5
|
+
#define SyncFormatEdittextViewNativeComponent_h
|
|
6
|
+
|
|
7
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
8
|
+
|
|
9
|
+
@interface SyncFormatEdittextView : RCTViewComponentView
|
|
10
|
+
@end
|
|
11
|
+
|
|
12
|
+
NS_ASSUME_NONNULL_END
|
|
13
|
+
|
|
14
|
+
#endif /* SyncFormatEdittextViewNativeComponent_h */
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#import "SyncFormatEdittextView.h"
|
|
2
|
+
|
|
3
|
+
#import <React/RCTConversions.h>
|
|
4
|
+
|
|
5
|
+
#import <react/renderer/components/SyncFormatEdittextViewSpec/ComponentDescriptors.h>
|
|
6
|
+
#import <react/renderer/components/SyncFormatEdittextViewSpec/Props.h>
|
|
7
|
+
#import <react/renderer/components/SyncFormatEdittextViewSpec/RCTComponentViewHelpers.h>
|
|
8
|
+
|
|
9
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
10
|
+
|
|
11
|
+
using namespace facebook::react;
|
|
12
|
+
|
|
13
|
+
@implementation SyncFormatEdittextView {
|
|
14
|
+
UIView * _view;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
18
|
+
{
|
|
19
|
+
return concreteComponentDescriptorProvider<SyncFormatEdittextViewComponentDescriptor>();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
23
|
+
{
|
|
24
|
+
if (self = [super initWithFrame:frame]) {
|
|
25
|
+
static const auto defaultProps = std::make_shared<const SyncFormatEdittextViewProps>();
|
|
26
|
+
_props = defaultProps;
|
|
27
|
+
|
|
28
|
+
_view = [[UIView alloc] init];
|
|
29
|
+
|
|
30
|
+
self.contentView = _view;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return self;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
37
|
+
{
|
|
38
|
+
const auto &oldViewProps = *std::static_pointer_cast<SyncFormatEdittextViewProps const>(_props);
|
|
39
|
+
const auto &newViewProps = *std::static_pointer_cast<SyncFormatEdittextViewProps const>(props);
|
|
40
|
+
|
|
41
|
+
if (oldViewProps.color != newViewProps.color) {
|
|
42
|
+
[_view setBackgroundColor: RCTUIColorFromSharedColor(newViewProps.color)];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[super updateProps:props oldProps:oldProps];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"..\\..\\src","sources":["NativeFormatModule.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAMlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,cAAc,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
export function SyncFormatEdittextView({
|
|
6
|
+
format,
|
|
7
|
+
onSyncFormatChange,
|
|
8
|
+
...rest
|
|
9
|
+
}) {
|
|
10
|
+
return /*#__PURE__*/_jsx(View, {
|
|
11
|
+
...rest
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=SyncFormatEdittextView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["View","jsx","_jsx","SyncFormatEdittextView","format","onSyncFormatChange","rest"],"sourceRoot":"..\\..\\src","sources":["SyncFormatEdittextView.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGpC,OAAO,SAASC,sBAAsBA,CAAC;EAAEC,MAAM;EAAEC,kBAAkB;EAAE,GAAGC;AAA8B,CAAC,EAAE;EACvG,oBAAOJ,IAAA,CAACF,IAAI;IAAA,GAAMM;EAAI,CAAW,CAAC;AACpC","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
4
|
+
import { findNodeHandle, TurboModuleRegistry } from 'react-native';
|
|
5
|
+
import SyncFormatEdittextViewNativeComponent from './SyncFormatEdittextViewNativeComponent';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
// Install JSI bindings on first use
|
|
8
|
+
try {
|
|
9
|
+
const fmtModule = TurboModuleRegistry.getEnforcing('FormatModule');
|
|
10
|
+
fmtModule.install();
|
|
11
|
+
} catch {}
|
|
12
|
+
export function SyncFormatEdittextView({
|
|
13
|
+
format,
|
|
14
|
+
onSyncFormatChange,
|
|
15
|
+
onChange,
|
|
16
|
+
onChangeText,
|
|
17
|
+
...rest
|
|
18
|
+
}) {
|
|
19
|
+
const viewRef = useRef(null);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!format || !viewRef.current) return;
|
|
22
|
+
const formatModule = globalThis.__formatModule;
|
|
23
|
+
if (!formatModule) return;
|
|
24
|
+
const tag = findNodeHandle(viewRef.current);
|
|
25
|
+
if (tag) {
|
|
26
|
+
formatModule.setFormat(tag, format);
|
|
27
|
+
}
|
|
28
|
+
return () => {
|
|
29
|
+
if (tag) {
|
|
30
|
+
formatModule.removeFormat(tag);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}, [viewRef.current]);
|
|
34
|
+
const handleSyncFormatChange = useCallback(event => {
|
|
35
|
+
const {
|
|
36
|
+
text,
|
|
37
|
+
cursorPos
|
|
38
|
+
} = event.nativeEvent;
|
|
39
|
+
onSyncFormatChange?.(text, cursorPos);
|
|
40
|
+
}, [onSyncFormatChange]);
|
|
41
|
+
return /*#__PURE__*/_jsx(SyncFormatEdittextViewNativeComponent, {
|
|
42
|
+
ref: viewRef,
|
|
43
|
+
...rest,
|
|
44
|
+
onChange: onChange,
|
|
45
|
+
onChangeText: onChangeText,
|
|
46
|
+
onSyncFormatChange: handleSyncFormatChange
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=SyncFormatEdittextView.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useRef","findNodeHandle","TurboModuleRegistry","SyncFormatEdittextViewNativeComponent","jsx","_jsx","fmtModule","getEnforcing","install","SyncFormatEdittextView","format","onSyncFormatChange","onChange","onChangeText","rest","viewRef","current","formatModule","globalThis","__formatModule","tag","setFormat","removeFormat","handleSyncFormatChange","event","text","cursorPos","nativeEvent","ref"],"sourceRoot":"..\\..\\src","sources":["SyncFormatEdittextView.native.tsx"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACtD,SACEC,cAAc,EACdC,mBAAmB,QAGd,cAAc;AACrB,OAAOC,qCAAqC,MAAM,yCAAyC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAiB5F;AACA,IAAI;EACF,MAAMC,SAAS,GAAGJ,mBAAmB,CAACK,YAAY,CAChD,cACF,CAAmC;EACnCD,SAAS,CAACE,OAAO,CAAC,CAAC;AACrB,CAAC,CAAC,MAAM,CAAC;AAET,OAAO,SAASC,sBAAsBA,CAAC;EACrCC,MAAM;EACNC,kBAAkB;EAClBC,QAAQ;EACRC,YAAY;EACZ,GAAGC;AACoB,CAAC,EAAE;EAC1B,MAAMC,OAAO,GAAGf,MAAM,CAAC,IAAI,CAAC;EAE5BD,SAAS,CAAC,MAAM;IACd,IAAI,CAACW,MAAM,IAAI,CAACK,OAAO,CAACC,OAAO,EAAE;IAEjC,MAAMC,YAAY,GAAIC,UAAU,CAASC,cAK5B;IACb,IAAI,CAACF,YAAY,EAAE;IAEnB,MAAMG,GAAG,GAAGnB,cAAc,CAACc,OAAO,CAACC,OAAO,CAAC;IAC3C,IAAII,GAAG,EAAE;MACPH,YAAY,CAACI,SAAS,CAACD,GAAG,EAAEV,MAAM,CAAC;IACrC;IACA,OAAO,MAAM;MACX,IAAIU,GAAG,EAAE;QACPH,YAAY,CAACK,YAAY,CAACF,GAAG,CAAC;MAChC;IACF,CAAC;EACH,CAAC,EAAE,CAACL,OAAO,CAACC,OAAO,CAAC,CAAC;EAErB,MAAMO,sBAAsB,GAAGzB,WAAW,CACvC0B,KAA4B,IAAK;IAChC,MAAM;MAAEC,IAAI;MAAEC;IAAU,CAAC,GAAGF,KAAK,CAACG,WAAW;IAC7ChB,kBAAkB,GAAGc,IAAI,EAAEC,SAAS,CAAC;EACvC,CAAC,EACD,CAACf,kBAAkB,CACrB,CAAC;EAED,oBACEN,IAAA,CAACF,qCAAqC;IACpCyB,GAAG,EAAEb,OAAQ;IAAA,GACRD,IAAI;IACTF,QAAQ,EAAEA,QAAgB;IAC1BC,YAAY,EAAEA,YAAoB;IAClCF,kBAAkB,EAAEY;EAAuB,CAC5C,CAAC;AAEN","ignoreList":[]}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import type { CodegenTypes } from 'react-native';
|
|
2
|
+
import { codegenNativeComponent, type ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
type KeyboardType =
|
|
5
|
+
| 'default'
|
|
6
|
+
| 'email-address'
|
|
7
|
+
| 'numeric'
|
|
8
|
+
| 'phone-pad'
|
|
9
|
+
| 'number-pad'
|
|
10
|
+
| 'decimal-pad'
|
|
11
|
+
| 'url'
|
|
12
|
+
| 'ascii-capable'
|
|
13
|
+
| 'numbers-and-punctuation'
|
|
14
|
+
| 'name-phone-pad'
|
|
15
|
+
| 'twitter'
|
|
16
|
+
| 'web-search'
|
|
17
|
+
| 'visible-password';
|
|
18
|
+
|
|
19
|
+
type ReturnKeyType =
|
|
20
|
+
| 'done'
|
|
21
|
+
| 'go'
|
|
22
|
+
| 'next'
|
|
23
|
+
| 'search'
|
|
24
|
+
| 'send'
|
|
25
|
+
| 'none'
|
|
26
|
+
| 'previous'
|
|
27
|
+
| 'default'
|
|
28
|
+
| 'emergency-call'
|
|
29
|
+
| 'google'
|
|
30
|
+
| 'join'
|
|
31
|
+
| 'route'
|
|
32
|
+
| 'yahoo';
|
|
33
|
+
|
|
34
|
+
type SubmitBehavior = 'submit' | 'blurAndSubmit' | 'newline';
|
|
35
|
+
|
|
36
|
+
interface NativeProps extends ViewProps {
|
|
37
|
+
// Android-specific props
|
|
38
|
+
autoComplete?: CodegenTypes.WithDefault<
|
|
39
|
+
| 'birthdate-day'
|
|
40
|
+
| 'birthdate-full'
|
|
41
|
+
| 'birthdate-month'
|
|
42
|
+
| 'birthdate-year'
|
|
43
|
+
| 'cc-csc'
|
|
44
|
+
| 'cc-exp'
|
|
45
|
+
| 'cc-exp-day'
|
|
46
|
+
| 'cc-exp-month'
|
|
47
|
+
| 'cc-exp-year'
|
|
48
|
+
| 'cc-number'
|
|
49
|
+
| 'email'
|
|
50
|
+
| 'gender'
|
|
51
|
+
| 'name'
|
|
52
|
+
| 'name-family'
|
|
53
|
+
| 'name-given'
|
|
54
|
+
| 'name-middle'
|
|
55
|
+
| 'name-middle-initial'
|
|
56
|
+
| 'name-prefix'
|
|
57
|
+
| 'name-suffix'
|
|
58
|
+
| 'password'
|
|
59
|
+
| 'password-new'
|
|
60
|
+
| 'postal-address'
|
|
61
|
+
| 'postal-address-country'
|
|
62
|
+
| 'postal-address-extended'
|
|
63
|
+
| 'postal-address-extended-postal-code'
|
|
64
|
+
| 'postal-address-locality'
|
|
65
|
+
| 'postal-address-region'
|
|
66
|
+
| 'postal-code'
|
|
67
|
+
| 'street-address'
|
|
68
|
+
| 'sms-otp'
|
|
69
|
+
| 'tel'
|
|
70
|
+
| 'tel-country-code'
|
|
71
|
+
| 'tel-national'
|
|
72
|
+
| 'tel-device'
|
|
73
|
+
| 'username'
|
|
74
|
+
| 'username-new'
|
|
75
|
+
| 'off',
|
|
76
|
+
'off'
|
|
77
|
+
>;
|
|
78
|
+
returnKeyLabel?: string;
|
|
79
|
+
numberOfLines?: CodegenTypes.Int32;
|
|
80
|
+
disableFullscreenUI?: boolean;
|
|
81
|
+
textBreakStrategy?: CodegenTypes.WithDefault<
|
|
82
|
+
'simple' | 'highQuality' | 'balanced',
|
|
83
|
+
'simple'
|
|
84
|
+
>;
|
|
85
|
+
underlineColorAndroid?: CodegenTypes.Int32;
|
|
86
|
+
inlineImageLeft?: string;
|
|
87
|
+
inlineImagePadding?: CodegenTypes.Int32;
|
|
88
|
+
importantForAutofill?: string;
|
|
89
|
+
showSoftInputOnFocus?: boolean;
|
|
90
|
+
|
|
91
|
+
// TextInput core props
|
|
92
|
+
autoCapitalize?: CodegenTypes.WithDefault<
|
|
93
|
+
'none' | 'sentences' | 'words' | 'characters',
|
|
94
|
+
'none'
|
|
95
|
+
>;
|
|
96
|
+
autoCorrect?: boolean;
|
|
97
|
+
autoFocus?: boolean;
|
|
98
|
+
allowFontScaling?: boolean;
|
|
99
|
+
maxFontSizeMultiplier?: CodegenTypes.Float;
|
|
100
|
+
editable?: boolean;
|
|
101
|
+
keyboardType?: CodegenTypes.WithDefault<KeyboardType, 'default'>;
|
|
102
|
+
returnKeyType?: CodegenTypes.WithDefault<ReturnKeyType, 'done'>;
|
|
103
|
+
maxLength?: CodegenTypes.Int32;
|
|
104
|
+
multiline?: boolean;
|
|
105
|
+
|
|
106
|
+
// Events
|
|
107
|
+
onBlur?: CodegenTypes.BubblingEventHandler<{ target: CodegenTypes.Int32 }>;
|
|
108
|
+
onFocus?: CodegenTypes.BubblingEventHandler<{ target: CodegenTypes.Int32 }>;
|
|
109
|
+
onChange?: CodegenTypes.BubblingEventHandler<{
|
|
110
|
+
target: CodegenTypes.Int32;
|
|
111
|
+
eventCount: CodegenTypes.Int32;
|
|
112
|
+
text: string;
|
|
113
|
+
}>;
|
|
114
|
+
onChangeText?: CodegenTypes.BubblingEventHandler<{
|
|
115
|
+
target: CodegenTypes.Int32;
|
|
116
|
+
eventCount: CodegenTypes.Int32;
|
|
117
|
+
text: string;
|
|
118
|
+
}>;
|
|
119
|
+
onContentSizeChange?: CodegenTypes.DirectEventHandler<{
|
|
120
|
+
target: CodegenTypes.Int32;
|
|
121
|
+
contentSize: { width: CodegenTypes.Double; height: CodegenTypes.Double };
|
|
122
|
+
}>;
|
|
123
|
+
onEndEditing?: CodegenTypes.BubblingEventHandler<{
|
|
124
|
+
target: CodegenTypes.Int32;
|
|
125
|
+
text: string;
|
|
126
|
+
}>;
|
|
127
|
+
onSelectionChange?: CodegenTypes.DirectEventHandler<{
|
|
128
|
+
target: CodegenTypes.Int32;
|
|
129
|
+
selection: { start: CodegenTypes.Double; end: CodegenTypes.Double };
|
|
130
|
+
}>;
|
|
131
|
+
onSubmitEditing?: CodegenTypes.BubblingEventHandler<{
|
|
132
|
+
target: CodegenTypes.Int32;
|
|
133
|
+
text: string;
|
|
134
|
+
}>;
|
|
135
|
+
onKeyPress?: CodegenTypes.BubblingEventHandler<{
|
|
136
|
+
target: CodegenTypes.Int32;
|
|
137
|
+
key: string;
|
|
138
|
+
}>;
|
|
139
|
+
onScroll?: CodegenTypes.DirectEventHandler<{
|
|
140
|
+
target: CodegenTypes.Int32;
|
|
141
|
+
responderIgnoreScroll: boolean;
|
|
142
|
+
contentInset: {
|
|
143
|
+
top: CodegenTypes.Double;
|
|
144
|
+
bottom: CodegenTypes.Double;
|
|
145
|
+
left: CodegenTypes.Double;
|
|
146
|
+
right: CodegenTypes.Double;
|
|
147
|
+
};
|
|
148
|
+
contentOffset: { x: CodegenTypes.Double; y: CodegenTypes.Double };
|
|
149
|
+
contentSize: { width: CodegenTypes.Double; height: CodegenTypes.Double };
|
|
150
|
+
layoutMeasurement: { width: CodegenTypes.Double; height: CodegenTypes.Double };
|
|
151
|
+
velocity: { x: CodegenTypes.Double; y: CodegenTypes.Double };
|
|
152
|
+
}>;
|
|
153
|
+
|
|
154
|
+
// Value and display props
|
|
155
|
+
placeholder?: string;
|
|
156
|
+
placeholderTextColor?: CodegenTypes.Int32;
|
|
157
|
+
secureTextEntry?: boolean;
|
|
158
|
+
selectionColor?: CodegenTypes.Int32;
|
|
159
|
+
selectionHandleColor?: CodegenTypes.Int32;
|
|
160
|
+
selection?: { start: CodegenTypes.Int32; end?: CodegenTypes.Int32 };
|
|
161
|
+
value?: string;
|
|
162
|
+
defaultValue?: string;
|
|
163
|
+
selectTextOnFocus?: boolean;
|
|
164
|
+
blurOnSubmit?: boolean;
|
|
165
|
+
submitBehavior?: CodegenTypes.WithDefault<SubmitBehavior, 'blurAndSubmit'>;
|
|
166
|
+
caretHidden?: boolean;
|
|
167
|
+
contextMenuHidden?: boolean;
|
|
168
|
+
|
|
169
|
+
// Text styling props
|
|
170
|
+
textShadowColor?: CodegenTypes.Int32;
|
|
171
|
+
textShadowRadius?: CodegenTypes.Float;
|
|
172
|
+
textDecorationLine?: string;
|
|
173
|
+
fontStyle?: string;
|
|
174
|
+
textShadowOffset?: { width?: CodegenTypes.Double; height?: CodegenTypes.Double };
|
|
175
|
+
lineHeight?: CodegenTypes.Float;
|
|
176
|
+
textTransform?: string;
|
|
177
|
+
color?: CodegenTypes.Int32;
|
|
178
|
+
letterSpacing?: CodegenTypes.Float;
|
|
179
|
+
fontSize?: CodegenTypes.Float;
|
|
180
|
+
textAlign?: string;
|
|
181
|
+
includeFontPadding?: boolean;
|
|
182
|
+
fontWeight?: string;
|
|
183
|
+
fontFamily?: string;
|
|
184
|
+
textAlignVertical?: string;
|
|
185
|
+
cursorColor?: CodegenTypes.Int32;
|
|
186
|
+
|
|
187
|
+
// Internal props (used by TextInput.js)
|
|
188
|
+
mostRecentEventCount?: CodegenTypes.Int32;
|
|
189
|
+
text?: string;
|
|
190
|
+
|
|
191
|
+
// Custom: sync format event
|
|
192
|
+
onSyncFormatChange?: CodegenTypes.DirectEventHandler<{
|
|
193
|
+
text: string;
|
|
194
|
+
cursorPos: CodegenTypes.Double;
|
|
195
|
+
}>;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export default codegenNativeComponent<NativeProps>('SyncFormatEdittextView');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SyncFormatEdittextView"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,sBAAsB,QAAQ,0BAA0B","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeFormatModule.d.ts","sourceRoot":"","sources":["../../../src/NativeFormatModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,OAAO,IAAI,IAAI,CAAC;CACjB;;AAED,wBAAsE"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SyncFormatEditTextProps } from './SyncFormatEdittextView.native';
|
|
2
|
+
export declare function SyncFormatEdittextView({ format, onSyncFormatChange, ...rest }: SyncFormatEditTextProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
//# sourceMappingURL=SyncFormatEdittextView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SyncFormatEdittextView.d.ts","sourceRoot":"","sources":["../../../src/SyncFormatEdittextView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE/E,wBAAgB,sBAAsB,CAAC,EAAE,MAAM,EAAE,kBAAkB,EAAE,GAAG,IAAI,EAAE,EAAE,uBAAuB,2CAEtG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type TextInputProps } from 'react-native';
|
|
2
|
+
type FormatFn = (text: string, cursorPos: number) => {
|
|
3
|
+
text: string;
|
|
4
|
+
cursorPos: number;
|
|
5
|
+
};
|
|
6
|
+
export type SyncFormatEditTextProps = TextInputProps & {
|
|
7
|
+
format?: FormatFn;
|
|
8
|
+
onSyncFormatChange?: (text: string, cursorPos: number) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function SyncFormatEdittextView({ format, onSyncFormatChange, onChange, onChangeText, ...rest }: SyncFormatEditTextProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=SyncFormatEdittextView.native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SyncFormatEdittextView.native.d.ts","sourceRoot":"","sources":["../../../src/SyncFormatEdittextView.native.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,cAAc,CAAC;AAGtB,KAAK,QAAQ,GAAG,CACd,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,KACd;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAOzC,MAAM,MAAM,uBAAuB,GAAG,cAAc,GAAG;IACrD,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAChE,CAAC;AAUF,wBAAgB,sBAAsB,CAAC,EACrC,MAAM,EACN,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,GAAG,IAAI,EACR,EAAE,uBAAuB,2CA0CzB"}
|