@jescon-technologies/react-native-ui-kit 0.0.5 → 0.0.7
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/dist/Common/ErrorBoundary.d.ts +15 -0
- package/dist/Common/ErrorBoundary.d.ts.map +1 -0
- package/dist/Common/ErrorBoundary.js +64 -0
- package/dist/Common/ErrorBoundary.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/src/Common/ErrorBoundary.d.ts +15 -0
- package/dist/src/Common/ErrorBoundary.d.ts.map +1 -0
- package/dist/src/Common/ErrorBoundary.js +64 -0
- package/dist/src/Common/ErrorBoundary.js.map +1 -0
- package/package.json +17 -5
- package/.gitattributes +0 -2
- package/index.d.ts +0 -66
- package/index.js +0 -66
- package/src/Alerts/AAlert.js +0 -137
- package/src/Alerts/AAlertIOS.js +0 -97
- package/src/Alerts/ABlink.js +0 -40
- package/src/Common/ErrorBoundary.tsx +0 -73
- package/src/Common/Icons.js +0 -49
- package/src/Common/NetworkServiceCall.js +0 -265
- package/src/CommonStyle/CommonTheme.js +0 -11
- package/src/CommonStyle/ComponentFunctions.js +0 -632
- package/src/CommonStyle/PopupStyle.js +0 -146
- package/src/CommonStyle/commonStyle.js +0 -93
- package/src/CommonStyle/componentStyle.js +0 -545
- package/src/CommonStyle/optionListStyles.js +0 -175
- package/src/Components/ByProductPage.js +0 -200
- package/src/Components/CDropDownListNew.js +0 -153
- package/src/Components/CSupplierList.js +0 -88
- package/src/Components/CVerificationCard.js +0 -2822
- package/src/Components/CustomButton.js +0 -67
- package/src/Components/CustomCard.js +0 -127
- package/src/Components/CustomTextInput.js +0 -47
- package/src/Components/EquipmentPage.js +0 -313
- package/src/Components/FilterInput.Copy.js +0 -723
- package/src/Components/FilterInput.js +0 -569
- package/src/Components/HSubHeading.js +0 -68
- package/src/Components/HeaderCard.js +0 -40
- package/src/Components/MoreOptionsScreen.js +0 -251
- package/src/Components/NonSwipableProductCard.js +0 -226
- package/src/Components/NonSwipableSupplierCard.js +0 -348
- package/src/Components/ProductCard.js +0 -1336
- package/src/Components/QualityProductCard.js +0 -1059
- package/src/Components/RateProductCard.js +0 -1452
- package/src/Components/RawMaterial.js +0 -261
- package/src/Components/SDropDownEdited.js +0 -549
- package/src/Components/SDropDownNew.js +0 -529
- package/src/Components/SHelpDescription.js +0 -147
- package/src/Components/STextInputNew.js +0 -510
- package/src/Components/SearchProductCard.js +0 -470
- package/src/Components/StageByProduct.js +0 -199
- package/src/Components/SupplierCard.js +0 -243
- package/src/Components/SupplierInvoiceCard.js +0 -405
- package/src/Components/SwipableSupplierCard.js +0 -136
- package/src/Components/TagTemplate.js +0 -74
- package/src/Components/WrappedComponent.js +0 -25
- package/src/Custom/CBooking.js +0 -944
- package/src/Custom/CBookingPostpone.js +0 -1822
- package/src/Custom/CCalendar.js +0 -560
- package/src/Custom/CCard.js +0 -880
- package/src/Custom/CDetailCard.js +0 -205
- package/src/Custom/CHelpImage.js +0 -52
- package/src/Custom/CReport.js +0 -569
- package/src/Custom/CScrollView.js +0 -73
- package/src/Custom/CSignature.js +0 -112
- package/src/Custom/CSliderMenu.js +0 -339
- package/src/Custom/CSupplierCard.js +0 -99
- package/src/Custom/CTemplateCard.js +0 -438
- package/src/Custom/CTokenAllocation.js +0 -1402
- package/src/Custom/CTokenListOverlay.js +0 -122
- package/src/Custom/CWardStatus.js +0 -444
- package/src/Custom/Charts/CBarChart.js +0 -218
- package/src/Custom/Charts/CDashBoardList.js +0 -133
- package/src/Custom/Charts/CDashBoardTable.js +0 -172
- package/src/Custom/Charts/CLineChart.js +0 -193
- package/src/Custom/Charts/CPieChart.js +0 -186
- package/src/Custom/Loader.js +0 -182
- package/src/Custom/OUserView.js +0 -1121
- package/src/Custom/PreviewDosage.js +0 -115
- package/src/Custom/SearchLoader.js +0 -32
- package/src/Custom/TableComponent/CActivityTable.js +0 -707
- package/src/Custom/TableComponent/CMoreButtonTable.js +0 -197
- package/src/Custom/TableComponent/CTable.js +0 -185
- package/src/Custom/TableComponent/CTextBody.js +0 -40
- package/src/Custom/TableComponent/CTextHeader.js +0 -17
- package/src/Custom/TableComponent/PreviewPrescriptionNew.js +0 -1011
- package/src/Custom/TableComponent/SDropdownTable.js +0 -491
- package/src/Custom/TableComponent/TagTable.js +0 -1200
- package/src/CustomComponents/CAddColumn.js +0 -140
- package/src/CustomComponents/CAssessmentDelete.js +0 -307
- package/src/CustomComponents/CAwesomeButton.js +0 -83
- package/src/CustomComponents/CAwesomeMoreButton.js +0 -54
- package/src/CustomComponents/CBackHandler.js +0 -273
- package/src/CustomComponents/CCalendar.js +0 -243
- package/src/CustomComponents/CCommentOverlay.js +0 -202
- package/src/CustomComponents/CComments.js +0 -162
- package/src/CustomComponents/CContainerView.js +0 -24
- package/src/CustomComponents/CCustomTextInput.js +0 -336
- package/src/CustomComponents/CDetailView.js +0 -40
- package/src/CustomComponents/CDropDownList.js +0 -153
- package/src/CustomComponents/CDropdownSelect.js +0 -555
- package/src/CustomComponents/CFooterView.js +0 -42
- package/src/CustomComponents/CImagePickerSave.js +0 -316
- package/src/CustomComponents/CModalOverlay.js +0 -91
- package/src/CustomComponents/CNetworkStatus.js +0 -327
- package/src/CustomComponents/CNotesInstructions.js +0 -1000
- package/src/CustomComponents/COverlay.js +0 -81
- package/src/CustomComponents/CRemarks.js +0 -176
- package/src/CustomComponents/CRowAdd.js +0 -143
- package/src/CustomComponents/CSummaryDropDown.js +0 -327
- package/src/CustomComponents/CText.js +0 -9
- package/src/CustomComponents/CVectorIcon.js +0 -34
- package/src/CustomComponents/HtmlContentViewer.js +0 -65
- package/src/CustomComponents/PdfContentViewer.js +0 -90
- package/src/CustomComponents/SDropDownDosage.js +0 -1087
- package/src/CustomComponents/SwipableProductCard.js +0 -246
- package/src/CustomComponents/SwipableProductImageCard.js +0 -254
- package/src/CustomComponents/WorkOrderDetails.js +0 -1216
- package/src/CustomComponents/WorkOrderDetailsPage.js +0 -1213
- package/src/HOC/ConfirmOverlay.js +0 -192
- package/src/HOC/HHeading.js +0 -70
- package/src/HOC/HMoreButton.js +0 -88
- package/src/HOC/HNatureHeading.js +0 -402
- package/src/HOC/HOCIcons.js +0 -80
- package/src/HOC/HOverlayCentered.js +0 -140
- package/src/HOC/HShadowButton.js +0 -45
- package/src/HOC/HShadowCountButton.js +0 -82
- package/src/HOC/OptionOverlay.js +0 -48
- package/src/Json/Chart.json +0 -818
- package/src/Json/Consultation.json +0 -622
- package/src/Json/CreditBill.json +0 -490
- package/src/Json/Dropdown.json +0 -216
- package/src/Json/DropdownConsultation.json +0 -228
- package/src/Json/DynamicReports.json +0 -623
- package/src/Json/Footer.json +0 -79
- package/src/Media/AudioScreen.js +0 -342
- package/src/Media/BarcodeScan.js +0 -145
- package/src/Media/CAudioPlay.js +0 -228
- package/src/Media/CCaptureImageWithoutEdit.js +0 -330
- package/src/Media/CImageGallery.js +0 -289
- package/src/Media/CImageZoom.js +0 -82
- package/src/Media/CSingleImage.js +0 -391
- package/src/Media/CSketchCanvas.js +0 -76
- package/src/Media/CVideoPlay.js +0 -31
- package/src/Media/DocumentScreen.js +0 -362
- package/src/Media/DrawingScreen.js +0 -578
- package/src/Media/ImageScreen.js +0 -309
- package/src/Media/RecordAudio.js +0 -250
- package/src/Media/RecordVideo.js +0 -223
- package/src/Media/VideoScreen.js +0 -378
- package/src/Navigation/PageNavigation.js +0 -224
- package/src/Navigation/useFocusEffect.js +0 -2
- package/src/Navigation/useFocusEffect.native.js +0 -1
- package/src/Navigation/useFocusEffect.web.js +0 -1
- package/src/Navigation/useIsFocused.js +0 -1
- package/src/Navigation/useIsFocused.native.js +0 -1
- package/src/Navigation/useIsFocused.web.js +0 -1
- package/src/Navigation/useNavigation.js +0 -2
- package/src/Navigation/useNavigation.native.js +0 -1
- package/src/Navigation/useNavigation.web.js +0 -1
- package/src/Screens/CMedications.js +0 -528
- package/src/Screens/CWebViewGallery.js +0 -203
- package/src/Screens/ChartScan.js +0 -279
- package/src/Screens/ChartScreenNew.js +0 -1579
- package/src/Screens/Consultation.js +0 -1500
- package/src/Screens/Dashboard.js +0 -778
- package/src/Screens/FileExplorer.js +0 -288
- package/src/Screens/Footer.js +0 -340
- package/src/Screens/ForgotPassword.js +0 -288
- package/src/Screens/HeaderBlock.js +0 -353
- package/src/Screens/Login.js +0 -328
- package/src/Screens/Notification.js +0 -149
- package/src/Screens/OcrScreen.js +0 -20
- package/src/Screens/PdfPreview.js +0 -507
- package/src/Screens/RegistrationDetails.js +0 -467
- package/src/Screens/SearchScreen.js +0 -582
- package/src/Screens/Splash.js +0 -788
- package/src/Screens/SwipeLeftView.js +0 -1867
- package/src/StaticComponents/SAlphabet.js +0 -47
- package/src/StaticComponents/SCheckBox.js +0 -42
- package/src/StaticComponents/SDatePicker.js +0 -208
- package/src/StaticComponents/SDatePickerLabel.js +0 -253
- package/src/StaticComponents/SDatePickerNew.js +0 -258
- package/src/StaticComponents/SDateTimePickerNew.js +0 -381
- package/src/StaticComponents/SDropDownGenerate.js +0 -450
- package/src/StaticComponents/SDropDownHoc.js +0 -636
- package/src/StaticComponents/SDropDownIcon.js +0 -500
- package/src/StaticComponents/SMenuBox.js +0 -131
- package/src/StaticComponents/SOverlay.js +0 -177
- package/src/StaticComponents/SOverlayTextInput.js +0 -109
- package/src/StaticComponents/SSearch.js +0 -438
- package/src/StaticComponents/SSearchBar.js +0 -53
- package/src/StaticComponents/SSpeedDial.js +0 -303
- package/src/StaticComponents/STextInput.js +0 -289
- package/src/StaticComponents/STextInputProps.js +0 -36
- package/src/StaticComponents/STimePicker.js +0 -171
- package/src/StaticComponents/STimingDropDownNew.js +0 -1585
- package/src/StaticComponents/STimingSwitch.js +0 -34
- package/src/layout/CContainerView.js +0 -21
- package/src/layout/CDetailView.js +0 -81
- package/src/layout/HeaderBlock.js +0 -353
- package/src/layout/INVLoginLayout.js +0 -657
- package/src/layout/Loader.js +0 -176
|
@@ -1,258 +0,0 @@
|
|
|
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 '../../../../../src/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
|
-
}
|
|
@@ -1,381 +0,0 @@
|
|
|
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 '../../../../../src/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;
|