@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.
- package/autocomplete-field/Component.js +9 -19
- package/autocomplete-field/Component.js.map +1 -1
- package/autocomplete-field/index.css +1 -1
- package/autocomplete-field/index.module.css.js +1 -1
- package/autocomplete-mobile-field/Component.js +10 -35
- package/autocomplete-mobile-field/Component.js.map +1 -1
- package/autocomplete-mobile-field/index.css +15 -13
- package/autocomplete-mobile-field/index.module.css.js +1 -1
- package/cssm/autocomplete-field/Component.js +9 -19
- package/cssm/autocomplete-field/Component.js.map +1 -1
- package/cssm/autocomplete-mobile-field/Component.js +13 -38
- package/cssm/autocomplete-mobile-field/Component.js.map +1 -1
- package/cssm/autocomplete-mobile-field/index.module.css +5 -3
- package/esm/autocomplete-field/Component.js +10 -20
- package/esm/autocomplete-field/Component.js.map +1 -1
- package/esm/autocomplete-field/index.css +1 -1
- package/esm/autocomplete-field/index.module.css.js +1 -1
- package/esm/autocomplete-mobile-field/Component.js +12 -37
- package/esm/autocomplete-mobile-field/Component.js.map +1 -1
- package/esm/autocomplete-mobile-field/index.css +15 -13
- package/esm/autocomplete-mobile-field/index.module.css.js +1 -1
- package/esm/mobile/mobile.css +1 -1
- package/esm/mobile/mobile.module.css.js +1 -1
- package/mobile/mobile.css +1 -1
- package/mobile/mobile.module.css.js +1 -1
- package/modern/autocomplete-field/Component.js +7 -17
- package/modern/autocomplete-field/Component.js.map +1 -1
- package/modern/autocomplete-field/index.css +1 -1
- package/modern/autocomplete-field/index.module.css.js +1 -1
- package/modern/autocomplete-mobile-field/Component.js +12 -37
- package/modern/autocomplete-mobile-field/Component.js.map +1 -1
- package/modern/autocomplete-mobile-field/index.css +15 -13
- package/modern/autocomplete-mobile-field/index.module.css.js +1 -1
- package/modern/mobile/mobile.css +1 -1
- package/modern/mobile/mobile.module.css.js +1 -1
- package/moderncssm/autocomplete-field/Component.js +7 -17
- package/moderncssm/autocomplete-field/Component.js.map +1 -1
- package/moderncssm/autocomplete-mobile-field/Component.js +12 -37
- package/moderncssm/autocomplete-mobile-field/Component.js.map +1 -1
- package/moderncssm/autocomplete-mobile-field/index.module.css +2 -1
- package/package.json +10 -10
- package/src/autocomplete-field/Component.tsx +9 -16
- 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 {
|
|
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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B,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,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 {
|
|
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
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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:
|
|
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,
|
|
1
|
+
{"version":3,"file":"Component.js","sources":["../../src/autocomplete-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,EACP,OAAO,EACP,OAAO,EACP,MAAM,GAAG,SAAS,EAClB,GAAG,SAAS,EAC4B,KAAI;IAC5C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AAE7C,IAAA,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC;IAE/C,MAAM,CAAC,YAAY,CAAC,GAAG,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;AAEvD,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAC7B,MAAM,eAAe,GAAG,WAAW,IAAI,CAAC,MAAM,IAAI,SAAS,KAAK,OAAO;AAEvE,IAAA,MAAM,eAAe,GAAG,IAAI,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE;IAE7C,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,EAAE,GAAG,UAAU;AAElD;;;;;;;AAOG;AACH,IAAA,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AAiB,EACd,EAAA,cAAc,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,cAAc,EAAE;AAC7C,gBAAA,CAAC,MAAM,CAAC,QAAQ,GAAG,QAAQ;AAC3B,gBAAA,CAAC,MAAM,CAAC,YAAY,GAAG,YAAY;AACtC,aAAA,CAAC,EACF,KAAK,EAAE,IAAI,EACX,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,aAAa,CAAC,UAAU,EAAE,cAAc,CAAC;;AAErD,YAAA,QAAQ,EAAE,IAAI,GAAG,SAAS,GAAG,QAAQ,EACjC,GAAA,SAAS,KACT,cAAc,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,iBAAiB,EAAE,EAAA;AAEhC,YAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,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;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-input-autocomplete",
|
|
3
|
-
"version": "14.0.
|
|
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
|
-
"@alfalab/core-components-input": "
|
|
15
|
-
"@alfalab/core-components-mq": "
|
|
16
|
-
"@alfalab/core-components-popover": "
|
|
17
|
-
"@alfalab/core-components-select": "
|
|
18
|
-
"@alfalab/core-components-shared": "
|
|
19
|
-
"@alfalab/core-components-status-badge": "
|
|
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.
|
|
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
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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={
|
|
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,
|
|
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
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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={
|
|
134
|
+
rightAddons={renderRightAddons()}
|
|
155
135
|
>
|
|
156
136
|
<div className={styles.contentWrapper}>
|
|
157
137
|
{showPlaceholder && <span className={styles.placeholder}>{placeholder}</span>}
|