@sima-land/ui-nucleons 41.2.1 → 42.1.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.
package/alert/index.d.ts CHANGED
@@ -8,8 +8,6 @@ export interface AlertProps extends WithBodyScrollLock {
8
8
  className?: string;
9
9
  /** Содержимое "подвала". */
10
10
  footer?: React.ReactNode;
11
- /** Нужно ли выводить в Layer. */
12
- inPortal?: boolean;
13
11
  /** Свойства компонента NavBar. */
14
12
  navBarProps?: NavBarProps;
15
13
  /** Заголовок. */
@@ -26,4 +24,4 @@ export interface AlertProps extends WithBodyScrollLock {
26
24
  * @param props Свойства.
27
25
  * @return Элемент.
28
26
  */
29
- export declare const Alert: ({ inPortal, ...restProps }: AlertProps) => JSX.Element;
27
+ export declare const Alert: ({ children, className, footer, navBarProps, title, withDivideNavBar, withNavBar, withScrollDisable, scrollDisableOptions, onClose, }: AlertProps) => JSX.Element;
package/alert/index.js CHANGED
@@ -18,24 +18,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
21
- var __rest = (this && this.__rest) || function (s, e) {
22
- var t = {};
23
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
- t[p] = s[p];
25
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
- t[p[i]] = s[p[i]];
29
- }
30
- return t;
31
- };
32
21
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
23
  };
35
24
  Object.defineProperty(exports, "__esModule", { value: true });
36
25
  exports.Alert = void 0;
37
26
  const react_1 = __importStar(require("react"));
38
- const portal_1 = require("../portal");
39
27
  const nav_bar_1 = require("../nav-bar");
40
28
  const bind_1 = __importDefault(require("classnames/bind"));
41
29
  const alert_module_scss_1 = __importDefault(require("./alert.module.scss"));
@@ -48,27 +36,15 @@ const cx = bind_1.default.bind(alert_module_scss_1.default);
48
36
  * @param props Свойства.
49
37
  * @return Элемент.
50
38
  */
51
- const Alert = (_a) => {
52
- var { inPortal = true } = _a, restProps = __rest(_a, ["inPortal"]);
39
+ const Alert = ({ children, className, footer, navBarProps, title, withDivideNavBar, withNavBar = Boolean(title), withScrollDisable = false, scrollDisableOptions, onClose, }) => {
53
40
  const layer = (0, layer_1.useLayer)() + 100;
54
- const Wrapper = inPortal ? portal_1.Portal : react_1.Fragment;
55
- return (react_1.default.createElement(layer_1.LayerProvider, { value: layer },
56
- react_1.default.createElement(Wrapper, null,
57
- react_1.default.createElement(AlertInner, Object.assign({}, restProps)))));
58
- };
59
- exports.Alert = Alert;
60
- /**
61
- * Промежуточный компонент, необходимый для того чтобы не передавать реф для блокировки прокрутки через портал.
62
- * @param props Свойства.
63
- * @return Элемент.
64
- */
65
- const AlertInner = ({ children, className, footer, navBarProps, title, withDivideNavBar, withNavBar = Boolean(title), withScrollDisable = false, scrollDisableOptions, onClose, }) => {
66
41
  const rootRef = (0, react_1.useRef)(null);
67
- const layer = (0, layer_1.useLayer)();
68
42
  (0, body_scroll_1.useBodyScrollLock)(rootRef, withScrollDisable, Object.assign({ allowTouchMove: body_scroll_1.allowTouchMove }, scrollDisableOptions));
69
- return (react_1.default.createElement("div", { ref: rootRef, className: cx('overlay'), style: { zIndex: layer }, onClick: e => e.target === e.currentTarget && (onClose === null || onClose === void 0 ? void 0 : onClose()), "data-testid": 'alert:overlay' },
70
- react_1.default.createElement("div", { className: cx('alert', className), "data-testid": 'alert' },
71
- withNavBar && (react_1.default.createElement(nav_bar_1.NavBar, Object.assign({}, navBarProps, { title: title, bottomBordered: withDivideNavBar, className: cx('header') }))),
72
- react_1.default.createElement("div", { className: cx('main') }, children),
73
- Boolean(footer) && react_1.default.createElement("div", { className: borders_1.InnerBorder.top }, footer))));
43
+ return (react_1.default.createElement(layer_1.LayerProvider, { value: layer },
44
+ react_1.default.createElement("div", { ref: rootRef, className: cx('overlay'), style: { zIndex: layer }, onClick: e => e.target === e.currentTarget && (onClose === null || onClose === void 0 ? void 0 : onClose()), "data-testid": 'alert:overlay' },
45
+ react_1.default.createElement("div", { className: cx('alert', className), "data-testid": 'alert' },
46
+ withNavBar && (react_1.default.createElement(nav_bar_1.NavBar, Object.assign({}, navBarProps, { title: title, bottomBordered: withDivideNavBar, className: cx('header') }))),
47
+ react_1.default.createElement("div", { className: cx('main') }, children),
48
+ Boolean(footer) && react_1.default.createElement("div", { className: borders_1.InnerBorder.top }, footer)))));
74
49
  };
50
+ exports.Alert = Alert;
package/modal/index.d.ts CHANGED
@@ -13,8 +13,6 @@ export interface ModalProps extends WithBodyScrollLock {
13
13
  onClose?: () => void;
14
14
  /** Размер окна. */
15
15
  size?: ModalSize;
16
- /** Нужно ли выводить элемент в портале (для SSR следует указывать false). */
17
- inPortal?: boolean;
18
16
  /** Идентификатор для систем автоматизированного тестирования. */
19
17
  'data-testid'?: string;
20
18
  }
package/modal/index.js CHANGED
@@ -18,17 +18,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
21
- var __rest = (this && this.__rest) || function (s, e) {
22
- var t = {};
23
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
- t[p] = s[p];
25
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
- t[p[i]] = s[p[i]];
29
- }
30
- return t;
31
- };
32
21
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
23
  };
