@geneui/components 3.0.0-next-06dadf3-29102024 → 3.0.0-next-48d0ef7-31102024

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 (247) hide show
  1. package/Avatar.js +63 -0
  2. package/Divider.js +23 -0
  3. package/{GeneUIProvider/index.js → GeneUIProvider.js} +51 -64
  4. package/HelperText.js +69 -0
  5. package/Info.js +64 -0
  6. package/Label.js +38 -0
  7. package/Loader.js +21 -0
  8. package/Pill.js +64 -0
  9. package/TextLink.js +20 -0
  10. package/{index-c7646e48.js → Tooltip.js} +101 -79
  11. package/{lib → components}/atoms/Avatar/Avatar.d.ts +7 -6
  12. package/components/atoms/Avatar/index.d.ts +1 -0
  13. package/{lib → components}/atoms/Divider/Divider.d.ts +5 -5
  14. package/components/atoms/Divider/index.d.ts +1 -0
  15. package/{lib → components}/atoms/HelperText/HelperText.d.ts +6 -5
  16. package/components/atoms/HelperText/index.d.ts +1 -0
  17. package/{lib → components}/atoms/Info/Info.d.ts +5 -5
  18. package/components/atoms/Info/index.d.ts +1 -0
  19. package/{lib → components}/atoms/Label/Label.d.ts +3 -3
  20. package/components/atoms/Label/index.d.ts +1 -0
  21. package/{lib → components}/atoms/Loader/Loader.d.ts +5 -5
  22. package/components/atoms/Loader/index.d.ts +1 -0
  23. package/{lib → components}/atoms/Pill/Pill.d.ts +7 -6
  24. package/components/atoms/Pill/index.d.ts +1 -0
  25. package/{lib → components}/atoms/TextLink/TextLink.d.ts +5 -5
  26. package/components/atoms/TextLink/index.d.ts +1 -0
  27. package/{lib → components}/molecules/Tooltip/Tooltip.d.ts +26 -21
  28. package/components/molecules/Tooltip/index.d.ts +1 -0
  29. package/components/providers/GeneUIProvider/GeneUIProvider.d.ts +30 -0
  30. package/components/providers/GeneUIProvider/index.d.ts +1 -0
  31. package/hooks/index.d.ts +2 -20
  32. package/hooks/useDebounceCallback/index.d.ts +1 -0
  33. package/hooks/useDebounceCallback/useDebounceCallback.d.ts +2 -0
  34. package/hooks/useEllipsisDetection/index.d.ts +1 -1
  35. package/hooks/useEllipsisDetection/useEllipsisDetection.d.ts +2 -2
  36. package/{index-031ff73c.js → index-ce02421b.js} +4 -4
  37. package/index.d.ts +11 -121
  38. package/index.js +12 -159
  39. package/package.json +24 -43
  40. package/tokens-0abb4e1b.js +6 -0
  41. package/types/index.d.ts +0 -3
  42. package/useEllipsisDetection-46d712b6.js +34 -0
  43. package/ActionableList/index.js +0 -1694
  44. package/AdvancedSearch/index.js +0 -892
  45. package/Alert/index.js +0 -98
  46. package/Avatar/index.js +0 -58
  47. package/Badge/index.js +0 -29
  48. package/Breadcrumb/index.js +0 -130
  49. package/BusyLoader/index.js +0 -31
  50. package/Button/index.js +0 -30
  51. package/Card/index.js +0 -502
  52. package/CardList/index.js +0 -662
  53. package/CellMeasurerCache-26f3693c.js +0 -229
  54. package/Charts/index.js +0 -17662
  55. package/Checkbox/index.js +0 -229
  56. package/CheckboxGroup/index.js +0 -203
  57. package/CheckboxGroupWithSearch/index.js +0 -280
  58. package/Collapse/index.js +0 -195
  59. package/ColorPicker/index.js +0 -210
  60. package/ComboBox/index.js +0 -524
  61. package/Copy/index.js +0 -56
  62. package/Counter/index.js +0 -312
  63. package/DateFilter/index.js +0 -183
  64. package/DatePicker/index.js +0 -1229
  65. package/DatePickerInput/index.js +0 -883
  66. package/Divider/index.js +0 -23
  67. package/Drawer/index.js +0 -261
  68. package/Dropdown/index.js +0 -43
  69. package/Editor/index.js +0 -22975
  70. package/Empty/index.js +0 -76
  71. package/ExtendedInput/index.js +0 -590
  72. package/Form/index.js +0 -85
  73. package/FormContainer/index.js +0 -189
  74. package/FormableCheckbox/index.js +0 -24
  75. package/FormableDatePicker/index.js +0 -43
  76. package/FormableDropdown/index.js +0 -50
  77. package/FormableEditor/index.js +0 -26
  78. package/FormableHOC-85f89a81.js +0 -83
  79. package/FormableMultiSelectDropdown/index.js +0 -50
  80. package/FormableNumberInput/index.js +0 -34
  81. package/FormableRadio/index.js +0 -22
  82. package/FormableSwitcher/index.js +0 -22
  83. package/FormableTextInput/index.js +0 -34
  84. package/FormableUploader/index.js +0 -44
  85. package/Grid/index.js +0 -167
  86. package/HelperText/index.js +0 -86
  87. package/Holder/index.js +0 -261
  88. package/Icon/index.js +0 -62
  89. package/Image/index.js +0 -45
  90. package/ImagePreview/index.js +0 -217
  91. package/Info/index.js +0 -41
  92. package/InfoOutline-dd2e89d9.js +0 -29
  93. package/InteractiveWidget/index.js +0 -78
  94. package/KeyValue/index.js +0 -22
  95. package/Label/index.js +0 -48
  96. package/LinkButton/index.js +0 -34
  97. package/Loader/index.js +0 -23
  98. package/Menu/index.js +0 -281
  99. package/MobileNavigation/index.js +0 -94
  100. package/MobilePopup/index.js +0 -182
  101. package/Modal/index.js +0 -251
  102. package/ModuleTitle/index.js +0 -141
  103. package/NavigationMenu/index.js +0 -222
  104. package/Notification/index.js +0 -120
  105. package/Option/index.js +0 -184
  106. package/Overlay/index.js +0 -187
  107. package/Overspread/index.js +0 -291
  108. package/Pagination/index.js +0 -261
  109. package/Paper/index.js +0 -96
  110. package/Pill/index.js +0 -67
  111. package/Popover/index.js +0 -725
  112. package/PopoverV2/index.js +0 -19
  113. package/Portal/index.js +0 -58
  114. package/Products/index.js +0 -115
  115. package/Profile/index.js +0 -589
  116. package/Progress/index.js +0 -200
  117. package/QRCode/index.js +0 -814
  118. package/Radio/index.js +0 -151
  119. package/RadioGroup/index.js +0 -104
  120. package/Range/index.js +0 -191
  121. package/Rating/index.js +0 -174
  122. package/RichEditor/index.js +0 -13
  123. package/RichEditor-6ca8346f.js +0 -228
  124. package/Scrollbar/index.js +0 -1585
  125. package/Search/index.js +0 -75
  126. package/SearchWithDropdown/index.js +0 -140
  127. package/Section/index.js +0 -61
  128. package/SkeletonLoader/index.js +0 -81
  129. package/Slider/index.js +0 -261
  130. package/Status/index.js +0 -97
  131. package/Steps/index.js +0 -314
  132. package/SuggestionList/index.js +0 -385
  133. package/Switcher/index.js +0 -193
  134. package/Table/index.js +0 -57
  135. package/TableCompositions/index.js +0 -16995
  136. package/Tabs/index.js +0 -235
  137. package/Tag/index.js +0 -102
  138. package/TextLink/index.js +0 -20
  139. package/Textarea/index.js +0 -242
  140. package/Time/index.js +0 -62
  141. package/TimePicker/index.js +0 -575
  142. package/Timeline/index.js +0 -113
  143. package/Title/index.js +0 -65
  144. package/Toaster/index.js +0 -116
  145. package/Tooltip/index.js +0 -6
  146. package/TransferList/index.js +0 -493
  147. package/Uploader/index.js +0 -992
  148. package/ValidatableCheckbox/index.js +0 -123
  149. package/ValidatableDatePicker/index.js +0 -316
  150. package/ValidatableDropdown/index.js +0 -141
  151. package/ValidatableElements/index.js +0 -67
  152. package/ValidatableMultiSelectDropdown/index.js +0 -152
  153. package/ValidatableNumberInput/index.js +0 -204
  154. package/ValidatableRadio/index.js +0 -116
  155. package/ValidatableSwitcher/index.js +0 -93
  156. package/ValidatableTextInput/index.js +0 -167
  157. package/ValidatableTimeInput/index.js +0 -174
  158. package/ValidatableUploader/index.js +0 -98
  159. package/Widget/index.js +0 -225
  160. package/_commonjsHelpers-24198af3.js +0 -35
  161. package/_rollupPluginBabelHelpers-a83240e1.js +0 -11
  162. package/callAfterDelay-7272faca.js +0 -12
  163. package/checkTimeValidation-e56771be.js +0 -16
  164. package/checkboxRadioSwitcher-5b69d7bd.js +0 -4
  165. package/clsx.m-2bb6df4b.js +0 -3
  166. package/config-1053d64d.js +0 -20
  167. package/configs-00612ce0.js +0 -103
  168. package/configs.js +0 -111
  169. package/dateValidation-67caec66.js +0 -225
  170. package/debounce-4419bc2f.js +0 -17
  171. package/guid-8ddf77b3.js +0 -16
  172. package/hooks/useBodyScroll.js +0 -16
  173. package/hooks/useClick.js +0 -18
  174. package/hooks/useClickOutside.js +0 -25
  175. package/hooks/useDebounce.js +0 -28
  176. package/hooks/useDeviceType.js +0 -17
  177. package/hooks/useDidMount.js +0 -15
  178. package/hooks/useForceUpdate.js +0 -8
  179. package/hooks/useHover.js +0 -20
  180. package/hooks/useImgDownload.js +0 -18
  181. package/hooks/useKeyDown.js +0 -21
  182. package/hooks/useMount.js +0 -13
  183. package/hooks/useMutationObserver.js +0 -21
  184. package/hooks/usePrevious.js +0 -10
  185. package/hooks/useThrottle.js +0 -16
  186. package/hooks/useToggle.js +0 -11
  187. package/hooks/useUpdatableRef.js +0 -14
  188. package/hooks/useUpdate.js +0 -10
  189. package/hooks/useWidth.js +0 -16
  190. package/hooks/useWindowSize.js +0 -40
  191. package/index-122432cd.js +0 -270
  192. package/index-262edd7a.js +0 -77
  193. package/index-3188e46e.js +0 -1940
  194. package/index-45eafea6.js +0 -90
  195. package/index-5f37f281.js +0 -168
  196. package/index-ce12e4a9.js +0 -10032
  197. package/index-d0ecb950.js +0 -6483
  198. package/index-fcbae78d.js +0 -4
  199. package/index.mobile.d.ts +0 -14
  200. package/lib/atoms/Avatar/index.d.ts +0 -1
  201. package/lib/atoms/Badge/Badge.d.ts +0 -36
  202. package/lib/atoms/Badge/index.d.ts +0 -1
  203. package/lib/atoms/BusyLoader/BusyLoader.d.ts +0 -32
  204. package/lib/atoms/BusyLoader/BusyLoaderHolderHOC.d.ts +0 -8
  205. package/lib/atoms/BusyLoader/index.d.ts +0 -1
  206. package/lib/atoms/Button/Button.d.ts +0 -70
  207. package/lib/atoms/Button/index.d.ts +0 -1
  208. package/lib/atoms/Divider/index.d.ts +0 -1
  209. package/lib/atoms/Empty/Empty.d.ts +0 -39
  210. package/lib/atoms/Empty/index.d.ts +0 -1
  211. package/lib/atoms/Empty/utils.d.ts +0 -9
  212. package/lib/atoms/HelperText/index.d.ts +0 -1
  213. package/lib/atoms/Image/Image.d.ts +0 -51
  214. package/lib/atoms/Image/index.d.ts +0 -1
  215. package/lib/atoms/ImagePreview/ImagePreview.d.ts +0 -56
  216. package/lib/atoms/ImagePreview/ImagePreviewHOC.d.ts +0 -4
  217. package/lib/atoms/ImagePreview/Magnifier.d.ts +0 -40
  218. package/lib/atoms/ImagePreview/index.d.ts +0 -1
  219. package/lib/atoms/Info/index.d.ts +0 -1
  220. package/lib/atoms/KeyValue/KeyValue.d.ts +0 -29
  221. package/lib/atoms/KeyValue/index.d.ts +0 -1
  222. package/lib/atoms/Label/index.d.ts +0 -1
  223. package/lib/atoms/LinkButton/LinkButton.d.ts +0 -46
  224. package/lib/atoms/LinkButton/index.d.ts +0 -1
  225. package/lib/atoms/Loader/index.d.ts +0 -1
  226. package/lib/atoms/Pill/index.d.ts +0 -1
  227. package/lib/atoms/Rating/DefaultSvg.d.ts +0 -3
  228. package/lib/atoms/Rating/Rating.d.ts +0 -49
  229. package/lib/atoms/Rating/index.d.ts +0 -1
  230. package/lib/atoms/TextLink/index.d.ts +0 -1
  231. package/lib/molecules/Copy/Copy.d.ts +0 -38
  232. package/lib/molecules/Copy/index.d.ts +0 -1
  233. package/lib/molecules/InteractiveWidget/InteractiveWidget.d.ts +0 -70
  234. package/lib/molecules/InteractiveWidget/InteractiveWidgetIcon.d.ts +0 -8
  235. package/lib/molecules/InteractiveWidget/index.d.ts +0 -1
  236. package/lib/molecules/Tooltip/index.d.ts +0 -1
  237. package/lib/providers/GeneUIProvider/GeneUIProvider.d.ts +0 -30
  238. package/lib/providers/GeneUIProvider/index.d.ts +0 -1
  239. package/localization-4ba17032.js +0 -46
  240. package/objectWithoutPropertiesLoose-e1596bdb.js +0 -62
  241. package/rangeAndSlider-740a236c.js +0 -8676
  242. package/react-beautiful-dnd.esm-8c7b5a83.js +0 -10116
  243. package/react-lifecycles-compat.es-6e1f3768.js +0 -158
  244. package/redux-e591c1b8.js +0 -536
  245. package/tokens-8ab1179c.js +0 -6
  246. package/tslib.es6-f211516f.js +0 -35
  247. package/useEllipsisDetection-c1c9ad94.js +0 -38
