@jescon-technologies/react-native-ui-kit 0.0.1 → 0.0.2
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/index.js +70 -0
- package/package.json +26 -3
- package/src/Alerts/AAlert.js +1 -1
- package/src/HOC/ConfirmOverlay.js +192 -0
- package/src/HOC/HAbsolute.js +56 -0
- package/src/HOC/HDiscontinue.js +105 -0
- package/src/HOC/HHeading.js +70 -0
- package/src/HOC/HMoreButton.js +88 -0
- package/src/HOC/HNatureHeading.js +402 -0
- package/src/HOC/HOCIcons.js +80 -0
- package/src/HOC/HOverlay.js +99 -0
- package/src/HOC/HOverlayCentered.js +140 -0
- package/src/HOC/HShadowButton.js +45 -0
- package/src/HOC/HShadowCountButton.js +82 -0
- package/src/HOC/OptionOverlay.js +48 -0
- package/src/Media/AudioScreen.js +347 -0
- package/src/Media/BarcodeScan.js +145 -0
- package/src/Media/CAudioPlay.js +228 -0
- package/src/Media/CCaptureImageWithoutEdit.js +330 -0
- package/src/Media/CImageGallery.js +289 -0
- package/src/Media/CImageZoom.js +82 -0
- package/src/Media/CSingleImage.js +391 -0
- package/src/Media/CSketchCanvas.js +76 -0
- package/src/Media/CVideoPlay.js +31 -0
- package/src/Media/DocumentScreen.js +367 -0
- package/src/Media/DrawingScreen.js +582 -0
- package/src/Media/ImageScreen.js +313 -0
- package/src/Media/RecordAudio.js +250 -0
- package/src/Media/RecordVideo.js +223 -0
- package/src/Media/VideoScreen.js +383 -0
- package/src/StaticComponents/SAlphabet.js +47 -0
- package/src/StaticComponents/SCheckBox.js +42 -0
- package/src/StaticComponents/SDatePicker.js +208 -0
- package/src/StaticComponents/SDatePickerLabel.js +253 -0
- package/src/StaticComponents/SDatePickerNew.js +258 -0
- package/src/StaticComponents/SDateTimePickerNew.js +381 -0
- package/src/StaticComponents/SDropDownGenerate.js +450 -0
- package/src/StaticComponents/SDropDownHoc.js +636 -0
- package/src/StaticComponents/SDropDownIcon.js +500 -0
- package/src/StaticComponents/SMenuBox.js +131 -0
- package/src/StaticComponents/SOverlay.js +177 -0
- package/src/StaticComponents/SOverlayTextInput.js +109 -0
- package/src/StaticComponents/SSearch.js +438 -0
- package/src/StaticComponents/SSearchBar.js +53 -0
- package/src/StaticComponents/SSpeedDial.js +303 -0
- package/src/StaticComponents/STextInput.js +289 -0
- package/src/StaticComponents/STextInputProps.js +36 -0
- package/src/StaticComponents/STimePicker.js +171 -0
- package/src/StaticComponents/STimingDropDownNew.js +1589 -0
- package/src/StaticComponents/STimingSwitch.js +34 -0
- package/src/layout/CContainerView.js +21 -0
- package/src/layout/CDetailView.js +81 -0
- package/src/layout/FooterBlock.js +0 -3
- package/src/layout/HeaderBlock.js +353 -0
- package/src/index.js +0 -15
- package/src/screens/ForgotPassword.js +0 -346
- package/src/screens/Login.js +0 -328
- package/src/screens/Splash.js +0 -788
- /package/src/{components → layout}/Loader.js +0 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
|
+
import { View, TouchableOpacity, Platform, Dimensions, Text } from 'react-native';
|
|
3
|
+
import DateTimePicker from '@react-native-community/datetimepicker';
|
|
4
|
+
import CText from '../CustomComponents/CText';
|
|
5
|
+
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
|
|
6
|
+
import { normalize } from '../CommonStyle/componentStyle';
|
|
7
|
+
import moment from 'moment';
|
|
8
|
+
import { Global } from '../Common/Global';
|
|
9
|
+
import { isNU, ValueCheck } from '../CommonStyle/ComponentFunctions';
|
|
10
|
+
import HOCIcons from '../HOC/HOCIcons';
|
|
11
|
+
|
|
12
|
+
export default function SDatePickerNew(props) {
|
|
13
|
+
const [data, setData] = useState(props.data != undefined ? props.data : {});
|
|
14
|
+
const [date, setDate] = useState(props.passingDate != undefined ? new Date(props.passingDate) : new Date());
|
|
15
|
+
const [minimumdate, setMinimumDate] = useState(isNU(props.minimumdate) ? new Date(props.minimumdate) : new Date());
|
|
16
|
+
const [mode, setMode] = useState('date');
|
|
17
|
+
const [show, setShow] = useState(false);
|
|
18
|
+
|
|
19
|
+
const webInputRef = useRef(null);
|
|
20
|
+
|
|
21
|
+
// Handle date change for native platforms
|
|
22
|
+
const onNativeChange = (event, selectedDate) => {
|
|
23
|
+
setShow(Platform.OS === 'ios');
|
|
24
|
+
|
|
25
|
+
if (event && event.type == 'set') {
|
|
26
|
+
const currentDate = selectedDate || date;
|
|
27
|
+
setDate(currentDate);
|
|
28
|
+
setData({ ...data, ['value']: currentDate });
|
|
29
|
+
|
|
30
|
+
if (props.onChangeData) {
|
|
31
|
+
props.onChangeData(currentDate);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
console.log('onChangeData', currentDate);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Handle date change for web platform
|
|
39
|
+
const onWebChange = (e) => {
|
|
40
|
+
const value = e.target.value;
|
|
41
|
+
if (!value) {return;}
|
|
42
|
+
|
|
43
|
+
const selectedDate = new Date(value + 'T00:00:00');
|
|
44
|
+
if (isNaN(selectedDate.getTime())) {return;}
|
|
45
|
+
|
|
46
|
+
setDate(selectedDate);
|
|
47
|
+
setData({ ...data, ['value']: selectedDate });
|
|
48
|
+
|
|
49
|
+
if (props.onChangeData) {
|
|
50
|
+
props.onChangeData(selectedDate);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log('onChangeData web', selectedDate);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Get minimum date for web input
|
|
57
|
+
const getWebMinDate = () => {
|
|
58
|
+
if (!isNU(props.minimumdate) && minimumdate instanceof Date) {
|
|
59
|
+
return minimumdate.toISOString().split('T')[0];
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// Get web input value in YYYY-MM-DD format
|
|
65
|
+
const getWebInputValue = () => {
|
|
66
|
+
if (!(date instanceof Date) || isNaN(date.getTime())) {return '';}
|
|
67
|
+
return date.toISOString().split('T')[0];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const showMode = (currentMode) => {
|
|
71
|
+
setShow(true);
|
|
72
|
+
setMode(currentMode);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const showDatepicker = () => {
|
|
76
|
+
showMode('date');
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Focus web input when icon is clicked
|
|
80
|
+
const handleWebIconClick = () => {
|
|
81
|
+
if (webInputRef.current && !props.disabled) {
|
|
82
|
+
webInputRef.current.focus();
|
|
83
|
+
webInputRef.current.showPicker?.(); // This works in modern browsers
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// Web-specific render
|
|
88
|
+
if (Platform.OS === 'web') {
|
|
89
|
+
return (
|
|
90
|
+
<View style={{
|
|
91
|
+
width: data.itemwidth != undefined ? data.itemwidth : Dimensions.get('screen').width * 0.5,
|
|
92
|
+
borderWidth: 0,
|
|
93
|
+
}}>
|
|
94
|
+
{props.disableplaceholder && isNU(props.table) ?
|
|
95
|
+
<Text
|
|
96
|
+
style={{
|
|
97
|
+
borderWidth: 0,
|
|
98
|
+
fontSize: normalize(9),
|
|
99
|
+
color: 'black',
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
{data.displaytext != undefined ? data.displaytext : 'Date'}
|
|
103
|
+
</Text>
|
|
104
|
+
: null}
|
|
105
|
+
|
|
106
|
+
<View style={props.pickerstyle ?
|
|
107
|
+
props.pickerstyle :
|
|
108
|
+
{
|
|
109
|
+
flexDirection: 'row',
|
|
110
|
+
backgroundColor: '#fff',
|
|
111
|
+
width: ValueCheck(props.width) ? props.width : null,
|
|
112
|
+
borderColor: 'lightgrey',
|
|
113
|
+
borderWidth: props.table != undefined && props.table != true ? 1 : 0,
|
|
114
|
+
borderRadius: 5,
|
|
115
|
+
alignItems: 'center',
|
|
116
|
+
height: normalize(30),
|
|
117
|
+
elevation: props.table != undefined && props.table != true ? 3 : 0,
|
|
118
|
+
justifyContent: props.table != undefined && props.table != true ? 'flex-start' : 'flex-start',
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
{props.icon ?
|
|
122
|
+
<div
|
|
123
|
+
onClick={handleWebIconClick}
|
|
124
|
+
style={{ cursor: props.disabled ? 'not-allowed' : 'pointer' }}
|
|
125
|
+
>
|
|
126
|
+
<HOCIcons.Icons
|
|
127
|
+
icongroup={isNU(props.icon.icongroup) ? props.icon.icongroup : 5}
|
|
128
|
+
name={props.icon.name}
|
|
129
|
+
size={props.icon.size}
|
|
130
|
+
style={props.iconstyle}
|
|
131
|
+
/>
|
|
132
|
+
</div>
|
|
133
|
+
:
|
|
134
|
+
<div
|
|
135
|
+
onClick={handleWebIconClick}
|
|
136
|
+
style={{ cursor: props.disabled ? 'not-allowed' : 'pointer' }}
|
|
137
|
+
>
|
|
138
|
+
<FontAwesome5
|
|
139
|
+
name={'calendar-alt'}
|
|
140
|
+
size={normalize(15)}
|
|
141
|
+
color={Global.AppTheme.primary_color}
|
|
142
|
+
style={{ width: normalize(25) }}
|
|
143
|
+
/>
|
|
144
|
+
</div>
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
{/* Hidden HTML date input */}
|
|
148
|
+
<input
|
|
149
|
+
ref={webInputRef}
|
|
150
|
+
type="date"
|
|
151
|
+
value={getWebInputValue()}
|
|
152
|
+
onChange={onWebChange}
|
|
153
|
+
// min={getWebMinDate()}
|
|
154
|
+
disabled={props.disabled}
|
|
155
|
+
style={{
|
|
156
|
+
flex: 1,
|
|
157
|
+
height: '100%',
|
|
158
|
+
border: 'none',
|
|
159
|
+
backgroundColor: 'transparent',
|
|
160
|
+
fontSize: normalize(14),
|
|
161
|
+
color: 'black',
|
|
162
|
+
fontWeight: 'bold',
|
|
163
|
+
outline: 'none',
|
|
164
|
+
paddingLeft: normalize(5),
|
|
165
|
+
opacity: 0,
|
|
166
|
+
position: 'absolute',
|
|
167
|
+
width: '100%',
|
|
168
|
+
left: normalize(25),
|
|
169
|
+
cursor: props.disabled ? 'not-allowed' : 'pointer',
|
|
170
|
+
}}
|
|
171
|
+
/>
|
|
172
|
+
|
|
173
|
+
{/* Display text that shows the formatted date */}
|
|
174
|
+
<Text style={props.textstyle ? props.textstyle : {
|
|
175
|
+
fontSize: normalize(14),
|
|
176
|
+
color: 'black',
|
|
177
|
+
fontWeight: 'bold',
|
|
178
|
+
marginLeft: normalize(5),
|
|
179
|
+
pointerEvents: 'none',
|
|
180
|
+
userSelect: 'none',
|
|
181
|
+
}}>
|
|
182
|
+
{moment(date).format('DD-MM-YYYY')}
|
|
183
|
+
</Text>
|
|
184
|
+
</View>
|
|
185
|
+
</View>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Native platforms (iOS/Android) render
|
|
190
|
+
return (
|
|
191
|
+
<View style={{
|
|
192
|
+
width: data.itemwidth != undefined ? data.itemwidth : Dimensions.get('screen').width * 0.5,
|
|
193
|
+
borderWidth: 0,
|
|
194
|
+
}}>
|
|
195
|
+
{props.disableplaceholder && isNU(props.table) ?
|
|
196
|
+
<Text
|
|
197
|
+
style={{
|
|
198
|
+
borderWidth: 0,
|
|
199
|
+
fontSize: normalize(9),
|
|
200
|
+
color: 'black',
|
|
201
|
+
}}
|
|
202
|
+
>
|
|
203
|
+
{data.displaytext != undefined ? data.displaytext : 'Date'}
|
|
204
|
+
</Text>
|
|
205
|
+
: null}
|
|
206
|
+
|
|
207
|
+
<TouchableOpacity
|
|
208
|
+
disabled={props.disabled ? true : false}
|
|
209
|
+
onPress={() => showDatepicker()}
|
|
210
|
+
style={props.pickerstyle ?
|
|
211
|
+
props.pickerstyle :
|
|
212
|
+
{
|
|
213
|
+
flexDirection: 'row',
|
|
214
|
+
backgroundColor: '#fff',
|
|
215
|
+
width: ValueCheck(props.width) ? props.width : null,
|
|
216
|
+
borderColor: 'lightgrey',
|
|
217
|
+
borderWidth: props.table != undefined && props.table != true ? 1 : 0,
|
|
218
|
+
borderRadius: 5,
|
|
219
|
+
alignItems: 'center',
|
|
220
|
+
height: normalize(30),
|
|
221
|
+
elevation: props.table != undefined && props.table != true ? 3 : 0,
|
|
222
|
+
justifyContent: props.table != undefined && props.table != true ? 'flex-start' : 'flex-start',
|
|
223
|
+
}}
|
|
224
|
+
>
|
|
225
|
+
{props.icon ?
|
|
226
|
+
<HOCIcons.Icons
|
|
227
|
+
icongroup={isNU(props.icon.icongroup) ? props.icon.icongroup : 5}
|
|
228
|
+
name={props.icon.name}
|
|
229
|
+
size={props.icon.size}
|
|
230
|
+
style={props.iconstyle}
|
|
231
|
+
/>
|
|
232
|
+
:
|
|
233
|
+
<FontAwesome5
|
|
234
|
+
name={'calendar-alt'}
|
|
235
|
+
size={normalize(15)}
|
|
236
|
+
color={Global.AppTheme.primary_color}
|
|
237
|
+
style={{ width: normalize(25) }}
|
|
238
|
+
/>
|
|
239
|
+
}
|
|
240
|
+
<Text style={props.textstyle ? props.textstyle : { fontSize: normalize(14), color: 'black', fontWeight: 'bold' }}>
|
|
241
|
+
{moment(date).format('DD-MM-YYYY')}
|
|
242
|
+
</Text>
|
|
243
|
+
</TouchableOpacity>
|
|
244
|
+
|
|
245
|
+
{show && (
|
|
246
|
+
<DateTimePicker
|
|
247
|
+
minimumDate={isNU(props.minimumdate) ? minimumdate : null}
|
|
248
|
+
testID={'dateTimePicker'}
|
|
249
|
+
value={date}
|
|
250
|
+
mode={'date'}
|
|
251
|
+
is24Hour={true}
|
|
252
|
+
display="default"
|
|
253
|
+
onChange={onNativeChange}
|
|
254
|
+
/>
|
|
255
|
+
)}
|
|
256
|
+
</View>
|
|
257
|
+
);
|
|
258
|
+
}
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
+
import { View, Text, Button, Platform, TouchableOpacity } from 'react-native';
|
|
3
|
+
import DateTimePicker from '@react-native-community/datetimepicker';
|
|
4
|
+
import HOCIcons from '../HOC/HOCIcons';
|
|
5
|
+
import moment from 'moment';
|
|
6
|
+
import { normalize } from '../CommonStyle/componentStyle';
|
|
7
|
+
import { isNU, ValueCheck } from '../CommonStyle/ComponentFunctions';
|
|
8
|
+
import { MaterialCommunityIcons } from '../Common/Icons';
|
|
9
|
+
import { Global } from '../Common/Global';
|
|
10
|
+
|
|
11
|
+
const SDateTimePickerNew = props => {
|
|
12
|
+
// State management
|
|
13
|
+
const [dateTime, setDateTime] = useState(props.passingDate ? new Date(props.passingDate) : new Date());
|
|
14
|
+
const [timeZone, setTimeZone] = useState(formatTime12Hour(new Date()));
|
|
15
|
+
const [mode, setMode] = useState('date');
|
|
16
|
+
const [showPicker, setShowPicker] = useState(false);
|
|
17
|
+
const [data, setData] = useState(props.data ?? {});
|
|
18
|
+
|
|
19
|
+
// Minimum and maximum date constraints
|
|
20
|
+
const [minimumdate] = useState(isNU(props.minimumdate) ? new Date(props.minimumdate) : null);
|
|
21
|
+
const [maximumdate] = useState(isNU(props.maximumdate) ? new Date(props.maximumdate) : null);
|
|
22
|
+
|
|
23
|
+
const inputRef = useRef(null);
|
|
24
|
+
|
|
25
|
+
// Format time in 12-hour format
|
|
26
|
+
function formatTime12Hour(date) {
|
|
27
|
+
return date.toLocaleTimeString('en-US', {
|
|
28
|
+
hour: '2-digit',
|
|
29
|
+
minute: '2-digit',
|
|
30
|
+
hour12: true,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Format date for display
|
|
35
|
+
const formatDate = date => {
|
|
36
|
+
return date.toLocaleDateString('en-US', {
|
|
37
|
+
weekday: 'short',
|
|
38
|
+
year: 'numeric',
|
|
39
|
+
month: 'short',
|
|
40
|
+
day: 'numeric',
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Handle date/time change for native platforms
|
|
45
|
+
const onNativeChange = (event, selectedValue) => {
|
|
46
|
+
if (selectedValue) {
|
|
47
|
+
setDateTime(prevDateTime => {
|
|
48
|
+
let newDateTime = new Date(prevDateTime);
|
|
49
|
+
|
|
50
|
+
if (mode === 'date') {
|
|
51
|
+
// If date is being selected, merge it with the existing time
|
|
52
|
+
newDateTime.setUTCFullYear(selectedValue.getUTCFullYear());
|
|
53
|
+
newDateTime.setUTCMonth(selectedValue.getUTCMonth());
|
|
54
|
+
newDateTime.setUTCDate(selectedValue.getUTCDate());
|
|
55
|
+
|
|
56
|
+
if (props.time === true) {
|
|
57
|
+
setMode('time');
|
|
58
|
+
setShowPicker(true);
|
|
59
|
+
} else {
|
|
60
|
+
setShowPicker(false);
|
|
61
|
+
// Update data and notify parent
|
|
62
|
+
setData({ ...data, value: newDateTime });
|
|
63
|
+
props.onChangeData?.(newDateTime.toISOString());
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
// If time is being selected, merge it with the existing date
|
|
67
|
+
newDateTime.setUTCHours(selectedValue.getUTCHours());
|
|
68
|
+
newDateTime.setUTCMinutes(selectedValue.getUTCMinutes());
|
|
69
|
+
newDateTime.setUTCSeconds(0);
|
|
70
|
+
newDateTime.setUTCMilliseconds(0);
|
|
71
|
+
|
|
72
|
+
setShowPicker(false);
|
|
73
|
+
|
|
74
|
+
// Update data and notify parent
|
|
75
|
+
setData({ ...data, value: newDateTime });
|
|
76
|
+
props.onChangeData?.(newDateTime.toISOString());
|
|
77
|
+
|
|
78
|
+
// Update time display
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
setTimeZone(formatTime12Hour(newDateTime));
|
|
81
|
+
}, 10);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return newDateTime;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// Handle date/time change for web platform
|
|
90
|
+
const onWebChange = (e) => {
|
|
91
|
+
const value = e.target.value;
|
|
92
|
+
if (!value) {return;}
|
|
93
|
+
|
|
94
|
+
let selectedDate;
|
|
95
|
+
|
|
96
|
+
if (props.time === true && props.date === true) {
|
|
97
|
+
// For datetime-local input (both date and time)
|
|
98
|
+
// datetime-local format: YYYY-MM-DDTHH:mm returns local time
|
|
99
|
+
const parts = value.split('T');
|
|
100
|
+
const dateParts = parts[0].split('-');
|
|
101
|
+
const timeParts = parts[1].split(':');
|
|
102
|
+
|
|
103
|
+
selectedDate = new Date(
|
|
104
|
+
parseInt(dateParts[0]),
|
|
105
|
+
parseInt(dateParts[1]) - 1,
|
|
106
|
+
parseInt(dateParts[2]),
|
|
107
|
+
parseInt(timeParts[0]),
|
|
108
|
+
parseInt(timeParts[1]),
|
|
109
|
+
0
|
|
110
|
+
);
|
|
111
|
+
} else if (props.time !== true && props.date === true) {
|
|
112
|
+
// For date-only picker
|
|
113
|
+
selectedDate = new Date(value + 'T00:00:00');
|
|
114
|
+
} else {
|
|
115
|
+
// For other cases
|
|
116
|
+
selectedDate = new Date(value);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (isNaN(selectedDate.getTime())) {return;}
|
|
120
|
+
|
|
121
|
+
setDateTime(selectedDate);
|
|
122
|
+
setData({ ...data, value: selectedDate });
|
|
123
|
+
|
|
124
|
+
// Update time display if time component exists
|
|
125
|
+
if (props.time === true) {
|
|
126
|
+
setTimeZone(formatTime12Hour(selectedDate));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Notify parent
|
|
130
|
+
props.onChangeData?.(selectedDate.toISOString());
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// Show date picker
|
|
134
|
+
const showDatepicker = () => {
|
|
135
|
+
setMode('date');
|
|
136
|
+
setShowPicker(true);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// Show time picker
|
|
140
|
+
const showTimepicker = () => {
|
|
141
|
+
setMode('time');
|
|
142
|
+
setShowPicker(true);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// Effect to notify parent of dateTime changes
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
if (props.onChangeData && Platform.OS !== 'web') {
|
|
148
|
+
props.onChangeData(dateTime.toISOString());
|
|
149
|
+
}
|
|
150
|
+
}, [dateTime]);
|
|
151
|
+
|
|
152
|
+
// Web-specific input value formatting
|
|
153
|
+
const getWebInputValue = () => {
|
|
154
|
+
if (!(dateTime instanceof Date) || isNaN(dateTime.getTime())) {return '';}
|
|
155
|
+
|
|
156
|
+
if (props.time === true && props.date === true) {
|
|
157
|
+
// For datetime-local: format as YYYY-MM-DDTHH:mm
|
|
158
|
+
const year = dateTime.getFullYear();
|
|
159
|
+
const month = String(dateTime.getMonth() + 1).padStart(2, '0');
|
|
160
|
+
const day = String(dateTime.getDate()).padStart(2, '0');
|
|
161
|
+
const hours = String(dateTime.getHours()).padStart(2, '0');
|
|
162
|
+
const minutes = String(dateTime.getMinutes()).padStart(2, '0');
|
|
163
|
+
return `${year}-${month}-${day}T${hours}:${minutes}`;
|
|
164
|
+
} else if (props.time !== true && props.date === true) {
|
|
165
|
+
// Date only
|
|
166
|
+
return dateTime.toISOString().split('T')[0];
|
|
167
|
+
} else if (props.time === true) {
|
|
168
|
+
// Time only
|
|
169
|
+
const timeStr = dateTime.toTimeString().split(' ')[0].substring(0, 5);
|
|
170
|
+
return timeStr;
|
|
171
|
+
}
|
|
172
|
+
// Full datetime
|
|
173
|
+
return dateTime.toISOString().substring(0, 16);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// Render for web platform
|
|
177
|
+
if (Platform.OS === 'web') {
|
|
178
|
+
return (
|
|
179
|
+
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
180
|
+
{/* Date picker for web */}
|
|
181
|
+
{props.date === true && (
|
|
182
|
+
<View style={{ marginRight: props.time === true ? normalize(10) : 0 }}>
|
|
183
|
+
{props.labeltext && (
|
|
184
|
+
<Text style={props.positiontextstyle || { fontSize: normalize(12), marginBottom: 5 }}>
|
|
185
|
+
{props.labeltext}
|
|
186
|
+
</Text>
|
|
187
|
+
)}
|
|
188
|
+
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
189
|
+
{props.icon && (
|
|
190
|
+
<HOCIcons.Icons
|
|
191
|
+
icongroup={props.icon.icongroup}
|
|
192
|
+
name={props.icon.name}
|
|
193
|
+
size={props.icon.size}
|
|
194
|
+
color={props.icon.color}
|
|
195
|
+
style={[props.icon.style, { marginRight: normalize(5) }]}
|
|
196
|
+
/>
|
|
197
|
+
)}
|
|
198
|
+
<input
|
|
199
|
+
ref={inputRef}
|
|
200
|
+
type={props.time === true ? 'datetime-local' : 'date'}
|
|
201
|
+
value={getWebInputValue()}
|
|
202
|
+
min={minimumdate instanceof Date ? minimumdate.toISOString().split('T')[0] : undefined}
|
|
203
|
+
max={maximumdate instanceof Date ? maximumdate.toISOString().split('T')[0] : undefined}
|
|
204
|
+
onChange={onWebChange}
|
|
205
|
+
disabled={props.disabled}
|
|
206
|
+
style={{
|
|
207
|
+
height: normalize(35),
|
|
208
|
+
padding: normalize(5),
|
|
209
|
+
border: '1px solid #ccc',
|
|
210
|
+
borderRadius: normalize(5),
|
|
211
|
+
fontSize: normalize(14),
|
|
212
|
+
...props.inputStyle,
|
|
213
|
+
}}
|
|
214
|
+
/>
|
|
215
|
+
</View>
|
|
216
|
+
</View>
|
|
217
|
+
)}
|
|
218
|
+
|
|
219
|
+
{/* Time picker for web (separate if needed) */}
|
|
220
|
+
{props.time === true && props.date !== true && (
|
|
221
|
+
<View style={{ marginHorizontal: normalize(5) }}>
|
|
222
|
+
<View style={{
|
|
223
|
+
position: 'absolute',
|
|
224
|
+
top: normalize(-4),
|
|
225
|
+
left: normalize(7),
|
|
226
|
+
backgroundColor: 'white',
|
|
227
|
+
flexDirection: 'row',
|
|
228
|
+
alignItems: 'center',
|
|
229
|
+
zIndex: 100,
|
|
230
|
+
}}>
|
|
231
|
+
{props.table === undefined && (
|
|
232
|
+
<Text style={{ fontSize: normalize(9), paddingLeft: normalize(2) }}>
|
|
233
|
+
{ValueCheck(props.timeplaceholder) ? props.timeplaceholder : 'TIME'}
|
|
234
|
+
</Text>
|
|
235
|
+
)}
|
|
236
|
+
</View>
|
|
237
|
+
|
|
238
|
+
<input
|
|
239
|
+
type="time"
|
|
240
|
+
value={dateTime.toTimeString().substring(0, 5)}
|
|
241
|
+
onChange={onWebChange}
|
|
242
|
+
disabled={props.timedisabled}
|
|
243
|
+
style={{
|
|
244
|
+
width: props.timewidth ? normalize(props.timewidth) : normalize(80),
|
|
245
|
+
height: props.timeheight ? normalize(props.timeheight) : normalize(35),
|
|
246
|
+
border: '1px solid lightgrey',
|
|
247
|
+
backgroundColor: ValueCheck(props.timebgcolor) ? props.timebgcolor : '#fff',
|
|
248
|
+
borderRadius: normalize(7),
|
|
249
|
+
padding: normalize(5),
|
|
250
|
+
fontSize: normalize(14),
|
|
251
|
+
}}
|
|
252
|
+
/>
|
|
253
|
+
</View>
|
|
254
|
+
)}
|
|
255
|
+
</View>
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Render for native platforms (iOS/Android)
|
|
260
|
+
return (
|
|
261
|
+
<View>
|
|
262
|
+
<View style={{ flexDirection: 'row' }}>
|
|
263
|
+
{/* Date picker with label */}
|
|
264
|
+
{props.date === true && (
|
|
265
|
+
<TouchableOpacity
|
|
266
|
+
disabled={props.disabled}
|
|
267
|
+
onPress={showDatepicker}
|
|
268
|
+
style={props.pickerstyle}
|
|
269
|
+
>
|
|
270
|
+
<View style={props.positionviewstyle}>
|
|
271
|
+
<Text style={props.positiontextstyle}> {props.labeltext} </Text>
|
|
272
|
+
</View>
|
|
273
|
+
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
274
|
+
<HOCIcons.Icons
|
|
275
|
+
icongroup={props.icon.icongroup}
|
|
276
|
+
name={props.icon.name}
|
|
277
|
+
size={props.icon.size}
|
|
278
|
+
color={props.icon.color}
|
|
279
|
+
style={props.icon.style}
|
|
280
|
+
/>
|
|
281
|
+
<Text style={props.textstyle}>
|
|
282
|
+
{moment(dateTime).format('DD-MM-YYYY')}
|
|
283
|
+
</Text>
|
|
284
|
+
</View>
|
|
285
|
+
</TouchableOpacity>
|
|
286
|
+
)}
|
|
287
|
+
|
|
288
|
+
{/* Time picker */}
|
|
289
|
+
{props.time === true && (
|
|
290
|
+
<View style={{
|
|
291
|
+
marginHorizontal: normalize(5),
|
|
292
|
+
marginVertical: normalize(1.5),
|
|
293
|
+
}}>
|
|
294
|
+
<View style={{
|
|
295
|
+
position: 'absolute',
|
|
296
|
+
top: normalize(-4),
|
|
297
|
+
left: normalize(7),
|
|
298
|
+
backgroundColor: 'white',
|
|
299
|
+
flexDirection: 'row',
|
|
300
|
+
alignItems: 'center',
|
|
301
|
+
zIndex: 100,
|
|
302
|
+
}}>
|
|
303
|
+
{props.table === undefined && (
|
|
304
|
+
<Text style={{ fontSize: normalize(9), paddingLeft: normalize(2) }}>
|
|
305
|
+
{ValueCheck(props.timeplaceholder) ? props.timeplaceholder : 'TIME'}
|
|
306
|
+
</Text>
|
|
307
|
+
)}
|
|
308
|
+
</View>
|
|
309
|
+
|
|
310
|
+
<TouchableOpacity
|
|
311
|
+
disabled={props.timedisabled}
|
|
312
|
+
onPress={showTimepicker}
|
|
313
|
+
style={
|
|
314
|
+
isNU(props.timepickerstyle)
|
|
315
|
+
? props.timepickerstyle
|
|
316
|
+
: {
|
|
317
|
+
flexDirection: 'row',
|
|
318
|
+
alignItems: 'center',
|
|
319
|
+
width: props.timewidth ? normalize(props.timewidth) : normalize(60),
|
|
320
|
+
height: props.timeheight ? normalize(props.timeheight) : normalize(30),
|
|
321
|
+
borderWidth: 1,
|
|
322
|
+
borderColor: 'lightgrey',
|
|
323
|
+
backgroundColor: ValueCheck(props.timebgcolor) ? props.timebgcolor : '#fff',
|
|
324
|
+
borderRadius: normalize(7),
|
|
325
|
+
}
|
|
326
|
+
}>
|
|
327
|
+
{props.timeicon ? (
|
|
328
|
+
<HOCIcons.Icons
|
|
329
|
+
icongroup={isNU(props.timeicon.icongroup) ? props.timeicon.icongroup : 5}
|
|
330
|
+
name={props.timeicon.name}
|
|
331
|
+
size={props.timeicon.size}
|
|
332
|
+
style={props.timeiconstyle}
|
|
333
|
+
/>
|
|
334
|
+
) : (
|
|
335
|
+
<MaterialCommunityIcons
|
|
336
|
+
name="timer-outline"
|
|
337
|
+
color={Global.AppTheme.primary_color}
|
|
338
|
+
size={normalize(15)}
|
|
339
|
+
style={{ paddingHorizontal: normalize(1) }}
|
|
340
|
+
/>
|
|
341
|
+
)}
|
|
342
|
+
|
|
343
|
+
{isNU(props.timetextstyle) ? (
|
|
344
|
+
<Text adjustsFontSizeToFit style={props.timetextstyle}>
|
|
345
|
+
{isNU(timeZone) ? timeZone : null}
|
|
346
|
+
</Text>
|
|
347
|
+
) : null}
|
|
348
|
+
|
|
349
|
+
{!isNU(props.timetextstyle) && (
|
|
350
|
+
<View>
|
|
351
|
+
<Text style={{
|
|
352
|
+
fontSize: normalize(9),
|
|
353
|
+
color: 'black',
|
|
354
|
+
fontWeight: 'bold',
|
|
355
|
+
}}>
|
|
356
|
+
{timeZone}
|
|
357
|
+
</Text>
|
|
358
|
+
</View>
|
|
359
|
+
)}
|
|
360
|
+
</TouchableOpacity>
|
|
361
|
+
</View>
|
|
362
|
+
)}
|
|
363
|
+
</View>
|
|
364
|
+
|
|
365
|
+
{/* DateTimePicker for native platforms */}
|
|
366
|
+
{showPicker && Platform.OS !== 'web' && (
|
|
367
|
+
<DateTimePicker
|
|
368
|
+
value={dateTime}
|
|
369
|
+
mode={mode}
|
|
370
|
+
is24Hour={false}
|
|
371
|
+
display={Platform.OS === 'ios' ? 'spinner' : 'default'}
|
|
372
|
+
minimumDate={minimumdate}
|
|
373
|
+
maximumDate={maximumdate}
|
|
374
|
+
onChange={onNativeChange}
|
|
375
|
+
/>
|
|
376
|
+
)}
|
|
377
|
+
</View>
|
|
378
|
+
);
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
export default SDateTimePickerNew;
|