@alfalab/core-components-input-autocomplete 11.0.3 → 11.2.0

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.
Files changed (60) hide show
  1. package/Component.responsive.js +1 -0
  2. package/autocomplete-field/Component.js +1 -1
  3. package/autocomplete-field/index.css +2 -2
  4. package/autocomplete-mobile-field/Component.d.ts +1 -1
  5. package/autocomplete-mobile-field/Component.js +10 -5
  6. package/autocomplete-mobile-field/index.css +8 -8
  7. package/autocomplete-mobile-field/index.js +1 -0
  8. package/cssm/Component.responsive.js +1 -0
  9. package/cssm/autocomplete-mobile-field/Component.d.ts +1 -1
  10. package/cssm/autocomplete-mobile-field/Component.js +9 -4
  11. package/cssm/autocomplete-mobile-field/index.js +1 -0
  12. package/cssm/index.js +1 -0
  13. package/cssm/mobile/Component.mobile.d.ts +2 -0
  14. package/cssm/mobile/Component.mobile.js +10 -4
  15. package/cssm/mobile/Component.modal.mobile.d.ts +2 -0
  16. package/cssm/mobile/Component.modal.mobile.js +1 -0
  17. package/cssm/mobile/index.js +1 -0
  18. package/cssm/types.d.ts +8 -0
  19. package/esm/Component.responsive.js +1 -0
  20. package/esm/autocomplete-field/Component.js +1 -1
  21. package/esm/autocomplete-field/index.css +2 -2
  22. package/esm/autocomplete-mobile-field/Component.d.ts +1 -1
  23. package/esm/autocomplete-mobile-field/Component.js +10 -5
  24. package/esm/autocomplete-mobile-field/index.css +8 -8
  25. package/esm/autocomplete-mobile-field/index.js +1 -0
  26. package/esm/index.js +1 -0
  27. package/esm/mobile/Component.mobile.d.ts +2 -0
  28. package/esm/mobile/Component.mobile.js +11 -5
  29. package/esm/mobile/Component.modal.mobile.d.ts +2 -0
  30. package/esm/mobile/Component.modal.mobile.js +1 -0
  31. package/esm/mobile/index.js +1 -0
  32. package/esm/mobile/mobile.css +2 -2
  33. package/esm/types.d.ts +8 -0
  34. package/index.js +1 -0
  35. package/mobile/Component.mobile.d.ts +2 -0
  36. package/mobile/Component.mobile.js +11 -5
  37. package/mobile/Component.modal.mobile.d.ts +2 -0
  38. package/mobile/Component.modal.mobile.js +1 -0
  39. package/mobile/index.js +1 -0
  40. package/mobile/mobile.css +2 -2
  41. package/modern/Component.responsive.js +1 -0
  42. package/modern/autocomplete-field/Component.js +1 -1
  43. package/modern/autocomplete-field/index.css +2 -2
  44. package/modern/autocomplete-mobile-field/Component.d.ts +1 -1
  45. package/modern/autocomplete-mobile-field/Component.js +9 -4
  46. package/modern/autocomplete-mobile-field/index.css +8 -8
  47. package/modern/autocomplete-mobile-field/index.js +1 -0
  48. package/modern/index.js +1 -0
  49. package/modern/mobile/Component.mobile.d.ts +2 -0
  50. package/modern/mobile/Component.mobile.js +12 -4
  51. package/modern/mobile/Component.modal.mobile.d.ts +2 -0
  52. package/modern/mobile/Component.modal.mobile.js +1 -0
  53. package/modern/mobile/index.js +1 -0
  54. package/modern/mobile/mobile.css +2 -2
  55. package/modern/types.d.ts +8 -0
  56. package/package.json +5 -5
  57. package/src/autocomplete-mobile-field/Component.tsx +27 -1
  58. package/src/mobile/Component.mobile.tsx +12 -2
  59. package/src/types.ts +10 -0
  60. package/types.d.ts +8 -0
@@ -4,5 +4,7 @@ import React from 'react';
4
4
  declare const InputAutocompleteMobile: React.ForwardRefExoticComponent<import("../types").InputAutocompleteCommonProps & {
5
5
  isBottomSheet?: boolean | undefined;
6
6
  transitionProps?: Partial<import("react-transition-group/Transition").TransitionProps<undefined>> | undefined;
7
+ onApply?: (() => void) | undefined;
8
+ onCancel?: (() => void) | undefined;
7
9
  } & React.RefAttributes<unknown>>;
8
10
  export { InputAutocompleteMobile };
@@ -12,6 +12,7 @@ var shared = require('@alfalab/core-components-select/shared');
12
12
  var autocompleteMobileField_Component = require('../autocomplete-mobile-field/Component.js');