@@ -1,883 +0,0 @@
1
- import { s as styleInject } from '../style-inject.es-746bb8ed.js';
2
- import { _ as _extends } from '../_rollupPluginBabelHelpers-a83240e1.js';
3
- import React__default, { useMemo, useState, useRef, useCallback, useEffect } from 'react';
4
- import PropTypes from 'prop-types';
5
- import { d as dayjsWithPlugins, a as dayjs } from '../dateValidation-67caec66.js';
6
- import { c as classnames } from '../index-031ff73c.js';
7
- import { g as popoverConfig, i as inputConfig } from '../configs-00612ce0.js';
8
- import { n as noop, s as stopEvent } from '../index-5f37f281.js';
9
- import useClick from '../hooks/useClick.js';
10
- import useKeyDown from '../hooks/useKeyDown.js';
11
- import useDeviceType from '../hooks/useDeviceType.js';
12
- import { P as PopoverV2 } from '../index-3188e46e.js';
13
- import ExtendedInput from '../ExtendedInput/index.js';
14
- import DatePicker from '../DatePicker/index.js';
15
- import { g as getBrowserDateFormat } from '../localization-4ba17032.js';
16
- import '../_commonjsHelpers-24198af3.js';
17
- import 'react-dom';
18
- import '../hooks/useWindowSize.js';
19
- import '../hooks/useDebounce.js';
20
- import '../index-122432cd.js';
21
- import '../hooks/useClickOutside.js';
22
- import '../Scrollbar/index.js';
23
- import '../GeneUIProvider/index.js';
24
- import '../debounce-4419bc2f.js';
25
- import '../useEllipsisDetection-c1c9ad94.js';
26
- import '../Icon/index.js';
27
- import '../SuggestionList/index.js';
28
- import '../config-1053d64d.js';
29
- import '../callAfterDelay-7272faca.js';
30
- import '../index-c7646e48.js';
31
- import '../tslib.es6-f211516f.js';
32
- import '../guid-8ddf77b3.js';
33
- import '../Button/index.js';
34
-
35
- var css_248z = "[data-gene-ui-version=\"2.16.4\"] .mobile-date-ranges-holder{width:100%}[data-gene-ui-version=\"2.16.4\"] .md-range-title{font:600 1.6rem/2.2rem var(--font-family);margin:0 0 1.5rem;padding:0 1rem}[data-gene-ui-version=\"2.16.4\"] .default-cursor{cursor:default!important}[data-gene-ui-version=\"2.16.4\"] .text-cursor{cursor:text}[data-gene-ui-version=\"2.16.4\"] .mobile-date-ranges-picker{grid-column-gap:2rem;grid-row-gap:2rem;display:grid;grid-template-areas:\"m-start-date m-end-date\";grid-template-columns:repeat(2,calc(50% - 1rem));width:100%}[data-gene-ui-version=\"2.16.4\"] .mobile-date-ranges-picker.with-time{grid-template-areas:\"m-start-date m-start-time\" \"m-end-date m-end-time\";grid-template-columns:calc(55% - 1rem) calc(45% - 1rem)}[data-gene-ui-version=\"2.16.4\"] .mobile-date-ranges-picker .m-start-date{grid-area:m-start-date}[data-gene-ui-version=\"2.16.4\"] .mobile-date-ranges-picker .m-end-date{grid-area:m-end-date}[data-gene-ui-version=\"2.16.4\"] .mobile-date-ranges-picker .m-start-time{grid-area:m-start-time}[data-gene-ui-version=\"2.16.4\"] .mobile-date-ranges-picker .m-end-time{grid-area:m-end-time}[data-gene-ui-version=\"2.16.4\"] .mobile-date-ranges-picker i[class*=calendar],[data-gene-ui-version=\"2.16.4\"] .mobile-single-date-picker i[class*=calendar]{order:-2;pointer-events:none}[data-gene-ui-version=\"2.16.4\"] .mobile-date-ranges-picker i[class*=clear],[data-gene-ui-version=\"2.16.4\"] .mobile-single-date-picker i[class*=clear]{order:-1}[data-gene-ui-version=\"2.16.4\"] .date-input .input-structure>label{height:var(--input-element-height)}[data-gene-ui-version=\"2.16.4\"] .date-input .input-structure>.icon+label input{padding-inline:2rem 4.4rem}[data-gene-ui-version=\"2.16.4\"] .date-input .input-structure .input-element-relative{left:0;position:absolute;width:100%}[data-gene-ui-version=\"2.16.4\"] .date-input .input-structure .input-element-relative>input{padding-inline:2rem 1.5rem;padding-inline-end:6.4rem}[data-gene-ui-version=\"2.16.4\"] .date-input .input-structure .input-element-relative>.read-only{padding-inline:2rem 1.5rem}[data-gene-ui-version=\"2.16.4\"] .date-input i[class*=calendar]{order:-2}[data-gene-ui-version=\"2.16.4\"] .date-input i[class*=clear]{order:-1}[data-gene-ui-version=\"2.16.4\"] .mobile-date-ranges-picker .bc-icon-calendar,[data-gene-ui-version=\"2.16.4\"] .mobile-date-ranges-picker .bc-icon.clock,[data-gene-ui-version=\"2.16.4\"] .mobile-single-date-picker .bc-icon-calendar,[data-gene-ui-version=\"2.16.4\"] .mobile-single-date-picker .bc-icon.clock{pointer-events:none}";
36
- styleInject(css_248z);
37
-
38
- const getLastValidValue$1 = (date, validFormat) => date && date.isValid() ? date.format(validFormat) : '';
39
- function DatePickerInput(_ref) {
40
- let {
41
- min,
42
- max,
43
- size,
44
- title,
45
- value,
46
- onBlur,
47
- onFocus,
48
- isValid,
49
- required,
50
- onChange,
51
- readOnly,
52
- disabled,
53
- className,
54
- appearance,
55
- pickerProps,
56
- flexibility,
57
- popoverAlign,
58
- withoutPicker,
59
- withTime,
60
- format: dateFormat,
61
- placeholder: inputPlaceholder,
62
- markedDate,
63
- frozenDateRange,
64
- clearable,
65
- ...restProps
66
- } = _ref;
67
- const {
68
- isMobile
69
- } = useDeviceType();
70
- const maxDate = max && dayjsWithPlugins(max);
71
- const minDate = min && dayjsWithPlugins(min);
72
- const mobileFormat = useMemo(() => withTime ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD', [withTime]);
73
- const defaultFormat = useMemo(() => withTime ? 'DD/MM/YYYY HH:mm:ss' : 'DD/MM/YYYY', [withTime]);
74
- const format = useMemo(() => dateFormat || defaultFormat, [dateFormat, defaultFormat]);
75
- const placeholder = useMemo(() => inputPlaceholder || format, [inputPlaceholder, format]);
76
- const validFormat = useMemo(() => isMobile ? mobileFormat : format, [isMobile, mobileFormat, format]);
77
- const [date, setDate] = useState('');
78
- const [inputValue, setInputValue] = useState('');
79
- const [popoverOpened, setPopoverState] = useState(false);
80
- const setPickerRef = useClick(e => {
81
- e.preventDefault();
82
- });
83
- const inputRef = useRef();
84
- const handleChange = useCallback(value => {
85
- const date = dayjsWithPlugins(value);
86
- if (!withTime) {
87
- setPopoverState(false);
88
- inputRef.current.blur();
89
- }
90
- setDate(date);
91
- onChange(date.toDate());
92
- setInputValue(date.format(validFormat));
93
- }, [validFormat, withTime, onChange]);
94
- const handleInputChange = useCallback(e => {
95
- const {
96
- value
97
- } = e.target;
98
- const isPM = dayjs(value.toLocaleLowerCase().replace('am', '').replace('pm', '')).hour() >= 12;
99
- const customValue = isPM ? value.replace('am', 'PM') : value.replace('pm', 'AM');
100
- let isFrozenDate = false;
101
- const date = dayjsWithPlugins(customValue, validFormat);
102
- const isValid = dayjs(date).format(validFormat) === customValue;
103
- if (frozenDateRange.length && Array.isArray(frozenDateRange)) {
104
- const format = 'YYYY/MM/DD';
105
- isFrozenDate = !!frozenDateRange.find(_ref2 => {
106
- let {
107
- from,
108
- to
109
- } = _ref2;
110
- return from && to && date.isBetween(dayjs(from).format(format), dayjs(to).format(format), 'day', '[]');
111
- });
112
- }
113
- if (!isFrozenDate) {
114
- if (isValid) {
115
- setDate(date);
116
- onChange(date.toDate());
117
- } else if (!required && value === '') {
118
- setDate('');
119
- onChange(null);
120
- }
121
- }
122
- setInputValue(value);
123
- }, [frozenDateRange, validFormat, onChange, required]);
124
- const checkDateInerval = useCallback(() => {
125
- let value = getLastValidValue$1(date, validFormat);
126
- if (!value) {
127
- return null;
128
- }
129
- const minUnix = minDate && minDate.valueOf();
130
- const maxUnix = maxDate && maxDate.valueOf();
131
- const dateUnix = date && dayjs(date, validFormat).valueOf();
132
- if (value) {
133
- if (minUnix > dateUnix) {
134
- value = minDate.format(validFormat);
135
- } else if (maxUnix < dateUnix) {
136
- value = maxDate.format(validFormat);
137
- }
138
- }
139
- handleInputChange({
140
- target: {
141
- value
142
- }
143
- });
144
- }, [date, validFormat, minDate, maxDate, handleInputChange]);
145
- const handleBlur = useCallback(e => {
146
- onBlur(e);
147
- setPopoverState(false);
148
- checkDateInerval();
149
- }, [onBlur, checkDateInerval]);
150
- const handleFocus = useCallback(e => {
151
- setPopoverState(true);
152
- onFocus(e);
153
- }, [onFocus]);
154
- const handleIconClick = useCallback((e, isBlurInitiatorCalendarIcon) => {
155
- e.stopPropagation();
156
- e.preventDefault();
157
- if (!popoverOpened && !isBlurInitiatorCalendarIcon || withoutPicker) {
158
- inputRef.current.focus();
159
- }
160
- }, [popoverOpened, withoutPicker]);
161
- useEffect(() => {
162
- const date = dayjsWithPlugins(value);
163
- if (value) {
164
- setDate(dayjsWithPlugins(date, validFormat));
165
- setInputValue(date.format(validFormat));
166
- } else if (value === null) {
167
- setDate('');
168
- setInputValue('');
169
- }
170
- }, [value, validFormat]);
171
- useKeyDown(() => setPopoverState(false), [], {
172
- current: window
173
- }, ['Escape']);
174
- const sharedProps = {
175
- flexibility,
176
- placeholder,
177
- appearance,
178
- label: title,
179
- isValid,
180
- inputSize: size,
181
- disabled,
182
- readOnly,
183
- required,
184
- ref: inputRef,
185
- canClear: clearable,
186
- ...restProps
187
- };
188
-
189
- /* *** Mobile functions *** */
190
- const mobileValue = useMemo(() => {
191
- const val = value || inputValue;
192
- return val ? dayjs(val).format(withTime ? 'YYYY-MM-DDTHH:mm' : 'YYYY-MM-DD') : '';
193
- }, [withTime, value, inputValue]);
194
- const mobileInputType = useMemo(() => withTime ? 'datetime-local' : 'date', [withTime]);
195
- const handleMobileChange = useCallback(event => {
196
- const {
197
- value
198
- } = event.target;
199
- withTime ? handleChange(value) : handleInputChange({
200
- target: {
201
- value
202
- }
203
- });
204
- }, [handleChange, handleInputChange, withTime]);
205
- return isMobile ? /*#__PURE__*/React__default.createElement(ExtendedInput, _extends({
206
- value: mobileValue,
207
- itemsDirection: "end",
208
- onKeyDown: stopEvent,
209
- type: mobileInputType,
210
- onChange: handleMobileChange,
211
- className: "mobile-single-date-picker",
212
- icon: readOnly ? '' : 'bc-icon-calendar'
213
- }, sharedProps)) : /*#__PURE__*/React__default.createElement(PopoverV2, {
214
- behave: "open",
215
- align: popoverAlign,
216
- isOpen: popoverOpened,
217
- extendTargetWidth: false,
218
- Content: !withoutPicker && /*#__PURE__*/React__default.createElement(DatePicker, _extends({
219
- value: date,
220
- min: minDate,
221
- max: maxDate,
222
- ref: setPickerRef,
223
- withTime: withTime,
224
- format: validFormat,
225
- defaultValue: value,
226
- defaultPreview: date,
227
- onChange: handleChange,
228
- onTimeChange: handleChange,
229
- className: readOnly ? 'pointer-events-none' : ''
230
- }, pickerProps, {
231
- markedDate: markedDate,
232
- frozenDateRange: frozenDateRange
233
- }))
234
- }, /*#__PURE__*/React__default.createElement(ExtendedInput, _extends({
235
- clickableIcon: true,
236
- value: inputValue,
237
- onBlur: handleBlur,
238
- itemsDirection: "end",
239
- onFocus: handleFocus,
240
- onIconClick: handleIconClick,
241
- onChange: handleInputChange,
242
- icon: readOnly ? '' : 'bc-icon-calendar',
243
- className: classnames(className, 'date-input', {
244
- 'default-cursor': readOnly || disabled,
245
- 'clearable-date-picker': clearable,
246
- 'text-cursor': withoutPicker
247
- })
248
- }, sharedProps)));
249
- }
250
- const {
251
- flexibility: flexibility$1,
252
- appearance: appearances$1,
253
- size: size$1
254
- } = inputConfig;
255
- DatePickerInput.propTypes = {
256
- /**
257
- * Controls alignment of popover
258
- */
259
- popoverAlign: PropTypes.oneOf(popoverConfig.align),
260
- /**
261
- * Controls flexibility of input element
262
- */
263
- flexibility: PropTypes.oneOf(flexibility$1),
264
- /**
265
- * Controls appearance of input element
266
- */
267
- appearance: PropTypes.oneOf(appearances$1),
268
- /**
269
- * Placeholder text for input
270
- */
271
- placeholder: PropTypes.string,
272
- /**
273
- * Disables datepicker when input is focused
274
- */
275
- withoutPicker: PropTypes.bool,
276
- /**
277
- * Accepts same props as DatePicker component(organisms)
278
- */
279
- pickerProps: PropTypes.object,
280
- /**
281
- * Min specifies the minimum value allowed for datepicker
282
- */
283
- min: PropTypes.oneOfType([PropTypes.instanceOf(dayjsWithPlugins), PropTypes.instanceOf(Date), PropTypes.string, PropTypes.number]),
284
- /**
285
- * Max specifies the maximum value allowed for datepicker
286
- */
287
- max: PropTypes.oneOfType([PropTypes.instanceOf(dayjsWithPlugins), PropTypes.instanceOf(Date), PropTypes.string, PropTypes.number]),
288
- /**
289
- * The value of the input element, required for a controlled component.
290
- */
291
- value: PropTypes.oneOfType([PropTypes.instanceOf(dayjsWithPlugins), PropTypes.instanceOf(Date), PropTypes.string, PropTypes.number]),
292
- /**
293
- * The CSS class name of the wrapper element.
294
- */
295
- className: PropTypes.string,
296
- /**
297
- * Controls input size
298
- */
299
- size: PropTypes.oneOf(size$1),
300
- /**
301
- * Custom date format
302
- */
303
- format: PropTypes.string,
304
- /**
305
- * If true, the input element will be disabled.
306
- */
307
- disabled: PropTypes.bool,
308
- /**
309
- * It prevents the user from changing the value of the field.
310
- */
311
- readOnly: PropTypes.bool,
312
- /**
313
- * If true, the input element will show icon which can reset selected date.
314
- */
315
- clearable: PropTypes.bool,
316
- /**
317
- * Callback fired when the value is changed.
318
- * function(date: Date) => void
319
- */
320
- onChange: PropTypes.func,
321
- /**
322
- * Callback fired when the input looses focus.
323
- * function(e: Event) => void
324
- */
325
- onBlur: PropTypes.func,
326
- /**
327
- * Callback fired when the input get focused.
328
- * function(e: Event) => void
329
- */
330
- onFocus: PropTypes.func,
331
- /**
332
- * If false, the input will indicate an error.
333
- */
334
- isValid: PropTypes.bool,
335
- /**
336
- * Title for input
337
- */
338
- title: PropTypes.string,
339
- /**
340
- * MarkedDate specifies the default mark date
341
- */
342
- markedDate: PropTypes.oneOfType([PropTypes.instanceOf(dayjs), PropTypes.instanceOf(Date), PropTypes.string, PropTypes.number]),
343
- /**
344
- * Prop is responsible for disabling selected range
345
- */
346
- frozenDateRange: PropTypes.arrayOf(PropTypes.shape({
347
- from: PropTypes.oneOfType([PropTypes.instanceOf(dayjs), PropTypes.instanceOf(Date), PropTypes.string, PropTypes.number]).isRequired,
348
- to: PropTypes.oneOfType([PropTypes.instanceOf(dayjs), PropTypes.instanceOf(Date), PropTypes.string, PropTypes.number]).isRequired
349
- }))
350
- };
351
- DatePickerInput.defaultProps = {
352
- popoverAlign: popoverConfig.align[1],
353
- flexibility: flexibility$1[0],
354
- appearance: appearances$1[0],
355
- title: 'Datepicker',
356
- onChange: noop,
357
- onFocus: noop,
358
- onBlur: noop,
359
- size: size$1[1],
360
- frozenDateRange: [],
361
- clearable: false
362
- };
363
-
364
- function getLastValidValue(startDate, endDate, validFormat, rangeSeparator) {
365
- if (startDate && endDate && startDate.isValid() && endDate.isValid()) {
366
- return "".concat(startDate.format(validFormat)).concat(rangeSeparator).concat(endDate.format(validFormat));
367
- }
368
- return '';
369
- }
370
- const rangeSeparator = ' — ';
371
- function DateRangePickerInput(_ref) {
372
- let {
373
- startTimePlaceholder,
374
- startDatePlaceholder,
375
- endDatePlaceholder,
376
- endTimePlaceholder,
377
- defaultStartTime,
378
- defaultEndTime,
379
- withoutPicker,
380
- popoverAlign,
381
- flexibility,
382
- placeholder,
383
- pickerProps,
384
- appearance,
385
- className,
386
- withTime,
387
- onChange,
388
- required,
389
- disabled,
390
- readOnly,
391
- isValid,
392
- onFocus,
393
- format,
394
- onBlur,
395
- title,
396
- value,
397
- size,
398
- max,
399
- min,
400
- isIncludeEndDateLastSecond,
401
- markedDate,
402
- frozenDateRange,
403
- clearable,
404
- ...restProps
405
- } = _ref;
406
- const {
407
- isMobile
408
- } = useDeviceType();
409
- const maxDate = max && dayjsWithPlugins(max);
410
- const minDate = min && dayjsWithPlugins(min);
411
- const validFormat = useMemo(() => isMobile ? withTime ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD' : format || getBrowserDateFormat(!!withTime), [isMobile, withTime, format]);
412
- const [inputValue, setInputValue] = useState('');
413
- const [startDate, setStartDate] = useState('');
414
- const [endDate, setEndDate] = useState('');
415
- const [mobileStartDate, setMobileStartDate] = useState('');
416
- const [mobileEndDate, setMobileEndDate] = useState('');
417
- const [mobileStartTime, setMobileStartTime] = useState('');
418
- const [mobileEndTime, setMobileEndTime] = useState('');
419
- const [popoverOpened, setPopoverState] = useState(false);
420
- const inputRef = useRef();
421
- const setPickerRef = useClick(e => {
422
- e.preventDefault();
423
- });
424
- const setMobileDate = useCallback((start, end) => {
425
- setMobileStartDate(start ? start.format('YYYY-MM-DD') : '');
426
- setMobileEndDate(end ? end.format('YYYY-MM-DD') : '');
427
- setMobileStartTime(start ? start.format('HH:mm') : '');
428
- setMobileEndTime(end ? end.format('HH:mm') : '');
429
- }, []);
430
- const handleDateValidation = useCallback((first, second, value) => {
431
- const startDateLocal = dayjsWithPlugins(first, validFormat);
432
- const endDateLocal = dayjsWithPlugins(second, validFormat);
433
- const isStartDateValid = startDateLocal.isValid() && startDateLocal.format(validFormat) === first;
434
- const isEndDateValid = endDateLocal.isValid() && endDateLocal.format(validFormat) === second;
435
- if (frozenDateRange.length && Array.isArray(frozenDateRange)) {
436
- const format = 'YYYY/MM/DD';
437
- const isValid = !frozenDateRange.find(_ref2 => {
438
- let {
439
- from,
440
- to
441
- } = _ref2;
442
- return from && to && (startDateLocal.isBetween(dayjs(from).format(format), dayjs(to).format(format), 'day', '[]') || endDateLocal.isBetween(dayjs(from).format(format), dayjs(to).format(format), 'day', '[]'));
443
- });
444
- if (!isValid) {
445
- return [null, null];
446
- }
447
- }
448
- if (isStartDateValid && isEndDateValid && dayjsWithPlugins(startDateLocal).isAfter(endDateLocal)) {
449
- const diff = endDate && startDate ? dayjsWithPlugins(endDate).diff(startDate, 'm') : 0;
450
- const changedDate = dayjsWithPlugins(startDateLocal).isSame(startDate) ? {
451
- start: endDateLocal.subtract(diff, 'minute'),
452
- end: endDateLocal
453
- } : {
454
- start: startDateLocal,
455
- end: startDateLocal.add(diff, 'minute')
456
- };
457
- setStartDate(changedDate.start);
458
- setEndDate(changedDate.end);
459
- return [changedDate.start, changedDate.end];
460
- }
461
- if (isStartDateValid && isEndDateValid) {
462
- setStartDate(startDateLocal);
463
- setEndDate(endDateLocal);
464
- return [startDateLocal, endDateLocal];
465
- }
466
- if (!required && value === '') {
467
- setStartDate('');
468
- setEndDate('');
469
- return [null, null];
470
- }
471
- }, [frozenDateRange, validFormat, endDate, startDate, required]);
472
- const handleRangeChange = useCallback(value => {
473
- const [startDate, endDate] = value;
474
- if (startDate && endDate) {
475
- const start = dayjsWithPlugins(startDate);
476
- const end = dayjsWithPlugins(endDate);
477
- setStartDate(start);
478
- setEndDate(end);
479
- if (!withTime && !isMobile) {
480
- inputRef.current.blur();
481
- setPopoverState(false);
482
- }
483
- setInputValue("".concat(start.format(validFormat)).concat(rangeSeparator).concat(end.format(validFormat)));
484
- onChange(value);
485
- }
486
- }, [validFormat, rangeSeparator, onChange, withTime]);
487
- const handleInputChange = useCallback(e => {
488
- var _value, _value2, _value3;
489
- let {
490
- value
491
- } = e.target;
492
- if (((_value = value) === null || _value === void 0 ? void 0 : _value.length) >= (validFormat === null || validFormat === void 0 ? void 0 : validFormat.length) && !((_value2 = value) !== null && _value2 !== void 0 && _value2.includes(rangeSeparator)) && (inputValue === null || inputValue === void 0 ? void 0 : inputValue.length) < ((_value3 = value) === null || _value3 === void 0 ? void 0 : _value3.length)) {
493
- value = "".concat(value).concat(rangeSeparator);
494
- }
495
- const [startDate = null, endDate = null] = value.split(rangeSeparator.trim());
496
- const dates = handleDateValidation(startDate === null || startDate === void 0 ? void 0 : startDate.trim(), endDate === null || endDate === void 0 ? void 0 : endDate.trim(), value);
497
- if (dates && dates[0] && dates[1]) {
498
- onChange([dates[0].toDate(), dates[1].toDate()]);
499
- }
500
- setInputValue(value);
501
- return dates;
502
- }, [onChange, handleDateValidation, inputValue]);
503
- const handleMobileDateChange = useCallback((e, index) => {
504
- const isStart = index === 0;
505
- const {
506
- value
507
- } = e.target;
508
- const date = dayjsWithPlugins(value);
509
- const start = isStart ? value : mobileStartDate || date.subtract(1, 'day').format('YYYY-MM-DD');
510
- const end = !isStart ? value : mobileEndDate || date.add(1, 'day').format('YYYY-MM-DD');
511
- const startTime = mobileStartTime || defaultStartTime;
512
- const endTime = mobileEndTime || defaultEndTime;
513
- const fullStartDate = withTime ? "".concat(start, " ").concat(startTime).concat(rangeSeparator).concat(end, " ").concat(endTime) : "".concat(start).concat(rangeSeparator).concat(end);
514
- const [first, second] = handleInputChange({
515
- target: {
516
- value: fullStartDate
517
- }
518
- }) || [];
519
- setMobileStartDate(first === null || first === void 0 ? void 0 : first.format('YYYY-MM-DD'));
520
- setMobileEndDate(second === null || second === void 0 ? void 0 : second.format('YYYY-MM-DD'));
521
- setMobileStartTime(startTime);
522
- setMobileEndTime(endTime);
523
- }, [mobileStartDate, mobileEndDate, mobileStartTime, defaultStartTime, mobileEndTime, defaultEndTime, withTime, rangeSeparator, handleInputChange]);
524
- const handleMobileTimeChange = useCallback((e, index) => {
525
- const isStart = index === 0;
526
- const {
527
- value
528
- } = e.target;
529
- const date = dayjsWithPlugins();
530
- const startTime = isStart ? value : mobileStartTime || defaultStartTime;
531
- const endTime = !isStart ? value : mobileEndTime || defaultEndTime;
532
- const start = mobileStartDate || date.format('YYYY-MM-DD');
533
- const end = mobileEndDate || date.add(1, 'day').format('YYYY-MM-DD');
534
- if (startTime && endTime) {
535
- const [first, second] = handleInputChange({
536
- target: {
537
- value: "".concat(start, " ").concat(startTime).concat(rangeSeparator).concat(end, " ").concat(endTime)
538
- }
539
- });
540
- setMobileStartDate(first.format('YYYY-MM-DD'));
541
- setMobileEndDate(second.format('YYYY-MM-DD'));
542
- setMobileStartTime(first.format('HH:mm'));
543
- setMobileEndTime(second.format('HH:mm'));
544
- } else {
545
- endTime && setMobileStartTime(startTime);
546
- startTime && setMobileEndTime(endTime);
547
- }
548
- }, [mobileStartTime, defaultStartTime, mobileEndTime, defaultEndTime, mobileStartDate, mobileEndDate, handleInputChange, rangeSeparator]);
549
- const checkDateInerval = useCallback(validDate => {
550
- if (!validDate) {
551
- return null;
552
- }
553
- let value = dayjs(validDate, validFormat);
554
- const minUnix = minDate && minDate.valueOf();
555
- const maxUnix = maxDate && maxDate.valueOf();
556
- const dateUnix = value && value.valueOf();
557
- if (minUnix > dateUnix) {
558
- value = minUnix;
559
- } else if (maxUnix < dateUnix) {
560
- value = maxUnix;
561
- }
562
- return dayjs(value);
563
- }, [validFormat, maxDate, minDate]);
564
- const handleBlur = useCallback(e => {
565
- const lastValidValue = getLastValidValue(startDate, endDate, validFormat, rangeSeparator);
566
- setInputValue(lastValidValue);
567
- setPopoverState(false);
568
- onBlur(e);
569
- if (lastValidValue) {
570
- handleRangeChange([checkDateInerval(startDate.format(validFormat)), checkDateInerval(endDate.format(validFormat))]);
571
- } else {
572
- onChange([null, null]);
573
- }
574
- }, [startDate, endDate, validFormat, rangeSeparator, onBlur, handleRangeChange, checkDateInerval, onChange]);
575
- const handleFocus = useCallback(e => {
576
- setPopoverState(true);
577
- onFocus(e);
578
- }, [onFocus]);
579
- const handleOnApply = useCallback(e => {
580
- pickerProps === null || pickerProps === void 0 ? void 0 : pickerProps.onApply(e);
581
- setPopoverState(false);
582
- }, [pickerProps]);
583
- const handleIconClick = useCallback((e, isBlurInitiatorCalendarIcon) => {
584
- e.stopPropagation();
585
- e.preventDefault();
586
- if (!popoverOpened && !isBlurInitiatorCalendarIcon || withoutPicker) {
587
- inputRef.current.focus();
588
- }
589
- }, [popoverOpened, withoutPicker]);
590
- useEffect(() => {
591
- const [first, second] = value;
592
- const startDate = dayjsWithPlugins(first);
593
- const endDate = dayjsWithPlugins(second);
594
- if (first && second) {
595
- setStartDate(dayjsWithPlugins(startDate, validFormat));
596
- setEndDate(dayjsWithPlugins(endDate, validFormat));
597
- isMobile && setMobileDate(startDate, endDate);
598
- setInputValue("".concat(startDate.format(validFormat)).concat(rangeSeparator).concat(endDate.format(validFormat)));
599
- } else if (first === null && second === null) {
600
- setStartDate('');
601
- setEndDate('');
602
- isMobile && setMobileDate();
603
- setInputValue('');
604
- }
605
- }, [value, validFormat, isMobile]);
606
- useKeyDown(() => setPopoverState(false), [], {
607
- current: window
608
- }, ['Escape']);
609
- const onClear = useCallback(() => onChange([null, null]), []);
610
- const sharedProps = {
611
- appearance,
612
- inputSize: size,
613
- disabled,
614
- readOnly,
615
- required,
616
- onClear,
617
- canClear: clearable,
618
- ...restProps
619
- };
620
- const dynamicProps = {};
621
- if (isIncludeEndDateLastSecond) {
622
- // @TODO need move to separated file
623
- // add constants available for all lib components
624
- // as this constant value also used in organisms
625
- dynamicProps.defaultTimeValues = [['00', '00', '00'], ['00', '00', '00']];
626
- }
627
- return isMobile ? /*#__PURE__*/React__default.createElement("div", {
628
- className: "mobile-date-ranges-holder"
629
- }, placeholder && /*#__PURE__*/React__default.createElement("div", {
630
- className: "md-range-title"
631
- }, placeholder), /*#__PURE__*/React__default.createElement("div", {
632
- className: classnames('mobile-date-ranges-picker', {
633
- 'with-time': withTime
634
- })
635
- }, /*#__PURE__*/React__default.createElement(ExtendedInput, _extends({
636
- type: "date",
637
- label: "From",
638
- isValid: isValid,
639
- onBlur: handleBlur,
640
- itemsDirection: "end",
641
- onFocus: handleFocus,
642
- value: mobileStartDate,
643
- className: "m-start-date",
644
- placeholder: startDatePlaceholder,
645
- onKeyDown: e => stopEvent(e, true),
646
- icon: readOnly ? '' : 'bc-icon-calendar',
647
- onChange: e => handleMobileDateChange(e, 0)
648
- }, sharedProps)), /*#__PURE__*/React__default.createElement(ExtendedInput, _extends({
649
- label: "To",
650
- type: "date",
651
- isValid: isValid,
652
- onBlur: handleBlur,
653
- itemsDirection: "end",
654
- onFocus: handleFocus,
655
- value: mobileEndDate,
656
- className: "m-end-date",
657
- placeholder: endDatePlaceholder,
658
- onKeyDown: e => stopEvent(e, true),
659
- icon: readOnly ? '' : 'bc-icon-calendar',
660
- onChange: e => handleMobileDateChange(e, 1)
661
- }, sharedProps)), withTime && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ExtendedInput, _extends({
662
- type: "time",
663
- label: "Time",
664
- isValid: isValid,
665
- value: mobileStartTime,
666
- className: "m-start-time",
667
- placeholder: startTimePlaceholder,
668
- icon: readOnly ? '' : 'bc-icon-clock',
669
- onChange: e => handleMobileTimeChange(e, 0)
670
- }, sharedProps)), /*#__PURE__*/React__default.createElement(ExtendedInput, _extends({
671
- type: "time",
672
- label: "Time",
673
- isValid: isValid,
674
- value: mobileEndTime,
675
- className: "m-end-time",
676
- placeholder: endTimePlaceholder,
677
- icon: readOnly ? '' : 'bc-icon-clock',
678
- onChange: e => handleMobileTimeChange(e, 1)
679
- }, sharedProps))))) : /*#__PURE__*/React__default.createElement(PopoverV2, {
680
- behave: "open",
681
- align: popoverAlign,
682
- isOpen: popoverOpened,
683
- extendTargetWidth: false,
684
- Content: !withoutPicker && /*#__PURE__*/React__default.createElement(DatePicker.RangePicker, _extends({
685
- min: minDate,
686
- max: maxDate,
687
- value: value,
688
- withApply: false,
689
- ref: setPickerRef,
690
- withTime: withTime,
691
- rangeEndDefault: endDate,
692
- onChange: handleRangeChange,
693
- rangeStartDefault: startDate,
694
- frozenDateRange: frozenDateRange,
695
- className: classnames({
696
- 'pointer-events-none': readOnly
697
- })
698
- }, pickerProps, {
699
- onApply: handleOnApply
700
- }, dynamicProps, {
701
- markedDate: markedDate
702
- }))
703
- }, /*#__PURE__*/React__default.createElement(ExtendedInput, _extends({
704
- label: title,
705
- clickableIcon: true,
706
- ref: inputRef,
707
- isValid: isValid,
708
- value: inputValue,
709
- onBlur: handleBlur,
710
- itemsDirection: "end",
711
- onFocus: handleFocus,
712
- flexibility: flexibility,
713
- placeholder: placeholder,
714
- onChange: handleInputChange,
715
- icon: readOnly ? '' : 'bc-icon-calendar',
716
- onIconClick: handleIconClick,
717
- className: classnames(className, 'date-input', {
718
- 'default-cursor': readOnly || disabled,
719
- 'clearable-date-picker': clearable,
720
- 'text-cursor': withoutPicker
721
- }),
722
- autocomplete: "off"
723
- }, sharedProps)));
724
- }
725
- const {
726
- flexibility,
727
- appearance: appearances,
728
- size
729
- } = inputConfig;
730
- DateRangePickerInput.propTypes = {
731
- /**
732
- * Controls appearance of input element
733
- */
734
- appearance: PropTypes.oneOf(appearances),
735
- /**
736
- * Placeholder text for input
737
- */
738
- placeholder: PropTypes.string,
739
- /**
740
- * Title for input
741
- */
742
- title: PropTypes.string,
743
- /**
744
- * The CSS class name of the wrapper element.
745
- */
746
- className: PropTypes.string,
747
- /**
748
- * Custom date format
749
- */
750
- format: PropTypes.string,
751
- /**
752
- * Controls flexibility of input element
753
- */
754
- flexibility: PropTypes.oneOf(flexibility),
755
- /**
756
- * Define range picker is with time or no.
757
- */
758
- withTime: PropTypes.bool,
759
- /**
760
- * If true, the input element will show icon which can reset selected date.
761
- */
762
- clearable: PropTypes.bool,
763
- /**
764
- * If true, the input element will be disabled.
765
- */
766
- disabled: PropTypes.bool,
767
- /**
768
- * It prevents the user from changing the value of the field.
769
- */
770
- readOnly: PropTypes.bool,
771
- /**
772
- * Callback fired when the value is changed.
773
- * function([startDate: Date, endDate: Date) => void
774
- */
775
- onChange: PropTypes.func,
776
- /**
777
- * Callback fired when the input looses focus.
778
- * function(e: Event) => void
779
- */
780
- onBlur: PropTypes.func,
781
- /**
782
- * Callback fired when the input get focused.
783
- * function(e: Event) => void
784
- */
785
- onFocus: PropTypes.func,
786
- /**
787
- * The value of the input element, required for a controlled component.
788
- */
789
- value: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.instanceOf(dayjsWithPlugins)), PropTypes.arrayOf(PropTypes.instanceOf(Date)), PropTypes.arrayOf(PropTypes.string), PropTypes.arrayOf(PropTypes.number)]),
790
- /**
791
- * If false, the input will indicate an error.
792
- */
793
- isValid: PropTypes.bool,
794
- /**
795
- * Disables datepicker when input is focused
796
- */
797
- withoutPicker: PropTypes.bool,
798
- /**
799
- * Accepts same props as DatePicker component(organisms)
800
- */
801
- pickerProps: PropTypes.object,
802
- /**
803
- * Min specifies the minimum value allowed for datepicker
804
- */
805
- min: PropTypes.oneOfType([PropTypes.instanceOf(dayjsWithPlugins), PropTypes.instanceOf(Date), PropTypes.string, PropTypes.number]),
806
- /**
807
- * Max specifies the maximum value allowed for datepicker
808
- */
809
- max: PropTypes.oneOfType([PropTypes.instanceOf(dayjsWithPlugins), PropTypes.instanceOf(Date), PropTypes.string, PropTypes.number]),
810
- /**
811
- * Controls input size
812
- */
813
- size: PropTypes.oneOf(size),
814
- /**
815
- * Controls alignment of popover
816
- */
817
- popoverAlign: PropTypes.oneOf(popoverConfig.align),
818
- /**
819
- * Placeholder text for start date input, which is used in mobile version
820
- */
821
- startDatePlaceholder: PropTypes.string,
822
- /**
823
- * Placeholder text for end date input, which is used in mobile version
824
- */
825
- endDatePlaceholder: PropTypes.string,
826
- /**
827
- * Placeholder text for start time input, which is used in mobile version
828
- */
829
- startTimePlaceholder: PropTypes.string,
830
- /**
831
- * Placeholder text for end time input, which is used in mobile version
832
- */
833
- endTimePlaceholder: PropTypes.string,
834
- /**
835
- * Set default start time when date changed
836
- */
837
- defaultStartTime: PropTypes.string,
838
- /**
839
- * Set default end time when date changed
840
- */
841
- defaultEndTime: PropTypes.string,
842
- /**
843
- * Prop is responsible for add one second to end date time value in case of true parameter
844
- */
845
- isIncludeEndDateLastSecond: PropTypes.bool,
846
- /**
847
- * MarkedDate specifies the default mark date
848
- */
849
- markedDate: PropTypes.oneOfType([PropTypes.instanceOf(dayjs), PropTypes.instanceOf(Date), PropTypes.string, PropTypes.number]),
850
- /**
851
- * Prop is responsible for disabling selected range
852
- */
853
- frozenDateRange: PropTypes.arrayOf(PropTypes.shape({
854
- from: PropTypes.oneOfType([PropTypes.instanceOf(dayjs), PropTypes.instanceOf(Date), PropTypes.string, PropTypes.number]).isRequired,
855
- to: PropTypes.oneOfType([PropTypes.instanceOf(dayjs), PropTypes.instanceOf(Date), PropTypes.string, PropTypes.number]).isRequired
856
- }))
857
- };
858
- DateRangePickerInput.defaultProps = {
859
- popoverAlign: popoverConfig.align[1],
860
- placeholder: getBrowserDateFormat(),
861
- flexibility: flexibility[0],
862
- appearance: appearances[0],
863
- title: 'Datepicker',
864
- onChange: noop,
865
- size: size[1],
866
- onFocus: noop,
867
- onBlur: noop,
868
- value: [],
869
- defaultStartTime: '00:00',
870
- defaultEndTime: '00:00',
871
- startDatePlaceholder: 'Start date',
872
- endDatePlaceholder: 'End date',
873
- startTimePlaceholder: 'Start',
874
- endTimePlaceholder: 'End',
875
- isIncludeEndDateLastSecond: false,
876
- frozenDateRange: [],
877
- clearable: false
878
- };
879
-
880
- // Styles
881
- DatePickerInput.WithRange = DateRangePickerInput;
882
-
883
- export { DatePickerInput as default };