rc-field-form
Advanced tools
Comparing version 0.0.0-alpha.6 to 0.0.0-alpha.7
import * as React from 'react'; | ||
import { FieldEntity, FormInstance, Meta, NamePath, NotifyInfo, Rule, Store, ValidateOptions, InternalFormInstance, RuleObject, StoreValue, EventArgs } from './interface'; | ||
interface ChildProps { | ||
value?: StoreValue; | ||
onChange?: (...args: EventArgs) => void; | ||
onFocus?: (...args: EventArgs) => void; | ||
onBlur?: (...args: EventArgs) => void; | ||
[name: string]: any; | ||
} | ||
@@ -26,2 +23,3 @@ export interface FieldProps { | ||
validateTrigger?: string | string[] | false; | ||
valuePropName?: string; | ||
} | ||
@@ -36,2 +34,3 @@ export interface FieldState { | ||
validateTrigger: string; | ||
valuePropName: string; | ||
}; | ||
@@ -69,6 +68,3 @@ state: { | ||
getControlled: (childProps?: ChildProps) => { | ||
value: any; | ||
onChange?: (...args: any[]) => void; | ||
onFocus?: (...args: any[]) => void; | ||
onBlur?: (...args: any[]) => void; | ||
[x: string]: any; | ||
}; | ||
@@ -75,0 +71,0 @@ render(): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)>) | (new (props: any) => React.Component<any, any, any>)> | ((control: ChildProps, meta: Meta, form: FormInstance) => React.ReactNode); |
@@ -312,3 +312,4 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
getValueFromEvent = _this$props2.getValueFromEvent, | ||
normalize = _this$props2.normalize; | ||
normalize = _this$props2.normalize, | ||
valuePropName = _this$props2.valuePropName; | ||
@@ -329,5 +330,3 @@ var namePath = _this.getNamePath(); | ||
var control = _objectSpread({}, childProps, { | ||
value: value | ||
}); // Add trigger | ||
var control = _objectSpread({}, childProps, _defineProperty({}, valuePropName, value)); // Add trigger | ||
@@ -338,4 +337,14 @@ | ||
_this.touched = true; | ||
var newValue = (getValueFromEvent || defaultGetValueFromEvent).apply(void 0, arguments); | ||
var newValue; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
if (getValueFromEvent) { | ||
newValue = getValueFromEvent.apply(void 0, args); | ||
} else { | ||
newValue = defaultGetValueFromEvent.apply(void 0, [valuePropName].concat(args)); | ||
} | ||
if (normalize) { | ||
@@ -352,3 +361,3 @@ newValue = normalize(newValue, value, getFieldsValue()); | ||
if (originTriggerFunc) { | ||
originTriggerFunc.apply(void 0, arguments); | ||
originTriggerFunc.apply(void 0, args); | ||
} | ||
@@ -445,4 +454,5 @@ }; // Add validateTrigger | ||
trigger: 'onChange', | ||
validateTrigger: 'onChange' | ||
validateTrigger: 'onChange', | ||
valuePropName: 'value' | ||
}; | ||
export default Field; |
@@ -202,3 +202,3 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
return false; | ||
return isAllFieldsTouched; | ||
}; | ||
@@ -205,0 +205,0 @@ |
@@ -18,3 +18,3 @@ import { InternalNamePath, NamePath, Store, StoreValue, EventArgs } from '../interface'; | ||
export declare function isSimilar(source: SimilarObject, target: SimilarObject): boolean; | ||
export declare function defaultGetValueFromEvent(...args: EventArgs): any; | ||
export declare function defaultGetValueFromEvent(valuePropName: string, ...args: EventArgs): any; | ||
export {}; |
@@ -122,7 +122,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
} | ||
export function defaultGetValueFromEvent() { | ||
var event = arguments.length <= 0 ? undefined : arguments[0]; | ||
export function defaultGetValueFromEvent(valuePropName) { | ||
var event = arguments.length <= 1 ? undefined : arguments[1]; | ||
if (event && event.target && 'value' in event.target) { | ||
return event.target.value; | ||
if (event && event.target && valuePropName in event.target) { | ||
return event.target[valuePropName]; | ||
} | ||
@@ -129,0 +129,0 @@ |
import * as React from 'react'; | ||
import { FieldEntity, FormInstance, Meta, NamePath, NotifyInfo, Rule, Store, ValidateOptions, InternalFormInstance, RuleObject, StoreValue, EventArgs } from './interface'; | ||
interface ChildProps { | ||
value?: StoreValue; | ||
onChange?: (...args: EventArgs) => void; | ||
onFocus?: (...args: EventArgs) => void; | ||
onBlur?: (...args: EventArgs) => void; | ||
[name: string]: any; | ||
} | ||
@@ -26,2 +23,3 @@ export interface FieldProps { | ||
validateTrigger?: string | string[] | false; | ||
valuePropName?: string; | ||
} | ||
@@ -36,2 +34,3 @@ export interface FieldState { | ||
validateTrigger: string; | ||
valuePropName: string; | ||
}; | ||
@@ -69,6 +68,3 @@ state: { | ||
getControlled: (childProps?: ChildProps) => { | ||
value: any; | ||
onChange?: (...args: any[]) => void; | ||
onFocus?: (...args: any[]) => void; | ||
onBlur?: (...args: any[]) => void; | ||
[x: string]: any; | ||
}; | ||
@@ -75,0 +71,0 @@ render(): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)>) | (new (props: any) => React.Component<any, any, any>)> | ((control: ChildProps, meta: Meta, form: FormInstance) => React.ReactNode); |
@@ -329,3 +329,4 @@ "use strict"; | ||
getValueFromEvent = _this$props2.getValueFromEvent, | ||
normalize = _this$props2.normalize; | ||
normalize = _this$props2.normalize, | ||
valuePropName = _this$props2.valuePropName; | ||
@@ -346,5 +347,3 @@ var namePath = _this.getNamePath(); | ||
var control = _objectSpread({}, childProps, { | ||
value: value | ||
}); // Add trigger | ||
var control = _objectSpread({}, childProps, _defineProperty({}, valuePropName, value)); // Add trigger | ||
@@ -355,5 +354,14 @@ | ||
_this.touched = true; | ||
var newValue; | ||
var newValue = (getValueFromEvent || _valueUtil.defaultGetValueFromEvent).apply(void 0, arguments); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
if (getValueFromEvent) { | ||
newValue = getValueFromEvent.apply(void 0, args); | ||
} else { | ||
newValue = _valueUtil.defaultGetValueFromEvent.apply(void 0, [valuePropName].concat(args)); | ||
} | ||
if (normalize) { | ||
@@ -370,3 +378,3 @@ newValue = normalize(newValue, value, getFieldsValue()); | ||
if (originTriggerFunc) { | ||
originTriggerFunc.apply(void 0, arguments); | ||
originTriggerFunc.apply(void 0, args); | ||
} | ||
@@ -463,5 +471,6 @@ }; // Add validateTrigger | ||
trigger: 'onChange', | ||
validateTrigger: 'onChange' | ||
validateTrigger: 'onChange', | ||
valuePropName: 'value' | ||
}; | ||
var _default = Field; | ||
exports.default = _default; |
@@ -221,3 +221,3 @@ "use strict"; | ||
return false; | ||
return isAllFieldsTouched; | ||
}; | ||
@@ -224,0 +224,0 @@ |
@@ -18,3 +18,3 @@ import { InternalNamePath, NamePath, Store, StoreValue, EventArgs } from '../interface'; | ||
export declare function isSimilar(source: SimilarObject, target: SimilarObject): boolean; | ||
export declare function defaultGetValueFromEvent(...args: EventArgs): any; | ||
export declare function defaultGetValueFromEvent(valuePropName: string, ...args: EventArgs): any; | ||
export {}; |
@@ -148,7 +148,7 @@ "use strict"; | ||
function defaultGetValueFromEvent() { | ||
var event = arguments.length <= 0 ? undefined : arguments[0]; | ||
function defaultGetValueFromEvent(valuePropName) { | ||
var event = arguments.length <= 1 ? undefined : arguments[1]; | ||
if (event && event.target && 'value' in event.target) { | ||
return event.target.value; | ||
if (event && event.target && valuePropName in event.target) { | ||
return event.target[valuePropName]; | ||
} | ||
@@ -155,0 +155,0 @@ |
{ | ||
"name": "rc-field-form", | ||
"version": "0.0.0-alpha.6", | ||
"version": "0.0.0-alpha.7", | ||
"description": "React Form Component", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -76,12 +76,13 @@ # rc-field-form | ||
| Prop | Description | Type | Default | | ||
| ----------------- | --------------------------------------- | -------------------------------------------- | -------- | | ||
| dependencies | Will re-render if dependencies changed | [NamePath](#namepath)[] | - | | ||
| getValueFromEvent | Specify how to get value from event | (..args: any[]) => any | - | | ||
| name | Field name path | [NamePath](#namepath) | - | | ||
| normalize | Normalize value before update | (value, prevValue, prevValues) => any | - | | ||
| rules | Validate rules | [Rule](#rule)[] | - | | ||
| Prop | Description | Type | Default | | ||
| ----------------- | --------------------------------------- | ----------------------------------------- | -------- | | ||
| dependencies | Will re-render if dependencies changed | [NamePath](#namepath)[] | - | | ||
| getValueFromEvent | Specify how to get value from event | (..args: any[]) => any | - | | ||
| name | Field name path | [NamePath](#namepath) | - | | ||
| normalize | Normalize value before update | (value, prevValue, prevValues) => any | - | | ||
| rules | Validate rules | [Rule](#rule)[] | - | | ||
| shouldUpdate | Check if Field should update | true \| (prevValues, nextValues): boolean | - | | ||
| trigger | Collect value update by event trigger | string | onChange | | ||
| validateTrigger | Config trigger point with rule validate | string \| string[] | onChange | | ||
| trigger | Collect value update by event trigger | string | onChange | | ||
| validateTrigger | Config trigger point with rule validate | string \| string[] | onChange | | ||
| valuePropName | Config value mapping prop with element | string | value | | ||
@@ -88,0 +89,0 @@ ## List |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
197520
4246
274