Skip to content

Commit

Permalink
fix(input): removed card type
Browse files Browse the repository at this point in the history
  • Loading branch information
Валерия Чуричева authored and Валерия Чуричева committed Jun 10, 2024
1 parent 57c0bf2 commit d979ec6
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/five-waves-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alfalab/core-components-input": major
---

Удален тип 'card'
5 changes: 5 additions & 0 deletions .changeset/soft-coats-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alfalab/core-components-codemod": minor
---

Добавлен кодмод, который изменяет значение type компонента Input с 'card' на 'number'
1 change: 1 addition & 0 deletions packages/codemod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ $ npx @alfalab/core-components-codemod --transformers=button-xs,button-views --g
| button-breakpoint-768 | Добавляет свойство breakpoint со значением 768 к респонсивной кнопке |
| button-views-45 | Меняет вид кнопки с view `tertiary` на `outlined`, `link` на `transparent`, `ghost` на `text` |
| skeleton-blur | Добавляет свойство `allowBackdropBlur` со значение true к компоненту Skeleton |
| input-type-card | Изменяет type компонента Input с `card` на `number`|

### 42 мажорный релиз

Expand Down
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>
);
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>
);
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' });
36 changes: 36 additions & 0 deletions packages/codemod/src/input-type-card/transform.ts
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;
2 changes: 1 addition & 1 deletion packages/input/src/components/base-input/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export type BaseInputProps = Omit<
/**
* Атрибут type
*/
type?: 'number' | 'card' | 'email' | 'money' | 'password' | 'tel' | 'text';
type?: 'number' | 'email' | 'money' | 'password' | 'tel' | 'text';

/**
* Ref для обертки input
Expand Down

0 comments on commit d979ec6

Please sign in to comment.