@altiore/form
Advanced tools
Comparing version 0.3.27 to 0.3.28
import { MouseEventHandler, MutableRefObject } from 'react'; | ||
export declare type NamedFieldProps<T, R extends string> = Omit<T, R> & { | ||
fieldArrayState: FieldArrayState; | ||
formState: FormContextState; | ||
providedName: string; | ||
}; | ||
export declare enum InsertPosition { | ||
BEFORE = 0, | ||
AFTER = 1 | ||
} | ||
export interface ListItem { | ||
@@ -3,0 +12,0 @@ key: string; |
@@ -1,1 +0,5 @@ | ||
export {}; | ||
export var InsertPosition; | ||
(function (InsertPosition) { | ||
InsertPosition[InsertPosition["BEFORE"] = 0] = "BEFORE"; | ||
InsertPosition[InsertPosition["AFTER"] = 1] = "AFTER"; | ||
})(InsertPosition || (InsertPosition = {})); |
@@ -1,7 +0,3 @@ | ||
import { ValidateFuncType } from '../@common/types'; | ||
import { InternalFieldArrayProps } from './validated-field-array'; | ||
export declare type FieldArrayProps = { | ||
name: string; | ||
validators?: Array<ValidateFuncType>; | ||
}; | ||
import { InternalFieldArrayProps } from './named-field-array'; | ||
import { FieldArrayProps } from './types/field-array-props'; | ||
/** | ||
@@ -12,3 +8,3 @@ * Создает массив полей | ||
* | ||
* @param {string} имя поля | ||
* @param component | ||
* | ||
@@ -15,0 +11,0 @@ * @typedef createFieldArray |
@@ -1,12 +0,1 @@ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -23,16 +12,6 @@ var t = {}; | ||
}; | ||
import React, { useMemo } from 'react'; | ||
import React from 'react'; | ||
import { FieldArrayContext } from '../@common/field-array-context'; | ||
import { FormContext } from '../@common/form-context'; | ||
import { useRegisterField } from '../@common/hooks/use-register-field'; | ||
import FieldArray from './validated-field-array'; | ||
var NamedField = function (_a) { | ||
var fieldArrayState = _a.fieldArrayState, formState = _a.formState, providedName = _a.providedName, rest = __rest(_a, ["fieldArrayState", "formState", "providedName"]); | ||
var _b = useRegisterField(fieldArrayState, formState, providedName, true), field = _b.field, isInsideForm = _b.isInsideForm, name = _b.name; | ||
var setItems = useMemo(function () { return formState === null || formState === void 0 ? void 0 : formState.setItems; }, [formState === null || formState === void 0 ? void 0 : formState.setItems]); | ||
if (isInsideForm && !field) { | ||
return null; | ||
} | ||
return React.createElement(FieldArray, __assign({}, rest, { field: field, setItems: setItems, name: name })); | ||
}; | ||
import NamedFieldArray from './named-field-array'; | ||
/** | ||
@@ -43,3 +22,3 @@ * Создает массив полей | ||
* | ||
* @param {string} имя поля | ||
* @param component | ||
* | ||
@@ -88,5 +67,5 @@ * @typedef createFieldArray | ||
return (React.createElement(FormContext.Consumer, null, function (formState) { return (React.createElement(FieldArrayContext.Consumer, null, function (fieldArrayState) { | ||
return (React.createElement(NamedField, { fieldArrayState: fieldArrayState, formState: formState, component: component, componentProps: props, providedName: name, validators: validators })); | ||
return (React.createElement(NamedFieldArray, { fieldArrayState: fieldArrayState, formState: formState, component: component, componentProps: props, providedName: name, validators: validators })); | ||
})); })); | ||
}); | ||
}; |
@@ -5,3 +5,3 @@ import React from 'react'; | ||
import { createFieldArray } from './create-field-array'; | ||
import Field from '../create-field/field'; | ||
import Field from '../stories/field'; | ||
describe('~/create-field-array', function () { | ||
@@ -8,0 +8,0 @@ describe('не перерендеривать, если рендерится родитель, но пропсы не меняются', function () { |
export * from './create-field-array'; | ||
export type { FieldArrayProps } from './types'; |
import { FieldMeta, ValidateFuncType } from '../@common/types'; | ||
import { InternalFieldProps } from './validated-field'; | ||
import { InternalFieldProps } from './named-field'; | ||
export declare type FieldProps = { | ||
@@ -4,0 +4,0 @@ name: string; |
@@ -1,12 +0,1 @@ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -26,12 +15,3 @@ var t = {}; | ||
import { FormContext } from '../@common/form-context'; | ||
import { useRegisterField } from '../@common/hooks/use-register-field'; | ||
import ValidatedField from './validated-field'; | ||
var NamedField = function (_a) { | ||
var fieldArrayState = _a.fieldArrayState, formState = _a.formState, providedName = _a.providedName, rest = __rest(_a, ["fieldArrayState", "formState", "providedName"]); | ||
var _b = useRegisterField(fieldArrayState, formState, providedName), field = _b.field, isInsideForm = _b.isInsideForm, name = _b.name; | ||
if (isInsideForm && !field) { | ||
return null; | ||
} | ||
return React.createElement(ValidatedField, __assign({}, rest, { field: field, name: name })); | ||
}; | ||
import NamedField from './named-field'; | ||
/** | ||
@@ -38,0 +18,0 @@ * createField принимает пользовательский компонент и возвращает {name, validators, ...props} |
@@ -1,7 +0,2 @@ | ||
import { ReactNode } from 'react'; | ||
export interface FormProps<Values extends Record<string, any>> { | ||
children: ReactNode; | ||
defaultValues?: Partial<Values>; | ||
onSubmit: (values: Partial<Values>) => void; | ||
} | ||
import { FormProps } from './types'; | ||
/** | ||
@@ -8,0 +3,0 @@ * Компонент Form принимает children, defaultValues, onSubmit |
@@ -12,3 +12,3 @@ var __assign = (this && this.__assign) || function () { | ||
}; | ||
import React, { useCallback, useRef, useState, } from 'react'; | ||
import React, { useCallback, useRef, useState } from 'react'; | ||
import cloneDeep from 'lodash/cloneDeep'; | ||
@@ -15,0 +15,0 @@ import get from 'lodash/get'; |
export * from './form'; | ||
export type { FormProps } from './types'; |
{ | ||
"name": "@altiore/form", | ||
"version": "0.3.27", | ||
"version": "0.3.28", | ||
"description": "Form helper for building powerful forms", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
65245
133
1353
1