13
13
  var utils = require('../utils.js');
14
14
  require('@alfalab/core-components-form-control/mobile');
15
+ require('@alfalab/core-components-input/shared');
15
16
  require('@alfalab/core-components-shared');
16
17
  require('@alfalab/hooks');
17
18
 
@@ -22,13 +23,13 @@ var mergeRefs__default = /*#__PURE__*/_interopDefaultCompat(mergeRefs);
22
23
  var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
23
24
  var throttle__default = /*#__PURE__*/_interopDefaultCompat(throttle);
24
25
 
25
- var styles = {"input":"input-autocomplete__input_dae0s"};
26
+ var styles = {"input":"input-autocomplete__input_obkwb"};
26
27
  require('./mobile.css')
27
28
 
28
29
  var InputAutocompleteMobile = React__default.default.forwardRef(function (_a, ref) {
29
30
  var _b;
30
31
  var _c;
31
- var Input = _a.Input, value = _a.value, name = _a.name, _d = _a.Arrow, Arrow = _d === void 0 ? null : _d, label = _a.label, _e = _a.placeholder, placeholder = _e === void 0 ? '' : _e, _f = _a.size, size = _f === void 0 ? 's' : _f, openProp = _a.open, onInput = _a.onInput, onOpen = _a.onOpen, multiple = _a.multiple, inputProps = _a.inputProps, _g = _a.isBottomSheet, isBottomSheet = _g === void 0 ? true : _g, dataTestId = _a.dataTestId, transitionProps = _a.transitionProps, restProps = tslib.__rest(_a, ["Input", "value", "name", "Arrow", "label", "placeholder", "size", "open", "onInput", "onOpen", "multiple", "inputProps", "isBottomSheet", "dataTestId", "transitionProps"]);
32
+ var Input = _a.Input, value = _a.value, name = _a.name, _d = _a.Arrow, Arrow = _d === void 0 ? null : _d, label = _a.label, _e = _a.placeholder, placeholder = _e === void 0 ? '' : _e, _f = _a.size, size = _f === void 0 ? 's' : _f, openProp = _a.open, onInput = _a.onInput, onOpen = _a.onOpen, multiple = _a.multiple, inputProps = _a.inputProps, _g = _a.isBottomSheet, isBottomSheet = _g === void 0 ? true : _g, dataTestId = _a.dataTestId, transitionProps = _a.transitionProps, onCancel = _a.onCancel, onApply = _a.onApply, restProps = tslib.__rest(_a, ["Input", "value", "name", "Arrow", "label", "placeholder", "size", "open", "onInput", "onOpen", "multiple", "inputProps", "isBottomSheet", "dataTestId", "transitionProps", "onCancel", "onApply"]);
32
33
  var _h = React.useState(false), open = _h[0], setOpen = _h[1];
33
34
  var frozenValue = React.useRef('');
34
35
  var searchInputRef = React.useRef(null);
@@ -54,10 +55,14 @@ var InputAutocompleteMobile = React__default.default.forwardRef(function (_a, re
54
55
  }
55
56
  }, 300);
56
57
  }, []);
57
- var handleApply = function () { return setModalVisibility(false); };
58
+ var handleApply = function () {
59
+ setModalVisibility(false);
60
+ onApply === null || onApply === void 0 ? void 0 : onApply();
61
+ };
58
62
  var handleCancel = function () {
59
63
  setModalVisibility(false);
60
64
  restorePrevValue();
65
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel();
61
66
  };
