Skip to content

Commit

Permalink
feat(input): added mobile and responsive versions component (#716)
Browse files Browse the repository at this point in the history
  • Loading branch information
Valeri8888 authored Aug 7, 2023
1 parent 06b4a0b commit 1e38517
Show file tree
Hide file tree
Showing 170 changed files with 1,966 additions and 682 deletions.
6 changes: 6 additions & 0 deletions .changeset/hungry-items-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@alfalab/core-components-select": minor
"@alfalab/core-components-input-autocomplete": minor
---

Компонент FormControl заменен на mobile/desktop версии для мобильных и десктопных версий компонентов
6 changes: 6 additions & 0 deletions .changeset/rotten-geese-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@alfalab/core-components-date-time-input": minor
"@alfalab/core-components-date-range-input": minor
---

Компонент Input заменен на mobile/desktop версии для мобильных и десктопных версий компонентов
5 changes: 5 additions & 0 deletions .changeset/tricky-balloons-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alfalab/core-components-form-control": major
---

Для компонента FormControl добавлены мобильная и адаптивная версии компонента. Responsive компонент теперь экспортируется из индексного файла
5 changes: 5 additions & 0 deletions .changeset/unlucky-queens-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alfalab/core-components-input": major
---

- Для компонента Input добавлены мобильная и адаптивная версии компонента. Responsive компонент теперь экспортируется из индексного файла
14 changes: 14 additions & 0 deletions packages/amount-input/src/Component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ import { AmountInput } from './index';
import { AmountInputProps } from './Component';

describe('AmountInput', () => {
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
matches: true,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});

function renderAmountInput(
value: AmountInputProps['value'],
currency: CurrencyCodes | null = 'RUR',
Expand Down
2 changes: 2 additions & 0 deletions packages/amount-input/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const AmountInput = forwardRef<HTMLInputElement, AmountInputProps>(
clear = false,
onChange,
onClear,
breakpoint = 1024,
...restProps
},
ref,
Expand Down Expand Up @@ -255,6 +256,7 @@ export const AmountInput = forwardRef<HTMLInputElement, AmountInputProps>(
pattern={`[${positiveOnly ? '' : '-'}0-9\\s\\.,]*`}
dataTestId={dataTestId}
ref={ref}
breakpoint={breakpoint}
/>
</div>
);
Expand Down
30 changes: 15 additions & 15 deletions packages/amount-input/src/__snapshots__/Component.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Object {
class="container bold"
>
<div
class="component component component hasSuffix s"
class="component component component hasSuffix s s"
>
<div
class="inner inner"
class="inner inner inner inner"
>
<div
class="inputWrapper"
Expand All @@ -21,7 +21,7 @@ Object {
class="input"
>
<input
class="input input input"
class="input input input input"
inputmode="decimal"
pattern="[0-9\\\\s\\\\.,]*"
placeholder="0 ₽"
Expand Down Expand Up @@ -57,10 +57,10 @@ Object {
class="container bold"
>
<div
class="component component component hasSuffix s"
class="component component component hasSuffix s s"
>
<div
class="inner inner"
class="inner inner inner inner"
>
<div
class="inputWrapper"
Expand All @@ -69,7 +69,7 @@ Object {
class="input"
>
<input
class="input input input"
class="input input input input"
inputmode="decimal"
pattern="[0-9\\\\s\\\\.,]*"
placeholder="0 ₽"
Expand Down Expand Up @@ -162,10 +162,10 @@ Object {
class="container bold"
>
<div
class="component component component hasSuffix s"
class="component component component hasSuffix s s"
>
<div
class="inner inner"
class="inner inner inner inner"
>
<div
class="inputWrapper"
Expand All @@ -174,7 +174,7 @@ Object {
class="input"
>
<input
class="input input input"
class="input input input input"
inputmode="decimal"
pattern="[0-9\\\\s\\\\.,]*"
placeholder="0 ₽"
Expand Down Expand Up @@ -209,10 +209,10 @@ Object {
class="container bold filled"
>
<div
class="component component component suffixVisible hasSuffix s"
class="component component component suffixVisible hasSuffix s s"
>
<div
class="inner inner filled"
class="inner inner inner inner filled"
>
<div
class="inputWrapper"
Expand All @@ -221,7 +221,7 @@ Object {
class="input"
>
<input
class="input input input"
class="input input input input"
inputmode="decimal"
pattern="[0-9\\\\s\\\\.,]*"
placeholder="0 $"
Expand Down Expand Up @@ -261,10 +261,10 @@ Object {
class="container bold filled"
>
<div
class="component component component suffixVisible hasSuffix s"
class="component component component suffixVisible hasSuffix s s"
>
<div
class="inner inner filled"
class="inner inner inner inner filled"
>
<div
class="inputWrapper"
Expand All @@ -273,7 +273,7 @@ Object {
class="input"
>
<input
class="input input input"
class="input input input input"
inputmode="decimal"
pattern="[0-9\\\\s\\\\.,]*"
placeholder="0 $"
Expand Down
5 changes: 4 additions & 1 deletion packages/amount-input/src/component.screenshots.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ describe('AmountInput ', () =>
block: true,
},
},
'padding: 0 270px; transform:scale(2.1)',
'width:800px;padding: 0 270px; transform:scale(2.1)',
{
viewport: { width: 1024, height: 600 },
},
));

describe(
Expand Down
2 changes: 2 additions & 0 deletions packages/amount-input/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"baseUrl": ".",
"paths": {
"@alfalab/core-components-*": ["../*/src"],
"@alfalab/core-components-input/*": ["../input/src/*"],
"@alfalab/core-components-form-control/*": ["../form-control/src/*"],
"@alfalab/core-components-button/*": ["../button/src/*"]
}
},
Expand Down
14 changes: 14 additions & 0 deletions packages/bank-card/src/Component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ import { AlfaBankLIcon } from '@alfalab/icons-logotype/AlfaBankLIcon';
import { BankCard } from './index';

describe('BankCard', () => {
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
matches: true,
media: query,
onchange: null,
addListener: jest.fn(), // Deprecated
removeListener: jest.fn(), // Deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});

const VISA_VALID_NUMBER = '4111111111111111';
const MC_VALID_NUMBER = '5500000000000004';
const MIR_VALID_NUMBER = '2201382000000013';
Expand Down
24 changes: 12 additions & 12 deletions packages/bank-card/src/__snapshots__/Component.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ exports[`BankCard Snapshots tests should match snapshots 1`] = `
</svg>
</div>
<div
class="component component filled m block hasRightAddons"
class="component component filled m m block hasRightAddons"
>
<div
class="inner inner filled hasInnerLabel"
class="inner inner inner inner filled hasInnerLabel"
>
<div
class="inputWrapper"
Expand All @@ -59,7 +59,7 @@ exports[`BankCard Snapshots tests should match snapshots 1`] = `
>
<input
aria-label="Номер карты или счёта"
class="input input m hasInnerLabel input"
class="input input input m hasInnerLabel input"
inputmode="numeric"
pattern="[0-9]*"
type="text"
Expand Down Expand Up @@ -148,10 +148,10 @@ exports[`BankCard Snapshots tests should match snapshots 2`] = `
</svg>
</div>
<div
class="component component filled m block hasRightAddons"
class="component component filled m m block hasRightAddons"
>
<div
class="inner inner filled hasInnerLabel"
class="inner inner inner inner filled hasInnerLabel"
>
<div
class="inputWrapper"
Expand All @@ -176,7 +176,7 @@ exports[`BankCard Snapshots tests should match snapshots 2`] = `
>
<input
aria-label="Номер карты или счёта"
class="input input m hasInnerLabel input"
class="input input input m hasInnerLabel input"
inputmode="numeric"
pattern="[0-9]*"
type="text"
Expand Down Expand Up @@ -263,10 +263,10 @@ exports[`BankCard Snapshots tests should match snapshots 3`] = `
</svg>
</div>
<div
class="component component filled m block hasRightAddons"
class="component component filled m m block hasRightAddons"
>
<div
class="inner inner filled hasInnerLabel"
class="inner inner inner inner filled hasInnerLabel"
>
<div
class="inputWrapper"
Expand All @@ -291,7 +291,7 @@ exports[`BankCard Snapshots tests should match snapshots 3`] = `
>
<input
aria-label="Номер карты или счёта"
class="input input m hasInnerLabel input"
class="input input input m hasInnerLabel input"
inputmode="numeric"
pattern="[0-9]*"
type="text"
Expand Down Expand Up @@ -378,10 +378,10 @@ exports[`BankCard Snapshots tests should match snapshots 4`] = `
</svg>
</div>
<div
class="component component filled m block hasRightAddons"
class="component component filled m m block hasRightAddons"
>
<div
class="inner inner filled hasInnerLabel"
class="inner inner inner inner filled hasInnerLabel"
>
<div
class="inputWrapper"
Expand All @@ -406,7 +406,7 @@ exports[`BankCard Snapshots tests should match snapshots 4`] = `
>
<input
aria-label="Номер карты или счёта"
class="input input m hasInnerLabel input"
class="input input input m hasInnerLabel input"
inputmode="numeric"
pattern="[0-9]*"
type="text"
Expand Down
2 changes: 2 additions & 0 deletions packages/bank-card/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"baseUrl": ".",
"paths": {
"@alfalab/core-components-*": ["../*/src"],
"@alfalab/core-components-form-control/*": ["../form-control/src/*"],
"@alfalab/core-components-input/*": ["../input/src/*"],
"@alfalab/core-components-button/*": ["../button/src/*"]
}
},
Expand Down
16 changes: 15 additions & 1 deletion packages/calendar-input/src/Component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@ import React from 'react';
import userEvent from '@testing-library/user-event';
import { render, waitFor, fireEvent } from '@testing-library/react';

import { CalendarInput } from './index';
import { CalendarInputDesktop as CalendarInput } from './desktop';

describe('CalendarInput', () => {
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
matches: true,
media: query,
onchange: null,
addListener: jest.fn(), // Deprecated
removeListener: jest.fn(), // Deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});

const getSelectedDay = () =>
document.querySelector('td[aria-selected="true"]') as HTMLButtonElement;

Expand Down
Loading

0 comments on commit 1e38517

Please sign in to comment.