@maif/react-forms 1.0.29 → 1.0.32

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.
Files changed (44) hide show
  1. package/README.md +5 -4
  2. package/lib/esm/index.js +30260 -0
  3. package/lib/index.js +30281 -39
  4. package/package.json +29 -36
  5. package/rollup.config.js +53 -0
  6. package/dist/react-form.js +0 -2
  7. package/dist/react-form.js.LICENSE.txt +0 -103
  8. package/lib/Option.d.ts +0 -39
  9. package/lib/Option.js +0 -66
  10. package/lib/constraints.d.ts +0 -90
  11. package/lib/constraints.js +0 -371
  12. package/lib/form.d.ts +0 -2
  13. package/lib/form.js +0 -1361
  14. package/lib/format.d.ts +0 -12
  15. package/lib/format.js +0 -19
  16. package/lib/index.d.ts +0 -4
  17. package/lib/inputs/ArrayInput.d.ts +0 -1
  18. package/lib/inputs/ArrayInput.js +0 -141
  19. package/lib/inputs/BooleanInput.d.ts +0 -4
  20. package/lib/inputs/BooleanInput.js +0 -35
  21. package/lib/inputs/CodeInput.d.ts +0 -9
  22. package/lib/inputs/CodeInput.js +0 -89
  23. package/lib/inputs/Collapse.d.ts +0 -1
  24. package/lib/inputs/Collapse.js +0 -73
  25. package/lib/inputs/MarkdownInput.d.ts +0 -1
  26. package/lib/inputs/MarkdownInput.js +0 -433
  27. package/lib/inputs/SelectInput.d.ts +0 -1
  28. package/lib/inputs/SelectInput.js +0 -236
  29. package/lib/inputs/index.d.ts +0 -7
  30. package/lib/inputs/index.js +0 -96
  31. package/lib/inputs/objectInput.d.ts +0 -1
  32. package/lib/inputs/objectInput.js +0 -115
  33. package/lib/resolvers/index.d.ts +0 -2
  34. package/lib/resolvers/index.js +0 -19
  35. package/lib/resolvers/utils.d.ts +0 -5
  36. package/lib/resolvers/utils.js +0 -133
  37. package/lib/style.d.ts +0 -230
  38. package/lib/style.js +0 -178
  39. package/lib/styleContext.d.ts +0 -1
  40. package/lib/styleContext.js +0 -29
  41. package/lib/type.d.ts +0 -8
  42. package/lib/type.js +0 -15
  43. package/lib/utils.d.ts +0 -2
  44. package/lib/utils.js +0 -37
