-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Валерия Чуричева
authored and
Валерия Чуричева
committed
Jun 10, 2024
1 parent
57c0bf2
commit d979ec6
Showing
8 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
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,5 @@ | ||
--- | ||
"@alfalab/core-components-input": major | ||
--- | ||
|
||
Удален тип 'card' |
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,5 @@ | ||
--- | ||
"@alfalab/core-components-codemod": minor | ||
--- | ||
|
||
Добавлен кодмод, который изменяет значение type компонента Input с 'card' на 'number' |
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
28 changes: 28 additions & 0 deletions
28
packages/codemod/src/input-type-card/__testfixtures__/transform.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,28 @@ | ||
import React from 'react'; | ||
|
||
import { Input } from '@alfalab/core-components-input'; | ||
import { InputDesktop } from '@alfalab/core-components-input/desktop'; | ||
import { InputMobile } from '@alfalab/core-components-input/mobile'; | ||
|
||
export const Component = () => ( | ||
<React.Fragment> | ||
<Input type='number'/> | ||
<Input type='email'/> | ||
<Input type='card' size='56'/> | ||
<Input type='card'/> | ||
<Input type='text'/> | ||
<Input/> | ||
<InputDesktop type='number'/> | ||
<InputDesktop type='email'/> | ||
<InputDesktop type='card' size='56'/> | ||
<InputDesktop type='card'/> | ||
<InputDesktop type='text'/> | ||
<InputDesktop/> | ||
<InputMobile type='number'/> | ||
<InputMobile type='email'/> | ||
<InputMobile type='card' size='56'/> | ||
<InputMobile type='card'/> | ||
<InputMobile type='text'/> | ||
<InputMobile/> | ||
</React.Fragment> | ||
); |
28 changes: 28 additions & 0 deletions
28
packages/codemod/src/input-type-card/__testfixtures__/transform.output.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,28 @@ | ||
import React from 'react'; | ||
|
||
import { Input } from '@alfalab/core-components-input'; | ||
import { InputDesktop } from '@alfalab/core-components-input/desktop'; | ||
import { InputMobile } from '@alfalab/core-components-input/mobile'; | ||
|
||
export const Component = () => ( | ||
<React.Fragment> | ||
<Input type='number'/> | ||
<Input type='email'/> | ||
<Input inputMode='numeric' size='56'/> | ||
<Input inputMode='numeric'/> | ||
<Input type='text'/> | ||
<Input/> | ||
<InputDesktop type='number'/> | ||
<InputDesktop type='email'/> | ||
<InputDesktop inputMode='numeric' size='56'/> | ||
<InputDesktop inputMode='numeric'/> | ||
<InputDesktop type='text'/> | ||
<InputDesktop/> | ||
<InputMobile type='number'/> | ||
<InputMobile type='email'/> | ||
<InputMobile inputMode='numeric' size='56'/> | ||
<InputMobile inputMode='numeric'/> | ||
<InputMobile type='text'/> | ||
<InputMobile/> | ||
</React.Fragment> | ||
); |
6 changes: 6 additions & 0 deletions
6
packages/codemod/src/input-type-card/__tests__/transform.test.ts
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,6 @@ | ||
// eslint-disable-next-line prefer-destructuring | ||
const defineTest = require('jscodeshift/dist/testUtils').defineTest; | ||
|
||
jest.autoMockOff(); | ||
|
||
defineTest(__dirname, 'transform', null, 'transform', { parser: '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,36 @@ | ||
/* eslint-disable */ | ||
import { ASTPath, JSXElement, Transform } from 'jscodeshift'; | ||
import { addStringAttribute } from '../utils'; | ||
|
||
const inputTypeTransform: Transform = (fileInfo, api) => { | ||
const j = api.jscodeshift; | ||
const source = j(fileInfo.source); | ||
|
||
const componentsNames = ['Input', 'InputDesktop', 'InputMobile']; | ||
|
||
componentsNames.forEach((elementName) => { | ||
source.findJSXElements(elementName).forEach((path) => { | ||
j(path).replaceWith((path: ASTPath<JSXElement>) => { | ||
const { node } = path; | ||
|
||
const { openingElement } = node; | ||
|
||
j(openingElement) | ||
.find(j.JSXAttribute, { | ||
name: { name: 'type' }, | ||
value: { value: 'card' }, | ||
}) | ||
.replaceWith(() => | ||
j.jsxAttribute(j.jsxIdentifier('inputMode'), j.stringLiteral('numeric')), | ||
); | ||
return node; | ||
}); | ||
}); | ||
}); | ||
return source.toSource({ | ||
quote: 'single', | ||
wrapColumn: 1000, | ||
}); | ||
}; | ||
|
||
export default inputTypeTransform; |
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