Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-form-with-constraints-tools

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-form-with-constraints-tools - npm Package Compare versions

Comparing version 0.18.0 to 0.19.0-beta.1

dist/cjs/DisplayFields.js

428

dist/react-form-with-constraints-tools.development.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('prop-types'), require('react-form-with-constraints')) :
typeof define === 'function' && define.amd ? define(['exports', 'react', 'prop-types', 'react-form-with-constraints'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactFormWithConstraintsTools = {}, global.React, global.PropTypes, global.ReactFormWithConstraints));
}(this, (function (exports, React, PropTypes, reactFormWithConstraints) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('prop-types'), require('react-form-with-constraints')) :
typeof define === 'function' && define.amd ? define(['exports', 'react', 'prop-types', 'react-form-with-constraints'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactFormWithConstraintsTools = {}, global.React, global.PropTypes, global.ReactFormWithConstraints));
})(this, (function (exports, React, PropTypes, reactFormWithConstraints) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return Object.freeze(n);
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var React__namespace = /*#__PURE__*/_interopNamespace(React);
var PropTypes__namespace = /*#__PURE__*/_interopNamespace(PropTypes);
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
// Before:
// [
// {
// "element": "<input id=\"username\" name=\"username\" required=\"\" minlength=\"3\" class=\"form-control is-pending-sm is-invalid\" value=\"\">",
// "name": "username",
// "validations": [
// { "key": "0.0", "type": "error", "show": false },
// { "key": "0.1", "type": "error", "show": true },
// { "key": "0.2", "type": "whenValid" }
// ]
// }
// ]
//
// After:
// [
// {
// element: <input id="username" name="username" required="" minlength="3" class="form-control is-pending-sm is-invalid" value="">,
// name: "username",
// validations: [
// { key: "0.0", type: "error", show: false },
// { key: "0.1", type: "error", show: true },
// { key: "0.2", type: "whenValid", show: undefined }
// ]
// }
// ]
// eslint-disable-next-line @typescript-eslint/ban-types
function beautifulStringify(obj, space) {
// Keep undefined
// [Preserving undefined that JSON.stringify otherwise removes](https://stackoverflow.com/q/26540706)
let str = JSON.stringify(obj, (_key, value) => (value === undefined ? '__undefined__' : value), space);
str = str.replace(/"__undefined__"/g, 'undefined');
// Remove quotes from properties
// Before: "name":
// After: name:
// [JSON.stringify without quotes on properties?](https://stackoverflow.com/q/11233498)
str = str.replace(/"([^"]+)":/g, '$1:');
// Before: element: "<input id=\"username\" name=\"username\" required=\"\">",
// After: element: <input id=\"username\" name=\"username\" required=\"\">,
// eslint-disable-next-line unicorn/better-regex
str = str.replace(/: "(.*[\\"].*)",/g, ': $1,');
// Before: <input id=\"username\" name=\"username\" required=\"\">
// After: <input id="username" name="username" required="">
str = str.replace(/\\"/g, '"');
return str;
}
// Cannot display field.element directly, will throw "Converting circular structure to JSON" when calling JSON.stringify()
function normalizeFieldElementProperty(fields) {
return fields.map(field => {
const { element, ...otherProps } = field;
return element
? {
element: reactFormWithConstraints.isHTMLInput(element) ? element.outerHTML : element.props,
...otherProps
}
: field;
});
}
class DisplayFields extends React__namespace.Component {
constructor() {
super(...arguments);
this.reRender = () => {
this.forceUpdate();
};
/* eslint-enable react/destructuring-assignment */
}
/* eslint-disable react/destructuring-assignment */
componentDidMount() {
this.context.form.fieldsStore.addListener(reactFormWithConstraints.FieldEvent.Added, this.reRender);
this.context.form.fieldsStore.addListener(reactFormWithConstraints.FieldEvent.Removed, this.reRender);
this.context.form.addFieldDidValidateEventListener(this.reRender);
this.context.form.addFieldDidResetEventListener(this.reRender);
}
componentWillUnmount() {
this.context.form.fieldsStore.removeListener(reactFormWithConstraints.FieldEvent.Added, this.reRender);
this.context.form.fieldsStore.removeListener(reactFormWithConstraints.FieldEvent.Removed, this.reRender);
this.context.form.removeFieldDidValidateEventListener(this.reRender);
this.context.form.removeFieldDidResetEventListener(this.reRender);
}
render() {
let str = beautifulStringify(normalizeFieldElementProperty(this.context.form.fieldsStore.fields), 2);
// Cosmetic: improve formatting
//
// Replace this string:
// {
// key: "1.0",
// type: "error",
// show: true
// }
// with this:
// { key: "1.0", type: "error", show: true }
str = str.replace(/{\s+key: (.*),\s+type: (.*),\s+show: (.*)\s+}/g, '{ key: $1, type: $2, show: $3 }');
return str;
}
}
DisplayFields.contextTypes = {
form: PropTypes__namespace.instanceOf(reactFormWithConstraints.FormWithConstraints).isRequired
};
class FieldFeedbacks extends reactFormWithConstraints.FieldFeedbacks {
render() {
const { for: fieldName, stop } = this.props;
let attr = '';
if (fieldName)
attr += `for="${fieldName}" `;
attr += `stop="${stop}"`;
return (React__namespace.createElement(React__namespace.Fragment, null,
React__namespace.createElement("li", null,
"key=\"",
this.key,
"\" ",
attr),
React__namespace.createElement("ul", null, super.render())));
}
}
class FieldFeedback extends reactFormWithConstraints.FieldFeedback {
constructor() {
super(...arguments);
this.rootEl = null;
}
getTextDecoration() {
const { show } = this.state.validation;
let textDecoration = '';
switch (show) {
case false:
textDecoration = 'line-through';
break;
case undefined:
textDecoration = 'line-through dotted';
break;
default:
textDecoration = '';
}
return textDecoration;
}
render() {
const { key, type } = this.state.validation;
return (React__namespace.createElement("li", { ref: rootEl => (this.rootEl = rootEl) },
React__namespace.createElement("span", { style: { textDecoration: this.getTextDecoration() } },
"key=\"",
key,
"\" type=\"",
type,
"\""),
' ',
super.render()));
}
componentDidUpdate() {
// Hack: make FieldFeedback <span style="display: inline">
// Also make Bootstrap 4 happy because it sets 'display: none', https://github.com/twbs/bootstrap/blob/v4.1.2/scss/mixins/_forms.scss#L31
const fieldFeedbackSpans = this.rootEl.querySelectorAll('[data-feedback]');
fieldFeedbackSpans.forEach(fieldFeedbackSpan => {
// eslint-disable-next-line no-param-reassign
fieldFeedbackSpan.style.display = 'inline';
});
// Change Async parent style
const li = this.rootEl.closest('li.async');
if (li !== null) {
const async = li.querySelector('span[style]');
async.style.textDecoration = this.getTextDecoration();
}
// Change whenValid style
const { type } = this.state.validation;
if (type === reactFormWithConstraints.FieldFeedbackType.WhenValid) {
const span = this.rootEl.querySelector('span[style]');
const whenValid = this.rootEl.querySelector(`span.${this.props.classes.valid}`);
span.style.textDecoration = whenValid !== null ? '' : 'line-through';
}
}
}
class Async extends reactFormWithConstraints.Async {
constructor() {
super(...arguments);
this.rootEl = null;
}
static getTextDecoration() {
return 'line-through dotted';
}
componentDidUpdate() {
// Reset style
const async = this.rootEl.querySelector('span[style]');
async.style.textDecoration = Async.getTextDecoration();
}
render() {
return (React__namespace.createElement("li", { className: "async", ref: rootEl => (this.rootEl = rootEl) },
React__namespace.createElement("span", { style: { textDecoration: Async.getTextDecoration() } }, "Async"),
React__namespace.createElement("ul", null, super.render())));
}
}
function beautifulStringify(obj, space) {
var str = JSON.stringify(obj, function (_key, value) { return (value === undefined ? '__undefined__' : value); }, space);
str = str.replace(/"__undefined__"/g, 'undefined');
str = str.replace(/"([^"]+)":/g, '$1:');
str = str.replace(/: "(.*[\\"].*)",/g, ': $1,');
str = str.replace(/\\"/g, '"');
return str;
}
function normalizeFieldElementProperty(fields) {
return fields.map(function (field) {
var element = field.element, otherProps = __rest(field, ["element"]);
return element
? __assign({ element: reactFormWithConstraints.isHTMLInput(element) ? element.outerHTML : element.props }, otherProps) : field;
});
}
var DisplayFields = (function (_super) {
__extends(DisplayFields, _super);
function DisplayFields() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.reRender = function () {
_this.forceUpdate();
};
return _this;
}
DisplayFields.prototype.componentDidMount = function () {
this.context.form.fieldsStore.addListener(reactFormWithConstraints.FieldEvent.Added, this.reRender);
this.context.form.fieldsStore.addListener(reactFormWithConstraints.FieldEvent.Removed, this.reRender);
this.context.form.addFieldDidValidateEventListener(this.reRender);
this.context.form.addFieldDidResetEventListener(this.reRender);
};
DisplayFields.prototype.componentWillUnmount = function () {
this.context.form.fieldsStore.removeListener(reactFormWithConstraints.FieldEvent.Added, this.reRender);
this.context.form.fieldsStore.removeListener(reactFormWithConstraints.FieldEvent.Removed, this.reRender);
this.context.form.removeFieldDidValidateEventListener(this.reRender);
this.context.form.removeFieldDidResetEventListener(this.reRender);
};
DisplayFields.prototype.render = function () {
var str = beautifulStringify(normalizeFieldElementProperty(this.context.form.fieldsStore.fields), 2);
str = str.replace(/{\s+key: (.*),\s+type: (.*),\s+show: (.*)\s+}/g, '{ key: $1, type: $2, show: $3 }');
return str;
};
DisplayFields.contextTypes = {
form: PropTypes.instanceOf(reactFormWithConstraints.FormWithConstraints).isRequired
};
return DisplayFields;
}(React.Component));
var FieldFeedbacks = (function (_super) {
__extends(FieldFeedbacks, _super);
function FieldFeedbacks() {
return _super !== null && _super.apply(this, arguments) || this;
}
FieldFeedbacks.prototype.render = function () {
var _a = this.props, fieldName = _a.for, stop = _a.stop;
var attr = '';
if (fieldName)
attr += "for=\"" + fieldName + "\" ";
attr += "stop=\"" + stop + "\"";
return (React.createElement(React.Fragment, null,
React.createElement("li", null,
"key=\"",
this.key,
"\" ",
attr),
React.createElement("ul", null, _super.prototype.render.call(this))));
};
return FieldFeedbacks;
}(reactFormWithConstraints.FieldFeedbacks));
var FieldFeedback = (function (_super) {
__extends(FieldFeedback, _super);
function FieldFeedback() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.rootEl = null;
return _this;
}
FieldFeedback.prototype.getTextDecoration = function () {
var show = this.state.validation.show;
var textDecoration = '';
switch (show) {
case false:
textDecoration = 'line-through';
break;
case undefined:
textDecoration = 'line-through dotted';
break;
default:
textDecoration = '';
}
return textDecoration;
};
FieldFeedback.prototype.render = function () {
var _this = this;
var _a = this.state.validation, key = _a.key, type = _a.type;
return (React.createElement("li", { ref: function (rootEl) { return (_this.rootEl = rootEl); } },
React.createElement("span", { style: { textDecoration: this.getTextDecoration() } },
"key=\"",
key,
"\" type=\"",
type,
"\""),
' ',
_super.prototype.render.call(this)));
};
FieldFeedback.prototype.componentDidUpdate = function () {
var fieldFeedbackSpans = this.rootEl.querySelectorAll('[data-feedback]');
fieldFeedbackSpans.forEach(function (fieldFeedbackSpan) {
fieldFeedbackSpan.style.display = 'inline';
});
var li = this.rootEl.closest('li.async');
if (li !== null) {
var async = li.querySelector('span[style]');
async.style.textDecoration = this.getTextDecoration();
}
var type = this.state.validation.type;
if (type === reactFormWithConstraints.FieldFeedbackType.WhenValid) {
var span = this.rootEl.querySelector('span[style]');
var whenValid = this.rootEl.querySelector("span." + this.props.classes.valid);
span.style.textDecoration = whenValid !== null ? '' : 'line-through';
}
};
return FieldFeedback;
}(reactFormWithConstraints.FieldFeedback));
var Async = (function (_super) {
__extends(Async, _super);
function Async() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.rootEl = null;
return _this;
}
Async.getTextDecoration = function () {
return 'line-through dotted';
};
Async.prototype.componentDidUpdate = function () {
var async = this.rootEl.querySelector('span[style]');
async.style.textDecoration = Async.getTextDecoration();
};
Async.prototype.render = function () {
var _this = this;
return (React.createElement("li", { className: "async", ref: function (rootEl) { return (_this.rootEl = rootEl); } },
React.createElement("span", { style: { textDecoration: Async.getTextDecoration() } }, "Async"),
React.createElement("ul", null, _super.prototype.render.call(this))));
};
return Async;
}(reactFormWithConstraints.Async));
Object.defineProperty(exports, 'FormWithConstraints', {
enumerable: true,
get: function () { return reactFormWithConstraints.FormWithConstraints; }
});
exports.Async = Async;
exports.DisplayFields = DisplayFields;
exports.FieldFeedback = FieldFeedback;
exports.FieldFeedbacks = FieldFeedbacks;
Object.defineProperty(exports, 'FormWithConstraints', {
enumerable: true,
get: function () {
return reactFormWithConstraints.FormWithConstraints;
}
});
exports.Async = Async;
exports.DisplayFields = DisplayFields;
exports.FieldFeedback = FieldFeedback;
exports.FieldFeedbacks = FieldFeedbacks;
Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=react-form-with-constraints-tools.development.js.map
}));

