@itcase/forms 1.1.33 → 1.1.34

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.
@@ -1,4 +1,3 @@
1
-
2
1
  .form-field {
3
2
  &-checkbox {
4
3
  ^&__message {
@@ -26,10 +26,4 @@
26
26
  }
27
27
 
28
28
  :root {
29
- --radio-success-border: var(--color-success-border-primary);
30
- --radio-success-border-hover: var(--color-surface-border-quaternary);
31
- --radio-error-border: var(--color-error-border-primary);
32
- --radio-focus-background: var(--color-surface-primary);
33
- --radio-focus-border: var(--color-surface-border-quaternary);
34
- --form-filed-radio-size-m-gap: 4px;
35
29
  }
@@ -386,8 +386,8 @@ function FieldWrapperBase(props) {
386
386
  sizeMobile: labelTextSizeMobile,
387
387
  sizeTablet: labelTextSizeTablet
388
388
  }, label, labelHidden && '\u00A0')), desc && /*#__PURE__*/React__default.default.createElement("div", {
389
- className: "form-field__desc",
390
- dataTestId: `${inputName}FieldDesc`
389
+ dataTestId: `${inputName}FieldDesc`,
390
+ className: "form-field__desc"
391
391
  }, /*#__PURE__*/React__default.default.createElement(Text.Text, {
392
392
  size: descTextSize,
393
393
  textColor: descTextColor,
@@ -1573,6 +1573,7 @@ function FormFieldDatePicker(props) {
1573
1573
  errorKey,
1574
1574
  errorMessage,
1575
1575
  isErrorState,
1576
+ successKey,
1576
1577
  isValidState
1577
1578
  } = useFieldValidationState({
1578
1579
  fieldProps: fieldProps,
@@ -1581,7 +1582,7 @@ function FormFieldDatePicker(props) {
1581
1582
  });
1582
1583
  const updatedInputProps = useValidationAppearanceInputProps({
1583
1584
  inputProps: inputProps,
1584
- validationStateKey: isErrorState ? errorKey : 'success'
1585
+ validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
1585
1586
  });
1586
1587
  return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
1587
1588
  className: clsx__default.default('form-field_datepicker', 'form__item_datepicker', classNameGroupItem),
@@ -2292,75 +2293,13 @@ const defaultRadioProps = {
2292
2293
  appearance: 'defaultPrimary sizeM solid circular'
2293
2294
  };
2294
2295
 
2295
- function RadioGroupInput(props) {
2296
- const {
2297
- input,
2298
- value,
2299
- onChange
2300
- } = props;
2301
- const onChangeField = React.useCallback(event => onChange(event.target.value), [onChange]);
2302
- return /*#__PURE__*/React__default.default.createElement(Input.Input, Object.assign({
2303
- name: input.name,
2304
- autoComplete: "nope",
2305
- value: value,
2306
- onBlur: input.onBlur,
2307
- onChange: onChangeField,
2308
- onFocus: input.onFocus
2309
- }, props));
2310
- }
2311
-
2312
- function RadioGroupItem(props) {
2313
- const {
2314
- input,
2315
- inputProps,
2316
- option,
2317
- onChange
2318
- } = props;
2319
- const onChangeField = React.useCallback(event => {
2320
- if (event.target.checked) {
2321
- onChange(option.value);
2322
- }
2323
- }, [onChange]);
2324
- return /*#__PURE__*/React__default.default.createElement(Radio.Radio, Object.assign({
2325
- className: "form-radio__item",
2326
- type: "radio",
2327
- name: input.name,
2328
- label: option.label,
2329
- checked: option.value === input.value,
2330
- value: option.value,
2331
- onBlur: input.onBlur,
2332
- onChange: onChangeField,
2333
- onFocus: input.onFocus
2334
- }, inputProps));
2335
- }
2336
-
2337
2296
  function RadioGroupList(props) {
2338
2297
  const {
2339
- editableProps,
2340
2298
  input,
2341
2299
  inputProps,
2342
2300
  options,
2343
2301
  onChange
2344
2302
  } = props;
2345
- const [editableValue, setEditableValue] = React.useState(() => {
2346
- const isRadioValue = options.find(option => option.value === input.value);
2347
- if (!isRadioValue) {
2348
- return input.value;
2349
- }
2350
- return '';
2351
- });
2352
- React.useEffect(() => {
2353
- // When a new value from outside enters the form
2354
- if (input.value) {
2355
- // Check value for radio type
2356
- const isRadioValue = options.find(option => option.value === input.value && !option.editable);
2357
- // If new value not in radio list - set to editable input
2358
- setEditableValue(isRadioValue ? '' : input.value);
2359
- } else {
2360
- // If new value is empty - clear editable input
2361
- setEditableValue('');
2362
- }
2363
- }, [input.value]);
2364
2303
 
2365
2304
  // Callback for value changes
2366
2305
  const onChangeSomeInput = React.useCallback(value => {
@@ -2373,31 +2312,23 @@ function RadioGroupList(props) {
2373
2312
  }, [input, onChange]);
2374
2313
 
2375
2314
  // Handle for radio inputs
2376
- const onChangeRadio = React.useCallback(value => {
2377
- setEditableValue('');
2378
- onChangeSomeInput(value);
2379
- }, [onChangeSomeInput]);
2380
-
2381
- // Handle for text input
2382
- const onChangeEditable = React.useCallback(value => {
2383
- setEditableValue(value);
2384
- onChangeSomeInput(value);
2385
- }, [onChangeSomeInput]);
2386
- return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, options.map(option => option.editable ? /*#__PURE__*/React__default.default.createElement(RadioGroupInput, {
2387
- key: option.label,
2388
- editableProps: editableProps,
2389
- input: input,
2390
- inputProps: inputProps,
2391
- option: option,
2392
- value: editableValue,
2393
- onChange: onChangeEditable
2394
- }) : /*#__PURE__*/React__default.default.createElement(RadioGroupItem, {
2315
+ const onChangeRadio = React.useCallback(event => {
2316
+ if (event.target.checked) {
2317
+ onChangeSomeInput(event.target.value);
2318
+ }
2319
+ }, [onChange]);
2320
+ return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, options.map(option => /*#__PURE__*/React__default.default.createElement(Radio.Radio, Object.assign({
2321
+ className: "form-radio__item",
2395
2322
  key: option.value,
2396
- input: input,
2397
- inputProps: inputProps,
2398
- option: option,
2399
- onChange: onChangeRadio
2400
- })));
2323
+ type: "radio",
2324
+ name: input.name,
2325
+ label: option.label,
2326
+ checked: option.value === input.value,
2327
+ value: option.value,
2328
+ onBlur: input.onBlur,
2329
+ onChange: onChangeRadio,
2330
+ onFocus: input.onFocus
2331
+ }, inputProps))));
2401
2332
  }
2402
2333
 
2403
2334
  const RadioGroup = /*#__PURE__*/React__default.default.memo(function RadioGroup(props) {
@@ -2466,6 +2397,7 @@ const RadioGroup = /*#__PURE__*/React__default.default.memo(function RadioGroup(
2466
2397
  });
2467
2398
 
2468
2399
  const formTypes = {
2400
+ password: 'password',
2469
2401
  code: 'code',
2470
2402
  text: 'text',
2471
2403
  textarea: 'textarea',
@@ -2485,6 +2417,12 @@ const formTypes = {
2485
2417
  };
2486
2418
  function generateField(field, config, props) {
2487
2419
  switch (field.type) {
2420
+ case formTypes.password:
2421
+ {
2422
+ return /*#__PURE__*/React__default.default.createElement(FormFieldPassword, Object.assign({
2423
+ key: config.key
2424
+ }, field, props));
2425
+ }
2488
2426
  case formTypes.checkbox:
2489
2427
  {
2490
2428
  return /*#__PURE__*/React__default.default.createElement(FormFieldCheckbox, Object.assign({
@@ -2497,15 +2435,15 @@ function generateField(field, config, props) {
2497
2435
  key: config.key
2498
2436
  }, field, props));
2499
2437
  }
2500
- case formTypes.chips:
2438
+ case formTypes.code:
2501
2439
  {
2502
- return /*#__PURE__*/React__default.default.createElement(FormFieldChips, Object.assign({
2440
+ return /*#__PURE__*/React__default.default.createElement(FormFieldCode, Object.assign({
2503
2441
  key: config.key
2504
2442
  }, field, props));
2505
2443
  }
2506
- case formTypes.code:
2444
+ case formTypes.chips:
2507
2445
  {
2508
- return /*#__PURE__*/React__default.default.createElement(FormFieldCode, Object.assign({
2446
+ return /*#__PURE__*/React__default.default.createElement(FormFieldChips, Object.assign({
2509
2447
  key: config.key
2510
2448
  }, field, props));
2511
2449
  }
@@ -2551,12 +2489,6 @@ function generateField(field, config, props) {
2551
2489
  key: config.key
2552
2490
  }, field, props));
2553
2491
  }
2554
- case formTypes.password:
2555
- {
2556
- return /*#__PURE__*/React__default.default.createElement(FormFieldPassword, Object.assign({
2557
- key: config.key
2558
- }, field, props));
2559
- }
2560
2492
  case formTypes.textarea:
2561
2493
  {
2562
2494
  return /*#__PURE__*/React__default.default.createElement(FormFieldTextarea, Object.assign({
@@ -2793,6 +2725,7 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2793
2725
  onChangeFormValues,
2794
2726
  onSubmit
2795
2727
  } = props;
2728
+ console.log(buttonJustifyContent);
2796
2729
  const validate = useYupValidationSchema(validationSchema, language);
2797
2730
  const onRefFormInstance = React.useCallback(formInstance => {
2798
2731
  if (ref) {
@@ -2945,116 +2878,152 @@ FinalForm.defaultProps = {
2945
2878
  direction: 'vertical'
2946
2879
  };
2947
2880
 
2948
- const DEFAULT_MESSAGES_FIELDS = {
2949
- /*
2950
- !!! it also works without props simply based on the class and key as before `input_state_${meta.error.key}`
2951
- the KEY is needed for example for border color
2952
- the name of the key is anything you want, the main thing is that there is a props with the same KEY and color in FieldProps
2881
+ const DEFAULT_MESSAGES_REQUIRED = {
2882
+ required: {
2883
+ key: 'required',
2884
+ message: 'Обязательное поле'
2885
+ }
2886
+ };
2887
+ const DEFAULT_MESSAGES_ERROR = {
2888
+ invalid_value: {
2889
+ key: 'error',
2890
+ message: 'Некорректное значение'
2891
+ }
2892
+ };
2893
+ const DEFAULT_MESSAGES_URL = {
2894
+ url: {
2895
+ key: 'error',
2896
+ message: 'Введите корректный URL-адрес'
2897
+ }
2898
+ };
2899
+ const DEFAULT_MESSAGES_PASSWORD = {
2900
+ password_required: {
2901
+ key: 'required',
2902
+ message: 'Введите пароль'
2903
+ }
2904
+ };
2905
+ const DEFAULT_MESSAGES_NUMBER = {
2906
+ matches: {
2907
+ key: 'error',
2908
+ message: 'Допускается ввод только цифр от 0 до 9'
2909
+ },
2910
+ numeric_value: {
2911
+ key: 'error',
2912
+ message: 'Только числовое значение'
2913
+ }
2914
+ };
2915
+ const DEFAULT_MESSAGES_MIN_MAX = {
2916
+ min: {
2917
+ key: 'error',
2918
+ message: ({
2919
+ min
2920
+ }) => `Значение должно быть не менее ${min} символов`
2921
+ },
2922
+ max: {
2923
+ key: 'error',
2924
+ message: ({
2925
+ max
2926
+ }) => `Значение должно быть не менее ${max} символов`
2927
+ }
2928
+ };
2929
+ const DEFAULT_MESSAGES_PHONE = {
2930
+ phone_error: {
2931
+ key: 'error',
2932
+ message: 'Введите корректный номер телефона'
2933
+ },
2934
+ phone_or_email_required: {
2935
+ key: 'required',
2936
+ message: 'Введите телефон или адрес эл. почты'
2937
+ },
2938
+ phone_required: {
2939
+ key: 'required',
2940
+ message: 'Укажите номер телефона'
2941
+ }
2942
+ };
2943
+ const DEFAULT_MESSAGES_EMAIL = {
2944
+ email_error: {
2945
+ key: 'error',
2946
+ message: 'Введите корректный адрес электронной почты'
2947
+ },
2948
+ email_required: {
2949
+ key: 'required',
2950
+ message: 'Укажите адрес электронной почты'
2951
+ }
2952
+ };
2953
+
2954
+ /*
2955
+
2956
+ !!! It also works without props simply based on the class and key as before `input_state_${meta.error.key}`
2957
+
2958
+ The KEY is needed for example for border color
2959
+
2960
+ The name of the key is anything you want, the main thing is that there is a props with the same KEY and color in FieldProps
2953
2961
  ...example
2954
- required - KEY for yellow color
2962
+
2963
+ required - KEY for yellow color
2955
2964
  error - KEY for red color
2956
2965
  custom or blue - KEY blue or other color
2957
- requiredBorderColor: 'warningBorderPrimary',
2966
+
2967
+ requiredBorderColor: 'warningBorderPrimary',
2958
2968
  errorBorderColor: 'errorBorderPrimary',
2959
2969
  customBorderColor: 'customBorderPrimary',
2960
2970
  blueBorderColor: 'blueBorderPrimary',
2961
- const defaultFieldProps = {
2962
- messageTextSize: 's',
2971
+
2972
+ const defaultFieldProps = {
2973
+
2974
+ messageTextSize: 's',
2963
2975
  messageTextColor: 'surfaceTextSecondary',
2964
- requiredMessageTextSize: 's',
2976
+
2977
+ requiredMessageTextSize: 's',
2965
2978
  requiredMessageTextColor: 'warningTextPrimary',
2966
- errorMessageTextSize: 's',
2979
+
2980
+ errorMessageTextSize: 's',
2967
2981
  errorMessageTextColor: 'errorTextPrimary',
2968
2982
  }
2969
- // INPUT
2983
+
2984
+ // INPUT
2970
2985
  const defaultInputProps = {
2971
2986
  ... other
2972
- stateBorderColor: 'surfaceBorderTertiary',
2987
+
2988
+ stateBorderColor: 'surfaceBorderTertiary',
2973
2989
  requiredStateBorderColor: 'warningBorderPrimary',
2974
2990
  errorStateBorderColor: 'errorBorderPrimary',
2975
2991
  }
2976
- // RADIO
2992
+
2993
+ // RADIO
2977
2994
  const defaultRadioProps = {
2978
2995
  ... other
2979
- stateBorderColor: 'surfaceBorderTertiary',
2996
+
2997
+ stateBorderColor: 'surfaceBorderTertiary',
2980
2998
  requiredStateBorderColor: 'warningBorderPrimary',
2981
2999
  errorStateBorderColor: 'errorBorderPrimary',
2982
3000
  }
2983
- // SELECT
3001
+
3002
+ // SELECT
2984
3003
  const defaultSelectProps = {
2985
3004
  ... other
2986
- borderColor: 'surfaceBorderTertiary',
3005
+
3006
+ borderColor: 'surfaceBorderTertiary',
2987
3007
  requiredBorderColor: 'warningBorderPrimary',
2988
3008
  errorBorderColor: 'errorBorderPrimary',
2989
- inputBorderColor: 'surfaceBorderTertiary',
3009
+
3010
+ inputBorderColor: 'surfaceBorderTertiary',
2990
3011
  requiredInputBorderColor: 'warningBorderPrimary',
2991
3012
  errorInputBorderColor: 'errorBorderPrimary',
2992
3013
  }
2993
- ... etc
2994
- */
2995
3014
 
2996
- // DEFAULT
2997
- // required - KEY for yellow color
2998
- // error - KEY for red color
3015
+ ... etc
3016
+ */
2999
3017
 
3000
- min: {
3001
- key: 'error',
3002
- message: ({
3003
- min
3004
- }) => `Значение должно быть не менее ${min} символов`
3005
- },
3006
- max: {
3007
- key: 'error',
3008
- message: ({
3009
- max
3010
- }) => `Значение должно быть не менее ${max} символов`
3011
- },
3012
- url: {
3013
- key: 'error',
3014
- message: 'Введите корректный URL-адрес'
3015
- },
3016
- email_error: {
3017
- key: 'error',
3018
- message: 'Введите корректный адрес электронной почты'
3019
- },
3020
- phone_error: {
3021
- key: 'error',
3022
- message: 'Введите корректный номер телефона'
3023
- },
3024
- email_required: {
3025
- key: 'required',
3026
- message: 'Укажите адрес электронной почты'
3027
- },
3028
- invalid_value: {
3029
- key: 'error',
3030
- message: 'Некорректное значение'
3031
- },
3032
- // key: 'error'
3033
- matches: {
3034
- key: 'error',
3035
- message: 'Допускается ввод только цифр от 0 до 9'
3036
- },
3037
- numeric_value: {
3038
- key: 'error',
3039
- message: 'Только числовое значение'
3040
- },
3041
- password_required: {
3042
- key: 'required',
3043
- message: 'Введите пароль'
3044
- },
3045
- phone_or_email_required: {
3046
- key: 'required',
3047
- message: 'Введите телефон или адрес эл. почты'
3048
- },
3049
- phone_required: {
3050
- key: 'required',
3051
- message: 'Укажите номер телефона'
3052
- },
3053
- // key: 'required'
3054
- required: {
3055
- key: 'required',
3056
- message: 'Обязательное поле'
3057
- }
3018
+ const DEFAULT_MESSAGES_FIELDS = {
3019
+ ...DEFAULT_MESSAGES_EMAIL,
3020
+ ...DEFAULT_MESSAGES_ERROR,
3021
+ ...DEFAULT_MESSAGES_MIN_MAX,
3022
+ ...DEFAULT_MESSAGES_NUMBER,
3023
+ ...DEFAULT_MESSAGES_PASSWORD,
3024
+ ...DEFAULT_MESSAGES_PHONE,
3025
+ ...DEFAULT_MESSAGES_REQUIRED,
3026
+ ...DEFAULT_MESSAGES_URL
3058
3027
  };
3059
3028
 
3060
3029
  const parseNumericField = value => {
@@ -375,8 +375,8 @@ function FieldWrapperBase(props) {
375
375
  sizeMobile: labelTextSizeMobile,
376
376
  sizeTablet: labelTextSizeTablet
377
377
  }, label, labelHidden && '\u00A0')), desc && /*#__PURE__*/React.createElement("div", {
378
- className: "form-field__desc",
379
- dataTestId: `${inputName}FieldDesc`
378
+ dataTestId: `${inputName}FieldDesc`,
379
+ className: "form-field__desc"
380
380
  }, /*#__PURE__*/React.createElement(Text, {
381
381
  size: descTextSize,
382
382
  textColor: descTextColor,
@@ -1562,6 +1562,7 @@ function FormFieldDatePicker(props) {
1562
1562
  errorKey,
1563
1563
  errorMessage,
1564
1564
  isErrorState,
1565
+ successKey,
1565
1566
  isValidState
1566
1567
  } = useFieldValidationState({
1567
1568
  fieldProps: fieldProps,
@@ -1570,7 +1571,7 @@ function FormFieldDatePicker(props) {
1570
1571
  });
1571
1572
  const updatedInputProps = useValidationAppearanceInputProps({
1572
1573
  inputProps: inputProps,
1573
- validationStateKey: isErrorState ? errorKey : 'success'
1574
+ validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
1574
1575
  });
1575
1576
  return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
1576
1577
  className: clsx('form-field_datepicker', 'form__item_datepicker', classNameGroupItem),
@@ -2281,75 +2282,13 @@ const defaultRadioProps = {
2281
2282
  appearance: 'defaultPrimary sizeM solid circular'
2282
2283
  };
2283
2284
 
2284
- function RadioGroupInput(props) {
2285
- const {
2286
- input,
2287
- value,
2288
- onChange
2289
- } = props;
2290
- const onChangeField = useCallback(event => onChange(event.target.value), [onChange]);
2291
- return /*#__PURE__*/React.createElement(Input, Object.assign({
2292
- name: input.name,
2293
- autoComplete: "nope",
2294
- value: value,
2295
- onBlur: input.onBlur,
2296
- onChange: onChangeField,
2297
- onFocus: input.onFocus
2298
- }, props));
2299
- }
2300
-
2301
- function RadioGroupItem(props) {
2302
- const {
2303
- input,
2304
- inputProps,
2305
- option,
2306
- onChange
2307
- } = props;
2308
- const onChangeField = useCallback(event => {
2309
- if (event.target.checked) {
2310
- onChange(option.value);
2311
- }
2312
- }, [onChange]);
2313
- return /*#__PURE__*/React.createElement(Radio, Object.assign({
2314
- className: "form-radio__item",
2315
- type: "radio",
2316
- name: input.name,
2317
- label: option.label,
2318
- checked: option.value === input.value,
2319
- value: option.value,
2320
- onBlur: input.onBlur,
2321
- onChange: onChangeField,
2322
- onFocus: input.onFocus
2323
- }, inputProps));
2324
- }
2325
-
2326
2285
  function RadioGroupList(props) {
2327
2286
  const {
2328
- editableProps,
2329
2287
  input,
2330
2288
  inputProps,
2331
2289
  options,
2332
2290
  onChange
2333
2291
  } = props;
2334
- const [editableValue, setEditableValue] = useState(() => {
2335
- const isRadioValue = options.find(option => option.value === input.value);
2336
- if (!isRadioValue) {
2337
- return input.value;
2338
- }
2339
- return '';
2340
- });
2341
- useEffect(() => {
2342
- // When a new value from outside enters the form
2343
- if (input.value) {
2344
- // Check value for radio type
2345
- const isRadioValue = options.find(option => option.value === input.value && !option.editable);
2346
- // If new value not in radio list - set to editable input
2347
- setEditableValue(isRadioValue ? '' : input.value);
2348
- } else {
2349
- // If new value is empty - clear editable input
2350
- setEditableValue('');
2351
- }
2352
- }, [input.value]);
2353
2292
 
2354
2293
  // Callback for value changes
2355
2294
  const onChangeSomeInput = useCallback(value => {
@@ -2362,31 +2301,23 @@ function RadioGroupList(props) {
2362
2301
  }, [input, onChange]);
2363
2302
 
2364
2303
  // Handle for radio inputs
2365
- const onChangeRadio = useCallback(value => {
2366
- setEditableValue('');
2367
- onChangeSomeInput(value);
2368
- }, [onChangeSomeInput]);
2369
-
2370
- // Handle for text input
2371
- const onChangeEditable = useCallback(value => {
2372
- setEditableValue(value);
2373
- onChangeSomeInput(value);
2374
- }, [onChangeSomeInput]);
2375
- return /*#__PURE__*/React.createElement(React.Fragment, null, options.map(option => option.editable ? /*#__PURE__*/React.createElement(RadioGroupInput, {
2376
- key: option.label,
2377
- editableProps: editableProps,
2378
- input: input,
2379
- inputProps: inputProps,
2380
- option: option,
2381
- value: editableValue,
2382
- onChange: onChangeEditable
2383
- }) : /*#__PURE__*/React.createElement(RadioGroupItem, {
2304
+ const onChangeRadio = useCallback(event => {
2305
+ if (event.target.checked) {
2306
+ onChangeSomeInput(event.target.value);
2307
+ }
2308
+ }, [onChange]);
2309
+ return /*#__PURE__*/React.createElement(React.Fragment, null, options.map(option => /*#__PURE__*/React.createElement(Radio, Object.assign({
2310
+ className: "form-radio__item",
2384
2311
  key: option.value,
2385
- input: input,
2386
- inputProps: inputProps,
2387
- option: option,
2388
- onChange: onChangeRadio
2389
- })));
2312
+ type: "radio",
2313
+ name: input.name,
2314
+ label: option.label,
2315
+ checked: option.value === input.value,
2316
+ value: option.value,
2317
+ onBlur: input.onBlur,
2318
+ onChange: onChangeRadio,
2319
+ onFocus: input.onFocus
2320
+ }, inputProps))));
2390
2321
  }
2391
2322
 
2392
2323
  const RadioGroup = /*#__PURE__*/React.memo(function RadioGroup(props) {
@@ -2455,6 +2386,7 @@ const RadioGroup = /*#__PURE__*/React.memo(function RadioGroup(props) {
2455
2386
  });
2456
2387
 
2457
2388
  const formTypes = {
2389
+ password: 'password',
2458
2390
  code: 'code',
2459
2391
  text: 'text',
2460
2392
  textarea: 'textarea',
@@ -2474,6 +2406,12 @@ const formTypes = {
2474
2406
  };
2475
2407
  function generateField(field, config, props) {
2476
2408
  switch (field.type) {
2409
+ case formTypes.password:
2410
+ {
2411
+ return /*#__PURE__*/React.createElement(FormFieldPassword, Object.assign({
2412
+ key: config.key
2413
+ }, field, props));
2414
+ }
2477
2415
  case formTypes.checkbox:
2478
2416
  {
2479
2417
  return /*#__PURE__*/React.createElement(FormFieldCheckbox, Object.assign({
@@ -2486,15 +2424,15 @@ function generateField(field, config, props) {
2486
2424
  key: config.key
2487
2425
  }, field, props));
2488
2426
  }
2489
- case formTypes.chips:
2427
+ case formTypes.code:
2490
2428
  {
2491
- return /*#__PURE__*/React.createElement(FormFieldChips, Object.assign({
2429
+ return /*#__PURE__*/React.createElement(FormFieldCode, Object.assign({
2492
2430
  key: config.key
2493
2431
  }, field, props));
2494
2432
  }
2495
- case formTypes.code:
2433
+ case formTypes.chips:
2496
2434
  {
2497
- return /*#__PURE__*/React.createElement(FormFieldCode, Object.assign({
2435
+ return /*#__PURE__*/React.createElement(FormFieldChips, Object.assign({
2498
2436
  key: config.key
2499
2437
  }, field, props));
2500
2438
  }
@@ -2540,12 +2478,6 @@ function generateField(field, config, props) {
2540
2478
  key: config.key
2541
2479
  }, field, props));
2542
2480
  }
2543
- case formTypes.password:
2544
- {
2545
- return /*#__PURE__*/React.createElement(FormFieldPassword, Object.assign({
2546
- key: config.key
2547
- }, field, props));
2548
- }
2549
2481
  case formTypes.textarea:
2550
2482
  {
2551
2483
  return /*#__PURE__*/React.createElement(FormFieldTextarea, Object.assign({
@@ -2782,6 +2714,7 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2782
2714
  onChangeFormValues,
2783
2715
  onSubmit
2784
2716
  } = props;
2717
+ console.log(buttonJustifyContent);
2785
2718
  const validate = useYupValidationSchema(validationSchema, language);
2786
2719
  const onRefFormInstance = useCallback(formInstance => {
2787
2720
  if (ref) {
@@ -2934,116 +2867,152 @@ FinalForm.defaultProps = {
2934
2867
  direction: 'vertical'
2935
2868
  };
2936
2869
 
2937
- const DEFAULT_MESSAGES_FIELDS = {
2938
- /*
2939
- !!! it also works without props simply based on the class and key as before `input_state_${meta.error.key}`
2940
- the KEY is needed for example for border color
2941
- the name of the key is anything you want, the main thing is that there is a props with the same KEY and color in FieldProps
2870
+ const DEFAULT_MESSAGES_REQUIRED = {
2871
+ required: {
2872
+ key: 'required',
2873
+ message: 'Обязательное поле'
2874
+ }
2875
+ };
2876
+ const DEFAULT_MESSAGES_ERROR = {
2877
+ invalid_value: {
2878
+ key: 'error',
2879
+ message: 'Некорректное значение'
2880
+ }
2881
+ };
2882
+ const DEFAULT_MESSAGES_URL = {
2883
+ url: {
2884
+ key: 'error',
2885
+ message: 'Введите корректный URL-адрес'
2886
+ }
2887
+ };
2888
+ const DEFAULT_MESSAGES_PASSWORD = {
2889
+ password_required: {
2890
+ key: 'required',
2891
+ message: 'Введите пароль'
2892
+ }
2893
+ };
2894
+ const DEFAULT_MESSAGES_NUMBER = {
2895
+ matches: {
2896
+ key: 'error',
2897
+ message: 'Допускается ввод только цифр от 0 до 9'
2898
+ },
2899
+ numeric_value: {
2900
+ key: 'error',
2901
+ message: 'Только числовое значение'
2902
+ }
2903
+ };
2904
+ const DEFAULT_MESSAGES_MIN_MAX = {
2905
+ min: {
2906
+ key: 'error',
2907
+ message: ({
2908
+ min
2909
+ }) => `Значение должно быть не менее ${min} символов`
2910
+ },
2911
+ max: {
2912
+ key: 'error',
2913
+ message: ({
2914
+ max
2915
+ }) => `Значение должно быть не менее ${max} символов`
2916
+ }
2917
+ };
2918
+ const DEFAULT_MESSAGES_PHONE = {
2919
+ phone_error: {
2920
+ key: 'error',
2921
+ message: 'Введите корректный номер телефона'
2922
+ },
2923
+ phone_or_email_required: {
2924
+ key: 'required',
2925
+ message: 'Введите телефон или адрес эл. почты'
2926
+ },
2927
+ phone_required: {
2928
+ key: 'required',
2929
+ message: 'Укажите номер телефона'
2930
+ }
2931
+ };
2932
+ const DEFAULT_MESSAGES_EMAIL = {
2933
+ email_error: {
2934
+ key: 'error',
2935
+ message: 'Введите корректный адрес электронной почты'
2936
+ },
2937
+ email_required: {
2938
+ key: 'required',
2939
+ message: 'Укажите адрес электронной почты'
2940
+ }
2941
+ };
2942
+
2943
+ /*
2944
+
2945
+ !!! It also works without props simply based on the class and key as before `input_state_${meta.error.key}`
2946
+
2947
+ The KEY is needed for example for border color
2948
+
2949
+ The name of the key is anything you want, the main thing is that there is a props with the same KEY and color in FieldProps
2942
2950
  ...example
2943
- required - KEY for yellow color
2951
+
2952
+ required - KEY for yellow color
2944
2953
  error - KEY for red color
2945
2954
  custom or blue - KEY blue or other color
2946
- requiredBorderColor: 'warningBorderPrimary',
2955
+
2956
+ requiredBorderColor: 'warningBorderPrimary',
2947
2957
  errorBorderColor: 'errorBorderPrimary',
2948
2958
  customBorderColor: 'customBorderPrimary',
2949
2959
  blueBorderColor: 'blueBorderPrimary',
2950
- const defaultFieldProps = {
2951
- messageTextSize: 's',
2960
+
2961
+ const defaultFieldProps = {
2962
+
2963
+ messageTextSize: 's',
2952
2964
  messageTextColor: 'surfaceTextSecondary',
2953
- requiredMessageTextSize: 's',
2965
+
2966
+ requiredMessageTextSize: 's',
2954
2967
  requiredMessageTextColor: 'warningTextPrimary',
2955
- errorMessageTextSize: 's',
2968
+
2969
+ errorMessageTextSize: 's',
2956
2970
  errorMessageTextColor: 'errorTextPrimary',
2957
2971
  }
2958
- // INPUT
2972
+
2973
+ // INPUT
2959
2974
  const defaultInputProps = {
2960
2975
  ... other
2961
- stateBorderColor: 'surfaceBorderTertiary',
2976
+
2977
+ stateBorderColor: 'surfaceBorderTertiary',
2962
2978
  requiredStateBorderColor: 'warningBorderPrimary',
2963
2979
  errorStateBorderColor: 'errorBorderPrimary',
2964
2980
  }
2965
- // RADIO
2981
+
2982
+ // RADIO
2966
2983
  const defaultRadioProps = {
2967
2984
  ... other
2968
- stateBorderColor: 'surfaceBorderTertiary',
2985
+
2986
+ stateBorderColor: 'surfaceBorderTertiary',
2969
2987
  requiredStateBorderColor: 'warningBorderPrimary',
2970
2988
  errorStateBorderColor: 'errorBorderPrimary',
2971
2989
  }
2972
- // SELECT
2990
+
2991
+ // SELECT
2973
2992
  const defaultSelectProps = {
2974
2993
  ... other
2975
- borderColor: 'surfaceBorderTertiary',
2994
+
2995
+ borderColor: 'surfaceBorderTertiary',
2976
2996
  requiredBorderColor: 'warningBorderPrimary',
2977
2997
  errorBorderColor: 'errorBorderPrimary',
2978
- inputBorderColor: 'surfaceBorderTertiary',
2998
+
2999
+ inputBorderColor: 'surfaceBorderTertiary',
2979
3000
  requiredInputBorderColor: 'warningBorderPrimary',
2980
3001
  errorInputBorderColor: 'errorBorderPrimary',
2981
3002
  }
2982
- ... etc
2983
- */
2984
3003
 
2985
- // DEFAULT
2986
- // required - KEY for yellow color
2987
- // error - KEY for red color
3004
+ ... etc
3005
+ */
2988
3006
 
2989
- min: {
2990
- key: 'error',
2991
- message: ({
2992
- min
2993
- }) => `Значение должно быть не менее ${min} символов`
2994
- },
2995
- max: {
2996
- key: 'error',
2997
- message: ({
2998
- max
2999
- }) => `Значение должно быть не менее ${max} символов`
3000
- },
3001
- url: {
3002
- key: 'error',
3003
- message: 'Введите корректный URL-адрес'
3004
- },
3005
- email_error: {
3006
- key: 'error',
3007
- message: 'Введите корректный адрес электронной почты'
3008
- },
3009
- phone_error: {
3010
- key: 'error',
3011
- message: 'Введите корректный номер телефона'
3012
- },
3013
- email_required: {
3014
- key: 'required',
3015
- message: 'Укажите адрес электронной почты'
3016
- },
3017
- invalid_value: {
3018
- key: 'error',
3019
- message: 'Некорректное значение'
3020
- },
3021
- // key: 'error'
3022
- matches: {
3023
- key: 'error',
3024
- message: 'Допускается ввод только цифр от 0 до 9'
3025
- },
3026
- numeric_value: {
3027
- key: 'error',
3028
- message: 'Только числовое значение'
3029
- },
3030
- password_required: {
3031
- key: 'required',
3032
- message: 'Введите пароль'
3033
- },
3034
- phone_or_email_required: {
3035
- key: 'required',
3036
- message: 'Введите телефон или адрес эл. почты'
3037
- },
3038
- phone_required: {
3039
- key: 'required',
3040
- message: 'Укажите номер телефона'
3041
- },
3042
- // key: 'required'
3043
- required: {
3044
- key: 'required',
3045
- message: 'Обязательное поле'
3046
- }
3007
+ const DEFAULT_MESSAGES_FIELDS = {
3008
+ ...DEFAULT_MESSAGES_EMAIL,
3009
+ ...DEFAULT_MESSAGES_ERROR,
3010
+ ...DEFAULT_MESSAGES_MIN_MAX,
3011
+ ...DEFAULT_MESSAGES_NUMBER,
3012
+ ...DEFAULT_MESSAGES_PASSWORD,
3013
+ ...DEFAULT_MESSAGES_PHONE,
3014
+ ...DEFAULT_MESSAGES_REQUIRED,
3015
+ ...DEFAULT_MESSAGES_URL
3047
3016
  };
3048
3017
 
3049
3018
  const parseNumericField = value => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/forms",
3
- "version": "1.1.33",
3
+ "version": "1.1.34",
4
4
  "description": "Forms fields, inputs, etc.",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -34,11 +34,11 @@
34
34
  "dependencies": {
35
35
  "@itcase/common": "^1.2.28",
36
36
  "@itcase/config": "^1.0.55",
37
- "@itcase/icons": "^1.2.16",
38
- "@itcase/storybook-config": "^1.1.77",
37
+ "@itcase/icons": "^1.2.19",
38
+ "@itcase/storybook-config": "^1.1.83",
39
39
  "@itcase/tokens-am": "^1.1.19",
40
40
  "@itcase/tokens-baikal": "^1.1.17",
41
- "@itcase/ui": "^1.8.87",
41
+ "@itcase/ui": "^1.8.90",
42
42
  "axios": "^1.11.0",
43
43
  "clsx": "^2.1.1",
44
44
  "final-form": "4.20.10",
@@ -74,16 +74,16 @@
74
74
  "babel-plugin-inline-react-svg": "^2.0.2",
75
75
  "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
76
76
  "conventional-changelog-conventionalcommits": "^9.1.0",
77
- "eslint": "9.32.0",
77
+ "eslint": "9.33.0",
78
78
  "husky": "^9.1.7",
79
- "lint-staged": "^16.1.4",
79
+ "lint-staged": "^16.1.5",
80
80
  "postcss": "^8.5.6",
81
81
  "prettier": "3.6.2",
82
82
  "rollup": "^4.46.2",
83
83
  "rollup-plugin-peer-deps-external": "^2.2.4",
84
84
  "semantic-release": "^24.2.7",
85
85
  "storybook": "^9.1.1",
86
- "stylelint": "^16.23.0",
86
+ "stylelint": "^16.23.1",
87
87
  "typescript": "^5.9.2",
88
88
  "yup": "^1.7.0"
89
89
  }