62
67
  var handleExiting = function (node) {
63
68
  var _a, _b;
@@ -75,13 +80,14 @@ var InputAutocompleteMobile = React__default.default.forwardRef(function (_a, re
75
80
  onTouchMove: handleOptionsListTouchMove,
76
81
  },
77
82
  _b);
83
+ var clear = (_c = inputProps === null || inputProps === void 0 ? void 0 : inputProps.clear) !== null && _c !== void 0 ? _c : false;
78
84
  return (React__default.default.createElement(Component, tslib.__assign({ Field: autocompleteMobileField_Component.AutocompleteMobileField }, restProps, (isBottomSheet
79
85
  ? { bottomSheetProps: componentProps }
80
86
  : { modalProps: componentProps }), { dataTestId: dataTestId, useWithApplyHook: false, showSearch: true, searchProps: {
81
87
  value: value,
82
88
  filterFn: utils.searchFilterStub,
83
- componentProps: tslib.__assign(tslib.__assign({ leftAddons: null, placeholder: placeholder }, inputProps), { className: cn__default.default(styles.input, inputProps === null || inputProps === void 0 ? void 0 : inputProps.className), clear: (_c = inputProps === null || inputProps === void 0 ? void 0 : inputProps.clear) !== null && _c !== void 0 ? _c : false, ref: mergeRefs__default.default([searchInputRef, inputProps === null || inputProps === void 0 ? void 0 : inputProps.ref]), onChange: onInput }),
84
- }, Search: Input, ref: mergeRefs__default.default([targetRef, ref]), open: isOpen, onOpen: handleOpen, Arrow: Arrow, placeholder: placeholder, label: label, size: size, name: name, multiple: multiple, optionsListProps: tslib.__assign({ footer: (React__default.default.createElement(shared.Footer, { showClear: true, handleClear: handleCancel, handleApply: handleApply, clearText: '\u041E\u0442\u043C\u0435\u043D\u0430', applyText: '\u041F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C', dataTestId: dataTestId })) }, restProps.optionsListProps), fieldProps: tslib.__assign({ value: isOpen ? frozenValue.current : value }, restProps.fieldProps) })));
89
+ componentProps: tslib.__assign(tslib.__assign({ leftAddons: null, placeholder: placeholder }, inputProps), { className: cn__default.default(styles.input, inputProps === null || inputProps === void 0 ? void 0 : inputProps.className), clear: clear, ref: mergeRefs__default.default([searchInputRef, inputProps === null || inputProps === void 0 ? void 0 : inputProps.ref]), onChange: onInput }),
90
+ }, Search: Input, ref: mergeRefs__default.default([targetRef, ref]), open: isOpen, onOpen: handleOpen, Arrow: Arrow, placeholder: placeholder, label: label, size: size, name: name, multiple: multiple, optionsListProps: tslib.__assign({ footer: (React__default.default.createElement(shared.Footer, { showClear: true, handleClear: handleCancel, handleApply: handleApply, clearText: '\u041E\u0442\u043C\u0435\u043D\u0430', applyText: '\u041F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C', dataTestId: dataTestId })) }, restProps.optionsListProps), fieldProps: tslib.__assign({ value: isOpen ? frozenValue.current : value, clear: clear, onClear: clear ? inputProps === null || inputProps === void 0 ? void 0 : inputProps.onClear : undefined }, restProps.fieldProps) })));
85
91
  });
86
92
 
87
93
  exports.InputAutocompleteMobile = InputAutocompleteMobile;
@@ -4,5 +4,7 @@ import React from 'react';
4
4
  declare const InputAutocompleteModalMobile: React.ForwardRefExoticComponent<import("../types").InputAutocompleteCommonProps & {
5
5
  isBottomSheet?: boolean | undefined;
6
6
  transitionProps?: Partial<import("react-transition-group/Transition").TransitionProps<undefined>> | undefined;
7
+ onApply?: (() => void) | undefined;
8
+ onCancel?: (() => void) | undefined;
7
9
  } & React.RefAttributes<HTMLDivElement>>;
8
10
  export { InputAutocompleteModalMobile };
@@ -12,6 +12,7 @@ require('@alfalab/core-components-select/mobile');
12
12
  require('@alfalab/core-components-select/shared');
13
13
  require('../autocomplete-mobile-field/Component.js');
14
14
  require('@alfalab/core-components-form-control/mobile');
15
+ require('@alfalab/core-components-input/shared');
15
16
  require('@alfalab/core-components-shared');
16
17
  require('@alfalab/hooks');
17
18
  require('../utils.js');
package/mobile/index.js CHANGED
@@ -13,6 +13,7 @@ require('@alfalab/core-components-select/mobile');
13
13
  require('@alfalab/core-components-select/shared');
14
14
  require('../autocomplete-mobile-field/Component.js');
15
15
  require('@alfalab/core-components-form-control/mobile');
16
+ require('@alfalab/core-components-input/shared');
16
17
  require('@alfalab/core-components-shared');
17
18
  require('@alfalab/hooks');
18
19
  require('../utils.js');
package/mobile/mobile.css CHANGED
@@ -1,4 +1,4 @@
1
- /* hash: 5n9cn */
1
+ /* hash: 1kaq4 */
2
2
  :root {
3
3
  } /* deprecated */ :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
4
4
  } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
@@ -14,6 +14,6 @@
14
14
  } :root {
15
15
  } :root {
16
16
  } :root {
17
- } .input-autocomplete__input_dae0s {
17
+ } .input-autocomplete__input_obkwb {
18
18
  width: auto;
19
19
  }
@@ -13,6 +13,7 @@ import 'lodash.throttle';
13
13
  import '@alfalab/core-components-select/modern/mobile';
14
14
  import './autocomplete-mobile-field/Component.js';
15
15
  import '@alfalab/core-components-form-control/modern/mobile';
16
+ import '@alfalab/core-components-input/modern/shared';
16
17
  import '@alfalab/core-components-shared/modern';
17
18
  import '@alfalab/hooks';
