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

uniforms

Package Overview
Dependencies
Maintainers
1
Versions
190
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uniforms - npm Package Compare versions

Comparing version 2.4.1 to 2.5.0

AutoForm.d.ts

203

AutoForm.js
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
var _omit = _interopRequireDefault(require("lodash/omit"));
var _set = _interopRequireDefault(require("lodash/set"));
var _ValidatedQuickForm = _interopRequireDefault(require("./ValidatedQuickForm"));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var Auto = function Auto(parent) {
var _class, _temp;
return _temp = _class =
/*#__PURE__*/
function (_parent) {
(0, _inherits2["default"])(_class, _parent);
function _class() {
var _this;
(0, _classCallCheck2["default"])(this, _class);
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(_class).apply(this, arguments));
_this.state = _objectSpread({}, _this.state, {
model: _this.props.model,
modelSync: _this.props.model
});
return _this;
}
(0, _createClass2["default"])(_class, [{
key: "componentWillReceiveProps",
value: function componentWillReceiveProps(_ref) {
var model = _ref.model;
(0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "componentWillReceiveProps", this).apply(this, arguments);
if (!(0, _isEqual["default"])(this.props.model, model)) {
this.setState(function () {
return {
model: model,
modelSync: model
};
});
exports.__esModule = true;
var tslib_1 = require("tslib");
var PropTypes = tslib_1.__importStar(require("prop-types"));
var cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
var isEqual_1 = tslib_1.__importDefault(require("lodash/isEqual"));
var omit_1 = tslib_1.__importDefault(require("lodash/omit"));
var set_1 = tslib_1.__importDefault(require("lodash/set"));
var ValidatedQuickForm_1 = tslib_1.__importDefault(require("./ValidatedQuickForm"));
var Auto = function (parent) { var _a; return _a = /** @class */ (function (_super) {
tslib_1.__extends(class_1, _super);
function class_1() {
var _this = _super.apply(this, arguments) || this;
// @ts-ignore
_this.state = tslib_1.__assign({}, _this.state, { model: _this.props.model, modelSync: _this.props.model });
return _this;
}
}
}, {
key: "getNativeFormProps",
value: function getNativeFormProps() {
return (0, _omit["default"])((0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "getNativeFormProps", this).call(this), ['onChangeModel']);
}
}, {
key: "getModel",
value: function getModel(mode) {
return mode === 'form' ? this.state.modelSync : this.state.model;
}
}, {
key: "onChange",
value: function onChange(key, value) {
var _this2 = this,
_arguments = arguments;
var updateState = function updateState(state) {
return {
modelSync: (0, _set["default"])((0, _cloneDeep["default"])(state.modelSync), key, value)
};
class_1.prototype.componentWillReceiveProps = function (_a) {
var model = _a.model;
_super.prototype.componentWillReceiveProps.apply(this, arguments);
if (!isEqual_1["default"](this.props.model, model)) {
this.setState(function () { return ({ model: model, modelSync: model }); });
}
};
var updateModel = function updateModel(state) {
if (_this2.props.onChangeModel) {
_this2.props.onChangeModel(state.modelSync);
}
return {
model: state.modelSync
};
}; // Before componentDidMount, every call to onChange should call BaseForm#onChange synchronously
if (this.state.changed === null) {
this.setState(updateState);
(0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "onChange", this).apply(this, arguments);
this.setState(updateModel);
} else {
this.setState(updateState, function () {
(0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "onChange", _this2).apply(_this2, _arguments);
_this2.setState(updateModel);
});
}
}
}, {
key: "__reset",
value: function __reset(state) {
return _objectSpread({}, (0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "__reset", this).call(this, state), {
model: this.props.model,
modelSync: this.props.model
});
}
}, {
key: "onValidate",
value: function onValidate() {
return this.onValidateModel(this.getChildContextModel());
}
}]);
return _class;
}(parent), _class.Auto = Auto, _class.displayName = "Auto".concat(parent.displayName), _class.propTypes = _objectSpread({}, parent.propTypes, {
onChangeModel: _propTypes["default"].func
}), _temp;
};
var _default = Auto(_ValidatedQuickForm["default"]);
exports["default"] = _default;
class_1.prototype.getNativeFormProps = function () {
return omit_1["default"](_super.prototype.getNativeFormProps.call(this), ['onChangeModel']);
};
class_1.prototype.getModel = function (mode) {
return mode === 'form' ? this.state.modelSync : this.state.model;
};
class_1.prototype.onChange = function (key, value) {
var _this = this;
var updateState = function (state) { return ({
modelSync: set_1["default"](cloneDeep_1["default"](state.modelSync), key, value)
}); };
var updateModel = function (state) {
if (_this.props.onChangeModel) {
_this.props.onChangeModel(state.modelSync);
}
return { model: state.modelSync };
};
// Before componentDidMount, every call to onChange should call BaseForm#onChange synchronously
if (this.state.changed === null) {
this.setState(updateState);
_super.prototype.onChange.call(this, key, value);
this.setState(updateModel);
}
else {
this.setState(updateState, function () {
_super.prototype.onChange.call(_this, key, value);
_this.setState(updateModel);
});
}
};
class_1.prototype.__reset = function (state) {
return tslib_1.__assign({}, _super.prototype.__reset.call(this, state), { model: this.props.model, modelSync: this.props.model });
};
class_1.prototype.onValidate = function () {
return this.onValidateModel(this.getChildContextModel());
};
return class_1;
}(parent)),
_a.Auto = Auto,
_a.displayName = "Auto" + parent.displayName,
_a.propTypes = tslib_1.__assign({}, parent.propTypes, { onChangeModel: PropTypes.func }),
_a; };
exports["default"] = Auto(ValidatedQuickForm_1["default"]);
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _get = _interopRequireDefault(require("lodash/get"));
var _invariant = _interopRequireDefault(require("invariant"));
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
var _react = require("react");
var _BaseForm = _interopRequireDefault(require("./BaseForm"));
var _joinName = _interopRequireDefault(require("./joinName"));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
exports.__esModule = true;
var tslib_1 = require("tslib");
var prop_types_1 = tslib_1.__importDefault(require("prop-types"));
var get_1 = tslib_1.__importDefault(require("lodash/get"));
var invariant_1 = tslib_1.__importDefault(require("invariant"));
var isEqual_1 = tslib_1.__importDefault(require("lodash/isEqual"));
var react_1 = require("react");
var BaseForm_1 = tslib_1.__importDefault(require("./BaseForm"));
var joinName_1 = tslib_1.__importDefault(require("./joinName"));
// Used for calculating labels and placeholders.
var flowingProp = function flowingProp(prop, schema, state, fallback) {
var propDisabled = prop === '' || prop === false;
var propSet = prop !== undefined;
var schemaDisabled = schema === '' || schema === false;
var schemaValue = schema === true || schema === undefined ? fallback : schema;
var stateDisabled = !state;
var value = propDisabled || !propSet && (schemaDisabled || stateDisabled) ? '' : propSet ? prop === true ? schemaDisabled ? '' : schemaValue : prop : schemaValue;
return [value, schemaValue];
var flowingProp = function (prop, schema, state, fallback) {
var propDisabled = prop === '' || prop === false;
var propSet = prop !== undefined;
var schemaDisabled = schema === '' || schema === false;
var schemaValue = schema === true || schema === undefined ? fallback : schema;
var stateDisabled = !state;
var value = propDisabled || (!propSet && (schemaDisabled || stateDisabled))
? ''
: propSet
? prop === true
? schemaDisabled
? ''
: schemaValue
: prop
: schemaValue;
return [value, schemaValue];
};
var BaseField =
/*#__PURE__*/
function (_Component) {
(0, _inherits2["default"])(BaseField, _Component);
function BaseField() {
var _this;
(0, _classCallCheck2["default"])(this, BaseField);
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(BaseField).apply(this, arguments));
(0, _invariant["default"])(_this.context.uniforms, '<%s /> must be rendered within a form.', _this.constructor.displayName);
_this.options = {
ensureValue: true,
explicitInitialValue: false,
includeParent: false,
overrideValue: false
var BaseField = /** @class */ (function (_super) {
tslib_1.__extends(BaseField, _super);
function BaseField() {
var _this = _super.apply(this, arguments) || this;
invariant_1["default"](_this.context.uniforms, '<%s /> must be rendered within a form.',
// @ts-ignore
_this.constructor.displayName);
_this.options = {
ensureValue: true,
explicitInitialValue: false,
includeParent: false,
overrideValue: false
};
_this.randomId = _this.context.uniforms.randomId();
_this.findValue = _this.findValue.bind(_this);
_this.findField = _this.findField.bind(_this);
_this.findError = _this.findError.bind(_this);
return _this;
}
BaseField.prototype.getChildContext = function () {
return {
uniforms: {
name: this.getChildContextName(),
error: this.getChildContextError(),
model: this.getChildContextModel(),
state: this.getChildContextState(),
schema: this.getChildContextSchema(),
onChange: this.getChildContextOnChange(),
onSubmit: this.getChildContextOnSubmit(),
randomId: this.context.uniforms.randomId
}
};
};
_this.randomId = _this.context.uniforms.randomId();
_this.findValue = _this.findValue.bind((0, _assertThisInitialized2["default"])(_this));
_this.findField = _this.findField.bind((0, _assertThisInitialized2["default"])(_this));
_this.findError = _this.findError.bind((0, _assertThisInitialized2["default"])(_this));
return _this;
}
(0, _createClass2["default"])(BaseField, [{
key: "getChildContext",
value: function getChildContext() {
return {
uniforms: {
name: this.getChildContextName(),
error: this.getChildContextError(),
model: this.getChildContextModel(),
state: this.getChildContextState(),
schema: this.getChildContextSchema(),
onChange: this.getChildContextOnChange(),
onSubmit: this.getChildContextOnSubmit(),
randomId: this.context.uniforms.randomId
// eslint-disable-next-line complexity
BaseField.prototype.shouldComponentUpdate = function (nextProps, _, _a) {
var nextContext = _a.uniforms;
var prevProps = this.props;
var prevContext = this.context.uniforms;
if (!isEqual_1["default"](prevProps, nextProps)) {
return true;
}
};
} // eslint-disable-next-line complexity
}, {
key: "shouldComponentUpdate",
value: function shouldComponentUpdate(nextProps, _, _ref) {
var nextContext = _ref.uniforms;
var prevProps = this.props;
var prevContext = this.context.uniforms;
if (!(0, _isEqual["default"])(prevProps, nextProps)) {
return true;
}
var _nextContext$state = nextContext.state,
nextMap = _nextContext$state.changedMap,
nextState = (0, _objectWithoutProperties2["default"])(_nextContext$state, ["changedMap"]);
var _prevContext$state = prevContext.state,
prevMap = _prevContext$state.changedMap,
prevState = (0, _objectWithoutProperties2["default"])(_prevContext$state, ["changedMap"]);
if (!(0, _isEqual["default"])(prevState, nextState)) {
return true;
}
var prevName = (0, _joinName["default"])(prevContext.name, prevProps.name);
var nextName = (0, _joinName["default"])(nextContext.name, nextProps.name);
if (prevName !== nextName) {
return true;
}
if (!(0, _isEqual["default"])((0, _get["default"])(prevMap, prevName), (0, _get["default"])(nextMap, nextName))) {
return true;
} // Fields which are using parent props, need to be updated when parent value change
if (this.options.includeParent && nextName.indexOf('.') !== -1) {
var prevParentValue = (0, _get["default"])(prevContext.model, prevName.replace(/(.+)\..+$/, '$1'));
var nextParentValue = (0, _get["default"])(nextContext.model, nextName.replace(/(.+)\..+$/, '$1'));
if (!(0, _isEqual["default"])(prevParentValue, nextParentValue)) {
return true;
var _b = nextContext.state, nextMap = _b.changedMap, nextState = tslib_1.__rest(_b, ["changedMap"]);
var _c = prevContext.state, prevMap = _c.changedMap, prevState = tslib_1.__rest(_c, ["changedMap"]);
if (!isEqual_1["default"](prevState, nextState)) {
return true;
}
}
var prevValue = (0, _get["default"])(prevContext.model, prevName);
var nextValue = (0, _get["default"])(nextContext.model, nextName);
if (!(0, _isEqual["default"])(prevValue, nextValue)) {
return true;
}
if (prevContext.error !== nextContext.error) {
var prevError = prevContext.error && prevContext.schema.getError(prevName, prevContext.error);
var nextError = nextContext.error && nextContext.schema.getError(nextName, nextContext.error);
if (!(0, _isEqual["default"])(prevError, nextError)) {
return true;
} // Fields like List or Nest should update, whenever their children error has changed
if (nextValue === Object(nextValue) && !(nextValue instanceof Date)) {
return true;
var prevName = joinName_1["default"](prevContext.name, prevProps.name);
var nextName = joinName_1["default"](nextContext.name, nextProps.name);
if (prevName !== nextName) {
return true;
}
}
if (nextContext.schema !== prevContext.schema) {
return true;
}
return false;
}
}, {
key: "getChildContextName",
value: function getChildContextName() {
return (0, _joinName["default"])(null, this.context.uniforms.name, this.props.name);
}
}, {
key: "getChildContextError",
value: function getChildContextError() {
return this.context.uniforms.error;
}
}, {
key: "getChildContextModel",
value: function getChildContextModel() {
return this.context.uniforms.model;
}
}, {
key: "getChildContextState",
value: function getChildContextState() {
var state = this.context.uniforms.state;
var props = this.props;
var propagate = function propagate(name) {
return props[name] === undefined || props[name] === null ? state[name] : !!props[name];
};
return _objectSpread({}, state, {
label: propagate('label'),
disabled: propagate('disabled'),
placeholder: propagate('placeholder'),
showInlineError: propagate('showInlineError')
});
}
}, {
key: "getChildContextSchema",
value: function getChildContextSchema() {
return this.context.uniforms.schema;
}
}, {
key: "getChildContextOnChange",
value: function getChildContextOnChange() {
return this.context.uniforms.onChange;
}
}, {
key: "getChildContextOnSubmit",
value: function getChildContextOnSubmit() {
return this.context.uniforms.onSubmit;
} // eslint-disable-next-line complexity
}, {
key: "getFieldProps",
value: function getFieldProps(name, options) {
var context = this.context.uniforms;
var props = this.props;
var state = this.getChildContextState();
options = Object.assign({}, this.options, options);
if (name === undefined) {
name = (0, _joinName["default"])(context.name, props.name);
}
var changed = !!(0, _get["default"])(context.state.changedMap, name);
var error = context.schema.getError(name, context.error);
var errorMessage = context.schema.getErrorMessage(name, context.error);
var field = context.schema.getField(name);
var fieldType = context.schema.getType(name);
var fields = context.schema.getSubfields(name);
var schemaProps = context.schema.getProps(name, _objectSpread({}, state, {}, props));
var initialValue = options.explicitInitialValue ? context.schema.getInitialValue(name, props) : undefined;
var parent = options.includeParent && name.indexOf('.') !== -1 ? this.getFieldProps(name.replace(/(.+)\..+$/, '$1'), {
includeParent: false
}) : null;
var _flowingProp = flowingProp(props.label, schemaProps.label, state.label, ''),
_flowingProp2 = (0, _slicedToArray2["default"])(_flowingProp, 2),
label = _flowingProp2[0],
none = _flowingProp2[1];
var _flowingProp3 = flowingProp(props.placeholder, schemaProps.placeholder, state.placeholder, label || none),
_flowingProp4 = (0, _slicedToArray2["default"])(_flowingProp3, 1),
placeholder = _flowingProp4[0];
var value;
if (props.value === undefined || options.overrideValue) {
value = (0, _get["default"])(context.model, name);
if (value === undefined && !changed && !options.explicitInitialValue) {
value = context.schema.getInitialValue(name, props);
if (!isEqual_1["default"](get_1["default"](prevMap, prevName), get_1["default"](nextMap, nextName))) {
return true;
}
} // This prevents (un)controlled input change warning.
// More info: https://fb.me/react-controlled-components.
if (value === undefined && options.ensureValue) {
value = '';
}
return _objectSpread({
// 0. Constant props.
findError: this.findError,
findField: this.findField,
findValue: this.findValue,
id: this.randomId
}, state, {
// 2. Calculated field props.
changed: changed,
error: error,
errorMessage: errorMessage,
field: field,
fieldType: fieldType,
fields: fields,
onChange: function onChange(value) {
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : name;
return context.onChange(key, value);
},
parent: parent,
value: value
}, options.explicitInitialValue && {
initialValue: initialValue
}, {}, schemaProps, {}, props, {}, (options.explicitInitialValue || options.overrideValue) && {
value: value
}, {
// 6. Calculated _special_ field props.
label: label,
name: name,
placeholder: placeholder
});
}
}, {
key: "findError",
value: function findError(name) {
return this.context.uniforms.schema.getError(name, this.context.uniforms.error);
}
}, {
key: "findField",
value: function findField(name) {
return this.context.uniforms.schema.getField(name);
}
}, {
key: "findValue",
value: function findValue(name) {
return (0, _get["default"])(this.context.uniforms.model, name);
}
}]);
return BaseField;
}(_react.Component);
// Fields which are using parent props, need to be updated when parent value change
if (this.options.includeParent && nextName.indexOf('.') !== -1) {
var prevParentValue = get_1["default"](prevContext.model, prevName.replace(/(.+)\..+$/, '$1'));
var nextParentValue = get_1["default"](nextContext.model, nextName.replace(/(.+)\..+$/, '$1'));
if (!isEqual_1["default"](prevParentValue, nextParentValue)) {
return true;
}
}
var prevValue = get_1["default"](prevContext.model, prevName);
var nextValue = get_1["default"](nextContext.model, nextName);
if (!isEqual_1["default"](prevValue, nextValue)) {
return true;
}
if (prevContext.error !== nextContext.error) {
var prevError = prevContext.error &&
prevContext.schema.getError(prevName, prevContext.error);
var nextError = nextContext.error &&
nextContext.schema.getError(nextName, nextContext.error);
if (!isEqual_1["default"](prevError, nextError)) {
return true;
}
// Fields like List or Nest should update, whenever their children error has changed
if (nextValue === Object(nextValue) && !(nextValue instanceof Date)) {
return true;
}
}
if (nextContext.schema !== prevContext.schema) {
return true;
}
return false;
};
BaseField.prototype.getChildContextName = function () {
return joinName_1["default"](null, this.context.uniforms.name, this.props.name);
};
BaseField.prototype.getChildContextError = function () {
return this.context.uniforms.error;
};
BaseField.prototype.getChildContextModel = function () {
return this.context.uniforms.model;
};
BaseField.prototype.getChildContextState = function () {
var state = this.context.uniforms.state;
var props = this.props;
var propagate = function (name) {
return props[name] === undefined || props[name] === null
? state[name]
: !!props[name];
};
return tslib_1.__assign({}, state, { label: propagate('label'), disabled: propagate('disabled'), placeholder: propagate('placeholder'), showInlineError: propagate('showInlineError') });
};
BaseField.prototype.getChildContextSchema = function () {
return this.context.uniforms.schema;
};
BaseField.prototype.getChildContextOnChange = function () {
return this.context.uniforms.onChange;
};
BaseField.prototype.getChildContextOnSubmit = function () {
return this.context.uniforms.onSubmit;
};
// eslint-disable-next-line complexity
BaseField.prototype.getFieldProps = function (name, options) {
var context = this.context.uniforms;
var props = this.props;
var state = this.getChildContextState();
options = Object.assign({}, this.options, options);
if (name === undefined) {
name = joinName_1["default"](context.name, props.name);
}
var changed = !!get_1["default"](context.state.changedMap, name);
var error = context.schema.getError(name, context.error);
var errorMessage = context.schema.getErrorMessage(name, context.error);
var field = context.schema.getField(name);
var fieldType = context.schema.getType(name);
var fields = context.schema.getSubfields(name);
var schemaProps = context.schema.getProps(name, tslib_1.__assign({}, state, props));
var initialValue = options.explicitInitialValue
? context.schema.getInitialValue(name, props)
: undefined;
var parent = options.includeParent && name.indexOf('.') !== -1
? this.getFieldProps(name.replace(/(.+)\..+$/, '$1'), {
includeParent: false
})
: null;
var _a = flowingProp(props.label, schemaProps.label, state.label, ''), label = _a[0], none = _a[1];
var placeholder = flowingProp(props.placeholder, schemaProps.placeholder, state.placeholder, label || none)[0];
var value;
if (props.value === undefined || options.overrideValue) {
value = get_1["default"](context.model, name);
if (value === undefined && !changed && !options.explicitInitialValue) {
value = context.schema.getInitialValue(name, props);
}
}
// This prevents (un)controlled input change warning.
// More info: https://fb.me/react-controlled-components.
if (value === undefined && options.ensureValue) {
value = '';
}
return tslib_1.__assign({
// 0. Constant props.
findError: this.findError, findField: this.findField, findValue: this.findValue, id: this.randomId }, state, {
// 2. Calculated field props.
changed: changed,
error: error,
errorMessage: errorMessage,
field: field,
fieldType: fieldType,
fields: fields, onChange: function (value, key) {
if (key === void 0) { key = name; }
return context.onChange(key, value);
}, parent: parent,
value: value }, (options.explicitInitialValue && { initialValue: initialValue }), schemaProps, props, ((options.explicitInitialValue || options.overrideValue) && { value: value }), {
// 6. Calculated _special_ field props.
label: label,
name: name,
placeholder: placeholder });
};
BaseField.prototype.findError = function (name) {
return this.context.uniforms.schema.getError(name, this.context.uniforms.error);
};
BaseField.prototype.findField = function (name) {
return this.context.uniforms.schema.getField(name);
};
BaseField.prototype.findValue = function (name) {
return get_1["default"](this.context.uniforms.model, name);
};
BaseField.displayName = 'Field';
BaseField.propTypes = {
id: prop_types_1["default"].string,
name: prop_types_1["default"].string.isRequired,
disabled: prop_types_1["default"].bool,
label: prop_types_1["default"].oneOfType([
prop_types_1["default"].bool,
prop_types_1["default"].string,
prop_types_1["default"].node
]),
placeholder: prop_types_1["default"].oneOfType([prop_types_1["default"].bool, prop_types_1["default"].string])
};
BaseField.contextTypes = BaseForm_1["default"].childContextTypes;
BaseField.childContextTypes = BaseForm_1["default"].childContextTypes;
return BaseField;
}(react_1.Component));
exports["default"] = BaseField;
BaseField.displayName = 'Field';
BaseField.contextTypes = _BaseForm["default"].childContextTypes;
BaseField.childContextTypes = _BaseForm["default"].childContextTypes;
BaseField.propTypes = process.env.NODE_ENV !== "production" ? {
id: _propTypes["default"].string,
name: _propTypes["default"].string.isRequired,
disabled: _propTypes["default"].bool,
label: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].string, _propTypes["default"].node]),
placeholder: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].string])
} : {};
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = exports.__childContextTypesBuild = exports.__childContextTypes = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireWildcard(require("react"));
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
var _get = _interopRequireDefault(require("lodash/get"));
var _isFunction = _interopRequireDefault(require("lodash/isFunction"));
var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
var _mapValues = _interopRequireDefault(require("lodash/mapValues"));
var _omit = _interopRequireDefault(require("lodash/omit"));
var _set = _interopRequireDefault(require("lodash/set"));
var _randomIds = _interopRequireDefault(require("./randomIds"));
var _createSchemaBridge = _interopRequireDefault(require("./createSchemaBridge"));
var _changedKeys = _interopRequireDefault(require("./changedKeys"));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var __childContextTypes = {
name: _propTypes["default"].arrayOf(_propTypes["default"].string).isRequired,
error: _propTypes["default"].object,
model: _propTypes["default"].object.isRequired,
schema: {
getError: _propTypes["default"].func.isRequired,
getErrorMessage: _propTypes["default"].func.isRequired,
getErrorMessages: _propTypes["default"].func.isRequired,
getField: _propTypes["default"].func.isRequired,
getInitialValue: _propTypes["default"].func.isRequired,
getProps: _propTypes["default"].func.isRequired,
getSubfields: _propTypes["default"].func.isRequired,
getType: _propTypes["default"].func.isRequired,
getValidator: _propTypes["default"].func.isRequired
},
state: {
changed: _propTypes["default"].bool.isRequired,
changedMap: _propTypes["default"].object.isRequired,
submitting: _propTypes["default"].bool.isRequired,
label: _propTypes["default"].bool.isRequired,
disabled: _propTypes["default"].bool.isRequired,
placeholder: _propTypes["default"].bool.isRequired,
showInlineError: _propTypes["default"].bool.isRequired
},
onChange: _propTypes["default"].func.isRequired,
onSubmit: _propTypes["default"].func.isRequired,
randomId: _propTypes["default"].func.isRequired
exports.__esModule = true;
var tslib_1 = require("tslib");
var prop_types_1 = tslib_1.__importDefault(require("prop-types"));
var react_1 = tslib_1.__importStar(require("react"));
var cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
var get_1 = tslib_1.__importDefault(require("lodash/get"));
var isFunction_1 = tslib_1.__importDefault(require("lodash/isFunction"));
var isPlainObject_1 = tslib_1.__importDefault(require("lodash/isPlainObject"));
var mapValues_1 = tslib_1.__importDefault(require("lodash/mapValues"));
var omit_1 = tslib_1.__importDefault(require("lodash/omit"));
var set_1 = tslib_1.__importDefault(require("lodash/set"));
var randomIds_1 = tslib_1.__importDefault(require("./randomIds"));
var createSchemaBridge_1 = tslib_1.__importDefault(require("./createSchemaBridge"));
var changedKeys_1 = tslib_1.__importDefault(require("./changedKeys"));
exports.__childContextTypes = {
name: prop_types_1["default"].arrayOf(prop_types_1["default"].string).isRequired,
error: prop_types_1["default"].object,
model: prop_types_1["default"].object.isRequired,
schema: {
getError: prop_types_1["default"].func.isRequired,
getErrorMessage: prop_types_1["default"].func.isRequired,
getErrorMessages: prop_types_1["default"].func.isRequired,
getField: prop_types_1["default"].func.isRequired,
getInitialValue: prop_types_1["default"].func.isRequired,
getProps: prop_types_1["default"].func.isRequired,
getSubfields: prop_types_1["default"].func.isRequired,
getType: prop_types_1["default"].func.isRequired,
getValidator: prop_types_1["default"].func.isRequired
},
state: {
changed: prop_types_1["default"].bool.isRequired,
changedMap: prop_types_1["default"].object.isRequired,
submitting: prop_types_1["default"].bool.isRequired,
label: prop_types_1["default"].bool.isRequired,
disabled: prop_types_1["default"].bool.isRequired,
placeholder: prop_types_1["default"].bool.isRequired,
showInlineError: prop_types_1["default"].bool.isRequired
},
onChange: prop_types_1["default"].func.isRequired,
onSubmit: prop_types_1["default"].func.isRequired,
randomId: prop_types_1["default"].func.isRequired
};
exports.__childContextTypes = __childContextTypes;
var __childContextTypesBuild = function __childContextTypesBuild(type) {
return (0, _isPlainObject["default"])(type) ? _propTypes["default"].shape((0, _mapValues["default"])(type, __childContextTypesBuild)).isRequired : type;
exports.__childContextTypesBuild = function (type) {
return isPlainObject_1["default"](type)
? prop_types_1["default"].shape(mapValues_1["default"](type, exports.__childContextTypesBuild)).isRequired
: type;
};
exports.__childContextTypesBuild = __childContextTypesBuild;
var BaseForm =
/*#__PURE__*/
function (_Component) {
(0, _inherits2["default"])(BaseForm, _Component);
function BaseForm() {
var _this;
(0, _classCallCheck2["default"])(this, BaseForm);
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(BaseForm).apply(this, arguments));
_this.state = {
bridge: (0, _createSchemaBridge["default"])(_this.props.schema),
changed: null,
changedMap: {},
resetCount: 0,
submitting: false
var BaseForm = /** @class */ (function (_super) {
tslib_1.__extends(BaseForm, _super);
function BaseForm() {
var _this = _super.apply(this, arguments) || this;
_this.state = {
bridge: createSchemaBridge_1["default"](_this.props.schema),
changed: null,
changedMap: {},
resetCount: 0,
submitting: false
};
_this.mounted = false;
_this.randomId = randomIds_1["default"](_this.props.id);
_this.onReset = _this.reset = _this.onReset.bind(_this);
_this.onChange = _this.change = _this.onChange.bind(_this);
_this.onSubmit = _this.submit = _this.onSubmit.bind(_this);
// TODO: It shouldn't be here
var getModel = _this.getModel.bind(_this);
_this.getModel = function (mode, model) {
if (mode === void 0) { mode = null; }
if (model === void 0) { model = getModel(mode); }
return mode !== null && _this.props.modelTransform
? _this.props.modelTransform(mode, model)
: model;
};
return _this;
}
BaseForm.prototype.getChildContext = function () {
return {
uniforms: {
name: this.getChildContextName(),
error: this.getChildContextError(),
model: this.getChildContextModel(),
state: this.getChildContextState(),
schema: this.getChildContextSchema(),
onChange: this.getChildContextOnChange(),
onSubmit: this.getChildContextOnSubmit(),
randomId: this.randomId
}
};
};
_this.delayId = false;
_this.mounted = false;
_this.randomId = (0, _randomIds["default"])(_this.props.id);
_this.onReset = _this.reset = _this.onReset.bind((0, _assertThisInitialized2["default"])(_this));
_this.onChange = _this.change = _this.onChange.bind((0, _assertThisInitialized2["default"])(_this));
_this.onSubmit = _this.submit = _this.onSubmit.bind((0, _assertThisInitialized2["default"])(_this)); // TODO: It shouldn't be here
var getModel = _this.getModel.bind((0, _assertThisInitialized2["default"])(_this));
_this.getModel = function () {
var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var model = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getModel(mode);
return mode !== null && _this.props.modelTransform ? _this.props.modelTransform(mode, model) : model;
BaseForm.prototype.componentWillMount = function () {
var _this = this;
this.mounted = true;
this.setState(function () { return ({}); }, function () { return _this.setState(function () { return ({ changed: false, changedMap: {} }); }); });
};
return _this;
}
(0, _createClass2["default"])(BaseForm, [{
key: "getChildContext",
value: function getChildContext() {
return {
uniforms: {
name: this.getChildContextName(),
error: this.getChildContextError(),
model: this.getChildContextModel(),
state: this.getChildContextState(),
schema: this.getChildContextSchema(),
onChange: this.getChildContextOnChange(),
onSubmit: this.getChildContextOnSubmit(),
randomId: this.randomId
BaseForm.prototype.componentWillReceiveProps = function (_a) {
var schema = _a.schema;
if (this.props.schema !== schema) {
this.setState(function () { return ({ bridge: createSchemaBridge_1["default"](schema) }); });
}
};
}
}, {
key: "componentWillMount",
value: function componentWillMount() {
var _this2 = this;
this.mounted = true;
this.setState(function () {
return {};
}, function () {
return _this2.setState(function () {
return {
};
BaseForm.prototype.componentWillUnmount = function () {
this.mounted = false;
};
BaseForm.prototype.getChildContextName = function () {
return [];
};
BaseForm.prototype.getChildContextError = function () {
return this.props.error;
};
BaseForm.prototype.getChildContextModel = function () {
return this.getModel('form');
};
BaseForm.prototype.getChildContextState = function () {
return {
changed: !!this.state.changed,
changedMap: this.state.changedMap,
submitting: this.state.submitting,
label: !!this.props.label,
disabled: !!this.props.disabled,
placeholder: !!this.props.placeholder,
showInlineError: !!this.props.showInlineError
};
};
BaseForm.prototype.getChildContextSchema = function () {
return this.state.bridge;
};
BaseForm.prototype.getChildContextOnChange = function () {
return this.onChange;
};
BaseForm.prototype.getChildContextOnSubmit = function () {
return this.onSubmit;
};
BaseForm.prototype.getModel = function (mode) {
return this.props.model;
};
BaseForm.prototype.getChangedKeys = function (root, valueA, valueB) {
return changedKeys_1["default"](root, valueA, valueB);
};
BaseForm.prototype.getNativeFormProps = function () {
var props = omit_1["default"](this.props, [
'autosave',
'autosaveDelay',
'disabled',
'error',
'label',
'model',
'modelTransform',
'onChange',
'onSubmit',
'onSubmitFailure',
'onSubmitSuccess',
'placeholder',
'schema',
'showInlineError'
]);
return tslib_1.__assign({}, props, { onSubmit: this.onSubmit, key: "reset-" + this.state.resetCount });
};
BaseForm.prototype.onChange = function (key, value) {
var _this = this;
// Do not set `changed` before componentDidMount
if (this.state.changed !== null) {
// @ts-ignore
this.state.changed = true;
this.getChangedKeys(key, value, get_1["default"](this.getModel(), key)).forEach(function (key) {
return _this.setState(function (state) { return ({
changedMap: set_1["default"](cloneDeep_1["default"](state.changedMap), key, {})
}); });
});
}
if (this.props.onChange) {
this.props.onChange(key, value);
}
// Do not call `onSubmit` before componentDidMount
if (this.state.changed !== null && this.props.autosave) {
if (this.delayId) {
this.delayId = clearTimeout(this.delayId);
}
if (this.props.autosaveDelay > 0) {
this.delayId = setTimeout(this.onSubmit, this.props.autosaveDelay);
}
else {
this.onSubmit();
}
}
};
BaseForm.prototype.__reset = function (state) {
return {
changed: false,
changedMap: {}
};
});
});
}
}, {
key: "componentWillReceiveProps",
value: function componentWillReceiveProps(_ref) {
var schema = _ref.schema;
if (this.props.schema !== schema) {
this.setState(function () {
return {
bridge: (0, _createSchemaBridge["default"])(schema)
};
});
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
this.mounted = false;
}
}, {
key: "getChildContextName",
value: function getChildContextName() {
return [];
}
}, {
key: "getChildContextError",
value: function getChildContextError() {
return this.props.error;
}
}, {
key: "getChildContextModel",
value: function getChildContextModel() {
return this.getModel('form');
}
}, {
key: "getChildContextState",
value: function getChildContextState() {
return {
changed: !!this.state.changed,
changedMap: this.state.changedMap,
submitting: this.state.submitting,
label: !!this.props.label,
disabled: !!this.props.disabled,
placeholder: !!this.props.placeholder,
showInlineError: !!this.props.showInlineError
};
}
}, {
key: "getChildContextSchema",
value: function getChildContextSchema() {
return this.state.bridge;
}
}, {
key: "getChildContextOnChange",
value: function getChildContextOnChange() {
return this.onChange;
}
}, {
key: "getChildContextOnSubmit",
value: function getChildContextOnSubmit() {
return this.onSubmit;
}
}, {
key: "getModel",
value: function getModel()
/* mode */
{
return this.props.model;
}
}, {
key: "getChangedKeys",
value: function getChangedKeys(root, valueA, valueB) {
return (0, _changedKeys["default"])(root, valueA, valueB);
}
}, {
key: "getNativeFormProps",
value: function getNativeFormProps() {
var props = (0, _omit["default"])(this.props, ['autosave', 'autosaveDelay', 'disabled', 'error', 'label', 'model', 'modelTransform', 'onChange', 'onSubmit', 'onSubmitFailure', 'onSubmitSuccess', 'placeholder', 'schema', 'showInlineError']);
return _objectSpread({}, props, {
onSubmit: this.onSubmit,
key: "reset-".concat(this.state.resetCount)
});
}
}, {
key: "onChange",
value: function onChange(key, value) {
var _this3 = this;
// Do not set `changed` before componentDidMount
if (this.state.changed !== null) {
this.state.changed = true;
this.getChangedKeys(key, value, (0, _get["default"])(this.getModel(), key)).forEach(function (key) {
return _this3.setState(function (state) {
return {
changedMap: (0, _set["default"])((0, _cloneDeep["default"])(state.changedMap), key, {})
};
});
});
}
if (this.props.onChange) {
this.props.onChange(key, value);
} // Do not call `onSubmit` before componentDidMount
if (this.state.changed !== null && this.props.autosave) {
if (this.delayId) {
this.delayId = clearTimeout(this.delayId);
changedMap: {},
submitting: false,
resetCount: state.resetCount + 1
};
};
BaseForm.prototype.onReset = function () {
this.setState(this.__reset);
};
BaseForm.prototype.onSubmit = function (event) {
var _this = this;
if (event) {
event.preventDefault();
event.stopPropagation();
}
if (this.props.autosaveDelay > 0) {
this.delayId = setTimeout(this.onSubmit, this.props.autosaveDelay);
} else {
this.onSubmit();
var result = this.props.onSubmit && this.props.onSubmit(this.getModel('submit'));
// Set the `submitting` state only if onSubmit is async so we don't cause an unnecessary re-render
var submitting;
if (result && isFunction_1["default"](result.then)) {
this.setState({ submitting: true });
submitting = result["finally"](function () { return _this.setState({ submitting: false }); });
}
}
}
}, {
key: "__reset",
value: function __reset(state) {
return {
changed: false,
changedMap: {},
submitting: false,
resetCount: state.resetCount + 1
};
}
}, {
key: "onReset",
value: function onReset() {
this.setState(this.__reset);
}
}, {
key: "onSubmit",
value: function onSubmit(event) {
var _this4 = this;
if (event) {
event.preventDefault();
event.stopPropagation();
}
var result = this.props.onSubmit && this.props.onSubmit(this.getModel('submit')); // Set the `submitting` state only if onSubmit is async so we don't cause an unnecessary re-render
var submitting;
if (result && (0, _isFunction["default"])(result.then)) {
this.setState({
submitting: true
});
submitting = result["finally"](function () {
return _this4.setState({
submitting: false
});
});
} else {
submitting = Promise.resolve(result);
}
return submitting.then(this.props.onSubmitSuccess, this.props.onSubmitFailure);
}
}, {
key: "render",
value: function render() {
return _react["default"].createElement("form", this.getNativeFormProps());
}
}]);
return BaseForm;
}(_react.Component);
else {
submitting = Promise.resolve(result);
}
return submitting.then(this.props.onSubmitSuccess, this.props.onSubmitFailure);
};
BaseForm.prototype.render = function () {
return react_1["default"].createElement("form", tslib_1.__assign({}, this.getNativeFormProps()));
};
BaseForm.displayName = 'Form';
BaseForm.defaultProps = {
model: {},
label: true,
autosave: false,
autosaveDelay: 0,
noValidate: true
};
BaseForm.propTypes = {
error: prop_types_1["default"].object,
model: prop_types_1["default"].object,
schema: prop_types_1["default"].any.isRequired,
modelTransform: prop_types_1["default"].func,
onChange: prop_types_1["default"].func,
onSubmit: prop_types_1["default"].func,
onSubmitFailure: prop_types_1["default"].func,
onSubmitSuccess: prop_types_1["default"].func,
label: prop_types_1["default"].bool,
disabled: prop_types_1["default"].bool,
placeholder: prop_types_1["default"].bool,
showInlineError: prop_types_1["default"].bool,
autosave: prop_types_1["default"].bool,
autosaveDelay: prop_types_1["default"].number
};
BaseForm.childContextTypes = {
uniforms: exports.__childContextTypesBuild(exports.__childContextTypes)
};
return BaseForm;
}(react_1.Component));
exports["default"] = BaseForm;
BaseForm.displayName = 'Form';
BaseForm.defaultProps = {
model: {},
label: true,
autosave: false,
autosaveDelay: 0,
noValidate: true
};
BaseForm.childContextTypes = {
uniforms: __childContextTypesBuild(__childContextTypes)
};
BaseForm.propTypes = process.env.NODE_ENV !== "production" ? {
error: _propTypes["default"].object,
model: _propTypes["default"].object,
schema: _propTypes["default"].any.isRequired,
modelTransform: _propTypes["default"].func,
onChange: _propTypes["default"].func,
onSubmit: _propTypes["default"].func,
onSubmitFailure: _propTypes["default"].func,
onSubmitSuccess: _propTypes["default"].func,
label: _propTypes["default"].bool,
disabled: _propTypes["default"].bool,
placeholder: _propTypes["default"].bool,
showInlineError: _propTypes["default"].bool,
autosave: _propTypes["default"].bool,
autosaveDelay: _propTypes["default"].number
} : {};
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _invariant = _interopRequireDefault(require("invariant"));
var Bridge =
/*#__PURE__*/
function () {
function Bridge() {
(0, _classCallCheck2["default"])(this, Bridge);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
exports.__esModule = true;
var tslib_1 = require("tslib");
var invariant_1 = tslib_1.__importDefault(require("invariant"));
var Bridge = /** @class */ (function () {
function Bridge() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
invariant_1["default"](this.constructor !== Bridge, 'Bridge cannot be instantiated (args=%o).', { args: args });
}
(0, _invariant["default"])(this.constructor !== Bridge, 'Bridge cannot be instantiated (args=%o).', {
args: args
});
}
(0, _createClass2["default"])(Bridge, [{
key: "getError",
value: function getError(name, error) {
(0, _invariant["default"])(false, '%s have not implemented `getError` method (args=%o).', this.constructor.name, {
name: name,
error: error
});
}
}, {
key: "getErrorMessage",
value: function getErrorMessage(name, error) {
(0, _invariant["default"])(false, '%s have not implemented `getErrorMessage` method (args=%o).', this.constructor.name, {
name: name,
error: error
});
}
}, {
key: "getErrorMessages",
value: function getErrorMessages(error) {
(0, _invariant["default"])(false, '%s have not implemented `getErrorMessages` method (args=%o).', this.constructor.name, {
error: error
});
}
}, {
key: "getField",
value: function getField(name) {
(0, _invariant["default"])(false, '%s have not implemented `getField` method (args=%o).', this.constructor.name, {
name: name
});
}
}, {
key: "getInitialValue",
value: function getInitialValue(name, props) {
(0, _invariant["default"])(false, '%s have not implemented `getInitialValue` method (args=%o).', this.constructor.name, {
name: name,
props: props
});
}
}, {
key: "getProps",
value: function getProps(name, props) {
(0, _invariant["default"])(false, '%s have not implemented `getProps` method (args=%o).', this.constructor.name, {
name: name,
props: props
});
}
}, {
key: "getSubfields",
value: function getSubfields(name) {
(0, _invariant["default"])(false, '%s have not implemented `getSubfields` method (args=%o).', this.constructor.name, {
name: name
});
}
}, {
key: "getType",
value: function getType(name) {
(0, _invariant["default"])(false, '%s have not implemented `getType` method (args=%o).', this.constructor.name, {
name: name
});
}
}, {
key: "getValidator",
value: function getValidator(options) {
(0, _invariant["default"])(false, '%s have not implemented `getValidator` method (args=%o).', this.constructor.name, {
options: options
});
}
}], [{
key: "check",
value: function check(schema) {
(0, _invariant["default"])(false, '%s have not implemented `check` method (args=%o).', this.name, {
schema: schema
});
}
}]);
return Bridge;
}();
exports["default"] = Bridge;
Bridge.check = function (schema) {
invariant_1["default"](false, '%s have not implemented `check` method (args=%o).', this.name, { schema: schema });
};
Bridge.prototype.getError = function (name, error) {
invariant_1["default"](false, '%s have not implemented `getError` method (args=%o).', this.constructor.name, { name: name, error: error });
};
Bridge.prototype.getErrorMessage = function (name, error) {
invariant_1["default"](false, '%s have not implemented `getErrorMessage` method (args=%o).', this.constructor.name, { name: name, error: error });
};
Bridge.prototype.getErrorMessages = function (error) {
invariant_1["default"](false, '%s have not implemented `getErrorMessages` method (args=%o).', this.constructor.name, { error: error });
};
Bridge.prototype.getField = function (name) {
invariant_1["default"](false, '%s have not implemented `getField` method (args=%o).', this.constructor.name, { name: name });
};
Bridge.prototype.getInitialValue = function (name, props) {
invariant_1["default"](false, '%s have not implemented `getInitialValue` method (args=%o).', this.constructor.name, { name: name, props: props });
};
Bridge.prototype.getProps = function (name, props) {
invariant_1["default"](false, '%s have not implemented `getProps` method (args=%o).', this.constructor.name, { name: name, props: props });
};
Bridge.prototype.getSubfields = function (name) {
invariant_1["default"](false, '%s have not implemented `getSubfields` method (args=%o).', this.constructor.name, { name: name });
};
Bridge.prototype.getType = function (name) {
invariant_1["default"](false, '%s have not implemented `getType` method (args=%o).', this.constructor.name, { name: name });
};
Bridge.prototype.getValidator = function (options) {
invariant_1["default"](false, '%s have not implemented `getValidator` method (args=%o).', this.constructor.name, { options: options });
};
return Bridge;
}());
exports["default"] = Bridge;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.__esModule = true;
var tslib_1 = require("tslib");
var isEqual_1 = tslib_1.__importDefault(require("lodash/isEqual"));
var xorWith_1 = tslib_1.__importDefault(require("lodash/xorWith"));
var joinName_1 = tslib_1.__importDefault(require("./joinName"));
function changedKeys(root, valueA, valueB) {
if (!valueA || valueA !== Object(valueA) || valueA instanceof Date)
return isEqual_1["default"](valueA, valueB) ? [] : [root];
if (!valueB)
return [root].concat(Object.keys(valueA).map(function (key) { return joinName_1["default"](root, key); }));
var changed = xorWith_1["default"](Object.entries(valueA), Object.entries(valueB), isEqual_1["default"]).map(function (pair) { return joinName_1["default"](root, pair[0]); });
if (changed.length)
changed.unshift(root);
return changed;
}
exports["default"] = changedKeys;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
var _xorWith = _interopRequireDefault(require("lodash/xorWith"));
var _joinName = _interopRequireDefault(require("./joinName"));
function changedKeys(root, valueA, valueB) {
if (!valueA || valueA !== Object(valueA) || valueA instanceof Date) return (0, _isEqual["default"])(valueA, valueB) ? [] : [root];
if (!valueB) return [root].concat((0, _toConsumableArray2["default"])(Object.keys(valueA).map(function (key) {
return (0, _joinName["default"])(root, key);
})));
var changed = (0, _xorWith["default"])(Object.entries(valueA), Object.entries(valueB), _isEqual["default"]).map(function (pair) {
return (0, _joinName["default"])(root, pair[0]);
});
if (changed.length) changed.unshift(root);
return changed;
}
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.__esModule = true;
var tslib_1 = require("tslib");
var react_1 = require("react");
var BaseField_1 = tslib_1.__importDefault(require("./BaseField"));
var identity = function (x) { return x; };
function connectField(component, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.baseField, baseField = _c === void 0 ? BaseField_1["default"] : _c, _d = _b.mapProps, mapProps = _d === void 0 ? identity : _d, ensureValue = _b.ensureValue, includeInChain = _b.includeInChain, includeParent = _b.includeParent, initialValue = _b.initialValue;
var _e;
return _e = /** @class */ (function (_super) {
tslib_1.__extends(class_1, _super);
function class_1() {
var _this = _super.apply(this, arguments) || this;
_this.options.includeInChain =
includeInChain === undefined ? true : includeInChain;
_this.options.initialValue =
initialValue === undefined ? true : initialValue;
if (ensureValue !== undefined)
_this.options.ensureValue = ensureValue;
if (includeParent !== undefined)
_this.options.includeParent = includeParent;
return _this;
}
class_1.prototype.getChildContextName = function () {
return this.options.includeInChain
? _super.prototype.getChildContextName.call(this)
: this.context.uniforms.name;
};
class_1.prototype.componentWillMount = function () {
if (this.options.initialValue) {
var props = this.getFieldProps(undefined, {
ensureValue: false,
explicitInitialValue: true,
includeParent: false
});
// https://github.com/vazco/uniforms/issues/52
// If field is initially rendered with value, we treat it as an initial value.
if (this.props.value !== undefined &&
this.props.value !== props.value) {
props.onChange(this.props.value);
return;
}
if (props.required &&
props.initialValue !== undefined &&
props.value === undefined) {
props.onChange(props.initialValue);
}
}
};
class_1.prototype.render = function () {
return react_1.createElement(component, mapProps(this.getFieldProps()));
};
return class_1;
}(baseField)),
_e.displayName = "" + (component.displayName ||
component.name) + (baseField.displayName || baseField.name),
_e;
}
exports["default"] = connectField;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _react = require("react");
var _BaseField = _interopRequireDefault(require("./BaseField"));
var identity = function identity(x) {
return x;
};
function connectField(component) {
var _class, _temp;
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$baseField = _ref.baseField,
baseField = _ref$baseField === void 0 ? _BaseField["default"] : _ref$baseField,
_ref$mapProps = _ref.mapProps,
mapProps = _ref$mapProps === void 0 ? identity : _ref$mapProps,
ensureValue = _ref.ensureValue,
includeInChain = _ref.includeInChain,
includeParent = _ref.includeParent,
initialValue = _ref.initialValue;
return _temp = _class =
/*#__PURE__*/
function (_baseField) {
(0, _inherits2["default"])(_class, _baseField);
function _class() {
var _this;
(0, _classCallCheck2["default"])(this, _class);
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(_class).apply(this, arguments));
_this.options.includeInChain = includeInChain === undefined ? true : includeInChain;
_this.options.initialValue = initialValue === undefined ? true : initialValue;
if (ensureValue !== undefined) _this.options.ensureValue = ensureValue;
if (includeParent !== undefined) _this.options.includeParent = includeParent;
return _this;
}
(0, _createClass2["default"])(_class, [{
key: "getChildContextName",
value: function getChildContextName() {
return this.options.includeInChain ? (0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "getChildContextName", this).call(this) : this.context.uniforms.name;
}
}, {
key: "componentWillMount",
value: function componentWillMount() {
if (this.options.initialValue) {
var props = this.getFieldProps(undefined, {
ensureValue: false,
explicitInitialValue: true,
includeParent: false
}); // https://github.com/vazco/uniforms/issues/52
// If field is initially rendered with value, we treat it as an initial value.
if (this.props.value !== undefined && this.props.value !== props.value) {
props.onChange(this.props.value);
return;
}
if (props.required && props.initialValue !== undefined && props.value === undefined) {
props.onChange(props.initialValue);
}
}
}
}, {
key: "render",
value: function render() {
return (0, _react.createElement)(component, mapProps(this.getFieldProps()));
}
}]);
return _class;
}(baseField), _class.displayName = "".concat(component.displayName || component.name).concat(baseField.displayName || baseField.name), _temp;
}
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = createSchemaBridge;
var _invariant = _interopRequireDefault(require("invariant"));
var bridges = [];
var isBridge = function isBridge(schema) {
return schema && schema.getError && schema.getErrorMessage && schema.getErrorMessages && schema.getField && schema.getInitialValue && schema.getProps && schema.getSubfields && schema.getType && schema.getValidator;
};
function createSchemaBridge(schema) {
// There's no need for an extra wrapper.
if (isBridge(schema)) {
return schema;
}
var Bridge = bridges.find(function (bridge) {
return bridge.check(schema);
});
(0, _invariant["default"])(Bridge, 'Unrecognised schema: %s', schema);
return new Bridge(schema);
exports.__esModule = true;
var tslib_1 = require("tslib");
var invariant_1 = tslib_1.__importDefault(require("invariant"));
var registered = [];
function create(schema) {
// There's no need for an extra wrapper.
if (isBridge(schema)) {
return schema;
}
var Bridge = registered.find(function (bridge) { return bridge.check(schema); });
invariant_1["default"](Bridge, 'Unrecognised schema: %s', schema);
return new Bridge(schema);
}
createSchemaBridge.register = function (bridge) {
bridges.unshift(bridge);
};
function isBridge(schema) {
return !!(schema &&
schema.getError &&
schema.getErrorMessage &&
schema.getErrorMessages &&
schema.getField &&
schema.getInitialValue &&
schema.getProps &&
schema.getSubfields &&
schema.getType &&
schema.getValidator);
}
function register(bridge) {
registered.unshift(bridge);
}
exports["default"] = Object.assign(create, { register: register, registered: registered });
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = filterDOMProps;
var _omit = _interopRequireDefault(require("lodash/omit"));
var unwantedProps = [// These props are provided by BaseField
'changed', 'changedMap', 'disabled', 'error', 'errorMessage', 'field', 'fieldType', 'fields', 'findError', 'findField', 'findValue', 'initialCount', 'label', 'name', 'onChange', 'parent', 'placeholder', 'showInlineError', 'submitting', 'transform', 'validating', 'value', // These are used by AutoField
'allowedValues', 'component'];
function filterDOMProps(props) {
return (0, _omit["default"])(props, unwantedProps);
} // Bridges have to register additional props
filterDOMProps.register = function () {
for (var _len = arguments.length, props = new Array(_len), _key = 0; _key < _len; _key++) {
props[_key] = arguments[_key];
}
props.forEach(function (prop) {
if (unwantedProps.indexOf(prop) === -1) {
unwantedProps.push(prop);
exports.__esModule = true;
var tslib_1 = require("tslib");
var omit_1 = tslib_1.__importDefault(require("lodash/omit"));
var registered = [
// These props are provided by BaseField
'changed',
'changedMap',
'disabled',
'error',
'errorMessage',
'field',
'fieldType',
'fields',
'findError',
'findField',
'findValue',
'initialCount',
'label',
'name',
'onChange',
'parent',
'placeholder',
'showInlineError',
'submitting',
'transform',
'validating',
'value',
// These are used by AutoField
'allowedValues',
'component'
];
function filter(props) {
return omit_1["default"](props, registered);
}
function register() {
var props = [];
for (var _i = 0; _i < arguments.length; _i++) {
props[_i] = arguments[_i];
}
});
}; // It might be handy at some point
filterDOMProps.registered = unwantedProps;
props.forEach(function (prop) {
if (registered.indexOf(prop) === -1) {
registered.push(prop);
}
});
}
exports["default"] = Object.assign(filter, { register: register, registered: registered });
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "AutoForm", {
enumerable: true,
get: function get() {
return _AutoForm["default"];
}
});
Object.defineProperty(exports, "BaseField", {
enumerable: true,
get: function get() {
return _BaseField["default"];
}
});
Object.defineProperty(exports, "BaseForm", {
enumerable: true,
get: function get() {
return _BaseForm["default"];
}
});
Object.defineProperty(exports, "Bridge", {
enumerable: true,
get: function get() {
return _Bridge["default"];
}
});
Object.defineProperty(exports, "QuickForm", {
enumerable: true,
get: function get() {
return _QuickForm["default"];
}
});
Object.defineProperty(exports, "ValidatedForm", {
enumerable: true,
get: function get() {
return _ValidatedForm["default"];
}
});
Object.defineProperty(exports, "ValidatedQuickForm", {
enumerable: true,
get: function get() {
return _ValidatedQuickForm["default"];
}
});
Object.defineProperty(exports, "changedKeys", {
enumerable: true,
get: function get() {
return _changedKeys["default"];
}
});
Object.defineProperty(exports, "connectField", {
enumerable: true,
get: function get() {
return _connectField["default"];
}
});
Object.defineProperty(exports, "createSchemaBridge", {
enumerable: true,
get: function get() {
return _createSchemaBridge["default"];
}
});
Object.defineProperty(exports, "filterDOMProps", {
enumerable: true,
get: function get() {
return _filterDOMProps["default"];
}
});
Object.defineProperty(exports, "injectName", {
enumerable: true,
get: function get() {
return _injectName["default"];
}
});
Object.defineProperty(exports, "joinName", {
enumerable: true,
get: function get() {
return _joinName["default"];
}
});
Object.defineProperty(exports, "nothing", {
enumerable: true,
get: function get() {
return _nothing["default"];
}
});
Object.defineProperty(exports, "randomIds", {
enumerable: true,
get: function get() {
return _randomIds["default"];
}
});
var _AutoForm = _interopRequireDefault(require("./AutoForm"));
var _BaseField = _interopRequireDefault(require("./BaseField"));
var _BaseForm = _interopRequireDefault(require("./BaseForm"));
var _Bridge = _interopRequireDefault(require("./Bridge"));
var _QuickForm = _interopRequireDefault(require("./QuickForm"));
var _ValidatedForm = _interopRequireDefault(require("./ValidatedForm"));
var _ValidatedQuickForm = _interopRequireDefault(require("./ValidatedQuickForm"));
var _changedKeys = _interopRequireDefault(require("./changedKeys"));
var _connectField = _interopRequireDefault(require("./connectField"));
var _createSchemaBridge = _interopRequireDefault(require("./createSchemaBridge"));
var _filterDOMProps = _interopRequireDefault(require("./filterDOMProps"));
var _injectName = _interopRequireDefault(require("./injectName"));
var _joinName = _interopRequireDefault(require("./joinName"));
var _nothing = _interopRequireDefault(require("./nothing"));
var _randomIds = _interopRequireDefault(require("./randomIds"));
exports.__esModule = true;
var AutoForm_1 = require("./AutoForm");
exports.AutoForm = AutoForm_1["default"];
var BaseField_1 = require("./BaseField");
exports.BaseField = BaseField_1["default"];
var BaseForm_1 = require("./BaseForm");
exports.BaseForm = BaseForm_1["default"];
var Bridge_1 = require("./Bridge");
exports.Bridge = Bridge_1["default"];
var QuickForm_1 = require("./QuickForm");
exports.QuickForm = QuickForm_1["default"];
var ValidatedForm_1 = require("./ValidatedForm");
exports.ValidatedForm = ValidatedForm_1["default"];
var ValidatedQuickForm_1 = require("./ValidatedQuickForm");
exports.ValidatedQuickForm = ValidatedQuickForm_1["default"];
var changedKeys_1 = require("./changedKeys");
exports.changedKeys = changedKeys_1["default"];
var connectField_1 = require("./connectField");
exports.connectField = connectField_1["default"];
var createSchemaBridge_1 = require("./createSchemaBridge");
exports.createSchemaBridge = createSchemaBridge_1["default"];
var filterDOMProps_1 = require("./filterDOMProps");
exports.filterDOMProps = filterDOMProps_1["default"];
var injectName_1 = require("./injectName");
exports.injectName = injectName_1["default"];
var joinName_1 = require("./joinName");
exports.joinName = joinName_1["default"];
var nothing_1 = require("./nothing");
exports.nothing = nothing_1["default"];
var randomIds_1 = require("./randomIds");
exports.randomIds = randomIds_1["default"];
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.__esModule = true;
var tslib_1 = require("tslib");
var get_1 = tslib_1.__importDefault(require("lodash/get"));
var react_1 = require("react");
var joinName_1 = tslib_1.__importDefault(require("./joinName"));
function injectName(name, children, parent) {
return react_1.Children.map(children, function (child) {
if (!child || typeof child === 'string' || get_1["default"](parent, 'props.name'))
return child;
return react_1.cloneElement(child, {
children: injectName(name, child.props.children, child),
name: joinName_1["default"](name, child.props.name)
});
});
}
exports["default"] = injectName;
var _react = require("react");
var _joinName = _interopRequireDefault(require("./joinName"));
function injectName(name, children, parent) {
return _react.Children.map(children, function (child) {
return child && typeof child !== 'string' && (!parent || !parent.props || !parent.props.name) ? !child.props ? (0, _react.cloneElement)(child, {
name: name
}) : (0, _react.cloneElement)(child, {
name: (0, _joinName["default"])(name, child.props.name),
children: injectName(name, child.props.children, child)
}) : child;
});
}
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.__esModule = true;
function joinName() {
var parts = [];
for (var _i = 0; _i < arguments.length; _i++) {
parts[_i] = arguments[_i];
}
var name = parts.reduce(function (parts, part) {
return part || part === 0
? parts.concat(typeof part === 'string' ? part.split('.') : part)
: parts;
}, []);
return parts[0] === null ? name.map(function (part) { return '' + part; }) : name.join('.');
}
exports["default"] = joinName;
function joinName() {
for (var _len = arguments.length, parts = new Array(_len), _key = 0; _key < _len; _key++) {
parts[_key] = arguments[_key];
}
var name = parts.reduce(function (parts, part) {
return part || part === 0 ? parts.concat(typeof part === 'string' ? part.split('.') : part) : parts;
}, []);
return parts[0] === null ? name.map(function (part) {
return '' + part;
}) : name.join('.');
}
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
exports.__esModule = true;
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importDefault(require("react"));
// React < 15 workaround
// https://github.com/vazco/uniforms/issues/42
// https://github.com/facebook/react/issues/5355
var _default = parseInt(_react["default"].version, 10) < 15 ? _react["default"].createElement("noscript", null) : null;
exports["default"] = _default;
exports["default"] = parseInt(react_1["default"].version, 10) < 15 ? react_1["default"].createElement("noscript", null) : null;
{
"name": "uniforms",
"version": "2.4.1",
"version": "2.5.0",
"license": "MIT",

@@ -19,6 +19,6 @@ "main": "index.js",

"files": [
"*.d.ts",
"*.js",
"*.ts",
"*.tsx",
"src/"
"src/*.ts",
"src/*.tsx"
],

@@ -30,8 +30,8 @@ "peerDependencies": {

"dependencies": {
"@babel/runtime": "^7.0.0",
"invariant": "^2.0.0",
"lodash": "^4.0.0",
"prop-types": "^15.5.7"
"prop-types": "^15.5.7",
"tslib": "^1.0.0"
},
"gitHead": "8da4f0cc555bb66c5c55479fb24c64ca0ed37298"
"gitHead": "9faf28364bc7407d056b84d9362ac01bd9823436"
}
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _BaseForm = _interopRequireDefault(require("./BaseForm"));
var _nothing = _interopRequireDefault(require("./nothing"));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var Quick = function Quick(parent) {
var _class, _temp;
return _temp = _class =
/*#__PURE__*/
function (_parent) {
(0, _inherits2["default"])(_class, _parent);
function _class() {
(0, _classCallCheck2["default"])(this, _class);
return (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(_class).apply(this, arguments));
}
(0, _createClass2["default"])(_class, [{
key: "getNativeFormProps",
value: function getNativeFormProps() {
var _get$call = (0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "getNativeFormProps", this).call(this),
_get$call$autoField = _get$call.autoField,
AutoField = _get$call$autoField === void 0 ? this.getAutoField() : _get$call$autoField,
_get$call$errorsField = _get$call.errorsField,
ErrorsField = _get$call$errorsField === void 0 ? this.getErrorsField() : _get$call$errorsField,
_get$call$submitField = _get$call.submitField,
SubmitField = _get$call$submitField === void 0 ? this.getSubmitField() : _get$call$submitField,
props = (0, _objectWithoutProperties2["default"])(_get$call, ["autoField", "errorsField", "submitField"]);
if (!props.children) {
props.children = this.getChildContextSchema().getSubfields().map(function (key) {
return _react["default"].createElement(AutoField, {
key: key,
name: key
});
}).concat([_react["default"].createElement(ErrorsField, {
key: "$ErrorsField"
}), _react["default"].createElement(SubmitField, {
key: "$SubmitField"
})]);
exports.__esModule = true;
var tslib_1 = require("tslib");
var prop_types_1 = tslib_1.__importDefault(require("prop-types"));
var react_1 = tslib_1.__importDefault(require("react"));
var BaseForm_1 = tslib_1.__importDefault(require("./BaseForm"));
var nothing_1 = tslib_1.__importDefault(require("./nothing"));
var Quick = function (parent) { var _a; return _a = /** @class */ (function (_super) {
tslib_1.__extends(class_1, _super);
function class_1() {
return _super !== null && _super.apply(this, arguments) || this;
}
return props;
}
}, {
key: "getAutoField",
value: function getAutoField() {
return function () {
return _nothing["default"];
class_1.prototype.getNativeFormProps = function () {
var _a = _super.prototype.getNativeFormProps.call(this), _b = _a.autoField, AutoField = _b === void 0 ? this.getAutoField() : _b, _c = _a.errorsField, ErrorsField = _c === void 0 ? this.getErrorsField() : _c, _d = _a.submitField, SubmitField = _d === void 0 ? this.getSubmitField() : _d, props = tslib_1.__rest(_a, ["autoField", "errorsField", "submitField"]);
if (!props.children) {
props.children = this.getChildContextSchema()
.getSubfields()
.map(function (key) { return react_1["default"].createElement(AutoField, { key: key, name: key }); })
.concat([
react_1["default"].createElement(ErrorsField, { key: "$ErrorsField" }),
react_1["default"].createElement(SubmitField, { key: "$SubmitField" })
]);
}
return props;
};
}
}, {
key: "getErrorsField",
value: function getErrorsField() {
return function () {
return _nothing["default"];
class_1.prototype.getAutoField = function () {
return function () { return nothing_1["default"]; };
};
}
}, {
key: "getSubmitField",
value: function getSubmitField() {
return function () {
return _nothing["default"];
class_1.prototype.getErrorsField = function () {
return function () { return nothing_1["default"]; };
};
}
}]);
return _class;
}(parent), _class.Quick = Quick, _class.displayName = "Quick".concat(parent.displayName), _class.propTypes = _objectSpread({}, parent.propTypes, {
autoField: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].string]),
errorsField: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].string]),
submitField: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].string])
}), _temp;
};
var _default = Quick(_BaseForm["default"]);
exports["default"] = _default;
class_1.prototype.getSubmitField = function () {
return function () { return nothing_1["default"]; };
};
return class_1;
}(parent)),
_a.Quick = Quick,
_a.displayName = "Quick" + parent.displayName,
_a.propTypes = tslib_1.__assign({}, parent.propTypes, { autoField: prop_types_1["default"].oneOfType([prop_types_1["default"].func, prop_types_1["default"].string]), errorsField: prop_types_1["default"].oneOfType([prop_types_1["default"].func, prop_types_1["default"].string]), submitField: prop_types_1["default"].oneOfType([prop_types_1["default"].func, prop_types_1["default"].string]) }),
_a; };
exports["default"] = Quick(BaseForm_1["default"]);
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = randomIds;
exports.__esModule = true;
// Workaround for SSR

@@ -12,13 +7,10 @@ // https://github.com/vazco/uniforms/issues/40

function randomIdsGenerator(prefix) {
var counter = 0;
return function () {
return "".concat(prefix, "-").concat(('000' + (counter++).toString(36)).slice(-4));
};
var counter = 0;
return function () { return prefix + "-" + ('000' + (counter++).toString(36)).slice(-4); };
}
var randomIdPrefix = randomIdsGenerator('uniforms');
function randomIds() {
var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : randomIdPrefix();
return randomIdsGenerator(prefix);
}
function randomIds(prefix) {
if (prefix === void 0) { prefix = randomIdPrefix(); }
return randomIdsGenerator(prefix);
}
exports["default"] = randomIds;

@@ -5,17 +5,5 @@ import invariant from 'invariant';

const bridges: (typeof Bridge)[] = [];
const registered: (typeof Bridge)[] = [];
const isBridge = (schema: any): schema is Bridge =>
schema &&
schema.getError &&
schema.getErrorMessage &&
schema.getErrorMessages &&
schema.getField &&
schema.getInitialValue &&
schema.getProps &&
schema.getSubfields &&
schema.getType &&
schema.getValidator;
export default function createSchemaBridge(schema: any): Bridge {
function create(schema: any): Bridge {
// There's no need for an extra wrapper.

@@ -26,3 +14,3 @@ if (isBridge(schema)) {

const Bridge: any = bridges.find(bridge => bridge.check(schema));
const Bridge: any = registered.find(bridge => bridge.check(schema));

@@ -34,4 +22,21 @@ invariant(Bridge, 'Unrecognised schema: %s', schema);

createSchemaBridge.register = (bridge: typeof Bridge) => {
bridges.unshift(bridge);
};
function isBridge(schema: any): schema is Bridge {
return !!(
schema &&
schema.getError &&
schema.getErrorMessage &&
schema.getErrorMessages &&
schema.getField &&
schema.getInitialValue &&
schema.getProps &&
schema.getSubfields &&
schema.getType &&
schema.getValidator
);
}
function register(bridge: typeof Bridge) {
registered.unshift(bridge);
}
export default Object.assign(create, { register, registered });
import omit from 'lodash/omit';
const unwantedProps = [
const registered = [
// These props are provided by BaseField

@@ -33,16 +33,14 @@ 'changed',

export default function filterDOMProps(props: {}) {
return omit(props, unwantedProps);
function filter(props: {}) {
return omit(props, registered);
}
// Bridges have to register additional props
filterDOMProps.register = (...props: string[]) => {
function register(...props: string[]) {
props.forEach(prop => {
if (unwantedProps.indexOf(prop) === -1) {
unwantedProps.push(prop);
if (registered.indexOf(prop) === -1) {
registered.push(prop);
}
});
};
}
// It might be handy at some point
filterDOMProps.registered = unwantedProps;
export default Object.assign(filter, { register, registered });

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

import get from 'lodash/get';
import { Children, cloneElement } from 'react';

@@ -10,14 +11,11 @@

): JSX.Element[] {
return Children.map(children, child =>
child &&
typeof child !== 'string' &&
(!parent || !parent.props || !parent.props.name)
? !child.props
? cloneElement(child, { name })
: cloneElement(child, {
name: joinName(name, child.props.name),
children: injectName(name, child.props.children, child)
})
: child
);
return Children.map(children, child => {
if (!child || typeof child === 'string' || get(parent, 'props.name'))
return child;
return cloneElement(child, {
children: injectName(name, child.props.children, child),
name: joinName(name, child.props.name)
});
});
}

@@ -1,4 +0,4 @@

export default function joinName(flag: null, ...parts: unknown[]): string[];
export default function joinName(...parts: unknown[]): string;
export default function joinName(...parts: unknown[]) {
function joinName(flag: null, ...parts: unknown[]): string[];
function joinName(...parts: unknown[]): string;
function joinName(...parts: unknown[]) {
const name = parts.reduce(

@@ -14,1 +14,3 @@ (parts: unknown[], part: unknown) =>

}
export default joinName;
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
var _merge = _interopRequireDefault(require("lodash/merge"));
var _noop = _interopRequireDefault(require("lodash/noop"));
var _omit = _interopRequireDefault(require("lodash/omit"));
var _set = _interopRequireDefault(require("lodash/set"));
var _BaseForm = _interopRequireWildcard(require("./BaseForm"));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var childContextTypes = (0, _BaseForm.__childContextTypesBuild)((0, _merge["default"])({
state: {
validating: _propTypes["default"].bool.isRequired
}
}, _BaseForm.__childContextTypes));
var Validated = function Validated(parent) {
var _class, _temp;
return _temp = _class =
/*#__PURE__*/
function (_parent) {
(0, _inherits2["default"])(_class, _parent);
function _class() {
var _this;
(0, _classCallCheck2["default"])(this, _class);
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(_class).apply(this, arguments));
_this.state = _objectSpread({}, _this.state, {
error: null,
validate: false,
validating: false,
validator: _this.getChildContextSchema().getValidator(_this.props.validator)
});
_this.onValidate = _this.validate = _this.onValidate.bind((0, _assertThisInitialized2["default"])(_this));
_this.onValidateModel = _this.validateModel = _this.onValidateModel.bind((0, _assertThisInitialized2["default"])(_this));
return _this;
}
(0, _createClass2["default"])(_class, [{
key: "getChildContextError",
value: function getChildContextError() {
return (0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "getChildContextError", this).call(this) || this.state.error;
}
}, {
key: "getChildContextState",
value: function getChildContextState() {
return _objectSpread({}, (0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "getChildContextState", this).call(this), {
validating: this.state.validating
});
}
}, {
key: "getNativeFormProps",
value: function getNativeFormProps() {
return (0, _omit["default"])((0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "getNativeFormProps", this).call(this), ['onValidate', 'validate', 'validator']);
}
}, {
key: "componentWillReceiveProps",
value: function componentWillReceiveProps(_ref) {
var _this2 = this;
var model = _ref.model,
schema = _ref.schema,
validate = _ref.validate,
validator = _ref.validator;
(0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "componentWillReceiveProps", this).apply(this, arguments);
if (this.props.schema !== schema || this.props.validator !== validator) {
this.setState(function (state) {
return {
validator: state.bridge.getValidator(validator)
};
}, function () {
if (shouldRevalidate(validate, _this2.state.validate)) {
_this2.onValidate()["catch"](_noop["default"]);
}
});
} else if (!(0, _isEqual["default"])(this.props.model, model) && shouldRevalidate(validate, this.state.validate)) {
this.onValidateModel(model)["catch"](_noop["default"]);
exports.__esModule = true;
var tslib_1 = require("tslib");
var prop_types_1 = tslib_1.__importDefault(require("prop-types"));
var cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
var isEqual_1 = tslib_1.__importDefault(require("lodash/isEqual"));
var merge_1 = tslib_1.__importDefault(require("lodash/merge"));
var noop_1 = tslib_1.__importDefault(require("lodash/noop"));
var omit_1 = tslib_1.__importDefault(require("lodash/omit"));
var set_1 = tslib_1.__importDefault(require("lodash/set"));
var BaseForm_1 = tslib_1.__importStar(require("./BaseForm"));
var childContextTypes = BaseForm_1.__childContextTypesBuild(merge_1["default"]({ state: { validating: prop_types_1["default"].bool.isRequired } }, BaseForm_1.__childContextTypes));
var Validated = function (parent) { var _a; return _a = /** @class */ (function (_super) {
tslib_1.__extends(class_1, _super);
function class_1() {
var _this = _super.apply(this, arguments) || this;
// @ts-ignore
_this.state = tslib_1.__assign({}, _this.state, { error: null, validate: false, validating: false, validator: _this.getChildContextSchema().getValidator(_this.props.validator) });
_this.onValidate = _this.validate = _this.onValidate.bind(_this);
_this.onValidateModel = _this.validateModel = _this.onValidateModel.bind(_this);
return _this;
}
}
}, {
key: "onChange",
value: function onChange(key, value) {
if (shouldRevalidate(this.props.validate, this.state.validate)) {
this.onValidate(key, value)["catch"](_noop["default"]);
} // FIXME: https://github.com/vazco/uniforms/issues/293
// if (this.props.validate === 'onSubmit' && this.state.validate) {
// this.setState(() => ({error: null}));
// }
(0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "onChange", this).apply(this, arguments);
}
}, {
key: "__reset",
value: function __reset(state) {
return _objectSpread({}, (0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "__reset", this).call(this, state), {
error: null,
validate: false,
validating: false
});
}
}, {
key: "onSubmit",
value: function onSubmit(event) {
var _this3 = this;
if (event) {
event.preventDefault();
event.stopPropagation();
}
var promise = new Promise(function (resolve, reject) {
_this3.setState(function () {
return {
submitting: true,
validate: true
};
}, function () {
_this3.onValidate().then(function () {
(0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "onSubmit", _this3).call(_this3).then(resolve, function (error) {
_this3.setState({
error: error
class_1.prototype.getChildContextError = function () {
return _super.prototype.getChildContextError.call(this) || this.state.error;
};
class_1.prototype.getChildContextState = function () {
return tslib_1.__assign({}, _super.prototype.getChildContextState.call(this), { validating: this.state.validating });
};
class_1.prototype.getNativeFormProps = function () {
return omit_1["default"](_super.prototype.getNativeFormProps.call(this), [
'onValidate',
'validate',
'validator'
]);
};
class_1.prototype.componentWillReceiveProps = function (_a) {
var _this = this;
var model = _a.model, schema = _a.schema, validate = _a.validate, validator = _a.validator;
// @ts-ignore
_super.prototype.componentWillReceiveProps.apply(this, arguments);
if (this.props.schema !== schema || this.props.validator !== validator) {
this.setState(function (state) { return ({ validator: state.bridge.getValidator(validator) }); }, function () {
if (shouldRevalidate(validate, _this.state.validate)) {
_this.onValidate()["catch"](noop_1["default"]);
}
});
reject(error);
});
}, reject);
});
});
promise // `onSubmit` should never reject, so we ignore this rejection.
["catch"](_noop["default"]).then(function () {
// It can be already unmounted.
if (_this3.mounted) // If validation fails, or `super.onSubmit` doesn't touch `submitting`, we need to reset it.
_this3.setState(function (state) {
return state.submitting ? {
submitting: false
} : null;
}
else if (!isEqual_1["default"](this.props.model, model) &&
shouldRevalidate(validate, this.state.validate)) {
this.onValidateModel(model)["catch"](noop_1["default"]);
}
};
class_1.prototype.onChange = function (key, value) {
if (shouldRevalidate(this.props.validate, this.state.validate)) {
this.onValidate(key, value)["catch"](noop_1["default"]);
}
// FIXME: https://github.com/vazco/uniforms/issues/293
// if (this.props.validate === 'onSubmit' && this.state.validate) {
// this.setState(() => ({error: null}));
// }
// @ts-ignore
_super.prototype.onChange.apply(this, arguments);
};
class_1.prototype.__reset = function (state) {
return tslib_1.__assign({}, _super.prototype.__reset.call(this, state), { error: null, validate: false, validating: false });
};
class_1.prototype.onSubmit = function (event) {
var _this = this;
if (event) {
event.preventDefault();
event.stopPropagation();
}
var promise = new Promise(function (resolve, reject) {
_this.setState(function () { return ({ submitting: true, validate: true }); }, function () {
_this.onValidate().then(function () {
_super.prototype.onSubmit.call(_this).then(resolve, function (error) {
_this.setState({ error: error });
reject(error);
});
}, reject);
});
});
});
return promise;
}
}, {
key: "onValidate",
value: function onValidate(key, value) {
var model = this.getChildContextModel();
if (model && key) {
model = (0, _set["default"])((0, _cloneDeep["default"])(model), key, (0, _cloneDeep["default"])(value));
}
return this.onValidateModel(model);
}
}, {
key: "onValidateModel",
value: function onValidateModel(model) {
var _this4 = this;
model = this.getModel('validate', model);
var catched = this.props.error || null;
try {
this.state.validator(model);
} catch (error) {
catched = error;
}
this.setState({
validating: true
});
return new Promise(function (resolve, reject) {
_this4.props.onValidate(model, catched, function () {
var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : catched;
// Do not copy error from props to state.
_this4.setState(function () {
return {
error: error === _this4.props.error ? null : error,
validating: false
};
}, function () {
if (error) {
reject(error);
} else {
resolve();
}
promise["catch"](noop_1["default"])
.then(function () {
// It can be already unmounted.
if (_this.mounted)
// If validation fails, or `super.onSubmit` doesn't touch `submitting`, we need to reset it.
_this.setState(function (state) {
return state.submitting ? { submitting: false } : null;
});
});
});
});
}
}]);
return _class;
}(parent), _class.Validated = Validated, _class.displayName = "Validated".concat(parent.displayName), _class.defaultProps = _objectSpread({}, parent.defaultProps, {
onValidate: function onValidate(model, error, callback) {
callback();
},
validate: 'onChangeAfterSubmit'
}), _class.propTypes = _objectSpread({}, parent.propTypes, {
onValidate: _propTypes["default"].func.isRequired,
validator: _propTypes["default"].any,
validate: _propTypes["default"].oneOf(['onChange', 'onChangeAfterSubmit', 'onSubmit']).isRequired
}), _class.childContextTypes = _objectSpread({}, parent.childContextTypes || {}, {
uniforms: childContextTypes
}), _temp;
};
return promise;
};
class_1.prototype.onValidate = function (key, value) {
var model = this.getChildContextModel();
if (model && key) {
model = set_1["default"](cloneDeep_1["default"](model), key, cloneDeep_1["default"](value));
}
return this.onValidateModel(model);
};
class_1.prototype.onValidateModel = function (model) {
var _this = this;
model = this.getModel('validate', model);
var catched = this.props.error || null;
try {
this.state.validator(model);
}
catch (error) {
catched = error;
}
this.setState({ validating: true });
return new Promise(function (resolve, reject) {
_this.props.onValidate(model, catched, function (error) {
if (error === void 0) { error = catched; }
// Do not copy error from props to state.
_this.setState(function () { return ({
error: error === _this.props.error ? null : error,
validating: false
}); }, function () {
if (error) {
reject(error);
}
else {
resolve();
}
});
});
});
};
return class_1;
}(parent)),
_a.Validated = Validated,
_a.displayName = "Validated" + parent.displayName,
_a.defaultProps = tslib_1.__assign({}, parent.defaultProps, { onValidate: function (model, error, callback) {
callback();
}, validate: 'onChangeAfterSubmit' }),
_a.propTypes = tslib_1.__assign({}, parent.propTypes, { onValidate: prop_types_1["default"].func.isRequired, validator: prop_types_1["default"].any, validate: prop_types_1["default"].oneOf(['onChange', 'onChangeAfterSubmit', 'onSubmit'])
.isRequired }),
_a.childContextTypes = tslib_1.__assign({}, (parent.childContextTypes || {}), { uniforms: childContextTypes }),
_a; };
function shouldRevalidate(inProps, inState) {
return inProps === 'onChange' || inProps === 'onChangeAfterSubmit' && inState;
return (inProps === 'onChange' || (inProps === 'onChangeAfterSubmit' && inState));
}
var _default = Validated(_BaseForm["default"]);
exports["default"] = _default;
exports["default"] = Validated(BaseForm_1["default"]);
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _BaseForm = _interopRequireDefault(require("./BaseForm"));
var _QuickForm = _interopRequireDefault(require("./QuickForm"));
var _ValidatedForm = _interopRequireDefault(require("./ValidatedForm"));
var _default = _ValidatedForm["default"].Validated(_QuickForm["default"].Quick(_BaseForm["default"]));
exports["default"] = _default;
exports.__esModule = true;
var tslib_1 = require("tslib");
var BaseForm_1 = tslib_1.__importDefault(require("./BaseForm"));
var QuickForm_1 = tslib_1.__importDefault(require("./QuickForm"));
var ValidatedForm_1 = tslib_1.__importDefault(require("./ValidatedForm"));
exports["default"] = ValidatedForm_1["default"].Validated(QuickForm_1["default"].Quick(BaseForm_1["default"]));
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