@invoicebox/ui 0.1.0-alpha.210 → 0.1.0-alpha.212

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.
@@ -24,6 +24,7 @@ var Drawer = exports.Drawer = function Drawer(_ref) {
24
24
  overflow = _ref.overflow,
25
25
  borderColor = _ref.borderColor;
26
26
  var palette = (0, _palette.useComponentPalette)('drawer');
27
+ if (!isOpen) return null;
27
28
  return /*#__PURE__*/_react["default"].createElement(S.BottomSheet, {
28
29
  open: isOpen,
29
30
  onDismiss: onClose,
@@ -1,4 +1,5 @@
1
1
  import { TCreateErrorFunc } from './types';
2
+ export declare const WEBSITE_WRONG_MESSAGE = "\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u0430\u0434\u0440\u0435\u0441";
2
3
  export declare class Validate {
3
4
  static bic(value: string, createError: TCreateErrorFunc): any;
4
5
  static website(value: string, createError: TCreateErrorFunc, isOnlyHttpsFormat?: boolean): any;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Validate = void 0;
6
+ exports.WEBSITE_WRONG_MESSAGE = exports.Validate = void 0;
7
7
  var _vatNumberValidateHelpers = require("./utils/vatNumberValidateHelpers");
8
8
  var _types = require("../components/form/PhoneInput/types");
9
9
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
@@ -12,6 +12,7 @@ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o =
12
12
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
13
13
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
14
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
+ var WEBSITE_WRONG_MESSAGE = exports.WEBSITE_WRONG_MESSAGE = 'Некорректный адрес';
15
16
  var Validate = exports.Validate = /*#__PURE__*/function () {
16
17
  function Validate() {
17
18
  _classCallCheck(this, Validate);
@@ -36,14 +37,14 @@ var Validate = exports.Validate = /*#__PURE__*/function () {
36
37
  if (value === '') {
37
38
  return true;
38
39
  }
39
- var basePattern = "(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?::\\d{1,5})?(?:\\/[\\w\\-\\.~!$&'()*+,;=:@%\\/?#]*)?";
40
- var prefix = isOnlyHttpsFormat ? '^https://' : '^(https://)?';
41
- var pattern = "".concat(prefix).concat(basePattern, "$");
42
- var regex = new RegExp(pattern, 'iu');
40
+ var basePattern = "(?:(?:[a-z\xA1-\uFFFF](?:[a-z\xA1-\uFFFF-]{0,61}[a-z\xA1-\uFFFF])?\\.)+([a-z\xA1-\uFFFF]{2,63}))(?::\\d+)?)(?:\\/[\\w \\/-]*)*(?:\\?[^#\\s]*)?(?:\\#\\S*)";
41
+ var prefix = isOnlyHttpsFormat ? '^((https:\\/\\/)' : '^((?:https?:\\/\\/)?';
42
+ var pattern = "".concat(prefix).concat(basePattern, "?");
43
+ var regex = new RegExp(pattern, 'i');
43
44
  if (value.match(regex)) {
44
45
  return true;
45
46
  }
46
- return createError('Некорректный адрес');
47
+ return createError(WEBSITE_WRONG_MESSAGE);
47
48
  }
48
49
  }, {
49
50
  key: "vatNumber",
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ var _index = require("../index");
4
+ describe('Website validate', function () {
5
+ var validateAllFunc = function validateAllFunc(value) {
6
+ return _index.Validate.website(value, function (result) {
7
+ return result;
8
+ });
9
+ };
10
+ test('validate web sites all variants', function () {
11
+ expect(validateAllFunc('abc.com')).toBe(true);
12
+ expect(validateAllFunc('http://abc.com')).toBe(true);
13
+ expect(validateAllFunc('https://abc.com')).toBe(true);
14
+ expect(validateAllFunc('http://www.abc.com')).toBe(true);
15
+ expect(validateAllFunc('https://www.abc.com')).toBe(true);
16
+ expect(validateAllFunc('https://дом.рф')).toBe(true);
17
+ expect(validateAllFunc('дом.рф')).toBe(true);
18
+ expect(validateAllFunc('http://abc.com/anyhere')).toBe(true);
19
+ expect(validateAllFunc('http://abc.com/anyhere/anyhere')).toBe(true);
20
+ expect(validateAllFunc('https://abc.com/anyhere/anyhere?any')).toBe(true);
21
+ expect(validateAllFunc('https://www')).toBe(_index.WEBSITE_WRONG_MESSAGE);
22
+ expect(validateAllFunc('www')).toBe(_index.WEBSITE_WRONG_MESSAGE);
23
+ expect(validateAllFunc('.com')).toBe(_index.WEBSITE_WRONG_MESSAGE);
24
+ expect(validateAllFunc('дом')).toBe(_index.WEBSITE_WRONG_MESSAGE);
25
+ });
26
+ var validateHttpsFunc = function validateHttpsFunc(value) {
27
+ return _index.Validate.website(value, function (result) {
28
+ return result;
29
+ }, true);
30
+ };
31
+ test('validate web sites only https variants', function () {
32
+ expect(validateHttpsFunc('https://abc.com')).toBe(true);
33
+ expect(validateHttpsFunc('https://www.abc.com')).toBe(true);
34
+ expect(validateHttpsFunc('https://дом.рф')).toBe(true);
35
+ expect(validateAllFunc('https://abc.com/anyhere')).toBe(true);
36
+ expect(validateAllFunc('https://abc.com/anyhere/anyhere')).toBe(true);
37
+ expect(validateAllFunc('https://abc.com/anyhere/anyhere?any')).toBe(true);
38
+ expect(validateHttpsFunc('дом.рф')).toBe(_index.WEBSITE_WRONG_MESSAGE);
39
+ expect(validateHttpsFunc('http://www.abc.com')).toBe(_index.WEBSITE_WRONG_MESSAGE);
40
+ expect(validateHttpsFunc('abc.com')).toBe(_index.WEBSITE_WRONG_MESSAGE);
41
+ expect(validateHttpsFunc('http://abc.com')).toBe(_index.WEBSITE_WRONG_MESSAGE);
42
+ // expect(validateHttpsFunc('https://www')).toBe(WEBSITE_WRONG_MESSAGE);
43
+ expect(validateHttpsFunc('www')).toBe(_index.WEBSITE_WRONG_MESSAGE);
44
+ expect(validateHttpsFunc('.com')).toBe(_index.WEBSITE_WRONG_MESSAGE);
45
+ expect(validateHttpsFunc('дом')).toBe(_index.WEBSITE_WRONG_MESSAGE);
46
+ });
47
+ });
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@invoicebox/ui",
3
- "version": "0.1.0-alpha.210",
3
+ "version": "0.1.0-alpha.212",
4
4
  "description": "Invoicebox UI",
5
5
  "license": "Apache License 2.0",
6
6
  "scripts": {
7
7
  "storybook": "storybook dev -p 6006",
8
- "release": "./release.sh"
8
+ "release": "./release.sh",
9
+ "test": "jest"
9
10
  },
10
11
  "bugs": {
11
12
  "url": "https://github.com/InvoiceBox/invoicebox-ui/issues"
@@ -30,6 +31,7 @@
30
31
  "@storybook/react": "^7.6.13",
31
32
  "@storybook/react-webpack5": "^7.6.13",
32
33
  "@storybook/test": "^7.6.13",
34
+ "@types/jest": "^29.5.8",
33
35
  "@typescript-eslint/eslint-plugin": "^5.62.0",
34
36
  "@typescript-eslint/parser": "^5.62.0",
35
37
  "babel-plugin-inline-json-import": "^0.3.2",
@@ -40,6 +42,7 @@
40
42
  "eslint-plugin-react": "^7.34.1",
41
43
  "eslint-plugin-react-hooks": "^4.6.0",
42
44
  "eslint-plugin-storybook": "^0.6.15",
45
+ "jest": "^29.7.0",
43
46
  "markdown-to-jsx": "^7.4.1",
44
47
  "prettier": "^3.2.5",
45
48
  "prop-types": "^15.8.1",