@skbkontur/react-ui-validations 1.7.0 → 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 CHANGED
@@ -3,6 +3,22 @@
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
+
6
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)
7
23
 
8
24
 
package/index.d.ts CHANGED
@@ -95,7 +95,7 @@ declare module '@skbkontur/react-ui-validations/src/ValidationWrapperInternal' {
95
95
  componentWillUnmount(): void;
96
96
  componentDidUpdate(): void;
97
97
  focus(): Promise<void>;
98
- render(): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)>;
98
+ render(): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
99
99
  getRootNode: () => Nullable<HTMLElement>;
100
100
  getControlPosition(): Nullable<Point>;
101
101
  processBlur(): Promise<void>;
package/index.js CHANGED
@@ -90,13 +90,14 @@ function __generator(thisArg, body) {
90
90
  }
91
91
  }
92
92
 
93
- /** @deprecated */
94
- function __spreadArrays() {
95
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
96
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
97
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
98
- r[k] = a[j];
99
- return r;
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['default'].Children.only(this.props.children);
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['default'].createElement(Tooltip, { useWrapper: false, pos: this.props.pos, render: this.props.error && this.props.render, trigger: 'hover&focus' }, child));
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['default'].createElement(Tooltip, { pos: this.props.pos, render: this.props.error && this.props.render, trigger: 'hover&focus' }, this.props.children));
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['default'].Component));
149
+ }(React__default["default"].Component));
149
150
 
