@dongsuo/react-native-uitextview 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 +225 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNUITextViewSpec-generated.cpp +22 -0
- package/android/generated/jni/RNUITextViewSpec.h +24 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/ComponentDescriptors.cpp +23 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/ComponentDescriptors.h +25 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/EventEmitters.cpp +61 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/EventEmitters.h +49 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/Props.cpp +47 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/Props.h +182 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/RNUITextViewSpecJSI-generated.cpp +17 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/RNUITextViewSpecJSI.h +19 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/ShadowNodes.cpp +18 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/ShadowNodes.h +43 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/States.h +41 -0
- package/ios/RNUITextView.h +23 -0
- package/ios/RNUITextView.mm +474 -0
- package/ios/RNUITextViewChild.h +24 -0
- package/ios/RNUITextViewChild.mm +76 -0
- package/ios/RNUITextViewChildComponentDescriptor.h +13 -0
- package/ios/RNUITextViewChildShadowNode.cpp +6 -0
- package/ios/RNUITextViewChildShadowNode.h +16 -0
- package/ios/RNUITextViewComponentDescriptor.h +13 -0
- package/ios/RNUITextViewEventEmitter.h +26 -0
- package/ios/RNUITextViewManager.mm +36 -0
- package/ios/RNUITextViewShadowNode.cpp +127 -0
- package/ios/RNUITextViewShadowNode.h +48 -0
- package/ios/RNUITextViewSpecJSI-generated.cpp +17 -0
- package/ios/RNUITextViewSpecJSI.h +19 -0
- package/ios/generated/RNUITextViewSpec/ComponentDescriptors.cpp +23 -0
- package/ios/generated/RNUITextViewSpec/ComponentDescriptors.h +25 -0
- package/ios/generated/RNUITextViewSpec/EventEmitters.cpp +61 -0
- package/ios/generated/RNUITextViewSpec/EventEmitters.h +49 -0
- package/ios/generated/RNUITextViewSpec/Props.cpp +47 -0
- package/ios/generated/RNUITextViewSpec/Props.h +182 -0
- package/ios/generated/RNUITextViewSpec/RCTComponentViewHelpers.h +24 -0
- package/ios/generated/RNUITextViewSpec/RNUITextViewSpec-generated.mm +16 -0
- package/ios/generated/RNUITextViewSpec/RNUITextViewSpec.h +38 -0
- package/ios/generated/RNUITextViewSpec/ShadowNodes.cpp +18 -0
- package/ios/generated/RNUITextViewSpec/ShadowNodes.h +43 -0
- package/ios/generated/RNUITextViewSpec/States.cpp +16 -0
- package/ios/generated/RNUITextViewSpec/States.h +41 -0
- package/ios/generated/RNUITextViewSpecJSI-generated.cpp +17 -0
- package/ios/generated/RNUITextViewSpecJSI.h +19 -0
- package/lib/commonjs/RNUITextViewChildNativeComponent.ts +48 -0
- package/lib/commonjs/RNUITextViewNativeComponent.ts +47 -0
- package/lib/commonjs/Text.js +140 -0
- package/lib/commonjs/Text.js.map +1 -0
- package/lib/commonjs/index.js +17 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/util.js +64 -0
- package/lib/commonjs/util.js.map +1 -0
- package/lib/module/RNUITextViewChildNativeComponent.ts +48 -0
- package/lib/module/RNUITextViewNativeComponent.ts +47 -0
- package/lib/module/Text.js +136 -0
- package/lib/module/Text.js.map +1 -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/module/util.js +60 -0
- package/lib/module/util.js.map +1 -0
- package/lib/typescript/commonjs/example/src/App.d.ts +2 -0
- package/lib/typescript/commonjs/example/src/App.d.ts.map +1 -0
- package/lib/typescript/commonjs/example/src/CustomMenuExample.d.ts +3 -0
- package/lib/typescript/commonjs/example/src/CustomMenuExample.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/RNUITextViewChildNativeComponent.d.ts +28 -0
- package/lib/typescript/commonjs/src/RNUITextViewChildNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/RNUITextViewNativeComponent.d.ts +29 -0
- package/lib/typescript/commonjs/src/RNUITextViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Text.d.ts +17 -0
- package/lib/typescript/commonjs/src/Text.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +2 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/util.d.ts +160 -0
- package/lib/typescript/commonjs/src/util.d.ts.map +1 -0
- package/lib/typescript/module/example/src/App.d.ts +2 -0
- package/lib/typescript/module/example/src/App.d.ts.map +1 -0
- package/lib/typescript/module/example/src/CustomMenuExample.d.ts +3 -0
- package/lib/typescript/module/example/src/CustomMenuExample.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/RNUITextViewChildNativeComponent.d.ts +28 -0
- package/lib/typescript/module/src/RNUITextViewChildNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/RNUITextViewNativeComponent.d.ts +29 -0
- package/lib/typescript/module/src/RNUITextViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/Text.d.ts +17 -0
- package/lib/typescript/module/src/Text.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +2 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/util.d.ts +160 -0
- package/lib/typescript/module/src/util.d.ts.map +1 -0
- package/package.json +187 -0
- package/react-native-uitextview.podspec +21 -0
- package/react-native.config.js +28 -0
- package/src/RNUITextViewChildNativeComponent.ts +48 -0
- package/src/RNUITextViewNativeComponent.ts +47 -0
- package/src/Text.tsx +148 -0
- package/src/index.tsx +1 -0
- package/src/util.ts +65 -0
package/src/util.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {type StyleProp, StyleSheet, type TextStyle} from 'react-native'
|
|
2
|
+
import type {NativeFontWeight} from './RNUITextViewChildNativeComponent'
|
|
3
|
+
|
|
4
|
+
export function flattenStyles(
|
|
5
|
+
rootStyle: TextStyle,
|
|
6
|
+
style: StyleProp<TextStyle>,
|
|
7
|
+
) {
|
|
8
|
+
const flattenedStyle = StyleSheet.flatten([rootStyle, style]) as TextStyle
|
|
9
|
+
return {
|
|
10
|
+
...flattenedStyle,
|
|
11
|
+
fontWeight: fontWeightToNativeProp(flattenedStyle.fontWeight ?? 'normal'),
|
|
12
|
+
backgroundColor: flattenedStyle.backgroundColor
|
|
13
|
+
? flattenedStyle.backgroundColor
|
|
14
|
+
: 'transparent',
|
|
15
|
+
shadowOffset: flattenedStyle.shadowOffset
|
|
16
|
+
? flattenedStyle.shadowOffset
|
|
17
|
+
: {width: 0, height: 0},
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Codegen doesn't like using integer values for enums (c++ L) so we'll conver them to the proper native prop
|
|
22
|
+
// value before returning flattened styles.
|
|
23
|
+
function fontWeightToNativeProp(
|
|
24
|
+
fontWeight: TextStyle['fontWeight'],
|
|
25
|
+
): NativeFontWeight {
|
|
26
|
+
switch (fontWeight) {
|
|
27
|
+
case 'normal':
|
|
28
|
+
return 'normal'
|
|
29
|
+
case 'bold':
|
|
30
|
+
return 'bold'
|
|
31
|
+
case 100:
|
|
32
|
+
case '100':
|
|
33
|
+
case 'ultralight':
|
|
34
|
+
return 'ultraLight'
|
|
35
|
+
case 200:
|
|
36
|
+
case '200':
|
|
37
|
+
return 'ultraLight'
|
|
38
|
+
case 300:
|
|
39
|
+
case '300':
|
|
40
|
+
case 'light':
|
|
41
|
+
return 'light'
|
|
42
|
+
case 400:
|
|
43
|
+
case '400':
|
|
44
|
+
case 'regular':
|
|
45
|
+
return 'normal'
|
|
46
|
+
case 500:
|
|
47
|
+
return 'medium'
|
|
48
|
+
case 600:
|
|
49
|
+
case '600':
|
|
50
|
+
case 'semibold':
|
|
51
|
+
return 'semibold'
|
|
52
|
+
case 700:
|
|
53
|
+
case '700':
|
|
54
|
+
return 'semibold'
|
|
55
|
+
case 800:
|
|
56
|
+
case '800':
|
|
57
|
+
return 'bold'
|
|
58
|
+
case 900:
|
|
59
|
+
case '900':
|
|
60
|
+
case 'heavy':
|
|
61
|
+
return 'heavy'
|
|
62
|
+
default:
|
|
63
|
+
return 'normal'
|
|
64
|
+
}
|
|
65
|
+
}
|