@alfalab/core-components-input-autocomplete 14.0.6 → 14.0.7-alfasans

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 (43) hide show
  1. package/autocomplete-field/Component.js +9 -19
  2. package/autocomplete-field/Component.js.map +1 -1
  3. package/autocomplete-field/index.css +1 -1
  4. package/autocomplete-field/index.module.css.js +1 -1
  5. package/autocomplete-mobile-field/Component.js +10 -35
  6. package/autocomplete-mobile-field/Component.js.map +1 -1
  7. package/autocomplete-mobile-field/index.css +15 -13
  8. package/autocomplete-mobile-field/index.module.css.js +1 -1
  9. package/cssm/autocomplete-field/Component.js +9 -19
  10. package/cssm/autocomplete-field/Component.js.map +1 -1
  11. package/cssm/autocomplete-mobile-field/Component.js +13 -38
  12. package/cssm/autocomplete-mobile-field/Component.js.map +1 -1
  13. package/cssm/autocomplete-mobile-field/index.module.css +5 -3
  14. package/esm/autocomplete-field/Component.js +10 -20
  15. package/esm/autocomplete-field/Component.js.map +1 -1
  16. package/esm/autocomplete-field/index.css +1 -1
  17. package/esm/autocomplete-field/index.module.css.js +1 -1
  18. package/esm/autocomplete-mobile-field/Component.js +12 -37
  19. package/esm/autocomplete-mobile-field/Component.js.map +1 -1
  20. package/esm/autocomplete-mobile-field/index.css +15 -13
  21. package/esm/autocomplete-mobile-field/index.module.css.js +1 -1
  22. package/esm/mobile/mobile.css +1 -1
  23. package/esm/mobile/mobile.module.css.js +1 -1
  24. package/mobile/mobile.css +1 -1
  25. package/mobile/mobile.module.css.js +1 -1
  26. package/modern/autocomplete-field/Component.js +7 -17
  27. package/modern/autocomplete-field/Component.js.map +1 -1
  28. package/modern/autocomplete-field/index.css +1 -1
  29. package/modern/autocomplete-field/index.module.css.js +1 -1
  30. package/modern/autocomplete-mobile-field/Component.js +12 -37
  31. package/modern/autocomplete-mobile-field/Component.js.map +1 -1
  32. package/modern/autocomplete-mobile-field/index.css +15 -13
  33. package/modern/autocomplete-mobile-field/index.module.css.js +1 -1
  34. package/modern/mobile/mobile.css +1 -1
  35. package/modern/mobile/mobile.module.css.js +1 -1
  36. package/moderncssm/autocomplete-field/Component.js +7 -17
  37. package/moderncssm/autocomplete-field/Component.js.map +1 -1
  38. package/moderncssm/autocomplete-mobile-field/Component.js +12 -37
  39. package/moderncssm/autocomplete-mobile-field/Component.js.map +1 -1
  40. package/moderncssm/autocomplete-mobile-field/index.module.css +2 -1
  41. package/package.json +10 -10
  42. package/src/autocomplete-field/Component.tsx +9 -16
  43. package/src/autocomplete-mobile-field/Component.tsx +17 -37
