New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@uform/core

Package Overview
Dependencies
Maintainers
2
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uform/core - npm Package Compare versions

Comparing version 0.1.0-alpha.8 to 0.1.0-alpha.9

86

lib/field.js

@@ -58,5 +58,7 @@ "use strict";

this.namePath = (0, _utils.resolveFieldPath)(this.name);
this.editable = this.getEditable(options.editable);
var editable = this.getEditableFromProps(options.props);
this.editable = !(0, _utils.isEmpty)(editable) ? editable : this.editable;
this.path = (0, _utils.resolveFieldPath)(!(0, _utils.isEmpty)(options.path) ? options.path : this.path || []);
this.rules = !(0, _utils.isEmpty)(options.rules) ? (0, _utils.clone)(options.rules) : this.rules;
var rules = this.getRulesFromProps(options.props);
this.rules = !(0, _utils.isEmpty)(rules) ? rules : this.rules;
this.required = (0, _utils.hasRequired)(this.rules);

@@ -70,5 +72,38 @@ this.props = (0, _utils.isEmpty)(options.props) ? (0, _utils.clone)(this.props, filterSchema) : (0, _utils.clone)((0, _extends2.default)({}, this.props, options.props), filterSchema);

_proto.getEditableFromProps = function getEditableFromProps(props) {
if (props) {
if (!(0, _utils.isEmpty)(props.editable)) {
return this.getEditable(props.editable);
} else {
if (props['x-props'] && !(0, _utils.isEmpty)(props['x-props'].editable)) {
return this.getEditable(props['x-props'].editable);
}
}
}
return this.editable;
};
_proto.getRulesFromProps = function getRulesFromProps(props) {
if (props) {
var rules = (0, _utils.toArr)(props['x-rules']);
if (props.required && !rules.some(function (rule) {
return rule.required;
})) {
rules.push({
required: true
});
}
return (0, _utils.clone)(rules);
}
return this.rules;
};
_proto.getEditable = function getEditable(editable) {
if ((0, _utils.isFn)(editable)) return editable(this.name);
return editable;
if ((0, _utils.isBool)(editable)) return editable;
return this.editable;
};

@@ -127,22 +162,2 @@

_proto.changeEditable = function changeEditable(editable) {
editable = this.getEditable(editable);
if (editable !== undefined && this.editable !== editable) {
this.editable = editable;
this.dirty = true;
this.notify();
}
};
_proto.changeRules = function changeRules(rules) {
var lastRules = this.rules;
if (!(0, _utils.isEqual)(lastRules, rules)) {
this.rules = (0, _utils.clone)(rules);
this.dirty = true;
this.notify();
}
};
_proto.changeProps = function changeProps(props, force) {

@@ -222,2 +237,10 @@ var lastProps = this.props;

this.dirty = true;
} else {
var propsEditable = this.getEditableFromProps(published.props);
if (!(0, _utils.isEmpty)(propsEditable) && !(0, _utils.isEqual)(propsEditable, this.editable)) {
this.editable = propsEditable;
this.dirtyType = 'editable';
this.dirty = true;
}
}

@@ -244,2 +267,13 @@

this.dirty = true;
} else {
var propsRules = this.getRulesFromProps(published.props);
if (!(0, _utils.isEmpty)(propsRules) && !(0, _utils.isEqual)(propsRules, this.rules)) {
this.rules = propsRules;
this.errors = [];
this.valid = true;
this.invalid = false;
this.dirtyType = 'rules';
this.dirty = true;
}
}

@@ -272,8 +306,2 @@

if (published.editable !== this.editable) {
this.editable = published.editable;
this.dirtyType = 'editable';
this.dirty = true;
}
if (!(0, _utils.isEqual)(published.visible, this.visible)) {

@@ -280,0 +308,0 @@ this.visible = published.visible;

{
"name": "@uform/core",
"version": "0.1.0-alpha.8",
"version": "0.1.0-alpha.9",
"license": "MIT",

@@ -18,4 +18,4 @@ "main": "lib",

"dependencies": {
"@uform/utils": "^0.1.0-alpha.8",
"@uform/validator": "^0.1.0-alpha.8",
"@uform/utils": "^0.1.0-alpha.9",
"@uform/validator": "^0.1.0-alpha.9",
"dot-match": "^0.1.18",

@@ -29,3 +29,3 @@ "immer": "^1.7.4",

},
"gitHead": "633332d592747d26044230b1c980217c89525e90"
"gitHead": "1d13621762466c9491c0d58cfec85a32dbafe424"
}

@@ -7,2 +7,3 @@ import {

isFn,
isBool,
toArr,

@@ -50,7 +51,9 @@ isStr,

this.namePath = resolveFieldPath(this.name)
this.editable = this.getEditable(options.editable)
const editable = this.getEditableFromProps(options.props)
this.editable = !isEmpty(editable) ? editable : this.editable
this.path = resolveFieldPath(
!isEmpty(options.path) ? options.path : this.path || []
)
this.rules = !isEmpty(options.rules) ? clone(options.rules) : this.rules
const rules = this.getRulesFromProps(options.props)
this.rules = !isEmpty(rules) ? rules : this.rules
this.required = hasRequired(this.rules)

@@ -67,5 +70,30 @@

getEditableFromProps(props) {
if (props) {
if (!isEmpty(props.editable)) {
return this.getEditable(props.editable)
} else {
if (props['x-props'] && !isEmpty(props['x-props'].editable)) {
return this.getEditable(props['x-props'].editable)
}
}
}
return this.editable
}
getRulesFromProps(props) {
if (props) {
const rules = toArr(props['x-rules'])
if (props.required && !rules.some(rule => rule.required)) {
rules.push({ required: true })
}
return clone(rules)
}
return this.rules
}
getEditable(editable) {
if (isFn(editable)) return editable(this.name)
return editable
if (isBool(editable)) return editable
return this.editable
}

@@ -122,20 +150,2 @@

changeEditable(editable) {
editable = this.getEditable(editable)
if (editable !== undefined && this.editable !== editable) {
this.editable = editable
this.dirty = true
this.notify()
}
}
changeRules(rules) {
let lastRules = this.rules
if (!isEqual(lastRules, rules)) {
this.rules = clone(rules)
this.dirty = true
this.notify()
}
}
changeProps(props, force) {

@@ -209,2 +219,9 @@ let lastProps = this.props

this.dirty = true
} else {
const propsEditable = this.getEditableFromProps(published.props)
if (!isEmpty(propsEditable) && !isEqual(propsEditable, this.editable)) {
this.editable = propsEditable
this.dirtyType = 'editable'
this.dirty = true
}
}

@@ -229,2 +246,12 @@

this.dirty = true
} else {
const propsRules = this.getRulesFromProps(published.props)
if (!isEmpty(propsRules) && !isEqual(propsRules, this.rules)) {
this.rules = propsRules
this.errors = []
this.valid = true
this.invalid = false
this.dirtyType = 'rules'
this.dirty = true
}
}

@@ -255,8 +282,2 @@

if (published.editable !== this.editable) {
this.editable = published.editable
this.dirtyType = 'editable'
this.dirty = true
}
if (!isEqual(published.visible, this.visible)) {

@@ -263,0 +284,0 @@ this.visible = published.visible

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc