@teamnhz/rn-ui-toolkit 1.4.8 → 1.5.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.
@@ -0,0 +1,29 @@
1
+ declare module "@react-native-community/datetimepicker" {
2
+ import * as React from "react";
3
+ import { StyleProp, ViewStyle } from "react-native";
4
+ type DateTimePickerEvent = {
5
+ type: "set" | "dismissed";
6
+ nativeEvent: {
7
+ timestamp?: number;
8
+ };
9
+ };
10
+ type Display = "default" | "spinner" | "clock" | "calendar";
11
+ type AndroidVariant = "nativeAndroid" | "iosClone";
12
+ interface DateTimePickerProps {
13
+ value: Date;
14
+ mode?: "date" | "time" | "datetime";
15
+ display?: Display;
16
+ onChange: (event: DateTimePickerEvent, date?: Date) => void;
17
+ minimumDate?: Date;
18
+ maximumDate?: Date;
19
+ locale?: string;
20
+ timeZoneOffsetInMinutes?: number;
21
+ minuteInterval?: number;
22
+ textColor?: string;
23
+ style?: StyleProp<ViewStyle>;
24
+ is24Hour?: boolean;
25
+ androidVariant?: AndroidVariant;
26
+ }
27
+ export default class DateTimePicker extends React.Component<DateTimePickerProps> {
28
+ }
29
+ }
@@ -1,27 +1,21 @@
1
- import React from "react";
2
- import { ImageSourcePropType, StyleProp, TextStyle, ViewStyle, ImageStyle } from "react-native";
1
+ import React from 'react';
2
+ import { StyleProp, TextStyle, ViewStyle, ImageStyle, ImageSourcePropType } from 'react-native';
3
3
  interface DateTimePickerProps {
4
4
  value: Date | null;
5
5
  onChange: (date: Date) => void;
6
6
  label?: string;
7
7
  placeholder?: string;
8
8
  intlType?: string;
9
- mode?: "date" | "time" | "datetime";
9
+ mode?: 'date' | 'time' | 'datetime';
10
10
  disabled?: boolean;
11
- /** raw DatePicker props */
12
11
  minimumDate?: Date;
13
12
  maximumDate?: Date;
14
- modal?: boolean;
15
- confirmText?: string;
16
- cancelText?: string;
17
- /** style overrides */
18
13
  containerStyle?: StyleProp<ViewStyle>;
19
14
  pickerContainerStyle?: StyleProp<ViewStyle>;
20
15
  labelStyle?: StyleProp<TextStyle>;
21
16
  textStyle?: StyleProp<TextStyle>;
22
17
  leftImageStyle?: StyleProp<ImageStyle>;
23
18
  rightImageStyle?: StyleProp<ImageStyle>;
24
- /** icons */
25
19
  leftIcon?: ImageSourcePropType;
26
20
  rightIcon?: ImageSourcePropType;
27
21
  leftIconShow?: boolean;
@@ -29,5 +23,5 @@ interface DateTimePickerProps {
29
23
  error?: string | boolean;
30
24
  errorTextStyle?: StyleProp<TextStyle>;
31
25
  }
32
- declare const DateTimePicker: React.FC<DateTimePickerProps>;
33
- export default DateTimePicker;
26
+ declare const DateTimePickerComponent: React.FC<DateTimePickerProps>;
27
+ export default DateTimePickerComponent;
@@ -1,58 +1,119 @@
1
- import React, { useState } from "react";
2
- import { View, TouchableOpacity, Text, StyleSheet, Image, } from "react-native";
3
- import DatePicker from "react-native-date-picker";
4
- import { useTranslation } from "react-i18next";
5
- import { Colors, Scale, Typography, Images } from "../../styles";
6
- const DateTimePicker = ({ value, onChange, label, placeholder, intlType, mode = "date", disabled = false, minimumDate, maximumDate, modal = true, confirmText, cancelText, containerStyle, pickerContainerStyle, labelStyle, textStyle, leftImageStyle, rightImageStyle, leftIcon, rightIcon, leftIconShow, onCancel, error, errorTextStyle, }) => {
7
- const { t } = useTranslation(["common", "validation", "address", "sell"]);
8
- const [open, setOpen] = useState(false);
9
- /** default icons based on mode */
10
- const defaultLeftIcon = mode === "time"
11
- ? Images.ic_time // ⏰ your clock asset
12
- : Images.ic_calendar; // 📅 your calendar asset
1
+ import React, { useEffect, useState } from 'react';
2
+ import { View, TouchableOpacity, Text, StyleSheet, Image, Platform, Modal, } from 'react-native';
3
+ import DateTimePicker from '@react-native-community/datetimepicker';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { Colors, Scale, Typography, Images } from '../../styles';
6
+ const DateTimePickerComponent = ({ value, onChange, label, placeholder, intlType, mode = 'date', disabled = false, minimumDate, maximumDate, containerStyle, pickerContainerStyle, labelStyle, textStyle, leftImageStyle, rightImageStyle, leftIcon, rightIcon, leftIconShow = true, onCancel, error, errorTextStyle, }) => {
7
+ const { t } = useTranslation(['common', 'validation', 'address', 'sell']);
8
+ const [show, setShow] = useState(false);
9
+ const [step, setStep] = useState('date');
10
+ const [tempDate, setTempDate] = useState(value || new Date());
11
+ useEffect(() => {
12
+ if (value) {
13
+ setTempDate(value);
14
+ }
15
+ }, [value]);
16
+ const defaultLeftIcon = mode === 'time' ? Images.ic_time : Images.ic_calendar;
13
17
  const getTranslatedLabel = () => {
14
- if (intlType) {
18
+ if (intlType && label) {
15
19
  const translated = t(label, { ns: intlType });
16
20
  if (translated !== label)
17
21
  return translated;
18
22
  }
19
23
  return label;
20
24
  };
25
+ const onChangeHandler = (event, selectedDate) => {
26
+ if (event.type === 'dismissed') {
27
+ setShow(false);
28
+ onCancel?.();
29
+ return;
30
+ }
31
+ if (mode === 'datetime') {
32
+ if (step === 'date') {
33
+ if (selectedDate) {
34
+ setTempDate(selectedDate);
35
+ if (Platform.OS === 'android') {
36
+ // open time picker after date
37
+ setStep('time');
38
+ }
39
+ }
40
+ if (Platform.OS === 'ios') {
41
+ // iOS can combine date+time with spinner, so just update temp
42
+ if (selectedDate)
43
+ setTempDate(selectedDate);
44
+ }
45
+ }
46
+ else {
47
+ if (selectedDate) {
48
+ const finalDate = mergeDateAndTime(tempDate, selectedDate);
49
+ onChange(finalDate);
50
+ }
51
+ setShow(false);
52
+ setStep('date');
53
+ }
54
+ }
55
+ else {
56
+ if (selectedDate) {
57
+ if (Platform.OS === 'ios') {
58
+ setTempDate(selectedDate);
59
+ }
60
+ else {
61
+ onChange(selectedDate);
62
+ }
63
+ }
64
+ setShow(Platform.OS === 'ios');
65
+ }
66
+ };
67
+ const mergeDateAndTime = (datePart, timePart) => {
68
+ const final = new Date(datePart);
69
+ final.setHours(timePart.getHours());
70
+ final.setMinutes(timePart.getMinutes());
71
+ final.setSeconds(timePart.getSeconds());
72
+ return final;
73
+ };
74
+ const handlePress = () => {
75
+ if (!disabled)
76
+ setShow(true);
77
+ };
21
78
  return (React.createElement(View, { style: containerStyle },
22
- label ? (React.createElement(Text, { style: [styles.label, labelStyle] }, getTranslatedLabel())) : null,
79
+ label && (React.createElement(Text, { style: [styles.label, labelStyle] }, getTranslatedLabel())),
23
80
  React.createElement(TouchableOpacity, { style: [
24
81
  styles.button,
25
82
  pickerContainerStyle,
26
83
  disabled && { backgroundColor: Colors.disabledGrey, borderWidth: 0 },
27
- ], disabled: disabled, onPress: () => setOpen(true) },
28
- leftIconShow && (React.createElement(Image, { source: leftIcon || defaultLeftIcon, style: [styles.icon, leftImageStyle] })),
29
- React.createElement(Text, { style: [styles.text, textStyle, !value && { color: Colors.textGrey }], numberOfLines: 1 }, value ? formatValue(value, mode) : placeholder || "Select"),
30
- rightIcon && (React.createElement(Image, { source: rightIcon, style: [styles.icon, rightImageStyle] }))),
31
- typeof error === "string" && error.length > 0 && (React.createElement(Text, { style: [styles.errorText, errorTextStyle] }, error)),
32
- React.createElement(DatePicker, { modal: modal, open: open, date: value || new Date(), mode: mode, minimumDate: minimumDate, maximumDate: maximumDate, confirmText: confirmText, cancelText: cancelText, onConfirm: (val) => {
33
- setOpen(false);
34
- onChange(val);
35
- }, onCancel: () => {
36
- setOpen(false);
37
- onCancel && onCancel();
38
- } })));
84
+ ], disabled: disabled, onPress: handlePress },
85
+ leftIconShow && (React.createElement(Image, { source: leftIcon || defaultLeftIcon, style: [styles.icon, styles.leftIcon, leftImageStyle] })),
86
+ React.createElement(Text, { style: [styles.text, textStyle, !value && { color: Colors.textGrey }], numberOfLines: 1 }, value ? formatValue(value, mode) : placeholder || 'Select'),
87
+ rightIcon && (React.createElement(Image, { source: rightIcon, style: [styles.icon, styles.rightIcon, rightImageStyle] }))),
88
+ typeof error === 'string' && error.length > 0 && (React.createElement(Text, { style: [styles.errorText, errorTextStyle] }, error)),
89
+ show && Platform.OS === 'android' && (React.createElement(DateTimePicker, { value: value || new Date(), mode: mode === 'datetime' ? step : mode, minimumDate: minimumDate, maximumDate: maximumDate, onChange: onChangeHandler })),
90
+ Platform.OS === 'ios' && (React.createElement(Modal, { transparent: true, animationType: "slide", visible: show, onRequestClose: () => setShow(false) },
91
+ React.createElement(View, { style: styles.overlay },
92
+ React.createElement(View, { style: styles.container },
93
+ React.createElement(TouchableOpacity, { style: styles.doneBtn, onPress: () => {
94
+ setShow(false);
95
+ if (tempDate)
96
+ onChange(tempDate);
97
+ } },
98
+ React.createElement(Text, { style: styles.doneText }, "Done")),
99
+ React.createElement(DateTimePicker, { value: tempDate, mode: mode, minimumDate: minimumDate, maximumDate: maximumDate, display: "spinner", onChange: (e, d) => d && setTempDate(d) })))))));
39
100
  };
40
101
  const formatValue = (date, mode) => {
41
102
  try {
42
103
  switch (mode) {
43
- case "time":
104
+ case 'time':
44
105
  return date.toLocaleTimeString([], {
45
- hour: "2-digit",
46
- minute: "2-digit",
106
+ hour: '2-digit',
107
+ minute: '2-digit',
47
108
  });
48
- case "datetime":
109
+ case 'datetime':
49
110
  return date.toLocaleString();
50
111
  default:
51
112
  return date.toLocaleDateString();
52
113
  }
53
114
  }
54
115
  catch {
55
- return "";
116
+ return '';
56
117
  }
57
118
  };
58
119
  const styles = StyleSheet.create({
@@ -63,214 +124,52 @@ const styles = StyleSheet.create({
63
124
  },
64
125
  button: {
65
126
  borderWidth: 1,
66
- borderColor: Colors.primaryColor,
127
+ borderColor: Colors.black,
67
128
  borderRadius: Scale.moderateScale(6),
68
129
  paddingVertical: Scale.moderateScale(12),
69
130
  paddingHorizontal: Scale.moderateScale(10),
70
- flexDirection: "row",
71
- alignItems: "center",
131
+ flexDirection: 'row',
132
+ alignItems: 'center',
72
133
  },
73
134
  text: {
74
135
  flex: 1,
75
136
  ...Typography.style.standardU(),
76
137
  color: Colors.textColor,
77
- textTransform: "none",
138
+ textTransform: 'none',
78
139
  },
79
140
  icon: {
80
141
  width: Scale.moderateScale(20),
81
142
  height: Scale.moderateScale(20),
82
- resizeMode: "contain",
143
+ resizeMode: 'contain',
144
+ },
145
+ leftIcon: {
146
+ marginRight: Scale.moderateScale(8),
147
+ },
148
+ rightIcon: {
149
+ marginLeft: Scale.moderateScale(8),
83
150
  },
84
151
  errorText: {
85
152
  color: Colors.dangerRed,
86
153
  fontSize: Scale.moderateScale(12),
87
154
  marginTop: 3,
88
155
  },
156
+ overlay: {
157
+ flex: 1,
158
+ justifyContent: 'flex-end',
159
+ backgroundColor: 'rgba(0,0,0,0.3)',
160
+ },
161
+ container: {
162
+ backgroundColor: Colors.white,
163
+ paddingBottom: 20,
164
+ },
165
+ doneBtn: {
166
+ alignSelf: 'flex-end',
167
+ padding: 12,
168
+ },
169
+ doneText: {
170
+ color: Colors.primaryColor,
171
+ fontSize: 16,
172
+ fontWeight: '600',
173
+ },
89
174
  });
90
- export default DateTimePicker;
91
- // import React, { useState } from 'react';
92
- // import {
93
- // View,
94
- // TouchableOpacity,
95
- // Text,
96
- // StyleSheet,
97
- // Image,
98
- // ImageSourcePropType,
99
- // StyleProp,
100
- // TextStyle,
101
- // ViewStyle,
102
- // ImageStyle,
103
- // } from 'react-native';
104
- // import DatePicker from 'react-native-date-picker';
105
- // import { useTranslation } from 'react-i18next';
106
- // import { Colors, Scale, Typography, Images } from '../../styles';
107
- // interface DateTimePickerProps {
108
- // value: Date | null;
109
- // onChange: (date: Date) => void;
110
- // label?: string;
111
- // placeholder?: string;
112
- // intlType?: string;
113
- // mode?: 'date' | 'time' | 'datetime';
114
- // disabled?: boolean;
115
- // /** raw DatePicker props */
116
- // minimumDate?: Date;
117
- // maximumDate?: Date;
118
- // modal?: boolean;
119
- // confirmText?: string;
120
- // cancelText?: string;
121
- // /** style overrides */
122
- // containerStyle?: StyleProp<ViewStyle>;
123
- // pickerContainerStyle?: StyleProp<ViewStyle>;
124
- // labelStyle?: StyleProp<TextStyle>;
125
- // textStyle?: StyleProp<TextStyle>;
126
- // leftImageStyle?: StyleProp<ImageStyle>;
127
- // rightImageStyle?: StyleProp<ImageStyle>;
128
- // /** icons */
129
- // leftIcon?: ImageSourcePropType;
130
- // rightIcon?: ImageSourcePropType;
131
- // leftIconShow?: boolean;
132
- // onCancel?: () => void;
133
- // }
134
- // const DateTimePicker: React.FC<DateTimePickerProps> = ({
135
- // value,
136
- // onChange,
137
- // label,
138
- // placeholder,
139
- // intlType,
140
- // mode = 'date',
141
- // disabled = false,
142
- // minimumDate,
143
- // maximumDate,
144
- // modal = true,
145
- // confirmText,
146
- // cancelText,
147
- // containerStyle,
148
- // pickerContainerStyle,
149
- // labelStyle,
150
- // textStyle,
151
- // leftImageStyle,
152
- // rightImageStyle,
153
- // leftIcon,
154
- // rightIcon,
155
- // leftIconShow,
156
- // onCancel,
157
- // }) => {
158
- // const { t } = useTranslation(['common', 'validation', 'address', 'sell']);
159
- // const [open, setOpen] = useState(false);
160
- // /** default icons based on mode */
161
- // const defaultLeftIcon =
162
- // mode === 'time'
163
- // ? Images.ic_time // ⏰ your clock asset
164
- // : Images.ic_calendar; // 📅 your calendar asset
165
- // const getTranslatedLabel = () => {
166
- // if (intlType) {
167
- // const translated = t(label, { ns: intlType });
168
- // if (translated !== label) return translated;
169
- // }
170
- // return label;
171
- // };
172
- // return (
173
- // <View style={[styles.container, containerStyle]}>
174
- // {/* Top label */}
175
- // {label ? (
176
- // <Text style={[styles.label, labelStyle]}>{getTranslatedLabel()}</Text>
177
- // ) : null}
178
- // <TouchableOpacity
179
- // style={[
180
- // styles.button,
181
- // pickerContainerStyle,
182
- // disabled && { backgroundColor: Colors.disabledGrey, borderWidth: 0 },
183
- // ]}
184
- // disabled={disabled}
185
- // onPress={() => setOpen(true)}
186
- // >
187
- // {/* Left icon */}
188
- // {leftIconShow &&
189
- // <Image
190
- // source={leftIcon || defaultLeftIcon}
191
- // style={[styles.icon, leftImageStyle]}
192
- // />}
193
- // {/* Text / Placeholder */}
194
- // <Text
195
- // style={[
196
- // styles.text,
197
- // textStyle,
198
- // !value && { color: Colors.textGrey },
199
- // ]}
200
- // numberOfLines={1}
201
- // >
202
- // {value ? formatValue(value, mode) : placeholder || 'Select'}
203
- // </Text>
204
- // {/* Right icon (mandatory) */}
205
- // {rightIcon &&
206
- // <Image
207
- // source={rightIcon}
208
- // style={[styles.icon, rightImageStyle]}
209
- // />}
210
- // </TouchableOpacity>
211
- // <DatePicker
212
- // modal={modal}
213
- // open={open}
214
- // date={value || new Date()}
215
- // mode={mode}
216
- // minimumDate={minimumDate}
217
- // maximumDate={maximumDate}
218
- // confirmText={confirmText}
219
- // cancelText={cancelText}
220
- // onConfirm={(val) => {
221
- // setOpen(false);
222
- // onChange(val);
223
- // }}
224
- // onCancel={() => {
225
- // setOpen(false);
226
- // onCancel && onCancel();
227
- // }}
228
- // />
229
- // </View>
230
- // );
231
- // };
232
- // const formatValue = (date: Date, mode: 'date' | 'time' | 'datetime') => {
233
- // try {
234
- // switch (mode) {
235
- // case 'time':
236
- // return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
237
- // case 'datetime':
238
- // return date.toLocaleString();
239
- // default:
240
- // return date.toLocaleDateString();
241
- // }
242
- // } catch {
243
- // return '';
244
- // }
245
- // };
246
- // const styles = StyleSheet.create({
247
- // container: {
248
- // marginVertical: Scale.moderateScale(8),
249
- // },
250
- // label: {
251
- // ...Typography.style.standardU(),
252
- // color: Colors.textColor,
253
- // marginBottom: Scale.moderateScale(8),
254
- // },
255
- // button: {
256
- // borderWidth: 1,
257
- // borderColor: Colors.primaryColor,
258
- // borderRadius: Scale.moderateScale(6),
259
- // paddingVertical: Scale.moderateScale(12),
260
- // paddingHorizontal: Scale.moderateScale(10),
261
- // flexDirection: 'row',
262
- // alignItems: 'center',
263
- // },
264
- // text: {
265
- // flex: 1,
266
- // ...Typography.style.standardU(),
267
- // color: Colors.textColor,
268
- // textTransform: "none",
269
- // },
270
- // icon: {
271
- // width: Scale.moderateScale(20),
272
- // height: Scale.moderateScale(20),
273
- // resizeMode: 'contain',
274
- // },
275
- // });
276
- // export default DateTimePicker;
175
+ export default DateTimePickerComponent;
@@ -1,22 +1,3 @@
1
- // import { setColorConfig } from "./colors";
2
- // import { setTypographyConfig } from "./typography";
3
- // export type AppConfig = {
4
- // colors?: Record<string, string>;
5
- // fonts?: any;
6
- // sizes?: any;
7
- // lang?: any;
8
- // scaleFn?: any;
9
- // };
10
- // export function setAppConfig(config: AppConfig) {
11
- // if (config.colors) setColorConfig(config.colors);
12
- // setTypographyConfig({
13
- // fonts: config.fonts,
14
- // sizes: config.sizes,
15
- // lang: config.lang,
16
- // scaleFn: config.scaleFn,
17
- // });
18
- // }
19
- // appConfig.js
20
1
  let appLanguage = "en"; // en | hi
21
2
  let customFonts = {
22
3
  en: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnhz/rn-ui-toolkit",
3
- "version": "1.4.8",
3
+ "version": "1.5.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -17,13 +17,16 @@
17
17
  "react": ">=19.0.0",
18
18
  "react-i18next": "^15.7.2",
19
19
  "react-native": ">=0.77.2",
20
- "react-native-date-picker": "^5.0.13",
20
+ "react-native-compressor": "^1.13.0",
21
21
  "react-native-element-dropdown": "^2.12.4",
22
22
  "react-native-elements": "^3.4.3",
23
+ "react-native-fs": "^2.20.0",
23
24
  "react-native-gesture-handler": "^2.26.0",
24
25
  "react-native-image-crop-picker": "^0.51.1",
25
26
  "react-native-image-picker": "^8.2.0",
27
+ "react-native-image-resizer": "^1.4.5",
26
28
  "react-native-keyboard-aware-scroll-view": "^0.9.5",
29
+ "react-native-linear-gradient": "^2.8.3",
27
30
  "react-native-modal": "^14.0.0-rc.1",
28
31
  "react-native-permissions": "^4.1.5",
29
32
  "react-native-reanimated": "^3.17.5",
@@ -31,10 +34,7 @@
31
34
  "react-native-svg": "^15.12.1",
32
35
  "react-native-vector-icons": "^10.3.0",
33
36
  "react-native-video-trim": "^3.0.9",
34
- "react-native-compressor": "^1.13.0",
35
- "react-native-fs": "^2.20.0",
36
- "react-native-linear-gradient": "^2.8.3",
37
- "react-native-image-resizer":"^1.4.5"
37
+ "@react-native-community/datetimepicker": "^8.5.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@react-native-documents/picker": "^10.1.5",