Skip to content

Commit

Permalink
fix: react-ui-validations
Browse files Browse the repository at this point in the history
  • Loading branch information
mshatikhin committed Nov 21, 2024
1 parent 81eeec0 commit b60bae5
Show file tree
Hide file tree
Showing 64 changed files with 178 additions and 189 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React, { ComponentType } from 'react';
import { DatePicker, DatePickerProps } from '@skbkontur/react-ui/components/DatePicker';
import type { ComponentType } from 'react';
import React from 'react';
import type { DatePickerProps } from '@skbkontur/react-ui/components/DatePicker';
import { DatePicker } from '@skbkontur/react-ui/components/DatePicker';
import { Input } from '@skbkontur/react-ui/components/Input';

import { RenderErrorMessage, ValidationInfo, ValidationWrapper } from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { RenderErrorMessage, ValidationInfo } from '../../../../src';
import { ValidationWrapper } from '../../../../src';
import type { Nullable } from '../../../../typings/Types';

type ValidationFunc<T> = (value: Nullable<T>) => Nullable<ValidationInfo>;
interface ValidationProps<TValue> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button } from '@skbkontur/react-ui/components/Button';

import { ValidationContainer } from '../../../../src';
import { Form } from '../../../Common/Form';
import { Nullable } from '../../../../typings/Types';
import type { Nullable } from '../../../../typings/Types';

import { Input, DatePicker, lessThanDate } from './ControlsWithValidations';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import React from 'react';
import { Input } from '@skbkontur/react-ui/components/Input';

import {
ValidationContainer,
ValidationWrapper,
ValidationInfo,
text,
} from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { ValidationInfo } from '../../../../src';
import { ValidationContainer, ValidationWrapper, text } from '../../../../src';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

