@snack-uikit/fields 0.25.2 → 0.25.3-preview-4ab4d581.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/README.md CHANGED
@@ -223,6 +223,7 @@ FieldStepper в основном предназначен для работы с
223
223
  | maxLength | `number` | - | Максимальная длина вводимого значения |
224
224
  | onFocus | `FocusEventHandler<HTMLInputElement>` | - | Колбек обработки получения фокуса |
225
225
  | onBlur | `FocusEventHandler<HTMLInputElement>` | - | Колбек обработки потери фокуса |
226
+ | autoComplete | `string \| boolean` | false | Включен ли автокомплит для поля |
226
227
  | error | `string` | - | |
227
228
  | className | `string` | - | CSS-класс |
228
229
  | label | `string` | - | Лейбл |
@@ -30,7 +30,6 @@ const defaultSelectedOptionFormatter = item =>
30
30
  // @ts-expect-error
31
31
  (item === null || item === void 0 ? void 0 : item.content.option) || '';
32
32
  export const FieldSelectSingle = forwardRef((props, ref) => {
33
- var _a;
34
33
  const { id, name, placeholder, size = 's', options, value: valueProp, defaultValue, onChange: onChangeProp, disabled = false, readonly = false, searchable = true, showCopyButton = true, showClearButton = true, onKeyDown: onInputKeyDownProp, required = false, validationState = 'default', search, autocomplete = false, prefixIcon, addOptionByEnter = false, untouchableScrollbars = false, open: openProp, onOpenChange, selectedOptionFormatter = defaultSelectedOptionFormatter } = props, rest = __rest(props, ["id", "name", "placeholder", "size", "options", "value", "defaultValue", "onChange", "disabled", "readonly", "searchable", "showCopyButton", "showClearButton", "onKeyDown", "required", "validationState", "search", "autocomplete", "prefixIcon", "addOptionByEnter", "untouchableScrollbars", "open", "onOpenChange", "selectedOptionFormatter"]);
35
34
  const localRef = useRef(null);
36
35
  const [open = false, setOpen] = useValueControl({ value: openProp, onChange: onOpenChange });
@@ -40,10 +39,7 @@ export const FieldSelectSingle = forwardRef((props, ref) => {
40
39
  onChange: onChangeProp,
41
40
  });
42
41
  const [{ selectedItem, items = [] }, setItems] = useState(() => updateItems({ options, value, currentItems: [], selectedItem: undefined }));
43
- const { inputValue, setInputValue, prevInputValue, updateInputValue } = useSearchInput(Object.assign(Object.assign({}, search), {
44
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
45
- // @ts-expect-error
46
- defaultValue: (_a = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.content.option) !== null && _a !== void 0 ? _a : '', selectedOptionFormatter }));
42
+ const { inputValue, setInputValue, prevInputValue, updateInputValue } = useSearchInput(Object.assign(Object.assign({}, search), { defaultValue: selectedOptionFormatter(selectedItem), selectedOptionFormatter }));
47
43
  const prevSelectedItem = useRef(selectedItem);
48
44
  useLayoutEffect(() => {
49
45
  setItems(({ selectedItem }) => updateItems({ options, value, selectedItem }));
@@ -2,7 +2,7 @@ import { ReactElement } from 'react';
2
2
  import { InputPrivateProps } from '@snack-uikit/input-private';
3
3
  import { WithSupportProps } from '@snack-uikit/utils';
4
4
  import { FieldDecoratorProps } from '../FieldDecorator';
5
- type InputProps = Pick<Partial<InputPrivateProps>, 'value' | 'onChange'> & Pick<InputPrivateProps, 'id' | 'name' | 'placeholder' | 'maxLength' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur'>;
5
+ type InputProps = Pick<Partial<InputPrivateProps>, 'value' | 'onChange'> & Pick<InputPrivateProps, 'id' | 'name' | 'placeholder' | 'maxLength' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur' | 'autoComplete'>;
6
6
  type WrapperProps = Pick<FieldDecoratorProps, 'className' | 'label' | 'labelTooltip' | 'required' | 'caption' | 'hint' | 'showHintIcon' | 'size' | 'validationState' | 'labelTooltipPlacement' | 'error'>;
7
7
  type FieldTextOwnProps = {
8
8
  /** Отображение кнопки Копировать для поля (актуально только для `readonly = true`) */
@@ -20,5 +20,5 @@ type FieldTextOwnProps = {
20
20
  export type FieldTextProps = WithSupportProps<FieldTextOwnProps & InputProps & WrapperProps>;
21
21
  export declare const FieldText: import("react").ForwardRefExoticComponent<{
22
22
  'data-test-id'?: string;
23
- } & import("react").AriaAttributes & FieldTextOwnProps & Pick<Partial<InputPrivateProps>, "onChange" | "value"> & Pick<InputPrivateProps, "disabled" | "readonly" | "id" | "name" | "onFocus" | "onBlur" | "placeholder" | "maxLength"> & WrapperProps & import("react").RefAttributes<HTMLInputElement>>;
23
+ } & import("react").AriaAttributes & FieldTextOwnProps & Pick<Partial<InputPrivateProps>, "onChange" | "value"> & Pick<InputPrivateProps, "disabled" | "readonly" | "id" | "name" | "onFocus" | "onBlur" | "placeholder" | "autoComplete" | "maxLength"> & WrapperProps & import("react").RefAttributes<HTMLInputElement>>;
24
24
  export {};
@@ -20,7 +20,7 @@ import { useCopyButton, useValueControl } from '../../hooks';
20
20
  import { getValidationState } from '../../utils/getValidationState';
21
21
  import { FieldDecorator } from '../FieldDecorator';
22
22
  export const FieldText = forwardRef((_a, ref) => {
23
- var { id, name, value: valueProp, placeholder, maxLength, disabled = false, readonly = false, showCopyButton: showCopyButtonProp = true, showClearButton: showClearButtonProp = true, allowMoreThanMaxLength = false, onChange: onChangeProp, onFocus, onBlur, className, label, labelTooltip, labelTooltipPlacement, required = false, caption, hint, showHintIcon, size = SIZE.S, validationState = VALIDATION_STATE.Default, prefixIcon, error } = _a, rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "disabled", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "prefixIcon", "error"]);
23
+ var { id, name, value: valueProp, placeholder, maxLength, disabled = false, readonly = false, showCopyButton: showCopyButtonProp = true, showClearButton: showClearButtonProp = true, allowMoreThanMaxLength = false, onChange: onChangeProp, onFocus, onBlur, className, label, labelTooltip, labelTooltipPlacement, required = false, caption, hint, showHintIcon, size = SIZE.S, validationState = VALIDATION_STATE.Default, prefixIcon, error, autoComplete } = _a, rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "disabled", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "prefixIcon", "error", "autoComplete"]);
24
24
  const [value = '', onChange] = useValueControl({
25
25
  value: valueProp,
26
26
  defaultValue: '',
@@ -48,5 +48,5 @@ export const FieldText = forwardRef((_a, ref) => {
48
48
  readonly,
49
49
  submitKeys: ['Enter', 'Space', 'Tab'],
50
50
  });
51
- return (_jsx(FieldDecorator, Object.assign({ className: className, label: label, labelTooltip: labelTooltip, labelTooltipPlacement: labelTooltipPlacement, labelFor: id, required: required, caption: caption, length: maxLength ? { max: maxLength, current: value.length } : undefined, hint: hint, disabled: disabled, readonly: readonly, showHintIcon: showHintIcon, size: size, validationState: fieldValidationState, error: error }, extractSupportProps(rest), { children: _jsx(FieldContainerPrivate, { size: size, validationState: fieldValidationState, disabled: disabled, readonly: readonly, variant: CONTAINER_VARIANT.SingleLine, inputRef: localRef, prefix: prefixIcon, postfix: buttons, children: _jsx(InputPrivate, { ref: mergeRefs(ref, localRef), "data-size": size, value: value, onChange: onChange, onFocus: onFocus, onBlur: onBlur, tabIndex: inputTabIndex, onKeyDown: onInputKeyDown, placeholder: placeholder, disabled: disabled, readonly: readonly, type: 'text', maxLength: allowMoreThanMaxLength ? undefined : maxLength || undefined, id: id, name: name, "data-test-id": 'field-text__input' }) }) })));
51
+ return (_jsx(FieldDecorator, Object.assign({ className: className, label: label, labelTooltip: labelTooltip, labelTooltipPlacement: labelTooltipPlacement, labelFor: id, required: required, caption: caption, length: maxLength ? { max: maxLength, current: value.length } : undefined, hint: hint, disabled: disabled, readonly: readonly, showHintIcon: showHintIcon, size: size, validationState: fieldValidationState, error: error }, extractSupportProps(rest), { children: _jsx(FieldContainerPrivate, { size: size, validationState: fieldValidationState, disabled: disabled, readonly: readonly, variant: CONTAINER_VARIANT.SingleLine, inputRef: localRef, prefix: prefixIcon, postfix: buttons, children: _jsx(InputPrivate, { ref: mergeRefs(ref, localRef), "data-size": size, value: value, onChange: onChange, onFocus: onFocus, onBlur: onBlur, tabIndex: inputTabIndex, onKeyDown: onInputKeyDown, placeholder: placeholder, disabled: disabled, readonly: readonly, type: 'text', maxLength: allowMoreThanMaxLength ? undefined : maxLength || undefined, id: id, name: name, autoComplete: autoComplete, "data-test-id": 'field-text__input' }) }) })));
52
52
  });
@@ -35,7 +35,7 @@
35
35
  outline-style:var(--border-state-focus-s-border-style, solid);
36
36
  outline-color:var(--border-state-focus-s-border-color, );
37
37
  color:var(--sys-neutral-text-support, #6d707f);
38
- outline-color:var(--sys-available-complementary, #15151b);
38
+ outline-color:var(--sys-available-complementary, #1c1c24);
39
39
  outline-offset:var(--spacing-state-focus-offset, 2px);
40
40
  }
41
41
  .buttonCopyValue:active{
@@ -35,7 +35,7 @@
35
35
  outline-style:var(--border-state-focus-s-border-style, solid);
36
36
  outline-color:var(--border-state-focus-s-border-color, );
37
37
  color:var(--sys-neutral-text-support, #6d707f);
38
- outline-color:var(--sys-available-complementary, #15151b);
38
+ outline-color:var(--sys-available-complementary, #1c1c24);
39
39
  outline-offset:var(--spacing-state-focus-offset, 2px);
40
40
  }
41
41
  .buttonHideValue:active{
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Fields",
7
- "version": "0.25.2",
7
+ "version": "0.25.3-preview-4ab4d581.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -59,5 +59,5 @@
59
59
  "peerDependencies": {
60
60
  "@snack-uikit/locale": "*"
61
61
  },
62
- "gitHead": "f238fd8b9d363de790ebcfd189aa17cbe101f3eb"
62
+ "gitHead": "0d52e9b583e9a990834cd94ec67277bdd27651c1"
63
63
  }
@@ -75,9 +75,7 @@ export const FieldSelectSingle = forwardRef<HTMLInputElement, FieldSelectSingleP
75
75
 
76
76
  const { inputValue, setInputValue, prevInputValue, updateInputValue } = useSearchInput({
77
77
  ...search,
78
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
79
- // @ts-expect-error
80
- defaultValue: selectedItem?.content.option ?? '',
78
+ defaultValue: selectedOptionFormatter(selectedItem),
81
79
  selectedOptionFormatter,
82
80
  });
83
81
 
@@ -11,7 +11,10 @@ import { getValidationState } from '../../utils/getValidationState';
11
11
  import { FieldDecorator, FieldDecoratorProps } from '../FieldDecorator';
12
12
 
13
13
  type InputProps = Pick<Partial<InputPrivateProps>, 'value' | 'onChange'> &
14
- Pick<InputPrivateProps, 'id' | 'name' | 'placeholder' | 'maxLength' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur'>;
14
+ Pick<
15
+ InputPrivateProps,
16
+ 'id' | 'name' | 'placeholder' | 'maxLength' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur' | 'autoComplete'
17
+ >;
15
18
 
16
19
  type WrapperProps = Pick<
17
20
  FieldDecoratorProps,
@@ -72,6 +75,7 @@ export const FieldText = forwardRef<HTMLInputElement, FieldTextProps>(
72
75
  validationState = VALIDATION_STATE.Default,
73
76
  prefixIcon,
74
77
  error,
78
+ autoComplete,
75
79
  ...rest
76
80
  },
77
81
  ref,
@@ -151,6 +155,7 @@ export const FieldText = forwardRef<HTMLInputElement, FieldTextProps>(
151
155
  maxLength={allowMoreThanMaxLength ? undefined : maxLength || undefined}
152
156
  id={id}
153
157
  name={name}
158
+ autoComplete={autoComplete}
154
159
  data-test-id='field-text__input'
155
160
  />
156
161
  </FieldContainerPrivate>