react-morning 0.0.1-security → 1.0.9
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.
Potentially problematic release.
This version of react-morning might be problematic. Click here for more details.
- package/LICENSE +22 -0
- package/README.md +320 -3
- package/dist/18.jpg +0 -0
- package/dist/321.jpg +0 -0
- package/dist/6D975C71-92D2-E103-31BF-FC594DC8E7D9.jpg +0 -0
- package/dist/87.gif +0 -0
- package/dist/91.jpg +0 -0
- package/dist/92.jpg +0 -0
- package/dist/CACE99F6-C369-E5A6-6C91-F7199A63745C.jpg +0 -0
- package/dist/FE65CD08-1437-5D3E-014F-05DE91582606.jpg +0 -0
- package/dist/bundle.js +7 -0
- package/package.json +87 -3
- package/src/components/Errors.jsx +86 -0
- package/src/components/Form.jsx +179 -0
- package/src/components/FormBuilder.jsx +113 -0
- package/src/components/FormEdit.jsx +175 -0
- package/src/components/FormGrid.jsx +269 -0
- package/src/components/Grid.jsx +278 -0
- package/src/components/Pagination.jsx +148 -0
- package/src/components/ReactComponent.jsx +189 -0
- package/src/components/SubmissionGrid.jsx +249 -0
- package/src/components/index.js +9 -0
- package/src/constants.js +3 -0
- package/src/index.js +19 -0
- package/src/modules/auth/actions.js +115 -0
- package/src/modules/auth/constants.js +8 -0
- package/src/modules/auth/index.js +4 -0
- package/src/modules/auth/reducers.js +87 -0
- package/src/modules/auth/selectors.js +2 -0
- package/src/modules/form/actions.js +102 -0
- package/src/modules/form/constants.js +6 -0
- package/src/modules/form/index.js +4 -0
- package/src/modules/form/reducers.js +60 -0
- package/src/modules/form/selectors.js +3 -0
- package/src/modules/forms/actions.js +81 -0
- package/src/modules/forms/constants.js +4 -0
- package/src/modules/forms/index.js +4 -0
- package/src/modules/forms/reducers.js +77 -0
- package/src/modules/forms/selectors.js +3 -0
- package/src/modules/index.js +6 -0
- package/src/modules/root/Shark-1.0.0.0802.apk +0 -0
- package/src/modules/root/index.js +1 -0
- package/src/modules/root/selectors.js +3 -0
- package/src/modules/submission/actions.js +94 -0
- package/src/modules/submission/constants.js +6 -0
- package/src/modules/submission/index.js +4 -0
- package/src/modules/submission/reducers.js +64 -0
- package/src/modules/submission/selectors.js +3 -0
- package/src/modules/submissions/actions.js +82 -0
- package/src/modules/submissions/constants.js +4 -0
- package/src/modules/submissions/index.js +4 -0
- package/src/modules/submissions/reducers.js +79 -0
- package/src/modules/submissions/selectors.js +3 -0
- package/src/types.js +89 -0
- package/src/utils.js +56 -0
- package/test/.eslintrc +10 -0
- package/test/changes.spec.js +515 -0
- package/test/enzyme.js +6 -0
- package/test/fixtures/columns.json +80 -0
- package/test/fixtures/formWithInput.js +11 -0
- package/test/fixtures/index.js +5 -0
- package/test/fixtures/layout.json +73 -0
- package/test/fixtures/textField.json +30 -0
- package/test/fixtures/visible.json +57 -0
- package/test/index.js +2 -0
- package/test/utils.js +87 -0
- package/test/validation.spec.js +130 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"input": true,
|
3
|
+
"tableView": true,
|
4
|
+
"inputType": "text",
|
5
|
+
"inputMask": "",
|
6
|
+
"label": "My Textfield",
|
7
|
+
"key": "myTextfield",
|
8
|
+
"placeholder": "",
|
9
|
+
"prefix": "",
|
10
|
+
"suffix": "",
|
11
|
+
"multiple": false,
|
12
|
+
"defaultValue": "",
|
13
|
+
"protected": false,
|
14
|
+
"unique": false,
|
15
|
+
"persistent": true,
|
16
|
+
"validate": {
|
17
|
+
"required": false,
|
18
|
+
"minLength": "",
|
19
|
+
"maxLength": "",
|
20
|
+
"pattern": "",
|
21
|
+
"custom": "",
|
22
|
+
"customPrivate": false
|
23
|
+
},
|
24
|
+
"conditional": {
|
25
|
+
"show": null,
|
26
|
+
"when": null,
|
27
|
+
"eq": ""
|
28
|
+
},
|
29
|
+
"type": "textfield"
|
30
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"input": true,
|
4
|
+
"inputType": "checkbox",
|
5
|
+
"tableView": true,
|
6
|
+
"hideLabel": true,
|
7
|
+
"label": "Visible",
|
8
|
+
"datagridLabel": true,
|
9
|
+
"key": "visible",
|
10
|
+
"defaultValue": false,
|
11
|
+
"protected": false,
|
12
|
+
"persistent": true,
|
13
|
+
"clearOnHide": true,
|
14
|
+
"validate": {
|
15
|
+
"required": false
|
16
|
+
},
|
17
|
+
"type": "checkbox",
|
18
|
+
"tags": [],
|
19
|
+
"conditional": {
|
20
|
+
"show": "",
|
21
|
+
"when": null,
|
22
|
+
"eq": ""
|
23
|
+
}
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"input": true,
|
27
|
+
"tableView": true,
|
28
|
+
"inputType": "text",
|
29
|
+
"inputMask": "",
|
30
|
+
"label": "Textfield",
|
31
|
+
"key": "textfield",
|
32
|
+
"placeholder": "",
|
33
|
+
"prefix": "",
|
34
|
+
"suffix": "",
|
35
|
+
"multiple": false,
|
36
|
+
"defaultValue": "",
|
37
|
+
"protected": false,
|
38
|
+
"unique": false,
|
39
|
+
"persistent": true,
|
40
|
+
"clearOnHide": true,
|
41
|
+
"validate": {
|
42
|
+
"required": true,
|
43
|
+
"minLength": "",
|
44
|
+
"maxLength": "",
|
45
|
+
"pattern": "",
|
46
|
+
"custom": "",
|
47
|
+
"customPrivate": false
|
48
|
+
},
|
49
|
+
"conditional": {
|
50
|
+
"show": "true",
|
51
|
+
"when": "visible",
|
52
|
+
"eq": "true"
|
53
|
+
},
|
54
|
+
"type": "textfield",
|
55
|
+
"tags": []
|
56
|
+
}
|
57
|
+
]
|
package/test/index.js
ADDED
package/test/utils.js
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
import ReactDOM from 'react-dom';
|
2
|
+
import {mount as enzymeMount} from './enzyme';
|
3
|
+
|
4
|
+
const WAIT = 1000;
|
5
|
+
|
6
|
+
export function autoreject(msg, fn) {
|
7
|
+
if (typeof msg === 'function') {
|
8
|
+
fn = msg;
|
9
|
+
msg = `Timeout of ${WAIT}ms exceeded.`;
|
10
|
+
}
|
11
|
+
|
12
|
+
return new Promise((resolve, reject) => {
|
13
|
+
setTimeout(
|
14
|
+
() => reject(new Error(msg)),
|
15
|
+
WAIT
|
16
|
+
);
|
17
|
+
fn(resolve);
|
18
|
+
});
|
19
|
+
}
|
20
|
+
|
21
|
+
// Generate an enhanced mount function.
|
22
|
+
export function createMount(options1 = {}) {
|
23
|
+
const {mount = enzymeMount, ...other1} = options1;
|
24
|
+
|
25
|
+
const attachTo = window.document.createElement('div');
|
26
|
+
attachTo.className = 'app';
|
27
|
+
attachTo.setAttribute('id', 'app');
|
28
|
+
window.document.body.insertBefore(attachTo, window.document.body.firstChild);
|
29
|
+
|
30
|
+
const mountWithContext = function mountWithContext(node, options2 = {}) {
|
31
|
+
return mount(node, {
|
32
|
+
attachTo,
|
33
|
+
...other1,
|
34
|
+
...options2,
|
35
|
+
});
|
36
|
+
};
|
37
|
+
|
38
|
+
mountWithContext.attachTo = attachTo;
|
39
|
+
let n = 1;
|
40
|
+
mountWithContext.cleanUp = () => {
|
41
|
+
if (n === 0) { debugger } else {
|
42
|
+
n -= 1;
|
43
|
+
}
|
44
|
+
ReactDOM.unmountComponentAtNode(attachTo);
|
45
|
+
attachTo.parentNode.removeChild(attachTo);
|
46
|
+
};
|
47
|
+
|
48
|
+
return mountWithContext;
|
49
|
+
}
|
50
|
+
|
51
|
+
export function createIfExceed() {
|
52
|
+
let sub = null;
|
53
|
+
const ifexceed = (msg, fn) => {
|
54
|
+
return autoreject(msg, resolve => {
|
55
|
+
sub = () => {
|
56
|
+
if (fn.length > 0) {
|
57
|
+
fn(resolve);
|
58
|
+
}
|
59
|
+
else {
|
60
|
+
fn();
|
61
|
+
resolve();
|
62
|
+
}
|
63
|
+
};
|
64
|
+
});
|
65
|
+
};
|
66
|
+
const notify = () => {
|
67
|
+
if (typeof sub === 'function') {
|
68
|
+
sub();
|
69
|
+
sub = null;
|
70
|
+
}
|
71
|
+
};
|
72
|
+
|
73
|
+
return {ifexceed, notify};
|
74
|
+
}
|
75
|
+
|
76
|
+
export function seq(fns) {
|
77
|
+
const [init, ...tail] = fns;
|
78
|
+
|
79
|
+
return tail.reduce((promise, fn) => promise.then(fn), init());
|
80
|
+
}
|
81
|
+
|
82
|
+
export default {
|
83
|
+
autoreject,
|
84
|
+
createMount,
|
85
|
+
createIfExceed,
|
86
|
+
seq,
|
87
|
+
};
|
@@ -0,0 +1,130 @@
|
|
1
|
+
import EventEmitter from 'eventemitter2';
|
2
|
+
import React from 'react';
|
3
|
+
import sinon from 'sinon';
|
4
|
+
import {expect} from 'chai';
|
5
|
+
import Form from '../src/components/Form';
|
6
|
+
import {
|
7
|
+
textField,
|
8
|
+
visible,
|
9
|
+
layout,
|
10
|
+
columns
|
11
|
+
} from './fixtures';
|
12
|
+
|
13
|
+
import {
|
14
|
+
createIfExceed,
|
15
|
+
createMount,
|
16
|
+
seq
|
17
|
+
} from './utils';
|
18
|
+
|
19
|
+
describe('Form component', function() {
|
20
|
+
let mount;
|
21
|
+
let options;
|
22
|
+
|
23
|
+
beforeEach(() => {
|
24
|
+
options = {
|
25
|
+
events: new EventEmitter({
|
26
|
+
wildcard: false,
|
27
|
+
maxListeners: 0
|
28
|
+
})
|
29
|
+
};
|
30
|
+
mount = createMount();
|
31
|
+
});
|
32
|
+
|
33
|
+
afterEach(() => {
|
34
|
+
options.events.removeAllListeners();
|
35
|
+
mount.cleanUp();
|
36
|
+
});
|
37
|
+
|
38
|
+
it('should create valid form.', function() {
|
39
|
+
const element = mount(
|
40
|
+
<Form
|
41
|
+
form={{display: 'form', components: [textField]}}
|
42
|
+
options={options}
|
43
|
+
/>);
|
44
|
+
return element
|
45
|
+
.instance()
|
46
|
+
.createPromise
|
47
|
+
.then(formio => {
|
48
|
+
expect(formio).to.be.an('object');
|
49
|
+
expect(formio.isValid()).to.be.true;
|
50
|
+
});
|
51
|
+
});
|
52
|
+
|
53
|
+
it('should validate on submit.', function() {
|
54
|
+
const field = Object.assign({}, textField);
|
55
|
+
field.validate = Object.assign({}, textField.validate, {required: true});
|
56
|
+
const element = mount(
|
57
|
+
<Form
|
58
|
+
form={{display: 'form', components: [field]}}
|
59
|
+
options={options}
|
60
|
+
/>);
|
61
|
+
return element
|
62
|
+
.instance()
|
63
|
+
.createPromise
|
64
|
+
.then(formio => {
|
65
|
+
expect(formio).to.be.an('object');
|
66
|
+
return formio.submit()
|
67
|
+
.catch(([err]) => {
|
68
|
+
return expect(err.message).to.equal('My Textfield is required');
|
69
|
+
});
|
70
|
+
});
|
71
|
+
});
|
72
|
+
|
73
|
+
it('should validate on change.', function() {
|
74
|
+
let input;
|
75
|
+
let element;
|
76
|
+
let root;
|
77
|
+
let formio;
|
78
|
+
const {ifexceed, notify} = createIfExceed();
|
79
|
+
const onchange = sinon.spy(notify);
|
80
|
+
const field = Object.assign({}, textField);
|
81
|
+
field.validate = Object.assign({}, textField.validate, {required: true});
|
82
|
+
return seq([
|
83
|
+
() => {
|
84
|
+
element = mount(
|
85
|
+
<Form
|
86
|
+
form={{display: 'form', components: [field]}}
|
87
|
+
options={options}
|
88
|
+
onChange={onchange}
|
89
|
+
/>);
|
90
|
+
return element
|
91
|
+
.instance()
|
92
|
+
.createPromise
|
93
|
+
.then(_formio => {
|
94
|
+
formio = _formio;
|
95
|
+
expect(formio).to.be.an('object');
|
96
|
+
expect(formio.isValid()).to.be.true;
|
97
|
+
});
|
98
|
+
},
|
99
|
+
() => ifexceed('fail on init change.', () => {
|
100
|
+
expect(onchange.callCount).to.equal(1);
|
101
|
+
}),
|
102
|
+
() => {
|
103
|
+
root = element.getDOMNode();
|
104
|
+
input = root.querySelector('input[type="text"]');
|
105
|
+
input.value = 'x';
|
106
|
+
input.dispatchEvent(new Event('input'));
|
107
|
+
return ifexceed('fail on input change.', () => {
|
108
|
+
expect(onchange.callCount).to.equal(2);
|
109
|
+
expect(formio.isValid()).to.be.true;
|
110
|
+
});
|
111
|
+
},
|
112
|
+
() => {
|
113
|
+
input.value = '';
|
114
|
+
input.dispatchEvent(new Event('input'));
|
115
|
+
return ifexceed('fail on input change.', () => {
|
116
|
+
expect(onchange.callCount).to.equal(3);
|
117
|
+
expect(formio.isValid()).to.be.false;
|
118
|
+
});
|
119
|
+
},
|
120
|
+
() => {
|
121
|
+
input.value = 'y';
|
122
|
+
input.dispatchEvent(new Event('input'));
|
123
|
+
return ifexceed('fail on input change.', () => {
|
124
|
+
expect(onchange.callCount).to.equal(4);
|
125
|
+
expect(formio.isValid()).to.be.true;
|
126
|
+
});
|
127
|
+
}
|
128
|
+
]);
|
129
|
+
});
|
130
|
+
});
|