@@ -1,103 +0,0 @@
1
- /*
2
- object-assign
3
- (c) Sindre Sorhus
4
- @license MIT
5
- */
6
-
7
- /*!
8
- autosize 4.0.4
9
- license: MIT
10
- http://www.jacklmoore.com/autosize
11
- */
12
-
13
- /*!
14
- Copyright (c) 2018 Jed Watson.
15
- Licensed under the MIT License (MIT), see
16
- http://jedwatson.github.io/classnames
17
- */
18
-
19
- /*!
20
- * Chart.js v2.9.4
21
- * https://www.chartjs.org
22
- * (c) 2020 Chart.js Contributors
23
- * Released under the MIT License
24
- */
25
-
26
- /*!
27
- * Determine if an object is a Buffer
28
- *
29
- * @author Feross Aboukhadijeh <https://feross.org>
30
- * @license MIT
31
- */
32
-
33
- /*!
34
- * repeat-string <https://github.com/jonschlinkert/repeat-string>
35
- *
36
- * Copyright (c) 2014-2015, Jon Schlinkert.
37
- * Licensed under the MIT License.
38
- */
39
-
40
- /*! *****************************************************************************
41
- Copyright (c) Microsoft Corporation. All rights reserved.
42
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
43
- this file except in compliance with the License. You may obtain a copy of the
44
- License at http://www.apache.org/licenses/LICENSE-2.0
45
-
46
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
47
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
48
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
49
- MERCHANTABLITY OR NON-INFRINGEMENT.
50
-
51
- See the Apache Version 2.0 License for specific language governing permissions
52
- and limitations under the License.
53
- ***************************************************************************** */
54
-
55
- /*! showdown v 1.9.1 - 02-11-2019 */
56
-
57
- /**
58
- * A better abstraction over CSS.
59
- *
60
- * @copyright Oleg Isonen (Slobodskoi) / Isonen 2014-present
61
- * @website https://github.com/cssinjs/jss
62
- * @license MIT
63
- */
64
-
65
- /** @license React v0.20.2
66
- * scheduler.production.min.js
67
- *
68
- * Copyright (c) Facebook, Inc. and its affiliates.
69
- *
70
- * This source code is licensed under the MIT license found in the
71
- * LICENSE file in the root directory of this source tree.
72
- */
73
-
74
- /** @license React v16.13.1
75
- * react-is.production.min.js
76
- *
77
- * Copyright (c) Facebook, Inc. and its affiliates.
78
- *
79
- * This source code is licensed under the MIT license found in the
80
- * LICENSE file in the root directory of this source tree.
81
- */
82
-
83
- /** @license React v17.0.2
84
- * react-dom.production.min.js
85
- *
86
- * Copyright (c) Facebook, Inc. and its affiliates.
87
- *
88
- * This source code is licensed under the MIT license found in the
89
- * LICENSE file in the root directory of this source tree.
90
- */
91
-
92
- /** @license React v17.0.2
93
- * react.production.min.js
94
- *
95
- * Copyright (c) Facebook, Inc. and its affiliates.
96
- *
97
- * This source code is licensed under the MIT license found in the
98
- * LICENSE file in the root directory of this source tree.
99
- */
100
-
101
- //! moment.js
102
-
103
- //! moment.js locale configuration
package/lib/Option.d.ts DELETED
@@ -1,39 +0,0 @@
1
- export function option(x: any): any;
2
- export function Some(x: any): {
3
- map: (f: any) => any;
4
- flatMap: (f: any) => any;
5
- fold: (_ifEmpty: any, f: any) => any;
6
- orElse: () => any;
7
- getOrElse: () => any;
8
- getOrNull: () => any;
9
- isDefined: boolean;
10
- exists: (f: any) => any;
11
- };
12
- export namespace None {
13
- function map(): {
14
- map: () => any;
15
- flatMap: () => any;
16
- fold: (ifEmpty: any, _f: any) => any;
17
- orElse: (x: any) => any;
18
- getOrElse: (ifEmpty: any) => any;
19
- getOrNull: () => undefined;
20
- isDefined: boolean;
21
- exists: () => boolean;
22
- };
23
- function flatMap(): {
24
- map: () => any;
25
- flatMap: () => any;
26
- fold: (ifEmpty: any, _f: any) => any;
27
- orElse: (x: any) => any;
28
- getOrElse: (ifEmpty: any) => any;
29
- getOrNull: () => undefined;
30
- isDefined: boolean;
31
- exists: () => boolean;
32
- };
33
- function fold(ifEmpty: any, _f: any): any;
34
- function orElse(x: any): any;
35
- function getOrElse(ifEmpty: any): any;
36
- function getOrNull(): undefined;
37
- const isDefined: boolean;
38
- function exists(): boolean;
39
- }
package/lib/Option.js DELETED
@@ -1,66 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.None = exports.Some = exports.option = void 0;
7
-
8
- var option = function option(x) {
9
- return x === undefined || x === null ? None : Some(x);
10
- };
11
-
12
- exports.option = option;
13
-
14
- var Some = function Some(x) {
15
- return {
16
- map: function map(f) {
17
- return option(f(x));
18
- },
19
- flatMap: function flatMap(f) {
20
- return f(x);
21
- },
22
- fold: function fold(_ifEmpty, f) {
23
- return f(x);
24
- },
25
- orElse: function orElse() {
26
- return option(x);
27
- },
28
- getOrElse: function getOrElse() {
29
- return x;
30
- },
31
- getOrNull: function getOrNull() {
32
- return x;
33
- },
34
- isDefined: true,
35
- exists: function exists(f) {
36
- return option(f(x)).isDefined;
37
- }
38
- };
39
- };
40
-
41
- exports.Some = Some;
42
- var None = {
43
- map: function map() {
44
- return None;
45
- },
46
- flatMap: function flatMap() {
47
- return None;
48
- },
49
- fold: function fold(ifEmpty, _f) {
50
- return ifEmpty();
51
- },
52
- orElse: function orElse(x) {
53
- return option(x);
54
- },
55
- getOrElse: function getOrElse(ifEmpty) {
56
- return ifEmpty;
57
- },
58
- getOrNull: function getOrNull() {
59
- return undefined;
60
- },
61
- isDefined: false,
62
- exists: function exists() {
63
- return false;
64
- }
65
- };
66
- exports.None = None;
@@ -1,90 +0,0 @@
1
- import * as yup from 'yup';
2
- import Reference from "yup/lib/Reference";
3
- interface NumberReference {
4
- ref: number | Reference<number>;
5
- message: string;
6
- }
7
- interface ArrayOfStringConstraint {
8
- arrayOfValues: string[];
9
- message: string;
10
- }
11
- interface ArrayOfAnyConstraint {
12
- arrayOfValues: any[];
13
- message: string;
14
- }
15
- interface TestConstraint {
16
- name: string;
17
- message: string;
18
- test: (val: any) => boolean;
19
- }
20
- interface WhenConstraint {
21
- ref: string;
22
- test: (val: any) => boolean;
23
- then: any;
24
- otherwise: any;
25
- }
26
- interface Ref {
27
- ref: string;
28
- }
29
- export declare const required: (message?: string) => (r: yup.AnySchema) => any;
30
- export declare const url: (message?: string) => (r: yup.StringSchema) => yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
31
- export declare const email: (message?: string) => (r: yup.StringSchema) => yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
32
- export declare const uuid: (message?: string) => (r: yup.StringSchema) => yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
33
- export declare const matches: (regexp?: RegExp, message?: string) => (r: yup.StringSchema) => yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
34
- export declare const min: (ref: number | Reference<number>, message?: string) => (r: yup.NumberSchema | yup.StringSchema) => yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined> | yup.NumberSchema<number | undefined, import("yup/lib/types").AnyObject, number | undefined>;
35
- export declare const max: (ref: number | Reference<number>, message?: string) => (r: yup.NumberSchema | yup.StringSchema) => yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined> | yup.NumberSchema<number | undefined, import("yup/lib/types").AnyObject, number | undefined>;
36
- export declare const positive: (message?: string) => (r: yup.NumberSchema) => yup.NumberSchema<number | undefined, import("yup/lib/types").AnyObject, number | undefined>;
37
- export declare const negative: (message?: string) => (r: yup.NumberSchema) => yup.NumberSchema<number | undefined, import("yup/lib/types").AnyObject, number | undefined>;
38
- export declare const integer: (message?: string) => (r: yup.NumberSchema) => yup.NumberSchema<number | undefined, import("yup/lib/types").AnyObject, number | undefined>;
39
- export declare const lessThan: (ref: number | Reference<number>, message?: string) => (r: yup.NumberSchema, key: string, dependencies: any) => yup.NumberSchema<number | undefined, import("yup/lib/types").AnyObject, number | undefined>;
40
- export declare const moreThan: (ref: number | Reference<number>, message?: string) => (r: yup.NumberSchema, key: string, dependencies: any) => yup.NumberSchema<number | undefined, import("yup/lib/types").AnyObject, number | undefined>;
41
- export declare const length: (ref: number | Reference<number>, message?: string) => (r: yup.ArraySchema<yup.AnySchema>) => yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
42
- export declare const supportedFormat: (arrayOfValues: string[], message?: string) => (r: yup.ObjectSchema<any, any, any, any>) => yup.ObjectSchema<any, any, any, any>;
43
- export declare const unsupportedFormat: (arrayOfValues: string[], message?: string) => (r: yup.ObjectSchema<any, any, any, any>) => yup.ObjectSchema<any, any, any, any>;
44
- export declare const maxSize: (ref: number | Reference<number>, message?: string) => (r: yup.ObjectSchema<any, any, any, any>) => yup.ObjectSchema<any, any, any, any>;
45
- export declare const nullable: () => (r: yup.AnySchema) => any;
46
- export declare const test: (name: string, message: string | undefined, test: (val: any) => boolean) => (r: yup.AnySchema) => yup.AnySchema<any, any, any>;
47
- export declare const when: (ref: string, test: (val: any) => boolean, then?: any, otherwise?: any) => (r: yup.AnySchema, key: string, dependencies: any) => yup.AnySchema<any, any, any>;
48
- export declare const oneOf: (arrayOfValues: any[], message?: string) => (r: yup.AnySchema) => yup.AnySchema<any, any, any>;
49
- export declare const ref: (ref: string) => Reference;
50
- export declare const jsonConstraints: {
51
- required: ({ message }: {
52
- message?: string | undefined;
53
- }) => (r: yup.AnySchema) => any;
54
- url: ({ message }: {
55
- message?: string | undefined;
56
- }) => (r: yup.StringSchema) => yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
57
- email: ({ message }: {
58
- message?: string | undefined;
59
- }) => (r: yup.StringSchema) => yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
60
- uuid: ({ message }: {
61
- message?: string | undefined;
62
- }) => (r: yup.StringSchema) => yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
63
- matches: ({ regexp, message }: {
64
- regexp?: RegExp | undefined;
65
- message?: string | undefined;
66
- }) => (r: yup.StringSchema) => yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
67
- min: ({ ref, message }: NumberReference) => (r: yup.NumberSchema | yup.StringSchema) => yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined> | yup.NumberSchema<number | undefined, import("yup/lib/types").AnyObject, number | undefined>;
68
- max: ({ ref, message }: NumberReference) => (r: yup.NumberSchema | yup.StringSchema) => yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined> | yup.NumberSchema<number | undefined, import("yup/lib/types").AnyObject, number | undefined>;
69
- positive: ({ message }: {
70
- message?: string | undefined;
71
- }) => (r: yup.NumberSchema) => yup.NumberSchema<number | undefined, import("yup/lib/types").AnyObject, number | undefined>;
72
- negative: ({ message }: {
73
- message?: string | undefined;
74
- }) => (r: yup.NumberSchema) => yup.NumberSchema<number | undefined, import("yup/lib/types").AnyObject, number | undefined>;
75
- integer: ({ message }: {
76
- message?: string | undefined;
77
- }) => (r: yup.NumberSchema) => yup.NumberSchema<number | undefined, import("yup/lib/types").AnyObject, number | undefined>;
78
- lessThan: ({ ref, message }: NumberReference) => (r: yup.NumberSchema, key: string, dependencies: any) => yup.NumberSchema<number | undefined, import("yup/lib/types").AnyObject, number | undefined>;
79
- moreThan: ({ ref, message }: NumberReference) => (r: yup.NumberSchema, key: string, dependencies: any) => yup.NumberSchema<number | undefined, import("yup/lib/types").AnyObject, number | undefined>;
80
- length: ({ ref, message }: NumberReference) => (r: yup.ArraySchema<yup.AnySchema>) => yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
81
- supportedFormat: ({ arrayOfValues, message }: ArrayOfStringConstraint) => (r: yup.ObjectSchema<any, any, any, any>) => yup.ObjectSchema<any, any, any, any>;
82
- unsupportedFormat: ({ arrayOfValues, message }: ArrayOfStringConstraint) => (r: yup.ObjectSchema<any, any, any, any>) => yup.ObjectSchema<any, any, any, any>;
83
- maxSize: ({ ref, message }: NumberReference) => (r: yup.ObjectSchema<any, any, any, any>) => yup.ObjectSchema<any, any, any, any>;
84
- test: (c: TestConstraint) => (r: yup.AnySchema) => yup.AnySchema<any, any, any>;
85
- when: ({ ref, test, then, otherwise }: WhenConstraint) => (r: yup.AnySchema, key: string, dependencies: any) => yup.AnySchema<any, any, any>;
86
- oneOf: ({ arrayOfValues, message }: ArrayOfAnyConstraint) => (r: yup.AnySchema) => yup.AnySchema<any, any, any>;
87
- ref: (val: Ref) => Reference;
88
- nullable: () => (r: yup.AnySchema) => any;
89
- };
90
- export {};
@@ -1,371 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.jsonConstraints = exports.ref = exports.oneOf = exports.when = exports.test = exports.nullable = exports.maxSize = exports.unsupportedFormat = exports.supportedFormat = exports.length = exports.moreThan = exports.lessThan = exports.integer = exports.negative = exports.positive = exports.max = exports.min = exports.matches = exports.uuid = exports.email = exports.url = exports.required = void 0;
9
-
10
- var yup = _interopRequireWildcard(require("yup"));
11
-
12
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
-
14
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
-
16
- var _required = function required() {
17
- var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "Value required";
18
- return function (r) {
19
- return r.required(message);
20
- };
21
- }; //string
22
-
23
-
24
- exports.required = _required;
25
-
26
- var _url = function url() {
27
- var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "That is not a valid url";
28
- return function (r) {
29
- return r.url(message);
30
- };
31
- };
32
-
33
- exports.url = _url;
34
-
35
- var _email = function email() {
36
- var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "That is not a valid email";
37
- return function (r) {
38
- return r.email(message);
39
- };
40
- };
41
-
42
- exports.email = _email;
43
-
44
- var _uuid = function uuid() {
45
- var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "That is not a valid uuid";
46
- return function (r) {
47
- return r.uuid(message);
48
- };
49
- };
50
-
51
- exports.uuid = _uuid;
52
-
53
- var _matches = function matches() {
54
- var regexp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : /.*/;
55
- var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "This field does not match the pattern";
56
- return function (r) {
57
- return r.matches(regexp, {
58
- message: message
59
- });
60
- };
61
- }; //string & number
62
-
63
-
64
- exports.matches = _matches;
65
-
66
- var _min = function min(ref) {
67
- var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "Min value is required";
68
- return function (r) {
69
- return r.min(maybeRef(ref), message);
70
- };
71
- };
72
-
73
- exports.min = _min;
74
-
75
- var _max = function max(ref) {
76
- var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "Max value is required";
77
- return function (r) {
78
- return r.max(maybeRef(ref), message);
79
- };
80
- }; //number
81
-
82
-
83
- exports.max = _max;
84
-
85
- var _positive = function positive() {
86
- var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "Positive value is required";
87
- return function (r) {
88
- return r.positive(message);
89
- };
90
- };
91
-
92
- exports.positive = _positive;
93
-
94
- var _negative = function negative() {
95
- var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "Negative value is required";
96
- return function (r) {
97
- return r.negative(message);
98
- };
99
- };
100
-
101
- exports.negative = _negative;
102
-
103
- var _integer = function integer() {
104
- var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "an integer please";
105
- return function (r) {
106
- return r.integer(message);
107
- };
108
- };
109
-
110
- exports.integer = _integer;
111
-
112
- var _lessThan = function lessThan(ref) {
113
- var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "This field must be less than ".concat(ref);
114
- return function (r, key, dependencies) {
115
- if (typeof ref !== 'number') {
116
- dependencies.push([key, ref]);
117
- }
118
-
119
- return r.lessThan(maybeRef(ref), message);
120
- };
121
- };
122
-
123
- exports.lessThan = _lessThan;
124
-
125
- var _moreThan = function moreThan(ref) {
126
- var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "This field must be more than ".concat(ref);
127
- return function (r, key, dependencies) {
128
- if (typeof ref !== 'number') {
129
- dependencies.push([key, ref]);
130
- }
131
-
132
- return r.moreThan(maybeRef(ref), message);
133
- };
134
- }; //array
135
-
136
-
137
- exports.moreThan = _moreThan;
138
-
139
- var _length = function length(ref) {
140
- var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "The size of this collection must be ".concat(ref);
141
- return function (r) {
142
- return r.length(maybeRef(ref), message);
143
- };
144
- }; //file
145
-
146
-
147
- exports.length = _length;
148
-
149
- var _supportedFormat = function supportedFormat(arrayOfValues) {
150
- var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Unsupported File Format';
151
- return function (r) {
152
- var SUPPORTED_FORMATS = arrayOfValues.map(function (f) {
153
- return f.toLowerCase();
154
- });
155
- return r.test('supportedFormat', message, function (value) {
156
- if (!value.length) return true;
157
- return SUPPORTED_FORMATS.some(function (format) {
158
- return value[0].type.toLowerCase().includes(format);
159
- });
160
- });
161
- };
162
- };
163
-
164
- exports.supportedFormat = _supportedFormat;
165
-
166
- var _unsupportedFormat = function unsupportedFormat(arrayOfValues) {
167
- var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Unsupported File Format';
168
- return function (r) {
169
- var UNSUPPORTED_FORMATS = arrayOfValues.map(function (f) {
170
- return f.toLowerCase();
171
- });
172
- return r.test('unsupportedFormat', message, function (value) {
173
- if (!value.length) return true;
174
- return UNSUPPORTED_FORMATS.some(function (format) {
175
- return value[0].type.toLowerCase().includes(format);
176
- });
177
- });
178
- };
179
- };
180
-
181
- exports.unsupportedFormat = _unsupportedFormat;
182
-
183
- var _maxSize = function maxSize(ref) {
184
- var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "size is excedeed ".concat(ref);
185
- return function (r) {
186
- return r.test('fileSize', message, function (value) {
187
- if (!value.length) return true;
188
- return value[0].size <= maybeRef(ref);
189
- });
190
- };
191
- }; //mixed
192
-
193
-
194
- exports.maxSize = _maxSize;
195
-
196
- var _nullable = function nullable() {
197
- return function (r) {
198
- return r.nullable();
199
- };
200
- };
201
-
202
- exports.nullable = _nullable;
203
-
204
- var _test = function test(name) {
205
- var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Test failed';
206
- var test = arguments.length > 2 ? arguments[2] : undefined;
207
- return function (r) {
208
- return r.test(name, message, test);
209
- };
210
- };
211
-
212
- exports.test = _test;
213
-
214
- var _when = function when(ref, test) {
215
- var then = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
216
- var otherwise = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
217
- return function (r, key, dependencies) {
218
- // dependencies.push([key, ref])
219
- var thenReducer = then.reduce(function (resolver, constraint) {
220
- return constraint(resolver, key, dependencies);
221
- }, r);
222
- var otherWiseReducer = otherwise.reduce(function (resolver, constraint) {
223
- return constraint(resolver, key, dependencies);
224
- }, r);
225
- return r.when(ref, {
226
- is: test,
227
- then: thenReducer,
228
- otherwise: otherWiseReducer
229
- });
230
- };
231
- };
232
-
233
- exports.when = _when;
234
-
235
- var _oneOf = function oneOf(arrayOfValues) {
236
- var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "This value must be one of ".concat(arrayOfValues.join(', '));
237
- return function (r) {
238
- return r.oneOf(arrayOfValues.map(maybeRef), message);
239
- };
240
- };
241
-
242
- exports.oneOf = _oneOf;
243
-
244
- var _ref20 = function ref(_ref) {
245
- return yup.ref(_ref);
246
- };
247
-
248
- exports.ref = _ref20;
249
-
250
- var maybeRef = function maybeRef(x) {
251
- return x !== null && x !== void 0 && x.ref ? _ref20(x.ref) : x;
252
- }; //### JSON method ###
253
-
254
-
255
- var jsonConstraints = {
256
- required: function required(_ref2) {
257
- var _ref2$message = _ref2.message,
258
- message = _ref2$message === void 0 ? "Value required" : _ref2$message;
259
- return _required(message);
260
- },
261
- url: function url(_ref3) {
262
- var _ref3$message = _ref3.message,
263
- message = _ref3$message === void 0 ? "That is not a valid url" : _ref3$message;
264
- return _url(message);
265
- },
266
- email: function email(_ref4) {
267
- var _ref4$message = _ref4.message,
268
- message = _ref4$message === void 0 ? "That is not a valid email" : _ref4$message;
269
- return _email(message);
270
- },
271
- uuid: function uuid(_ref5) {
272
- var _ref5$message = _ref5.message,
273
- message = _ref5$message === void 0 ? "That is not a valid uuid" : _ref5$message;
274
- return _uuid(message);
275
- },
276
- matches: function matches(_ref6) {
277
- var _ref6$regexp = _ref6.regexp,
278
- regexp = _ref6$regexp === void 0 ? /.*/ : _ref6$regexp,
279
- _ref6$message = _ref6.message,
280
- message = _ref6$message === void 0 ? "This field does not match the pattern" : _ref6$message;
281
- return _matches(regexp, message);
282
- },
283
- min: function min(_ref7) {
284
- var ref = _ref7.ref,
285
- _ref7$message = _ref7.message,
286
- message = _ref7$message === void 0 ? "Min value is required" : _ref7$message;
287
- return _min(ref, message);
288
- },
289
- max: function max(_ref8) {
290
- var ref = _ref8.ref,
291
- _ref8$message = _ref8.message,
292
- message = _ref8$message === void 0 ? "Max value is required" : _ref8$message;
293
- return _max(ref, message);
294
- },
295
- positive: function positive(_ref9) {
296
- var _ref9$message = _ref9.message,
297
- message = _ref9$message === void 0 ? "Positive value is required" : _ref9$message;
298
- return _positive(message);
299
- },
300
- negative: function negative(_ref10) {
301
- var _ref10$message = _ref10.message,
302
- message = _ref10$message === void 0 ? "Negative value is required" : _ref10$message;
303
- return _negative(message);
304
- },
305
- integer: function integer(_ref11) {
306
- var _ref11$message = _ref11.message,
307
- message = _ref11$message === void 0 ? "an integer please" : _ref11$message;
308
- return _integer(message);
309
- },
310
- lessThan: function lessThan(_ref12) {
311
- var ref = _ref12.ref,
312
- _ref12$message = _ref12.message,
313
- message = _ref12$message === void 0 ? "This field must be less than ".concat(ref) : _ref12$message;
314
- return _lessThan(ref, message);
315
- },
316
- moreThan: function moreThan(_ref13) {
317
- var ref = _ref13.ref,
318
- _ref13$message = _ref13.message,
319
- message = _ref13$message === void 0 ? "This field must be more than ".concat(ref) : _ref13$message;
320
- return _moreThan(ref, message);
321
- },
322
- length: function length(_ref14) {
323
- var ref = _ref14.ref,
324
- _ref14$message = _ref14.message,
325
- message = _ref14$message === void 0 ? "The size of this collection must be ".concat(ref) : _ref14$message;
326
- return _length(ref, message);
327
- },
328
- supportedFormat: function supportedFormat(_ref15) {
329
- var arrayOfValues = _ref15.arrayOfValues,
330
- _ref15$message = _ref15.message,
331
- message = _ref15$message === void 0 ? 'Unsupported File Format' : _ref15$message;
332
- return _supportedFormat(arrayOfValues, message);
333
- },
334
- unsupportedFormat: function unsupportedFormat(_ref16) {
335
- var arrayOfValues = _ref16.arrayOfValues,
336
- _ref16$message = _ref16.message,
337
- message = _ref16$message === void 0 ? 'Unsupported File Format' : _ref16$message;
338
- return _unsupportedFormat(arrayOfValues, message);
339
- },
340
- maxSize: function maxSize(_ref17) {
341
- var ref = _ref17.ref,
342
- _ref17$message = _ref17.message,
343
- message = _ref17$message === void 0 ? "size is excedeed ".concat(ref) : _ref17$message;
344
- return _maxSize(ref, message);
345
- },
346
- test: function test(c) {
347
- return _test(c.name, c.message, c.test);
348
- },
349
- when: function when(_ref18) {
350
- var ref = _ref18.ref,
351
- test = _ref18.test,
352
- _ref18$then = _ref18.then,
353
- then = _ref18$then === void 0 ? [] : _ref18$then,
354
- _ref18$otherwise = _ref18.otherwise,
355
- otherwise = _ref18$otherwise === void 0 ? [] : _ref18$otherwise;
356
- return _when(ref, test, then, otherwise);
357
- },
358
- oneOf: function oneOf(_ref19) {
359
- var arrayOfValues = _ref19.arrayOfValues,
360
- _ref19$message = _ref19.message,
361
- message = _ref19$message === void 0 ? "This value must be one of ".concat(arrayOfValues.join(', ')) : _ref19$message;
362
- return _oneOf(arrayOfValues, message);
363
- },
364
- ref: function ref(val) {
365
- return _ref20(val.ref);
366
- },
367
- nullable: function nullable() {
368
- return _nullable();
369
- }
370
- };
371
- exports.jsonConstraints = jsonConstraints;
package/lib/form.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export const Form: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
2
- import React from "react";