-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Calendar): rename
onClose
prop to onDoneButtonClick
- Loading branch information
1 parent
ebb46a5
commit e95e660
Showing
7 changed files
with
92 additions
and
7 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
packages/codemods/src/transforms/v7/__testfixtures__/calendar/basic.input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Calendar } from '@vkontakte/vkui'; | ||
import React from 'react'; | ||
|
||
const App = () => { | ||
const callback = () => {} | ||
return ( | ||
<React.Fragment> | ||
<Calendar | ||
onChange={() => {}} | ||
enableTime={true} | ||
disablePast={true} | ||
disableFuture={true} | ||
onClose={() => {}} | ||
/> | ||
|
||
<Calendar | ||
onChange={() => {}} | ||
enableTime={true} | ||
disablePast={true} | ||
disableFuture={true} | ||
onClose={callback} | ||
/> | ||
</React.Fragment> | ||
); | ||
}; |
28 changes: 28 additions & 0 deletions
28
packages/codemods/src/transforms/v7/__tests__/__snapshots__/calendar.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`calendar transforms correctly 1`] = ` | ||
"import { Calendar } from '@vkontakte/vkui'; | ||
import React from 'react'; | ||
const App = () => { | ||
const callback = () => {} | ||
return ( | ||
(<React.Fragment> | ||
<Calendar | ||
onChange={() => {}} | ||
enableTime={true} | ||
disablePast={true} | ||
disableFuture={true} | ||
onDoneButtonClick={() => {}} | ||
/> | ||
<Calendar | ||
onChange={() => {}} | ||
enableTime={true} | ||
disablePast={true} | ||
disableFuture={true} | ||
onDoneButtonClick={callback} | ||
/> | ||
</React.Fragment>) | ||
); | ||
};" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
jest.autoMockOff(); | ||
|
||
import { defineSnapshotTestFromFixture } from '../../../testHelpers/testHelper'; | ||
|
||
const name = 'calendar'; | ||
const fixtures = ['basic'] as const; | ||
|
||
describe(name, () => { | ||
fixtures.forEach((test) => | ||
defineSnapshotTestFromFixture(__dirname, name, global.TRANSFORM_OPTIONS, `${name}/${test}`), | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { API, FileInfo } from 'jscodeshift'; | ||
import { getImportInfo, renameProp } from '../../codemod-helpers'; | ||
import { JSCodeShiftOptions } from '../../types'; | ||
|
||
export const parser = 'tsx'; | ||
|
||
export default function transformer(file: FileInfo, api: API, options: JSCodeShiftOptions) { | ||
const { alias } = options; | ||
const j = api.jscodeshift; | ||
const source = j(file.source); | ||
const { localName } = getImportInfo(j, file, 'Calendar', alias); | ||
|
||
if (!localName) { | ||
return source.toSource(); | ||
} | ||
|
||
renameProp(j, source, localName, { onClose: 'onDoneButtonClick' }); | ||
|
||
return source.toSource(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters