Skip to content

Commit

Permalink
Refactor #1951 - For Calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Apr 12, 2021
1 parent a42b128 commit 394ee87
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/components/calendar/Calendar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ interface CalendarProps {
onViewDateChange?(e: ViewChangeParams): void;
onTodayButtonClick?(event: React.MouseEvent<HTMLButtonElement>): void;
onClearButtonClick?(event: React.MouseEvent<HTMLButtonElement>): void;
onShow?(): void;
onHide?(): void;
}

export class Calendar extends React.Component<CalendarProps, any> { }
12 changes: 10 additions & 2 deletions src/components/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export class Calendar extends Component {
onChange: null,
onViewDateChange: null,
onTodayButtonClick: null,
onClearButtonClick: null
onClearButtonClick: null,
onShow: null,
onHide: null
}

static propTypes = {
Expand Down Expand Up @@ -162,7 +164,9 @@ export class Calendar extends Component {
onChange: PropTypes.func,
onViewDateChange: PropTypes.func,
onTodayButtonClick: PropTypes.func,
onClearButtonClick: PropTypes.func
onClearButtonClick: PropTypes.func,
onShow: PropTypes.func,
onHide: PropTypes.func
}

constructor(props) {
Expand Down Expand Up @@ -1537,6 +1541,8 @@ export class Calendar extends Component {
this.bindDocumentClickListener();
this.bindDocumentResizeListener();
this.bindScrollListener();

this.props.onShow && this.props.onShow();
}

onOverlayExit() {
Expand All @@ -1547,6 +1553,8 @@ export class Calendar extends Component {

onOverlayExited() {
ZIndexUtils.clear(this.overlayRef.current);

this.props.onHide && this.props.onHide();
}

bindDocumentClickListener() {
Expand Down
10 changes: 10 additions & 0 deletions src/showcase/calendar/CalendarDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,16 @@ dateTemplate(date) {
value: New date</td>
<td>Callback to invoke when the displayed month/year is changed.</td>
</tr>
<tr>
<td>onShow</td>
<td>-</td>
<td>Callback to invoke when overlay panel or modal becomes visible.</td>
</tr>
<tr>
<td>onHide</td>
<td>-</td>
<td>Callback to invoke when overlay panel or modal becomes hidden.</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit 394ee87

Please sign in to comment.