@npm_leadtech/legal-lib-components 5.14.9 → 5.14.11

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.
@@ -5,7 +5,8 @@ import { de } from 'date-fns/locale';
5
5
  import { DatePickerCustomStyled } from './DatePickerCustom.styled';
6
6
  // import './DatepickerPlugin.scss'
7
7
  registerLocale('de', de);
8
- const DatePickerCustom = ({ class: className, dateFormat = 'MM/dd/yyyy', isStartDate = false, isValidGroup = false, label, locale = 'en', name, onChange, relatedDate, tooltip, type, validate = false, value }) => {
8
+ const DatePickerCustom = ({ class: className, dateFormat = 'MM/dd/yyyy', isStartDate = false, isValidGroup = false, label, locale = 'en', name, onChange, relatedDate, isMobile, tooltip, type, validate = false, value }) => {
9
+ const [event, setEvent] = useState();
9
10
  const [date, setDate] = useState(() => {
10
11
  return typeof value === 'string' && value !== '' ? new Date(value) : null;
11
12
  });
@@ -57,7 +58,26 @@ const DatePickerCustom = ({ class: className, dateFormat = 'MM/dd/yyyy', isStart
57
58
  monthName
58
59
  };
59
60
  });
60
- return (_jsxs(DatePickerCustomStyled, { className: classStyle, "data-qa": name, children: [TooltipObject, _jsx(DatePicker, { locale: locale, dateFormat: dateFormat, renderCustomHeader: ({ date, changeYear, changeMonth, decreaseMonth, increaseMonth, prevMonthButtonDisabled, nextMonthButtonDisabled }) => (_jsxs("div", { style: {
61
+ let propsForMobileDevices = {};
62
+ if (isMobile) {
63
+ propsForMobileDevices = {
64
+ portalId: 'root-portal',
65
+ withPortal: true,
66
+ onFocus: (event) => {
67
+ setEvent(event);
68
+ event.target.blur();
69
+ },
70
+ onCalendarClose: () => {
71
+ if (event) {
72
+ const timmerID = setTimeout(() => {
73
+ event.target.blur();
74
+ clearTimeout(timmerID);
75
+ }, 1);
76
+ }
77
+ }
78
+ };
79
+ }
80
+ return (_jsxs(DatePickerCustomStyled, { className: classStyle, "data-qa": name, children: [TooltipObject, _jsx(DatePicker, { ...propsForMobileDevices, locale: locale, dateFormat: dateFormat, renderCustomHeader: ({ date, changeYear, changeMonth, decreaseMonth, increaseMonth, prevMonthButtonDisabled, nextMonthButtonDisabled }) => (_jsxs("div", { style: {
61
81
  margin: 10,
62
82
  display: 'flex',
63
83
  justifyContent: 'center'
@@ -18,11 +18,13 @@ const DatePickerCustom: FC<DatePickerCustomProps> = ({
18
18
  name,
19
19
  onChange,
20
20
  relatedDate,
21
+ isMobile,
21
22
  tooltip,
22
23
  type,
23
24
  validate = false,
24
25
  value
25
26
  }): React.JSX.Element => {
27
+ const [event, setEvent] = useState<React.ChangeEvent<HTMLInputElement>>()
26
28
  const [date, setDate] = useState(() => {
27
29
  return typeof value === 'string' && value !== '' ? new Date(value) : null
28
30
  })
@@ -90,10 +92,32 @@ const DatePickerCustom: FC<DatePickerCustomProps> = ({
90
92
  }
91
93
  })
92
94
 
95
+ let propsForMobileDevices = {}
96
+
97
+ if (isMobile) {
98
+ propsForMobileDevices = {
99
+ portalId: 'root-portal',
100
+ withPortal: true,
101
+ onFocus: (event) => {
102
+ setEvent(event)
103
+ event.target.blur()
104
+ },
105
+ onCalendarClose: () => {
106
+ if (event) {
107
+ const timmerID = setTimeout(() => {
108
+ event.target.blur()
109
+ clearTimeout(timmerID)
110
+ }, 1)
111
+ }
112
+ }
113
+ }
114
+ }
115
+
93
116
  return (
94
117
  <DatePickerCustomStyled className={classStyle} data-qa={name}>
95
118
  {TooltipObject}
96
119
  <DatePicker
120
+ {...propsForMobileDevices}
97
121
  locale={locale}
98
122
  dateFormat={dateFormat}
99
123
  renderCustomHeader={({
@@ -13,5 +13,6 @@ export interface DatePickerCustomProps {
13
13
  relatedDate?: Date;
14
14
  type?: string;
15
15
  dateFormat?: string;
16
+ isMobile?: boolean;
16
17
  onChange?: (dateObject: any) => void;
17
18
  }
@@ -14,5 +14,6 @@ export interface DatePickerCustomProps {
14
14
  relatedDate?: Date
15
15
  type?: string
16
16
  dateFormat?: string
17
+ isMobile?: boolean
17
18
  onChange?: (dateObject: any) => void
18
19
  }