@@ -1 +1 @@
1
- {"version":3,"file":"Component.js","sources":["../../src/autocomplete-field/Component.tsx"],"sourcesContent":["import React, { useCallback, useRef } from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport cn from 'classnames';\n\nimport { type InputProps } from '@alfalab/core-components-input';\nimport { InputDesktop as DefaultInput } from '@alfalab/core-components-input/desktop';\nimport { getAddonsByPriority } from '@alfalab/core-components-input/helpers/get-addons-by-priority';\nimport { type FieldProps } from '@alfalab/core-components-select/shared';\n\nimport { OnInputReason } from '../enums';\nimport { type InputAutocompleteCommonProps } from '../types';\n\nimport styles from './index.module.css';\n\nexport type AutocompleteFieldProps = FieldProps &\n Pick<InputAutocompleteCommonProps, 'Input' | 'inputProps' | 'value' | 'onInput' | 'readOnly'>;\n\nexport const AutocompleteField = ({\n label,\n labelView = 'inner',\n placeholder,\n size,\n Arrow,\n Input = DefaultInput,\n value,\n error,\n success,\n hint,\n disabled,\n readOnly,\n onInput,\n inputProps = {},\n innerProps,\n dataTestId,\n}: AutocompleteFieldProps) => {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const { onClick, onFocus } = innerProps;\n\n const inputDisabled = disabled || readOnly;\n\n const handleClick = useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n if (onClick) onClick(event);\n\n if (inputRef.current) {\n inputRef.current.focus();\n }\n },\n [onClick],\n );\n\n const handleInput: InputProps['onChange'] = (_, payload) =>\n onInput?.(payload.value, OnInputReason.Change);\n\n /**\n * Right addons priority [4] <= [3] <= [2] <= [1] or [0]\n * [4] - Clear\n * [3] - Status (error, success)\n * [2] - Common (info, e.g.)\n * [1] - Indicators (eye, calendar, chevron, stepper e.g.)\n * [0] - Lock\n */\n const rightAddonsMap = getAddonsByPriority([\n {\n priority: 2,\n predicate: Boolean(inputProps.rightAddons),\n render: () => inputProps.rightAddons,\n },\n {\n priority: 1,\n predicate: Boolean(Arrow) && !inputDisabled,\n render: () => (\n <span\n className={cn(styles.arrow, {\n [styles.error]: error,\n })}\n >\n {Arrow}\n </span>\n ),\n },\n ]);\n\n return (\n <Input\n dataTestId={dataTestId}\n {...inputProps}\n {...innerProps}\n wrapperRef={mergeRefs([\n innerProps.ref as React.Ref<HTMLElement>,\n inputProps.wrapperRef as React.Ref<HTMLElement>,\n ])}\n ref={mergeRefs([inputRef, inputProps.ref as React.Ref<HTMLElement>])}\n disabled={disabled}\n readOnly={readOnly}\n block={true}\n label={label}\n labelView={labelView}\n placeholder={placeholder}\n size={size}\n error={error}\n success={success}\n hint={hint}\n onChange={handleInput}\n onClick={inputDisabled ? undefined : handleClick}\n onFocus={inputDisabled ? undefined : onFocus}\n autoComplete='off'\n value={value}\n rightAddons={rightAddonsMap}\n />\n );\n};\n"],"names":["DefaultInput"],"mappings":";;;;;;;;MAiBa,iBAAiB,GAAG,CAAC,EAC9B,KAAK,EACL,SAAS,GAAG,OAAO,EACnB,WAAW,EACX,IAAI,EACJ,KAAK,EACL,KAAK,GAAGA,YAAY,EACpB,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,UAAU,GAAG,EAAE,EACf,UAAU,EACV,UAAU,GACW,KAAI;AACzB,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC;AAE/C,IAAA,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,UAAU;AAEvC,IAAA,MAAM,aAAa,GAA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AC,CAAC,EACpE,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,IAAI,EACX,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,aAAa,GAAG,SAAS,GAAG,WAAW,EAChD,OAAO,EAAE,aAAa,GAAG,SAAS,GAAG,OAAO,EAC5C,YAAY,EAAC,KAAK,EAClB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,cAAc,EAC7B,CAAA;AAEV;;;;"}
1
+ {"version":3,"file":"Component.js","sources":["../../src/autocomplete-field/Component.tsx"],"sourcesContent":["import React, { Fragment, useCallback, useRef } from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport cn from 'classnames';\n\nimport { type InputProps } from '@alfalab/core-components-input';\nimport { InputDesktop as DefaultInput } from '@alfalab/core-components-input/desktop';\nimport { type FieldProps } from '@alfalab/core-components-select/shared';\n\nimport { OnInputReason } from '../enums';\nimport { type InputAutocompleteCommonProps } from '../types';\n\nimport styles from './index.module.css';\n\nexport type AutocompleteFieldProps = FieldProps &\n Pick<InputAutocompleteCommonProps, 'Input' | 'inputProps' | 'value' | 'onInput' | 'readOnly'>;\n\nexport const AutocompleteField = ({\n label,\n labelView = 'inner',\n placeholder,\n size,\n Arrow,\n Input = DefaultInput,\n value,\n error,\n success,\n hint,\n disabled,\n readOnly,\n onInput,\n inputProps = {},\n innerProps,\n dataTestId,\n}: AutocompleteFieldProps) => {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const { onClick, onFocus } = innerProps;\n\n const inputDisabled = disabled || readOnly;\n\n const handleClick = useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n if (onClick) onClick(event);\n\n if (inputRef.current) {\n inputRef.current.focus();\n }\n },\n [onClick],\n );\n\n const handleInput: InputProps['onChange'] = (_, payload) =>\n onInput?.(payload.value, OnInputReason.Change);\n\n /**\n * Right addons priority [4] <= [3] <= [2] <= [1] or [0]\n * [4] - Clear\n * [3] - Status (error, success)\n * [2] - Common (info, e.g.)\n * [1] - Indicators (eye, calendar, chevron, stepper e.g.)\n * [0] - Lock\n */\n const renderRightAddons = () => (\n <Fragment>\n {inputProps.rightAddons}\n {Arrow && !inputDisabled && (\n <span\n className={cn(styles.arrow, {\n [styles.error]: error,\n })}\n >\n {Arrow}\n </span>\n )}\n </Fragment>\n );\n\n return (\n <Input\n dataTestId={dataTestId}\n {...inputProps}\n {...innerProps}\n wrapperRef={mergeRefs([\n innerProps.ref as React.Ref<HTMLElement>,\n inputProps.wrapperRef as React.Ref<HTMLElement>,\n ])}\n ref={mergeRefs([inputRef, inputProps.ref as React.Ref<HTMLElement>])}\n disabled={disabled}\n readOnly={readOnly}\n block={true}\n label={label}\n labelView={labelView}\n placeholder={placeholder}\n size={size}\n error={error}\n success={success}\n hint={hint}\n onChange={handleInput}\n onClick={inputDisabled ? undefined : handleClick}\n onFocus={inputDisabled ? undefined : onFocus}\n autoComplete='off'\n value={value}\n rightAddons={renderRightAddons()}\n />\n );\n};\n"],"names":["DefaultInput"],"mappings":";;;;;;;MAgBa,iBAAiB,GAAG,CAAC,EAC9B,KAAK,EACL,SAAS,GAAG,OAAO,EACnB,WAAW,EACX,IAAI,EACJ,KAAK,EACL,KAAK,GAAGA,YAAY,EACpB,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,UAAU,GAAG,EAAE,EACf,UAAU,EACV,UAAU,GACW,KAAI;AACzB,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC;AAE/C,IAAA,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,UAAU;AAEvC,IAAA,MAAM,aAAa,GAAG,QAAQ,IAAI,Q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EAAE,IAAI,EACV,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,aAAa,GAAG,SAAS,GAAG,WAAW,EAChD,OAAO,EAAE,aAAa,GAAG,SAAS,GAAG,OAAO,EAC5C,YAAY,EAAC,KAAK,EAClB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,iBAAiB,EAAE,EAClC,CAAA;AAEV;;;;"}
@@ -1,7 +1,7 @@
1
- import React, { useState, useRef } from 'react';
1
+ import React, { useState, useRef, Fragment } from 'react';
2
2
  import cn from 'classnames';