export default class TextValidationDemo extends React.Component {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import React from 'react';
import { Input } from '@skbkontur/react-ui/components/Input';

import {
ValidationContainer,
ValidationWrapper,
ValidationInfo,
tooltip,
} from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { ValidationInfo } from '../../../../src';
import { ValidationContainer, ValidationWrapper, tooltip } from '../../../../src';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

interface TooltipValidationDemoState {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import { Button, Checkbox } from '@skbkontur/react-ui';

import { ValidationContainer, ValidationInfo, ValidationWrapper } from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { ValidationInfo } from '../../../../src';
import { ValidationContainer, ValidationWrapper } from '../../../../src';
import type { Nullable } from '../../../../typings/Types';

interface CheckboxState {
checked: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ import { Button } from '@skbkontur/react-ui/components/Button';
import { Input } from '@skbkontur/react-ui/components/Input';
import { Gapped } from '@skbkontur/react-ui/components/Gapped';

import {
ValidationBehaviour,
ValidationContainer,
ValidationInfo,
ValidationWrapper,
} from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { ValidationBehaviour, ValidationInfo } from '../../../../src';
import { ValidationContainer, ValidationWrapper } from '../../../../src';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

interface FormValidityDemoState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import React from 'react';
import { Button } from '@skbkontur/react-ui/components/Button';
import { Input } from '@skbkontur/react-ui/components/Input';

import { ValidationContainer, ValidationInfo, ValidationWrapper } from '../../../../src';
import type { ValidationInfo } from '../../../../src';
import { ValidationContainer, ValidationWrapper } from '../../../../src';
import { Form } from '../../../Common/Form';
import { SpaceFiller } from '../../../Common/SpaceFiller';
import { Nullable } from '../../../../typings/Types';
import type { Nullable } from '../../../../typings/Types';

export default class ScrollToValidationDemo extends React.Component {
public state = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import React, { useState } from 'react';
import { Input } from '@skbkontur/react-ui/components/Input';

import {
ValidationContainer,
ValidationWrapper,
ValidationInfo,
text,
} from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { ValidationInfo } from '../../../../src';
import { ValidationContainer, ValidationWrapper, text } from '../../../../src';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

const validate = (value: string): Nullable<ValidationInfo> => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import React, { useState } from 'react';
import { Input } from '@skbkontur/react-ui/components/Input';

import {
ValidationContainer,
ValidationWrapper,
ValidationInfo,
text,
} from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { ValidationInfo } from '../../../../src';
import { ValidationContainer, ValidationWrapper, text } from '../../../../src';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

const validate = (value: string): Nullable<ValidationInfo> => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import { Input } from '@skbkontur/react-ui/components/Input';

import { ValidationContainer, ValidationWrapper, ValidationInfo } from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { ValidationInfo } from '../../../../src';
import { ValidationContainer, ValidationWrapper } from '../../../../src';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

export default class ImmediateValidationDemo extends React.Component {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import { Input } from '@skbkontur/react-ui/components/Input';

import { ValidationContainer, ValidationWrapper, ValidationInfo } from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { ValidationInfo } from '../../../../src';
import { ValidationContainer, ValidationWrapper } from '../../../../src';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

interface LostfocusValidationDemoState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React from 'react';
import { Button } from '@skbkontur/react-ui/components/Button';
import { Input } from '@skbkontur/react-ui/components/Input';

import { ValidationContainer, ValidationWrapper, ValidationInfo } from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { ValidationInfo } from '../../../../src';
import { ValidationContainer, ValidationWrapper } from '../../../../src';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

export default class SubmitValidationDemo extends React.Component {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ValidationContainer,
ValidationWrapper,
} from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

interface ArrayExampleDemoState {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import React from 'react';
import { Button, Gapped, Input, Select } from '@skbkontur/react-ui';

import {
ValidationBehaviour,
ValidationContainer,
ValidationInfo,
ValidationWrapper,
} from '../../../../src';
import type { ValidationBehaviour, ValidationInfo } from '../../../../src';
import { ValidationContainer, ValidationWrapper } from '../../../../src';
import { Form } from '../../../Common/Form';

interface CustomControlProps<Elem = HTMLElement> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Select } from '@skbkontur/react-ui/components/Select';
import { Textarea } from '@skbkontur/react-ui/components/Textarea';

import { createValidator, ValidationContainer, ValidationWrapper } from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

export interface ContactInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button } from '@skbkontur/react-ui/components/Button';
import { Input } from '@skbkontur/react-ui/components/Input';

import { ValidationContainer, ValidationWrapper, createValidator } from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

interface Organization {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button } from '@skbkontur/react-ui/components/Button';
import { Input } from '@skbkontur/react-ui/components/Input';

import { createValidator, ValidationContainer, ValidationWrapper } from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

interface ContactInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button } from '@skbkontur/react-ui/components/Button';
import { Input } from '@skbkontur/react-ui/components/Input';

import { ValidationContainer, ValidationWrapper, createValidator } from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

const validate = createValidator<string[]>((b) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import React from 'react';
import { Input } from '@skbkontur/react-ui/components/Input';

import {
ValidationContainer,
ValidationWrapper,
ValidationInfo,
text,
} from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { ValidationInfo } from '../../../../src';
import { ValidationContainer, ValidationWrapper, text } from '../../../../src';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

export default class LostfocusDependentDemo extends React.Component {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import React from 'react';
import { Input } from '@skbkontur/react-ui/components/Input';

import {
ValidationContainer,
ValidationWrapper,
ValidationInfo,
text,
} from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { ValidationInfo } from '../../../../src';
import { ValidationContainer, ValidationWrapper, text } from '../../../../src';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

interface LostfocusDependentErrorValidationDemoState {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import React from 'react';
import { Button, Gapped, Input } from '@skbkontur/react-ui';

import { Nullable } from '../../../../typings/Types';
import {
text,
ValidationBehaviour,
ValidationContainer,
ValidationInfo,
ValidationWrapper,
} from '../../../../src';
import type { Nullable } from '../../../../typings/Types';
import type { ValidationBehaviour, ValidationInfo } from '../../../../src';
import { text, ValidationContainer, ValidationWrapper } from '../../../../src';
import { Form } from '../../../Common/Form';

interface IndependentCompareState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Input } from '@skbkontur/react-ui/components/Input';
import { Toggle } from '@skbkontur/react-ui/components/Toggle';

import { ValidationContainer, ValidationWrapper, createValidator } from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

interface ContactInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Input } from '@skbkontur/react-ui/components/Input';
import { Toggle } from '@skbkontur/react-ui/components/Toggle';

import { ValidationContainer, ValidationWrapper, createValidator } from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

interface ContactInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button } from '@skbkontur/react-ui/components/Button';
import { Input } from '@skbkontur/react-ui/components/Input';

import { createValidator, ValidationContainer, ValidationWrapper } from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

interface ContactInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button } from '@skbkontur/react-ui/components/Button';
import { Input } from '@skbkontur/react-ui/components/Input';

import { ValidationContainer, ValidationWrapper, createValidator } from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

interface FullName {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button } from '@skbkontur/react-ui/components/Button';
import { Input } from '@skbkontur/react-ui/components/Input';

import { ValidationContainer, ValidationWrapper, createValidator } from '../../../../src';
import { Nullable } from '../../../../typings/Types';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';

interface PrimitiveTypeDemoState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ import React from 'react';
import { Button } from '@skbkontur/react-ui/components/Button';
import { Input } from '@skbkontur/react-ui/components/Input';

import { Nullable } from '../../../../typings/Types';
import type { Nullable } from '../../../../typings/Types';
import { Form } from '../../../Common/Form';
import {
ValidationContainer,
ValidationWrapper,
createValidator,
ValidationBuilder,
ValidationRule,
} from '../../../../src';
import type { ValidationBuilder, ValidationRule } from '../../../../src';
import { ValidationContainer, ValidationWrapper, createValidator } from '../../../../src';

interface ReusableDemoState {
email: string;
Expand Down
5 changes: 3 additions & 2 deletions packages/react-ui-validations/src/ErrorRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';

import { ValidationText } from './ValidationText';
import { TooltipPosition, ValidationTooltip } from './ValidationTooltip';
import { RenderErrorMessage, TextPosition } from './ValidationWrapperInternal';
import type { TooltipPosition } from './ValidationTooltip';
import { ValidationTooltip } from './ValidationTooltip';
import type { RenderErrorMessage, TextPosition } from './ValidationWrapperInternal';

export function tooltip(pos: TooltipPosition): RenderErrorMessage {
return (control, hasError, validation) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui-validations/src/ValidationContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { Nullable } from '../typings/Types';
import type { Nullable } from '../typings/Types';

import { createPropsGetter } from './utils/createPropsGetter';
import { isTestEnv } from './utils/utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { ValidationWrapperInternal } from './ValidationWrapperInternal';
import type { ValidationWrapperInternal } from './ValidationWrapperInternal';
import type { ScrollOffset, ValidateArgumentType } from './ValidationContainer';
import { isNullable } from './utils/isNullable';
import { FocusMode } from './FocusMode';
Expand Down
4 changes: 2 additions & 2 deletions packages/react-ui-validations/src/ValidationHelper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Nullable } from '../typings/Types';
import type { Nullable } from '../typings/Types';

import { Validation, ValidationBehaviour, ValidationLevel } from './ValidationWrapperInternal';
import type { Validation, ValidationBehaviour, ValidationLevel } from './ValidationWrapperInternal';

export function getVisibleValidation(
visible: Nullable<Validation>,
Expand Down
6 changes: 3 additions & 3 deletions packages/react-ui-validations/src/ValidationText.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useContext } from 'react';

import { Nullable } from '../typings/Types';
import { ThemeValidations } from '../typings/theme-context';
import type { Nullable } from '../typings/Types';
import type { ThemeValidations } from '../typings/theme-context';

import { TextPosition, Validation } from './ValidationWrapperInternal';
import type { TextPosition, Validation } from './ValidationWrapperInternal';
import { getValidationTextColor } from './utils/getValidationTextColor';
import { ThemeContext } from './ReactUiDetection';

Expand Down
Loading

0 comments on commit b60bae5

Please sign in to comment.