cerebral-forms
Advanced tools
Comparing version 1.0.0-b-alpha.d1c1c8d6 to 1.0.0-b-alpha.d465c033
@@ -24,3 +24,3 @@ 'use strict'; | ||
exports.default = [(0, _operators.set)((0, _tags.state)(_templateObject, (0, _tags.input)(_templateObject2)), (0, _tags.input)(_templateObject3)), (0, _validateField2.default)((0, _tags.state)(_templateObject4, (0, _tags.input)(_templateObject2)))]; | ||
exports.default = [(0, _operators.set)((0, _tags.state)(_templateObject, (0, _tags.props)(_templateObject2)), (0, _tags.props)(_templateObject3)), (0, _validateField2.default)((0, _tags.state)(_templateObject4, (0, _tags.props)(_templateObject2)))]; | ||
//# sourceMappingURL=changeField.js.map |
@@ -17,3 +17,3 @@ 'use strict'; | ||
path = _ref.path, | ||
resolveArg = _ref.resolveArg; | ||
resolve = _ref.resolve; | ||
@@ -31,7 +31,7 @@ if (typeof formPath === 'string') { | ||
} else { | ||
if (!resolveArg.isTag(formPath, 'state')) { | ||
if (!resolve.isTag(formPath, 'state')) { | ||
throw new Error('Cerebral Forms - isValidForm factory requires a STATE TAG'); | ||
} | ||
var _form = resolveArg.value(formPath); | ||
var _form = resolve.value(formPath); | ||
@@ -38,0 +38,0 @@ if ((0, _isValidForm2.default)(_form)) { |
@@ -45,3 +45,3 @@ 'use strict'; | ||
var state = _ref.state, | ||
resolveArg = _ref.resolveArg; | ||
resolve = _ref.resolve; | ||
@@ -55,9 +55,9 @@ if (typeof formPath === 'string') { | ||
} else { | ||
if (!resolveArg.isTag(formPath, 'state')) { | ||
if (!resolve.isTag(formPath, 'state')) { | ||
throw new Error('Cerebral Forms - isValidForm factory requires a STATE TAG'); | ||
} | ||
var _form = resolveArg.value(formPath); | ||
var _form = resolve.value(formPath); | ||
state.merge(resolveArg.path(formPath), resetObject(_form)); | ||
state.merge(resolve.path(formPath), resetObject(_form)); | ||
} | ||
@@ -64,0 +64,0 @@ } |
@@ -17,3 +17,3 @@ 'use strict'; | ||
var state = _ref.state, | ||
resolveArg = _ref.resolveArg; | ||
resolve = _ref.resolve; | ||
@@ -26,7 +26,7 @@ var path = void 0; | ||
} else { | ||
if (!resolveArg.isTag(fieldPath, 'state')) { | ||
if (!resolve.isTag(fieldPath, 'state')) { | ||
throw new Error('Cerebral Forms - validateField factory requires a STATE TAG'); | ||
} | ||
path = resolveArg.path(fieldPath); | ||
path = resolve.path(fieldPath); | ||
} | ||
@@ -37,3 +37,3 @@ | ||
var field = state.get(path); | ||
var form = state.get(formPath); | ||
var form = state.get(formPath.join('.')); | ||
var validationResult = (0, _runValidation2.default)(field, form); | ||
@@ -40,0 +40,0 @@ |
@@ -17,4 +17,4 @@ 'use strict'; | ||
var state = _ref.state, | ||
input = _ref.input, | ||
resolveArg = _ref.resolveArg; | ||
props = _ref.props, | ||
resolve = _ref.resolve; | ||
@@ -44,7 +44,7 @@ function validate(path, form) { | ||
} else { | ||
if (!resolveArg.isTag(formPath, 'state')) { | ||
if (!resolve.isTag(formPath, 'state')) { | ||
throw new Error('Cerebral Forms - validateField factory requires a STATE TAG'); | ||
} | ||
validate(resolveArg.path(formPath).split('.'), resolveArg.value(formPath)); | ||
validate(resolve.path(formPath).split('.'), resolve.value(formPath)); | ||
} | ||
@@ -51,0 +51,0 @@ } |
@@ -19,12 +19,7 @@ 'use strict'; | ||
}); | ||
currentPath.pop(); | ||
return allFields; | ||
} else if (object[key] === Object(object[key]) && 'value' in object[key]) { | ||
allFields[currentPath.join('.')] = object[key]; | ||
currentPath.pop(); | ||
return allFields; | ||
} else if (object[key] === Object(object[key])) { | ||
getFormFields(object[key], currentPath, allFields); | ||
} | ||
getFormFields(object[key], currentPath, allFields); | ||
currentPath.pop(); | ||
@@ -31,0 +26,0 @@ |
{ | ||
"name": "cerebral-forms", | ||
"version": "1.0.0-b-alpha.d1c1c8d6", | ||
"version": "1.0.0-b-alpha.d465c033", | ||
"description": "Signals, actions and state factories to create forms", | ||
@@ -28,7 +28,7 @@ "main": "lib/index.js", | ||
"peerDependencies": { | ||
"cerebral": "^2.0.0-b-alpha.d1c1c8d6" | ||
"cerebral": "2.0.0-b-alpha.d465c033" | ||
}, | ||
"devDependencies": { | ||
"@cerebral/monorepo": "^0.0.1-alpha.d1c1c8d6", | ||
"cerebral": "^2.0.0-b-alpha.d1c1c8d6" | ||
"@cerebral/monorepo": "0.0.1-alpha.d465c033", | ||
"cerebral": "2.0.0-b-alpha.d465c033" | ||
}, | ||
@@ -35,0 +35,0 @@ "nyc": { |
@@ -50,6 +50,4 @@ # cerebral-forms | ||
// Some properties are created for you, set when validation runs | ||
// and you can use them in components. You can also set these | ||
// properties manually, though usually the validate action factory | ||
// is used to handle this | ||
// Some properties are created for you by the validate action factory | ||
// which can be used in the components. | ||
@@ -97,2 +95,22 @@ // Toggled when field is validated | ||
#### Custom global props | ||
You can add custom props to the root to the form state. | ||
For example if you want to show validation errors only | ||
when submitting the form you can add a `showErrors` prop | ||
which you set true when validation fails during form submit. | ||
```js | ||
import {form} from 'cerebral-forms' | ||
export default function MyAction({state}) { | ||
state.set('some.new.form', form({ | ||
name: { | ||
value: '', | ||
}, | ||
showErrors: false | ||
})) | ||
} | ||
``` | ||
#### Set a default value for the whole form | ||
@@ -108,3 +126,3 @@ You can set a default value for a property using a factory: | ||
// You can also set some special properties for the whole form | ||
newForm.showErrors = false | ||
myForm.showErrors = false | ||
@@ -121,22 +139,2 @@ fields.forEach((field) => { | ||
#### Custom global props | ||
You can add custom props to the root to the form state. | ||
For example if you want to show validation errors only | ||
when submitting the form you can add a `showErrors` prop | ||
which you set true when validation fails during form submit. | ||
```js | ||
import {form} from 'cerebral-forms' | ||
export default function MyAction({state}) { | ||
state.set('some.new.form', form({ | ||
name: { | ||
value: '', | ||
}, | ||
showErrors: false | ||
})) | ||
} | ||
``` | ||
### field | ||
@@ -209,3 +207,3 @@ To add a new field you simply merge a new form into the existing one. | ||
```js | ||
import {input} from 'cerebral/operators' | ||
import {props} from 'cerebral/tags' | ||
import {validateField} from 'cerebral-forms' | ||
@@ -218,3 +216,3 @@ | ||
// dynamic | ||
validateField(input`fieldPath`), | ||
validateField(props`fieldPath`), | ||
doThat | ||
@@ -228,3 +226,3 @@ ] | ||
```js | ||
import {input} from 'cerebral/operators' | ||
import {props} from 'cerebral/tags' | ||
import {validateForm} from 'cerebral-forms' | ||
@@ -236,3 +234,3 @@ | ||
// dynamic | ||
validateForm(input`formPath`), | ||
validateForm(props`formPath`), | ||
isFormValid, { | ||
@@ -253,3 +251,3 @@ true: [ | ||
```js | ||
import {input} from 'cerebral/operators' | ||
import {props} from 'cerebral/tags' | ||
import {resetForm} from 'cerebral-forms' | ||
@@ -262,3 +260,3 @@ | ||
// dynamic | ||
resetForm(input`formPath`), | ||
resetForm(props`formPath`), | ||
doThat | ||
@@ -354,3 +352,3 @@ ] | ||
```js | ||
import {input} from 'cerebral/operators' | ||
import {props} from 'cerebral/tags' | ||
import {isValidForm} from 'cerebral-forms' | ||
@@ -362,3 +360,3 @@ | ||
// dynamic | ||
isValidForm(input`formPath`), { | ||
isValidForm(props`formPath`), { | ||
true: [], | ||
@@ -365,0 +363,0 @@ false: [] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72256
16
37
576
393