@@ -1,2 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("react-form-with-constraints")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","react-form-with-constraints"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactFormWithConstraintsTools={},e.React,e.PropTypes,e.ReactFormWithConstraints)}(this,function(e,n,t,o){"use strict";var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function r(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var s=function(){return(s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function l(e){return e.map(function(e){var t=e.element,r=function(e,t){var r={};for(o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]]);return r}(e,["element"]);return t?s({element:o.isHTMLInput(t)?t.outerHTML:t.props},r):e})}var a,c=(r(p,a=n.Component),p.prototype.componentDidMount=function(){this.context.form.fieldsStore.addListener(o.FieldEvent.Added,this.reRender),this.context.form.fieldsStore.addListener(o.FieldEvent.Removed,this.reRender),this.context.form.addFieldDidValidateEventListener(this.reRender),this.context.form.addFieldDidResetEventListener(this.reRender)},p.prototype.componentWillUnmount=function(){this.context.form.fieldsStore.removeListener(o.FieldEvent.Added,this.reRender),this.context.form.fieldsStore.removeListener(o.FieldEvent.Removed,this.reRender),this.context.form.removeFieldDidValidateEventListener(this.reRender),this.context.form.removeFieldDidResetEventListener(this.reRender)},p.prototype.render=function(){var e,t;return(e=l(this.context.form.fieldsStore.fields),t=2,t=(t=(t=(t=(t=JSON.stringify(e,function(e,t){return void 0===t?"__undefined__":t},t)).replace(/"__undefined__"/g,"undefined")).replace(/"([^"]+)":/g,"$1:")).replace(/: "(.*[\\"].*)",/g,": $1,")).replace(/\\"/g,'"')).replace(/{\s+key: (.*),\s+type: (.*),\s+show: (.*)\s+}/g,"{ key: $1, type: $2, show: $3 }")},p.contextTypes={form:t.instanceOf(o.FormWithConstraints).isRequired},p);function p(){var e=null!==a&&a.apply(this,arguments)||this;return e.reRender=function(){e.forceUpdate()},e}var d,u=(r(f,d=o.FieldFeedbacks),f.prototype.render=function(){var e=this.props,t=e.for,r="";return t&&(r+='for="'+t+'" '),r+='stop="'+e.stop+'"',n.createElement(n.Fragment,null,n.createElement("li",null,'key="',this.key,'" ',r),n.createElement("ul",null,d.prototype.render.call(this)))},f);function f(){return null!==d&&d.apply(this,arguments)||this}var y,h=(r(m,y=o.FieldFeedback),m.prototype.getTextDecoration=function(){var e="";switch(this.state.validation.show){case!1:e="line-through";break;case void 0:e="line-through dotted";break;default:e=""}return e},m.prototype.render=function(){var t=this,e=this.state.validation,r=e.key,e=e.type;return n.createElement("li",{ref:function(e){return t.rootEl=e}},n.createElement("span",{style:{textDecoration:this.getTextDecoration()}},'key="',r,'" type="',e,'"')," ",y.prototype.render.call(this))},m.prototype.componentDidUpdate=function(){this.rootEl.querySelectorAll("[data-feedback]").forEach(function(e){e.style.display="inline"});var e,t=this.rootEl.closest("li.async");null!==t&&(t.querySelector("span[style]").style.textDecoration=this.getTextDecoration()),this.state.validation.type===o.FieldFeedbackType.WhenValid&&(e=this.rootEl.querySelector("span[style]"),t=this.rootEl.querySelector("span."+this.props.classes.valid),e.style.textDecoration=null!==t?"":"line-through")},m);function m(){var e=null!==y&&y.apply(this,arguments)||this;return e.rootEl=null,e}var v,t=(r(E,v=o.Async),E.getTextDecoration=function(){return"line-through dotted"},E.prototype.componentDidUpdate=function(){this.rootEl.querySelector("span[style]").style.textDecoration=E.getTextDecoration()},E.prototype.render=function(){var t=this;return n.createElement("li",{className:"async",ref:function(e){return t.rootEl=e}},n.createElement("span",{style:{textDecoration:E.getTextDecoration()}},"Async"),n.createElement("ul",null,v.prototype.render.call(this)))},E);function E(){var e=null!==v&&v.apply(this,arguments)||this;return e.rootEl=null,e}Object.defineProperty(e,"FormWithConstraints",{enumerable:!0,get:function(){return o.FormWithConstraints}}),e.Async=t,e.DisplayFields=c,e.FieldFeedback=h,e.FieldFeedbacks=u,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=react-form-with-constraints-tools.production.min.js.map
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("react-form-with-constraints")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","react-form-with-constraints"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactFormWithConstraintsTools={},e.React,e.PropTypes,e.ReactFormWithConstraints)}(this,(function(e,t,r,n){"use strict";function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var s=o(t),i=o(r);class l extends s.Component{constructor(){super(...arguments),this.reRender=()=>{this.forceUpdate()}}componentDidMount(){this.context.form.fieldsStore.addListener(n.FieldEvent.Added,this.reRender),this.context.form.fieldsStore.addListener(n.FieldEvent.Removed,this.reRender),this.context.form.addFieldDidValidateEventListener(this.reRender),this.context.form.addFieldDidResetEventListener(this.reRender)}componentWillUnmount(){this.context.form.fieldsStore.removeListener(n.FieldEvent.Added,this.reRender),this.context.form.fieldsStore.removeListener(n.FieldEvent.Removed,this.reRender),this.context.form.removeFieldDidValidateEventListener(this.reRender),this.context.form.removeFieldDidResetEventListener(this.reRender)}render(){let e=function(e,t){let r=JSON.stringify(e,((e,t)=>void 0===t?"__undefined__":t),t);return r=r.replace(/"__undefined__"/g,"undefined"),r=r.replace(/"([^"]+)":/g,"$1:"),r=r.replace(/: "(.*[\\"].*)",/g,": $1,"),r=r.replace(/\\"/g,'"'),r}(this.context.form.fieldsStore.fields.map((e=>{const{element:t,...r}=e;return t?{element:n.isHTMLInput(t)?t.outerHTML:t.props,...r}:e})),2);return e=e.replace(/{\s+key: (.*),\s+type: (.*),\s+show: (.*)\s+}/g,"{ key: $1, type: $2, show: $3 }"),e}}l.contextTypes={form:i.instanceOf(n.FormWithConstraints).isRequired};class d extends n.FieldFeedbacks{render(){const{for:e,stop:t}=this.props;let r="";return e&&(r+=`for="${e}" `),r+=`stop="${t}"`,s.createElement(s.Fragment,null,s.createElement("li",null,'key="',this.key,'" ',r),s.createElement("ul",null,super.render()))}}class c extends n.FieldFeedback{constructor(){super(...arguments),this.rootEl=null}getTextDecoration(){const{show:e}=this.state.validation;let t="";switch(e){case!1:t="line-through";break;case void 0:t="line-through dotted";break;default:t=""}return t}render(){const{key:e,type:t}=this.state.validation;return s.createElement("li",{ref:e=>this.rootEl=e},s.createElement("span",{style:{textDecoration:this.getTextDecoration()}},'key="',e,'" type="',t,'"')," ",super.render())}componentDidUpdate(){this.rootEl.querySelectorAll("[data-feedback]").forEach((e=>{e.style.display="inline"}));const e=this.rootEl.closest("li.async");if(null!==e){e.querySelector("span[style]").style.textDecoration=this.getTextDecoration()}const{type:t}=this.state.validation;if(t===n.FieldFeedbackType.WhenValid){const e=this.rootEl.querySelector("span[style]"),t=this.rootEl.querySelector(`span.${this.props.classes.valid}`);e.style.textDecoration=null!==t?"":"line-through"}}}class a extends n.Async{constructor(){super(...arguments),this.rootEl=null}static getTextDecoration(){return"line-through dotted"}componentDidUpdate(){this.rootEl.querySelector("span[style]").style.textDecoration=a.getTextDecoration()}render(){return s.createElement("li",{className:"async",ref:e=>this.rootEl=e},s.createElement("span",{style:{textDecoration:a.getTextDecoration()}},"Async"),s.createElement("ul",null,super.render()))}}Object.defineProperty(e,"FormWithConstraints",{enumerable:!0,get:function(){return n.FormWithConstraints}}),e.Async=a,e.DisplayFields=l,e.FieldFeedback=c,e.FieldFeedbacks=d,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "react-form-with-constraints-tools",
"version": "0.18.0",
"repository": {
"type": "git",
"url": "https://github.com/tkrotoff/react-form-with-constraints.git"
},
"version": "0.19.0-beta.1",
"description": "Simple form validation for React",
"repository": "github:tkrotoff/react-form-with-constraints",
"license": "MIT",

