@weareconceptstudio/form 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ export default Checkbox;
2
+ declare function Checkbox(props: any): React.JSX.Element;
3
+ declare namespace Checkbox {
4
+ let displayName: string;
5
+ }
6
+ import React from 'react';
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import BaseCheckbox from './BaseCheckbox';
3
+ import classNames from 'classnames';
4
+ import { useInput } from '../form/hooks/useInput';
5
+ const Checkbox = (props) => {
6
+ const { type = 'checkbox', prefixCls = 'checkbox', children, value, ...restProps } = props;
7
+ const { field } = useInput({
8
+ type,
9
+ name: props.name,
10
+ });
11
+ const checkboxProps = {
12
+ ...field,
13
+ // checked: field.value.includes(value),
14
+ ...restProps,
15
+ };
16
+ const classString = classNames(`${prefixCls}-wrapper`, {
17
+ [`${prefixCls}-wrapper-checked`]: checkboxProps.checked,
18
+ [`${prefixCls}-wrapper-disabled`]: checkboxProps.disabled,
19
+ });
20
+ return (React.createElement("label", { className: classString },
21
+ React.createElement(BaseCheckbox, { ...checkboxProps }),
22
+ children !== undefined && React.createElement("span", { className: `${prefixCls}-content` }, children)));
23
+ };
24
+ if (process.env.NODE_ENV !== 'production') {
25
+ Checkbox.displayName = 'Checkbox';
26
+ }
27
+ export default Checkbox;
@@ -0,0 +1,3 @@
1
+ export default CheckboxGroup;
2
+ declare function CheckboxGroup(props: any): React.JSX.Element;
3
+ import React from 'react';
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import classNames from 'classnames';
3
+ import Checkbox from './Checkbox';
4
+ import { CheckboxGroupContextProvider } from './context';
5
+ const CheckboxGroup = (props) => {
6
+ const { name, className, children, options, ...restProps } = props;
7
+ let childrenNode = options.length
8
+ ? options.map((option) => (React.createElement(Checkbox, { key: option.value.toString(), value: option.value, onChange: option.onChange, name: 'checkbox_group' }, option.label)))
9
+ : children;
10
+ const classString = classNames('checkbox-group', {
11
+ [className]: className,
12
+ });
13
+ return (React.createElement("div", { className: classString },
14
+ React.createElement(CheckboxGroupContextProvider, null, childrenNode)));
15
+ };
16
+ export default CheckboxGroup;
@@ -0,0 +1,6 @@
1
+ export const CheckboxGroupContextProvider: React.Provider<any>;
2
+ export default CheckboxGroupContext;
3
+ export const CheckboxOptionTypeContext: React.Context<any>;
4
+ export const CheckboxOptionTypeContextProvider: React.Provider<any>;
5
+ import React from 'react';
6
+ declare const CheckboxGroupContext: React.Context<any>;
@@ -0,0 +1,6 @@
1
+ import React, { createContext } from 'react';
2
+ const CheckboxGroupContext = createContext(null);
3
+ export const CheckboxGroupContextProvider = CheckboxGroupContext.Provider;
4
+ export default CheckboxGroupContext;
5
+ export const CheckboxOptionTypeContext = createContext(null);
6
+ export const CheckboxOptionTypeContextProvider = CheckboxOptionTypeContext.Provider;
@@ -1,3 +1,2 @@
1
1
  export default Checkbox;
2
- declare const Checkbox: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
3
- import React from 'react';
2
+ import Checkbox from './Checkbox';
@@ -1,21 +1,4 @@
1
- import React, { forwardRef } from 'react';
2
- import BaseCheckbox from './BaseCheckbox';
3
- import classNames from 'classnames';
4
- const Checkbox = forwardRef((props, forwardRef) => {
5
- const { type = 'checkbox', prefixCls = 'checkbox', children, ...restProps } = props;
6
- const checkboxProps = {
7
- ref: forwardRef,
8
- ...restProps,
9
- };
10
- const classString = classNames(`${prefixCls}-wrapper`, {
11
- [`${prefixCls}-wrapper-checked`]: checkboxProps.checked,
12
- [`${prefixCls}-wrapper-disabled`]: checkboxProps.disabled,
13
- });
14
- return (React.createElement("label", { className: classString },
15
- React.createElement(BaseCheckbox, { ...checkboxProps }),
16
- children !== undefined && React.createElement("span", { className: `${prefixCls}-content` }, children)));
17
- });
18
- if (process.env.NODE_ENV !== 'production') {
19
- Checkbox.displayName = 'Checkbox';
20
- }
1
+ import Checkbox from './Checkbox';
2
+ import CheckboxGroup from './Group';
3
+ Checkbox.Group = CheckboxGroup;
21
4
  export default Checkbox;
