Skip to content

Commit 88cbce0

Browse files
authored
feat(RelativeRangeDatePicker): remove dates hint (#75)
Co-authored-by: kseniyakuzina <[email protected]>
1 parent 9f4488f commit 88cbce0

File tree

1 file changed

+57
-91
lines changed

1 file changed

+57
-91
lines changed

src/components/RelativeRangeDatePicker/RelativeRangeDatePicker.tsx

Lines changed: 57 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import React from 'react';
22

3-
import {dateTimeParse} from '@gravity-ui/date-utils';
43
import type {DateTime} from '@gravity-ui/date-utils';
54
import {Calendar as CalendarIcon} from '@gravity-ui/icons';
6-
import {Button, Icon, Popover, TextInput, useFocusWithin, useMobile} from '@gravity-ui/uikit';
5+
import {Button, Icon, TextInput, useFocusWithin, useMobile} from '@gravity-ui/uikit';
76

87
import {block} from '../../utils/cn';
98
import type {Value} from '../RelativeDatePicker';
@@ -23,7 +22,6 @@ import type {Preset} from './components/Presets/defaultPresets';
2322
import type {PresetTab} from './components/Presets/utils';
2423
import {useRelativeRangeDatePickerState} from './hooks/useRelativeRangeDatePickerState';
2524
import type {RelativeRangeDatePickerStateOptions} from './hooks/useRelativeRangeDatePickerState';
26-
import {i18n} from './i18n';
2725
import {getDefaultTitle} from './utils';
2826

2927
import './RelativeRangeDatePicker.scss';
@@ -116,75 +114,63 @@ export function RelativeRangeDatePicker(props: RelativeRangeDatePickerProps) {
116114
className={b(null, props.className)}
117115
style={props.style}
118116
>
119-
<Popover
120-
className={b('value-label')}
121-
tooltipContentClassName={b('value-label-tooltip')}
122-
disabled={isMobile || open || !state.value}
123-
delayOpening={500}
124-
placement={['right', 'right-start', 'right-end', 'auto']}
125-
hasArrow={false}
126-
content={
127-
<ValueLabel value={state.value} format={format} timeZone={state.timeZone} />
128-
}
129-
>
130-
<TextInput
131-
autoFocus={props.autoFocus}
132-
controlRef={inputRef}
133-
value={text}
134-
placeholder={props.placeholder}
135-
onUpdate={(v) => {
136-
if (!props.readOnly && !v) {
137-
state.setValue(null, 'default');
138-
}
139-
}}
140-
controlProps={{
141-
'aria-haspopup': 'dialog',
142-
'aria-expanded': open,
143-
disabled: isMobile,
144-
className: b('input', {mobile: isMobile}),
145-
}}
146-
onKeyDown={(e) => {
147-
if (props.disabled) {
148-
return;
149-
}
150-
if (e.altKey && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) {
151-
e.preventDefault();
152-
setOpen(true);
153-
}
154-
}}
155-
onFocus={() => {
156-
if (!isActive) {
157-
setIsActive(true);
158-
setOpen(true);
159-
}
160-
}}
161-
validationState={validationState}
162-
errorMessage={errorMessage}
163-
errorPlacement={props.errorPlacement}
164-
pin={props.pin}
165-
size={props.size}
166-
label={props.label}
167-
hasClear={props.hasClear}
168-
disabled={props.disabled}
169-
endContent={
170-
<Button
171-
view="flat-secondary"
172-
size={getButtonSizeForInput(props.size)}
173-
disabled={props.disabled}
174-
extraProps={{
175-
'aria-haspopup': 'dialog',
176-
'aria-expanded': open,
177-
}}
178-
onClick={() => {
179-
setIsActive(true);
180-
setOpen(!open);
181-
}}
182-
>
183-
<Icon data={CalendarIcon} />
184-
</Button>
117+
<TextInput
118+
autoFocus={props.autoFocus}
119+
controlRef={inputRef}
120+
value={text}
121+
placeholder={props.placeholder}
122+
onUpdate={(v) => {
123+
if (!props.readOnly && !v) {
124+
state.setValue(null, 'default');
185125
}
186-
/>
187-
</Popover>
126+
}}
127+
controlProps={{
128+
'aria-haspopup': 'dialog',
129+
'aria-expanded': open,
130+
disabled: isMobile,
131+
className: b('input', {mobile: isMobile}),
132+
}}
133+
onKeyDown={(e) => {
134+
if (props.disabled) {
135+
return;
136+
}
137+
if (e.altKey && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) {
138+
e.preventDefault();
139+
setOpen(true);
140+
}
141+
}}
142+
onFocus={() => {
143+
if (!isActive) {
144+
setIsActive(true);
145+
setOpen(true);
146+
}
147+
}}
148+
validationState={validationState}
149+
errorMessage={errorMessage}
150+
errorPlacement={props.errorPlacement}
151+
pin={props.pin}
152+
size={props.size}
153+
label={props.label}
154+
hasClear={props.hasClear}
155+
disabled={props.disabled}
156+
endContent={
157+
<Button
158+
view="flat-secondary"
159+
size={getButtonSizeForInput(props.size)}
160+
disabled={props.disabled}
161+
extraProps={{
162+
'aria-haspopup': 'dialog',
163+
'aria-expanded': open,
164+
}}
165+
onClick={() => {
166+
setIsActive(true);
167+
setOpen(!open);
168+
}}
169+
>
170+
<Icon data={CalendarIcon} />
171+
</Button>
172+
}
173+
/>
188174
{isMobile ? (
189175
<button
190176
className={b('mobile-trigger', {
@@ -212,23 +198,3 @@ export function RelativeRangeDatePicker(props: RelativeRangeDatePickerProps) {
212198
</div>
213199
);
214200
}
215-
216-
interface ValueLabelProps {
217-
value: RangeValue<Value | null> | null;
218-
format: string;
219-
timeZone: string;
220-
}
221-
function ValueLabel({value, format, timeZone}: ValueLabelProps) {
222-
return (
223-
<div className={b('value-label-content')}>
224-
<span className={b('value-label-item')}>
225-
{dateTimeParse(value?.start?.value, {timeZone})?.format(format)}
226-
</span>
227-
<span className={b('value-label-to')}>{i18n('to')}</span>
228-
<span className={b('value-label-item')}>
229-
{dateTimeParse(value?.end?.value, {timeZone, roundUp: true})?.format(format)}
230-
</span>
231-
{timeZone && <span className={b('value-label-tz')}>{timeZone}</span>}
232-
</div>
233-
);
234-
}

0 commit comments

Comments
 (0)