@maif/react-forms 1.0.36 → 1.0.39

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 (69) hide show
  1. package/README.md +2 -12
  2. package/lib/esm/index.js +620 -824
  3. package/lib/index.js +622 -825
  4. package/package.json +11 -4
  5. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -10
  6. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -10
  7. package/.github/workflows/build-playground.yml +0 -34
  8. package/.github/workflows/generate-release-note.yml +0 -48
  9. package/.github/workflows/release.yml +0 -73
  10. package/docs/asset-manifest.json +0 -24
  11. package/docs/index.html +0 -1
  12. package/docs/manifest.json +0 -25
  13. package/docs/robots.txt +0 -3
  14. package/docs/static/css/2.6902daba.chunk.css +0 -11
  15. package/docs/static/css/2.6902daba.chunk.css.map +0 -1
  16. package/docs/static/css/main.8693c9f3.chunk.css +0 -2
  17. package/docs/static/css/main.8693c9f3.chunk.css.map +0 -1
  18. package/docs/static/js/2.bc3a307f.chunk.js +0 -3
  19. package/docs/static/js/2.bc3a307f.chunk.js.LICENSE.txt +0 -147
  20. package/docs/static/js/2.bc3a307f.chunk.js.map +0 -1
  21. package/docs/static/js/main.a5abf7f1.chunk.js +0 -2
  22. package/docs/static/js/main.a5abf7f1.chunk.js.map +0 -1
  23. package/docs/static/js/runtime-main.368a22f5.js +0 -2
  24. package/docs/static/js/runtime-main.368a22f5.js.map +0 -1
  25. package/docs/static/media/fa-brands-400.2285773e.woff +0 -0
  26. package/docs/static/media/fa-brands-400.23f19bb0.eot +0 -0
  27. package/docs/static/media/fa-brands-400.2f517e09.svg +0 -3717
  28. package/docs/static/media/fa-brands-400.527940b1.ttf +0 -0
  29. package/docs/static/media/fa-brands-400.d878b0a6.woff2 +0 -0
  30. package/docs/static/media/fa-regular-400.4689f52c.svg +0 -801
  31. package/docs/static/media/fa-regular-400.491974d1.ttf +0 -0
  32. package/docs/static/media/fa-regular-400.77206a6b.eot +0 -0
  33. package/docs/static/media/fa-regular-400.7a333762.woff2 +0 -0
  34. package/docs/static/media/fa-regular-400.bb58e57c.woff +0 -0
  35. package/docs/static/media/fa-solid-900.1551f4f6.woff2 +0 -0
  36. package/docs/static/media/fa-solid-900.7a8b4f13.svg +0 -5034
  37. package/docs/static/media/fa-solid-900.9bbb245e.eot +0 -0
  38. package/docs/static/media/fa-solid-900.be9ee23c.ttf +0 -0
  39. package/docs/static/media/fa-solid-900.eeccf4f6.woff +0 -0
  40. package/examples/.env +0 -2
  41. package/examples/README.md +0 -0
  42. package/examples/package.json +0 -43
  43. package/examples/public/index.html +0 -43
  44. package/examples/public/manifest.json +0 -25
  45. package/examples/public/robots.txt +0 -3
  46. package/examples/src/App.css +0 -10
  47. package/examples/src/Playground.js +0 -158
  48. package/examples/src/WrapperError.js +0 -21
  49. package/examples/src/index.css +0 -13
  50. package/examples/src/index.js +0 -11
  51. package/examples/src/reportWebVitals.js +0 -13
  52. package/examples/src/schema/basic.json +0 -15
  53. package/examples/src/schema/constrainedBasic.json +0 -28
  54. package/examples/src/schema/constraintsWithRef.json +0 -44
  55. package/examples/src/schema/dynamicForm.json +0 -57
  56. package/examples/src/schema/formArray.js +0 -30
  57. package/examples/src/schema/formInForm.json +0 -39
  58. package/examples/src/schema/selector.json +0 -14
  59. package/jest-sync.config.json +0 -17
  60. package/rollup.config.js +0 -66
  61. package/scripts/build.sh +0 -34
  62. package/test/array.spec.js +0 -78
  63. package/test/bool.spec.js +0 -29
  64. package/test/date.spec.js +0 -41
  65. package/test/number.spec.js +0 -124
  66. package/test/object.spec.js +0 -14
  67. package/test/string.spec.js +0 -87
  68. package/test/testUtils.js +0 -30
  69. package/test-setup.js +0 -9