3
3
  import { FormControlMobile } from '@alfalab/core-components-form-control/moderncssm/mobile';
4
- import { getAddonsByPriority, ClearButton, LockIcon } from '@alfalab/core-components-input/moderncssm/shared';
4
+ import { ClearButton, LockIcon } from '@alfalab/core-components-input/moderncssm/shared';
5
5
  import { getDataTestId } from '@alfalab/core-components-shared/moderncssm';
6
6
  import { StatusBadge } from '@alfalab/core-components-status-badge/moderncssm';
7
7
  import { useFocus } from '@alfalab/hooks';
@@ -24,47 +24,22 @@ const AutocompleteMobileField = ({ size = 56, open, disabled, value, innerProps,
24
24
  * [1] - Indicators (eye, calendar, chevron, stepper e.g.)
25
25
  * [0] - Lock
26
26
  */
27
- const rightAddonsMap = getAddonsByPriority([
28
- {
29
- priority: 4,
30
- predicate: clear && filled && !disabled && !readOnly,
31
- render: () => React.createElement(ClearButton, { onClick: onClear, disabled: disabled, colors: colors }),
32
- },
33
- {
34
- priority: 3,
35
- predicate: Boolean(error),
36
- render: () => (React.createElement("div", { className: styles.errorIcon, "data-addon": 'error-icon' },
37
- React.createElement(StatusBadge, { view: 'negative-alert', size: statusBadgeSize, dataTestId: getDataTestId(dataTestId, 'error-icon') }))),
38
- },
39
- {
40
- priority: 3,
41
- predicate: Boolean(success && !error),
42
- render: () => (React.createElement("div", { className: styles.successIcon },
43
- React.createElement(StatusBadge, { view: 'positive-checkmark', size: statusBadgeSize, dataTestId: getDataTestId(dataTestId, 'success-icon') }))),
44
- },
45
- {
46
- priority: 2,
47
- predicate: Boolean(rightAddons),
48
- render: () => rightAddons,
49
- },
50
- {
51
- priority: 1,
52
- predicate: Boolean(Arrow) && !disabled && !readOnly,
53
- render: () => Arrow,
54
- },
55
- {
56
- priority: 0,
57
- predicate: Boolean(disabled || readOnly),
58
- render: () => React.createElement(LockIcon, { colors: colors, size: size }),
59
- },
60
- ]);
27
+ const renderRightAddons = () => (React.createElement(Fragment, null,
28
+ clear && filled && !disabled && !readOnly && (React.createElement(ClearButton, { onClick: onClear, disabled: disabled, colors: colors })),
29
+ error && (React.createElement("div", { className: styles.errorIcon, "data-addon": 'error-icon' },
30
+ React.createElement(StatusBadge, { view: 'negative-alert', size: statusBadgeSize, dataTestId: getDataTestId(dataTestId, 'error-icon') }))),
31
+ success && !error && (React.createElement("div", { className: styles.successIcon },
32
+ React.createElement(StatusBadge, { view: 'positive-checkmark', size: statusBadgeSize, dataTestId: getDataTestId(dataTestId, 'success-icon') }))),
33
+ rightAddons,
34
+ !disabled && !readOnly && Arrow,
35
+ (disabled || readOnly) && React.createElement(LockIcon, { colors: colors, size: size })));
61
36
  return (React.createElement("div", { className: styles.component, ref: wrapperRef, onFocus: () => setFocused(true), onBlur: () => setFocused(false) },
62
37
  React.createElement(FormControlMobile, { fieldClassName: cn(styles.field, fieldClassName, {
63
38
  [styles.disabled]: disabled,
64
39
  [styles.focusVisible]: focusVisible,
65
40
  }), block: true, size: size, focused: focused, disabled: disabled, filled: filled, labelView: labelView, dataTestId: getDataTestId(dataTestId, 'form-control'),
66
41
  // downshift устанавливает фокус на таргет поле после выбора опции, не даем ему это сделать пока открыт список, иначе поле поиска будет терять фокус
67
- tabIndex: open ? undefined : tabIndex, ...restProps, ...restInnerProps, readOnly: readOnly, colors: colors, error: error, rightAddons: rightAddonsMap },
42
+ tabIndex: open ? undefined : tabIndex, ...restProps, ...restInnerProps, readOnly: readOnly, colors: colors, error: error, rightAddons: renderRightAddons() },
68
43
  React.createElement("div", { className: styles.contentWrapper },
69
44
  showPlaceholder && React.createElement("span", { className: styles.placeholder }, placeholder),
70
45
  filled && React.createElement("div", { className: styles.value }, value)))));
@@ -1 +1 @@
1
- {"version":3,"file":"Component.js","sources":["../../src/autocomplete-mobile-field/Component.tsx"],"sourcesContent":["import React, { type ElementType, useRef, useState } from 'react';\nimport cn from 'classnames';\n\nimport {\n FormControlMobile,\n type FormControlMobileProps,\n} from '@alfalab/core-components-form-control/mobile';\nimport { ClearButton, getAddonsByPriority, LockIcon } from '@alfalab/core-components-input/shared';\nimport { type FieldProps as BaseFieldProps } from '@alfalab/core-components-select/shared';\nimport { getDataTestId } from '@alfalab/core-components-shared';\nimport { StatusBadge } from '@alfalab/core-components-status-badge';\nimport { useFocus } from '@alfalab/hooks';\n\nimport styles from './index.module.css';\n\ntype FieldProps = {\n /**\n * Компонент FormControl\n */\n FormControlComponent?: ElementType;\n};\n\nexport type AutocompleteMobileFieldProps = FormControlMobileProps &\n Omit<BaseFieldProps, 'selected' | 'multiple' | 'success'> & {\n /**\n * Значение поля ввода\n */\n value?: string;\n };\n\n// eslint-disable-next-line complexity\nexport const AutocompleteMobileField = ({\n size = 56,\n open,\n disabled,\n value,\n innerProps,\n dataTestId,\n fieldClassName,\n labelView = 'inner',\n placeholder,\n Arrow,\n valueRenderer,\n toggleMenu,\n setSelectedItems,\n selectedMultiple,\n FormControlComponent,\n rightAddons,\n error,\n readOnly,\n clear,\n success,\n onClear,\n onInput,\n colors = 'default',\n ...restProps\n}: AutocompleteMobileFieldProps & FieldProps) => {\n const [focused, setFocused] = useState(false);\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n const [focusVisible] = useFocus(wrapperRef, 'keyboard');\n\n const filled = Boolean(value);\n const showPlaceholder = placeholder && !filled && labelView === 'outer';\n\n const statusBadgeSize = size === 40 ? 16 : 20;\n\n const { tabIndex, ...restInnerProps } = innerProps;\n\n /**\n * Right addons priority [4] <= [3] <= [2] <= [1] or [0]\n * [4] - Clear\n * [3] - Status (error, success)\n * [2] - Common (info, e.g.)\n * [1] - Indicators (eye, calendar, chevron, stepper e.g.)\n * [0] - Lock\n */\n const rightAddonsMap = getAddonsByPriority([\n {\n priority: 4,\n predicate: clear && filled && !disabled && !readOnly,\n render: () => <ClearButton onClick={onClear} disabled={disabled} colors={colors} />,\n },\n {\n priority: 3,\n predicate: Boolean(error),\n render: () => (\n <div className={styles.errorIcon} data-addon='error-icon'>\n <StatusBadge\n view='negative-alert'\n size={statusBadgeSize}\n dataTestId={getDataTestId(dataTestId, 'error-icon')}\n />\n </div>\n ),\n },\n {\n priority: 3,\n predicate: Boolean(success && !error),\n render: () => (\n <div className={styles.successIcon}>\n <StatusBadge\n view='positive-checkmark'\n size={statusBadgeSize}\n dataTestId={getDataTestId(dataTestId, 'success-icon')}\n />\n </div>\n ),\n },\n {\n priority: 2,\n predicate: Boolean(rightAddons),\n render: () => rightAddons,\n },\n {\n priority: 1,\n predicate: Boolean(Arrow) && !disabled && !readOnly,\n render: () => Arrow,\n },\n {\n priority: 0,\n predicate: Boolean(disabled || readOnly),\n render: () => <LockIcon colors={colors} size={size} />,\n },\n ]);\n\n return (\n <div\n className={styles.component}\n ref={wrapperRef}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n >\n <FormControlMobile\n fieldClassName={cn(styles.field, fieldClassName, {\n [styles.disabled]: disabled,\n [styles.focusVisible]: focusVisible,\n })}\n block={true}\n size={size}\n focused={focused}\n disabled={disabled}\n filled={filled}\n labelView={labelView}\n dataTestId={getDataTestId(dataTestId, 'form-control')}\n // downshift устанавливает фокус на таргет поле после выбора опции, не даем ему это сделать пока открыт список, иначе поле поиска будет терять фокус\n tabIndex={open ? undefined : tabIndex}\n {...restProps}\n {...restInnerProps}\n readOnly={readOnly}\n colors={colors}\n error={error}\n rightAddons={rightAddonsMap}\n >\n <div className={styles.contentWrapper}>\n {showPlaceholder && <span className={styles.placeholder}>{placeholder}</span>}\n {filled && <div className={styles.value}>{value}</div>}\n </div>\n </FormControlMobile>\n </div>\n );\n};\n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-mobile-field/Component.tsx"],"sourcesContent":["import React, { type ElementType, Fragment, useRef, useState } from 'react';\nimport cn from 'classnames';\n\nimport {\n FormControlMobile,\n type FormControlMobileProps,\n} from '@alfalab/core-components-form-control/mobile';\nimport { ClearButton, LockIcon } from '@alfalab/core-components-input/shared';\nimport { type FieldProps as BaseFieldProps } from '@alfalab/core-components-select/shared';\nimport { getDataTestId } from '@alfalab/core-components-shared';\nimport { StatusBadge } from '@alfalab/core-components-status-badge';\nimport { useFocus } from '@alfalab/hooks';\n\nimport styles from './index.module.css';\n\ntype FieldProps = {\n /**\n * Компонент FormControl\n */\n FormControlComponent?: ElementType;\n};\n\nexport type AutocompleteMobileFieldProps = FormControlMobileProps &\n Omit<BaseFieldProps, 'selected' | 'multiple' | 'success'> & {\n /**\n * Значение поля ввода\n */\n value?: string;\n };\n\n// eslint-disable-next-line complexity\nexport const AutocompleteMobileField = ({\n size = 56,\n open,\n disabled,\n value,\n innerProps,\n dataTestId,\n fieldClassName,\n labelView = 'inner',\n placeholder,\n Arrow,\n valueRenderer,\n toggleMenu,\n setSelectedItems,\n selectedMultiple,\n FormControlComponent,\n rightAddons,\n error,\n readOnly,\n clear,\n success,\n onClear,\n onInput,\n colors = 'default',\n ...restProps\n}: AutocompleteMobileFieldProps & FieldProps) => {\n const [focused, setFocused] = useState(false);\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n const [focusVisible] = useFocus(wrapperRef, 'keyboard');\n\n const filled = Boolean(value);\n const showPlaceholder = placeholder && !filled && labelView === 'outer';\n\n const statusBadgeSize = size === 40 ? 16 : 20;\n\n const { tabIndex, ...restInnerProps } = innerProps;\n\n /**\n * Right addons priority [4] <= [3] <= [2] <= [1] or [0]\n * [4] - Clear\n * [3] - Status (error, success)\n * [2] - Common (info, e.g.)\n * [1] - Indicators (eye, calendar, chevron, stepper e.g.)\n * [0] - Lock\n */\n const renderRightAddons = () => (\n <Fragment>\n {clear && filled && !disabled && !readOnly && (\n <ClearButton onClick={onClear} disabled={disabled} colors={colors} />\n )}\n {error && (\n <div className={styles.errorIcon} data-addon='error-icon'>\n <StatusBadge\n view='negative-alert'\n size={statusBadgeSize}\n dataTestId={getDataTestId(dataTestId, 'error-icon')}\n />\n </div>\n )}\n {success && !error && (\n <div className={styles.successIcon}>\n <StatusBadge\n view='positive-checkmark'\n size={statusBadgeSize}\n dataTestId={getDataTestId(dataTestId, 'success-icon')}\n />\n </div>\n )}\n {rightAddons}\n {!disabled && !readOnly && Arrow}\n {(disabled || readOnly) && <LockIcon colors={colors} size={size} />}\n </Fragment>\n );\n\n return (\n <div\n className={styles.component}\n ref={wrapperRef}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n >\n <FormControlMobile\n fieldClassName={cn(styles.field, fieldClassName, {\n [styles.disabled]: disabled,\n [styles.focusVisible]: focusVisible,\n })}\n block={true}\n size={size}\n focused={focused}\n disabled={disabled}\n filled={filled}\n labelView={labelView}\n dataTestId={getDataTestId(dataTestId, 'form-control')}\n // downshift устанавливает фокус на таргет поле после выбора опции, не даем ему это сделать пока открыт список, иначе поле поиска будет терять фокус\n tabIndex={open ? undefined : tabIndex}\n {...restProps}\n {...restInnerProps}\n readOnly={readOnly}\n colors={colors}\n error={error}\n rightAddons={renderRightAddons()}\n >\n <div className={styles.contentWrapper}>\n {showPlaceholder && <span className={styles.placeholder}>{placeholder}</span>}\n {filled && <div className={styles.value}>{value}</div>}\n </div>\n </FormControlMobile>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA8BA;AACO,MAAM,uBAAuB,GAAG,CAAC,EACpC,IAAI,GAAG,EAAE,EACT,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,UAAU,EACV,UAAU,EACV,cAAc,EACd,SAAS,GAAG,OAAO,EACnB,WAAW,EACX,KAAK,EACL,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACX,KAAK,EACL,QAAQ,EACR,KAAK,EACL,OAAO,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AAE,MAAM,CAAC,cAAc,EAAA;gBAChC,eAAe,IAAI,8BAAM,SAAS,EAAE,MAAM,CAAC,WAAW,EAAG,EAAA,WAAW,CAAQ;AAC5E,gBAAA,MAAM,IAAI,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,KAAK,EAAG,EAAA,KAAK,CAAO,CACpD,CACU,CAClB;AAEd;;;;"}
@@ -37,7 +37,8 @@
37
37
  font-size: 16px;
38
38
  line-height: 20px;
39
39
  font-weight: 400;
40
- font-family: var(--font-family-system);
40
+ letter-spacing: -0.24px;
41
+ font-family: var(--font-family-alfasans);
41
42
 
42
43
  white-space: nowrap;
43
44
  text-overflow: ellipsis;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-input-autocomplete",
3
- "version": "14.0.6",
3
+ "version": "14.0.7-alfasans",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -10,13 +10,13 @@
10
10
  "main": "index.js",
11
11
  "module": "./esm/index.js",
12
12
  "dependencies": {
13
- "@alfalab/core-components-form-control": "^14.0.2",
14
- "@alfalab/core-components-input": "^17.1.1",
15
- "@alfalab/core-components-mq": "^6.0.2",
16
- "@alfalab/core-components-popover": "^8.0.2",
17
- "@alfalab/core-components-select": "^19.0.6",
18
- "@alfalab/core-components-shared": "^2.1.0",
19
- "@alfalab/core-components-status-badge": "^3.0.1",
13
+ "@alfalab/core-components-form-control": "14.0.3-alfasans",
14
+ "@alfalab/core-components-input": "17.1.2-alfasans",
15
+ "@alfalab/core-components-mq": "6.0.2-alfasans",
16
+ "@alfalab/core-components-popover": "8.0.2-alfasans",
17
+ "@alfalab/core-components-select": "19.1.0-alfasans",
18
+ "@alfalab/core-components-shared": "2.1.0-alfasans",
19
+ "@alfalab/core-components-status-badge": "3.0.1-alfasans",
20
20
  "@alfalab/hooks": "^1.13.1",
21
21
  "@maskito/core": "^1.7.0",
22
22
  "classnames": "^2.5.1",
@@ -32,6 +32,6 @@
32
32
  "access": "public",
33
33
  "directory": "dist"
34
34
  },
35
- "themesVersion": "15.0.1",
36
- "varsVersion": "11.0.1"
35
+ "themesVersion": "15.0.2-alfasans",
36
+ "varsVersion": "11.0.1-alfasans"
37
37
  }
@@ -1,10 +1,9 @@
1
- import React, { useCallback, useRef } from 'react';
1
+ import React, { Fragment, useCallback, useRef } from 'react';
2
2
  import mergeRefs from 'react-merge-refs';
3
3
  import cn from 'classnames';
4
4
 
5
5
  import { type InputProps } from '@alfalab/core-components-input';
6
6
  import { InputDesktop as DefaultInput } from '@alfalab/core-components-input/desktop';
7
- import { getAddonsByPriority } from '@alfalab/core-components-input/helpers/get-addons-by-priority';
8
7
  import { type FieldProps } from '@alfalab/core-components-select/shared';
9
8
 
10
9
  import { OnInputReason } from '../enums';
@@ -61,16 +60,10 @@ export const AutocompleteField = ({
61
60
  * [1] - Indicators (eye, calendar, chevron, stepper e.g.)
62
61
  * [0] - Lock
63
62
  */
64
- const rightAddonsMap = getAddonsByPriority([
65
- {
66
- priority: 2,
67
- predicate: Boolean(inputProps.rightAddons),
68
- render: () => inputProps.rightAddons,
69
- },
70
- {
71
- priority: 1,
72
- predicate: Boolean(Arrow) && !inputDisabled,
73
- render: () => (
63
+ const renderRightAddons = () => (
64
+ <Fragment>
65
+ {inputProps.rightAddons}
66
+ {Arrow && !inputDisabled && (
74
67
  <span
75
68
  className={cn(styles.arrow, {
76
69
  [styles.error]: error,
@@ -78,9 +71,9 @@ export const AutocompleteField = ({
78
71
  >
79
72
  {Arrow}
80
73
  </span>
81
- ),
82
- },
83
- ]);
74
+ )}
75
+ </Fragment>
76
+ );
84
77
 
85
78
  return (
86
79
  <Input
@@ -107,7 +100,7 @@ export const AutocompleteField = ({
107
100
  onFocus={inputDisabled ? undefined : onFocus}
108
101
  autoComplete='off'
109
102
  value={value}
110
- rightAddons={rightAddonsMap}
103
+ rightAddons={renderRightAddons()}
111
104
  />
112
105
  );
113
106
  };
@@ -1,11 +1,11 @@
1
- import React, { type ElementType, useRef, useState } from 'react';
1
+ import React, { type ElementType, Fragment, useRef, useState } from 'react';
2
2
  import cn from 'classnames';
3
3
 
4
4
  import {
5
5
  FormControlMobile,
6
6
  type FormControlMobileProps,
7
7
  } from '@alfalab/core-components-form-control/mobile';
8
- import { ClearButton, getAddonsByPriority, LockIcon } from '@alfalab/core-components-input/shared';
8
+ import { ClearButton, LockIcon } from '@alfalab/core-components-input/shared';
9
9
  import { type FieldProps as BaseFieldProps } from '@alfalab/core-components-select/shared';
10
10
  import { getDataTestId } from '@alfalab/core-components-shared';
11
11
  import { StatusBadge } from '@alfalab/core-components-status-badge';
@@ -76,16 +76,12 @@ export const AutocompleteMobileField = ({
76
76
  * [1] - Indicators (eye, calendar, chevron, stepper e.g.)
77
77
  * [0] - Lock
78
78
  */
79
- const rightAddonsMap = getAddonsByPriority([
80
- {
81
- priority: 4,
82
- predicate: clear && filled && !disabled && !readOnly,
83
- render: () => <ClearButton onClick={onClear} disabled={disabled} colors={colors} />,
84
- },
85
- {
86
- priority: 3,
87
- predicate: Boolean(error),
88
- render: () => (
79
+ const renderRightAddons = () => (
80
+ <Fragment>
81
+ {clear && filled && !disabled && !readOnly && (
82
+ <ClearButton onClick={onClear} disabled={disabled} colors={colors} />
83
+ )}
84
+ {error && (
89
85
  <div className={styles.errorIcon} data-addon='error-icon'>
90
86
  <StatusBadge
91
87
  view='negative-alert'
@@ -93,12 +89,8 @@ export const AutocompleteMobileField = ({
93
89
  dataTestId={getDataTestId(dataTestId, 'error-icon')}
94
90
  />
95
91
  </div>
96
- ),
97
- },
98
- {
99
- priority: 3,
100
- predicate: Boolean(success && !error),
101
- render: () => (
92
+ )}
93
+ {success && !error && (
102
94
  <div className={styles.successIcon}>
103
95
  <StatusBadge
104
96
  view='positive-checkmark'
@@ -106,24 +98,12 @@ export const AutocompleteMobileField = ({
106
98
  dataTestId={getDataTestId(dataTestId, 'success-icon')}
107
99
  />
108
100
  </div>
109
- ),
110
- },
111
- {
112
- priority: 2,
113
- predicate: Boolean(rightAddons),
114
- render: () => rightAddons,
115
- },
116
- {
117
- priority: 1,
118
- predicate: Boolean(Arrow) && !disabled && !readOnly,
119
- render: () => Arrow,
120
- },
121
- {
122
- priority: 0,
123
- predicate: Boolean(disabled || readOnly),
124
- render: () => <LockIcon colors={colors} size={size} />,
125
- },
126
- ]);
101
+ )}
102
+ {rightAddons}
103
+ {!disabled && !readOnly && Arrow}
104
+ {(disabled || readOnly) && <LockIcon colors={colors} size={size} />}
105
+ </Fragment>
106
+ );
127
107
 
128
108
  return (
129
109
  <div
@@ -151,7 +131,7 @@ export const AutocompleteMobileField = ({
151
131
  readOnly={readOnly}
152
132
  colors={colors}
153
133
  error={error}
154
- rightAddons={rightAddonsMap}
134
+ rightAddons={renderRightAddons()}
155
135
  >
156
136
  <div className={styles.contentWrapper}>
157
137
  {showPlaceholder && <span className={styles.placeholder}>{placeholder}</span>}