-
Notifications
You must be signed in to change notification settings - Fork 7
feat(RelativeRangeDatePicker): allow null values in relative range presets #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(RelativeRangeDatePicker): allow null values in relative range presets #188
Conversation
Preview is ready. |
src/components/RelativeRangeDatePicker/components/PickerDialog/PickerDoc.tsx
Outdated
Show resolved
Hide resolved
src/components/RelativeRangeDatePicker/components/PickerDialog/PickerDoc.tsx
Outdated
Show resolved
Hide resolved
src/components/RelativeRangeDatePicker/__stories__/RelativeRangeDatePiker.stories.tsx
Outdated
Show resolved
Hide resolved
allowNullableValues: true, | ||
withPresets: true, | ||
presetTabs: DEFAULT_RANGE_DATE_PICKER_PRESET, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you trying to mess with arguments of the default story? If you want to show example with custom presets, you can do it via argTypes
or another story.
@@ -122,7 +127,7 @@ function PresetsList({presets, onChoosePreset, size = 'm'}: PresetsListProps) { | |||
renderItem={(item) => item.title} | |||
itemHeight={SIZE_TO_ITEM_HEIGHT[size]} | |||
onItemClick={(item) => { | |||
onChoosePreset(item.from, item.to); | |||
onChoosePreset(item?.from, item?.to); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need optional chaining here?
if (!start) { | ||
return `${i18n('To')}: ${endText}`; | ||
} | ||
if (!end) { | ||
return `${i18n('From')}: ${startText}`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!start) { | |
return `${i18n('To')}: ${endText}`; | |
} | |
if (!end) { | |
return `${i18n('From')}: ${startText}`; | |
} | |
if (!startText) { | |
return `${i18n('To')}: ${endText}`; | |
} | |
if (!endText) { | |
return `${i18n('From')}: ${startText}`; | |
} |
if (end === 'now') { | ||
const match = lastRe.exec(startText); | ||
const match = lastRe.exec(startText || ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (end === 'now') { | |
const match = lastRe.exec(startText); | |
const match = lastRe.exec(startText || ''); | |
if (endText === 'now') { | |
const match = lastRe.exec(startText); |
let start, end; | ||
if (value.start === null) { | ||
start = null; | ||
} | ||
if (value.start?.type === 'relative') { | ||
start = value.start?.value || ''; | ||
} | ||
if (value.end === null) { | ||
end = null; | ||
} | ||
if (value.end?.type === 'relative') { | ||
end = value.end?.value || ''; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let start, end; | |
if (value.start === null) { | |
start = null; | |
} | |
if (value.start?.type === 'relative') { | |
start = value.start?.value || ''; | |
} | |
if (value.end === null) { | |
end = null; | |
} | |
if (value.end?.type === 'relative') { | |
end = value.end?.value || ''; | |
} | |
let start = null; | |
let end = null; | |
if (value.start?.type === 'relative') { | |
start = value.start.value; | |
} | |
if (value.end?.type === 'relative') { | |
end = value.end.value; | |
} |
start?: string | null, | ||
end?: string | null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
start?: string | null, | |
end?: string | null, | |
start: string | null, | |
end: string | null, |
@@ -105,7 +121,7 @@ export function getDefaultPresetTabs({ | |||
if (withTime) { | |||
mainPresets.unshift(...DEFAULT_TIME_PRESETS); | |||
} | |||
mainTab.presets = filterPresets(mainPresets, minValue); | |||
mainTab.presets = filterPresets(mainPresets, minValue, allowNullableValues); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to filter DEFAULT_OTHERS_PRESETS
with allowNullableValues
?
I hereby agree to the terms of the CLA available at: [https://yandex.ru/legal/cla/?lang=en]