package/rollup.config.js DELETED
@@ -1,66 +0,0 @@
1
- import babel from '@rollup/plugin-babel'
2
- import external from 'rollup-plugin-peer-deps-external'
3
- import del from 'rollup-plugin-delete'
4
- import pkg from './package.json'
5
- import commonjs from '@rollup/plugin-commonjs'
6
- import resolve from "@rollup/plugin-node-resolve"
7
- import { terser } from 'rollup-plugin-terser'
8
- import copy from 'rollup-plugin-copy'
9
-
10
- const isDev = process.env.NODE_ENV !== 'production'
11
-
12
- export default [
13
- {
14
- input: "./src/codemirror-editor.js",
15
- inlineDynamicImports: true,
16
- output: {
17
- file: "./src/inputs/__generated/editor.js",
18
- format: "esm",
19
- strict: false
20
- },
21
- plugins: [
22
- babel({
23
- exclude: [
24
- 'docs/**',
25
- 'node_modules/**',
26
- 'src/inputs/editor.js'
27
- ],
28
- babelHelpers: 'bundled'
29
- }),
30
- resolve(),
31
- commonjs(),
32
- isDev ? undefined : terser()
33
- ].filter(f => f)
34
- },
35
- {
36
- input: pkg.source,
37
- output: [
38
- { file: pkg.main, format: 'cjs' },
39
- { file: pkg.module, format: 'esm' }
40
- ],
41
- plugins: [
42
- external(),
43
- babel({
44
- exclude: [
45
- 'docs/**',
46
- 'node_modules/**',
47
- 'src/inputs/__generated/editor.js'
48
- ],
49
- babelHelpers: 'bundled'
50
- }),
51
- del({ targets: ['dist/*', 'lib/*', 'examples/node_modules/@maif/react-forms/lib'], verbose: true }),
52
- isDev ? undefined : terser(),
53
- copy({
54
- targets: [
55
- {
56
- src: 'lib/index.js',
57
- dest: 'examples/node_modules/@maif/react-forms/lib'
58
- }
59
- ],
60
- verbose: true,
61
- hook: 'closeBundle'
62
- })
63
- ].filter(f => f),
64
- external: Object.keys(pkg.peerDependencies || {})
65
- }
66
- ];
package/scripts/build.sh DELETED
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- LOCATION=`pwd`
4
-
5
- build () {
6
- cd $LOCATION
7
- yarn install
8
- yarn build
9
- }
10
-
11
- publish () {
12
- TAG_NAME=`git describe --tags`
13
- echo "Publishing npm packages for tag ${TAG_NAME}"
14
-
15
- PACKAGE_VERSION=$(echo "${TAG_NAME}" | cut -d "v" -f 2)
16
- cd ${LOCATION}
17
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >>.npmrc
18
-
19
- echo "Setting version to ${PACKAGE_VERSION}"
20
- npm version ${PACKAGE_VERSION}
21
- echo 'Publishing'
22
- npm publish
23
- }
24
-
25
- case "${1}" in
26
- github)
27
- build
28
- publish
29
- ;;
30
- *)
31
- echo "bad params"
32
- esac
33
-
34
- exit ${?}
@@ -1,78 +0,0 @@
1
-
2
- import * as constraints from '../src/constraints';
3
- import * as yup from 'yup';
4
- import { getShapeAndDependencies } from '../src/resolvers';
5
-
6
- const testArrayConstraints = (constraints = [], message, right, wrong, type) => {
7
- const schema = {
8
- test: {
9
- type,
10
- array: true,
11
- constraints
12
- }
13
- }
14
-
15
- const flow = ['test']
16
-
17
- const { shape, dependencies } = getShapeAndDependencies(flow, schema);
18
- const resolver = yup.object().shape(shape, dependencies);
19
-
20
- return resolver.validate(right)
21
- .then(r => {
22
- console.log({r})
23
- return expect(r).to.equal(right)})
24
- .then(() => resolver.validate(wrong))
25
- .catch(e => {
26
- console.warn({e})
27
- expect(e.errors[0]).to.equal(message)})
28
- };
29
-
30
- describe('Array resolver', () => {
31
- it('should resolve array constraints', () => {
32
-
33
- const errorMessage = "test must be a `array` type, but the final value was: `null` (cast from the value `\"fifou\"`).\n If \"null\" is intended as an empty value be sure to mark the schema as `.nullable()`";
34
- const testConstraints = []
35
-
36
- const right = { test: [1, 2, 3] }
37
- const wrong = { test: 'fifou' }
38
-
39
-
40
- return testArrayConstraints(testConstraints, errorMessage, right, wrong, 'number')
41
- })
42
- it('should resolve min constraints', () => {
43
-
44
- const errorMessage = "min";
45
- const testConstraints = [
46
- constraints.min(3, errorMessage)
47
- ]
48
-
49
- const right = { test: [1, 2, 3, 4] }
50
- const wrong = { test: [1, 2] }
51
-
52
- return testArrayConstraints(testConstraints, errorMessage, right, wrong, 'number')
53
- })
54
- it('should resolve max constraints', () => {
55
-
56
- const errorMessage = "max";
57
- const testConstraints = [
58
- constraints.max(3, errorMessage)
59
- ]
60
-
61
- const right = { test: [1, 2] }
62
- const wrong = { test: [1, 2, 3, 4] }
63
-
64
- return testArrayConstraints(testConstraints, errorMessage, right, wrong, 'number')
65
- })
66
- it('should resolve length constraints', () => {
67
-
68
- const errorMessage = "length";
69
- const testConstraints = [
70
- constraints.length(2, errorMessage)
71
- ]
72
-
73
- const right = { test: [1, 2] }
74
- const wrong = { test: [1] }
75
-
76
- return testArrayConstraints(testConstraints, errorMessage, right, wrong, 'number')
77
- })
78
- })
package/test/bool.spec.js DELETED
@@ -1,29 +0,0 @@
1
-
2
- import * as constraints from '../src/constraints';
3
- import { testBasicConstraints } from './testUtils';
4
-
5
-
6
- describe('Boolean resolver', () => {
7
- it('should resolve boolean constraints', () => {
8
-
9
- const errorMessage = "test must be a `boolean` type, but the final value was: `\"fifou\"`.";
10
- const testConstraints = []
11
-
12
- const right = { test: true }
13
- const wrong = { test: 'fifou' }
14
-
15
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'bool')
16
- })
17
- it('should resolve required constraints', () => {
18
-
19
- const errorMessage = "required";
20
- const testConstraints = [
21
- constraints.required(errorMessage)
22
- ]
23
-
24
- const right = { test: true }
25
- const wrong = { foo: false }
26
-
27
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'bool')
28
- })
29
- })
package/test/date.spec.js DELETED
@@ -1,41 +0,0 @@
1
- import * as constraints from '../src/constraints';
2
- import { testBasicConstraints } from './testUtils';
3
-
4
-
5
-
6
- describe('Date resolver', () => {
7
- //todo: test with string instead of number
8
- it('should resolve date constraints', () => {
9
-
10
- const errorMessage = "Value must be a date";
11
- const testConstraints = []
12
- const right = { test: new Date('November 3, 1985 23:15:30') }
13
- const wrong = { test: 'fifou' }
14
-
15
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'date')
16
- })
17
- it('should resolve min constraints', () => {
18
-
19
- const errorMessage = "not min";
20
- const testConstraints = [
21
- constraints.min(new Date('November 2, 1985 23:15:30'), errorMessage)
22
- ]
23
-
24
- const right = { test: new Date('November 3, 1985 23:15:30') }
25
- const wrong = { test: new Date('November 1, 1985 23:15:30') }
26
-
27
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'date')
28
- })
29
- it('should resolve max constraints', () => {
30
-
31
- const errorMessage = "not max";
32
- const testConstraints = [
33
- constraints.max(new Date('November 2, 1985 23:15:30'), errorMessage)
34
- ]
35
-
36
- const right = { test: new Date('November 1, 1985 23:15:30') }
37
- const wrong = { foo: new Date('November 3, 1985 23:15:30') }
38
-
39
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'date')
40
- })
41
- })
@@ -1,124 +0,0 @@
1
- import * as constraints from '../src/constraints';
2
- import { testBasicConstraints } from './testUtils';
3
-
4
- describe('Number resolver', () => {
5
- it('should resolve number constraints', () => {
6
-
7
- const errorMessage = "Value must be a number";
8
- const testConstraints = []
9
-
10
- const right = { test: 1 }
11
- const wrong = { test: 'fifou' }
12
-
13
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'number')
14
- })
15
- it('should resolve integer constraints', () => {
16
-
17
- const errorMessage = "not integer";
18
- const testConstraints = [
19
- constraints.integer(errorMessage)
20
- ]
21
-
22
- const right = { test: 42 }
23
- const wrong = { test: 1.2 }
24
-
25
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'number')
26
- })
27
- it('should resolve positive constraints', () => {
28
-
29
- const errorMessage = "not positive";
30
- const testConstraints = [
31
- constraints.positive(errorMessage)
32
- ]
33
-
34
- const right = { test: 42 }
35
- const wrong = { test: -42 }
36
-
37
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'number')
38
- })
39
- it('should resolve negative constraints', () => {
40
-
41
- const errorMessage = "not negative";
42
- const testConstraints = [
43
- constraints.negative(errorMessage)
44
- ]
45
-
46
- const right = { test: -42 }
47
- const wrong = { test: 42 }
48
-
49
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'number')
50
- })
51
- it('should resolve min constraints', () => {
52
-
53
- const errorMessage = "there is a min condition";
54
- const testConstraints = [
55
- constraints.min(40, errorMessage)
56
- ]
57
-
58
- const right = { test: 42 }
59
- const wrong = { test: 2 }
60
-
61
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'number')
62
- })
63
- it('should resolve max constraints', () => {
64
-
65
- const errorMessage = "there is a max condition";
66
- const testConstraints = [
67
- constraints.max(44, errorMessage)
68
- ]
69
-
70
- const right = { test: 42 }
71
- const wrong = { test: 45 }
72
-
73
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'number')
74
- })
75
- it('should resolve moreThan constraints with ref', () => {
76
-
77
- const errorMessage = "not more than value";
78
- const testConstraints = [
79
- constraints.moreThan(constraints.ref('value'), errorMessage)
80
- ]
81
-
82
- const right = { test: 42, value: 40 }
83
- const wrong = { test: 38, value: 40 }
84
-
85
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'number')
86
- })
87
- it('should resolve moreThan constraints', () => {
88
-
89
- const errorMessage = "not more than value";
90
- const testConstraints = [
91
- constraints.moreThan(40, errorMessage)
92
- ]
93
-
94
- const right = { test: 42 }
95
- const wrong = { test: 38 }
96
-
97
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'number')
98
- })
99
- it('should resolve lessThan constraints with ref', () => {
100
-
101
- const errorMessage = "not less than value";
102
- const testConstraints = [
103
- constraints.lessThan(constraints.ref('value'), errorMessage)
104
- ]
105
-
106
- const right = { test: 42, value: 44 }
107
- const wrong = { test: 46, value: 44 }
108
-
109
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'number')
110
- })
111
- it('should resolve lessThan constraints', () => {
112
-
113
- const errorMessage = "not less than value";
114
- const testConstraints = [
115
- constraints.lessThan(44, errorMessage)
116
- ]
117
-
118
- const right = { test: 42 }
119
- const wrong = { test: 46 }
120
-
121
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'number')
122
- })
123
- })
124
-
@@ -1,14 +0,0 @@
1
- import { testBasicConstraints } from './testUtils';
2
-
3
-
4
- describe('Object resolver', () => {
5
- it('should resolve object constraints', () => {
6
- const message = `test must be a \`object\` type, but the final value was: \`null\` (cast from the value \`"fifou"\`).\n If "null" is intended as an empty value be sure to mark the schema as \`.nullable()\``
7
- const testConstraints = []
8
-
9
- const right = { test: {foo: 'bar'} }
10
- const wrong = { test: 'fifou' }
11
-
12
- return testBasicConstraints(testConstraints, message, right, wrong, 'object')
13
- })
14
- })
@@ -1,87 +0,0 @@
1
- import * as constraints from '../src/constraints';
2
- import { testBasicConstraints } from './testUtils';
3
-
4
- describe('String resolver', () => {
5
- it('should resolve string constraints', () => {
6
-
7
- const errorMessage = "test must be a `string` type, but the final value was: `42`.";
8
- const testConstraints = []
9
-
10
- const right = { test: 'fifou' }
11
- const wrong = { test: 42 }
12
-
13
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'string')
14
- })
15
- it('should resolve min constraints', () => {
16
-
17
- const errorMessage = "not here";
18
- const testConstraints = [
19
- constraints.min(5, errorMessage)
20
- ]
21
-
22
- const right = {test: "fifou"}
23
- const wrong = {test: "foo"}
24
-
25
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'string')
26
- })
27
-
28
- it('should resolve max constraints', () => {
29
- const errorMessage = "too long";
30
- const testConstraints = [
31
- constraints.max(5, errorMessage)
32
- ]
33
-
34
- const right = {test: "foo"}
35
- const wrong = {test: "fifou"}
36
-
37
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'string')
38
- })
39
-
40
- it('should resolve url constraints', () => {
41
- const errorMessage = "not an url";
42
- const testConstraints = [
43
- constraints.url(errorMessage)
44
- ]
45
-
46
- const right = {test: "http://fifou.io"}
47
- const wrong = {test: "fifou"}
48
-
49
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'string')
50
- })
51
-
52
- it('should resolve email constraints', () => {
53
- const errorMessage = "not an email";
54
- const testConstraints = [
55
- constraints.email(errorMessage)
56
- ]
57
-
58
- const right = {test: "fifou@foo.bar"}
59
- const wrong = {test: "fifou"}
60
-
61
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'string')
62
- })
63
-
64
- it('should resolve uuid constraints', () => {
65
- const errorMessage = "not an uuid";
66
- const testConstraints = [
67
- constraints.uuid(errorMessage)
68
- ]
69
-
70
- const right = {test: "12345678-1234-1234-1234-1234567890123"}
71
- const wrong = {test: "fifou"}
72
-
73
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'string')
74
- })
75
-
76
- it('should resolve matches constraints', () => {
77
- const errorMessage = "no matche";
78
- const testConstraints = [
79
- constraints.matches(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$^+=!*()@%&]).{8,1000}$/, errorMessage)
80
- ]
81
-
82
- const right = {test: "F1f0u!"}
83
- const wrong = {test: "fifou"}
84
-
85
- return testBasicConstraints(testConstraints, errorMessage, right, wrong, 'string')
86
- })
87
- })
package/test/testUtils.js DELETED
@@ -1,30 +0,0 @@
1
- import * as yup from 'yup';
2
-
3
- import { getShapeAndDependencies } from '../src/resolvers';
4
-
5
- export const testBasicConstraints = (constraints = [], message, right, wrong, type) => {
6
- const schema = {
7
- test: {
8
- type,
9
- constraints
10
- }
11
- }
12
-
13
- const flow = ['test']
14
-
15
- const { shape, dependencies } = getShapeAndDependencies(flow, schema);
16
- const resolver = yup.object().shape(shape, dependencies);
17
-
18
- // return Promise.all([
19
- // resolver.isValid(right),
20
- // resolver.isValid(wrong),
21
- // ]).then(([rR, rW]) => {
22
- // expect(rR).to.equal(true)
23
- // expect(rW).to.equal(false)
24
- // })
25
-
26
- return resolver.validate(right)
27
- .then(r => expect(r).to.equal(right))
28
- .then(() => resolver.validate(wrong))
29
- .catch(e => expect(e.errors[0]).to.equal(message))
30
- };
package/test-setup.js DELETED
@@ -1,9 +0,0 @@
1
- global.chai = require('chai');
2
- global.sinon = require('sinon');
3
-
4
- global.chai.use(require('sinon-chai'));
5
- global.chai.use(require('chai-as-promised'));
6
- global.chai.use(require('dirty-chai'));
7
-
8
- global.expect = global.chai.expect;
9
- global.chai.should();