18
19
  import './utils.js';
@@ -3,7 +3,7 @@ import mergeRefs from 'react-merge-refs';
3
3
  import cn from 'classnames';
4
4
  import { InputDesktop } from '@alfalab/core-components-input/modern/desktop';
5
5
 
6
- const styles = {"arrow":"input-autocomplete__arrow_z2bi9","error":"input-autocomplete__error_z2bi9"};
6
+ const styles = {"arrow":"input-autocomplete__arrow_1ohhy","error":"input-autocomplete__error_1ohhy"};
7
7
  require('./index.css')
8
8
 
9
9
  const AutocompleteField = ({ label, labelView = 'inner', placeholder, size, Arrow, Input = InputDesktop, value, error, success, hint, disabled, readOnly, onInput, inputProps = {}, innerProps, }) => {
@@ -1,4 +1,4 @@
1
- /* hash: xfkzu */
2
- .input-autocomplete__arrow_z2bi9.input-autocomplete__error_z2bi9 ~ * {
1
+ /* hash: 1g9go */
2
+ .input-autocomplete__arrow_1ohhy.input-autocomplete__error_1ohhy ~ * {
3
3
  display: none;
4
4
  }
@@ -15,5 +15,5 @@ type AutocompleteMobileFieldProps = FormControlMobileProps & Omit<BaseFieldProps
15
15
  */
16
16
  value?: string;
17
17
  };
18
- declare const AutocompleteMobileField: ({ size, open, disabled, value, innerProps, dataTestId, fieldClassName, labelView, placeholder, Arrow, valueRenderer, toggleMenu, setSelectedItems, selectedMultiple, FormControlComponent, ...restProps }: AutocompleteMobileFieldProps & FieldProps) => React.JSX.Element;
18
+ declare const AutocompleteMobileField: ({ size, open, disabled, value, innerProps, dataTestId, fieldClassName, labelView, placeholder, Arrow, valueRenderer, toggleMenu, setSelectedItems, selectedMultiple, FormControlComponent, rightAddons, error, readOnly, clear, onClear, onInput, colors, ...restProps }: AutocompleteMobileFieldProps & FieldProps) => React.JSX.Element;
19
19
  export { AutocompleteMobileFieldProps, AutocompleteMobileField };
@@ -1,26 +1,31 @@
1
1
  import React, { useState, useRef } from 'react';
2
2
  import cn from 'classnames';
3
3
  import { FormControlMobile } from '@alfalab/core-components-form-control/modern/mobile';
4
+ import { ClearButton } from '@alfalab/core-components-input/modern/shared';
4
5
  import { getDataTestId } from '@alfalab/core-components-shared/modern';
5
6
  import { useFocus } from '@alfalab/hooks';
6
7
 
7
- const styles = {"component":"input-autocomplete__component_gg3o5","field":"input-autocomplete__field_gg3o5","disabled":"input-autocomplete__disabled_gg3o5","placeholder":"input-autocomplete__placeholder_gg3o5","contentWrapper":"input-autocomplete__contentWrapper_gg3o5","value":"input-autocomplete__value_gg3o5","focusVisible":"input-autocomplete__focusVisible_gg3o5"};
8
+ const styles = {"component":"input-autocomplete__component_zrg4l","field":"input-autocomplete__field_zrg4l","disabled":"input-autocomplete__disabled_zrg4l","placeholder":"input-autocomplete__placeholder_zrg4l","contentWrapper":"input-autocomplete__contentWrapper_zrg4l","value":"input-autocomplete__value_zrg4l","focusVisible":"input-autocomplete__focusVisible_zrg4l"};
8
9
  require('./index.css')
9
10
 
10
- const AutocompleteMobileField = ({ size = 'm', open, disabled, value, innerProps, dataTestId, fieldClassName, labelView = 'inner', placeholder, Arrow, valueRenderer, toggleMenu, setSelectedItems, selectedMultiple, FormControlComponent, ...restProps }) => {
11
+ const AutocompleteMobileField = ({ size = 'm', open, disabled, value, innerProps, dataTestId, fieldClassName, labelView = 'inner', placeholder, Arrow, valueRenderer, toggleMenu, setSelectedItems, selectedMultiple, FormControlComponent, rightAddons, error, readOnly, clear, onClear, onInput, colors = 'default', ...restProps }) => {
11
12
  const [focused, setFocused] = useState(false);
12
13
  const wrapperRef = useRef(null);
13
14
  const [focusVisible] = useFocus(wrapperRef, 'keyboard');
14
15
  const filled = Boolean(value);
15
16
  const showPlaceholder = placeholder && !filled && labelView === 'outer';
17
+ const clearButtonVisible = clear && filled && !disabled && !readOnly;
16
18
  const { tabIndex, ...restInnerProps } = innerProps;
17
19
  return (React.createElement("div", { className: styles.component, ref: wrapperRef, onFocus: () => setFocused(true), onBlur: () => setFocused(false) },
18
20
  React.createElement(FormControlMobile, { fieldClassName: cn(styles.field, fieldClassName, {
19
21
  [styles.disabled]: disabled,
20
22
  [styles.focusVisible]: focusVisible,
21
- }), block: true, size: size, focused: focused, disabled: disabled, filled: filled, labelView: labelView, rightAddons: Arrow, dataTestId: getDataTestId(dataTestId, 'form-control'),
23
+ }), block: true, size: size, focused: focused, disabled: disabled, filled: filled, labelView: labelView, dataTestId: getDataTestId(dataTestId, 'form-control'),
22
24
  // downshift устанавливает фокус на таргет поле после выбора опции, не даем ему это сделать пока открыт список, иначе поле поиска будет терять фокус
23
- tabIndex: open ? undefined : tabIndex, ...restProps, ...restInnerProps },
25
+ tabIndex: open ? undefined : tabIndex, ...restProps, ...restInnerProps, readOnly: readOnly, colors: colors, error: error, rightAddons: (Arrow || rightAddons || clearButtonVisible) && (React.createElement(React.Fragment, null,
26
+ clearButtonVisible && (React.createElement(ClearButton, { onClick: onClear, disabled: disabled, colors: colors })),
27
+ rightAddons,
28
+ Arrow)) },
24
29
  React.createElement("div", { className: styles.contentWrapper },
25
30
  showPlaceholder && React.createElement("span", { className: styles.placeholder }, placeholder),
26
31
  filled && React.createElement("div", { className: styles.value }, value)))));