@@ -39,7 +28,6 @@ const top_bar_1 = require("../top-bar");
39
28
  const bottom_bar_1 = require("../bottom-bar");
40
29
  const utils_1 = require("./utils");
41
30
  const shadows_1 = require("../styling/shadows");
42
- const portal_1 = require("../portal");
43
31
  const lodash_1 = require("lodash");
44
32
  const slots_1 = require("./slots");
45
33
  const layer_1 = require("../helpers/layer");
@@ -53,19 +41,7 @@ const cx = bind_1.default.bind(modal_module_scss_1.default);
53
41
  * @param props Свойства.
54
42
  * @return Элемент.
55
43
  */
56
- const Modal = (_a) => {
57
- var { inPortal } = _a, restProps = __rest(_a, ["inPortal"]);
58
- const Wrapper = inPortal ? portal_1.Portal : react_1.Fragment;
59
- return (react_1.default.createElement(Wrapper, null,
60
- react_1.default.createElement(ModalInner, Object.assign({}, restProps))));
61
- };
62
- exports.Modal = Modal;
63
- /**
64
- * Внутренний компонент для того чтобы не прокидывать реф через портал.
65
- * @param props Свойства.
66
- * @return Элемент.
67
- */
68
- const ModalInner = ({ children, height, onClose, scrollDisableOptions = { reserveScrollBarGap: true }, size = 'm', withScrollDisable = false, 'data-testid': testId = 'modal', }) => {
44
+ const Modal = ({ children, height, onClose, scrollDisableOptions = { reserveScrollBarGap: true }, size = 'm', withScrollDisable = false, 'data-testid': testId = 'modal', }) => {
69
45
  const layer = (0, layer_1.useLayer)() + 100;
70
46
  const rootRef = (0, react_1.useRef)(null);
71
47
  const bind = (0, utils_1.useCloseHandler)(onClose);
@@ -102,6 +78,7 @@ const ModalInner = ({ children, height, onClose, scrollDisableOptions = { reserv
102
78
  !footer && !fullscreen && react_1.default.createElement("div", { className: cx('footer-stub') }),
103
79
  !fullscreen && overlap && react_1.default.createElement("div", { className: cx('overlap') }, overlap))));
104
80
  };
81
+ exports.Modal = Modal;
105
82
  exports.Modal.Header = slots_1.ModalHeader;
106
83
  exports.Modal.Body = slots_1.ModalBody;
107
84
  exports.Modal.Footer = slots_1.ModalFooter;
package/modal/utils.d.ts CHANGED
@@ -1,9 +1,10 @@
1
+ import React from 'react';
1
2
  /**
2
3
  * Вызывает callback только если клик был начат и закончен по одному и тому же элементу.
3
4
  * @param callback Сработает при клике.
4
5
  * @return Свойства для целевого элемента.
5
6
  */
6
7
  export declare const useCloseHandler: (callback?: (() => void) | undefined) => {
7
- onMouseUp: ({ target, currentTarget, button }: any) => void;
8
- onMouseDown: ({ button, target }: any) => void;
8
+ onMouseUp: ({ target, currentTarget, button }: React.MouseEvent) => void;
9
+ onMouseDown: ({ button, target }: React.MouseEvent) => void;
9
10
  };
package/modal/utils.js CHANGED
@@ -2,12 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useCloseHandler = void 0;
4
4
  const react_1 = require("react");
5
+ const identity_1 = require("../hooks/identity");
5
6
  /**
6
7
  * Вызывает callback только если клик был начат и закончен по одному и тому же элементу.
7
8
  * @param callback Сработает при клике.
8
9
  * @return Свойства для целевого элемента.
9
10
  */
10
11
  const useCloseHandler = (callback) => {
12
+ const callbackRef = (0, identity_1.useIdentityRef)(callback);
11
13
  const mouseDownTarget = (0, react_1.useRef)();
12
14
  const onMouseDown = (0, react_1.useCallback)(({ button, target }) => {
13
15
  if (button === 0) {
@@ -15,12 +17,13 @@ const useCloseHandler = (callback) => {
15
17
  }
16
18
  }, []);
17
19
  const onMouseUp = (0, react_1.useCallback)(({ target, currentTarget, button }) => {
18
- callback &&
20
+ const fn = callbackRef.current;
21
+ fn &&
19
22
  button === 0 &&
20
23
  target === currentTarget &&
21
24
  currentTarget === mouseDownTarget.current &&
22
- callback();
23
- }, [callback]);
25
+ fn();
26
+ }, []);
24
27
  return { onMouseUp, onMouseDown };
25
28
  };