@@ -17,7 +17,7 @@ interface BaseFormProps<T extends FieldValues> {
17
17
  className?: string;
18
18
  }
19
19
  declare const BaseForm: {
20
- <T extends FieldValues>({ initialValues: defaultValues, values, children, onSubmit: onFinish, mode, reValidateMode, errors, resetOptions, criteriaMode, shouldFocusError, delayError, shouldUseNativeValidation, shouldUnregister, className, }: BaseFormProps<T>): React.JSX.Element;
20
+ <T extends FieldValues>({ initialValues: defaultValues, values, children, onSubmit, mode, reValidateMode, errors, resetOptions, criteriaMode, shouldFocusError, delayError, shouldUseNativeValidation, shouldUnregister, className, }: BaseFormProps<T>): React.JSX.Element;
21
21
  displayName: string;
22
22
  };
23
23
  export default BaseForm;
@@ -2,7 +2,7 @@ import React, { useCallback } from 'react';
2
2
  import { FormProvider, useForm } from 'react-hook-form';
3
3
  import { Text } from '@weareconceptstudio/core';
4
4
  import classNames from 'classnames';
5
- const BaseForm = ({ initialValues: defaultValues, values, children, onSubmit: onFinish, mode = 'onChange', reValidateMode = 'onChange', errors, resetOptions, criteriaMode, shouldFocusError, delayError = 0, shouldUseNativeValidation, shouldUnregister, className, }) => {
5
+ const BaseForm = ({ initialValues: defaultValues, values, children, onSubmit, mode = 'onChange', reValidateMode = 'onChange', errors, resetOptions, criteriaMode = 'firstError', shouldFocusError, delayError = 0, shouldUseNativeValidation, shouldUnregister, className, }) => {
6
6
  const methods = useForm({
7
7
  mode,
8
8
  errors,
@@ -17,8 +17,8 @@ const BaseForm = ({ initialValues: defaultValues, values, children, onSubmit: on
17
17
  shouldUnregister,
18
18
  shouldUseNativeValidation,
19
19
  });
20
- const onSubmit = useCallback((values) => {
21
- return onFinish(values).catch(({ data, status, ...err }) => {
20
+ const handleSubmit = useCallback(async (values) => {
21
+ return await onSubmit(values)?.catch(({ data, status }) => {
22
22
  if (status === 422) {
23
23
  for (const key in data.errors) {
24
24
  if (data.errors.hasOwnProperty(key)) {
@@ -37,12 +37,12 @@ const BaseForm = ({ initialValues: defaultValues, values, children, onSubmit: on
37
37
  });
38
38
  }
39
39
  });
40
- }, [methods, onFinish]);
40
+ }, [methods, onSubmit]);
41
41
  return (React.createElement(FormProvider, { ...methods },
42
42
  methods.formState.errors.root?.serverError && (React.createElement("div", { className: "global-error-wrap" },
43
43
  React.createElement(Text, { className: 'backend-error', text: methods.formState.errors.root?.serverError.message }),
44
44
  React.createElement(Text, { className: 'frontend-error', text: 'globalError' }))),
45
- React.createElement("form", { onSubmit: methods.handleSubmit(onSubmit), className: classNames({
45
+ React.createElement("form", { onSubmit: methods.handleSubmit(handleSubmit), className: classNames({
46
46
  [className]: !!className,
47
47
  }) }, children)));
48
48
  };
@@ -1,3 +1,11 @@
1
- export function validationPatterns(type: any, pattern: any): any;
1
+ export function validationPatterns({ type, pattern, message, translate }: {
2
+ type: any;
3
+ pattern: any;
4
+ message: any;
5
+ translate: any;
6
+ }): {
7
+ value: any;
8
+ message: any;
9
+ };
2
10
  export function useRules(props: any): any[];
3
11
  export function mapValidationRules(errorKey: any, rules: any): any;
@@ -1,13 +1,13 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { useTranslation } from '@weareconceptstudio/core';
3
- export const validationPatterns = (type, pattern) => {
3
+ export const validationPatterns = ({ type, pattern, message, translate }) => {
4
4
  switch (type) {
5
5
  case 'email':
6
- return /^[^\s@]+@[^\s@]+\.[^\s@]+$/g;
6
+ return { value: /^[^\s@]+@[^\s@]+\.[^\s@]+$/g, message: message || translate('validateMessages.email') };
7
7
  case 'number':
8
- return /[0-9]/g;
8
+ return { value: /[0-9]/g, message };
9
9
  default:
10
- return pattern;
10
+ return { value: pattern, message };
11
11
  }
12
12
  };
13
13
  export const useRules = (props) => {
@@ -16,9 +16,14 @@ export const useRules = (props) => {
16
16
  if (props.required) {
17
17
  r.unshift({ required: true, message: props.requiredMessage });
18
18
  }
19
+ // TODO: Whitespace
20
+ // validator: (value) => {
21
+ // return !!value.trim();
22
+ // },
19
23
  return r;
20
24
  }, [props]);
21
25
  };
26
+ // TODO: rule messages from translations
22
27
  export const mapValidationRules = (errorKey, rules) => {
23
28
  const { translate } = useTranslation();
24
29
  return rules?.reduce((acc, rule) => {
@@ -26,7 +31,7 @@ export const mapValidationRules = (errorKey, rules) => {
26
31
  acc.required = rule.message || translate('validateMessages.required', { errorKey: translate(errorKey) });
27
32
  }
28
33
  if (rule.pattern || rule.type) {
29
- acc.pattern = { value: validationPatterns(rule.type, rule.pattern), message: rule.message || 'Invalid format' };
34
+ acc.pattern = validationPatterns({ ...rule, translate });
30
35
  }
31
36
  if (rule.minLength) {
32
37
  acc.minLength = { value: rule.minLength, message: rule.message || `Minimum length is ${rule.minLength}` };
@@ -36,7 +41,7 @@ export const mapValidationRules = (errorKey, rules) => {
36
41
  }
37
42
  if (rule.validator) {
38
43
  acc.validate = async (value) => {
39
- return (await rule.validator(value)) || rule.message || 'Validation failed';
44
+ return (await rule.validator(value)) || rule.message;
40
45
  };
41
46
  }
42
47
  return acc;
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- export * from "./FormConfig";
2
- export { default as Form } from "./form";
3
- export { default as FormBuilder } from "./form/Builder";
4
- export { default as ErrorMessage } from "./error-message";
5
- export { default as Input } from "./input";
6
- export { default as Checkbox } from "./checkbox";
7
- export { default as ColorPicker } from "./color-picker";
8
- export { default as DatePicker } from "./date-picker";
9
- export { default as Radio } from "./radio";
10
- export { default as Select } from "./select";
11
- export { default as Upload } from "./upload";
12
- export { default as PhoneNumber } from "./phone-number";
1
+ export * from './FormConfig';
2
+ export { default as Form } from './form';
3
+ export { default as FormBuilder } from './form/Builder';
4
+ export { default as ErrorMessage } from './error-message';
5
+ export { default as Input } from './input';
6
+ export { default as Checkbox } from './checkbox';
7
+ export { default as ColorPicker } from './color-picker';
8
+ export { default as DatePicker } from './date-picker';
9
+ export { default as Radio } from './radio';
10
+ export { default as Select } from './select';
11
+ export { default as Upload } from './upload';
12
+ export { default as PhoneNumber } from './phone-number';
@@ -1,7 +1,8 @@
1
1
  export default PhoneNumber;
2
- declare function PhoneNumber({ name, className, autoComplete }: {
2
+ declare function PhoneNumber({ name, className, autoComplete, options }: {
3
3
  name: any;
4
4
  className: any;
5
5
  autoComplete?: string;
6
+ options?: {};
6
7
  }): React.JSX.Element;
7
8
  import React from 'react';
@@ -2,12 +2,11 @@ import React from 'react';
2
2
  import classNames from 'classnames';
3
3
  import Input from 'react-phone-number-input/react-hook-form-input';
4
4
  import useFormInstance from '../form/hooks/useFormInstance';
5
- const PhoneNumber = ({ name, className, autoComplete = 'new-password' }) => {
5
+ const PhoneNumber = ({ name, className, autoComplete = 'new-password', options = {} }) => {
6
6
  const { control } = useFormInstance();
7
- //! ClassName
8
7
  const classString = classNames('phone-number-input', {
9
8
  [className]: className,
10
9
  });
11
- return (React.createElement(Input, { name: name, country: 'AM', international: true, maxLength: 14, control: control, withCountryCallingCode: true, className: classString, autoComplete: autoComplete }));
10
+ return (React.createElement(Input, { name: name, country: 'AM', international: true, maxLength: 14, control: control, withCountryCallingCode: true, className: classString, autoComplete: autoComplete, ...options }));
12
11
  };
13
12
  export default PhoneNumber;
@@ -1,3 +1,10 @@
1
- export default Radio;
2
- declare const Radio: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
1
+ export default BaseRadio;
2
+ declare function BaseRadio({ prefixCls, children, ...props }: {
3
+ [x: string]: any;
4
+ prefixCls?: string;
5
+ children: any;
6
+ }): React.JSX.Element;
7
+ declare namespace BaseRadio {
8
+ let displayName: string;
9
+ }
3
10
  import React from 'react';
@@ -1,19 +1,17 @@
1
- import React, { forwardRef, useContext } from 'react';
1
+ import React, { useContext } from 'react';
2
2
  import RadioGroupContext from './context';
3
3
  import classNames from 'classnames';
4
4
  import BaseCheckbox from '../checkbox/BaseCheckbox';
5
- const Radio = forwardRef(({ prefixCls = 'radio', children, ...props }, forwardRef) => {
5
+ const BaseRadio = ({ prefixCls = 'radio', children, ...props }) => {
6
6
  const groupContext = useContext(RadioGroupContext);
7
7
  const onChange = (e) => {
8
8
  props.onChange?.(e);
9
9
  groupContext?.onChange?.(e);
10
10
  };
11
11
  const radioProps = {
12
- ref: forwardRef,
13
12
  ...props,
14
13
  };
15
14
  if (groupContext) {
16
- radioProps.ref = groupContext.forwardRef;
17
15
  radioProps.checked = props.value === groupContext.value;
18
16
  radioProps.onChange = onChange;
19
17
  }
@@ -24,8 +22,8 @@ const Radio = forwardRef(({ prefixCls = 'radio', children, ...props }, forwardRe
24
22
  return (React.createElement("label", { className: wrapperClassString },
25
23
  React.createElement(BaseCheckbox, { type: 'radio', prefixCls: prefixCls, ...radioProps }),
26
24
  children !== undefined && React.createElement("span", { className: `${prefixCls}-content` }, children)));
27
- });
25
+ };
28
26
  if (process.env.NODE_ENV !== 'production') {
29
- Radio.displayName = 'Radio';
27
+ BaseRadio.displayName = 'BaseRadio';
30
28
  }
31
- export default Radio;
29
+ export default BaseRadio;
@@ -1,3 +1,3 @@
1
1
  export default RadioGroup;
2
- declare const RadioGroup: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
2
+ declare function RadioGroup(props: any): React.JSX.Element;
3
3
  import React from 'react';
@@ -1,40 +1,24 @@
1
- import React, { forwardRef } from 'react';
2
- import { useMergedState } from '@weareconceptstudio/core';
1
+ import React from 'react';
2
+ import classNames from 'classnames';
3
+ import { useInput } from '../form/hooks/useInput';
3
4
  import { RadioGroupContextProvider } from './context';
4
- import Radio from './BaseRadio';
5
- const RadioGroup = forwardRef((props, forwardRef) => {
6
- const [value, setValue] = useMergedState(props.defaultValue, {
7
- value: props.value,
8
- });
9
- const onRadioChange = (ev) => {
10
- const lastValue = value;
11
- const val = ev.target.value;
12
- if (!('value' in props)) {
13
- setValue(val);
14
- }
15
- const { onChange } = props;
16
- if (onChange && val !== lastValue) {
17
- onChange(ev);
18
- }
19
- };
20
- const { children, options } = props;
5
+ import BaseRadio from './BaseRadio';
6
+ const RadioGroup = (props) => {
7
+ const { field } = useInput(props);
8
+ const { className, children, options } = props;
21
9
  let childrenToRender = children;
22
10
  if (options && options.length > 0) {
23
11
  childrenToRender = options.map((option) => {
24
12
  if (typeof option === 'string' || typeof option === 'number') {
25
- return (React.createElement(Radio, { key: option.toString(), value: option }, option));
13
+ return (React.createElement(BaseRadio, { key: option.toString(), value: option }, option));
26
14
  }
27
- return (React.createElement(Radio, { key: `radio-group-value-options-${option.value}`, value: option.value }, option.label));
15
+ return (React.createElement(BaseRadio, { key: `radio-group-value-options-${option.value}`, value: option.value }, option.label));
28
16
  });
29
17
  }
30
- return (React.createElement("div", { className: 'radio-group' },
31
- React.createElement(RadioGroupContextProvider, { value: {
32
- onChange: onRadioChange,
33
- forwardRef: forwardRef,
34
- value,
35
- } }, childrenToRender)));
36
- });
37
- if (process.env.NODE_ENV !== 'production') {
38
- RadioGroup.displayName = 'RadioGroup';
39
- }
18
+ const classString = classNames('radio-group', {
19
+ [className]: className,
20
+ });
21
+ return (React.createElement("div", { className: classString },
22
+ React.createElement(RadioGroupContextProvider, { value: field }, childrenToRender)));
23
+ };
40
24
  export default RadioGroup;
@@ -1,2 +1,7 @@
1
1
  export default Radio;
2
- declare const Radio: import("react").ForwardRefExoticComponent<import("react").RefAttributes<any>>;
2
+ declare function Radio({ prefixCls, children, ...props }: {
3
+ [x: string]: any;
4
+ prefixCls?: string;
5
+ children: any;
6
+ }): import("react").JSX.Element;
7
+ declare namespace Radio { }
@@ -14,7 +14,7 @@ const Select = (props) => {
14
14
  const [val, setVal] = useState(value);
15
15
  selectProps = {
16
16
  onChange: (e) => {
17
- onChange && onChange(e.value);
17
+ onChange?.(e.value);
18
18
  setVal(e.value);
19
19
  },
20
20
  value: val,
@@ -4,6 +4,7 @@ declare const _default: {
4
4
  validateMessages: {
5
5
  default: string;
6
6
  required: string;
7
+ email: string;
7
8
  enum: string;
8
9
  whitespace: string;
9
10
  date: {
@@ -11,21 +12,6 @@ declare const _default: {
11
12
  parse: string;
12
13
  invalid: string;
13
14
  };
14
- types: {
15
- string: string;
16
- method: string;
17
- array: string;
18
- object: string;
19
- number: string;
20
- date: string;
21
- boolean: string;
22
- integer: string;
23
- float: string;
24
- regexp: string;
25
- email: string;
26
- url: string;
27
- hex: string;
28
- };
29
15
  string: {
30
16
  len: string;
31
17
  min: string;
@@ -1,10 +1,10 @@
1
- const typeTemplate = '{errorKey} is not a valid {type}';
2
1
  export default {
3
2
  serverError: 'Ups! there is something wrong with the website administration.',
4
3
  globalError: 'Please double-check the required fields and confirm again.',
5
4
  validateMessages: {
6
5
  default: 'Validation error on field {errorKey}',
7
6
  required: 'Please enter your {errorKey}',
7
+ email: 'Please enter a valid email address',
8
8
  enum: '{errorKey} must be one of [{enum}]',
9
9
  whitespace: '{errorKey} cannot be empty',
10
10
  date: {
@@ -12,21 +12,6 @@ export default {
12
12
  parse: '{errorKey} could not be parsed as date',
13
13
  invalid: '{errorKey} is invalid date',
14
14
  },
15
- types: {
16
- string: typeTemplate,
17
- method: typeTemplate,
18
- array: typeTemplate,
19
- object: typeTemplate,
20
- number: typeTemplate,
21
- date: typeTemplate,
22
- boolean: typeTemplate,
23
- integer: typeTemplate,
24
- float: typeTemplate,
25
- regexp: typeTemplate,
26
- email: typeTemplate,
27
- url: typeTemplate,
28
- hex: typeTemplate,
29
- },
30
15
  string: {
31
16
  len: '{errorKey} must be exactly {len} characters',
32
17
  min: '{errorKey} must be at least {min} characters',
@@ -0,0 +1,38 @@
1
+ declare const _default: {
2
+ serverError: string;
3
+ globalError: string;
4
+ validateMessages: {
5
+ default: string;
6
+ required: string;
7
+ email: string;
8
+ enum: string;
9
+ whitespace: string;
10
+ date: {
11
+ format: string;
12
+ parse: string;
13
+ invalid: string;
14
+ };
15
+ string: {
16
+ len: string;
17
+ min: string;
18
+ max: string;
19
+ range: string;
20
+ };
21
+ number: {
22
+ len: string;
23
+ min: string;
24
+ max: string;
25
+ range: string;
26
+ };
27
+ array: {
28
+ len: string;
29
+ min: string;
30
+ max: string;
31
+ range: string;
32
+ };
33
+ pattern: {
34
+ mismatch: string;
35
+ };
36
+ };
37
+ };
38
+ export default _default;
@@ -0,0 +1,37 @@
1
+ export default {
2
+ serverError: 'Ողջույն! Կայքի ադմինիստրացիայում խնդիր կա:',
3
+ globalError: 'Խնդրում ենք կրկին ստուգել պահանջվող դաշտերը և հաստատել:',
4
+ validateMessages: {
5
+ default: 'Դաշտի {errorKey}-ի համար վավերացման սխալ',
6
+ required: 'Խնդրում ենք մուտքագրել ձեր {errorKey}-ը',
7
+ email: 'Խնդրում ենք մուտքագրել վավեր էլ. հասցե:',
8
+ enum: '{errorKey}-ը պետք է լինի [{enum}] արժեքներից մեկը',
9
+ whitespace: '{errorKey}-ը չի կարող դատարկ լինել',
10
+ date: {
11
+ format: '{errorKey}-ի ֆորմատը անվավեր է',
12
+ parse: '{errorKey}-ը չի կարող անցնել որպես ամսաթիվ',
13
+ invalid: '{errorKey}-ը անվավեր ամսաթիվ է',
14
+ },
15
+ string: {
16
+ len: '{errorKey}-ը պետք է լինի ճիշտ {len} նիշ',
17
+ min: '{errorKey}-ը պետք է լինի առնվազն {min} նիշ',
18
+ max: '{errorKey}-ը չի կարող լինել {max} նիշից երկար',
19
+ range: '{errorKey}-ը պետք է լինի {min} և {max} նիշերի միջև',
20
+ },
21
+ number: {
22
+ len: '{errorKey}-ը պետք է հավասար լինի {len}-ին',
23
+ min: '{errorKey}-ը չի կարող լինել {min}-ից պակաս',
24
+ max: '{errorKey}-ը չի կարող լինել {max}-ից ավելին',
25
+ range: '{errorKey}-ը պետք է լինի {min} և {max} միջև',
26
+ },
27
+ array: {
28
+ len: '{errorKey}-ը պետք է լինի ճիշտ {len} երկարություն',
29
+ min: '{errorKey}-ը չի կարող լինել {min}-ից պակաս երկարությամբ',
30
+ max: '{errorKey}-ը չի կարող լինել {max}-ից ավել երկարությամբ',
31
+ range: '{errorKey}-ը պետք է լինի {min} և {max} երկարության միջև',
32
+ },
33
+ pattern: {
34
+ mismatch: '{errorKey}-ը չի համապատասխանում {pattern} օրինաչափությանը',
35
+ },
36
+ },
37
+ };
@@ -5,6 +5,7 @@ declare const _default: {
5
5
  validateMessages: {
6
6
  default: string;
7
7
  required: string;
8
+ email: string;
8
9
  enum: string;
9
10
  whitespace: string;
10
11
  date: {
@@ -12,20 +13,79 @@ declare const _default: {
12
13
  parse: string;
13
14
  invalid: string;
14
15
  };
15
- types: {
16
- string: string;
17
- method: string;
18
- array: string;
19
- object: string;
20
- number: string;
21
- date: string;
22
- boolean: string;
23
- integer: string;
24
- float: string;
25
- regexp: string;
26
- email: string;
27
- url: string;
28
- hex: string;
16
+ string: {
17
+ len: string;
18
+ min: string;
19
+ max: string;
20
+ range: string;
21
+ };
22
+ number: {
23
+ len: string;
24
+ min: string;
25
+ max: string;
26
+ range: string;
27
+ };
28
+ array: {
29
+ len: string;
30
+ min: string;
31
+ max: string;
32
+ range: string;
33
+ };
34
+ pattern: {
35
+ mismatch: string;
36
+ };
37
+ };
38
+ };
39
+ hy: {
40
+ serverError: string;
41
+ globalError: string;
42
+ validateMessages: {
43
+ default: string;
44
+ required: string;
45
+ email: string;
46
+ enum: string;
47
+ whitespace: string;
48
+ date: {
49
+ format: string;
50
+ parse: string;
51
+ invalid: string;
52
+ };
53
+ string: {
54
+ len: string;
55
+ min: string;
56
+ max: string;
57
+ range: string;
58
+ };
59
+ number: {
60
+ len: string;
61
+ min: string;
62
+ max: string;
63
+ range: string;
64
+ };
65
+ array: {
66
+ len: string;
67
+ min: string;
68
+ max: string;
69
+ range: string;
70
+ };
71
+ pattern: {
72
+ mismatch: string;
73
+ };
74
+ };
75
+ };
76
+ ru: {
77
+ serverError: string;
78
+ globalError: string;
79
+ validateMessages: {
80
+ default: string;
81
+ required: string;
82
+ email: string;
83
+ enum: string;
84
+ whitespace: string;
85
+ date: {
86
+ format: string;
87
+ parse: string;
88
+ invalid: string;
29
89
  };
30
90
  string: {
31
91
  len: string;
@@ -1,2 +1,4 @@
1
1
  import en from './en';
2
- export default { en };
2
+ import hy from './hy';
3
+ import ru from './ru';
4
+ export default { en, hy, ru };
@@ -0,0 +1,38 @@
1
+ declare const _default: {
2
+ serverError: string;
3
+ globalError: string;
4
+ validateMessages: {
5
+ default: string;
6
+ required: string;
7
+ email: string;
8
+ enum: string;
9
+ whitespace: string;
10
+ date: {
11
+ format: string;
12
+ parse: string;
13
+ invalid: string;
14
+ };
15
+ string: {
16
+ len: string;
17
+ min: string;
18
+ max: string;
19
+ range: string;
20
+ };
21
+ number: {
22
+ len: string;
23
+ min: string;
24
+ max: string;
25
+ range: string;
26
+ };
27
+ array: {
28
+ len: string;
29
+ min: string;
30
+ max: string;
31
+ range: string;
32
+ };
33
+ pattern: {
34
+ mismatch: string;
35
+ };
36
+ };
37
+ };
38
+ export default _default;
@@ -0,0 +1,37 @@
1
+ export default {
2
+ serverError: 'Упс! Возникла проблема с администрированием сайта.',
3
+ globalError: 'Пожалуйста, проверьте обязательные поля и подтвердите еще раз.',
4
+ validateMessages: {
5
+ default: 'Ошибка валидации для поля {errorKey}',
6
+ required: 'Пожалуйста, введите ваш {errorKey}',
7
+ email: 'Пожалуйста, введите действительный адрес электронной почты.',
8
+ enum: '{errorKey} должен быть одним из [{enum}]',
9
+ whitespace: '{errorKey} не может быть пустым',
10
+ date: {
11
+ format: '{errorKey} имеет недопустимый формат даты',
12
+ parse: '{errorKey} не удалось преобразовать в дату',
13
+ invalid: '{errorKey} является недопустимой датой',
14
+ },
15
+ string: {
16
+ len: '{errorKey} должен содержать ровно {len} символов',
17
+ min: '{errorKey} должен содержать как минимум {min} символов',
18
+ max: '{errorKey} не может содержать больше {max} символов',
19
+ range: '{errorKey} должен содержать от {min} до {max} символов',
20
+ },
21
+ number: {
22
+ len: '{errorKey} должен быть равен {len}',
23
+ min: '{errorKey} не может быть меньше {min}',
24
+ max: '{errorKey} не может быть больше {max}',
25
+ range: '{errorKey} должен быть между {min} и {max}',
26
+ },
27
+ array: {
28
+ len: '{errorKey} должен содержать ровно {len} элементов',
29
+ min: '{errorKey} не может содержать менее {min} элементов',
30
+ max: '{errorKey} не может содержать более {max} элементов',
31
+ range: '{errorKey} должен содержать от {min} до {max} элементов',
32
+ },
33
+ pattern: {
34
+ mismatch: '{errorKey} не соответствует шаблону {pattern}',
35
+ },
36
+ },
37
+ };
@@ -0,0 +1,5 @@
1
+ export interface FormField {
2
+ fieldType: 'input' | 'password' | 'textarea' | 'number' | 'checkbox' | 'radio' | 'phone' | 'select' | 'upload' | 'date' | 'color';
3
+ labelProps: any;
4
+ fieldProps: any;
5
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weareconceptstudio/form",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Concept Studio Form",
5
5
  "author": "Concept Studio",
6
6
  "license": "ISC",