@@ -1,4 +1,4 @@
1
- /* hash: r7aus */
1
+ /* hash: 1vqlc */
2
2
  :root {
3
3
  } /* deprecated */ :root {
4
4
  --color-light-border-link: #2288fa;
@@ -18,16 +18,16 @@
18
18
  } :root {
19
19
  --focus-color: var(--color-light-border-link);
20
20
  --disabled-cursor: not-allowed;
21
- } .input-autocomplete__component_gg3o5 {
21
+ } .input-autocomplete__component_zrg4l {
22
22
  width: 100%;
23
23
  outline: none;
24
- } .input-autocomplete__field_gg3o5:not(.input-autocomplete__disabled_gg3o5) {
24
+ } .input-autocomplete__field_zrg4l:not(.input-autocomplete__disabled_zrg4l) {
25
25
  cursor: pointer;
26
- } .input-autocomplete__disabled_gg3o5 {
26
+ } .input-autocomplete__disabled_zrg4l {
27
27
  cursor: var(--disabled-cursor);
28
- } .input-autocomplete__placeholder_gg3o5 {
28
+ } .input-autocomplete__placeholder_zrg4l {
29
29
  color: var(--color-light-text-secondary);
30
- } .input-autocomplete__contentWrapper_gg3o5 {
30
+ } .input-autocomplete__contentWrapper_zrg4l {
31
31
  font-size: 16px;
32
32
  line-height: 20px;
33
33
  font-weight: 400;
@@ -36,11 +36,11 @@
36
36
  text-overflow: ellipsis;
37
37
  overflow: hidden;
38
38
  width: 100%;
39
- } .input-autocomplete__value_gg3o5 {
39
+ } .input-autocomplete__value_zrg4l {
40
40
  overflow: hidden;
41
41
  text-overflow: ellipsis;
42
42
  text-align: left;
43
- } .input-autocomplete__focusVisible_gg3o5 {
43
+ } .input-autocomplete__focusVisible_zrg4l {
44
44
  outline: 2px solid var(--focus-color);
45
45
  outline-offset: 2px;
46
46
  }
@@ -2,5 +2,6 @@ export { AutocompleteMobileField } from './Component.js';
2
2
  import 'react';
3
3
  import 'classnames';
4
4
  import '@alfalab/core-components-form-control/modern/mobile';
5
+ import '@alfalab/core-components-input/modern/shared';
5
6
  import '@alfalab/core-components-shared/modern';
6
7
  import '@alfalab/hooks';
package/modern/index.js CHANGED
@@ -13,6 +13,7 @@ import 'lodash.throttle';
13
13
  import '@alfalab/core-components-select/modern/mobile';
14
14
  import './autocomplete-mobile-field/Component.js';
15
15
  import '@alfalab/core-components-form-control/modern/mobile';
16
+ import '@alfalab/core-components-input/modern/shared';
16
17
  import '@alfalab/core-components-shared/modern';
17
18
  import '@alfalab/hooks';
18
19
  import './utils.js';