26
29
  exports.useCloseHandler = useCloseHandler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sima-land/ui-nucleons",
3
- "version": "41.2.1",
3
+ "version": "42.1.0",
4
4
  "repository": "ssh://git@github.com:sima-land/ui-nucleons.git",
5
5
  "author": "www.sima-land.ru team",
6
6
  "license": "Apache-2.0",
package/select/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { TextFieldProps } from '../text-field';
3
3
  declare type Size = 's' | 'm' | 'l' | 'xl';
4
- export interface SelectProps extends Omit<TextFieldProps, 'style'> {
4
+ export interface SelectProps extends Omit<TextFieldProps, 'style' | 'endAdornment'> {
5
5
  /** Нужно ли выводить состояние загрузки списка. */
6
6
  loading?: boolean;
7
7
  /** Сработает при открытии/закрытии меню. */
@@ -16,11 +16,18 @@ export interface SelectProps extends Omit<TextFieldProps, 'style'> {
16
16
  renderOption?: (option: any) => React.ReactNode;
17
17
  /** Стили. */
18
18
  style?: React.CSSProperties;
19
+ endAdornment?: TextFieldProps['endAdornment'] | ((opened: boolean) => React.ReactNode);
19
20
  }
21
+ /**
22
+ * Выводит иконку стрелки для поля Select по умолчанию.
23
+ * @param opened Открыт ли список опций.
24
+ * @return Элемент.
25
+ */
26
+ export declare const renderDefaultArrow: (opened: boolean) => JSX.Element;
20
27
  /**
21
28
  * Поле выбора из списка.
22
29
  * @param props Свойства.
23
30
  * @return Элемент.
24
31
  */
25
- export declare const Select: React.FC<SelectProps>;
32
+ export declare const Select: ({ options, optionSize, onSelect, style, className, label, onClick, value, loading, onMenuToggle, renderOption, "data-testid": dataTestId, size, endAdornment, ...restProps }: SelectProps) => JSX.Element;
26
33
  export {};
package/select/index.js CHANGED
@@ -33,7 +33,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.Select = void 0;
36
+ exports.Select = exports.renderDefaultArrow = void 0;
37
37
  const react_1 = __importStar(require("react"));
38
38
  const dropdown_1 = require("../dropdown");
39
39
  const dropdown_item_1 = require("../dropdown-item");
@@ -45,38 +45,61 @@ const up_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/A
45
45
  const select_module_scss_1 = __importDefault(require("./select.module.scss"));
46
46
  const colors_1 = require("../colors");
47
47
  const dropdown_loading_1 = require("../_internal/dropdown-loading");
48
+ const hooks_1 = require("../hooks");
48
49
  const cx = bind_1.default.bind(select_module_scss_1.default);
50
+ /**
51
+ * Выводит иконку стрелки для поля Select по умолчанию.
52
+ * @param opened Открыт ли список опций.
53
+ * @return Элемент.
54
+ */
55
+ const renderDefaultArrow = (opened) => {
56
+ const ArrowSVG = opened ? up_1.default : down_1.default;
57
+ return react_1.default.createElement(ArrowSVG, { fill: colors_1.COLORS.get('gray38') });
58
+ };
59
+ exports.renderDefaultArrow = renderDefaultArrow;
49
60
  /**
50
61
  * Поле выбора из списка.
51
62
  * @param props Свойства.
52
63
  * @return Элемент.
53
64
  */
54
65
  const Select = (_a) => {
55
- var { options, optionSize, onSelect, style, className, label, onClick, value, loading, onMenuToggle, renderOption = String, 'data-testid': dataTestId } = _a, restProps = __rest(_a, ["options", "optionSize", "onSelect", "style", "className", "label", "onClick", "value", "loading", "onMenuToggle", "renderOption", 'data-testid']);
66
+ var { options, optionSize, onSelect, style, className, label, onClick, value, loading, onMenuToggle, renderOption = String, 'data-testid': dataTestId, size, endAdornment = exports.renderDefaultArrow } = _a, restProps = __rest(_a, ["options", "optionSize", "onSelect", "style", "className", "label", "onClick", "value", "loading", "onMenuToggle", "renderOption", 'data-testid', "size", "endAdornment"]);
67
+ const rootRef = (0, react_1.useRef)(null);
56
68
  const fieldRef = (0, react_1.useRef)(null);
57
69
  const menuRef = (0, react_1.useRef)(null);
58
70
  const [opened, toggleMenu] = (0, react_1.useState)(false);
59
- const ArrowSVG = opened ? up_1.default : down_1.default;
60
71
  (0, react_1.useEffect)(() => {
61
- opened && menuRef.current.focus();
72
+ opened && menuRef.current && menuRef.current.focus();
62
73
  onMenuToggle && onMenuToggle(opened);
63
74
  }, [opened]);
64
- return (react_1.default.createElement("div", { style: style, className: cx('root', className), "data-testid": dataTestId },
65
- react_1.default.createElement(text_field_1.TextField, Object.assign({}, restProps, { readOnly: true, "data-testid": 'select:field', ref: fieldRef, variant: 'desktop', label: label, value: value, multiline: false, focused: opened, onClick: e => {
66
- toggleMenu(o => !o);
67
- onClick && onClick(e);
68
- }, onBlur: ({ relatedTarget }) => {
69
- relatedTarget !== menuRef.current && toggleMenu(false);
70
- }, onKeyDown: (e) => {
71
- e.key === 'Enter' && toggleMenu(true);
72
- }, className: cx('field'), endAdornment: react_1.default.createElement(ArrowSVG, { fill: colors_1.COLORS.get('gray38') }) })),
73
- opened && (loading || options.length > 0) && (react_1.default.createElement(dropdown_1.Dropdown, Object.assign({}, (0, dropdown_2.placeDropdown)(restProps.size), { ref: menuRef, "data-testid": 'select:menu', tabIndex: -1, className: cx('menu'), onBlur: () => {
74
- toggleMenu(false);
75
- }, role: 'menu', onKeyDown: (event) => {
75
+ (0, hooks_1.useOutsideClick)(rootRef, toggleMenu.bind(null, false));
76
+ return (react_1.default.createElement("div", { ref: rootRef, style: style, className: cx('root', className), "data-testid": dataTestId },
77
+ react_1.default.createElement(text_field_1.TextField, Object.assign({}, restProps, { size: size, blockProps: {
78
+ ref: fieldRef,
79
+ tabIndex: 0,
80
+ onMouseDown: () => {
81
+ toggleMenu(a => !a);
82
+ },
83
+ onKeyDown: e => {
84
+ e.key === 'Enter' && toggleMenu(true);
85
+ },
86
+ onClick: e => {
87
+ e.preventDefault();
88
+ onClick && onClick(e);
89
+ },
90
+ }, className: select_module_scss_1.default.field, "data-testid": 'select:field', label: label, focused: opened, baseInputProps: {
91
+ // чтобы не ловить фокус на поле
92
+ style: { pointerEvents: 'none' },
93
+ tabIndex: -1,
94
+ }, value: value, multiline: false, variant: 'desktop', readOnly: true, endAdornment: typeof endAdornment === 'function' ? endAdornment(opened) : endAdornment })),
95
+ opened && (loading || options.length > 0) && (react_1.default.createElement(dropdown_1.Dropdown, Object.assign({}, (0, dropdown_2.placeDropdown)(size), { ref: menuRef, "data-testid": 'select:menu', role: 'menu', tabIndex: -1, className: cx('menu'), onKeyDown: event => {
76
96
  if (event.key === 'Enter') {
77
97
  toggleMenu(false);
78
98
  fieldRef.current && fieldRef.current.focus();
79
99
  }
100
+ }, onBlur: () => {
101
+ toggleMenu(false);
102
+ fieldRef.current && fieldRef.current.focus();
80
103
  } }), loading ? (react_1.default.createElement(dropdown_loading_1.DropdownLoading, { "data-testid": 'select:loading-area' })) : (options.map((option, index) => (react_1.default.createElement(dropdown_item_1.DropdownItem, { size: optionSize, key: index, role: 'menuitem', onClick: () => {
81
104
  toggleMenu(false);
82
105
  onSelect && onSelect(option);
@@ -41,7 +41,7 @@ export declare const SidePage: {
41
41
  };
42
42
  Body: {
43
43
  ({ children }: {
44
- children?: React.ReactNode; /** Обработчик "onExiting" для CSSTransition. */
44
+ children?: React.ReactNode;
45
45
  }): JSX.Element;
46
46
  displayName: string;
47
47
  };
@@ -81,10 +81,11 @@ const SidePageInner = ({ size = 'm', children, onClose, withScrollDisable, scrol
81
81
  });
82
82
  (0, body_scroll_1.useBodyScrollLock)(ref, withScrollDisable, scrollDisableOptions);
83
83
  return (react_1.default.createElement("div", Object.assign({ ref: ref, className: cx('overlay'), style: overlayStyles }, (transitionStatus !== 'entering' && overlayBind)),
84
- react_1.default.createElement("div", { className: cx('main', `size-${size}`) },
85
- header,
86
- react_1.default.createElement("div", { className: cx('body') }, body),
87
- footer)));
84
+ react_1.default.createElement(layer_1.LayerProvider, { value: layer },
85
+ react_1.default.createElement("div", { className: cx('main', `size-${size}`) },
86
+ header,
87
+ react_1.default.createElement("div", { className: cx('body') }, body),
88
+ footer))));
88
89
  };
89
90
  exports.SidePage.Header = slots_1.SidePageHeader;
90
91
  exports.SidePage.Body = slots_1.SidePageBody;
@@ -46,6 +46,8 @@ export interface TextFieldProps extends Omit<React.InputHTMLAttributes<HTMLInput
46
46
  startAdornment?: React.ReactNode;
47
47
  /** Вариант отображения. */
48
48
  variant?: Variant;
49
+ /** Свойства элемента-блока. */
50
+ blockProps?: React.HTMLProps<HTMLDivElement>;
49
51
  /** Идентификатор для систем автоматизированного тестирования. */
50
52
  'data-testid'?: string;
51
53
  }
@@ -51,7 +51,7 @@ const modifiersToClasses = ({ disabled, failed, focused, variant, }) => cx(disab
51
51
  * @param props Свойства.
52
52
  * @return Элемент.
53
53
  */
54
- exports.TextField = (0, react_1.forwardRef)(function TextField({ autoFocus, caption, classes = {}, defaultValue, disabled, endAdornment, failed, focused: asFocused, label, onClick, onBlur, onChange, onFocus, onInput, onKeyDown, onKeyUp, placeholder, readOnly, rounds = 'all', size = exports.DEFAULTS.size, startAdornment, value, variant = 'desktop', multiline, baseInputProps = {}, className, restPlaceholder, style, 'data-testid': dataTestId, }, ref) {
54
+ exports.TextField = (0, react_1.forwardRef)(function TextField({ autoFocus, caption, classes = {}, defaultValue, disabled, endAdornment, failed, focused: asFocused, label, onClick, onBlur, onChange, onFocus, onInput, onKeyDown, onKeyUp, placeholder, readOnly, rounds = 'all', size = exports.DEFAULTS.size, startAdornment, value, variant = 'desktop', multiline, baseInputProps = {}, className, restPlaceholder, style, blockProps, 'data-testid': dataTestId, }, ref) {
55
55
  const [hasValue, toggleHasValue] = (0, react_1.useState)(isVisible(value) || isVisible(defaultValue));
56
56
  const [reallyFocused, toggleFocused] = (0, react_1.useState)(autoFocus);
57
57
  const focused = reallyFocused || Boolean(asFocused);
@@ -70,21 +70,25 @@ exports.TextField = (0, react_1.forwardRef)(function TextField({ autoFocus, capt
70
70
  (0, react_1.useImperativeHandle)(ref, () => baseInputRef.current);
71
71
  (0, react_1.useEffect)(() => toggleHasValue(Boolean(baseInputRef.current.value)));
72
72
  return (react_1.default.createElement("div", { "data-testid": dataTestId, className: cx('root', className, classes.root), style: style },
73
- react_1.default.createElement("div", { "data-testid": 'text-field:block', className: cx('reset', 'input-block', commonModifyClasses, size && `size-${size}`, focused && classes.blockFocused, multiline && 'multiline', withLabel && 'with-label', variant === 'desktop' && rounds !== 'none' && shapes_1.SmallRounds[rounds]), onClick: event => {
73
+ react_1.default.createElement("div", Object.assign({ "data-testid": 'text-field:block', className: cx('reset', 'input-block', commonModifyClasses, size && `size-${size}`, focused && classes.blockFocused, multiline && 'multiline', withLabel && 'with-label', variant === 'desktop' && rounds !== 'none' && shapes_1.SmallRounds[rounds], blockProps === null || blockProps === void 0 ? void 0 : blockProps.className), onClick: event => {
74
74
  const input = baseInputRef.current;
75
75
  onClick === null || onClick === void 0 ? void 0 : onClick(event);
76
- input && !disabled && input !== document.activeElement && input.focus();
77
- } },
76
+ input &&
77
+ !disabled &&
78
+ !event.defaultPrevented &&
79
+ input !== document.activeElement &&
80
+ input.focus();
81
+ } }, blockProps),
78
82
  !multiline && Boolean(startAdornment) && (react_1.default.createElement(box_1.Box, { display: 'flex', alignItems: 'center', marginRight: 4 }, startAdornment)),
79
83
  react_1.default.createElement("div", { className: cx('main-column') },
80
84
  withLabel && (react_1.default.createElement("label", { className: cx('label', commonModifyClasses, hasValue && 'filled', labelAsPlaceholder && 'as-placeholder'), children: label, "data-testid": 'text-field:label' })),
81
85
  react_1.default.createElement("div", { className: cx('input-wrapper') },
82
86
  react_1.default.createElement(base_input_1.BaseInput, Object.assign({}, baseInputProps, { "data-testid": 'text-field:field', multiline: multiline, ref: baseInputRef, placeholder: withLabel && labelAsPlaceholder ? undefined : placeholder, restPlaceholder: withLabel && labelAsPlaceholder ? undefined : restPlaceholder, autoFocus: autoFocus, className: cx('base-input', commonModifyClasses, classes.baseInput, size && `size-${size}`), defaultValue: defaultValue, value: value, readOnly: readOnly, disabled: disabled, onFocus: (event) => {
83
- (0, lodash_1.isFunction)(onFocus) && onFocus(event);
87
+ onFocus && onFocus(event);
84
88
  toggleHasValue(Boolean(event.target.value));
85
89
  toggleFocused(true);
86
90
  }, onBlur: (event) => {
87
- (0, lodash_1.isFunction)(onBlur) && onBlur(event);
91
+ onBlur && onBlur(event);
88
92
  toggleHasValue(Boolean(event.target.value));
89
93
  toggleFocused(false);
90
94
  }, onInput: onInput, onChange: onChange, onKeyDown: onKeyDown, onKeyUp: onKeyUp })))),