@skbkontur/react-ui-validations 1.6.0-beta.1 → 1.8.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/CHANGELOG.md +46 -0
- package/README.md +4 -0
- package/index.d.ts +256 -256
- package/index.js +40 -37
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,52 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.8.0](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/compare/react-ui-validations@1.7.0...react-ui-validations@1.8.0) (2022-03-01)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **react-ui:** call original refs while replacing them ([#2729](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/issues/2729)) ([cd75e9f](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/commit/cd75e9f8fb03b469b783171cb74c099841b5ab6f))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **FileUploader:** new component FileUploader ([#2542](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/issues/2542)) ([18d009a](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/commit/18d009a8ebeafa2379d5fb46a564ead97c3da6a5))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [1.7.0](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/compare/react-ui-validations@1.6.0...react-ui-validations@1.7.0) (2022-01-27)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* **react-ui:** [StrictMode] give up findDomNode ([#2518](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/issues/2518)) ([8028cdd](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/commit/8028cdd3c2289fd48816bdaf92da6a28892f40a7))
|
|
28
|
+
* **react-ui:** [StrictMode] give up legacy context ([#2694](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/issues/2694)) ([d0253cc](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/commit/d0253ccc089764a317ccaa79aa00cc96fbb7aa0a))
|
|
29
|
+
* **react-ui:** [StrictMode] give up unsafe methods ([#2514](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/issues/2514)) ([6cc2201](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/commit/6cc2201f0e8f711441e6c63229b703c03d4b6953))
|
|
30
|
+
* **react-ui:** call original refs while replacing them ([#2736](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/issues/2736)) ([01ff2ab](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/commit/01ff2ab3243082c9347d20e844368ac775e54449))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* support React.StrictMode ([04a4bc9](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/commit/04a4bc9f2dd35fa98ea4d9526ddd775dd1017b71))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# [1.6.0](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/compare/react-ui-validations@1.5.7...react-ui-validations@1.6.0) (2021-12-27)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Features
|
|
45
|
+
|
|
46
|
+
* **react-ui-validations:** add independent validation ([#2632](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/issues/2632)) ([f1f2a9a](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/commit/f1f2a9adf61e2b9b096f9e1f4dbeb04c4046e582))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
6
52
|
## [1.5.7](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/compare/react-ui-validations@1.5.6...react-ui-validations@1.5.7) (2021-10-25)
|
|
7
53
|
|
|
8
54
|
**Note:** Version bump only for package react-ui-validations
|
package/README.md
CHANGED
|
@@ -39,3 +39,7 @@ export default class DataEditor extends React.Component {
|
|
|
39
39
|
```shell
|
|
40
40
|
yarn start:docs
|
|
41
41
|
```
|
|
42
|
+
|
|
43
|
+
## StrictMode
|
|
44
|
+
|
|
45
|
+
Библиотека поддерживает работу в React.StrictMode начиная с версии `1.7.0`. [Подробнее](https://github.com/skbkontur/retail-ui/blob/master/packages/react-ui/README.md#strictmode).
|
package/index.d.ts
CHANGED
|
@@ -1,256 +1,256 @@
|
|
|
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, ValidationContainerProps } from '@skbkontur/react-ui-validations/src/ValidationContainer';
|
|
8
|
-
import { TooltipPosition, ValidationTooltip, ValidationTooltipProps } from '@skbkontur/react-ui-validations/src/ValidationTooltip';
|
|
9
|
-
import { RenderErrorMessage, Validation, ValidationBehaviour } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
|
|
10
|
-
import { ValidationWrapper, ValidationInfo, ValidationWrapperProps } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
|
|
11
|
-
import { ValidationContext, ValidationContextType, ValidationContextWrapper, ValidationContextWrapperProps } from '@skbkontur/react-ui-validations/src/ValidationContextWrapper';
|
|
12
|
-
export { ValidationContainer, ValidationContainerProps, ValidationContext, ValidationContextType, ValidationContextWrapper, ValidationContextWrapperProps, ValidationWrapper as ValidationWrapperV1, ValidationWrapperProps as ValidationWrapperV1Props, RenderErrorMessage, ValidationBehaviour, Validation, ValidationWrapper, ValidationWrapperProps, ValidationInfo, ValidationTooltip, ValidationTooltipProps, TooltipPosition, tooltip, text, };
|
|
13
|
-
export * from '@skbkontur/react-ui-validations/src/Validations';
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare module '@skbkontur/react-ui-validations/src/ErrorRenderer' {
|
|
17
|
-
import { TooltipPosition } from '@skbkontur/react-ui-validations/src/ValidationTooltip';
|
|
18
|
-
import { RenderErrorMessage } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
|
|
19
|
-
export function tooltip(pos: TooltipPosition): RenderErrorMessage;
|
|
20
|
-
export function text(pos?: 'bottom' | 'right'): RenderErrorMessage;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
declare module '@skbkontur/react-ui-validations/src/ValidationContainer' {
|
|
24
|
-
import React from 'react';
|
|
25
|
-
import { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
|
|
26
|
-
export interface ScrollOffset {
|
|
27
|
-
top?: number;
|
|
28
|
-
bottom?: number;
|
|
29
|
-
}
|
|
30
|
-
export interface ValidationContainerProps {
|
|
31
|
-
children?: React.ReactNode;
|
|
32
|
-
onValidationUpdated?: (isValid?: Nullable<boolean>) => void;
|
|
33
|
-
scrollOffset?: number | ScrollOffset;
|
|
34
|
-
disableSmoothScroll: boolean;
|
|
35
|
-
}
|
|
36
|
-
export class ValidationContainer extends React.Component<ValidationContainerProps> {
|
|
37
|
-
static __KONTUR_REACT_UI__: string;
|
|
38
|
-
static defaultProps: {
|
|
39
|
-
disableSmoothScroll: boolean;
|
|
40
|
-
};
|
|
41
|
-
static propTypes: {
|
|
42
|
-
scrollOffset(props: ValidationContainerProps, propName: keyof ValidationContainerProps, componentName: string): Error | undefined;
|
|
43
|
-
};
|
|
44
|
-
submit(withoutFocus?: boolean): Promise<void>;
|
|
45
|
-
validate(withoutFocus?: boolean): Promise<boolean>;
|
|
46
|
-
render(): JSX.Element;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
declare module '@skbkontur/react-ui-validations/src/ValidationTooltip' {
|
|
51
|
-
import React from 'react';
|
|
52
|
-
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';
|
|
53
|
-
export interface ValidationTooltipProps {
|
|
54
|
-
children: React.ReactElement<any>;
|
|
55
|
-
error: boolean;
|
|
56
|
-
pos?: TooltipPosition;
|
|
57
|
-
render?: () => React.ReactNode;
|
|
58
|
-
}
|
|
59
|
-
export class ValidationTooltip extends React.Component<ValidationTooltipProps> {
|
|
60
|
-
render(): JSX.Element;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
declare module '@skbkontur/react-ui-validations/src/ValidationWrapperInternal' {
|
|
65
|
-
import React from 'react';
|
|
66
|
-
import { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
|
|
67
|
-
import { ValidationContextType } from '@skbkontur/react-ui-validations/src/ValidationContextWrapper';
|
|
68
|
-
export type ValidationBehaviour = 'immediate' | 'lostfocus' | 'submit';
|
|
69
|
-
export type ValidationLevel = 'error' | 'warning';
|
|
70
|
-
export interface Validation {
|
|
71
|
-
level: ValidationLevel;
|
|
72
|
-
behaviour: ValidationBehaviour;
|
|
73
|
-
message: React.ReactNode;
|
|
74
|
-
independent: boolean;
|
|
75
|
-
}
|
|
76
|
-
export type RenderErrorMessage = (control: React.ReactElement<any>, hasError: boolean, validation: Nullable<Validation>) => React.ReactElement<any>;
|
|
77
|
-
export interface ValidationWrapperInternalProps {
|
|
78
|
-
children?: React.ReactElement<any>;
|
|
79
|
-
validation: Nullable<Validation>;
|
|
80
|
-
errorMessage: RenderErrorMessage;
|
|
81
|
-
}
|
|
82
|
-
interface ValidationWrapperInternalState {
|
|
83
|
-
validation: Nullable<Validation>;
|
|
84
|
-
}
|
|
85
|
-
interface Point {
|
|
86
|
-
x: number;
|
|
87
|
-
y: number;
|
|
88
|
-
}
|
|
89
|
-
export class ValidationWrapperInternal extends React.Component<ValidationWrapperInternalProps, ValidationWrapperInternalState> {
|
|
90
|
-
state: ValidationWrapperInternalState;
|
|
91
|
-
isChanging: boolean;
|
|
92
|
-
static contextType: React.Context<ValidationContextType>;
|
|
93
|
-
context: ValidationContextType;
|
|
94
|
-
componentDidMount(): void;
|
|
95
|
-
componentWillUnmount(): void;
|
|
96
|
-
componentDidUpdate(): void;
|
|
97
|
-
focus(): Promise<void>;
|
|
98
|
-
render(): React.ReactElement<any, string |
|
|
99
|
-
getRootNode: () => Nullable<HTMLElement>;
|
|
100
|
-
getControlPosition(): Nullable<Point>;
|
|
101
|
-
processBlur(): Promise<void>;
|
|
102
|
-
processSubmit(): Promise<void>;
|
|
103
|
-
hasError(): boolean;
|
|
104
|
-
isIndependent(): boolean;
|
|
105
|
-
}
|
|
106
|
-
export {};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
declare module '@skbkontur/react-ui-validations/src/ValidationWrapper' {
|
|
110
|
-
import React from 'react';
|
|
111
|
-
import { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
|
|
112
|
-
import { RenderErrorMessage, ValidationBehaviour, ValidationLevel } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
|
|
113
|
-
export interface ValidationInfo {
|
|
114
|
-
type?: Nullable<ValidationBehaviour>;
|
|
115
|
-
level?: Nullable<ValidationLevel>;
|
|
116
|
-
message: React.ReactNode;
|
|
117
|
-
independent?: boolean;
|
|
118
|
-
}
|
|
119
|
-
export interface ValidationWrapperProps {
|
|
120
|
-
children?: React.ReactElement<any>;
|
|
121
|
-
validationInfo: Nullable<ValidationInfo>;
|
|
122
|
-
renderMessage?: Nullable<RenderErrorMessage>;
|
|
123
|
-
}
|
|
124
|
-
export class ValidationWrapper extends React.Component<ValidationWrapperProps> {
|
|
125
|
-
static __KONTUR_REACT_UI__: string;
|
|
126
|
-
render(): JSX.Element;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
declare module '@skbkontur/react-ui-validations/src/ValidationContextWrapper' {
|
|
131
|
-
import React from 'react';
|
|
132
|
-
import { ValidationWrapperInternal } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
|
|
133
|
-
import { ScrollOffset } from '@skbkontur/react-ui-validations/src/ValidationContainer';
|
|
134
|
-
export interface ValidationContextSettings {
|
|
135
|
-
scrollOffset: ScrollOffset;
|
|
136
|
-
disableSmoothScroll: boolean;
|
|
137
|
-
}
|
|
138
|
-
export interface ValidationContextWrapperProps {
|
|
139
|
-
children?: React.ReactNode;
|
|
140
|
-
onValidationUpdated?: (isValid?: boolean) => void;
|
|
141
|
-
scrollOffset?: number | ScrollOffset;
|
|
142
|
-
disableSmoothScroll: boolean;
|
|
143
|
-
}
|
|
144
|
-
export interface ValidationContextType {
|
|
145
|
-
register: (wrapper: ValidationWrapperInternal) => void;
|
|
146
|
-
unregister: (wrapper: ValidationWrapperInternal) => void;
|
|
147
|
-
instanceProcessBlur: (wrapper: ValidationWrapperInternal) => void;
|
|
148
|
-
onValidationUpdated: (wrapper: ValidationWrapperInternal, isValid: boolean) => void;
|
|
149
|
-
getSettings: () => ValidationContextSettings;
|
|
150
|
-
isAnyWrapperInChangingMode: () => boolean;
|
|
151
|
-
}
|
|
152
|
-
export const ValidationContext: React.Context<ValidationContextType>;
|
|
153
|
-
export class ValidationContextWrapper extends React.Component<ValidationContextWrapperProps> {
|
|
154
|
-
childWrappers: ValidationWrapperInternal[];
|
|
155
|
-
getSettings(): ValidationContextSettings;
|
|
156
|
-
register(wrapper: ValidationWrapperInternal): void;
|
|
157
|
-
unregister(wrapper: ValidationWrapperInternal): void;
|
|
158
|
-
instanceProcessBlur(instance: ValidationWrapperInternal): void;
|
|
159
|
-
onValidationUpdated(wrapper: ValidationWrapperInternal, isValid?: boolean): void;
|
|
160
|
-
isAnyWrapperInChangingMode(): boolean;
|
|
161
|
-
onValidationRemoved(): void;
|
|
162
|
-
getChildWrappersSortedByPosition(): ValidationWrapperInternal[];
|
|
163
|
-
validate(withoutFocus: boolean): Promise<boolean>;
|
|
164
|
-
render(): JSX.Element;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
declare module '@skbkontur/react-ui-validations/src/Validations' {
|
|
169
|
-
import { ValidationBuilder } from '@skbkontur/react-ui-validations/src/Validations/ValidationBuilder';
|
|
170
|
-
import { RootValidationRule, ValidationRule, ItemValidationRule } from '@skbkontur/react-ui-validations/src/Validations/Types';
|
|
171
|
-
import { ValidationReader } from '@skbkontur/react-ui-validations/src/Validations/ValidationReader';
|
|
172
|
-
export type Validator<T> = (value: T) => ValidationReader<T>;
|
|
173
|
-
export function createValidator<T>(rule: RootValidationRule<T>): Validator<T>;
|
|
174
|
-
export { ValidationReader, ValidationBuilder, RootValidationRule, ValidationRule, ItemValidationRule };
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
declare module '@skbkontur/react-ui-validations/typings/Types' {
|
|
178
|
-
export type Nullable<T> = T | null | undefined;
|
|
179
|
-
export type Omit<T extends object, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
180
|
-
export type ExtractItem<T> = T extends Array<infer TItem> ? TItem : never;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
declare module '@skbkontur/react-ui-validations/src/Validations/ValidationBuilder' {
|
|
184
|
-
import React from 'react';
|
|
185
|
-
import { ValidationBehaviour, ValidationLevel } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
|
|
186
|
-
import { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
|
|
187
|
-
import { LambdaPath, PathTokensCache } from '@skbkontur/react-ui-validations/src/Validations/PathHelper';
|
|
188
|
-
import { ValidationWriter } from '@skbkontur/react-ui-validations/src/Validations/ValidationWriter';
|
|
189
|
-
import { ItemValidationRule, ValidationRule } from '@skbkontur/react-ui-validations/src/Validations/Types';
|
|
190
|
-
export class ValidationBuilder<TRoot, T> {
|
|
191
|
-
constructor(writer: ValidationWriter<TRoot>, tokens: PathTokensCache, path: string[], data: T);
|
|
192
|
-
prop<TChild>(lambdaPath: LambdaPath<T, TChild>, rule: ValidationRule<TRoot, TChild>): void;
|
|
193
|
-
array<TChild>(lambdaPath: LambdaPath<T, TChild[]>, rule: ItemValidationRule<TRoot, TChild>): void;
|
|
194
|
-
invalid(isInvalid: (value: T) => boolean, validationInfo: ValidationInfo): void;
|
|
195
|
-
invalid(isInvalid: (value: T) => boolean, message: React.ReactNode, type?: ValidationBehaviour, level?: ValidationLevel, independent?: boolean): void;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
declare module '@skbkontur/react-ui-validations/src/Validations/Types' {
|
|
200
|
-
import { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
|
|
201
|
-
import { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
|
|
202
|
-
import { ValidationBuilder } from '@skbkontur/react-ui-validations/src/Validations/ValidationBuilder';
|
|
203
|
-
export interface ValidationNode<T> {
|
|
204
|
-
validation: Nullable<ValidationInfo>;
|
|
205
|
-
children: Nullable<{
|
|
206
|
-
[K in keyof T]: ValidationNode<T[K]>;
|
|
207
|
-
}>;
|
|
208
|
-
}
|
|
209
|
-
export type ValidationRule<TRoot, T> = (builder: ValidationBuilder<TRoot, T>, value: T) => void;
|
|
210
|
-
export type ItemValidationRule<TRoot, T> = (builder: ValidationBuilder<TRoot, T>, value: T, index: number, array: T[]) => void;
|
|
211
|
-
export type RootValidationRule<T> = ValidationRule<T, T>;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
declare module '@skbkontur/react-ui-validations/src/Validations/ValidationReader' {
|
|
215
|
-
import { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
|
|
216
|
-
import { ExtractItem, Nullable } from '@skbkontur/react-ui-validations/typings/Types';
|
|
217
|
-
import { ValidationNode } from '@skbkontur/react-ui-validations/src/Validations/Types';
|
|
218
|
-
import { LambdaPath, PathTokensCache } from '@skbkontur/react-ui-validations/src/Validations/PathHelper';
|
|
219
|
-
export class ValidationReader<T> {
|
|
220
|
-
constructor(node: Nullable<ValidationNode<T>>, tokens: PathTokensCache);
|
|
221
|
-
getNode<TChild>(lambdaPath: LambdaPath<T, TChild>): ValidationReader<TChild>;
|
|
222
|
-
getNodeByIndex(index: number): ValidationReader<ExtractItem<T>>;
|
|
223
|
-
getNodeByKey<TKey extends keyof T>(key: TKey): ValidationReader<T[TKey]>;
|
|
224
|
-
get(): Nullable<ValidationInfo>;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
declare module '@skbkontur/react-ui-validations/src/Validations/PathHelper' {
|
|
229
|
-
type NonNullableRecursive<T> = {
|
|
230
|
-
[K in keyof T]: T[K] extends object ? NonNullable<NonNullableRecursive<T[K]>> : NonNullable<T[K]>;
|
|
231
|
-
};
|
|
232
|
-
export type LambdaPath<T, TChild> = (x: NonNullable<NonNullableRecursive<T>>) => TChild;
|
|
233
|
-
export function extractPath(lambda: string): string;
|
|
234
|
-
export function extractTokens(path: string): string[];
|
|
235
|
-
export class PathTokensCache {
|
|
236
|
-
getOrAdd<T, TChild>(lambdaPath: LambdaPath<T, TChild>): string[];
|
|
237
|
-
has<T, TChild>(lambdaPath: LambdaPath<T, TChild>): boolean;
|
|
238
|
-
get size(): number;
|
|
239
|
-
}
|
|
240
|
-
export {};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
declare module '@skbkontur/react-ui-validations/src/Validations/ValidationWriter' {
|
|
244
|
-
import { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
|
|
245
|
-
import { ValidationNode } from '@skbkontur/react-ui-validations/src/Validations/Types';
|
|
246
|
-
import { ValidationReader } from '@skbkontur/react-ui-validations/src/Validations/ValidationReader';
|
|
247
|
-
import { PathTokensCache } from '@skbkontur/react-ui-validations/src/Validations/PathHelper';
|
|
248
|
-
export class ValidationWriter<T> {
|
|
249
|
-
constructor(node?: ValidationNode<T>);
|
|
250
|
-
getReader(tokens: PathTokensCache): ValidationReader<T>;
|
|
251
|
-
set(validation: ValidationInfo): void;
|
|
252
|
-
isValidated(): boolean;
|
|
253
|
-
getNode<TChild>(path: string[]): ValidationWriter<TChild>;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
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, ValidationContainerProps } from '@skbkontur/react-ui-validations/src/ValidationContainer';
|
|
8
|
+
import { TooltipPosition, ValidationTooltip, ValidationTooltipProps } from '@skbkontur/react-ui-validations/src/ValidationTooltip';
|
|
9
|
+
import { RenderErrorMessage, Validation, ValidationBehaviour } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
|
|
10
|
+
import { ValidationWrapper, ValidationInfo, ValidationWrapperProps } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
|
|
11
|
+
import { ValidationContext, ValidationContextType, ValidationContextWrapper, ValidationContextWrapperProps } from '@skbkontur/react-ui-validations/src/ValidationContextWrapper';
|
|
12
|
+
export { ValidationContainer, ValidationContainerProps, ValidationContext, ValidationContextType, ValidationContextWrapper, ValidationContextWrapperProps, ValidationWrapper as ValidationWrapperV1, ValidationWrapperProps as ValidationWrapperV1Props, RenderErrorMessage, ValidationBehaviour, Validation, ValidationWrapper, ValidationWrapperProps, ValidationInfo, ValidationTooltip, ValidationTooltipProps, TooltipPosition, tooltip, text, };
|
|
13
|
+
export * from '@skbkontur/react-ui-validations/src/Validations';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare module '@skbkontur/react-ui-validations/src/ErrorRenderer' {
|
|
17
|
+
import { TooltipPosition } from '@skbkontur/react-ui-validations/src/ValidationTooltip';
|
|
18
|
+
import { RenderErrorMessage } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
|
|
19
|
+
export function tooltip(pos: TooltipPosition): RenderErrorMessage;
|
|
20
|
+
export function text(pos?: 'bottom' | 'right'): RenderErrorMessage;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare module '@skbkontur/react-ui-validations/src/ValidationContainer' {
|
|
24
|
+
import React from 'react';
|
|
25
|
+
import { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
|
|
26
|
+
export interface ScrollOffset {
|
|
27
|
+
top?: number;
|
|
28
|
+
bottom?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface ValidationContainerProps {
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
onValidationUpdated?: (isValid?: Nullable<boolean>) => void;
|
|
33
|
+
scrollOffset?: number | ScrollOffset;
|
|
34
|
+
disableSmoothScroll: boolean;
|
|
35
|
+
}
|
|
36
|
+
export class ValidationContainer extends React.Component<ValidationContainerProps> {
|
|
37
|
+
static __KONTUR_REACT_UI__: string;
|
|
38
|
+
static defaultProps: {
|
|
39
|
+
disableSmoothScroll: boolean;
|
|
40
|
+
};
|
|
41
|
+
static propTypes: {
|
|
42
|
+
scrollOffset(props: ValidationContainerProps, propName: keyof ValidationContainerProps, componentName: string): Error | undefined;
|
|
43
|
+
};
|
|
44
|
+
submit(withoutFocus?: boolean): Promise<void>;
|
|
45
|
+
validate(withoutFocus?: boolean): Promise<boolean>;
|
|
46
|
+
render(): JSX.Element;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare module '@skbkontur/react-ui-validations/src/ValidationTooltip' {
|
|
51
|
+
import React from 'react';
|
|
52
|
+
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';
|
|
53
|
+
export interface ValidationTooltipProps {
|
|
54
|
+
children: React.ReactElement<any>;
|
|
55
|
+
error: boolean;
|
|
56
|
+
pos?: TooltipPosition;
|
|
57
|
+
render?: () => React.ReactNode;
|
|
58
|
+
}
|
|
59
|
+
export class ValidationTooltip extends React.Component<ValidationTooltipProps> {
|
|
60
|
+
render(): JSX.Element;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare module '@skbkontur/react-ui-validations/src/ValidationWrapperInternal' {
|
|
65
|
+
import React from 'react';
|
|
66
|
+
import { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
|
|
67
|
+
import { ValidationContextType } from '@skbkontur/react-ui-validations/src/ValidationContextWrapper';
|
|
68
|
+
export type ValidationBehaviour = 'immediate' | 'lostfocus' | 'submit';
|
|
69
|
+
export type ValidationLevel = 'error' | 'warning';
|
|
70
|
+
export interface Validation {
|
|
71
|
+
level: ValidationLevel;
|
|
72
|
+
behaviour: ValidationBehaviour;
|
|
73
|
+
message: React.ReactNode;
|
|
74
|
+
independent: boolean;
|
|
75
|
+
}
|
|
76
|
+
export type RenderErrorMessage = (control: React.ReactElement<any>, hasError: boolean, validation: Nullable<Validation>) => React.ReactElement<any>;
|
|
77
|
+
export interface ValidationWrapperInternalProps {
|
|
78
|
+
children?: React.ReactElement<any>;
|
|
79
|
+
validation: Nullable<Validation>;
|
|
80
|
+
errorMessage: RenderErrorMessage;
|
|
81
|
+
}
|
|
82
|
+
interface ValidationWrapperInternalState {
|
|
83
|
+
validation: Nullable<Validation>;
|
|
84
|
+
}
|
|
85
|
+
interface Point {
|
|
86
|
+
x: number;
|
|
87
|
+
y: number;
|
|
88
|
+
}
|
|
89
|
+
export class ValidationWrapperInternal extends React.Component<ValidationWrapperInternalProps, ValidationWrapperInternalState> {
|
|
90
|
+
state: ValidationWrapperInternalState;
|
|
91
|
+
isChanging: boolean;
|
|
92
|
+
static contextType: React.Context<ValidationContextType>;
|
|
93
|
+
context: ValidationContextType;
|
|
94
|
+
componentDidMount(): void;
|
|
95
|
+
componentWillUnmount(): void;
|
|
96
|
+
componentDidUpdate(): void;
|
|
97
|
+
focus(): Promise<void>;
|
|
98
|
+
render(): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
99
|
+
getRootNode: () => Nullable<HTMLElement>;
|
|
100
|
+
getControlPosition(): Nullable<Point>;
|
|
101
|
+
processBlur(): Promise<void>;
|
|
102
|
+
processSubmit(): Promise<void>;
|
|
103
|
+
hasError(): boolean;
|
|
104
|
+
isIndependent(): boolean;
|
|
105
|
+
}
|
|
106
|
+
export {};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
declare module '@skbkontur/react-ui-validations/src/ValidationWrapper' {
|
|
110
|
+
import React from 'react';
|
|
111
|
+
import { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
|
|
112
|
+
import { RenderErrorMessage, ValidationBehaviour, ValidationLevel } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
|
|
113
|
+
export interface ValidationInfo {
|
|
114
|
+
type?: Nullable<ValidationBehaviour>;
|
|
115
|
+
level?: Nullable<ValidationLevel>;
|
|
116
|
+
message: React.ReactNode;
|
|
117
|
+
independent?: boolean;
|
|
118
|
+
}
|
|
119
|
+
export interface ValidationWrapperProps {
|
|
120
|
+
children?: React.ReactElement<any>;
|
|
121
|
+
validationInfo: Nullable<ValidationInfo>;
|
|
122
|
+
renderMessage?: Nullable<RenderErrorMessage>;
|
|
123
|
+
}
|
|
124
|
+
export class ValidationWrapper extends React.Component<ValidationWrapperProps> {
|
|
125
|
+
static __KONTUR_REACT_UI__: string;
|
|
126
|
+
render(): JSX.Element;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
declare module '@skbkontur/react-ui-validations/src/ValidationContextWrapper' {
|
|
131
|
+
import React from 'react';
|
|
132
|
+
import { ValidationWrapperInternal } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
|
|
133
|
+
import { ScrollOffset } from '@skbkontur/react-ui-validations/src/ValidationContainer';
|
|
134
|
+
export interface ValidationContextSettings {
|
|
135
|
+
scrollOffset: ScrollOffset;
|
|
136
|
+
disableSmoothScroll: boolean;
|
|
137
|
+
}
|
|
138
|
+
export interface ValidationContextWrapperProps {
|
|
139
|
+
children?: React.ReactNode;
|
|
140
|
+
onValidationUpdated?: (isValid?: boolean) => void;
|
|
141
|
+
scrollOffset?: number | ScrollOffset;
|
|
142
|
+
disableSmoothScroll: boolean;
|
|
143
|
+
}
|
|
144
|
+
export interface ValidationContextType {
|
|
145
|
+
register: (wrapper: ValidationWrapperInternal) => void;
|
|
146
|
+
unregister: (wrapper: ValidationWrapperInternal) => void;
|
|
147
|
+
instanceProcessBlur: (wrapper: ValidationWrapperInternal) => void;
|
|
148
|
+
onValidationUpdated: (wrapper: ValidationWrapperInternal, isValid: boolean) => void;
|
|
149
|
+
getSettings: () => ValidationContextSettings;
|
|
150
|
+
isAnyWrapperInChangingMode: () => boolean;
|
|
151
|
+
}
|
|
152
|
+
export const ValidationContext: React.Context<ValidationContextType>;
|
|
153
|
+
export class ValidationContextWrapper extends React.Component<ValidationContextWrapperProps> {
|
|
154
|
+
childWrappers: ValidationWrapperInternal[];
|
|
155
|
+
getSettings(): ValidationContextSettings;
|
|
156
|
+
register(wrapper: ValidationWrapperInternal): void;
|
|
157
|
+
unregister(wrapper: ValidationWrapperInternal): void;
|
|
158
|
+
instanceProcessBlur(instance: ValidationWrapperInternal): void;
|
|
159
|
+
onValidationUpdated(wrapper: ValidationWrapperInternal, isValid?: boolean): void;
|
|
160
|
+
isAnyWrapperInChangingMode(): boolean;
|
|
161
|
+
onValidationRemoved(): void;
|
|
162
|
+
getChildWrappersSortedByPosition(): ValidationWrapperInternal[];
|
|
163
|
+
validate(withoutFocus: boolean): Promise<boolean>;
|
|
164
|
+
render(): JSX.Element;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
declare module '@skbkontur/react-ui-validations/src/Validations' {
|
|
169
|
+
import { ValidationBuilder } from '@skbkontur/react-ui-validations/src/Validations/ValidationBuilder';
|
|
170
|
+
import { RootValidationRule, ValidationRule, ItemValidationRule } from '@skbkontur/react-ui-validations/src/Validations/Types';
|
|
171
|
+
import { ValidationReader } from '@skbkontur/react-ui-validations/src/Validations/ValidationReader';
|
|
172
|
+
export type Validator<T> = (value: T) => ValidationReader<T>;
|
|
173
|
+
export function createValidator<T>(rule: RootValidationRule<T>): Validator<T>;
|
|
174
|
+
export { ValidationReader, ValidationBuilder, RootValidationRule, ValidationRule, ItemValidationRule };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
declare module '@skbkontur/react-ui-validations/typings/Types' {
|
|
178
|
+
export type Nullable<T> = T | null | undefined;
|
|
179
|
+
export type Omit<T extends object, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
180
|
+
export type ExtractItem<T> = T extends Array<infer TItem> ? TItem : never;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
declare module '@skbkontur/react-ui-validations/src/Validations/ValidationBuilder' {
|
|
184
|
+
import React from 'react';
|
|
185
|
+
import { ValidationBehaviour, ValidationLevel } from '@skbkontur/react-ui-validations/src/ValidationWrapperInternal';
|
|
186
|
+
import { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
|
|
187
|
+
import { LambdaPath, PathTokensCache } from '@skbkontur/react-ui-validations/src/Validations/PathHelper';
|
|
188
|
+
import { ValidationWriter } from '@skbkontur/react-ui-validations/src/Validations/ValidationWriter';
|
|
189
|
+
import { ItemValidationRule, ValidationRule } from '@skbkontur/react-ui-validations/src/Validations/Types';
|
|
190
|
+
export class ValidationBuilder<TRoot, T> {
|
|
191
|
+
constructor(writer: ValidationWriter<TRoot>, tokens: PathTokensCache, path: string[], data: T);
|
|
192
|
+
prop<TChild>(lambdaPath: LambdaPath<T, TChild>, rule: ValidationRule<TRoot, TChild>): void;
|
|
193
|
+
array<TChild>(lambdaPath: LambdaPath<T, TChild[]>, rule: ItemValidationRule<TRoot, TChild>): void;
|
|
194
|
+
invalid(isInvalid: (value: T) => boolean, validationInfo: ValidationInfo): void;
|
|
195
|
+
invalid(isInvalid: (value: T) => boolean, message: React.ReactNode, type?: ValidationBehaviour, level?: ValidationLevel, independent?: boolean): void;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
declare module '@skbkontur/react-ui-validations/src/Validations/Types' {
|
|
200
|
+
import { Nullable } from '@skbkontur/react-ui-validations/typings/Types';
|
|
201
|
+
import { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
|
|
202
|
+
import { ValidationBuilder } from '@skbkontur/react-ui-validations/src/Validations/ValidationBuilder';
|
|
203
|
+
export interface ValidationNode<T> {
|
|
204
|
+
validation: Nullable<ValidationInfo>;
|
|
205
|
+
children: Nullable<{
|
|
206
|
+
[K in keyof T]: ValidationNode<T[K]>;
|
|
207
|
+
}>;
|
|
208
|
+
}
|
|
209
|
+
export type ValidationRule<TRoot, T> = (builder: ValidationBuilder<TRoot, T>, value: T) => void;
|
|
210
|
+
export type ItemValidationRule<TRoot, T> = (builder: ValidationBuilder<TRoot, T>, value: T, index: number, array: T[]) => void;
|
|
211
|
+
export type RootValidationRule<T> = ValidationRule<T, T>;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
declare module '@skbkontur/react-ui-validations/src/Validations/ValidationReader' {
|
|
215
|
+
import { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
|
|
216
|
+
import { ExtractItem, Nullable } from '@skbkontur/react-ui-validations/typings/Types';
|
|
217
|
+
import { ValidationNode } from '@skbkontur/react-ui-validations/src/Validations/Types';
|
|
218
|
+
import { LambdaPath, PathTokensCache } from '@skbkontur/react-ui-validations/src/Validations/PathHelper';
|
|
219
|
+
export class ValidationReader<T> {
|
|
220
|
+
constructor(node: Nullable<ValidationNode<T>>, tokens: PathTokensCache);
|
|
221
|
+
getNode<TChild>(lambdaPath: LambdaPath<T, TChild>): ValidationReader<TChild>;
|
|
222
|
+
getNodeByIndex(index: number): ValidationReader<ExtractItem<T>>;
|
|
223
|
+
getNodeByKey<TKey extends keyof T>(key: TKey): ValidationReader<T[TKey]>;
|
|
224
|
+
get(): Nullable<ValidationInfo>;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
declare module '@skbkontur/react-ui-validations/src/Validations/PathHelper' {
|
|
229
|
+
type NonNullableRecursive<T> = {
|
|
230
|
+
[K in keyof T]: T[K] extends object ? NonNullable<NonNullableRecursive<T[K]>> : NonNullable<T[K]>;
|
|
231
|
+
};
|
|
232
|
+
export type LambdaPath<T, TChild> = (x: NonNullable<NonNullableRecursive<T>>) => TChild;
|
|
233
|
+
export function extractPath(lambda: string): string;
|
|
234
|
+
export function extractTokens(path: string): string[];
|
|
235
|
+
export class PathTokensCache {
|
|
236
|
+
getOrAdd<T, TChild>(lambdaPath: LambdaPath<T, TChild>): string[];
|
|
237
|
+
has<T, TChild>(lambdaPath: LambdaPath<T, TChild>): boolean;
|
|
238
|
+
get size(): number;
|
|
239
|
+
}
|
|
240
|
+
export {};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
declare module '@skbkontur/react-ui-validations/src/Validations/ValidationWriter' {
|
|
244
|
+
import { ValidationInfo } from '@skbkontur/react-ui-validations/src/ValidationWrapper';
|
|
245
|
+
import { ValidationNode } from '@skbkontur/react-ui-validations/src/Validations/Types';
|
|
246
|
+
import { ValidationReader } from '@skbkontur/react-ui-validations/src/Validations/ValidationReader';
|
|
247
|
+
import { PathTokensCache } from '@skbkontur/react-ui-validations/src/Validations/PathHelper';
|
|
248
|
+
export class ValidationWriter<T> {
|
|
249
|
+
constructor(node?: ValidationNode<T>);
|
|
250
|
+
getReader(tokens: PathTokensCache): ValidationReader<T>;
|
|
251
|
+
set(validation: ValidationInfo): void;
|
|
252
|
+
isValidated(): boolean;
|
|
253
|
+
getNode<TChild>(path: string[]): ValidationWriter<TChild>;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
package/index.js
CHANGED
|
@@ -90,13 +90,14 @@ function __generator(thisArg, body) {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
function __spreadArray(to, from, pack) {
|
|
94
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
95
|
+
if (ar || !(i in from)) {
|
|
96
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
97
|
+
ar[i] = from[i];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
var defaultOrNamed = function (module, component) {
|
|
@@ -135,21 +136,21 @@ var ValidationTooltip = /** @class */ (function (_super) {
|
|
|
135
136
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
136
137
|
}
|
|
137
138
|
ValidationTooltip.prototype.render = function () {
|
|
138
|
-
var onlyChild = React__default[
|
|
139
|
+
var onlyChild = React__default["default"].Children.only(this.props.children);
|
|
139
140
|
var child = onlyChild && onlyChild.props ? onlyChild.props.children : null;
|
|
140
141
|
if (ReactUiDetection.isRadioGroup(child) ||
|
|
141
142
|
ReactUiDetection.isTokenInput(child) ||
|
|
142
143
|
ReactUiDetection.isSwitcher(child)) {
|
|
143
|
-
return (React__default[
|
|
144
|
+
return (React__default["default"].createElement(Tooltip, { useWrapper: false, pos: this.props.pos, render: this.props.error && this.props.render, trigger: 'hover&focus' }, child));
|
|
144
145
|
}
|
|
145
|
-
return (React__default[
|
|
146
|
+
return (React__default["default"].createElement(Tooltip, { pos: this.props.pos, render: this.props.error && this.props.render, trigger: 'hover&focus' }, this.props.children));
|
|
146
147
|
};
|
|
147
148
|
return ValidationTooltip;
|
|
148
|
-
}(React__default[
|
|
149
|
+
}(React__default["default"].Component));
|
|
149
150
|
|
|
150
151
|
function tooltip(pos) {
|
|
151
152
|
return function (control, hasError, validation) {
|
|
152
|
-
return (React__default[
|
|
153
|
+
return (React__default["default"].createElement(ValidationTooltip, { pos: pos, error: hasError, render: function () {
|
|
153
154
|
if (!validation || !validation.message) {
|
|
154
155
|
return null;
|
|
155
156
|
}
|
|
@@ -161,16 +162,16 @@ function text(pos) {
|
|
|
161
162
|
if (pos === void 0) { pos = 'right'; }
|
|
162
163
|
if (pos === 'right') {
|
|
163
164
|
return function (control, hasError, validation) {
|
|
164
|
-
return (React__default[
|
|
165
|
+
return (React__default["default"].createElement("span", { style: { display: 'inline-block' } },
|
|
165
166
|
control,
|
|
166
|
-
React__default[
|
|
167
|
+
React__default["default"].createElement("span", { "data-validation-message": "text", style: { marginLeft: '10px', color: '#d43517' } }, (validation && validation.message) || '')));
|
|
167
168
|
};
|
|
168
169
|
}
|
|
169
170
|
return function (control, hasError, validation) {
|
|
170
|
-
return (React__default[
|
|
171
|
+
return (React__default["default"].createElement("span", { style: { position: 'relative', display: 'inline-block' } },
|
|
171
172
|
control,
|
|
172
|
-
React__default[
|
|
173
|
-
React__default[
|
|
173
|
+
React__default["default"].createElement("span", { style: { position: 'absolute', bottom: 0, left: 0, height: 0 } },
|
|
174
|
+
React__default["default"].createElement("span", { "data-validation-message": "text", style: {
|
|
174
175
|
color: '#d43517',
|
|
175
176
|
overflow: 'visible',
|
|
176
177
|
whiteSpace: 'nowrap',
|
|
@@ -190,7 +191,7 @@ var isReactUITestEnv = Boolean(REACT_UI_TEST) || // for cases when NODE_ENV is n
|
|
|
190
191
|
var isTestEnv = NODE_ENV === 'test' || isReactUITestEnv;
|
|
191
192
|
var isBrowser = typeof window !== 'undefined';
|
|
192
193
|
|
|
193
|
-
var ValidationContext = React__default[
|
|
194
|
+
var ValidationContext = React__default["default"].createContext({
|
|
194
195
|
register: function () { return undefined; },
|
|
195
196
|
unregister: function () { return undefined; },
|
|
196
197
|
instanceProcessBlur: function () { return undefined; },
|
|
@@ -262,7 +263,7 @@ var ValidationContextWrapper = /** @class */ (function (_super) {
|
|
|
262
263
|
}
|
|
263
264
|
};
|
|
264
265
|
ValidationContextWrapper.prototype.getChildWrappersSortedByPosition = function () {
|
|
265
|
-
var wrappersWithPosition =
|
|
266
|
+
var wrappersWithPosition = __spreadArray([], this.childWrappers, true).map(function (x) { return ({
|
|
266
267
|
target: x,
|
|
267
268
|
position: x.getControlPosition(),
|
|
268
269
|
}); });
|
|
@@ -308,11 +309,11 @@ var ValidationContextWrapper = /** @class */ (function (_super) {
|
|
|
308
309
|
});
|
|
309
310
|
};
|
|
310
311
|
ValidationContextWrapper.prototype.render = function () {
|
|
311
|
-
return (React__default[
|
|
312
|
-
React__default[
|
|
312
|
+
return (React__default["default"].createElement(ValidationContext.Provider, { value: this },
|
|
313
|
+
React__default["default"].createElement("span", null, this.props.children)));
|
|
313
314
|
};
|
|
314
315
|
return ValidationContextWrapper;
|
|
315
|
-
}(React__default[
|
|
316
|
+
}(React__default["default"].Component));
|
|
316
317
|
|
|
317
318
|
var ValidationContainer = /** @class */ (function (_super) {
|
|
318
319
|
__extends(ValidationContainer, _super);
|
|
@@ -347,7 +348,7 @@ var ValidationContainer = /** @class */ (function (_super) {
|
|
|
347
348
|
return this.childContext.validate(withoutFocus);
|
|
348
349
|
};
|
|
349
350
|
ValidationContainer.prototype.render = function () {
|
|
350
|
-
return (React__default[
|
|
351
|
+
return (React__default["default"].createElement(ValidationContextWrapper, { ref: this.refChildContext, scrollOffset: this.props.scrollOffset, disableSmoothScroll: this.props.disableSmoothScroll, onValidationUpdated: this.props.onValidationUpdated }, this.props.children));
|
|
351
352
|
};
|
|
352
353
|
ValidationContainer.__KONTUR_REACT_UI__ = 'ValidationContainer';
|
|
353
354
|
ValidationContainer.defaultProps = {
|
|
@@ -357,12 +358,12 @@ var ValidationContainer = /** @class */ (function (_super) {
|
|
|
357
358
|
scrollOffset: function (props, propName, componentName) {
|
|
358
359
|
var scrollOffset = props.scrollOffset;
|
|
359
360
|
if (typeof scrollOffset === 'number') {
|
|
360
|
-
return new Error("["
|
|
361
|
+
return new Error("[".concat(componentName, "]: scrollOffset as a number type has been deprecated, now use object { top?: number; bottom?: number; }"));
|
|
361
362
|
}
|
|
362
363
|
},
|
|
363
364
|
};
|
|
364
365
|
return ValidationContainer;
|
|
365
|
-
}(React__default[
|
|
366
|
+
}(React__default["default"].Component));
|
|
366
367
|
|
|
367
368
|
function smoothScrollIntoView(element, scrollOffset) {
|
|
368
369
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -563,9 +564,11 @@ var ValidationWrapperInternal = /** @class */ (function (_super) {
|
|
|
563
564
|
return _this;
|
|
564
565
|
}
|
|
565
566
|
ValidationWrapperInternal.prototype.componentDidMount = function () {
|
|
566
|
-
warning__default[
|
|
567
|
+
warning__default["default"](this.context, 'ValidationWrapper should appears as child of ValidationContainer.\n' +
|
|
567
568
|
'https://tech.skbkontur.ru/react-ui-validations/#/getting-started');
|
|
568
|
-
this.context
|
|
569
|
+
if (this.context) {
|
|
570
|
+
this.context.register(this);
|
|
571
|
+
}
|
|
569
572
|
this.applyValidation(this.props.validation);
|
|
570
573
|
};
|
|
571
574
|
ValidationWrapperInternal.prototype.componentWillUnmount = function () {
|
|
@@ -604,7 +607,7 @@ var ValidationWrapperInternal = /** @class */ (function (_super) {
|
|
|
604
607
|
var _this = this;
|
|
605
608
|
var children = this.props.children;
|
|
606
609
|
var validation = this.state.validation;
|
|
607
|
-
var clonedChild = children ? (React__default[
|
|
610
|
+
var clonedChild = children ? (React__default["default"].cloneElement(children, {
|
|
608
611
|
ref: function (x) {
|
|
609
612
|
var child = children; // todo type or maybe React.Children.only
|
|
610
613
|
if (child && child.ref) {
|
|
@@ -652,9 +655,9 @@ var ValidationWrapperInternal = /** @class */ (function (_super) {
|
|
|
652
655
|
(_a = children.props).onValueChange.apply(_a, args);
|
|
653
656
|
}
|
|
654
657
|
},
|
|
655
|
-
})) : (React__default[
|
|
658
|
+
})) : (React__default["default"].createElement("span", null));
|
|
656
659
|
if (ReactUiDetection.isComboBox(clonedChild)) {
|
|
657
|
-
clonedChild = React__default[
|
|
660
|
+
clonedChild = React__default["default"].cloneElement(clonedChild, {
|
|
658
661
|
onInputValueChange: function () {
|
|
659
662
|
var _a;
|
|
660
663
|
var args = [];
|
|
@@ -669,7 +672,7 @@ var ValidationWrapperInternal = /** @class */ (function (_super) {
|
|
|
669
672
|
},
|
|
670
673
|
});
|
|
671
674
|
}
|
|
672
|
-
return this.props.errorMessage(React__default[
|
|
675
|
+
return this.props.errorMessage(React__default["default"].createElement("span", { ref: this.setRootNode }, clonedChild), !!validation, validation);
|
|
673
676
|
};
|
|
674
677
|
ValidationWrapperInternal.prototype.getControlPosition = function () {
|
|
675
678
|
var htmlElement = this.getRootNode();
|
|
@@ -744,7 +747,7 @@ var ValidationWrapperInternal = /** @class */ (function (_super) {
|
|
|
744
747
|
};
|
|
745
748
|
ValidationWrapperInternal.contextType = ValidationContext;
|
|
746
749
|
return ValidationWrapperInternal;
|
|
747
|
-
}(React__default[
|
|
750
|
+
}(React__default["default"].Component));
|
|
748
751
|
|
|
749
752
|
var ValidationWrapper = /** @class */ (function (_super) {
|
|
750
753
|
__extends(ValidationWrapper, _super);
|
|
@@ -761,11 +764,11 @@ var ValidationWrapper = /** @class */ (function (_super) {
|
|
|
761
764
|
independent: validationInfo.independent || false,
|
|
762
765
|
}
|
|
763
766
|
: null;
|
|
764
|
-
return (React__default[
|
|
767
|
+
return (React__default["default"].createElement(ValidationWrapperInternal, { errorMessage: renderMessage || tooltip('right top'), validation: validation }, children));
|
|
765
768
|
};
|
|
766
769
|
ValidationWrapper.__KONTUR_REACT_UI__ = 'ValidationWrapper';
|
|
767
770
|
return ValidationWrapper;
|
|
768
|
-
}(React__default[
|
|
771
|
+
}(React__default["default"].Component));
|
|
769
772
|
|
|
770
773
|
var ValidationBuilder = /** @class */ (function () {
|
|
771
774
|
function ValidationBuilder(writer, tokens, path, data) {
|
|
@@ -789,7 +792,7 @@ var ValidationBuilder = /** @class */ (function () {
|
|
|
789
792
|
}
|
|
790
793
|
var array = info.data;
|
|
791
794
|
for (var i = 0; i < array.length; ++i) {
|
|
792
|
-
var path =
|
|
795
|
+
var path = __spreadArray(__spreadArray([], info.path, true), [i.toString()], false);
|
|
793
796
|
var builder = new ValidationBuilder(this.writer, this.tokens, path, array[i]);
|
|
794
797
|
rule(builder, builder.data, i, array);
|
|
795
798
|
}
|
|
@@ -820,7 +823,7 @@ var ValidationBuilder = /** @class */ (function () {
|
|
|
820
823
|
}
|
|
821
824
|
data = data[part];
|
|
822
825
|
}
|
|
823
|
-
return { data: data, path:
|
|
826
|
+
return { data: data, path: __spreadArray(__spreadArray([], this.path, true), path, true) };
|
|
824
827
|
};
|
|
825
828
|
return ValidationBuilder;
|
|
826
829
|
}());
|
|
@@ -908,7 +911,7 @@ function extractPath(lambda) {
|
|
|
908
911
|
if (match && match.length === 3) {
|
|
909
912
|
return (match[2] || '').replace(/(^\.\s*)/g, '');
|
|
910
913
|
}
|
|
911
|
-
throw new Error("Not supported or invalid path: <"
|
|
914
|
+
throw new Error("Not supported or invalid path: <".concat(lambda, ">"));
|
|
912
915
|
}
|
|
913
916
|
function extractTokens(path) {
|
|
914
917
|
return path.split(/[\s.[\]]+/g).filter(function (x) { return x; });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skbkontur/react-ui-validations",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Validations for @skbkontur/react-ui",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@skbkontur/react-ui": ">=0.53.7"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"prop-types": "^15.
|
|
23
|
+
"prop-types": "^15.8.0",
|
|
24
24
|
"smoothscroll-polyfill": "^0.4.4",
|
|
25
25
|
"warning": "^4.0.3"
|
|
26
26
|
},
|