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

uniforms-bootstrap4

Package Overview
Dependencies
Maintainers
1
Versions
191
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uniforms-bootstrap4 - npm Package Compare versions

Comparing version 3.6.0 to 3.6.1

cjs/AutoField.d.ts

2

esm/AutoField.js

@@ -11,3 +11,3 @@ import invariant from 'invariant';

import TextField from './TextField';
var AutoField = createAutoField(function (props) {
const AutoField = createAutoField(props => {
if (props.allowedValues) {

@@ -14,0 +14,0 @@ return props.checkboxes && props.fieldType !== Array

@@ -6,9 +6,7 @@ import { __rest } from "tslib";

export default function AutoFields(_a) {
var _b = _a.autoField, autoField = _b === void 0 ? AutoField : _b, _c = _a.element, element = _c === void 0 ? 'div' : _c, fields = _a.fields, _d = _a.omitFields, omitFields = _d === void 0 ? [] : _d, showInlineError = _a.showInlineError, props = __rest(_a, ["autoField", "element", "fields", "omitFields", "showInlineError"]);
var schema = useForm().schema;
var { autoField = AutoField, element = 'div', fields, omitFields = [], showInlineError } = _a, props = __rest(_a, ["autoField", "element", "fields", "omitFields", "showInlineError"]);
const { schema } = useForm();
return createElement(element, props, (fields !== null && fields !== void 0 ? fields : schema.getSubfields())
.filter(function (field) { return !omitFields.includes(field); })
.map(function (field) {
return createElement(autoField, Object.assign({ key: field, name: field }, showInlineError === undefined ? null : { showInlineError: showInlineError }));
}));
.filter(field => !omitFields.includes(field))
.map(field => createElement(autoField, Object.assign({ key: field, name: field }, showInlineError === undefined ? null : { showInlineError }))));
}

@@ -1,15 +0,9 @@

import { __extends } from "tslib";
import { AutoForm } from 'uniforms';
import ValidatedQuickForm from './ValidatedQuickForm';
function Auto(parent) {
var _ = /** @class */ (function (_super) {
__extends(_, _super);
function _() {
return _super !== null && _super.apply(this, arguments) || this;
}
_.Auto = Auto;
return _;
}(AutoForm.Auto(parent)));
class _ extends AutoForm.Auto(parent) {
}
_.Auto = Auto;
return _;
}
export default Auto(ValidatedQuickForm);

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

import { __assign, __extends } from "tslib";
import classnames from 'classnames';

@@ -6,21 +5,16 @@ import omit from 'lodash/omit';

function Bootstrap4(parent) {
var _ = /** @class */ (function (_super) {
__extends(_, _super);
function _() {
return _super !== null && _super.apply(this, arguments) || this;
class _ extends parent {
getContextState() {
return Object.assign(Object.assign({}, super.getContextState()), { grid: this.props.grid });
}
_.prototype.getContextState = function () {
return __assign(__assign({}, _super.prototype.getContextState.call(this)), { grid: this.props.grid });
};
_.prototype.getNativeFormProps = function () {
var error = this.getContextError();
var props = _super.prototype.getNativeFormProps.call(this);
return __assign(__assign({}, omit(props, ['grid'])), { className: classnames('form', { error: error }, props.className) });
};
_.Bootstrap4 = Bootstrap4;
_.displayName = "Bootstrap4" + parent.displayName;
return _;
}(parent));
getNativeFormProps() {
const error = this.getContextError();
const props = super.getNativeFormProps();
return Object.assign(Object.assign({}, omit(props, ['grid'])), { className: classnames('form', { error }, props.className) });
}
}
_.Bootstrap4 = Bootstrap4;
_.displayName = `Bootstrap4${parent.displayName}`;
return _;
}
export default Bootstrap4(BaseForm);

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

import { __assign, __rest } from "tslib";
import { __rest } from "tslib";
import classnames from 'classnames';

@@ -7,5 +7,5 @@ import React from 'react';

function Bool(_a) {
var onChange = _a.onChange, props = __rest(_a, ["onChange"]);
var disabled = props.disabled, error = props.error, inline = props.inline, inputClassName = props.inputClassName, inputRef = props.inputRef, label = props.label, labelBefore = props.labelBefore, name = props.name, readOnly = props.readOnly, value = props.value;
return wrapField(__assign(__assign({}, props), { label: labelBefore, value: props.value }), React.createElement("div", { className: classnames(inputClassName, 'form-check', 'checkbox', {
var { onChange } = _a, props = __rest(_a, ["onChange"]);
const { disabled, error, inline, inputClassName, inputRef, label, labelBefore, name, readOnly, value, } = props;
return wrapField(Object.assign(Object.assign({}, props), { label: labelBefore, value: props.value }), React.createElement("div", { className: classnames(inputClassName, 'form-check', 'checkbox', {
'custom-control-inline': inline,

@@ -16,3 +16,3 @@ 'text-danger': error,

React.createElement("label", { htmlFor: props.id, className: "form-check-label" },
React.createElement("input", { checked: value || false, className: "form-check-input", disabled: disabled, id: props.id, name: name, onChange: function () {
React.createElement("input", { checked: value || false, className: "form-check-input", disabled: disabled, id: props.id, name: name, onChange: () => {
if (!readOnly) {

@@ -19,0 +19,0 @@ onChange(!value);

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

import { __assign, __rest } from "tslib";
import { __rest } from "tslib";
import classnames from 'classnames';

@@ -7,12 +7,12 @@ import React from 'react';

/* istanbul ignore next */
var DateConstructor = (typeof global === 'object' ? global : window).Date;
var dateFormat = function (value) { return value === null || value === void 0 ? void 0 : value.toISOString().slice(0, -8); };
const DateConstructor = (typeof global === 'object' ? global : window).Date;
const dateFormat = (value) => value === null || value === void 0 ? void 0 : value.toISOString().slice(0, -8);
function Date(_a) {
var _b;
var disabled = _a.disabled, error = _a.error, id = _a.id, inputClassName = _a.inputClassName, inputRef = _a.inputRef, max = _a.max, min = _a.min, name = _a.name, onChange = _a.onChange, placeholder = _a.placeholder, readOnly = _a.readOnly, value = _a.value, props = __rest(_a, ["disabled", "error", "id", "inputClassName", "inputRef", "max", "min", "name", "onChange", "placeholder", "readOnly", "value"]);
return wrapField(__assign(__assign({}, props), { id: id }), React.createElement("input", { className: classnames(inputClassName, 'form-control', {
var { disabled, error, id, inputClassName, inputRef, max, min, name, onChange, placeholder, readOnly, value } = _a, props = __rest(_a, ["disabled", "error", "id", "inputClassName", "inputRef", "max", "min", "name", "onChange", "placeholder", "readOnly", "value"]);
return wrapField(Object.assign(Object.assign({}, props), { id }), React.createElement("input", { className: classnames(inputClassName, 'form-control', {
'is-invalid': error,
'is-valid': !error && props.changed,
}), disabled: disabled, id: id, max: dateFormat(max), min: dateFormat(min), name: name, onChange: function (event) {
var date = new DateConstructor(event.target.valueAsNumber);
}), disabled: disabled, id: id, max: dateFormat(max), min: dateFormat(min), name: name, onChange: event => {
const date = new DateConstructor(event.target.valueAsNumber);
if (date.getFullYear() < 10000) {

@@ -19,0 +19,0 @@ onChange(date);

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

import { __assign, __rest } from "tslib";
import { __rest } from "tslib";
import classnames from 'classnames';

@@ -6,4 +6,4 @@ import React from 'react';

function Error(_a) {
var children = _a.children, className = _a.className, error = _a.error, errorMessage = _a.errorMessage, props = __rest(_a, ["children", "className", "error", "errorMessage"]);
return !error ? null : (React.createElement("div", __assign({ className: classnames('card', 'mb-3', className) }, filterDOMProps(props)),
var { children, className, error, errorMessage } = _a, props = __rest(_a, ["children", "className", "error", "errorMessage"]);
return !error ? null : (React.createElement("div", Object.assign({ className: classnames('card', 'mb-3', className) }, filterDOMProps(props)),
React.createElement("div", { className: "card-body" }, children ? children : React.createElement("h4", { className: "card-title" }, errorMessage))));

@@ -10,0 +10,0 @@ }

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

import { __assign, __rest } from "tslib";
import { __rest } from "tslib";
import classnames from 'classnames';

@@ -6,9 +6,9 @@ import React from 'react';

function ErrorsField(_a) {
var children = _a.children, className = _a.className, props = __rest(_a, ["children", "className"]);
var _b = useForm(), error = _b.error, schema = _b.schema;
return !error && !children ? null : (React.createElement("div", __assign({ className: classnames('card border-danger mb-3 text-danger', className) }, filterDOMProps(props)),
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
const { error, schema } = useForm();
return !error && !children ? null : (React.createElement("div", Object.assign({ className: classnames('card border-danger mb-3 text-danger', className) }, filterDOMProps(props)),
React.createElement("div", { className: "card-body" },
children,
schema.getErrorMessages(error).map(function (message, index) { return (React.createElement("div", { key: index, className: "disabled" }, message)); }))));
schema.getErrorMessages(error).map((message, index) => (React.createElement("div", { key: index, className: "disabled" }, message))))));
}
export default ErrorsField;

@@ -1,9 +0,8 @@

import { __assign } from "tslib";
function gridClassNamePart(size, value, side) {
var sizeInfix = size === 'xs' ? '' : size + "-";
const sizeInfix = size === 'xs' ? '' : `${size}-`;
return side === 'label'
? "col-" + sizeInfix + value
: "col-" + sizeInfix + (12 - value);
? `col-${sizeInfix}${value}`
: `col-${sizeInfix}${12 - value}`;
}
var gridOrder = { xs: 1, sm: 2, md: 3, lg: 4, xl: 5 };
const gridOrder = { xs: 1, sm: 2, md: 3, lg: 4, xl: 5 };
function compareSizeClass(a, b) {

@@ -28,3 +27,3 @@ return gridOrder[a] - gridOrder[b];

if (!grid.xs) {
grid = __assign({ xs: grid.sm || grid.md || grid.lg || grid.xl }, grid);
grid = Object.assign({ xs: grid.sm || grid.md || grid.lg || grid.xl }, grid);
}

@@ -34,3 +33,3 @@ return (Object.keys(grid)

// @ts-expect-error Weird type refinement problem.
.map(function (size) { return gridClassNamePart(size, grid[size], side); })
.map(size => gridClassNamePart(size, grid[size], side))
.join(' '));

@@ -37,0 +36,0 @@ }

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

import { __assign, __rest } from "tslib";
import { __rest } from "tslib";
import React, { useEffect } from 'react';

@@ -6,5 +6,5 @@ import { filterDOMProps, useField } from 'uniforms';

var _b;
var value = _a.value, rawProps = __rest(_a, ["value"]);
var props = useField(rawProps.name, rawProps, { initialValue: false })[0];
useEffect(function () {
var { value } = _a, rawProps = __rest(_a, ["value"]);
const props = useField(rawProps.name, rawProps, { initialValue: false })[0];
useEffect(() => {
if (value !== undefined && value !== props.value) {

@@ -14,3 +14,3 @@ props.onChange(value);

});
return props.noDOM ? null : (React.createElement("input", __assign({ disabled: props.disabled, name: props.name, readOnly: props.readOnly, ref: props.inputRef, type: "hidden", value: (_b = value !== null && value !== void 0 ? value : props.value) !== null && _b !== void 0 ? _b : '' }, filterDOMProps(props))));
return props.noDOM ? null : (React.createElement("input", Object.assign({ disabled: props.disabled, name: props.name, readOnly: props.readOnly, ref: props.inputRef, type: "hidden", value: (_b = value !== null && value !== void 0 ? value : props.value) !== null && _b !== void 0 ? _b : '' }, filterDOMProps(props))));
}

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

import { __assign, __rest } from "tslib";
import { __rest } from "tslib";
import classnames from 'classnames';

@@ -7,7 +7,7 @@ import cloneDeep from 'lodash/cloneDeep';

function ListAdd(_a) {
var addIcon = _a.addIcon, className = _a.className, disabled = _a.disabled, initialCount = _a.initialCount, name = _a.name, readOnly = _a.readOnly, value = _a.value, props = __rest(_a, ["addIcon", "className", "disabled", "initialCount", "name", "readOnly", "value"]);
var nameParts = joinName(null, name);
var parentName = joinName(nameParts.slice(0, -1));
var parent = useField(parentName, { initialCount: initialCount }, { absoluteName: true })[0];
var limitNotReached = !disabled && !(parent.maxCount <= parent.value.length);
var { addIcon, className, disabled, initialCount, name, readOnly, value } = _a, props = __rest(_a, ["addIcon", "className", "disabled", "initialCount", "name", "readOnly", "value"]);
const nameParts = joinName(null, name);
const parentName = joinName(nameParts.slice(0, -1));
const parent = useField(parentName, { initialCount }, { absoluteName: true })[0];
const limitNotReached = !disabled && !(parent.maxCount <= parent.value.length);
function onAction(event) {

@@ -20,3 +20,3 @@ if (limitNotReached &&

}
return (React.createElement("div", __assign({}, filterDOMProps(props), { className: classnames('badge badge-pill float-right', className), onClick: onAction, onKeyDown: onAction, role: "button", tabIndex: 0 }), addIcon));
return (React.createElement("div", Object.assign({}, filterDOMProps(props), { className: classnames('badge badge-pill float-right', className), onClick: onAction, onKeyDown: onAction, role: "button", tabIndex: 0 }), addIcon));
}

@@ -23,0 +23,0 @@ ListAdd.defaultProps = { addIcon: React.createElement("i", { className: "octicon octicon-plus" }) };

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

import { __assign, __rest } from "tslib";
import { __rest } from "tslib";
import classnames from 'classnames';

@@ -6,8 +6,8 @@ import React from 'react';

function ListDel(_a) {
var className = _a.className, disabled = _a.disabled, name = _a.name, readOnly = _a.readOnly, removeIcon = _a.removeIcon, props = __rest(_a, ["className", "disabled", "name", "readOnly", "removeIcon"]);
var nameParts = joinName(null, name);
var nameIndex = +nameParts[nameParts.length - 1];
var parentName = joinName(nameParts.slice(0, -1));
var parent = useField(parentName, {}, { absoluteName: true })[0];
var limitNotReached = !disabled && !(parent.minCount >= parent.value.length);
var { className, disabled, name, readOnly, removeIcon } = _a, props = __rest(_a, ["className", "disabled", "name", "readOnly", "removeIcon"]);
const nameParts = joinName(null, name);
const nameIndex = +nameParts[nameParts.length - 1];
const parentName = joinName(nameParts.slice(0, -1));
const parent = useField(parentName, {}, { absoluteName: true })[0];
const limitNotReached = !disabled && !(parent.minCount >= parent.value.length);
function onAction(event) {

@@ -17,3 +17,3 @@ if (limitNotReached &&

(!('key' in event) || event.key === 'Enter')) {
var value = parent.value.slice();
const value = parent.value.slice();
value.splice(nameIndex, 1);

@@ -23,3 +23,3 @@ parent.onChange(value);

}
return (React.createElement("span", __assign({}, filterDOMProps(props), { className: classnames('badge badge-pill', className), onClick: onAction, onKeyDown: onAction, role: "button", tabIndex: 0 }), removeIcon));
return (React.createElement("span", Object.assign({}, filterDOMProps(props), { className: classnames('badge badge-pill', className), onClick: onAction, onKeyDown: onAction, role: "button", tabIndex: 0 }), removeIcon));
}

@@ -26,0 +26,0 @@ ListDel.defaultProps = {

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

import { __assign, __rest } from "tslib";
import { __rest } from "tslib";
import classnames from 'classnames';

@@ -8,4 +8,4 @@ import React, { Children, cloneElement, isValidElement, } from 'react';

function List(_a) {
var addIcon = _a.addIcon, _b = _a.children, children = _b === void 0 ? React.createElement(ListItemField, { name: "$" }) : _b, className = _a.className, error = _a.error, errorMessage = _a.errorMessage, initialCount = _a.initialCount, itemProps = _a.itemProps, label = _a.label, removeIcon = _a.removeIcon, showInlineError = _a.showInlineError, value = _a.value, props = __rest(_a, ["addIcon", "children", "className", "error", "errorMessage", "initialCount", "itemProps", "label", "removeIcon", "showInlineError", "value"]);
return (React.createElement("div", __assign({ className: classnames('card mb-3', className) }, filterDOMProps(props)),
var { addIcon, children = React.createElement(ListItemField, { name: "$" }), className, error, errorMessage, initialCount, itemProps, label, removeIcon, showInlineError, value } = _a, props = __rest(_a, ["addIcon", "children", "className", "error", "errorMessage", "initialCount", "itemProps", "label", "removeIcon", "showInlineError", "value"]);
return (React.createElement("div", Object.assign({ className: classnames('card mb-3', className) }, filterDOMProps(props)),
React.createElement("div", { className: "card-body" },

@@ -18,11 +18,9 @@ label && (React.createElement("div", { className: "card-title" },

!!(error && showInlineError) && (React.createElement("span", { className: "text-danger" }, errorMessage)))), value === null || value === void 0 ? void 0 :
value.map(function (item, itemIndex) {
return Children.map(children, function (child, childIndex) {
var _a;
return isValidElement(child)
? cloneElement(child, __assign(__assign({ key: itemIndex + "-" + childIndex, name: (_a = child.props.name) === null || _a === void 0 ? void 0 : _a.replace('$', '' + itemIndex) }, itemProps), { removeIcon: removeIcon }))
: child;
});
}))));
value.map((item, itemIndex) => Children.map(children, (child, childIndex) => {
var _a;
return isValidElement(child)
? cloneElement(child, Object.assign(Object.assign({ key: `${itemIndex}-${childIndex}`, name: (_a = child.props.name) === null || _a === void 0 ? void 0 : _a.replace('$', '' + itemIndex) }, itemProps), { removeIcon }))
: child;
})))));
}
export default connectField(List);

@@ -5,4 +5,3 @@ import React from 'react';

import ListDelField from './ListDelField';
function ListItem(_a) {
var _b = _a.children, children = _b === void 0 ? React.createElement(AutoField, { className: "col-11", label: null, name: "" }) : _b, removeIcon = _a.removeIcon;
function ListItem({ children = React.createElement(AutoField, { className: "col-11", label: null, name: "" }), removeIcon, }) {
return (React.createElement("div", { className: "row" },

@@ -9,0 +8,0 @@ React.createElement("div", { className: "col-1" },

@@ -10,4 +10,4 @@ import classnames from 'classnames';

'is-valid': !props.error && props.changed,
}), disabled: props.disabled, id: props.id, name: props.name, onChange: function (event) { return props.onChange(event.target.value); }, placeholder: props.placeholder, readOnly: props.readOnly, ref: props.inputRef, rows: props.rows, value: (_a = props.value) !== null && _a !== void 0 ? _a : '' }));
}), disabled: props.disabled, id: props.id, name: props.name, onChange: event => props.onChange(event.target.value), placeholder: props.placeholder, readOnly: props.readOnly, ref: props.inputRef, rows: props.rows, value: (_a = props.value) !== null && _a !== void 0 ? _a : '' }));
}
export default connectField(LongText, { kind: 'leaf' });

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

import { __assign, __rest } from "tslib";
import { __rest } from "tslib";
import classnames from 'classnames';

@@ -7,9 +7,9 @@ import React from 'react';

function Nest(_a) {
var children = _a.children, className = _a.className, error = _a.error, errorMessage = _a.errorMessage, fields = _a.fields, itemProps = _a.itemProps, label = _a.label, showInlineError = _a.showInlineError, props = __rest(_a, ["children", "className", "error", "errorMessage", "fields", "itemProps", "label", "showInlineError"]);
return (React.createElement("div", __assign({ className: classnames(className, { 'has-error': error }) }, filterDOMProps(props)),
var { children, className, error, errorMessage, fields, itemProps, label, showInlineError } = _a, props = __rest(_a, ["children", "className", "error", "errorMessage", "fields", "itemProps", "label", "showInlineError"]);
return (React.createElement("div", Object.assign({ className: classnames(className, { 'has-error': error }) }, filterDOMProps(props)),
label && React.createElement("label", null, label),
!!(error && showInlineError) && (React.createElement("span", { className: "text-danger" }, errorMessage)),
children ||
fields.map(function (field) { return (React.createElement(AutoField, __assign({ key: field, name: field }, itemProps))); })));
fields.map(field => (React.createElement(AutoField, Object.assign({ key: field, name: field }, itemProps))))));
}
export default connectField(Nest);

@@ -10,5 +10,5 @@ import classnames from 'classnames';

'is-valid': !props.error && props.changed,
}), disabled: props.disabled, id: props.id, max: props.max, min: props.min, name: props.name, onChange: function (event) {
var parse = props.decimal ? parseFloat : parseInt;
var value = parse(event.target.value);
}), disabled: props.disabled, id: props.id, max: props.max, min: props.min, name: props.name, onChange: event => {
const parse = props.decimal ? parseFloat : parseInt;
const value = parse(event.target.value);
props.onChange(isNaN(value) ? undefined : value);

@@ -15,0 +15,0 @@ }, placeholder: props.placeholder, readOnly: props.readOnly, ref: props.inputRef, step: props.step || (props.decimal ? 0.01 : 1), type: "number", value: (_a = props.value) !== null && _a !== void 0 ? _a : '' }));

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

import { __extends } from "tslib";
import { QuickForm } from 'uniforms';

@@ -8,21 +7,16 @@ import AutoField from './AutoField';

function Quick(parent) {
var _ = /** @class */ (function (_super) {
__extends(_, _super);
function _() {
return _super !== null && _super.apply(this, arguments) || this;
class _ extends QuickForm.Quick(parent) {
getAutoField() {
return AutoField;
}
_.prototype.getAutoField = function () {
return AutoField;
};
_.prototype.getErrorsField = function () {
getErrorsField() {
return ErrorsField;
};
_.prototype.getSubmitField = function () {
}
getSubmitField() {
return SubmitField;
};
_.Quick = Quick;
return _;
}(QuickForm.Quick(parent)));
}
}
_.Quick = Quick;
return _;
}
export default Quick(BaseForm);

@@ -5,9 +5,9 @@ import classnames from 'classnames';

import wrapField from './wrapField';
var base64 = typeof btoa === 'undefined'
? /* istanbul ignore next */ function (/* istanbul ignore next */ x) { return Buffer.from(x).toString('base64'); }
const base64 = typeof btoa === 'undefined'
? /* istanbul ignore next */ /* istanbul ignore next */ x => Buffer.from(x).toString('base64')
: btoa;
var escape = function (x) { return base64(encodeURIComponent(x)).replace(/=+$/, ''); };
const escape = (x) => base64(encodeURIComponent(x)).replace(/=+$/, '');
function Radio(props) {
var _a;
return wrapField(props, (_a = props.allowedValues) === null || _a === void 0 ? void 0 : _a.map(function (item) { return (React.createElement("div", { key: item, className: classnames(props.inputClassName, 'form-check', 'radio', {
return wrapField(props, (_a = props.allowedValues) === null || _a === void 0 ? void 0 : _a.map(item => (React.createElement("div", { key: item, className: classnames(props.inputClassName, 'form-check', 'radio', {
'custom-control-inline': props.inline,

@@ -17,4 +17,4 @@ 'text-danger': props.error,

}) },
React.createElement("label", { htmlFor: props.id + "-" + escape(item), className: "form-check-label" },
React.createElement("input", { checked: item === props.value, className: "form-check-input", disabled: props.disabled, id: props.id + "-" + escape(item), name: props.name, onChange: function () {
React.createElement("label", { htmlFor: `${props.id}-${escape(item)}`, className: "form-check-label" },
React.createElement("input", { checked: item === props.value, className: "form-check-input", disabled: props.disabled, id: `${props.id}-${escape(item)}`, name: props.name, onChange: () => {
if (!props.readOnly) {

@@ -25,4 +25,4 @@ props.onChange(item);

' ',
props.transform ? props.transform(item) : item))); }));
props.transform ? props.transform(item) : item)))));
}
export default connectField(Radio, { kind: 'leaf' });

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

import { __assign, __rest } from "tslib";
import { __rest } from "tslib";
import classnames from 'classnames';

@@ -7,16 +7,16 @@ import xor from 'lodash/xor';

import wrapField from './wrapField';
var base64 = typeof btoa === 'undefined'
? /* istanbul ignore next */ function (/* istanbul ignore next */ x) { return Buffer.from(x).toString('base64'); }
const base64 = typeof btoa === 'undefined'
? /* istanbul ignore next */ /* istanbul ignore next */ x => Buffer.from(x).toString('base64')
: btoa;
var escape = function (x) { return base64(encodeURIComponent(x)).replace(/=+$/, ''); };
const escape = (x) => base64(encodeURIComponent(x)).replace(/=+$/, '');
function Select(_a) {
var allowedValues = _a.allowedValues, checkboxes = _a.checkboxes, disableItem = _a.disableItem, disabled = _a.disabled, error = _a.error, fieldType = _a.fieldType, id = _a.id, inline = _a.inline, inputClassName = _a.inputClassName, inputRef = _a.inputRef, label = _a.label, name = _a.name, onChange = _a.onChange, placeholder = _a.placeholder, readOnly = _a.readOnly, required = _a.required, transform = _a.transform, value = _a.value, props = __rest(_a, ["allowedValues", "checkboxes", "disableItem", "disabled", "error", "fieldType", "id", "inline", "inputClassName", "inputRef", "label", "name", "onChange", "placeholder", "readOnly", "required", "transform", "value"]);
var multiple = fieldType === Array;
return wrapField(__assign(__assign({}, props), { disabled: disabled,
error: error,
id: id,
label: label,
required: required }), checkboxes ? (allowedValues === null || allowedValues === void 0 ? void 0 : allowedValues.map(function (item) { return (React.createElement("div", { key: item, className: classnames(inputClassName, "checkbox" + (inline ? '-inline' : '')) },
React.createElement("label", { htmlFor: id + "-" + escape(item) },
React.createElement("input", { checked: multiple ? value === null || value === void 0 ? void 0 : value.includes(item) : value === item, disabled: (disableItem === null || disableItem === void 0 ? void 0 : disableItem(item)) || disabled, id: id + "-" + escape(item), name: name, onChange: function () {
var { allowedValues, checkboxes, disableItem, disabled, error, fieldType, id, inline, inputClassName, inputRef, label, name, onChange, placeholder, readOnly, required, transform, value } = _a, props = __rest(_a, ["allowedValues", "checkboxes", "disableItem", "disabled", "error", "fieldType", "id", "inline", "inputClassName", "inputRef", "label", "name", "onChange", "placeholder", "readOnly", "required", "transform", "value"]);
const multiple = fieldType === Array;
return wrapField(Object.assign(Object.assign({}, props), { disabled,
error,
id,
label,
required }), checkboxes ? (allowedValues === null || allowedValues === void 0 ? void 0 : allowedValues.map(item => (React.createElement("div", { key: item, className: classnames(inputClassName, `checkbox${inline ? '-inline' : ''}`) },
React.createElement("label", { htmlFor: `${id}-${escape(item)}` },
React.createElement("input", { checked: multiple ? value === null || value === void 0 ? void 0 : value.includes(item) : value === item, disabled: (disableItem === null || disableItem === void 0 ? void 0 : disableItem(item)) || disabled, id: `${id}-${escape(item)}`, name: name, onChange: () => {
if (!readOnly) {

@@ -26,10 +26,10 @@ onChange(multiple ? xor([item], value) : item);

}, type: "checkbox" }),
transform ? transform(item) : item))); })) : (React.createElement("select", { className: classnames(inputClassName, 'c-select form-control', {
transform ? transform(item) : item))))) : (React.createElement("select", { className: classnames(inputClassName, 'c-select form-control', {
'is-invalid': error,
'is-valid': !error && props.changed,
}), disabled: disabled, id: id, multiple: multiple, name: name, onChange: function (event) {
}), disabled: disabled, id: id, multiple: multiple, name: name, onChange: event => {
if (!readOnly) {
var item = event.target.value;
const item = event.target.value;
if (multiple) {
var clear = event.target.selectedIndex === -1;
const clear = event.target.selectedIndex === -1;
onChange(clear ? [] : xor([item], value));

@@ -43,4 +43,4 @@ }

(!!placeholder || !required || value === undefined) && !multiple && (React.createElement("option", { value: "", disabled: required, hidden: required }, placeholder || label)), allowedValues === null || allowedValues === void 0 ? void 0 :
allowedValues.map(function (allowedValue) { return (React.createElement("option", { disabled: disableItem === null || disableItem === void 0 ? void 0 : disableItem(allowedValue), key: allowedValue, value: allowedValue }, transform ? transform(allowedValue) : allowedValue)); }))));
allowedValues.map(allowedValue => (React.createElement("option", { disabled: disableItem === null || disableItem === void 0 ? void 0 : disableItem(allowedValue), key: allowedValue, value: allowedValue }, transform ? transform(allowedValue) : allowedValue))))));
}
export default connectField(Select, { kind: 'leaf' });

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

import { __assign, __rest } from "tslib";
import { __rest } from "tslib";
import classnames from 'classnames';

@@ -7,8 +7,8 @@ import React from 'react';

function SubmitField(_a) {
var className = _a.className, disabled = _a.disabled, inputClassName = _a.inputClassName, inputRef = _a.inputRef, readOnly = _a.readOnly, value = _a.value, wrapClassName = _a.wrapClassName, props = __rest(_a, ["className", "disabled", "inputClassName", "inputRef", "readOnly", "value", "wrapClassName"]);
var _b = useForm(), error = _b.error, anyState = _b.state;
var state = anyState;
var hasWrap = !!(state.grid || wrapClassName);
var blockInput = (React.createElement("input", __assign({ className: inputClassName, disabled: disabled === undefined ? !!(error || state.disabled) : disabled, readOnly: readOnly, ref: inputRef, type: "submit" }, (value ? { value: value } : {}))));
return (React.createElement("div", __assign({ className: classnames(className, {
var { className, disabled, inputClassName, inputRef, readOnly, value, wrapClassName } = _a, props = __rest(_a, ["className", "disabled", "inputClassName", "inputRef", "readOnly", "value", "wrapClassName"]);
const { error, state: anyState } = useForm();
const state = anyState;
const hasWrap = !!(state.grid || wrapClassName);
const blockInput = (React.createElement("input", Object.assign({ className: inputClassName, disabled: disabled === undefined ? !!(error || state.disabled) : disabled, readOnly: readOnly, ref: inputRef, type: "submit" }, (value ? { value } : {}))));
return (React.createElement("div", Object.assign({ className: classnames(className, {
'is-invalid': error,

@@ -15,0 +15,0 @@ row: state.grid,

@@ -11,4 +11,4 @@ import classnames from 'classnames';

'is-valid': !props.error && props.changed,
}), disabled: props.disabled, id: props.id, name: props.name, onChange: function (event) { return props.onChange(event.target.value); }, placeholder: props.placeholder, readOnly: props.readOnly, ref: props.inputRef, type: (_a = props.type) !== null && _a !== void 0 ? _a : 'text', value: (_b = props.value) !== null && _b !== void 0 ? _b : '' }));
}), disabled: props.disabled, id: props.id, name: props.name, onChange: event => props.onChange(event.target.value), placeholder: props.placeholder, readOnly: props.readOnly, ref: props.inputRef, type: (_a = props.type) !== null && _a !== void 0 ? _a : 'text', value: (_b = props.value) !== null && _b !== void 0 ? _b : '' }));
}
export default connectField(Text, { kind: 'leaf' });

@@ -1,15 +0,9 @@

import { __extends } from "tslib";
import { ValidatedForm } from 'uniforms';
import BaseForm from './BaseForm';
function Validated(parent) {
var _ = /** @class */ (function (_super) {
__extends(_, _super);
function _() {
return _super !== null && _super.apply(this, arguments) || this;
}
_.Validated = Validated;
return _;
}(ValidatedForm.Validated(parent)));
class _ extends ValidatedForm.Validated(parent) {
}
_.Validated = Validated;
return _;
}
export default Validated(BaseForm);

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

import { __assign, __rest } from "tslib";
import { __rest } from "tslib";
import classnames from 'classnames';

@@ -8,18 +8,18 @@ import omit from 'lodash/omit';

export default function wrapField(_a, children) {
var changed = _a.changed, className = _a.className, disabled = _a.disabled, error = _a.error, errorMessage = _a.errorMessage, grid = _a.grid, // Grid is either an number between 1 and 11 or an object with keys like xs and md.
help = _a.help, // Help text.
helpClassName = _a.helpClassName, // Help text class name.
id = _a.id, label = _a.label, labelClassName = _a.labelClassName, // Label class name (String|Array[String]).
required = _a.required, showInlineError = _a.showInlineError, // Show inline error message?
wrapClassName = _a.wrapClassName, // Input wrapper class name.
var { changed, className, disabled, error, errorMessage, grid, // Grid is either an number between 1 and 11 or an object with keys like xs and md.
help, // Help text.
helpClassName, // Help text class name.
id, label, labelClassName, // Label class name (String|Array[String]).
required, showInlineError, // Show inline error message?
wrapClassName } = _a, // Input wrapper class name.
props = __rest(_a, ["changed", "className", "disabled", "error", "errorMessage", "grid", "help", "helpClassName", "id", "label", "labelClassName", "required", "showInlineError", "wrapClassName"]);
var hasWrap = !!(grid || wrapClassName);
var blockError = !!(error && showInlineError) && (React.createElement("span", { className: "form-text text-danger" }, errorMessage));
var blockHelp = !!help && (React.createElement("span", { className: classnames('form-text', helpClassName || 'text-muted') }, help));
var isValid = !error && changed;
return (React.createElement("div", __assign({ className: classnames(className, 'form-group', {
const hasWrap = !!(grid || wrapClassName);
const blockError = !!(error && showInlineError) && (React.createElement("span", { className: "form-text text-danger" }, errorMessage));
const blockHelp = !!help && (React.createElement("span", { className: classnames('form-text', helpClassName || 'text-muted') }, help));
const isValid = !error && changed;
return (React.createElement("div", Object.assign({ className: classnames(className, 'form-group', {
'is-invalid': error,
'is-valid': isValid,
disabled: disabled,
required: required,
disabled,
required,
row: grid,

@@ -26,0 +26,0 @@ }) }, omit(filterDOMProps(props), [

{
"name": "uniforms-bootstrap4",
"version": "3.6.0",
"version": "3.6.1",
"license": "MIT",
"main": "./es5/index.js",
"main": "./cjs/index.js",
"module": "./esm/index.js",

@@ -23,8 +23,6 @@ "sideEffects": false,

"files": [
"es5/*.d.ts",
"es5/*.js",
"cjs/*.d.ts",
"cjs/*.js",
"esm/*.d.ts",
"esm/*.js",
"es6/*.d.ts",
"es6/*.js",
"src/*.ts",

@@ -41,6 +39,6 @@ "src/*.tsx"

"tslib": "^2.2.0",
"uniforms": "^3.6.0",
"uniforms": "^3.6.1",
"warning": "^4.0.0"
},
"gitHead": "8ec8ba7751b6ce4b205c49d2aca1ab460bd09e0a"
"gitHead": "a36891aa6aa9bb10c40bf5709085fbe82ac4ae92"
}
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