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