@@ -4,5 +4,7 @@ import React from 'react';
4
4
  declare const InputAutocompleteMobile: React.ForwardRefExoticComponent<import("../types").InputAutocompleteCommonProps & {
5
5
  isBottomSheet?: boolean | undefined;
6
6
  transitionProps?: Partial<import("react-transition-group/Transition").TransitionProps<undefined>> | undefined;
7
+ onApply?: (() => void) | undefined;
8
+ onCancel?: (() => void) | undefined;
7
9
  } & React.RefAttributes<unknown>>;
8
10
  export { InputAutocompleteMobile };
@@ -7,13 +7,14 @@ import { Footer } from '@alfalab/core-components-select/modern/shared';
7
7
  import { AutocompleteMobileField } from '../autocomplete-mobile-field/Component.js';
8
8
  import { searchFilterStub } from '../utils.js';
9
9
  import '@alfalab/core-components-form-control/modern/mobile';
10
+ import '@alfalab/core-components-input/modern/shared';
10
11
  import '@alfalab/core-components-shared/modern';
11
12
  import '@alfalab/hooks';
12
13
 
13
- const styles = {"input":"input-autocomplete__input_dae0s"};
14
+ const styles = {"input":"input-autocomplete__input_obkwb"};
14
15
  require('./mobile.css')
15
16
 
