Skip to content

Commit

Permalink
feat(dateinput): added default active section for DateInput.tsx (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
session-kniP authored Aug 23, 2022
1 parent 5ed039d commit 4c82540
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/react-kit/src/components/DateInput/DateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export type TDateInputOwnProps = TSteppableInputProps &
onMouseLeave?: () => void;
target?: Element;
Calendar?: ComponentClass<TCalendarProps> | React.SFC<TCalendarProps>;
defaultActiveSection?: ActiveSection;
};

type TDateDefaultProps = {
Expand Down Expand Up @@ -156,11 +157,14 @@ class RawDateInput extends React.Component<TDateInputFullProps, TDateInputState>
}

private getSectionClassName = (activeSection: ActiveSection): string => {
const { theme, isDisabled } = this.props;
const { theme, isDisabled, defaultActiveSection } = this.props;
const { activeSection: selectedActiveSection } = this.state;

const activeSectionSelected = selectedActiveSection || selectedActiveSection === 0;

const selectedOrDefault = activeSectionSelected ? selectedActiveSection : defaultActiveSection;
return classnames(theme.section, {
[theme.section_isActive as string]: !isDisabled && selectedActiveSection === activeSection,
[theme.section_isActive as string]: !isDisabled && selectedOrDefault === activeSection,
});
};

Expand Down

0 comments on commit 4c82540

Please sign in to comment.