@itcase/forms 1.0.44 → 1.0.45

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.
@@ -411,22 +411,25 @@ CheckboxField.propTypes = {
411
411
 
412
412
  const ChoiceField = /*#__PURE__*/React__default.default.memo(function ChoiceField(props) {
413
413
  const {
414
- options,
415
414
  classNameGroupItem,
416
415
  fieldProps,
416
+ hideMessage,
417
+ initialValue,
417
418
  inputProps,
418
419
  isMultiple,
419
420
  isRequired,
420
- initialValue,
421
421
  label,
422
- name,
423
422
  messageType,
424
- hideMessage,
423
+ name,
424
+ options,
425
425
  placeholder
426
426
  } = props;
427
427
  const {
428
428
  change
429
429
  } = reactFinalForm.useForm();
430
+ const setActiveSegment = React.useCallback((option, isChecked) => {
431
+ change(name, isChecked && option.value);
432
+ }, [change]);
430
433
  return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
431
434
  name: name,
432
435
  initialValue: initialValue
@@ -445,9 +448,6 @@ const ChoiceField = /*#__PURE__*/React__default.default.memo(function ChoiceFiel
445
448
  }
446
449
  return emptyOption;
447
450
  }, [input.value]);
448
- const setActiveSegment = React.useCallback(option => {
449
- change(name, option.value);
450
- }, [change]);
451
451
  return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
452
452
  className: clsx__default.default('form-field_type_choice', 'form__item_type_choice', classNameGroupItem),
453
453
  fieldClassName: "form-choice",
@@ -467,7 +467,7 @@ const ChoiceField = /*#__PURE__*/React__default.default.memo(function ChoiceFiel
467
467
  }, fieldProps), /*#__PURE__*/React__default.default.createElement(Choice.Choice, Object.assign({
468
468
  className: clsx__default.default(meta.active && 'form-choice_state_focus', meta.error && meta.touched && 'form-choice_state_error'),
469
469
  options: options,
470
- inputName: input.name,
470
+ name: input.name,
471
471
  inputValue: input.value || [],
472
472
  isMultiple: isMultiple,
473
473
  isRequired: isRequired,
@@ -478,13 +478,20 @@ const ChoiceField = /*#__PURE__*/React__default.default.memo(function ChoiceFiel
478
478
  });
479
479
  });
480
480
  ChoiceField.propTypes = {
481
- options: PropTypes__default.default.array.isRequired,
482
- name: PropTypes__default.default.string.isRequired,
483
- className: PropTypes__default.default.string,
484
- inputClass: PropTypes__default.default.string,
481
+ classNameGroupItem: PropTypes__default.default.string,
482
+ fieldProps: PropTypes__default.default.object,
483
+ hideMessage: PropTypes__default.default.bool,
484
+ initialValue: PropTypes__default.default.string,
485
+ inputProps: PropTypes__default.default.object,
485
486
  isMultiple: PropTypes__default.default.bool,
486
487
  isRequired: PropTypes__default.default.bool,
487
488
  label: PropTypes__default.default.string,
489
+ messageType: PropTypes__default.default.string,
490
+ name: PropTypes__default.default.string,
491
+ options: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
492
+ value: PropTypes__default.default.string,
493
+ label: PropTypes__default.default.string
494
+ })),
488
495
  placeholder: PropTypes__default.default.string
489
496
  };
490
497
 
@@ -707,7 +714,6 @@ async function convertToFiles(inputValue, isPreviews) {
707
714
  // })
708
715
  // }
709
716
  }
710
-
711
717
  return newFiles;
712
718
  }
