🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@rc-component/form

Package Overview
Dependencies
Maintainers
5
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rc-component/form - npm Package Compare versions

Comparing version
1.8.1
to
1.8.2
+1
-3
es/Field.js
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import toChildrenArray from "@rc-component/util/es/Children/toArray";
import isEqual from "@rc-component/util/es/isEqual";
import warning from "@rc-component/util/es/warning";
import { isEqual, toArray as toChildrenArray, warning } from '@rc-component/util';
import * as React from 'react';

@@ -6,0 +4,0 @@ import FieldContext, { HOOK_MARK } from "./FieldContext";

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

import warning from "@rc-component/util/es/warning";
import { warning } from '@rc-component/util';
import * as React from 'react';

@@ -3,0 +3,0 @@ export const HOOK_MARK = 'RC_FORM_INTERNAL_HOOKS';

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

import { merge } from "@rc-component/util/es/utils/set";
import warning from "@rc-component/util/es/warning";
import { merge, warning } from '@rc-component/util';
import * as React from 'react';

@@ -4,0 +3,0 @@ import { HOOK_MARK } from "../FieldContext";

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

import warning from "@rc-component/util/es/warning";
import { useEvent, warning } from '@rc-component/util';
import { useContext, useEffect, useMemo, useRef, useState } from 'react';

@@ -6,3 +6,2 @@ import FieldContext, { HOOK_MARK } from "../FieldContext";

