@hero-design/rn 8.103.6 → 8.103.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.
Files changed (33) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/CHANGELOG.md +6 -0
  3. package/es/index.js +128 -61
  4. package/lib/index.js +128 -61
  5. package/package.json +1 -1
  6. package/src/components/DatePicker/DatePickerAndroid.tsx +18 -4
  7. package/src/components/DatePicker/DatePickerCalendar.tsx +18 -4
  8. package/src/components/DatePicker/DatePickerIOS.tsx +18 -4
  9. package/src/components/DatePicker/StyledDatePicker.tsx +19 -2
  10. package/src/components/DatePicker/__tests__/DatePicker.spec.tsx +102 -1
  11. package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +3 -0
  12. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +1 -0
  13. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +1 -0
  14. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +2 -0
  15. package/src/components/DatePicker/types.ts +11 -0
  16. package/src/components/TimePicker/StyledTimePicker.tsx +19 -2
  17. package/src/components/TimePicker/TimePickerAndroid.tsx +18 -4
  18. package/src/components/TimePicker/TimePickerIOS.tsx +21 -5
  19. package/src/components/TimePicker/__tests__/TimePicker.spec.tsx +72 -1
  20. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +2 -0
  21. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +2 -0
  22. package/src/components/TimePicker/types.ts +11 -0
  23. package/stats/8.103.6/rn-stats.html +0 -2
  24. package/stats/8.103.7/rn-stats.html +4844 -0
  25. package/types/components/DatePicker/DatePickerAndroid.d.ts +1 -1
  26. package/types/components/DatePicker/DatePickerCalendar.d.ts +1 -1
  27. package/types/components/DatePicker/DatePickerIOS.d.ts +1 -1
  28. package/types/components/DatePicker/StyledDatePicker.d.ts +8 -1
  29. package/types/components/DatePicker/types.d.ts +11 -0
  30. package/types/components/TimePicker/StyledTimePicker.d.ts +8 -1
  31. package/types/components/TimePicker/TimePickerAndroid.d.ts +1 -1
  32. package/types/components/TimePicker/TimePickerIOS.d.ts +1 -1
  33. package/types/components/TimePicker/types.d.ts +11 -0
package/lib/index.js CHANGED
@@ -20444,6 +20444,30 @@ var useFormatDate = function useFormatDate(_ref) {
20444
20444
  };
20445
20445
  };
20446
20446
 