@@ -17,22 +14,21 @@ "keywords": [

],
"main": "lib-es5/index.js",
"module": "lib/index.js",
"types": "lib/index.d.ts",
"main": "dist/cjs/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist/",
"lib/",
"lib-es5/"
"dist/"
],
"sideEffects": false,
"scripts": {
"clean": "rm -rf lib lib-es5 dist coverage .rpt2_cache LICENSE",
"clean": "rm -rf dist coverage LICENSE",
"tsc": "tsc",
"build": "yarn build:esnext && yarn build:es5",
"build:esnext": "tsc --project tsconfig.lib.json",
"build:es5": "tsc --project tsconfig.lib-es5.json",
"dist": "yarn dist:dev && yarn dist:prod",
"dist:dev": "NODE_ENV=development rollup --config",
"dist:prod": "NODE_ENV=production rollup --config",
"prepublishOnly": "yarn clean && yarn build && yarn dist",
"prepack": "cp ../../LICENSE . && jscodeshift --transform=../../removeConsoleTransform.ts lib lib-es5",
"build": "yarn build:dts && yarn build:esm && yarn build:cjs",
"build:dts": "tsc --project tsconfig.dist.json --declaration --emitDeclarationOnly --outDir dist",
"build:esm": "tsc --project tsconfig.dist.json --removeComments --outDir dist",
"build:cjs": "tsc --project tsconfig.dist.json --removeComments --module commonjs --outDir dist/cjs",
"build:umd": "yarn build:umd:dev && yarn build:umd:prod",
"build:umd:dev": "NODE_ENV=development rollup --config",
"build:umd:prod": "NODE_ENV=production rollup --config",
"prepublishOnly": "yarn clean && yarn build && yarn build:umd",
"prepack": "cp ../../LICENSE . && jscodeshift --transform=../../removeConsoleTransform.ts dist",
"postpack": "rm LICENSE",

@@ -46,22 +42,20 @@ "test": "jest --verbose",

"devDependencies": {
"@types/enzyme": "^3.10.7",
"@types/enzyme": "^3.10.12",
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/jest": "^26.0.14",
"@types/jscodeshift": "^0.7.1",
"@types/react": "^16.9.53",
"@types/react-dom": "^16.9.8",
"@types/jest": "^28.1.4",
"@types/jscodeshift": "^0.11.5",
"@types/react-dom": "^18.0.6",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"jest": "^26.6.0",
"jscodeshift": "^0.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"jest": "^26.6.3",
"jscodeshift": "^0.13.1",
"react": "^16.14.0",
"react-form-with-constraints": "^0.18.0",
"rollup": "^2.32.0",
"rollup-plugin-filesize": "^9.0.2",
"rollup-plugin-typescript2": "^0.28.0",
"rollup-plugin-uglify": "^6.0.4",
"ts-jest": "^26.4.1",
"typescript": "^4.0.3"
"react-form-with-constraints": "^0.19.0-beta.1",
"rollup": "^2.76.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.32.1",
"ts-jest": "^26.5.6",
"typescript": "^4.7.4"
},
"gitHead": "c4648fcf26c27f462eb730ea79eff2dfdd6d82ec"
"gitHead": "0071b45b6cb9c0381bb6066d69f4057d4f1f1632"
}
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