713
719
  function setFileDataURL(file, resolve) {
@@ -1641,7 +1647,6 @@ function getDefaultValue(options, selectValue) {
1641
1647
  const SelectField = /*#__PURE__*/React__default.default.memo(function SelectField(props) {
1642
1648
  const {
1643
1649
  isRequired,
1644
- key,
1645
1650
  name,
1646
1651
  options,
1647
1652
  fieldProps,
@@ -1657,12 +1662,6 @@ const SelectField = /*#__PURE__*/React__default.default.memo(function SelectFiel
1657
1662
  input,
1658
1663
  meta
1659
1664
  }) => {
1660
- const onChangeField = React.useCallback(value => {
1661
- input.onChange(value);
1662
- if (onChange) {
1663
- onChange(value, input.name);
1664
- }
1665
- }, [onChange]);
1666
1665
  const [selectedOptions, setSelectedOptions] = React.useState(null);
1667
1666
  const defaultValue = React.useMemo(() => {
1668
1667
  const optionsValues = getDefaultValue(options, input.value);
@@ -1674,12 +1673,18 @@ const SelectField = /*#__PURE__*/React__default.default.memo(function SelectFiel
1674
1673
  }
1675
1674
  return optionsValues;
1676
1675
  }, [input.value]);
1677
- React.useEffect(() => setSelectedOptions(defaultValue), [defaultValue]);
1676
+ const onChangeField = React.useCallback(value => {
1677
+ input.onChange(value);
1678
+ if (onChange) {
1679
+ onChange(value, input.name);
1680
+ }
1681
+ }, [onChange]);
1678
1682
  const onChangeValue = React.useCallback((option, actionMeta) => {
1679
1683
  const value = Array.isArray(option) ? option.map(o => o.value) : option?.value || null;
1680
1684
  setSelectedOptions(option);
1681
1685
  onChangeField(value);
1682
1686
  }, [onChangeField]);
1687
+ React.useEffect(() => setSelectedOptions(defaultValue), [defaultValue]);
1683
1688
  return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
1684
1689
  className: clsx__default.default('form-field_type_select', 'form__item_type_select', classNameGroupItem),
1685
1690
  fieldClassName: 'form-select',
@@ -1700,8 +1705,7 @@ const SelectField = /*#__PURE__*/React__default.default.memo(function SelectFiel
1700
1705
  value: selectedOptions,
1701
1706
  onChange: onChangeValue,
1702
1707
  options: options,
1703
- ref: selectRef,
1704
- key: key
1708
+ ref: selectRef
1705
1709
  }, selectProps)));
1706
1710
  });
1707
1711
  });
@@ -2264,7 +2268,7 @@ FinalForm.propTypes = {
2264
2268
  descriptionSize: PropTypes__default.default.string,
2265
2269
  descriptionTextColor: PropTypes__default.default.string,
2266
2270
  descriptionTextWeight: PropTypes__default.default.string,
2267
- disableFieldsAutoComplete: PropTypes__default.default.string,
2271
+ disableFieldsAutoComplete: PropTypes__default.default.bool,
2268
2272
  fieldsGap: PropTypes__default.default.string,
2269
2273
  formName: PropTypes__default.default.string,
2270
2274
  initialValues: PropTypes__default.default.any,
@@ -2276,10 +2280,10 @@ FinalForm.propTypes = {
2276
2280
  onChangeFormValues: PropTypes__default.default.func,
2277
2281
  onClickSecondaryButton: PropTypes__default.default.func,
2278
2282
  onSubmit: PropTypes__default.default.func,
2279
- primaryButton: PropTypes__default.default.string,
2283
+ primaryButton: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.element]),
2280
2284
  primaryButtonFill: PropTypes__default.default.string,
2281
2285
  primaryButtonLabel: PropTypes__default.default.string,
2282
- secondaryButton: PropTypes__default.default.string,
2286
+ secondaryButton: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.element]),
2283
2287
  secondaryButtonFill: PropTypes__default.default.string,
2284
2288
  secondaryButtonLabel: PropTypes__default.default.string,
2285
2289
  set: PropTypes__default.default.string,
@@ -2302,15 +2306,15 @@ FinalForm.defaultProps = {
2302
2306
  disableFieldsAutoComplete: false
2303
2307
  };
2304
2308
 