20447
+ var StyledPickerWrapper$1 = index$b(reactNative.View)(function (_ref) {
20448
+ var theme = _ref.theme;
20449
+ return {
20450
+ height: theme.__hd__.datePicker.sizes.height,
20451
+ alignItems: 'center'
20452
+ };
20453
+ });
20454
+ var getZIndexByState$2 = function getZIndexByState(_ref2) {
20455
+ var themeHasError = _ref2.themeHasError;
20456
+ if (themeHasError) {
20457
+ return 1;
20458
+ }
20459
+ return 0;
20460
+ };
20461
+ var StyledTouchableOpacity$2 = index$b(reactNative.TouchableOpacity)(function (_ref3) {
20462
+ var themeGroupStyleEnabled = _ref3.themeGroupStyleEnabled,
20463
+ themeHasError = _ref3.themeHasError;
20464
+ return _objectSpread2({}, themeGroupStyleEnabled && {
20465
+ zIndex: getZIndexByState$2({
20466
+ themeHasError: themeHasError
20467
+ })
20468
+ });
20469
+ });
20470
+
20447
20471
  var DatePickerAndroid = function DatePickerAndroid(_ref) {
20448
20472
  var value = _ref.value,
20449
20473
  minDate = _ref.minDate,
@@ -20463,7 +20487,10 @@ var DatePickerAndroid = function DatePickerAndroid(_ref) {
20463
20487
  variant = _ref$variant === void 0 ? 'default' : _ref$variant,
20464
20488
  renderSelectedValue = _ref.renderSelectedValue,
20465
20489
  locale = _ref.locale,
20466
- TextInputComponent = _ref.TextInputComponent;
20490
+ TextInputComponent = _ref.TextInputComponent,
20491
+ inputProps = _ref.inputProps,
20492
+ _ref$groupStyleEnable = _ref.groupStyleEnabled,
20493
+ groupStyleEnabled = _ref$groupStyleEnable === void 0 ? false : _ref$groupStyleEnable;
20467
20494
  var _useState = React.useState(false),
20468
20495
  _useState2 = _slicedToArray(_useState, 2),
20469
20496
  open = _useState2[0],
@@ -20482,15 +20509,19 @@ var DatePickerAndroid = function DatePickerAndroid(_ref) {
20482
20509
  value: value
20483
20510
  });
20484
20511
  var InputComponent = TextInputComponent || TextInput;
20485
- return /*#__PURE__*/React__namespace.default.createElement(reactNative.TouchableOpacity, {
20486
- onPress: function onPress() {
20487
- return setOpen(true);
20488
- },
20489
- disabled: disabled
20512
+ var onPress = React.useCallback(function () {
20513
+ setOpen(true);
20514
+ }, []);
20515
+ return /*#__PURE__*/React__namespace.default.createElement(StyledTouchableOpacity$2, {
20516
+ onPress: onPress,
20517
+ disabled: disabled,
20518
+ themeGroupStyleEnabled: groupStyleEnabled,
20519
+ themeHasError: !!error,
20520
+ testID: "date-picker-android-touchable-opacity"
20490
20521
  }, /*#__PURE__*/React__namespace.default.createElement(reactNative.View, {
20491
20522
  pointerEvents: "none",
20492
20523
  testID: "datePickerInputAndroid"
20493
- }, /*#__PURE__*/React__namespace.default.createElement(InputComponent, {
20524
+ }, /*#__PURE__*/React__namespace.default.createElement(InputComponent, _extends$1({}, inputProps, {
20494
20525
  label: label,
20495
20526
  value: displayValue,
20496
20527
  suffix: "calendar-dates-outlined",
@@ -20507,7 +20538,7 @@ var DatePickerAndroid = function DatePickerAndroid(_ref) {
20507
20538
  formattedDateString: displayValue
20508
20539
  }, props);
20509
20540
  } : undefined
20510
- })), /*#__PURE__*/React__namespace.default.createElement(AndroidDatePickerDialog, {
20541
+ }))), /*#__PURE__*/React__namespace.default.createElement(AndroidDatePickerDialog, {
20511
20542
  open: open,
20512
20543
  onClose: function onClose() {
20513
20544
  return setOpen(false);
@@ -20586,7 +20617,10 @@ var DatePickerCalendar = function DatePickerCalendar(_ref2) {
20586
20617
  supportedOrientations = _ref2$supportedOrient === void 0 ? ['portrait'] : _ref2$supportedOrient,
20587
20618
  renderSelectedValue = _ref2.renderSelectedValue,
20588
20619
  locale = _ref2.locale,
20589
- TextInputComponent = _ref2.TextInputComponent;
20620
+ TextInputComponent = _ref2.TextInputComponent,
20621
+ inputProps = _ref2.inputProps,
20622
+ _ref2$groupStyleEnabl = _ref2.groupStyleEnabled,
20623
+ groupStyleEnabled = _ref2$groupStyleEnabl === void 0 ? false : _ref2$groupStyleEnabl;
20590
20624
  var _useState5 = React.useState(false),
20591
20625
  _useState6 = _slicedToArray(_useState5, 2),
20592
20626
  open = _useState6[0],
@@ -20613,15 +20647,19 @@ var DatePickerCalendar = function DatePickerCalendar(_ref2) {
20613
20647
  value: value
20614
20648
  });
20615
20649
  var InputComponent = TextInputComponent || TextInput;
20616
- return /*#__PURE__*/React__namespace.default.createElement(reactNative.TouchableOpacity, {
20617
- onPress: function onPress() {
20618
- return setOpen(true);
20619
- },
20620
- disabled: disabled
20650
+ var onPress = React.useCallback(function () {
20651
+ setOpen(true);
20652
+ }, []);
20653
+ return /*#__PURE__*/React__namespace.default.createElement(StyledTouchableOpacity$2, {
20654
+ onPress: onPress,
20655
+ disabled: disabled,
20656
+ themeGroupStyleEnabled: groupStyleEnabled,
20657
+ themeHasError: !!error,
20658
+ testID: "date-picker-calendar-touchable-opacity"
20621
20659
  }, /*#__PURE__*/React__namespace.default.createElement(reactNative.View, {
20622
20660
  pointerEvents: "none",
20623
20661
  testID: "datePickerCalendar"
20624
- }, /*#__PURE__*/React__namespace.default.createElement(InputComponent, {
20662
+ }, /*#__PURE__*/React__namespace.default.createElement(InputComponent, _extends$1({}, inputProps, {
20625
20663
  label: label,
20626
20664
  value: displayValue,
20627
20665
  suffix: "calendar-dates-outlined",
@@ -20638,7 +20676,7 @@ var DatePickerCalendar = function DatePickerCalendar(_ref2) {
20638
20676
  formattedDateString: displayValue
20639
20677
  }, props);
20640
20678
  } : undefined
20641
- })), /*#__PURE__*/React__namespace.default.createElement(BottomSheet$1, {
20679
+ }))), /*#__PURE__*/React__namespace.default.createElement(BottomSheet$1, {
20642
20680
  open: open,
20643
20681
  onRequestClose: function onRequestClose() {
20644
20682
  return setOpen(false);
@@ -20668,14 +20706,6 @@ var DatePickerCalendar = function DatePickerCalendar(_ref2) {
20668
20706
  }))));
20669
20707
  };
20670
20708
 
20671
- var StyledPickerWrapper$1 = index$b(reactNative.View)(function (_ref) {
20672
- var theme = _ref.theme;
20673
- return {
20674
- height: theme.__hd__.datePicker.sizes.height,
20675
- alignItems: 'center'
20676
- };
20677
- });
20678
-
20679
20709
  var IOSDatePickerDialog = function IOSDatePickerDialog(_ref) {
20680
20710
  var label = _ref.label,
20681
20711
  open = _ref.open,
@@ -20769,7 +20799,10 @@ var DatePickerIOS = function DatePickerIOS(_ref) {
20769
20799
  variant = _ref$variant === void 0 ? 'default' : _ref$variant,
20770
20800
  locale = _ref.locale,
20771
20801
  renderSelectedValue = _ref.renderSelectedValue,
20772
- TextInputComponent = _ref.TextInputComponent;
20802
+ TextInputComponent = _ref.TextInputComponent,
20803
+ inputProps = _ref.inputProps,
20804
+ _ref$groupStyleEnable = _ref.groupStyleEnabled,
20805
+ groupStyleEnabled = _ref$groupStyleEnable === void 0 ? false : _ref$groupStyleEnable;
20773
20806
  var _useState = React.useState(false),
20774
20807
  _useState2 = _slicedToArray(_useState, 2),
20775
20808
  open = _useState2[0],
@@ -20790,15 +20823,19 @@ var DatePickerIOS = function DatePickerIOS(_ref) {
20790
20823
  value: value
20791
20824
  });
20792
20825
  var InputComponent = TextInputComponent || TextInput;
20793
- return /*#__PURE__*/React__namespace.default.createElement(reactNative.TouchableOpacity, {
20794
- onPress: function onPress() {
20795
- return setOpen(true);
20796
- },
20797
- disabled: disabled
20826
+ var onPress = React.useCallback(function () {
20827
+ setOpen(true);
20828
+ }, []);
20829
+ return /*#__PURE__*/React__namespace.default.createElement(StyledTouchableOpacity$2, {
20830
+ onPress: onPress,
20831
+ disabled: disabled,
20832
+ themeGroupStyleEnabled: groupStyleEnabled,
20833
+ themeHasError: !!error,
20834
+ testID: "date-picker-ios-touchable-opacity"
20798
20835
  }, /*#__PURE__*/React__namespace.default.createElement(reactNative.View, {
20799
20836
  pointerEvents: "none",
20800
20837
  testID: "datePickerInputIOS"
20801
- }, /*#__PURE__*/React__namespace.default.createElement(InputComponent, {
20838
+ }, /*#__PURE__*/React__namespace.default.createElement(InputComponent, _extends$1({}, inputProps, {
20802
20839
  label: label,
20803
20840
  value: displayValue,
20804
20841
  suffix: "calendar-dates-outlined",
@@ -20815,7 +20852,7 @@ var DatePickerIOS = function DatePickerIOS(_ref) {
20815
20852
  formattedDateString: displayValue
20816
20853
  }, props);
20817
20854
  } : undefined
20818
- })), /*#__PURE__*/React__namespace.default.createElement(IOSDatePickerDialog, {
20855
+ }))), /*#__PURE__*/React__namespace.default.createElement(IOSDatePickerDialog, {
20819
20856
  value: value,
20820
20857
  onChange: onChange,
20821
20858
  open: open,
@@ -24952,18 +24989,18 @@ var StyledSectionList = index$b(reactNative.SectionList)(function (_ref4) {
24952
24989
  paddingHorizontal: theme.__hd__.select.space.optionListHorizontalPadding
24953
24990
  };
24954
24991
  });
24955
- var getZIndexByState = function getZIndexByState(_ref5) {
24992
+ var getZIndexByState$1 = function getZIndexByState(_ref5) {
24956
24993
  var themeHasError = _ref5.themeHasError;
24957
24994
  if (themeHasError) {
24958
24995
  return 1;
24959
24996
  }
24960
24997
  return 0;
24961
24998
  };
24962
- var StyledTouchableOpacity = index$b(reactNative.TouchableOpacity)(function (_ref6) {
24999
+ var StyledTouchableOpacity$1 = index$b(reactNative.TouchableOpacity)(function (_ref6) {
24963
25000
  var themeGroupStyleEnabled = _ref6.themeGroupStyleEnabled,
24964
25001
  themeHasError = _ref6.themeHasError;
24965
25002
  return _objectSpread2({}, themeGroupStyleEnabled && {
24966
- zIndex: getZIndexByState({
25003
+ zIndex: getZIndexByState$1({
24967
25004
  themeHasError: themeHasError
24968
25005
  })
24969
25006
  });
@@ -25168,7 +25205,7 @@ function MultiSelect(_ref) {
25168
25205
  }, [open, value]);
25169
25206
  return /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, /*#__PURE__*/React__namespace.default.createElement(reactNative.View, {
25170
25207
  pointerEvents: !editable || disabled || inputProps !== null && inputProps !== void 0 && inputProps.loading ? 'none' : 'auto'
25171
- }, /*#__PURE__*/React__namespace.default.createElement(StyledTouchableOpacity, {
25208
+ }, /*#__PURE__*/React__namespace.default.createElement(StyledTouchableOpacity$1, {
25172
25209
  onPress: onPress,
25173
25210
  themeGroupStyleEnabled: groupStyleEnabled,
25174
25211
  themeHasError: !!error,
@@ -25376,7 +25413,7 @@ var SingleSelect = function SingleSelect(_ref) {
25376
25413
  }, []);
25377
25414
  return /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, /*#__PURE__*/React__namespace.default.createElement(reactNative.View, {
25378
25415
  pointerEvents: !editable || disabled || inputProps !== null && inputProps !== void 0 && inputProps.loading ? 'none' : 'auto'
25379
- }, /*#__PURE__*/React__namespace.default.createElement(StyledTouchableOpacity, {
25416
+ }, /*#__PURE__*/React__namespace.default.createElement(StyledTouchableOpacity$1, {
25380
25417
  onPress: onPress,
25381
25418
  themeGroupStyleEnabled: groupStyleEnabled,
25382
25419
  themeHasError: !!error,
@@ -26723,6 +26760,30 @@ var Tag = function Tag(_ref) {
26723
26760
  }, content) : content);
26724
26761
  };
26725
26762
 
26763
+ var StyledPickerWrapper = index$b(reactNative.View)(function (_ref) {
26764
+ var theme = _ref.theme;
26765
+ return {
26766
+ height: theme.__hd__.timePicker.sizes.height,
26767
+ alignItems: 'center'
26768
+ };
26769
+ });
26770
+ var getZIndexByState = function getZIndexByState(_ref2) {
26771
+ var themeHasError = _ref2.themeHasError;
26772
+ if (themeHasError) {
26773
+ return 1;
26774
+ }
26775
+ return 0;
26776
+ };
26777
+ var StyledTouchableOpacity = index$b(reactNative.TouchableOpacity)(function (_ref3) {
26778
+ var themeGroupStyleEnabled = _ref3.themeGroupStyleEnabled,
26779
+ themeHasError = _ref3.themeHasError;
26780
+ return _objectSpread2({}, themeGroupStyleEnabled && {
26781
+ zIndex: getZIndexByState({
26782
+ themeHasError: themeHasError
26783
+ })
26784
+ });
26785
+ });
26786
+
26726
26787
  var TimePickerAndroid = function TimePickerAndroid(_ref) {
26727
26788
  var value = _ref.value,
26728
26789
  label = _ref.label,
@@ -26739,7 +26800,10 @@ var TimePickerAndroid = function TimePickerAndroid(_ref) {
26739
26800
  testID = _ref.testID,
26740
26801
  _ref$showSuffix = _ref.showSuffix,
26741
26802
  showSuffix = _ref$showSuffix === void 0 ? true : _ref$showSuffix,
26742
- TextInputComponent = _ref.TextInputComponent;
26803
+ TextInputComponent = _ref.TextInputComponent,
26804
+ inputProps = _ref.inputProps,
26805
+ _ref$groupStyleEnable = _ref.groupStyleEnabled,
26806
+ groupStyleEnabled = _ref$groupStyleEnable === void 0 ? false : _ref$groupStyleEnable;
26743
26807
  var _useState = React.useState(false),
26744
26808
  _useState2 = _slicedToArray(_useState, 2),
26745
26809
  open = _useState2[0],
@@ -26748,15 +26812,19 @@ var TimePickerAndroid = function TimePickerAndroid(_ref) {
26748
26812
  var displayValue = value ? formatTime(displayFormat, value) : '';
26749
26813
  var pickerInitValue = value || new Date();
26750
26814
  var InputComponent = TextInputComponent || TextInput;
26751
- return /*#__PURE__*/React__namespace.default.createElement(reactNative.TouchableOpacity, {
26752
- onPress: function onPress() {
26753
- return setOpen(true);
26754
- },
26755
- disabled: disabled
26815
+ var onPress = React.useCallback(function () {
26816
+ setOpen(true);
26817
+ }, []);
26818
+ return /*#__PURE__*/React__namespace.default.createElement(StyledTouchableOpacity, {
26819
+ onPress: onPress,
26820
+ disabled: disabled,
26821
+ themeGroupStyleEnabled: groupStyleEnabled,
26822
+ themeHasError: !!error,
26823
+ testID: "time-picker-android-touchable-opacity"
26756
26824
  }, /*#__PURE__*/React__namespace.default.createElement(reactNative.View, {
26757
26825
  pointerEvents: "none",
26758
26826
  testID: "timePickerInputAndroid"
26759
- }, /*#__PURE__*/React__namespace.default.createElement(InputComponent, {
26827
+ }, /*#__PURE__*/React__namespace.default.createElement(InputComponent, _extends$1({}, inputProps, {
26760
26828
  label: label,
26761
26829
  value: displayValue,
26762
26830
  suffix: showSuffix ? 'clock-3' : undefined,
@@ -26767,7 +26835,7 @@ var TimePickerAndroid = function TimePickerAndroid(_ref) {
26767
26835
  helpText: helpText,
26768
26836
  style: style,
26769
26837
  testID: testID
26770
- })), open ? /*#__PURE__*/React__namespace.default.createElement(DateTimePicker__default.default, {
26838
+ }))), open ? /*#__PURE__*/React__namespace.default.createElement(DateTimePicker__default.default, {
26771
26839
  testID: "timePickerAndroid",
26772
26840
  mode: "time",
26773
26841
  value: pickerInitValue,
@@ -26782,14 +26850,6 @@ var TimePickerAndroid = function TimePickerAndroid(_ref) {
26782
26850
  }) : null);
26783
26851
  };
26784
26852
 
26785
- var StyledPickerWrapper = index$b(reactNative.View)(function (_ref) {
26786
- var theme = _ref.theme;
26787
- return {
26788
- height: theme.__hd__.timePicker.sizes.height,
26789
- alignItems: 'center'
26790
- };
26791
- });
26792
-
26793
26853
  var TimePickerIOS = function TimePickerIOS(_ref) {
26794
26854
  var value = _ref.value,
26795
26855
  label = _ref.label,
@@ -26809,7 +26869,10 @@ var TimePickerIOS = function TimePickerIOS(_ref) {
26809
26869
  showSuffix = _ref$showSuffix === void 0 ? true : _ref$showSuffix,
26810
26870
  _ref$supportedOrienta = _ref.supportedOrientations,
26811
26871
  supportedOrientations = _ref$supportedOrienta === void 0 ? ['portrait'] : _ref$supportedOrienta,
26812
- TextInputComponent = _ref.TextInputComponent;
26872
+ TextInputComponent = _ref.TextInputComponent,
26873
+ inputProps = _ref.inputProps,
26874
+ _ref$groupStyleEnable = _ref.groupStyleEnabled,
26875
+ groupStyleEnabled = _ref$groupStyleEnable === void 0 ? false : _ref$groupStyleEnable;
26813
26876
  var _useState = React.useState(value || new Date()),
26814
26877
  _useState2 = _slicedToArray(_useState, 2),
26815
26878
  selectingDate = _useState2[0],
@@ -26825,15 +26888,19 @@ var TimePickerIOS = function TimePickerIOS(_ref) {
26825
26888
  React.useEffect(function () {
26826
26889
  setSelectingDate(value || new Date());
26827
26890
  }, [value]);
26828
- return /*#__PURE__*/React__namespace.default.createElement(reactNative.TouchableOpacity, {
26829
- onPress: function onPress() {
26830
- return setOpen(true);
26831
- },
26832
- disabled: disabled
26891
+ var onPress = React.useCallback(function () {
26892
+ setOpen(true);
26893
+ }, []);
26894
+ return /*#__PURE__*/React__namespace.default.createElement(StyledTouchableOpacity, {
26895
+ onPress: onPress,
26896
+ disabled: disabled,
26897
+ themeGroupStyleEnabled: groupStyleEnabled,
26898
+ themeHasError: !!error,
26899
+ testID: "time-picker-ios-touchable-opacity"
26833
26900
  }, /*#__PURE__*/React__namespace.default.createElement(reactNative.View, {
26834
26901
  pointerEvents: "none",
26835
26902
  testID: "timePickerInputIOS"
26836
- }, /*#__PURE__*/React__namespace.default.createElement(InputComponent, {
26903
+ }, /*#__PURE__*/React__namespace.default.createElement(InputComponent, _extends$1({}, inputProps, {
26837
26904
  label: label,
26838
26905
  value: displayValue,
26839
26906
  suffix: showSuffix ? 'clock-3' : undefined,
@@ -26844,7 +26911,7 @@ var TimePickerIOS = function TimePickerIOS(_ref) {
26844
26911
  helpText: helpText,
26845
26912
  testID: testID,
26846
26913
  style: style
26847
- })), /*#__PURE__*/React__namespace.default.createElement(BottomSheet$1, {
26914
+ }))), /*#__PURE__*/React__namespace.default.createElement(BottomSheet$1, {
26848
26915
  open: open,
26849
26916
  onRequestClose: function onRequestClose() {
26850
26917
  return setOpen(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.103.6",
3
+ "version": "8.103.7",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -1,10 +1,11 @@
1
- import React, { useState } from 'react';
2
- import { TouchableOpacity, View } from 'react-native';
1
+ import React, { useState, useCallback } from 'react';
2
+ import { View } from 'react-native';
3
3
 
4
4
  import TextInput from '../TextInput';
5
5
  import AndroidDatePickerDialog from './Dialog/AndroidDialog';
6
6
  import useCalculateDate from './hooks/useCalculateDate';
7
7
  import useFormatDate from './hooks/useFormatDate';
8
+ import { StyledTouchableOpacity } from './StyledDatePicker';
8
9
  import type { InternalDatePickerProps } from './types';
9
10
 
10
11
  type DatePickerAndroidProps = Omit<
@@ -31,6 +32,8 @@ const DatePickerAndroid = ({
31
32
  renderSelectedValue,
32
33
  locale,
33
34
  TextInputComponent,
35
+ inputProps,
36
+ groupStyleEnabled = false,
34
37
  }: DatePickerAndroidProps) => {
35
38
  const [open, setOpen] = useState(false);
36
39
 
@@ -44,10 +47,21 @@ const DatePickerAndroid = ({
44
47
 
45
48
  const InputComponent = TextInputComponent || TextInput;
46
49
 
50
+ const onPress = useCallback(() => {
51
+ setOpen(true);
52
+ }, []);
53
+
47
54
  return (
48
- <TouchableOpacity onPress={() => setOpen(true)} disabled={disabled}>
55
+ <StyledTouchableOpacity
56
+ onPress={onPress}
57
+ disabled={disabled}
58
+ themeGroupStyleEnabled={groupStyleEnabled}
59
+ themeHasError={!!error}
60
+ testID="date-picker-android-touchable-opacity"
61
+ >
49
62
  <View pointerEvents="none" testID="datePickerInputAndroid">
50
63
  <InputComponent
64
+ {...inputProps}
51
65
  label={label}
52
66
  value={displayValue}
53
67
  suffix="calendar-dates-outlined"
@@ -81,7 +95,7 @@ const DatePickerAndroid = ({
81
95
  onChange={onChange}
82
96
  variant={variant}
83
97
  />
84
- </TouchableOpacity>
98
+ </StyledTouchableOpacity>
85
99
  );
86
100
  };
87
101
 
@@ -1,5 +1,5 @@
1
- import React, { useState } from 'react';
2
- import { Platform, ScrollView, TouchableOpacity, View } from 'react-native';
1
+ import React, { useState, useCallback } from 'react';
2
+ import { Platform, ScrollView, View } from 'react-native';
3
3
 
4
4
  import BottomSheet from '../BottomSheet';
5
5
  import Button from '../Button';
@@ -7,6 +7,7 @@ import Calendar, { CalendarProps } from '../Calendar';
7
7
  import TextInput from '../TextInput';
8
8
  import useCalculateDate from './hooks/useCalculateDate';
9
9
  import useFormatDate from './hooks/useFormatDate';
10
+ import { StyledTouchableOpacity } from './StyledDatePicker';
10
11
  import type { InternalDatePickerProps } from './types';
11
12
 
12
13
  const InternalCalendar = ({
@@ -81,6 +82,8 @@ const DatePickerCalendar = ({
81
82
  renderSelectedValue,
82
83
  locale,
83
84
  TextInputComponent,
85
+ inputProps,
86
+ groupStyleEnabled = false,
84
87
  }: Omit<InternalDatePickerProps, 'variant'>) => {
85
88
  const [open, setOpen] = useState(false);
86
89
  const [monthPickerVisible, setMonthPickerVisible] = useState(false);
@@ -98,10 +101,21 @@ const DatePickerCalendar = ({
98
101
 
99
102
  const InputComponent = TextInputComponent || TextInput;
100
103
 
104
+ const onPress = useCallback(() => {
105
+ setOpen(true);
106
+ }, []);
107
+
101
108
  return (
102
- <TouchableOpacity onPress={() => setOpen(true)} disabled={disabled}>
109
+ <StyledTouchableOpacity
110
+ onPress={onPress}
111
+ disabled={disabled}
112
+ themeGroupStyleEnabled={groupStyleEnabled}
113
+ themeHasError={!!error}
114
+ testID="date-picker-calendar-touchable-opacity"
115
+ >
103
116
  <View pointerEvents="none" testID="datePickerCalendar">
104
117
  <InputComponent
118
+ {...inputProps}
105
119
  label={label}
106
120
  value={displayValue}
107
121
  suffix="calendar-dates-outlined"
@@ -158,7 +172,7 @@ const DatePickerCalendar = ({
158
172
  />
159
173
  </ScrollView>
160
174
  </BottomSheet>
161
- </TouchableOpacity>
175
+ </StyledTouchableOpacity>
162
176
  );
163
177
  };
164
178
 
@@ -1,11 +1,12 @@
1
- import React, { useState } from 'react';
2
- import { TouchableOpacity, View } from 'react-native';
1
+ import React, { useState, useCallback } from 'react';
2
+ import { View } from 'react-native';
3
3
 
4
4
  import { useLocale } from '../LocaleProvider/hooks';
5
5
  import TextInput from '../TextInput';
6
6
  import IOSDatePickerDialog from './Dialog/IOSDialog';
7
7
  import useCalculateDate from './hooks/useCalculateDate';
8
8
  import useFormatDate from './hooks/useFormatDate';
9
+ import { StyledTouchableOpacity } from './StyledDatePicker';
9
10
  import type { InternalDatePickerProps } from './types';
10
11
 
11
12
  type DatePickerIOSProps = Omit<
@@ -34,6 +35,8 @@ const DatePickerIOS = ({
34
35
  locale,
35
36
  renderSelectedValue,
36
37
  TextInputComponent,
38
+ inputProps,
39
+ groupStyleEnabled = false,
37
40
  }: DatePickerIOSProps) => {
38
41
  const [open, setOpen] = useState(false);
39
42
  const { lang: defaultLocale } = useLocale();
@@ -47,10 +50,21 @@ const DatePickerIOS = ({
47
50
 
48
51
  const InputComponent = TextInputComponent || TextInput;
49
52
 
53
+ const onPress = useCallback(() => {
54
+ setOpen(true);
55
+ }, []);
56
+
50
57
  return (
51
- <TouchableOpacity onPress={() => setOpen(true)} disabled={disabled}>
58
+ <StyledTouchableOpacity
59
+ onPress={onPress}
60
+ disabled={disabled}
61
+ themeGroupStyleEnabled={groupStyleEnabled}
62
+ themeHasError={!!error}
63
+ testID="date-picker-ios-touchable-opacity"
64
+ >
52
65
  <View pointerEvents="none" testID="datePickerInputIOS">
53
66
  <InputComponent
67
+ {...inputProps}
54
68
  label={label}
55
69
  value={displayValue}
56
70
  suffix="calendar-dates-outlined"
@@ -88,7 +102,7 @@ const DatePickerIOS = ({
88
102
  minDate={minDate}
89
103
  maxDate={maxDate}
90
104
  />
91
- </TouchableOpacity>
105
+ </StyledTouchableOpacity>
92
106
  );
93
107
  };
94
108
 
@@ -1,5 +1,5 @@
1
1
  import styled from '@emotion/native';
2
- import { View } from 'react-native';
2
+ import { View, TouchableOpacity } from 'react-native';
3
3
  import type { ViewProps } from 'react-native';
4
4
 
5
5
  const StyledPickerWrapper = styled(View)<ViewProps>(({ theme }) => ({
@@ -7,4 +7,21 @@ const StyledPickerWrapper = styled(View)<ViewProps>(({ theme }) => ({
7
7
  alignItems: 'center',
8
8
  }));
9
9
 
10
- export { StyledPickerWrapper };
10
+ const getZIndexByState = ({ themeHasError }: { themeHasError: boolean }) => {
11
+ if (themeHasError) {
12
+ return 1;
13
+ }
14
+
15
+ return 0;
16
+ };
17
+
18
+ const StyledTouchableOpacity = styled(TouchableOpacity)<{
19
+ themeGroupStyleEnabled: boolean;
20
+ themeHasError: boolean;
21
+ }>(({ themeGroupStyleEnabled, themeHasError }) => ({
22
+ ...(themeGroupStyleEnabled && {
23
+ zIndex: getZIndexByState({ themeHasError }),
24
+ }),
25
+ }));
26
+
27
+ export { StyledPickerWrapper, StyledTouchableOpacity };
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import { Platform } from 'react-native';
3
3
  import { fireEvent } from '@testing-library/react-native';
4
- import DatePicker from '..';
4
+ // Use internal import for full prop support
5
+ import DatePicker from '../index.internal';
5
6
  import renderWithTheme from '../../../testHelpers/renderWithTheme';
6
7
  import { Button, Typography } from '../../..';
7
8
 
@@ -57,6 +58,106 @@ describe('DatePicker', () => {
57
58
  expect(getByTestId('datePickerCalendar')).toBeDefined();
58
59
  });
59
60
 
61
+ it('renders correctly when inputProps loading is true', () => {
62
+ Platform.OS = 'ios';
63
+ const { getByTestId } = renderWithTheme(
64
+ <DatePicker
65
+ label="Start date"
66
+ value={new Date('1995-12-17T00:00:00.000Z')}
67
+ minDate={new Date('1994-12-17T00:00:00.000Z')}
68
+ maxDate={new Date('1996-12-17T00:00:00.000Z')}
69
+ confirmLabel="Confirm"
70
+ inputProps={{ loading: true }}
71
+ onChange={jest.fn()}
72
+ />
73
+ );
74
+
75
+ expect(getByTestId('input-suffix')).toHaveProp('name', 'loading');
76
+ });
77
+
78
+ it('renders correctly when groupStyleEnabled is true and no error', () => {
79
+ Platform.OS = 'ios';
80
+ const { getByTestId } = renderWithTheme(
81
+ <DatePicker
82
+ label="Start date"
83
+ value={new Date('1995-12-17T00:00:00.000Z')}
84
+ minDate={new Date('1994-12-17T00:00:00.000Z')}
85
+ maxDate={new Date('1996-12-17T00:00:00.000Z')}
86
+ confirmLabel="Confirm"
87
+ groupStyleEnabled
88
+ onChange={jest.fn()}
89
+ />
90
+ );
91
+
92
+ const touchableOpacity = getByTestId('date-picker-ios-touchable-opacity');
93
+ expect(touchableOpacity).toBeTruthy();
94
+ expect(touchableOpacity.props.style).toHaveProperty('zIndex', 0);
95
+ });
96
+
97
+ it('renders correctly when groupStyleEnabled is true and has error', () => {
98
+ Platform.OS = 'ios';
99
+ const { getByTestId } = renderWithTheme(
100
+ <DatePicker
101
+ label="Start date"
102
+ value={new Date('1995-12-17T00:00:00.000Z')}
103
+ minDate={new Date('1994-12-17T00:00:00.000Z')}
104
+ maxDate={new Date('1996-12-17T00:00:00.000Z')}
105
+ confirmLabel="Confirm"
106
+ groupStyleEnabled
107
+ error="This field is required"
108
+ onChange={jest.fn()}
109
+ />
110
+ );
111
+
112
+ const touchableOpacity = getByTestId('date-picker-ios-touchable-opacity');
113
+ expect(touchableOpacity).toBeTruthy();
114
+ expect(touchableOpacity.props.style).toHaveProperty('zIndex', 1);
115
+ });
116
+
117
+ it('renders correctly when groupStyleEnabled is true and has error for Android', () => {
118
+ Platform.OS = 'android';
119
+ const { getByTestId } = renderWithTheme(
120
+ <DatePicker
121
+ label="Start date"
122
+ value={new Date('1995-12-17T00:00:00.000Z')}
123
+ minDate={new Date('1994-12-17T00:00:00.000Z')}
124
+ maxDate={new Date('1996-12-17T00:00:00.000Z')}
125
+ confirmLabel="Confirm"
126
+ groupStyleEnabled
127
+ error="This field is required"
128
+ onChange={jest.fn()}
129
+ />
130
+ );
131
+
132
+ const touchableOpacity = getByTestId(
133
+ 'date-picker-android-touchable-opacity'
134
+ );
135
+ expect(touchableOpacity).toBeTruthy();
136
+ expect(touchableOpacity.props.style).toHaveProperty('zIndex', 1);
137
+ });
138
+
139
+ it('renders correctly when groupStyleEnabled is true and has error for Calendar variant', () => {
140
+ const { getByTestId } = renderWithTheme(
141
+ <DatePicker
142
+ label="Start date"
143
+ value={new Date('1995-12-17T00:00:00.000Z')}
144
+ minDate={new Date('1994-12-17T00:00:00.000Z')}
145
+ maxDate={new Date('1996-12-17T00:00:00.000Z')}
146
+ confirmLabel="Confirm"
147
+ variant="calendar"
148
+ groupStyleEnabled
149
+ error="This field is required"
150
+ onChange={jest.fn()}
151
+ />
152
+ );
153
+
154
+ const touchableOpacity = getByTestId(
155
+ 'date-picker-calendar-touchable-opacity'
156
+ );
157
+ expect(touchableOpacity).toBeTruthy();
158
+ expect(touchableOpacity.props.style).toHaveProperty('zIndex', 1);
159
+ });
160
+
60
161
  it.each`
61
162
  OS | variant
62
163
  ${'ios'} | ${'calendar'}