@skbkontur/react-ui-validations 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,317 +1,316 @@
1
- // Generated by dts-bundle v0.7.3
2
- // Dependencies for this module:
3
- // ../../react
4
-
5
- declare module '@skbkontur/react-ui-validations' {
6
- import { text, tooltip } from '@skbkontur/react-ui-validations/src/ErrorRenderer';
7
- import { ValidationContainer } from '@skbkontur/react-ui-validations/src/ValidationContainer';
8
- import type { ValidationSettings, ValidateArgumentType, ValidationContainerProps, ScrollOffset } from '@skbkontur/react-ui-validations/src/ValidationContainer';
9
- import { ValidationTooltip } from '@skbkontur/react-ui-validations/src/ValidationTooltip';
10
- import type { TooltipPosition, ValidationTooltipProps } from '@skbkontur/react-ui-validations/src/ValidationTooltip';
11
- import type { ValidationLevel, TextPosition, RenderErrorMessage, Validation, ValidationBehaviour } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
12
- import { ValidationWrapper } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
13
- import type { ValidationInfo, ValidationWrapperProps } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
14
- import type { ValidationContextType, ValidationContextWrapperProps, ValidationContextSettings } from '@skbkontur/react-ui-validations/src/ValidationContextWrapper';
15
- import { ValidationContext, ValidationContextWrapper } from '@skbkontur/react-ui-validations/src/ValidationContextWrapper';
16
- import { validationsFeatureFlagsDefault, ValidationsFeatureFlagsContext, getFullValidationsFlagsContext } from '@skbkontur/react-ui-validations/src/utils/featureFlagsContext';
17
- import type { ValidationsFeatureFlags } from '@skbkontur/react-ui-validations/src/utils/featureFlagsContext';
18
- import { FocusMode } from '@skbkontur/react-ui-validations/src/FocusMode';
19
- export type { ValidationContainerProps, ValidationContextType, ValidationContextWrapperProps, ValidationWrapperProps, ValidationTooltipProps, ScrollOffset, ValidationLevel, TextPosition, ValidationsFeatureFlags, ValidationSettings, ValidateArgumentType, ValidationContextSettings, TooltipPosition, ValidationInfo, Validation, RenderErrorMessage, ValidationBehaviour, ValidationWrapperProps as ValidationWrapperV1Props, };
20
- export { ValidationContainer, ValidationContext, ValidationContextWrapper, ValidationWrapper as ValidationWrapperV1, ValidationWrapper, ValidationTooltip, tooltip, text, FocusMode, validationsFeatureFlagsDefault, ValidationsFeatureFlagsContext, getFullValidationsFlagsContext, };
21
- export * from '@skbkontur/react-ui-validations/src/Validations';
22
- }
23
-
24
- declare module '@skbkontur/react-ui-validations/src/ErrorRenderer' {
25
- import type { TooltipPosition } from '@skbkontur/react-ui-validations/src/ValidationTooltip';
26
- import type { RenderErrorMessage, TextPosition } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
27
- export function tooltip(pos: TooltipPosition): RenderErrorMessage;
28
- export function text(pos?: TextPosition): RenderErrorMessage;
29
- }
30
-
31
- declare module '@skbkontur/react-ui-validations/src/ValidationContainer' {
32
- import React from 'react';
33
- import type { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
34
- import { FocusMode } from '@skbkontur/react-ui-validations/src/FocusMode';
35
- export interface ScrollOffset {
36
- top?: number;
37
- bottom?: number;
38
- }
39
- export interface ValidationSettings {
40
- focusMode: FocusMode;
41
- }
42
- export type ValidateArgumentType = boolean | ValidationSettings;
43
- export interface ValidationContainerProps {
44
- 'data-tid'?: string;
45
- children?: React.ReactNode;
46
- onValidationUpdated?: (isValid?: Nullable<boolean>) => void;
47
- scrollOffset?: number | ScrollOffset;
48
- disableSmoothScroll?: boolean;
49
- }
50
- type DefaultProps = Required<Pick<ValidationContainerProps, 'disableSmoothScroll'>>;
51
- export class ValidationContainer extends React.Component<ValidationContainerProps> {
52
- static __KONTUR_REACT_UI__: string;
53
- static displayName: string;
54
- static defaultProps: DefaultProps;
55
- static propTypes: {
56
- scrollOffset(props: ValidationContainerProps, propName: keyof ValidationContainerProps, componentName: string): Error | undefined;
57
- };
58
- submit(withoutFocus?: boolean): Promise<void>;
59
- submit(validationSettings?: ValidationSettings): Promise<void>;
60
- validate(withoutFocus?: boolean): Promise<boolean>;
61
- validate(validationSettings?: ValidationSettings): Promise<boolean>;
62
- render(): React.JSX.Element;
63
- }
64
- export {};
65
- }
66
-
67
- declare module '@skbkontur/react-ui-validations/src/ValidationTooltip' {
68
- import React from 'react';
69
- export type TooltipPosition = 'top left' | 'top center' | 'top right' | 'bottom left' | 'bottom center' | 'bottom right' | 'left top' | 'left middle' | 'left bottom' | 'right top' | 'right middle' | 'right bottom';
70
- export interface ValidationTooltipProps {
71
- children: React.ReactElement<any>;
72
- error: boolean;
73
- pos?: TooltipPosition;
74
- render?: () => React.ReactNode;
75
- 'data-tid'?: string;
76
- }
77
- export class ValidationTooltip extends React.Component<ValidationTooltipProps> {
78
- static __KONTUR_REACT_UI__: string;
79
- static displayName: string;
80
- render(): React.JSX.Element;
81
- }
82
- }
83
-
84
- declare module '@skbkontur/react-ui-validations/src/ValidationWrapperInternal' {
85
- import React from 'react';
86
- import type { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
87
- import type { ValidationContextType } from '@skbkontur/react-ui-validations/src/ValidationContextWrapper';
88
- export type ValidationBehaviour = 'immediate' | 'lostfocus' | 'submit';
89
- export type ValidationLevel = 'error' | 'warning';
90
- export type TextPosition = 'bottom' | 'right';
91
- export interface Validation {
92
- level: ValidationLevel;
93
- behaviour: ValidationBehaviour;
94
- message: React.ReactNode;
95
- independent: boolean;
96
- }
97
- export type RenderErrorMessage = (control: React.ReactElement<any>, hasError: boolean, validation: Nullable<Validation>) => React.ReactElement<any>;
98
- export interface ValidationWrapperInternalProps {
99
- children?: React.ReactElement<any>;
100
- validation: Nullable<Validation>;
101
- errorMessage: RenderErrorMessage;
102
- 'data-tid'?: string;
103
- }
104
- interface ValidationWrapperInternalState {
105
- validation: Nullable<Validation>;
106
- }
107
- interface Point {
108
- x: number;
109
- y: number;
110
- }
111
- export class ValidationWrapperInternal extends React.Component<ValidationWrapperInternalProps, ValidationWrapperInternalState> {
112
- state: ValidationWrapperInternalState;
113
- isChanging: boolean;
114
- static contextType: React.Context<ValidationContextType>;
115
- context: ValidationContextType;
116
- componentDidMount(): void;
117
- componentWillUnmount(): void;
118
- componentDidUpdate(): void;
119
- focus(): Promise<void>;
120
- render(): React.JSX.Element;
121
- getRootNode: () => Nullable<Element>;
122
- getControlPosition(): Nullable<Point>;
123
- processBlur(): Promise<void>;
124
- processSubmit(): Promise<void>;
125
- hasError(): boolean;
126
- hasWarning(): boolean;
127
- isIndependent(): boolean;
128
- }
129
- export {};
130
- }
131
-
132
- declare module '@skbkontur/react-ui-validations/src/ValidationWrapper' {
133
- import React from 'react';
134
- import type { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
135
- import type { RenderErrorMessage, ValidationBehaviour, ValidationLevel, ValidationWrapperInternalProps } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
136
- export interface ValidationInfo {
137
- type?: Nullable<ValidationBehaviour>;
138
- level?: Nullable<ValidationLevel>;
139
- message: React.ReactNode;
140
- independent?: boolean;
141
- }
142
- export interface ValidationWrapperProps extends Pick<ValidationWrapperInternalProps, 'data-tid'> {
143
- children?: React.ReactElement<any>;
144
- validationInfo: Nullable<ValidationInfo>;
145
- renderMessage?: Nullable<RenderErrorMessage>;
146
- }
147
- export class ValidationWrapper extends React.Component<ValidationWrapperProps> {
148
- static __KONTUR_REACT_UI__: string;
149
- static displayName: string;
150
- render(): React.JSX.Element;
151
- }
152
- }
153
-
154
- declare module '@skbkontur/react-ui-validations/src/ValidationContextWrapper' {
155
- import React from 'react';
156
- import type { ValidationWrapperInternal } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
157
- import type { ScrollOffset, ValidateArgumentType } from '@skbkontur/react-ui-validations/src/ValidationContainer';
158
- export interface ValidationContextSettings {
159
- scrollOffset: ScrollOffset;
160
- disableSmoothScroll: boolean;
161
- }
162
- export interface ValidationContextWrapperProps {
163
- 'data-tid'?: string;
164
- children?: React.ReactNode;
165
- onValidationUpdated?: (isValid?: boolean) => void;
166
- scrollOffset?: number | ScrollOffset;
167
- disableSmoothScroll: boolean;
168
- }
169
- export interface ValidationContextType {
170
- register: (wrapper: ValidationWrapperInternal) => void;
171
- unregister: (wrapper: ValidationWrapperInternal) => void;
172
- instanceProcessBlur: (wrapper: ValidationWrapperInternal) => void;
173
- onValidationUpdated: (wrapper: ValidationWrapperInternal, isValid: boolean) => void;
174
- getSettings: () => ValidationContextSettings;
175
- isAnyWrapperInChangingMode: () => boolean;
176
- isValidationCalled: () => boolean;
177
- }
178
- export const ValidationContext: React.Context<ValidationContextType>;
179
- export class ValidationContextWrapper extends React.Component<ValidationContextWrapperProps> {
180
- childWrappers: ValidationWrapperInternal[];
181
- validationHasBeenCalled: boolean;
182
- getSettings(): ValidationContextSettings;
183
- register(wrapper: ValidationWrapperInternal): void;
184
- unregister(wrapper: ValidationWrapperInternal): void;
185
- instanceProcessBlur(instance: ValidationWrapperInternal): void;
186
- onValidationUpdated(wrapper: ValidationWrapperInternal, isValid?: boolean): void;
187
- isAnyWrapperInChangingMode(): boolean;
188
- isValidationCalled(): boolean;
189
- onValidationRemoved(): void;
190
- getChildWrappersSortedByPosition(): ValidationWrapperInternal[];
191
- validate(withoutFocusOrValidationSettings: ValidateArgumentType): Promise<boolean>;
192
- render(): React.JSX.Element;
193
- }
194
- }
195
-
196
- declare module '@skbkontur/react-ui-validations/src/utils/featureFlagsContext' {
197
- export * from '@skbkontur/react-ui-validations/src/utils/featureFlagsContext/ValidationsFeatureFlagsContext';
198
- export * from '@skbkontur/react-ui-validations/src/utils/featureFlagsContext/FeatureFlagsHelpers';
199
- }
200
-
201
- declare module '@skbkontur/react-ui-validations/src/FocusMode' {
202
- export enum FocusMode {
203
- 'Errors' = 0,
204
- 'ErrorsAndWarnings' = 1,
205
- 'None' = 2
206
- }
207
- }
208
-
209
- declare module '@skbkontur/react-ui-validations/src/Validations' {
210
- import { ValidationBuilder } from '@skbkontur/react-ui-validations/src/Validations/ValidationBuilder';
211
- import { RootValidationRule, ValidationRule, ItemValidationRule } from '@skbkontur/react-ui-validations/src/Validations/Types';
212
- import { ValidationReader } from '@skbkontur/react-ui-validations/src/Validations/ValidationReader';
213
- export type Validator<T> = (value: T) => ValidationReader<T>;
214
- export function createValidator<T>(rule: RootValidationRule<T>): Validator<T>;
215
- export { ValidationReader, ValidationBuilder, RootValidationRule, ValidationRule, ItemValidationRule };
216
- }
217
-
218
- declare module '@skbkontur/react-ui-validations/typings/Types' {
219
- export type Nullable<T> = T | null | undefined;
220
- export type Omit<T extends Record<string, any>, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
221
- export type ExtractItem<T> = T extends Array<infer TItem> ? TItem : never;
222
- }
223
-
224
- declare module '@skbkontur/react-ui-validations/src/utils/featureFlagsContext/ValidationsFeatureFlagsContext' {
225
- import React from 'react';
226
- export interface ValidationsFeatureFlags {
227
- dropdownsDoNotOpenOnFocusByValidation?: boolean;
228
- hideTooltipOnSelectionControls?: boolean;
229
- validationWrapperValidateOnMount?: boolean;
230
- }
231
- export const validationsFeatureFlagsDefault: ValidationsFeatureFlags;
232
- export const ValidationsFeatureFlagsContext: React.Context<ValidationsFeatureFlags>;
233
- }
234
-
235
- declare module '@skbkontur/react-ui-validations/src/utils/featureFlagsContext/FeatureFlagsHelpers' {
236
- import type { ValidationsFeatureFlags } from '@skbkontur/react-ui-validations/src/utils/featureFlagsContext/ValidationsFeatureFlagsContext';
237
- export const getFullValidationsFlagsContext: (flags: ValidationsFeatureFlags) => {
238
- dropdownsDoNotOpenOnFocusByValidation?: boolean | undefined;
239
- hideTooltipOnSelectionControls?: boolean | undefined;
240
- validationWrapperValidateOnMount?: boolean | undefined;
241
- };
242
- }
243
-
244
- declare module '@skbkontur/react-ui-validations/src/Validations/ValidationBuilder' {
245
- import type React from 'react';
246
- import type { ValidationBehaviour, ValidationLevel } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
247
- import type { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
248
- import type { LambdaPath, PathTokensCache } from '@skbkontur/react-ui-validations/src/Validations/PathHelper';
249
- import type { ValidationWriter } from '@skbkontur/react-ui-validations/src/Validations/ValidationWriter';
250
- import type { ItemValidationRule, ValidationRule } from '@skbkontur/react-ui-validations/src/Validations/Types';
251
- export class ValidationBuilder<TRoot, T> {
252
- constructor(writer: ValidationWriter<TRoot>, tokens: PathTokensCache, path: string[], data: T);
253
- prop<TChild>(lambdaPath: LambdaPath<T, TChild>, rule: ValidationRule<TRoot, TChild>): void;
254
- array<TChild>(lambdaPath: LambdaPath<T, TChild[]>, rule: ItemValidationRule<TRoot, TChild>): void;
255
- invalid(isInvalid: (value: T) => boolean, validationInfo: ValidationInfo): void;
256
- invalid(isInvalid: (value: T) => boolean, message: React.ReactNode, type?: ValidationBehaviour, level?: ValidationLevel, independent?: boolean): void;
257
- }
258
- }
259
-
260
- declare module '@skbkontur/react-ui-validations/src/Validations/Types' {
261
- import type { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
262
- import type { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
263
- import type { ValidationBuilder } from '@skbkontur/react-ui-validations/src/Validations/ValidationBuilder';
264
- export interface ValidationNode<T> {
265
- validation: Nullable<ValidationInfo>;
266
- children: Nullable<{
267
- [K in keyof T]: ValidationNode<T[K]>;
268
- }>;
269
- }
270
- export type ValidationRule<TRoot, T> = (builder: ValidationBuilder<TRoot, T>, value: T) => void;
271
- export type ItemValidationRule<TRoot, T> = (builder: ValidationBuilder<TRoot, T>, value: T, index: number, array: T[]) => void;
272
- export type RootValidationRule<T> = ValidationRule<T, T>;
273
- }
274
-
275
- declare module '@skbkontur/react-ui-validations/src/Validations/ValidationReader' {
276
- import type { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
277
- import type { ExtractItem, Nullable } from '@skbkontur/react-ui-validations/typings/Types';
278
- import type { ValidationNode } from '@skbkontur/react-ui-validations/src/Validations/Types';
279
- import type { LambdaPath, PathTokensCache } from '@skbkontur/react-ui-validations/src/Validations/PathHelper';
280
- export class ValidationReader<T> {
281
- constructor(node: Nullable<ValidationNode<T>>, tokens: PathTokensCache);
282
- getNode<TChild>(lambdaPath: LambdaPath<T, TChild>): ValidationReader<TChild>;
283
- getNodeByIndex(index: number): ValidationReader<ExtractItem<T>>;
284
- getNodeByKey<TKey extends keyof T>(key: TKey): ValidationReader<T[TKey]>;
285
- get(): Nullable<ValidationInfo>;
286
- }
287
- }
288
-
289
- declare module '@skbkontur/react-ui-validations/src/Validations/PathHelper' {
290
- type NonNullableRecursive<T> = {
291
- [K in keyof T]-?: T[K] extends Record<string, unknown> ? NonNullable<NonNullableRecursive<T[K]>> : NonNullable<T[K]>;
292
- };
293
- export type LambdaPath<T, TChild> = (x: NonNullable<NonNullableRecursive<T>>) => TChild;
294
- export function extractPath(lambda: string): string;
295
- export function extractTokens(path: string): string[];
296
- export class PathTokensCache {
297
- getOrAdd<T, TChild>(lambdaPath: LambdaPath<T, TChild>): string[];
298
- has<T, TChild>(lambdaPath: LambdaPath<T, TChild>): boolean;
299
- get size(): number;
300
- }
301
- export {};
302
- }
303
-
304
- declare module '@skbkontur/react-ui-validations/src/Validations/ValidationWriter' {
305
- import type { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
306
- import type { ValidationNode } from '@skbkontur/react-ui-validations/src/Validations/Types';
307
- import { ValidationReader } from '@skbkontur/react-ui-validations/src/Validations/ValidationReader';
308
- import type { PathTokensCache } from '@skbkontur/react-ui-validations/src/Validations/PathHelper';
309
- export class ValidationWriter<T> {
310
- constructor(node?: ValidationNode<T>);
311
- getReader(tokens: PathTokensCache): ValidationReader<T>;
312
- set(validation: ValidationInfo): void;
313
- isValidated(): boolean;
314
- getNode<TChild>(path: string[]): ValidationWriter<TChild>;
315
- }
316
- }
317
-
1
+ // Generated by dts-bundle v0.7.3
2
+ // Dependencies for this module:
3
+ // ../../react
4
+
5
+ declare module '@skbkontur/react-ui-validations' {
6
+ import { text, tooltip } from '@skbkontur/react-ui-validations/src/ErrorRenderer';
7
+ import { ValidationContainer } from '@skbkontur/react-ui-validations/src/ValidationContainer';
8
+ import type { ValidationSettings, ValidateArgumentType, ValidationContainerProps, ScrollOffset } from '@skbkontur/react-ui-validations/src/ValidationContainer';
9
+ import { ValidationTooltip } from '@skbkontur/react-ui-validations/src/ValidationTooltip';
10
+ import type { TooltipPosition, ValidationTooltipProps } from '@skbkontur/react-ui-validations/src/ValidationTooltip';
11
+ import type { ValidationLevel, TextPosition, RenderErrorMessage, Validation, ValidationBehaviour } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
12
+ import { ValidationWrapper } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
13
+ import type { ValidationInfo, ValidationWrapperProps } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
14
+ import type { ValidationContextType, ValidationContextWrapperProps, ValidationContextSettings } from '@skbkontur/react-ui-validations/src/ValidationContextWrapper';
15
+ import { ValidationContext, ValidationContextWrapper } from '@skbkontur/react-ui-validations/src/ValidationContextWrapper';
16
+ import { validationsFeatureFlagsDefault, ValidationsFeatureFlagsContext, getFullValidationsFlagsContext } from '@skbkontur/react-ui-validations/src/utils/featureFlagsContext';
17
+ import type { ValidationsFeatureFlags } from '@skbkontur/react-ui-validations/src/utils/featureFlagsContext';
18
+ import { FocusMode } from '@skbkontur/react-ui-validations/src/FocusMode';
19
+ export type { ValidationContainerProps, ValidationContextType, ValidationContextWrapperProps, ValidationWrapperProps, ValidationTooltipProps, ScrollOffset, ValidationLevel, TextPosition, ValidationsFeatureFlags, ValidationSettings, ValidateArgumentType, ValidationContextSettings, TooltipPosition, ValidationInfo, Validation, RenderErrorMessage, ValidationBehaviour, ValidationWrapperProps as ValidationWrapperV1Props, };
20
+ export { ValidationContainer, ValidationContext, ValidationContextWrapper, ValidationWrapper as ValidationWrapperV1, ValidationWrapper, ValidationTooltip, tooltip, text, FocusMode, validationsFeatureFlagsDefault, ValidationsFeatureFlagsContext, getFullValidationsFlagsContext, };
21
+ export * from '@skbkontur/react-ui-validations/src/Validations';
22
+ }
23
+
24
+ declare module '@skbkontur/react-ui-validations/src/ErrorRenderer' {
25
+ import type { TooltipPosition } from '@skbkontur/react-ui-validations/src/ValidationTooltip';
26
+ import type { RenderErrorMessage, TextPosition } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
27
+ export function tooltip(pos: TooltipPosition): RenderErrorMessage;
28
+ export function text(pos?: TextPosition): RenderErrorMessage;
29
+ }
30
+
31
+ declare module '@skbkontur/react-ui-validations/src/ValidationContainer' {
32
+ import React from 'react';
33
+ import type { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
34
+ import { FocusMode } from '@skbkontur/react-ui-validations/src/FocusMode';
35
+ export interface ScrollOffset {
36
+ top?: number;
37
+ bottom?: number;
38
+ }
39
+ export interface ValidationSettings {
40
+ focusMode: FocusMode;
41
+ }
42
+ export type ValidateArgumentType = boolean | ValidationSettings;
43
+ export interface ValidationContainerProps {
44
+ 'data-tid'?: string;
45
+ children?: React.ReactNode;
46
+ onValidationUpdated?: (isValid?: Nullable<boolean>) => void;
47
+ scrollOffset?: number | ScrollOffset;
48
+ disableSmoothScroll?: boolean;
49
+ }
50
+ type DefaultProps = Required<Pick<ValidationContainerProps, 'disableSmoothScroll'>>;
51
+ export class ValidationContainer extends React.Component<ValidationContainerProps> {
52
+ static __KONTUR_REACT_UI__: string;
53
+ static displayName: string;
54
+ static defaultProps: DefaultProps;
55
+ submit(withoutFocus?: boolean): Promise<void>;
56
+ submit(validationSettings?: ValidationSettings): Promise<void>;
57
+ validate(withoutFocus?: boolean): Promise<boolean>;
58
+ validate(validationSettings?: ValidationSettings): Promise<boolean>;
59
+ componentDidMount(): void;
60
+ componentDidUpdate(): void;
61
+ render(): React.JSX.Element;
62
+ }
63
+ export {};
64
+ }
65
+
66
+ declare module '@skbkontur/react-ui-validations/src/ValidationTooltip' {
67
+ import React from 'react';
68
+ export type TooltipPosition = 'top left' | 'top center' | 'top right' | 'bottom left' | 'bottom center' | 'bottom right' | 'left top' | 'left middle' | 'left bottom' | 'right top' | 'right middle' | 'right bottom';
69
+ export interface ValidationTooltipProps {
70
+ children: React.ReactElement<any>;
71
+ error: boolean;
72
+ pos?: TooltipPosition;
73
+ render?: () => React.ReactNode;
74
+ 'data-tid'?: string;
75
+ }
76
+ export class ValidationTooltip extends React.Component<ValidationTooltipProps> {
77
+ static __KONTUR_REACT_UI__: string;
78
+ static displayName: string;
79
+ render(): React.JSX.Element;
80
+ }
81
+ }
82
+
83
+ declare module '@skbkontur/react-ui-validations/src/ValidationWrapperInternal' {
84
+ import React from 'react';
85
+ import type { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
86
+ import type { ValidationContextType } from '@skbkontur/react-ui-validations/src/ValidationContextWrapper';
87
+ export type ValidationBehaviour = 'immediate' | 'lostfocus' | 'submit';
88
+ export type ValidationLevel = 'error' | 'warning';
89
+ export type TextPosition = 'bottom' | 'right';
90
+ export interface Validation {
91
+ level: ValidationLevel;
92
+ behaviour: ValidationBehaviour;
93
+ message: React.ReactNode;
94
+ independent: boolean;
95
+ }
96
+ export type RenderErrorMessage = (control: React.ReactElement<any>, hasError: boolean, validation: Nullable<Validation>) => React.ReactElement<any>;
97
+ export interface ValidationWrapperInternalProps {
98
+ children?: React.ReactElement<any>;
99
+ validation: Nullable<Validation>;
100
+ errorMessage: RenderErrorMessage;
101
+ 'data-tid'?: string;
102
+ }
103
+ interface ValidationWrapperInternalState {
104
+ validation: Nullable<Validation>;
105
+ }
106
+ interface Point {
107
+ x: number;
108
+ y: number;
109
+ }
110
+ export class ValidationWrapperInternal extends React.Component<ValidationWrapperInternalProps, ValidationWrapperInternalState> {
111
+ state: ValidationWrapperInternalState;
112
+ isChanging: boolean;
113
+ static contextType: React.Context<ValidationContextType>;
114
+ context: ValidationContextType;
115
+ componentDidMount(): void;
116
+ componentWillUnmount(): void;
117
+ componentDidUpdate(): void;
118
+ focus(): Promise<void>;
119
+ render(): React.JSX.Element;
120
+ getRootNode: () => Nullable<Element>;
121
+ getControlPosition(): Nullable<Point>;
122
+ processBlur(): Promise<void>;
123
+ processSubmit(): Promise<void>;
124
+ hasError(): boolean;
125
+ hasWarning(): boolean;
126
+ isIndependent(): boolean;
127
+ }
128
+ export {};
129
+ }
130
+
131
+ declare module '@skbkontur/react-ui-validations/src/ValidationWrapper' {
132
+ import React from 'react';
133
+ import type { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
134
+ import type { RenderErrorMessage, ValidationBehaviour, ValidationLevel, ValidationWrapperInternalProps } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
135
+ export interface ValidationInfo {
136
+ type?: Nullable<ValidationBehaviour>;
137
+ level?: Nullable<ValidationLevel>;
138
+ message: React.ReactNode;
139
+ independent?: boolean;
140
+ }
141
+ export interface ValidationWrapperProps extends Pick<ValidationWrapperInternalProps, 'data-tid'> {
142
+ children?: React.ReactElement<any>;
143
+ validationInfo: Nullable<ValidationInfo>;
144
+ renderMessage?: Nullable<RenderErrorMessage>;
145
+ }
146
+ export class ValidationWrapper extends React.Component<ValidationWrapperProps> {
147
+ static __KONTUR_REACT_UI__: string;
148
+ static displayName: string;
149
+ render(): React.JSX.Element;
150
+ }
151
+ }
152
+
153
+ declare module '@skbkontur/react-ui-validations/src/ValidationContextWrapper' {
154
+ import React from 'react';
155
+ import type { ValidationWrapperInternal } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
156
+ import type { ScrollOffset, ValidateArgumentType } from '@skbkontur/react-ui-validations/src/ValidationContainer';
157
+ export interface ValidationContextSettings {
158
+ scrollOffset: ScrollOffset;
159
+ disableSmoothScroll: boolean;
160
+ }
161
+ export interface ValidationContextWrapperProps {
162
+ 'data-tid'?: string;
163
+ children?: React.ReactNode;
164
+ onValidationUpdated?: (isValid?: boolean) => void;
165
+ scrollOffset?: number | ScrollOffset;
166
+ disableSmoothScroll: boolean;
167
+ }
168
+ export interface ValidationContextType {
169
+ register: (wrapper: ValidationWrapperInternal) => void;
170
+ unregister: (wrapper: ValidationWrapperInternal) => void;
171
+ instanceProcessBlur: (wrapper: ValidationWrapperInternal) => void;
172
+ onValidationUpdated: (wrapper: ValidationWrapperInternal, isValid: boolean) => void;
173
+ getSettings: () => ValidationContextSettings;
174
+ isAnyWrapperInChangingMode: () => boolean;
175
+ isValidationCalled: () => boolean;
176
+ }
177
+ export const ValidationContext: React.Context<ValidationContextType>;
178
+ export class ValidationContextWrapper extends React.Component<ValidationContextWrapperProps> {
179
+ childWrappers: ValidationWrapperInternal[];
180
+ validationHasBeenCalled: boolean;
181
+ getSettings(): ValidationContextSettings;
182
+ register(wrapper: ValidationWrapperInternal): void;
183
+ unregister(wrapper: ValidationWrapperInternal): void;
184
+ instanceProcessBlur(instance: ValidationWrapperInternal): void;
185
+ onValidationUpdated(wrapper: ValidationWrapperInternal, isValid?: boolean): void;
186
+ isAnyWrapperInChangingMode(): boolean;
187
+ isValidationCalled(): boolean;
188
+ onValidationRemoved(): void;
189
+ getChildWrappersSortedByPosition(): ValidationWrapperInternal[];
190
+ validate(withoutFocusOrValidationSettings: ValidateArgumentType): Promise<boolean>;
191
+ render(): React.JSX.Element;
192
+ }
193
+ }
194
+
195
+ declare module '@skbkontur/react-ui-validations/src/utils/featureFlagsContext' {
196
+ export * from '@skbkontur/react-ui-validations/src/utils/featureFlagsContext/ValidationsFeatureFlagsContext';
197
+ export * from '@skbkontur/react-ui-validations/src/utils/featureFlagsContext/FeatureFlagsHelpers';
198
+ }
199
+
200
+ declare module '@skbkontur/react-ui-validations/src/FocusMode' {
201
+ export enum FocusMode {
202
+ 'Errors' = 0,
203
+ 'ErrorsAndWarnings' = 1,
204
+ 'None' = 2
205
+ }
206
+ }
207
+
208
+ declare module '@skbkontur/react-ui-validations/src/Validations' {
209
+ import { ValidationBuilder } from '@skbkontur/react-ui-validations/src/Validations/ValidationBuilder';
210
+ import { RootValidationRule, ValidationRule, ItemValidationRule } from '@skbkontur/react-ui-validations/src/Validations/Types';
211
+ import { ValidationReader } from '@skbkontur/react-ui-validations/src/Validations/ValidationReader';
212
+ export type Validator<T> = (value: T) => ValidationReader<T>;
213
+ export function createValidator<T>(rule: RootValidationRule<T>): Validator<T>;
214
+ export { ValidationReader, ValidationBuilder, RootValidationRule, ValidationRule, ItemValidationRule };
215
+ }
216
+
217
+ declare module '@skbkontur/react-ui-validations/typings/Types' {
218
+ export type Nullable<T> = T | null | undefined;
219
+ export type Omit<T extends Record<string, any>, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
220
+ export type ExtractItem<T> = T extends Array<infer TItem> ? TItem : never;
221
+ }
222
+
223
+ declare module '@skbkontur/react-ui-validations/src/utils/featureFlagsContext/ValidationsFeatureFlagsContext' {
224
+ import React from 'react';
225
+ export interface ValidationsFeatureFlags {
226
+ dropdownsDoNotOpenOnFocusByValidation?: boolean;
227
+ hideTooltipOnSelectionControls?: boolean;
228
+ validationWrapperValidateOnMount?: boolean;
229
+ }
230
+ export const validationsFeatureFlagsDefault: ValidationsFeatureFlags;
231
+ export const ValidationsFeatureFlagsContext: React.Context<ValidationsFeatureFlags>;
232
+ }
233
+
234
+ declare module '@skbkontur/react-ui-validations/src/utils/featureFlagsContext/FeatureFlagsHelpers' {
235
+ import type { ValidationsFeatureFlags } from '@skbkontur/react-ui-validations/src/utils/featureFlagsContext/ValidationsFeatureFlagsContext';
236
+ export const getFullValidationsFlagsContext: (flags: ValidationsFeatureFlags) => {
237
+ dropdownsDoNotOpenOnFocusByValidation?: boolean | undefined;
238
+ hideTooltipOnSelectionControls?: boolean | undefined;
239
+ validationWrapperValidateOnMount?: boolean | undefined;
240
+ };
241
+ }
242
+
243
+ declare module '@skbkontur/react-ui-validations/src/Validations/ValidationBuilder' {
244
+ import type React from 'react';
245
+ import type { ValidationBehaviour, ValidationLevel } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
246
+ import type { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
247
+ import type { LambdaPath, PathTokensCache } from '@skbkontur/react-ui-validations/src/Validations/PathHelper';
248
+ import type { ValidationWriter } from '@skbkontur/react-ui-validations/src/Validations/ValidationWriter';
249
+ import type { ItemValidationRule, ValidationRule } from '@skbkontur/react-ui-validations/src/Validations/Types';
250
+ export class ValidationBuilder<TRoot, T> {
251
+ constructor(writer: ValidationWriter<TRoot>, tokens: PathTokensCache, path: string[], data: T);
252
+ prop<TChild>(lambdaPath: LambdaPath<T, TChild>, rule: ValidationRule<TRoot, TChild>): void;
253
+ array<TChild>(lambdaPath: LambdaPath<T, TChild[]>, rule: ItemValidationRule<TRoot, TChild>): void;
254
+ invalid(isInvalid: (value: T) => boolean, validationInfo: ValidationInfo): void;
255
+ invalid(isInvalid: (value: T) => boolean, message: React.ReactNode, type?: ValidationBehaviour, level?: ValidationLevel, independent?: boolean): void;
256
+ }
257
+ }
258
+
259
+ declare module '@skbkontur/react-ui-validations/src/Validations/Types' {
260
+ import type { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
261
+ import type { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
262
+ import type { ValidationBuilder } from '@skbkontur/react-ui-validations/src/Validations/ValidationBuilder';
263
+ export interface ValidationNode<T> {
264
+ validation: Nullable<ValidationInfo>;
265
+ children: Nullable<{
266
+ [K in keyof T]: ValidationNode<T[K]>;
267
+ }>;
268
+ }
269
+ export type ValidationRule<TRoot, T> = (builder: ValidationBuilder<TRoot, T>, value: T) => void;
270
+ export type ItemValidationRule<TRoot, T> = (builder: ValidationBuilder<TRoot, T>, value: T, index: number, array: T[]) => void;
271
+ export type RootValidationRule<T> = ValidationRule<T, T>;
272
+ }
273
+
274
+ declare module '@skbkontur/react-ui-validations/src/Validations/ValidationReader' {
275
+ import type { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
276
+ import type { ExtractItem, Nullable } from '@skbkontur/react-ui-validations/typings/Types';
277
+ import type { ValidationNode } from '@skbkontur/react-ui-validations/src/Validations/Types';
278
+ import type { LambdaPath, PathTokensCache } from '@skbkontur/react-ui-validations/src/Validations/PathHelper';
279
+ export class ValidationReader<T> {
280
+ constructor(node: Nullable<ValidationNode<T>>, tokens: PathTokensCache);
281
+ getNode<TChild>(lambdaPath: LambdaPath<T, TChild>): ValidationReader<TChild>;
282
+ getNodeByIndex(index: number): ValidationReader<ExtractItem<T>>;
283
+ getNodeByKey<TKey extends keyof T>(key: TKey): ValidationReader<T[TKey]>;
284
+ get(): Nullable<ValidationInfo>;
285
+ }
286
+ }
287
+
288
+ declare module '@skbkontur/react-ui-validations/src/Validations/PathHelper' {
289
+ type NonNullableRecursive<T> = {
290
+ [K in keyof T]-?: T[K] extends Record<string, unknown> ? NonNullable<NonNullableRecursive<T[K]>> : NonNullable<T[K]>;
291
+ };
292
+ export type LambdaPath<T, TChild> = (x: NonNullable<NonNullableRecursive<T>>) => TChild;
293
+ export function extractPath(lambda: string): string;
294
+ export function extractTokens(path: string): string[];
295
+ export class PathTokensCache {
296
+ getOrAdd<T, TChild>(lambdaPath: LambdaPath<T, TChild>): string[];
297
+ has<T, TChild>(lambdaPath: LambdaPath<T, TChild>): boolean;
298
+ get size(): number;
299
+ }
300
+ export {};
301
+ }
302
+
303
+ declare module '@skbkontur/react-ui-validations/src/Validations/ValidationWriter' {
304
+ import type { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
305
+ import type { ValidationNode } from '@skbkontur/react-ui-validations/src/Validations/Types';
306
+ import { ValidationReader } from '@skbkontur/react-ui-validations/src/Validations/ValidationReader';
307
+ import type { PathTokensCache } from '@skbkontur/react-ui-validations/src/Validations/PathHelper';
308
+ export class ValidationWriter<T> {
309
+ constructor(node?: ValidationNode<T>);
310
+ getReader(tokens: PathTokensCache): ValidationReader<T>;
311
+ set(validation: ValidationInfo): void;
312
+ isValidated(): boolean;
313
+ getNode<TChild>(path: string[]): ValidationWriter<TChild>;
314
+ }
315
+ }
316
+