react-native-empty-state 0.0.1

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/README.md ADDED
@@ -0,0 +1,349 @@
1
+ # react-native-empty-state
2
+
3
+ A lightweight, customizable, and TypeScript-friendly Empty State component for React Native applications.
4
+
5
+ Perfect for displaying:
6
+
7
+ - No Data Found
8
+ - Empty Cart
9
+ - No Search Results
10
+ - No Internet Connection
11
+ - No Notifications
12
+ - No Orders
13
+ - Custom Empty Screens
14
+
15
+ ---
16
+
17
+ ## Features
18
+
19
+ ✅ Lightweight and dependency-free
20
+
21
+ ✅ Fully customizable
22
+
23
+ ✅ TypeScript support
24
+
25
+ ✅ Optional image support
26
+
27
+ ✅ Optional action button
28
+
29
+ ✅ Custom styling support
30
+
31
+ ✅ Render custom components using children
32
+
33
+ ✅ React Native & Expo compatible
34
+
35
+ ---
36
+
37
+ ## Installation
38
+
39
+ ### npm
40
+
41
+ ```bash
42
+ npm install react-native-empty-state
43
+ ```
44
+
45
+ ### yarn
46
+
47
+ ```bash
48
+ yarn add react-native-empty-state
49
+ ```
50
+
51
+ ---
52
+
53
+ ## Peer Dependencies
54
+
55
+ Make sure your project includes:
56
+
57
+ ```json
58
+ {
59
+ "react": ">=18.0.0",
60
+ "react-native": ">=0.72.0"
61
+ }
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Basic Usage
67
+
68
+ ```tsx
69
+ import React from 'react';
70
+ import { View } from 'react-native';
71
+ import { EmptyState } from 'react-native-empty-state';
72
+
73
+ export default function App() {
74
+ return (
75
+ <View style={{ flex: 1 }}>
76
+ <EmptyState
77
+ title="No Orders"
78
+ description="You haven't placed any orders yet."
79
+ />
80
+ </View>
81
+ );
82
+ }
83
+ ```
84
+
85
+ ---
86
+
87
+ ## With Action Button
88
+
89
+ ```tsx
90
+ <EmptyState
91
+ title="No Internet Connection"
92
+ description="Please check your network and try again."
93
+ buttonText="Retry"
94
+ onPress={() => console.log('Retry')}
95
+ />
96
+ ```
97
+
98
+ ---
99
+
100
+ ## With Custom Image
101
+
102
+ ```tsx
103
+ <EmptyState
104
+ image={require('./assets/empty-cart.png')}
105
+ title="Your Cart is Empty"
106
+ description="Add products to start shopping."
107
+ />
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Complete Example
113
+
114
+ ```tsx
115
+ import React from 'react';
116
+ import { View } from 'react-native';
117
+ import { EmptyState } from 'react-native-empty-state';
118
+
119
+ export default function App() {
120
+ return (
121
+ <View style={{ flex: 1 }}>
122
+ <EmptyState
123
+ image={require('./assets/no-data.png')}
124
+ title="No Data Available"
125
+ description="There is currently nothing to display."
126
+ buttonText="Refresh"
127
+ onPress={() => console.log('Refresh')}
128
+ />
129
+ </View>
130
+ );
131
+ }
132
+ ```
133
+
134
+ ---
135
+
136
+ ## Custom Styling
137
+
138
+ All major UI elements can be customized.
139
+
140
+ ```tsx
141
+ <EmptyState
142
+ title="No Results"
143
+ description="Try changing your search filters."
144
+ buttonText="Search Again"
145
+ onPress={() => {}}
146
+ containerStyle={{
147
+ padding: 40,
148
+ }}
149
+ titleStyle={{
150
+ fontSize: 24,
151
+ color: '#111',
152
+ }}
153
+ descriptionStyle={{
154
+ color: '#666',
155
+ }}
156
+ buttonStyle={{
157
+ backgroundColor: '#28a745',
158
+ }}
159
+ buttonTextStyle={{
160
+ color: '#fff',
161
+ }}
162
+ />
163
+ ```
164
+
165
+ ---
166
+
167
+ ## Render Custom Components
168
+
169
+ Use the `children` prop to render additional content.
170
+
171
+ ```tsx
172
+ <EmptyState
173
+ title="No Products"
174
+ description="Products will appear here."
175
+ >
176
+ <CustomBanner />
177
+ </EmptyState>
178
+ ```
179
+
180
+ Example:
181
+
182
+ ```tsx
183
+ <EmptyState
184
+ title="No Notifications"
185
+ >
186
+ <Button
187
+ title="Go to Settings"
188
+ onPress={() => {}}
189
+ />
190
+ </EmptyState>
191
+ ```
192
+
193
+ ---
194
+
195
+ ## Props
196
+
197
+ | Prop | Type | Required | Default |
198
+ |--------|--------|----------|----------|
199
+ | title | string | No | No Data Found |
200
+ | description | string | No | Nothing to display. |
201
+ | image | ImageSourcePropType | No | - |
202
+ | buttonText | string | No | - |
203
+ | onPress | () => void | No | - |
204
+ | containerStyle | ViewStyle | No | - |
205
+ | titleStyle | TextStyle | No | - |
206
+ | descriptionStyle | TextStyle | No | - |
207
+ | buttonStyle | ViewStyle | No | - |
208
+ | buttonTextStyle | TextStyle | No | - |
209
+ | children | React.ReactNode | No | - |
210
+
211
+ ---
212
+
213
+ ## Conditional Rendering
214
+
215
+ The component automatically handles optional content.
216
+
217
+ ### Image
218
+
219
+ If `image` is not provided, no image will be rendered.
220
+
221
+ ```tsx
222
+ <EmptyState
223
+ title="No Data"
224
+ />
225
+ ```
226
+
227
+ ### Button
228
+
229
+ If `buttonText` is not provided, the button is hidden.
230
+
231
+ ```tsx
232
+ <EmptyState
233
+ title="No Internet"
234
+ />
235
+ ```
236
+
237
+ ---
238
+
239
+ ## TypeScript Support
240
+
241
+ The package is fully typed.
242
+
243
+ ```tsx
244
+ import {
245
+ EmptyState,
246
+ EmptyStateProps,
247
+ } from 'react-native-empty-state';
248
+ ```
249
+
250
+ ---
251
+
252
+ ## Expo Support
253
+
254
+ Works seamlessly with Expo projects.
255
+
256
+ ```bash
257
+ npx create-expo-app my-app
258
+ ```
259
+
260
+ ```bash
261
+ npm install react-native-empty-state
262
+ ```
263
+
264
+ No additional configuration required.
265
+
266
+ ---
267
+
268
+ ## Package Structure
269
+
270
+ ```text
271
+ react-native-empty-state
272
+
273
+ ├── src
274
+ │ ├── EmptyState.tsx
275
+ │ └── index.ts
276
+
277
+ ├── dist
278
+
279
+ ├── README.md
280
+ ├── package.json
281
+ └── tsconfig.json
282
+ ```
283
+
284
+ ---
285
+
286
+ ## Development
287
+
288
+ Clone the repository:
289
+
290
+ ```bash
291
+ git clone <repository-url>
292
+ ```
293
+
294
+ Install dependencies:
295
+
296
+ ```bash
297
+ npm install
298
+ ```
299
+
300
+ Build package:
301
+
302
+ ```bash
303
+ npm run build
304
+ ```
305
+
306
+ Generate npm package:
307
+
308
+ ```bash
309
+ npm pack
310
+ ```
311
+
312
+ Publish:
313
+
314
+ ```bash
315
+ npm publish --access public
316
+ ```
317
+
318
+ ---
319
+
320
+ ## Compatibility
321
+
322
+ | React Native | Status |
323
+ |-------------|---------|
324
+ | 0.72+ | ✅ Supported |
325
+ | 0.73+ | ✅ Supported |
326
+ | 0.74+ | ✅ Supported |
327
+ | Expo SDK 50+ | ✅ Supported |
328
+
329
+ ---
330
+
331
+ ## License
332
+
333
+ MIT
334
+
335
+ ---
336
+
337
+ ## Contributing
338
+
339
+ Contributions, issues, and feature requests are welcome.
340
+
341
+ Feel free to open an issue or submit a pull request.
342
+
343
+ ---
344
+
345
+ ## Author
346
+
347
+ Neeraj Singh
348
+
349
+ If you find this package useful, consider giving the repository a ⭐.
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { ImageSourcePropType, ViewStyle, TextStyle } from 'react-native';
3
+ export interface EmptyStateProps {
4
+ title?: string;
5
+ description?: string;
6
+ image?: ImageSourcePropType;
7
+ buttonText?: string;
8
+ onPress?: () => void;
9
+ containerStyle?: ViewStyle;
10
+ titleStyle?: TextStyle;
11
+ descriptionStyle?: TextStyle;
12
+ buttonStyle?: ViewStyle;
13
+ buttonTextStyle?: TextStyle;
14
+ children?: React.ReactNode;
15
+ }
16
+ declare const EmptyState: React.FC<EmptyStateProps>;
17
+ export default EmptyState;
18
+ //# sourceMappingURL=EmptyState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmptyState.d.ts","sourceRoot":"","sources":["../src/EmptyState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAMH,mBAAmB,EACnB,SAAS,EACT,SAAS,EACZ,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,eAAe;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAE5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,eAAe,CAAC,EAAE,SAAS,CAAC;IAE5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AAED,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAuDzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const react_native_1 = require("react-native");
8
+ const EmptyState = ({ title = 'No Data Found', description = 'Nothing to display.', image, buttonText, onPress, containerStyle, titleStyle, descriptionStyle, buttonStyle, buttonTextStyle, children, }) => {
9
+ return (<react_native_1.View style={[styles.container, containerStyle]}>
10
+ {image && (<react_native_1.Image source={image} style={styles.image} resizeMode="contain"/>)}
11
+
12
+ {!!title && (<react_native_1.Text style={[styles.title, titleStyle]}>
13
+ {title}
14
+ </react_native_1.Text>)}
15
+
16
+ {!!description && (<react_native_1.Text style={[styles.description, descriptionStyle]}>
17
+ {description}
18
+ </react_native_1.Text>)}
19
+
20
+ {!!buttonText && (<react_native_1.TouchableOpacity style={[styles.button, buttonStyle]} onPress={onPress} disabled={!onPress}>
21
+ <react_native_1.Text style={[
22
+ styles.buttonText,
23
+ buttonTextStyle,
24
+ ]}>
25
+ {buttonText}
26
+ </react_native_1.Text>
27
+ </react_native_1.TouchableOpacity>)}
28
+
29
+ {children}
30
+ </react_native_1.View>);
31
+ };
32
+ exports.default = EmptyState;
33
+ const styles = react_native_1.StyleSheet.create({
34
+ container: {
35
+ alignItems: 'center',
36
+ justifyContent: 'center',
37
+ padding: 24,
38
+ },
39
+ image: {
40
+ width: 180,
41
+ height: 180,
42
+ marginBottom: 20,
43
+ },
44
+ title: {
45
+ fontSize: 22,
46
+ fontWeight: '700',
47
+ marginBottom: 8,
48
+ },
49
+ description: {
50
+ fontSize: 15,
51
+ textAlign: 'center',
52
+ marginBottom: 16,
53
+ },
54
+ button: {
55
+ backgroundColor: '#007AFF',
56
+ paddingHorizontal: 20,
57
+ paddingVertical: 12,
58
+ borderRadius: 8,
59
+ },
60
+ buttonText: {
61
+ color: '#fff',
62
+ fontWeight: '600',
63
+ },
64
+ });
@@ -0,0 +1,3 @@
1
+ export { default as EmptyState } from './EmptyState';
2
+ export type { EmptyStateProps } from './EmptyState';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EmptyState = void 0;
7
+ var EmptyState_1 = require("./EmptyState");
8
+ Object.defineProperty(exports, "EmptyState", { enumerable: true, get: function () { return __importDefault(EmptyState_1).default; } });
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { ImageSourcePropType, ViewStyle, TextStyle } from 'react-native';
3
+ export interface EmptyStateProps {
4
+ title?: string;
5
+ description?: string;
6
+ image?: ImageSourcePropType;
7
+ buttonText?: string;
8
+ onPress?: () => void;
9
+ containerStyle?: ViewStyle;
10
+ titleStyle?: TextStyle;
11
+ descriptionStyle?: TextStyle;
12
+ buttonStyle?: ViewStyle;
13
+ buttonTextStyle?: TextStyle;
14
+ children?: React.ReactNode;
15
+ }
16
+ declare const EmptyState: React.FC<EmptyStateProps>;
17
+ export default EmptyState;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const react_native_1 = require("react-native");
8
+ const EmptyState = ({ title = 'No Data Found', description = 'Nothing to display.', image, buttonText, onPress, containerStyle, titleStyle, descriptionStyle, buttonStyle, buttonTextStyle, children, }) => {
9
+ return (<react_native_1.View style={[styles.container, containerStyle]}>
10
+ {image && (<react_native_1.Image source={image} style={styles.image} resizeMode="contain"/>)}
11
+
12
+ {!!title && (<react_native_1.Text style={[styles.title, titleStyle]}>
13
+ {title}
14
+ </react_native_1.Text>)}
15
+
16
+ {!!description && (<react_native_1.Text style={[styles.description, descriptionStyle]}>
17
+ {description}
18
+ </react_native_1.Text>)}
19
+
20
+ {!!buttonText && (<react_native_1.TouchableOpacity style={[styles.button, buttonStyle]} onPress={onPress} disabled={!onPress}>
21
+ <react_native_1.Text style={[
22
+ styles.buttonText,
23
+ buttonTextStyle,
24
+ ]}>
25
+ {buttonText}
26
+ </react_native_1.Text>
27
+ </react_native_1.TouchableOpacity>)}
28
+
29
+ {children}
30
+ </react_native_1.View>);
31
+ };
32
+ exports.default = EmptyState;
33
+ const styles = react_native_1.StyleSheet.create({
34
+ container: {
35
+ alignItems: 'center',
36
+ justifyContent: 'center',
37
+ padding: 24,
38
+ },
39
+ image: {
40
+ width: 180,
41
+ height: 180,
42
+ marginBottom: 20,
43
+ },
44
+ title: {
45
+ fontSize: 22,
46
+ fontWeight: '700',
47
+ marginBottom: 8,
48
+ },
49
+ description: {
50
+ fontSize: 15,
51
+ textAlign: 'center',
52
+ marginBottom: 16,
53
+ },
54
+ button: {
55
+ backgroundColor: '#007AFF',
56
+ paddingHorizontal: 20,
57
+ paddingVertical: 12,
58
+ borderRadius: 8,
59
+ },
60
+ buttonText: {
61
+ color: '#fff',
62
+ fontWeight: '600',
63
+ },
64
+ });
@@ -0,0 +1,2 @@
1
+ export { default as EmptyState } from './EmptyState';
2
+ export type { EmptyStateProps } from './EmptyState';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EmptyState = void 0;
7
+ var EmptyState_1 = require("./EmptyState");
8
+ Object.defineProperty(exports, "EmptyState", { enumerable: true, get: function () { return __importDefault(EmptyState_1).default; } });
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "react-native-empty-state",
3
+ "version": "0.0.1",
4
+ "description": "Customizable empty state component for React Native",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "prepare": "npm run build"
13
+ },
14
+ "keywords": [
15
+ "react-native",
16
+ "empty-state",
17
+ "placeholder",
18
+ "no-data",
19
+ "ui"
20
+ ],
21
+ "author": "Neeraj Singh",
22
+ "license": "MIT",
23
+ "peerDependencies": {
24
+ "react": ">=18.0.0",
25
+ "react-native": ">=0.72.0"
26
+ },
27
+ "devDependencies": {
28
+ "@types/react": "^18.2.0",
29
+ "@types/react-native": "^0.73.0",
30
+ "typescript": "^5.5.4"
31
+ }
32
+ }