import { getNamePath, getValue } from "../utils/valueUtil";
import { useEvent } from '@rc-component/util';
export function stringify(value) {

@@ -9,0 +8,0 @@ try {

import * as React from 'react';
import type { FormRef, FormInstance } from './interface';
import type { FormRef } from './interface';
import Field from './Field';

@@ -24,3 +24,6 @@ import List from './List';

export { Field, List, useForm, FormProvider, FieldContext, ListContext, useWatch };
export type { FormProps, FormInstance, FormRef };
export type { FieldProps } from './Field';
export type { FormProviderProps } from './FormContext';
export type { FormInstance, FormRef, InternalNamePath, Meta, NamePath, Rule, RuleObject, RuleRender, Store, StoreValue, ValidateErrorEntity, ValidateMessages, ValidatorRule, } from './interface';
export type { FormProps };
export default RefForm;
import * as React from 'react';
import warning from "@rc-component/util/es/warning";
import { warning } from '@rc-component/util';
import FieldContext from "./FieldContext";

@@ -4,0 +4,0 @@ import Field from "./Field";

import { macroTask } from "../hooks/useNotifyWatch";
import raf from "@rc-component/util/es/raf";
import { raf } from '@rc-component/util';
export default async function delayFrame() {

@@ -4,0 +4,0 @@ return new Promise(resolve => {

import RawAsyncValidator from '@rc-component/async-validator';
import * as React from 'react';
import warning from "@rc-component/util/es/warning";
import { merge, warning } from '@rc-component/util';
import { defaultValidateMessages } from "./messages";
import { merge } from "@rc-component/util/es/utils/set";

@@ -7,0 +6,0 @@ // Remove incorrect original ts define

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

import getValue from '@rc-component/util/lib/utils/get';
import setValue from '@rc-component/util/lib/utils/set';
import { get as getValue, set as setValue } from '@rc-component/util';
import type { InternalNamePath, NamePath, Store, EventArgs } from '../interface';

@@ -4,0 +3,0 @@ export { getValue, setValue };

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

import getValue from "@rc-component/util/es/utils/get";
import setValue from "@rc-component/util/es/utils/set";
import { get as getValue, set as setValue } from '@rc-component/util';
import { toArray } from "./typeUtil";

@@ -4,0 +3,0 @@ export { getValue, setValue };

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

exports.default = void 0;
var _toArray = _interopRequireDefault(require("@rc-component/util/lib/Children/toArray"));
var _isEqual = _interopRequireDefault(require("@rc-component/util/lib/isEqual"));
var _warning = _interopRequireDefault(require("@rc-component/util/lib/warning"));
var _util = require("@rc-component/util");
var React = _interopRequireWildcard(require("react"));

@@ -18,5 +16,5 @@ var _FieldContext = _interopRequireWildcard(require("./FieldContext"));

var _delayUtil = _interopRequireDefault(require("./utils/delayUtil"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

@@ -168,3 +166,3 @@ const EMPTY_ERRORS = [];

};
if (!(0, _isEqual.default)(this.metaCache, meta)) {
if (!(0, _util.isEqual)(this.metaCache, meta)) {
onMetaChange(meta);

@@ -195,3 +193,3 @@ }

// `setFieldsValue` is a quick access to update related status
if (info.type === 'valueUpdate' && info.source === 'external' && !(0, _isEqual.default)(prevValue, curValue)) {
if (info.type === 'valueUpdate' && info.source === 'external' && !(0, _util.isEqual)(prevValue, curValue)) {
this.touched = true;

@@ -452,3 +450,3 @@ this.dirty = true;

// Filed element only
const childList = (0, _toArray.default)(children);
const childList = (0, _util.toArray)(children);
if (childList.length !== 1 || ! /*#__PURE__*/React.isValidElement(childList[0])) {

@@ -504,3 +502,3 @@ return {

Object.keys(valueProps).forEach(key => {
(0, _warning.default)(typeof valueProps[key] !== 'function', `It's not recommended to generate dynamic function prop by \`getValueProps\`. Please pass it to child component directly (prop: ${key})`);
(0, _util.warning)(typeof valueProps[key] !== 'function', `It's not recommended to generate dynamic function prop by \`getValueProps\`. Please pass it to child component directly (prop: ${key})`);
});

@@ -586,3 +584,3 @@ }

} else {
(0, _warning.default)(!child, '`children` of Field is not validate ReactElement.');
(0, _util.warning)(!child, '`children` of Field is not validate ReactElement.');
returnChildNode = child;

@@ -611,3 +609,3 @@ }

if (process.env.NODE_ENV !== 'production' && restProps.preserve === false && isMergedListField && namePath.length <= 1) {
(0, _warning.default)(false, '`preserve` should not apply on Form.List fields.');
(0, _util.warning)(false, '`preserve` should not apply on Form.List fields.');
}

@@ -614,0 +612,0 @@ return /*#__PURE__*/React.createElement(Field, _extends({

@@ -7,7 +7,6 @@ "use strict";

exports.default = exports.HOOK_MARK = void 0;
var _warning = _interopRequireDefault(require("@rc-component/util/lib/warning"));
var _util = require("@rc-component/util");
var React = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const HOOK_MARK = exports.HOOK_MARK = 'RC_FORM_INTERNAL_HOOKS';

@@ -17,3 +16,3 @@

const warningFunc = () => {
(0, _warning.default)(false, 'Can not find FormContext. Please make sure you wrap Field under Form.');
(0, _util.warning)(false, 'Can not find FormContext. Please make sure you wrap Field under Form.');
};

@@ -20,0 +19,0 @@ const Context = /*#__PURE__*/React.createContext({

@@ -7,4 +7,3 @@ "use strict";

exports.default = exports.FormStore = void 0;
var _set = require("@rc-component/util/lib/utils/set");
var _warning = _interopRequireDefault(require("@rc-component/util/lib/warning"));
var _util = require("@rc-component/util");
var React = _interopRequireWildcard(require("react"));

@@ -17,5 +16,5 @@ var _FieldContext = require("../FieldContext");

var _useNotifyWatch = _interopRequireDefault(require("./useNotifyWatch"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class FormStore {

@@ -75,3 +74,3 @@ formHooked = false;

}
(0, _warning.default)(false, '`getInternalHooks` is internal usage. Should not call directly.');
(0, _util.warning)(false, '`getInternalHooks` is internal usage. Should not call directly.');
return null;

@@ -95,3 +94,3 @@ };

if (init) {
let nextStore = (0, _set.merge)(initialValues, this.store);
let nextStore = (0, _util.merge)(initialValues, this.store);

@@ -129,3 +128,3 @@ // We will take consider prev form unmount fields.

// Not cloneDeep when without `namePath`
return namePath.length ? (0, _set.merge)(initValue) : initValue;
return namePath.length ? (0, _util.merge)(initValue) : initValue;
};

@@ -157,3 +156,3 @@ setCallbacks = callbacks => {

if (!this.formHooked) {
(0, _warning.default)(false, 'Instance created by `useForm` is not connected to any Form element. Forget to pass `form` prop?');
(0, _util.warning)(false, 'Instance created by `useForm` is not connected to any Form element. Forget to pass `form` prop?');
}

@@ -412,3 +411,3 @@ });

// Warning if conflict with form initialValues and do not modify value
(0, _warning.default)(false, `Form already set 'initialValues' with path '${namePath.join('.')}'. Field can not overwrite it.`);
(0, _util.warning)(false, `Form already set 'initialValues' with path '${namePath.join('.')}'. Field can not overwrite it.`);
} else {

@@ -418,3 +417,3 @@ const records = cache.get(namePath);

// Warning if multiple field set `initialValue`and do not modify value
(0, _warning.default)(false, `Multiple Field with path '${namePath.join('.')}' set 'initialValue'. Can not decide which one to pick.`);
(0, _util.warning)(false, `Multiple Field with path '${namePath.join('.')}' set 'initialValue'. Can not decide which one to pick.`);
} else if (records) {

@@ -453,3 +452,3 @@ const originValue = this.getFieldValue(namePath);

if (!nameList) {
this.updateStore((0, _set.merge)(this.initialValues));
this.updateStore((0, _util.merge)(this.initialValues));
this.resetWithFieldInitialValue();

@@ -672,3 +671,3 @@ this.notifyObservers(prevStore, null, {

if (store) {
const nextStore = (0, _set.merge)(this.store, store);
const nextStore = (0, _util.merge)(this.store, store);
this.updateStore(nextStore);

@@ -675,0 +674,0 @@ }

@@ -8,3 +8,3 @@ "use strict";

exports.stringify = stringify;
var _warning = _interopRequireDefault(require("@rc-component/util/lib/warning"));
var _util = require("@rc-component/util");
var _react = require("react");

@@ -14,6 +14,4 @@ var _FieldContext = _interopRequireWildcard(require("../FieldContext"));

var _valueUtil = require("../utils/valueUtil");
var _util = require("@rc-component/util");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function stringify(value) {

@@ -47,3 +45,3 @@ try {

if (process.env.NODE_ENV !== 'production') {
(0, _warning.default)(args.length === 2 ? form ? isValidForm : true : isValidForm, 'useWatch requires a form instance since it can not auto detect from context.');
(0, _util.warning)(args.length === 2 ? form ? isValidForm : true : isValidForm, 'useWatch requires a form instance since it can not auto detect from context.');
}

@@ -50,0 +48,0 @@

import * as React from 'react';
import type { FormRef, FormInstance } from './interface';
import type { FormRef } from './interface';
import Field from './Field';

@@ -24,3 +24,6 @@ import List from './List';

export { Field, List, useForm, FormProvider, FieldContext, ListContext, useWatch };
export type { FormProps, FormInstance, FormRef };
export type { FieldProps } from './Field';
export type { FormProviderProps } from './FormContext';
export type { FormInstance, FormRef, InternalNamePath, Meta, NamePath, Rule, RuleObject, RuleRender, Store, StoreValue, ValidateErrorEntity, ValidateMessages, ValidatorRule, } from './interface';
export type { FormProps };
export default RefForm;

@@ -8,3 +8,3 @@ "use strict";

var React = _interopRequireWildcard(require("react"));
var _warning = _interopRequireDefault(require("@rc-component/util/lib/warning"));
var _util = require("@rc-component/util");
var _FieldContext = _interopRequireDefault(require("./FieldContext"));

@@ -52,3 +52,3 @@ var _Field = _interopRequireDefault(require("./Field"));

if (typeof children !== 'function') {
(0, _warning.default)(false, 'Form.List only accepts function as children.');
(0, _util.warning)(false, 'Form.List only accepts function as children.');
return null;

@@ -99,3 +99,3 @@ }

if (process.env.NODE_ENV !== 'production' && (index < 0 || index > newValue.length)) {
(0, _warning.default)(false, 'The second parameter of the add function should be a valid positive number.');
(0, _util.warning)(false, 'The second parameter of the add function should be a valid positive number.');
}

@@ -138,3 +138,3 @@ keyManager.keys = [...keyManager.keys, keyManager.id];

if (process.env.NODE_ENV !== 'production') {
(0, _warning.default)(false, `Current value of '${prefixName.join(' > ')}' is not an array type.`);
(0, _util.warning)(false, `Current value of '${prefixName.join(' > ')}' is not an array type.`);
}

@@ -141,0 +141,0 @@ }

@@ -8,8 +8,7 @@ "use strict";

var _useNotifyWatch = require("../hooks/useNotifyWatch");
var _raf = _interopRequireDefault(require("@rc-component/util/lib/raf"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _util = require("@rc-component/util");
async function delayFrame() {
return new Promise(resolve => {
(0, _useNotifyWatch.macroTask)(() => {
(0, _raf.default)(() => {
(0, _util.raf)(() => {
resolve();

@@ -16,0 +15,0 @@ });

@@ -9,5 +9,4 @@ "use strict";

var React = _interopRequireWildcard(require("react"));
var _warning = _interopRequireDefault(require("@rc-component/util/lib/warning"));
var _util = require("@rc-component/util");
var _messages = require("./messages");
var _set = require("@rc-component/util/lib/utils/set");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }

@@ -66,3 +65,3 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }

});
const messages = (0, _set.merge)(_messages.defaultValidateMessages, options.validateMessages);
const messages = (0, _util.merge)(_messages.defaultValidateMessages, options.validateMessages);
validator.messages(messages);

@@ -136,3 +135,3 @@ let result = [];

Promise.resolve().then(() => {
(0, _warning.default)(!hasPromise, 'Your validator function has already return a promise. `callback` will be ignored.');
(0, _util.warning)(!hasPromise, 'Your validator function has already return a promise. `callback` will be ignored.');
if (!hasPromise) {

@@ -152,3 +151,3 @@ callback(...args);

*/
(0, _warning.default)(hasPromise, '`callback` is deprecated. Please return a promise instead.');
(0, _util.warning)(hasPromise, '`callback` is deprecated. Please return a promise instead.');
if (hasPromise) {

@@ -155,0 +154,0 @@ promise.then(() => {

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

import getValue from '@rc-component/util/lib/utils/get';
import setValue from '@rc-component/util/lib/utils/set';
import { get as getValue, set as setValue } from '@rc-component/util';
import type { InternalNamePath, NamePath, Store, EventArgs } from '../interface';

@@ -4,0 +3,0 @@ export { getValue, setValue };

@@ -13,3 +13,3 @@ "use strict";

get: function () {
return _get.default;
return _util.get;
}

@@ -23,9 +23,7 @@ });

get: function () {
return _set.default;
return _util.set;
}
});
var _get = _interopRequireDefault(require("@rc-component/util/lib/utils/get"));
var _set = _interopRequireDefault(require("@rc-component/util/lib/utils/set"));
var _util = require("@rc-component/util");
var _typeUtil = require("./typeUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -49,4 +47,4 @@ * Convert name to internal supported format.

namePathList.forEach(namePath => {
const value = (0, _get.default)(store, namePath);
newStore = (0, _set.default)(newStore, namePath, value);
const value = (0, _util.get)(store, namePath);
newStore = (0, _util.set)(newStore, namePath, value);
});

@@ -53,0 +51,0 @@ return newStore;

{
"name": "@rc-component/form",
"version": "1.8.1",
"version": "1.8.2",
"description": "React Form Component",

@@ -53,7 +53,7 @@ "typings": "es/index.d.ts",

"@rc-component/async-validator": "^5.1.0",
"@rc-component/util": "^1.6.2",
"@rc-component/util": "^1.11.1",
"clsx": "^2.1.1"
},
"devDependencies": {
"@rc-component/father-plugin": "^2.0.1",
"@rc-component/father-plugin": "^2.2.0",
"@rc-component/np": "^1.0.2",

@@ -60,0 +60,0 @@ "@testing-library/jest-dom": "^6.1.4",