16
- const InputAutocompleteMobile = React.forwardRef(({ Input, value, name, Arrow = null, label, placeholder = '', size = 's', open: openProp, onInput, onOpen, multiple, inputProps, isBottomSheet = true, dataTestId, transitionProps, ...restProps }, ref) => {
17
+ const InputAutocompleteMobile = React.forwardRef(({ Input, value, name, Arrow = null, label, placeholder = '', size = 's', open: openProp, onInput, onOpen, multiple, inputProps, isBottomSheet = true, dataTestId, transitionProps, onCancel, onApply, ...restProps }, ref) => {
17
18
  const [open, setOpen] = useState(false);
18
19
  const frozenValue = useRef('');
19
20
  const searchInputRef = useRef(null);
@@ -37,10 +38,14 @@ const InputAutocompleteMobile = React.forwardRef(({ Input, value, name, Arrow =
37
38
  input.blur();
38
39
  }
39
40
  }, 300), []);
40
- const handleApply = () => setModalVisibility(false);
41
+ const handleApply = () => {
42
+ setModalVisibility(false);
43
+ onApply?.();
44
+ };
41
45
  const handleCancel = () => {
42
46
  setModalVisibility(false);
43
47
  restorePrevValue();
48
+ onCancel?.();
44
49
  };
45
50
  const handleExiting = (node) => {
46
51
  targetRef.current?.focus();
@@ -59,6 +64,7 @@ const InputAutocompleteMobile = React.forwardRef(({ Input, value, name, Arrow =
59
64
  onTouchMove: handleOptionsListTouchMove,
60
65
  },
61
66
  };
67
+ const clear = inputProps?.clear ?? false;
62
68
  return (React.createElement(Component, { Field: AutocompleteMobileField, ...restProps, ...(isBottomSheet
63
69
  ? { bottomSheetProps: componentProps }
64
70
  : { modalProps: componentProps }), dataTestId: dataTestId, useWithApplyHook: false, showSearch: true, searchProps: {
@@ -69,7 +75,7 @@ const InputAutocompleteMobile = React.forwardRef(({ Input, value, name, Arrow =
69
75
  placeholder,
70
76
  ...inputProps,
71
77
  className: cn(styles.input, inputProps?.className),
72
- clear: inputProps?.clear ?? false,
78
+ clear,
73
79
  ref: mergeRefs([searchInputRef, inputProps?.ref]),
74
80
  onChange: onInput,
75
81
  },
@@ -78,6 +84,8 @@ const InputAutocompleteMobile = React.forwardRef(({ Input, value, name, Arrow =
78
84
  ...restProps.optionsListProps,
79
85
  }, fieldProps: {
80
86
  value: isOpen ? frozenValue.current : value,
87
+ clear,
88
+ onClear: clear ? inputProps?.onClear : undefined,
81
89
  ...restProps.fieldProps,
82
90
  } }));
83
91
  });
@@ -4,5 +4,7 @@ import React from 'react';
4
4
  declare const InputAutocompleteModalMobile: React.ForwardRefExoticComponent<import("../types").InputAutocompleteCommonProps & {
5
5
  isBottomSheet?: boolean | undefined;
6
6
  transitionProps?: Partial<import("react-transition-group/Transition").TransitionProps<undefined>> | undefined;
7
+ onApply?: (() => void) | undefined;
8
+ onCancel?: (() => void) | undefined;
7
9
  } & React.RefAttributes<HTMLDivElement>>;
8
10
  export { InputAutocompleteModalMobile };
@@ -7,6 +7,7 @@ import '@alfalab/core-components-select/modern/mobile';
7
7
  import '@alfalab/core-components-select/modern/shared';
8
8
  import '../autocomplete-mobile-field/Component.js';
9
9
  import '@alfalab/core-components-form-control/modern/mobile';
10
+ import '@alfalab/core-components-input/modern/shared';
10
11
  import '@alfalab/core-components-shared/modern';
11
12
  import '@alfalab/hooks';
12
13
  import '../utils.js';
@@ -8,6 +8,7 @@ import '@alfalab/core-components-select/modern/mobile';
8
8
  import '@alfalab/core-components-select/modern/shared';
9
9
  import '../autocomplete-mobile-field/Component.js';
10
10
  import '@alfalab/core-components-form-control/modern/mobile';
11
+ import '@alfalab/core-components-input/modern/shared';
11
12
  import '@alfalab/core-components-shared/modern';
12
13
  import '@alfalab/hooks';
13
14
  import '../utils.js';
@@ -1,4 +1,4 @@
1
- /* hash: 5n9cn */
1
+ /* hash: 1kaq4 */
2
2
  :root {
3
3
  } /* deprecated */ :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
4
4
  } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
@@ -14,6 +14,6 @@
14
14
  } :root {
15
15
  } :root {
16
16
  } :root {
17
- } .input-autocomplete__input_dae0s {
17
+ } .input-autocomplete__input_obkwb {
18
18
  width: auto;
19
19
  }
package/modern/types.d.ts CHANGED
@@ -38,6 +38,14 @@ type MobileProps = {
38
38
  * Пропсы анимации контента (CSSTransition)
39
39
  */
40
40
  transitionProps?: NonNullable<BottomSheetSelectMobileProps['bottomSheetProps']>['transitionProps'];
41
+ /**
42
+ * Клик на кнопку "Применить"
43
+ */
44
+ onApply?: () => void;
45
+ /**
46
+ * Клик на кнопку "Отмена"
47
+ */
48
+ onCancel?: () => void;
41
49
  };
42
50
  type InputAutocompleteMobileProps = InputAutocompleteCommonProps & MobileProps;
43
51
  interface InputAutocompleteProps extends InputAutocompleteCommonProps {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-input-autocomplete",
3
- "version": "11.0.3",
3
+ "version": "11.2.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -14,10 +14,10 @@
14
14
  "react": "^16.9.0 || ^17.0.1 || ^18.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@alfalab/core-components-form-control": "^11.1.0",
18
- "@alfalab/core-components-input": "^13.0.2",
19
- "@alfalab/core-components-popover": "^6.1.0",
20
- "@alfalab/core-components-select": "^16.0.3",
17
+ "@alfalab/core-components-form-control": "^12.0.0",
18
+ "@alfalab/core-components-input": "^14.0.0",
19
+ "@alfalab/core-components-popover": "^6.2.0",
20
+ "@alfalab/core-components-select": "^17.0.0",
21
21
  "@alfalab/core-components-shared": "^0.8.0",
22
22
  "@alfalab/core-components-mq": "^4.2.0",
23
23
  "@alfalab/hooks": "^1.13.0",
@@ -5,6 +5,7 @@ import {
5
5
  FormControlMobile,
6
6
  FormControlMobileProps,
7
7
  } from '@alfalab/core-components-form-control/mobile';
8
+ import { ClearButton } from '@alfalab/core-components-input/shared';
8
9
  import type { FieldProps as BaseFieldProps } from '@alfalab/core-components-select/shared';
9
10
  import { getDataTestId } from '@alfalab/core-components-shared';
10
11
  import { useFocus } from '@alfalab/hooks';
@@ -42,6 +43,13 @@ export const AutocompleteMobileField = ({
42
43
  setSelectedItems,
43
44
  selectedMultiple,
44
45
  FormControlComponent,
46
+ rightAddons,
47
+ error,
48
+ readOnly,
49
+ clear,
50
+ onClear,
51
+ onInput,
52
+ colors = 'default',
45
53
  ...restProps
46
54
  }: AutocompleteMobileFieldProps & FieldProps) => {
47
55
  const [focused, setFocused] = useState(false);
@@ -52,6 +60,7 @@ export const AutocompleteMobileField = ({
52
60
 
53
61
  const filled = Boolean(value);
54
62
  const showPlaceholder = placeholder && !filled && labelView === 'outer';
63
+ const clearButtonVisible = clear && filled && !disabled && !readOnly;
55
64
 
56
65
  const { tabIndex, ...restInnerProps } = innerProps;
57
66
 
@@ -73,12 +82,29 @@ export const AutocompleteMobileField = ({
73
82
  disabled={disabled}
74
83
  filled={filled}
75
84
  labelView={labelView}
76
- rightAddons={Arrow}
77
85
  dataTestId={getDataTestId(dataTestId, 'form-control')}
78
86
  // downshift устанавливает фокус на таргет поле после выбора опции, не даем ему это сделать пока открыт список, иначе поле поиска будет терять фокус
79
87
  tabIndex={open ? undefined : tabIndex}
80
88
  {...restProps}
81
89
  {...restInnerProps}
90
+ readOnly={readOnly}
91
+ colors={colors}
92
+ error={error}
93
+ rightAddons={
94
+ (Arrow || rightAddons || clearButtonVisible) && (
95
+ <React.Fragment>
96
+ {clearButtonVisible && (
97
+ <ClearButton
98
+ onClick={onClear}
99
+ disabled={disabled}
100
+ colors={colors}
101
+ />
102
+ )}
103
+ {rightAddons}
104
+ {Arrow}
105
+ </React.Fragment>
106
+ )
107
+ }
82
108
  >
83
109
  <div className={styles.contentWrapper}>
84
110
  {showPlaceholder && <span className={styles.placeholder}>{placeholder}</span>}
@@ -39,6 +39,8 @@ export const InputAutocompleteMobile = React.forwardRef(
39
39
  isBottomSheet = true,
40
40
  dataTestId,
41
41
  transitionProps,
42
+ onCancel,
43
+ onApply,
42
44
  ...restProps
43
45
  }: InputAutocompleteMobileProps,
44
46
  ref,
@@ -78,11 +80,15 @@ export const InputAutocompleteMobile = React.forwardRef(
78
80
  [],
79
81
  );
80
82
 
81
- const handleApply = () => setModalVisibility(false);
83
+ const handleApply = () => {
84
+ setModalVisibility(false);
85
+ onApply?.();
86
+ };
82
87
 
83
88
  const handleCancel = () => {
84
89
  setModalVisibility(false);
85
90
  restorePrevValue();
91
+ onCancel?.();
86
92
  };
87
93
 
88
94
  const handleExiting = (node: HTMLElement) => {
@@ -108,6 +114,8 @@ export const InputAutocompleteMobile = React.forwardRef(
108
114
  },
109
115
  };
110
116
 
117
+ const clear = inputProps?.clear ?? false;
118
+
111
119
  return (
112
120
  <Component
113
121
  Field={AutocompleteMobileField}
@@ -126,7 +134,7 @@ export const InputAutocompleteMobile = React.forwardRef(
126
134
  placeholder,
127
135
  ...inputProps,
128
136
  className: cn(styles.input, inputProps?.className),
129
- clear: inputProps?.clear ?? false,
137
+ clear,
130
138
  ref: mergeRefs([searchInputRef, inputProps?.ref as Ref<HTMLInputElement>]),
131
139
  onChange: onInput,
132
140
  },
@@ -156,6 +164,8 @@ export const InputAutocompleteMobile = React.forwardRef(
156
164
  }}
157
165
  fieldProps={{
158
166
  value: isOpen ? frozenValue.current : value,
167
+ clear,
168
+ onClear: clear ? inputProps?.onClear : undefined,
159
169
  ...(restProps.fieldProps as AnyObject),
160
170
  }}
161
171
  />
package/src/types.ts CHANGED
@@ -54,6 +54,16 @@ type MobileProps = {
54
54
  transitionProps?: NonNullable<
55
55
  BottomSheetSelectMobileProps['bottomSheetProps']
56
56
  >['transitionProps'];
57
+
58
+ /**
59
+ * Клик на кнопку "Применить"
60
+ */
61
+ onApply?: () => void;
62
+
63
+ /**
64
+ * Клик на кнопку "Отмена"
65
+ */
66
+ onCancel?: () => void;
57
67
  };
58
68
 
59
69
  export type InputAutocompleteMobileProps = InputAutocompleteCommonProps & MobileProps;
package/types.d.ts CHANGED
@@ -38,6 +38,14 @@ type MobileProps = {
38
38
  * Пропсы анимации контента (CSSTransition)
39
39
  */
40
40
  transitionProps?: NonNullable<BottomSheetSelectMobileProps['bottomSheetProps']>['transitionProps'];
41
+ /**
42
+ * Клик на кнопку "Применить"
43
+ */
44
+ onApply?: () => void;
45
+ /**
46
+ * Клик на кнопку "Отмена"
47
+ */
48
+ onCancel?: () => void;
41
49
  };
42
50
  type InputAutocompleteMobileProps = InputAutocompleteCommonProps & MobileProps;
43
51
  interface InputAutocompleteProps extends InputAutocompleteCommonProps {