150
151
  function tooltip(pos) {
151
152
  return function (control, hasError, validation) {
152
- return (React__default['default'].createElement(ValidationTooltip, { pos: pos, error: hasError, render: function () {
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['default'].createElement("span", { style: { display: 'inline-block' } },
165
+ return (React__default["default"].createElement("span", { style: { display: 'inline-block' } },
165
166
  control,
166
- React__default['default'].createElement("span", { "data-validation-message": "text", style: { marginLeft: '10px', color: '#d43517' } }, (validation && validation.message) || '')));
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['default'].createElement("span", { style: { position: 'relative', display: 'inline-block' } },
171
+ return (React__default["default"].createElement("span", { style: { position: 'relative', display: 'inline-block' } },
171
172
  control,
172
- React__default['default'].createElement("span", { style: { position: 'absolute', bottom: 0, left: 0, height: 0 } },
173
- React__default['default'].createElement("span", { "data-validation-message": "text", style: {
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['default'].createContext({
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 = __spreadArrays(this.childWrappers).map(function (x) { return ({
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['default'].createElement(ValidationContext.Provider, { value: this },
312
- React__default['default'].createElement("span", null, this.props.children)));
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['default'].Component));
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['default'].createElement(ValidationContextWrapper, { ref: this.refChildContext, scrollOffset: this.props.scrollOffset, disableSmoothScroll: this.props.disableSmoothScroll, onValidationUpdated: this.props.onValidationUpdated }, this.props.children));
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("[" + componentName + "]: scrollOffset as a number type has been deprecated, now use object { top?: number; bottom?: number; }");
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['default'].Component));
366
+ }(React__default["default"].Component));
366
367
 
367
368
  function smoothScrollIntoView(element, scrollOffset) {
368
369
  return __awaiter(this, void 0, void 0, function () {
@@ -563,7 +564,7 @@ var ValidationWrapperInternal = /** @class */ (function (_super) {
563
564
  return _this;
564
565
  }
565
566
  ValidationWrapperInternal.prototype.componentDidMount = function () {
566
- warning__default['default'](this.context, 'ValidationWrapper should appears as child of ValidationContainer.\n' +
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
569
  if (this.context) {
569
570
  this.context.register(this);
@@ -606,7 +607,7 @@ var ValidationWrapperInternal = /** @class */ (function (_super) {
606
607
  var _this = this;
607
608
  var children = this.props.children;
608
609
  var validation = this.state.validation;
609
- var clonedChild = children ? (React__default['default'].cloneElement(children, {
610
+ var clonedChild = children ? (React__default["default"].cloneElement(children, {
610
611
  ref: function (x) {
611
612
  var child = children; // todo type or maybe React.Children.only
612
613
  if (child && child.ref) {
@@ -654,9 +655,9 @@ var ValidationWrapperInternal = /** @class */ (function (_super) {
654
655
  (_a = children.props).onValueChange.apply(_a, args);
655
656
  }
656
657
  },
657
- })) : (React__default['default'].createElement("span", null));
658
+ })) : (React__default["default"].createElement("span", null));
658
659
  if (ReactUiDetection.isComboBox(clonedChild)) {
659
- clonedChild = React__default['default'].cloneElement(clonedChild, {
660
+ clonedChild = React__default["default"].cloneElement(clonedChild, {
660
661
  onInputValueChange: function () {
661
662
  var _a;
662
663
  var args = [];
@@ -671,7 +672,7 @@ var ValidationWrapperInternal = /** @class */ (function (_super) {
671
672
  },
672
673
  });
673
674
  }
674
- return this.props.errorMessage(React__default['default'].createElement("span", { ref: this.setRootNode }, clonedChild), !!validation, validation);
675
+ return this.props.errorMessage(React__default["default"].createElement("span", { ref: this.setRootNode }, clonedChild), !!validation, validation);
675
676
  };
676
677
  ValidationWrapperInternal.prototype.getControlPosition = function () {
677
678
  var htmlElement = this.getRootNode();
@@ -746,7 +747,7 @@ var ValidationWrapperInternal = /** @class */ (function (_super) {
746
747
  };
747
748
  ValidationWrapperInternal.contextType = ValidationContext;
748
749
  return ValidationWrapperInternal;
749
- }(React__default['default'].Component));
750
+ }(React__default["default"].Component));
750
751
 
751
752
  var ValidationWrapper = /** @class */ (function (_super) {
752
753
  __extends(ValidationWrapper, _super);
@@ -763,11 +764,11 @@ var ValidationWrapper = /** @class */ (function (_super) {
763
764
  independent: validationInfo.independent || false,
764
765
  }
765
766
  : null;
766
- return (React__default['default'].createElement(ValidationWrapperInternal, { errorMessage: renderMessage || tooltip('right top'), validation: validation }, children));
767
+ return (React__default["default"].createElement(ValidationWrapperInternal, { errorMessage: renderMessage || tooltip('right top'), validation: validation }, children));
767
768
  };
768
769
  ValidationWrapper.__KONTUR_REACT_UI__ = 'ValidationWrapper';
769
770
  return ValidationWrapper;
770
- }(React__default['default'].Component));
771
+ }(React__default["default"].Component));
771
772
 
772
773
  var ValidationBuilder = /** @class */ (function () {
773
774
  function ValidationBuilder(writer, tokens, path, data) {
@@ -791,7 +792,7 @@ var ValidationBuilder = /** @class */ (function () {
791
792
  }
792
793
  var array = info.data;
793
794
  for (var i = 0; i < array.length; ++i) {
794
- var path = __spreadArrays(info.path, [i.toString()]);
795
+ var path = __spreadArray(__spreadArray([], info.path, true), [i.toString()], false);
795
796
  var builder = new ValidationBuilder(this.writer, this.tokens, path, array[i]);
796
797
  rule(builder, builder.data, i, array);
797
798
  }
@@ -822,7 +823,7 @@ var ValidationBuilder = /** @class */ (function () {
822
823
  }
823
824
  data = data[part];
824
825
  }
825
- return { data: data, path: __spreadArrays(this.path, path) };
826
+ return { data: data, path: __spreadArray(__spreadArray([], this.path, true), path, true) };
826
827
  };
827
828
  return ValidationBuilder;
828
829
  }());
@@ -910,7 +911,7 @@ function extractPath(lambda) {
910
911
  if (match && match.length === 3) {
911
912
  return (match[2] || '').replace(/(^\.\s*)/g, '');
912
913
  }
913
- throw new Error("Not supported or invalid path: <" + lambda + ">");
914
+ throw new Error("Not supported or invalid path: <".concat(lambda, ">"));
914
915
  }
915
916
  function extractTokens(path) {
916
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.7.0",
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.7.2",
23
+ "prop-types": "^15.8.0",
24
24
  "smoothscroll-polyfill": "^0.4.4",
25
25
  "warning": "^4.0.3"
26
26
  },