react-ui-validations
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -6,2 +6,10 @@ # Change Log | ||
## [1.1.3](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/compare/react-ui-validations@1.1.2...react-ui-validations@1.1.3) (2020-03-24) | ||
**Note:** Version bump only for package react-ui-validations | ||
## [1.1.2](https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-validations/compare/react-ui-validations@1.1.1...react-ui-validations@1.1.2) (2020-03-11) | ||
@@ -8,0 +16,0 @@ |
@@ -8,7 +8,7 @@ // Generated by dts-bundle v0.7.3 | ||
import { text, tooltip } from 'react-ui-validations/src/ErrorRenderer'; | ||
import ValidationContainer, { ValidationContainerProps } from 'react-ui-validations/src/ValidationContainer'; | ||
import ValidationContext, { ValidationContextProps } from 'react-ui-validations/src/ValidationContext'; | ||
import ValidationTooltip, { TooltipPosition, ValidationTooltipProps } from 'react-ui-validations/src/ValidationTooltip'; | ||
import { ValidationContainer, ValidationContainerProps } from 'react-ui-validations/src/ValidationContainer'; | ||
import { ValidationContext, ValidationContextProps } from 'react-ui-validations/src/ValidationContext'; | ||
import { TooltipPosition, ValidationTooltip, ValidationTooltipProps } from 'react-ui-validations/src/ValidationTooltip'; | ||
import { RenderErrorMessage, Validation, ValidationBehaviour } from 'react-ui-validations/src/ValidationWrapperInternal'; | ||
import ValidationWrapper, { ValidationInfo, ValidationWrapperProps } from 'react-ui-validations/src/ValidationWrapper'; | ||
import { ValidationWrapper, ValidationInfo, ValidationWrapperProps } from 'react-ui-validations/src/ValidationWrapper'; | ||
export { ValidationContainer, ValidationContainerProps, ValidationContext, ValidationContextProps, ValidationWrapper as ValidationWrapperV1, ValidationWrapperProps as ValidationWrapperV1Props, RenderErrorMessage, ValidationBehaviour, Validation, ValidationWrapper, ValidationWrapperProps, ValidationInfo, ValidationTooltip, ValidationTooltipProps, TooltipPosition, tooltip, text, }; | ||
@@ -26,3 +26,3 @@ export * from 'react-ui-validations/src/Validations'; | ||
declare module 'react-ui-validations/src/ValidationContainer' { | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import { Nullable } from 'react-ui-validations/typings/Types'; | ||
@@ -38,3 +38,3 @@ export interface ScrollOffset { | ||
} | ||
export default class ValidationContainer extends React.Component<ValidationContainerProps> { | ||
export class ValidationContainer extends React.Component<ValidationContainerProps> { | ||
static __KONTUR_REACT_UI__: string; | ||
@@ -52,6 +52,6 @@ static propTypes: { | ||
import * as PropTypes from 'prop-types'; | ||
import * as React from 'react'; | ||
import ValidationWrapperInternal from 'react-ui-validations/src/ValidationWrapperInternal'; | ||
import React from 'react'; | ||
import { ValidationWrapperInternal } from 'react-ui-validations/src/ValidationWrapperInternal'; | ||
import { ScrollOffset } from 'react-ui-validations/src/ValidationContainer'; | ||
export interface IValidationContextSettings { | ||
export interface ValidationContextSettings { | ||
scrollOffset: ScrollOffset; | ||
@@ -64,3 +64,3 @@ } | ||
onValidationUpdated(wrapper: ValidationWrapperInternal, isValid: boolean): void; | ||
getSettings(): IValidationContextSettings; | ||
getSettings(): ValidationContextSettings; | ||
isAnyWrapperInChangingMode(): boolean; | ||
@@ -73,3 +73,3 @@ } | ||
} | ||
export default class ValidationContext extends React.Component<ValidationContextProps> implements IValidationContext { | ||
export class ValidationContext extends React.Component<ValidationContextProps> implements IValidationContext { | ||
static childContextTypes: { | ||
@@ -82,3 +82,3 @@ validationContext: PropTypes.Requireable<any>; | ||
}; | ||
getSettings(): IValidationContextSettings; | ||
getSettings(): ValidationContextSettings; | ||
register(wrapper: ValidationWrapperInternal): void; | ||
@@ -97,3 +97,3 @@ unregister(wrapper: ValidationWrapperInternal): void; | ||
declare module 'react-ui-validations/src/ValidationTooltip' { | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
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'; | ||
@@ -106,3 +106,3 @@ export interface ValidationTooltipProps { | ||
} | ||
export default class ValidationTooltip extends React.Component<ValidationTooltipProps> { | ||
export class ValidationTooltip extends React.Component<ValidationTooltipProps> { | ||
render(): JSX.Element; | ||
@@ -114,3 +114,3 @@ } | ||
import * as PropTypes from 'prop-types'; | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import { Nullable } from 'react-ui-validations/typings/Types'; | ||
@@ -138,3 +138,3 @@ import { IValidationContext } from 'react-ui-validations/src/ValidationContext'; | ||
} | ||
export default class ValidationWrapperInternal extends React.Component<ValidationWrapperInternalProps, ValidationWrapperInternalState> { | ||
export class ValidationWrapperInternal extends React.Component<ValidationWrapperInternalProps, ValidationWrapperInternalState> { | ||
static contextTypes: { | ||
@@ -148,8 +148,8 @@ validationContext: PropTypes.Requireable<any>; | ||
isChanging: boolean; | ||
componentWillMount(): void; | ||
UNSAFE_componentWillMount(): void; | ||
componentDidMount(): void; | ||
componentWillUnmount(): void; | ||
componentWillReceiveProps(nextProps: ValidationWrapperInternalProps): void; | ||
UNSAFE_componentWillReceiveProps(nextProps: ValidationWrapperInternalProps): void; | ||
focus(): Promise<void>; | ||
render(): React.ReactElement<any>; | ||
render(): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>; | ||
getControlPosition(): Nullable<Point>; | ||
@@ -164,3 +164,3 @@ processBlur(): Promise<void>; | ||
declare module 'react-ui-validations/src/ValidationWrapper' { | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import { Nullable } from 'react-ui-validations/typings/Types'; | ||
@@ -174,7 +174,7 @@ import { RenderErrorMessage, ValidationBehaviour, ValidationLevel } from 'react-ui-validations/src/ValidationWrapperInternal'; | ||
export interface ValidationWrapperProps { | ||
children: React.ReactElement<any>; | ||
children?: React.ReactElement<any>; | ||
validationInfo: Nullable<ValidationInfo>; | ||
renderMessage?: Nullable<RenderErrorMessage>; | ||
} | ||
export default class ValidationWrapper extends React.Component<ValidationWrapperProps> { | ||
export class ValidationWrapper extends React.Component<ValidationWrapperProps> { | ||
static __KONTUR_REACT_UI__: string; | ||
@@ -201,7 +201,7 @@ render(): JSX.Element; | ||
declare module 'react-ui-validations/src/Validations/ValidationBuilder' { | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import { ValidationBehaviour, ValidationLevel } from 'react-ui-validations/src/ValidationWrapperInternal'; | ||
import { LambdaPath, PathTokensCache } from 'react-ui-validations/src/Validations/PathHelper'; | ||
import { ValidationWriter } from 'react-ui-validations/src/Validations/ValidationWriter'; | ||
import { ItemValidationRule, ValidationRule } from 'react-ui-validations/src/Validations/Types'; | ||
import { ValidationBehaviour, ValidationLevel } from 'react-ui-validations/src/ValidationWrapperInternal'; | ||
export class ValidationBuilder<TRoot, T> { | ||
@@ -216,5 +216,5 @@ constructor(writer: ValidationWriter<TRoot>, tokens: PathTokensCache, path: string[], data: T); | ||
declare module 'react-ui-validations/src/Validations/Types' { | ||
import { ValidationBuilder } from 'react-ui-validations/src/Validations/ValidationBuilder'; | ||
import { Nullable } from 'react-ui-validations/typings/Types'; | ||
import { ValidationInfo } from 'react-ui-validations/src/ValidationWrapper'; | ||
import { ValidationBuilder } from 'react-ui-validations/src/Validations/ValidationBuilder'; | ||
export interface ValidationNode<T> { | ||
@@ -232,6 +232,6 @@ validation: Nullable<ValidationInfo>; | ||
declare module 'react-ui-validations/src/Validations/ValidationReader' { | ||
import { ValidationInfo } from 'react-ui-validations/src/ValidationWrapper'; | ||
import { ExtractItem, Nullable } from 'react-ui-validations/typings/Types'; | ||
import { ValidationNode } from 'react-ui-validations/src/Validations/Types'; | ||
import { LambdaPath, PathTokensCache } from 'react-ui-validations/src/Validations/PathHelper'; | ||
import { ValidationInfo } from 'react-ui-validations/src/ValidationWrapper'; | ||
import { ExtractItem, Nullable } from 'react-ui-validations/typings/Types'; | ||
export class ValidationReader<T> { | ||
@@ -256,3 +256,3 @@ constructor(node: Nullable<ValidationNode<T>>, tokens: PathTokensCache); | ||
has<T, TChild>(lambdaPath: LambdaPath<T, TChild>): boolean; | ||
readonly size: number; | ||
get size(): number; | ||
} | ||
@@ -263,4 +263,4 @@ export {}; | ||
declare module 'react-ui-validations/src/Validations/ValidationWriter' { | ||
import { ValidationInfo } from 'react-ui-validations/src/ValidationWrapper'; | ||
import { ValidationNode } from 'react-ui-validations/src/Validations/Types'; | ||
import { ValidationInfo } from 'react-ui-validations/src/ValidationWrapper'; | ||
import { ValidationReader } from 'react-ui-validations/src/Validations/ValidationReader'; | ||
@@ -267,0 +267,0 @@ import { PathTokensCache } from 'react-ui-validations/src/Validations/PathHelper'; |
72
index.js
@@ -7,3 +7,3 @@ 'use strict'; | ||
var React = require('react'); | ||
var React = _interopDefault(require('react')); | ||
var PropTypes = require('prop-types'); | ||
@@ -90,9 +90,16 @@ var ReactDom = require('react-dom'); | ||
function localInteropDefault(obj) { | ||
return obj && obj.__esModule ? obj.default : obj; | ||
function __spreadArrays() { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
} | ||
// todo think about DatePicker & DatePickerOld | ||
var DatePicker = localInteropDefault(require("retail-ui" + '/components/DatePicker')); | ||
var RadioGroup = localInteropDefault(require("retail-ui" + '/components/RadioGroup')); | ||
var Tooltip = localInteropDefault(require("retail-ui" + '/components/Tooltip')); | ||
var defaultOrNamed = function (module, component) { | ||
return module && module.__esModule && module.default ? module.default : module[component]; | ||
}; | ||
var DatePicker = defaultOrNamed(require("retail-ui" + '/components/DatePicker'), 'DatePicker'); | ||
var RadioGroup = defaultOrNamed(require("retail-ui" + '/components/RadioGroup'), 'RadioGroup'); | ||
var Tooltip = defaultOrNamed(require("retail-ui" + '/components/Tooltip'), 'Tooltip'); | ||
var ReactUiDetection = /** @class */ (function () { | ||
@@ -128,5 +135,3 @@ function ReactUiDetection() { | ||
return function (control, hasError, validation) { | ||
return (React.createElement(ValidationTooltip, { pos: pos, error: hasError, | ||
// tslint:disable-next-line:jsx-no-lambda | ||
render: function () { | ||
return (React.createElement(ValidationTooltip, { pos: pos, error: hasError, render: function () { | ||
if (!validation || !validation.message) { | ||
@@ -227,3 +232,3 @@ return null; | ||
ValidationContext.prototype.getChildWrappersSortedByPosition = function () { | ||
var wrappersWithPosition = this.childWrappers.slice().map(function (x) { return ({ | ||
var wrappersWithPosition = __spreadArrays(this.childWrappers).map(function (x) { return ({ | ||
target: x, | ||
@@ -401,3 +406,3 @@ position: x.getControlPosition(), | ||
} | ||
return new Promise(function (resolve) { return step(__assign({}, context, { resolve: resolve })); }); | ||
return new Promise(function (resolve) { return step(__assign(__assign({}, context), { resolve: resolve })); }); | ||
} | ||
@@ -506,3 +511,3 @@ function step(context) { | ||
} | ||
ValidationWrapperInternal.prototype.componentWillMount = function () { | ||
ValidationWrapperInternal.prototype.UNSAFE_componentWillMount = function () { | ||
this.applyValidation(this.props.validation); | ||
@@ -522,3 +527,3 @@ }; | ||
}; | ||
ValidationWrapperInternal.prototype.componentWillReceiveProps = function (nextProps) { | ||
ValidationWrapperInternal.prototype.UNSAFE_componentWillReceiveProps = function (nextProps) { | ||
this.applyValidation(nextProps.validation); | ||
@@ -559,3 +564,3 @@ }; | ||
} | ||
if (child.ref.hasOwnProperty('current')) { | ||
if (Object.prototype.hasOwnProperty.call(child.ref, 'current')) { | ||
child.ref.current = x; | ||
@@ -569,2 +574,3 @@ } | ||
onBlur: function () { | ||
var _a; | ||
var args = []; | ||
@@ -574,3 +580,2 @@ for (var _i = 0; _i < arguments.length; _i++) { | ||
} | ||
var _a; | ||
_this.handleBlur(); | ||
@@ -582,2 +587,3 @@ if (children.props && children.props.onBlur) { | ||
onChange: function () { | ||
var _a; | ||
var args = []; | ||
@@ -587,3 +593,2 @@ for (var _i = 0; _i < arguments.length; _i++) { | ||
} | ||
var _a; | ||
_this.isChanging = true; | ||
@@ -594,2 +599,13 @@ if (children.props && children.props.onChange) { | ||
}, | ||
onValueChange: function () { | ||
var _a; | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
_this.isChanging = true; | ||
if (children.props && children.props.onValueChange) { | ||
(_a = children.props).onValueChange.apply(_a, args); | ||
} | ||
}, | ||
})) : (React.createElement("span", null)); | ||
@@ -709,3 +725,3 @@ return this.props.errorMessage(React.createElement("span", null, clonedChild), !!validation, validation); | ||
for (var i = 0; i < array.length; ++i) { | ||
var path = info.path.concat([i.toString()]); | ||
var path = __spreadArrays(info.path, [i.toString()]); | ||
var builder = new ValidationBuilder(this.writer, this.tokens, path, array[i]); | ||
@@ -736,3 +752,3 @@ rule(builder, builder.data, i, array); | ||
} | ||
return { data: data, path: this.path.concat(path) }; | ||
return { data: data, path: __spreadArrays(this.path, path) }; | ||
}; | ||
@@ -815,4 +831,4 @@ return ValidationBuilder; | ||
var classicFunctionRegEx = /^\s*function\s*\(\s*([A-Za-z0-9_]+)\s*\)\s*\{\s*(?:(?:\"use strict\"|\'use strict\');?)?\s*return\s+\1\s*([\.\[].*?)?\s*;?\s*\}\s*$/; | ||
var arrowFunctionRegEx = /^\s*\(?\s*([A-Za-z0-9_]+)\s*\)?\s*=>\s*\1\s*([\.\[].*?)?\s*$/; | ||
var classicFunctionRegEx = /^\s*function\s*\(\s*([A-Za-z0-9_]+)\s*\)\s*\{\s*(?:(?:"use strict"|'use strict');?)?\s*return\s+\1\s*([.[].*?)?\s*;?\s*\}\s*$/; | ||
var arrowFunctionRegEx = /^\s*\(?\s*([A-Za-z0-9_]+)\s*\)?\s*=>\s*\1\s*([.[].*?)?\s*$/; | ||
function extractPath(lambda) { | ||
@@ -826,3 +842,3 @@ var match = classicFunctionRegEx.exec(lambda) || arrowFunctionRegEx.exec(lambda); | ||
function extractTokens(path) { | ||
return path.split(/[\s\.\[\]]+/g).filter(function (x) { return x; }); | ||
return path.split(/[\s.[\]]+/g).filter(function (x) { return x; }); | ||
} | ||
@@ -869,12 +885,12 @@ var PathTokensCache = /** @class */ (function () { | ||
exports.ValidationBuilder = ValidationBuilder; | ||
exports.ValidationContainer = ValidationContainer; | ||
exports.ValidationContext = ValidationContext; | ||
exports.ValidationReader = ValidationReader; | ||
exports.ValidationTooltip = ValidationTooltip; | ||
exports.ValidationWrapper = ValidationWrapper; | ||
exports.ValidationWrapperV1 = ValidationWrapper; | ||
exports.ValidationWrapper = ValidationWrapper; | ||
exports.ValidationTooltip = ValidationTooltip; | ||
exports.createValidator = createValidator; | ||
exports.text = text; | ||
exports.tooltip = tooltip; | ||
exports.text = text; | ||
exports.createValidator = createValidator; | ||
exports.ValidationReader = ValidationReader; | ||
exports.ValidationBuilder = ValidationBuilder; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "react-ui-validations", | ||
"version": "1.1.2", | ||
"description": "Validations for retail-ui", | ||
"version": "1.1.3", | ||
"description": "Validations for @skbkontur/react-ui", | ||
"main": "./index.js", | ||
@@ -18,10 +18,10 @@ "types": "./index.d.ts", | ||
"peerDependencies": { | ||
"react": ">=15 <=16", | ||
"react-dom": ">=15 <=16", | ||
"react": ">=16.9", | ||
"react-dom": ">=16.9", | ||
"retail-ui": ">=0.52.0 <2.0.0" | ||
}, | ||
"dependencies": { | ||
"prop-types": "^15.5.10", | ||
"smoothscroll-polyfill": "^0.3.4", | ||
"warning": "^3.0.0" | ||
"prop-types": "^15.7.2", | ||
"smoothscroll-polyfill": "^0.4.4", | ||
"warning": "^4.0.3" | ||
}, | ||
@@ -28,0 +28,0 @@ "jest": { |
@@ -29,3 +29,3 @@ # react-ui-validations | ||
> | ||
<Input value={phone} onChange={value => setState({ phone: value })} /> | ||
<Input value={phone} onValueChange={value => setState({ phone: value })} /> | ||
</ValidationWrapper> | ||
@@ -32,0 +32,0 @@ </ValidationContainer> |
65716
1094
+ Addedreact@19.0.0(transitive)
+ Addedreact-dom@19.0.0(transitive)
+ Addedscheduler@0.25.0(transitive)
+ Addedsmoothscroll-polyfill@0.4.4(transitive)
- Removedsmoothscroll-polyfill@0.3.6(transitive)
Updatedprop-types@^15.7.2
Updatedsmoothscroll-polyfill@^0.4.4
Updatedwarning@^4.0.3