2305
- Object.defineProperty(exports, 'Field', {
2309
+ Object.defineProperty(exports, "Field", {
2306
2310
  enumerable: true,
2307
2311
  get: function () { return reactFinalForm.Field; }
2308
2312
  });
2309
- Object.defineProperty(exports, 'useForm', {
2313
+ Object.defineProperty(exports, "useForm", {
2310
2314
  enumerable: true,
2311
2315
  get: function () { return reactFinalForm.useForm; }
2312
2316
  });
2313
- Object.defineProperty(exports, 'useFormState', {
2317
+ Object.defineProperty(exports, "useFormState", {
2314
2318
  enumerable: true,
2315
2319
  get: function () { return reactFinalForm.useFormState; }
2316
2320
  });
@@ -401,22 +401,25 @@ CheckboxField.propTypes = {
401
401
 
402
402
  const ChoiceField = /*#__PURE__*/React.memo(function ChoiceField(props) {
403
403
  const {
404
- options,
405
404
  classNameGroupItem,
406
405
  fieldProps,
406
+ hideMessage,
407
+ initialValue,
407
408
  inputProps,
408
409
  isMultiple,
409
410
  isRequired,
410
- initialValue,
411
411
  label,
412
- name,
413
412
  messageType,
414
- hideMessage,
413
+ name,
414
+ options,
415
415
  placeholder
416
416
  } = props;
417
417
  const {
418
418
  change
419
419
  } = useForm();
420
+ const setActiveSegment = useCallback((option, isChecked) => {
421
+ change(name, isChecked && option.value);
422
+ }, [change]);
420
423
  return /*#__PURE__*/React.createElement(Field, {
421
424
  name: name,
422
425
  initialValue: initialValue
@@ -435,9 +438,6 @@ const ChoiceField = /*#__PURE__*/React.memo(function ChoiceField(props) {
435
438
  }
436
439
  return emptyOption;
437
440
  }, [input.value]);
438
- const setActiveSegment = useCallback(option => {
439
- change(name, option.value);
440
- }, [change]);
441
441
  return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
442
442
  className: clsx('form-field_type_choice', 'form__item_type_choice', classNameGroupItem),
443
443
  fieldClassName: "form-choice",
@@ -457,7 +457,7 @@ const ChoiceField = /*#__PURE__*/React.memo(function ChoiceField(props) {
457
457
  }, fieldProps), /*#__PURE__*/React.createElement(Choice, Object.assign({
458
458
  className: clsx(meta.active && 'form-choice_state_focus', meta.error && meta.touched && 'form-choice_state_error'),
459
459
  options: options,
460
- inputName: input.name,
460
+ name: input.name,
461
461
  inputValue: input.value || [],
462
462
  isMultiple: isMultiple,
463
463
  isRequired: isRequired,
@@ -468,13 +468,20 @@ const ChoiceField = /*#__PURE__*/React.memo(function ChoiceField(props) {
468
468
  });
469
469
  });
470
470
  ChoiceField.propTypes = {
471
- options: PropTypes.array.isRequired,
472
- name: PropTypes.string.isRequired,
473
- className: PropTypes.string,
474
- inputClass: PropTypes.string,
471
+ classNameGroupItem: PropTypes.string,
472
+ fieldProps: PropTypes.object,
473
+ hideMessage: PropTypes.bool,
474
+ initialValue: PropTypes.string,
475
+ inputProps: PropTypes.object,
475
476
  isMultiple: PropTypes.bool,
476
477
  isRequired: PropTypes.bool,
477
478
  label: PropTypes.string,
479
+ messageType: PropTypes.string,
480
+ name: PropTypes.string,
481
+ options: PropTypes.arrayOf(PropTypes.shape({
482
+ value: PropTypes.string,
483
+ label: PropTypes.string
484
+ })),
478
485
  placeholder: PropTypes.string
479
486
  };
480
487
 
@@ -697,7 +704,6 @@ async function convertToFiles(inputValue, isPreviews) {
697
704
  // })
698
705
  // }
699
706
  }
700
-
701
707
  return newFiles;
702
708
  }
703
709
  function setFileDataURL(file, resolve) {
@@ -1631,7 +1637,6 @@ function getDefaultValue(options, selectValue) {
1631
1637
  const SelectField = /*#__PURE__*/React.memo(function SelectField(props) {
1632
1638
  const {
1633
1639
  isRequired,
1634
- key,
1635
1640
  name,
1636
1641
  options,
1637
1642
  fieldProps,
@@ -1647,12 +1652,6 @@ const SelectField = /*#__PURE__*/React.memo(function SelectField(props) {
1647
1652
  input,
1648
1653
  meta
1649
1654
  }) => {
1650
- const onChangeField = useCallback(value => {
1651
- input.onChange(value);
1652
- if (onChange) {
1653
- onChange(value, input.name);
1654
- }
1655
- }, [onChange]);
1656
1655
  const [selectedOptions, setSelectedOptions] = useState(null);
1657
1656
  const defaultValue = useMemo(() => {
1658
1657
  const optionsValues = getDefaultValue(options, input.value);
@@ -1664,12 +1663,18 @@ const SelectField = /*#__PURE__*/React.memo(function SelectField(props) {
1664
1663
  }
1665
1664
  return optionsValues;
1666
1665
  }, [input.value]);
1667
- useEffect(() => setSelectedOptions(defaultValue), [defaultValue]);
1666
+ const onChangeField = useCallback(value => {
1667
+ input.onChange(value);
1668
+ if (onChange) {
1669
+ onChange(value, input.name);
1670
+ }
1671
+ }, [onChange]);
1668
1672
  const onChangeValue = useCallback((option, actionMeta) => {
1669
1673
  const value = Array.isArray(option) ? option.map(o => o.value) : option?.value || null;
1670
1674
  setSelectedOptions(option);
1671
1675
  onChangeField(value);
1672
1676
  }, [onChangeField]);
1677
+ useEffect(() => setSelectedOptions(defaultValue), [defaultValue]);
1673
1678
  return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
1674
1679
  className: clsx('form-field_type_select', 'form__item_type_select', classNameGroupItem),
1675
1680
  fieldClassName: 'form-select',
@@ -1690,8 +1695,7 @@ const SelectField = /*#__PURE__*/React.memo(function SelectField(props) {
1690
1695
  value: selectedOptions,
1691
1696
  onChange: onChangeValue,
1692
1697
  options: options,
1693
- ref: selectRef,
1694
- key: key
1698
+ ref: selectRef
1695
1699
  }, selectProps)));
1696
1700
  });
1697
1701
  });
@@ -2254,7 +2258,7 @@ FinalForm.propTypes = {
2254
2258
  descriptionSize: PropTypes.string,
2255
2259
  descriptionTextColor: PropTypes.string,
2256
2260
  descriptionTextWeight: PropTypes.string,
2257
- disableFieldsAutoComplete: PropTypes.string,
2261
+ disableFieldsAutoComplete: PropTypes.bool,
2258
2262
  fieldsGap: PropTypes.string,
2259
2263
  formName: PropTypes.string,
2260
2264
  initialValues: PropTypes.any,
@@ -2266,10 +2270,10 @@ FinalForm.propTypes = {
2266
2270
  onChangeFormValues: PropTypes.func,
2267
2271
  onClickSecondaryButton: PropTypes.func,
2268
2272
  onSubmit: PropTypes.func,
2269
- primaryButton: PropTypes.string,
2273
+ primaryButton: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
2270
2274
  primaryButtonFill: PropTypes.string,
2271
2275
  primaryButtonLabel: PropTypes.string,
2272
- secondaryButton: PropTypes.string,
2276
+ secondaryButton: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
2273
2277
  secondaryButtonFill: PropTypes.string,
2274
2278
  secondaryButtonLabel: PropTypes.string,
2275
2279
  set: PropTypes.string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/forms",
3
- "version": "1.0.44",
3
+ "version": "1.0.45",
4
4
  "description": "Forms fields, inputs, etc.",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -31,13 +31,13 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@itcase/common": "^1.1.10",
34
- "@itcase/ui": "^1.0.81",
34
+ "@itcase/ui": "^1.0.84",
35
35
  "axios": "^1.6.2",
36
36
  "clsx": "^2.0.0",
37
37
  "date-fns": "2.0.0-alpha.7",
38
38
  "final-form": "^4.20.10",
39
39
  "final-form-focus": "^1.1.2",
40
- "libphonenumber-js": "^1.10.49",
40
+ "libphonenumber-js": "^1.10.51",
41
41
  "lodash": "^4.17.21",
42
42
  "luxon": "^3.4.4",
43
43
  "prop-types": "^15.8.1",
@@ -49,37 +49,37 @@
49
49
  "react-select": "^5.8.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@babel/core": "^7.23.3",
52
+ "@babel/core": "^7.23.6",
53
53
  "@babel/eslint-parser": "^7.23.3",
54
- "@babel/preset-env": "^7.23.3",
54
+ "@babel/preset-env": "^7.23.6",
55
55
  "@babel/preset-react": "^7.23.3",
56
- "@commitlint/cli": "^18.4.2",
57
- "@commitlint/config-conventional": "^18.4.2",
56
+ "@commitlint/cli": "^18.4.3",
57
+ "@commitlint/config-conventional": "^18.4.3",
58
58
  "@rollup/plugin-babel": "^6.0.4",
59
59
  "@rollup/plugin-commonjs": "^25.0.7",
60
- "@rollup/plugin-json": "^6.0.1",
60
+ "@rollup/plugin-json": "^6.1.0",
61
61
  "@rollup/plugin-node-resolve": "^15.2.3",
62
62
  "@rollup/plugin-terser": "^0.4.4",
63
63
  "@semantic-release/git": "^10.0.1",
64
64
  "babel-plugin-inline-react-svg": "^2.0.2",
65
65
  "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
66
- "eslint": "8.53.0",
67
- "eslint-config-prettier": "^9.0.0",
66
+ "eslint": "8.55.0",
67
+ "eslint-config-prettier": "^9.1.0",
68
68
  "eslint-config-standard": "^17.1.0",
69
- "eslint-plugin-import": "^2.29.0",
70
- "eslint-plugin-n": "^16.3.1",
69
+ "eslint-plugin-import": "^2.29.1",
70
+ "eslint-plugin-n": "^16.4.0",
71
71
  "eslint-plugin-prettier": "^5.0.1",
72
72
  "eslint-plugin-promise": "^6.1.1",
73
73
  "eslint-plugin-react": "^7.33.2",
74
74
  "eslint-plugin-standard": "^5.0.0",
75
75
  "husky": "^8.0.3",
76
- "lint-staged": "^15.1.0",
77
- "npm": "^10.2.4",
76
+ "lint-staged": "^15.2.0",
77
+ "npm": "^10.2.5",
78
78
  "postcss-aspect-ratio-polyfill": "^2.0.0",
79
- "postcss-cli": "^10.1.0",
79
+ "postcss-cli": "^11.0.0",
80
80
  "postcss-combine-duplicated-selectors": "^10.0.3",
81
- "postcss-dark-theme-class": "^1.0.0",
82
- "postcss-discard-duplicates": "^6.0.0",
81
+ "postcss-dark-theme-class": "^1.1.0",
82
+ "postcss-discard-duplicates": "^6.0.1",
83
83
  "postcss-each": "^1.1.0",
84
84
  "postcss-easings": "^4.0.0",
85
85
  "postcss-extend-rule": "^4.0.0",
@@ -96,14 +96,14 @@
96
96
  "postcss-pxtorem": "^6.0.0",
97
97
  "postcss-responsive-type": "github:ITCase/postcss-responsive-type",
98
98
  "postcss-sort-media-queries": "^5.2.0",
99
- "prettier": "^3.1.0",
100
- "react-datepicker": "^4.21.0",
101
- "rollup": "^4.4.1",
99
+ "prettier": "^3.1.1",
100
+ "react-datepicker": "^4.24.0",
101
+ "rollup": "^4.9.0",
102
102
  "rollup-plugin-peer-deps-external": "^2.2.4",
103
- "semantic-release": "^22.0.7",
104
- "stylelint": "^15.11.0",
105
- "stylelint-config-standard": "^34.0.0",
103
+ "semantic-release": "^22.0.12",
104
+ "stylelint": "^16.0.2",
105
+ "stylelint-config-standard": "^35.0.0",
106
106
  "stylelint-no-unsupported-browser-features": "^7.0.0",
107
- "stylelint-order": "^6.0.3"
107
+ "stylelint-order": "^6.0.4"
108
108
  }
109
109
  }