react-native-signature-canvas 4.7.2 → 5.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/CHANGELOG.md CHANGED
@@ -1,3 +1,54 @@
1
+ # [5.0.0](https://github.com/YanYuanFE/react-native-signature-canvas/compare/v4.5.1...v5.0.0) (2025-06-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add originWhitelist prop ([068c646](https://github.com/YanYuanFE/react-native-signature-canvas/commit/068c6467d1e9910c4911e727b2144e065a9a7322))
7
+ * backgorund color to transparent and loader color to transparent ([3001d4e](https://github.com/YanYuanFE/react-native-signature-canvas/commit/3001d4edfdcf1806e2f16a518d25f1690b80557e))
8
+ * fix canvas not display for android api 28 ([835669b](https://github.com/YanYuanFE/react-native-signature-canvas/commit/835669bb65ab5c88c43830b7a783eed105f3910d))
9
+
10
+
11
+ ### Features
12
+
13
+ * add onLoadEnd prop ([49a8664](https://github.com/YanYuanFE/react-native-signature-canvas/commit/49a866408b6356ce9e71b1c794993a3f2fe85337))
14
+ * add showsVerticalScrollIndicator prop ([a4d64c5](https://github.com/YanYuanFE/react-native-signature-canvas/commit/a4d64c5754a9da4ecb9d531a1585a38994d18d6d))
15
+ * export SignatureViewProps ([8f0c321](https://github.com/YanYuanFE/react-native-signature-canvas/commit/8f0c3211b20782cd8f35a43083f39d5ea351f932))
16
+
17
+
18
+
19
+ ## [4.5.1](https://github.com/YanYuanFE/react-native-signature-canvas/compare/v4.3.0...v4.5.1) (2023-05-04)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * **android:** sigsegv crash on android ([49644b8](https://github.com/YanYuanFE/react-native-signature-canvas/commit/49644b802a7cb80443292972b1fbd3d4dbdfd9c4))
25
+ * fix bgSrc props ([bef3ab2](https://github.com/YanYuanFE/react-native-signature-canvas/commit/bef3ab27ebb990a94dd74517ab67754d557307ae))
26
+ * fix webview version ([1b55f45](https://github.com/YanYuanFE/react-native-signature-canvas/commit/1b55f45e27560cd8b0bdf62504a7d27b412687c2))
27
+
28
+
29
+ ### Features
30
+
31
+ * update rn latest example ([f9a568f](https://github.com/YanYuanFE/react-native-signature-canvas/commit/f9a568f68c966690ee2ec1b300b2e2fb6f18ee56))
32
+
33
+
34
+
35
+ # [4.3.0](https://github.com/YanYuanFE/react-native-signature-canvas/compare/v4.2.1...v4.3.0) (2021-08-11)
36
+
37
+
38
+
39
+ ## [4.2.1](https://github.com/YanYuanFE/react-native-signature-canvas/compare/v4.2.0...v4.2.1) (2021-08-04)
40
+
41
+
42
+ ### Bug Fixes
43
+
44
+ * ts imageType ([d50d227](https://github.com/YanYuanFE/react-native-signature-canvas/commit/d50d22747278f860152ff1c8a87be6e335236724))
45
+
46
+
47
+
48
+ # [4.2.0](https://github.com/YanYuanFE/react-native-signature-canvas/compare/v4.1.0...v4.2.0) (2021-07-24)
49
+
50
+
51
+
1
52
  # [4.1.0](https://github.com/YanYuanFE/react-native-signature-canvas/compare/v4.0.0...v4.1.0) (2021-07-14)
2
53
 
3
54
 
package/CLAUDE.md ADDED
@@ -0,0 +1,88 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ This is `react-native-signature-canvas`, a React Native library for capturing signatures and drawing on a canvas. The library provides a WebView-based signature pad component with smooth drawing capabilities across iOS, Android, and Expo.
8
+
9
+ ## Core Architecture
10
+
11
+ The library uses a hybrid architecture combining React Native and web technologies:
12
+
13
+ - **Main Component** (`index.js`): The React Native component that wraps a WebView
14
+ - **WebView Content** (`h5/`): HTML, CSS, and JavaScript that runs inside the WebView
15
+ - `html.js`: HTML template with placeholder variables for configuration
16
+ - `js/signature_pad.js`: Core signature pad functionality
17
+ - `js/app.js`: Application logic for handling signature interactions
18
+ - `css/signature-pad.css`: Styling for the signature pad interface
19
+ - **TypeScript Definitions** (`index.d.ts`): Type definitions for props and ref methods
20
+
21
+ ### Key Technical Details
22
+
23
+ 1. **Communication**: React Native communicates with the WebView through:
24
+ - `injectedJavaScript`: JavaScript code injected into the WebView
25
+ - `onMessage`: Messages sent from WebView to React Native
26
+ - Template variables in HTML (e.g., `<%penColor%>`, `<%bgSrc%>`)
27
+
28
+ 2. **Signature Export**: Signatures are captured as base64 data URLs and passed back to React Native via the WebView message bridge
29
+
30
+ 3. **Customization**: The component supports extensive customization through props that modify the injected HTML/CSS/JS
31
+
32
+ ## Common Development Commands
33
+
34
+ ### Example Apps
35
+ The repository contains multiple example applications for different use cases:
36
+
37
+ ```bash
38
+ # React Native CLI app with TypeScript
39
+ cd example/signapp && npm run android
40
+ cd example/signapp && npm run ios
41
+
42
+ # Expo app with modern Expo Router
43
+ cd example/expo-app && npm start
44
+ cd example/expo-app && npm run android
45
+ cd example/expo-app && npm run ios
46
+
47
+ # Basic React Native CLI app
48
+ cd example/exampleApp && npm start
49
+ ```
50
+
51
+ ### Testing
52
+ ```bash
53
+ # Run tests in example apps
54
+ cd example/signapp && npm test
55
+ cd example/expo-app && npm test
56
+ ```
57
+
58
+ ### Linting
59
+ ```bash
60
+ # Lint example apps
61
+ cd example/signapp && npm run lint
62
+ cd example/expo-app && npm run lint
63
+ ```
64
+
65
+ ## Development Notes
66
+
67
+ ### Modifying the Core Component
68
+ - The main component logic is in `index.js`
69
+ - WebView HTML template is in `h5/html.js`
70
+ - JavaScript functionality is split between `h5/js/signature_pad.js` and `h5/js/app.js`
71
+
72
+ ### Adding New Features
73
+ 1. Add props to the main component interface
74
+ 2. Update TypeScript definitions in `index.d.ts`
75
+ 3. Modify the HTML template in `h5/html.js` if UI changes are needed
76
+ 4. Update the injected JavaScript in `h5/js/app.js` for new functionality
77
+ 5. Test across multiple example apps to ensure compatibility
78
+
79
+ ### Example App Structure
80
+ - `signapp/`: Full React Native CLI app with TypeScript and Jest testing
81
+ - `expo-app/`: Modern Expo app with Expo Router and TypeScript
82
+ - `exampleApp/`: Basic React Native CLI app
83
+ - `expo-app1/`, `signapp1/`, `sign-app/`, `ts-expo/`: Various other example configurations
84
+
85
+ ### Dependencies
86
+ - Main library only has peer dependency on `react-native-webview`
87
+ - Example apps include additional dependencies for testing and development
88
+ - No build process required for the main library (it's a pure React Native component)
package/QUICK_START.md ADDED
@@ -0,0 +1,219 @@
1
+ # Quick Start Guide
2
+
3
+ Get up and running with `react-native-signature-canvas` in minutes!
4
+
5
+ ## 🚀 Installation
6
+
7
+ ```bash
8
+ # Install the package
9
+ npm install react-native-signature-canvas
10
+
11
+ # For React Native CLI projects, also install WebView
12
+ npm install react-native-webview
13
+ cd ios && pod install # iOS only
14
+ ```
15
+
16
+ ## 📱 Basic Example
17
+
18
+ ```jsx
19
+ import React, { useRef, useState } from 'react';
20
+ import { View, Button, StyleSheet } from 'react-native';
21
+ import SignatureCanvas from 'react-native-signature-canvas';
22
+
23
+ export default function App() {
24
+ const ref = useRef();
25
+ const [signature, setSignature] = useState();
26
+
27
+ const handleOK = (signature) => {
28
+ console.log(signature);
29
+ setSignature(signature);
30
+ };
31
+
32
+ const handleClear = () => {
33
+ ref.current?.clearSignature();
34
+ };
35
+
36
+ const handleSave = () => {
37
+ ref.current?.readSignature();
38
+ };
39
+
40
+ return (
41
+ <View style={styles.container}>
42
+ <SignatureCanvas
43
+ ref={ref}
44
+ onOK={handleOK}
45
+ onEmpty={() => console.log('Empty')}
46
+ descriptionText="Sign here"
47
+ clearText="Clear"
48
+ confirmText="Save"
49
+ style={styles.signature}
50
+ />
51
+
52
+ <View style={styles.buttons}>
53
+ <Button title="Clear" onPress={handleClear} />
54
+ <Button title="Save" onPress={handleSave} />
55
+ </View>
56
+ </View>
57
+ );
58
+ }
59
+
60
+ const styles = StyleSheet.create({
61
+ container: {
62
+ flex: 1,
63
+ padding: 20,
64
+ },
65
+ signature: {
66
+ flex: 1,
67
+ borderColor: '#000033',
68
+ borderWidth: 1,
69
+ },
70
+ buttons: {
71
+ flexDirection: 'row',
72
+ justifyContent: 'space-around',
73
+ marginTop: 20,
74
+ },
75
+ });
76
+ ```
77
+
78
+ ## ⚡ Enhanced Example with New Features
79
+
80
+ ```jsx
81
+ import React, { useRef, useState } from 'react';
82
+ import { View, Button, StyleSheet, Alert } from 'react-native';
83
+ import SignatureCanvas from 'react-native-signature-canvas';
84
+
85
+ export default function EnhancedSignatureApp() {
86
+ const ref = useRef();
87
+ const [signature, setSignature] = useState();
88
+ const [isLoading, setIsLoading] = useState(false);
89
+
90
+ const handleSignature = (signature) => {
91
+ setSignature(signature);
92
+ setIsLoading(false);
93
+ Alert.alert('Success', 'Signature saved!');
94
+ };
95
+
96
+ const handleEmpty = () => {
97
+ setIsLoading(false);
98
+ Alert.alert('Empty', 'Please draw a signature first');
99
+ };
100
+
101
+ const handleError = (error) => {
102
+ setIsLoading(false);
103
+ Alert.alert('Error', error.message);
104
+ };
105
+
106
+ const handleSave = () => {
107
+ setIsLoading(true);
108
+ ref.current?.readSignature();
109
+ };
110
+
111
+ return (
112
+ <View style={styles.container}>
113
+ <SignatureCanvas
114
+ ref={ref}
115
+ onOK={handleSignature}
116
+ onEmpty={handleEmpty}
117
+ onError={handleError}
118
+ descriptionText="Sign here"
119
+ clearText="Clear"
120
+ confirmText={isLoading ? "Saving..." : "Save"}
121
+ penColor="#0066cc"
122
+ backgroundColor="rgba(255,255,255,0)"
123
+ // NEW: WebView customization
124
+ webviewProps={{
125
+ cacheEnabled: true,
126
+ androidLayerType: "hardware",
127
+ }}
128
+ style={styles.signature}
129
+ />
130
+
131
+ <View style={styles.controls}>
132
+ <Button
133
+ title="Clear"
134
+ onPress={() => ref.current?.clearSignature()}
135
+ />
136
+ <Button
137
+ title="Undo"
138
+ onPress={() => ref.current?.undo()}
139
+ />
140
+ <Button
141
+ title="Save"
142
+ onPress={handleSave}
143
+ disabled={isLoading}
144
+ />
145
+ </View>
146
+ </View>
147
+ );
148
+ }
149
+
150
+ const styles = StyleSheet.create({
151
+ container: {
152
+ flex: 1,
153
+ backgroundColor: '#f5f5f5',
154
+ padding: 20,
155
+ },
156
+ signature: {
157
+ flex: 1,
158
+ borderColor: '#ddd',
159
+ borderWidth: 1,
160
+ borderRadius: 8,
161
+ backgroundColor: 'white',
162
+ },
163
+ controls: {
164
+ flexDirection: 'row',
165
+ justifyContent: 'space-around',
166
+ marginTop: 20,
167
+ paddingVertical: 10,
168
+ },
169
+ });
170
+ ```
171
+
172
+ ## 🔧 Common Configurations
173
+
174
+ ### High Performance Setup
175
+ ```jsx
176
+ <SignatureCanvas
177
+ webviewProps={{
178
+ cacheEnabled: true,
179
+ androidLayerType: "hardware",
180
+ androidHardwareAccelerationDisabled: false,
181
+ }}
182
+ />
183
+ ```
184
+
185
+ ### Low Memory Setup
186
+ ```jsx
187
+ <SignatureCanvas
188
+ webviewProps={{
189
+ cacheEnabled: false,
190
+ androidLayerType: "software",
191
+ androidHardwareAccelerationDisabled: true,
192
+ }}
193
+ />
194
+ ```
195
+
196
+ ### Security Focused Setup
197
+ ```jsx
198
+ <SignatureCanvas
199
+ webviewProps={{
200
+ allowFileAccess: false,
201
+ allowFileAccessFromFileURLs: false,
202
+ mixedContentMode: "never",
203
+ allowsLinkPreview: false,
204
+ }}
205
+ />
206
+ ```
207
+
208
+ ## 📖 Next Steps
209
+
210
+ - [Read the full documentation](./README.md)
211
+ - [Learn about WebView customization](./WEBVIEW_PROPS.md)
212
+ - [Check out example apps](./example/)
213
+ - [View TypeScript definitions](./index.d.ts)
214
+
215
+ ## 🆘 Need Help?
216
+
217
+ - [Check troubleshooting guide](./README.md#troubleshooting)
218
+ - [View common issues](https://github.com/YanYuanFE/react-native-signature-canvas/issues)
219
+ - [Ask questions in discussions](https://github.com/YanYuanFE/react-native-signature-canvas/discussions)