@snack-uikit/fields 0.28.0 → 0.29.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 (91) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +9 -0
  3. package/dist/components/FieldColor/FieldColor.d.ts +1 -1
  4. package/dist/components/FieldColor/FieldColor.js +3 -3
  5. package/dist/components/FieldDate/FieldDate.js +11 -5
  6. package/dist/components/FieldSecure/FieldSecure.d.ts +1 -1
  7. package/dist/components/FieldSecure/FieldSecure.js +3 -3
  8. package/dist/components/FieldSelect/FieldSelectMultiple.d.ts +3 -1
  9. package/dist/components/FieldSelect/FieldSelectMultiple.js +7 -5
  10. package/dist/components/FieldSelect/FieldSelectSingle.d.ts +3 -1
  11. package/dist/components/FieldSelect/FieldSelectSingle.js +8 -6
  12. package/dist/components/FieldSelect/hooks.d.ts +1 -1
  13. package/dist/components/FieldSelect/hooks.js +3 -3
  14. package/dist/components/FieldSelect/types.d.ts +5 -1
  15. package/dist/components/FieldSlider/FieldSlider.d.ts +6 -2
  16. package/dist/components/FieldSlider/FieldSlider.js +13 -11
  17. package/dist/components/FieldStepper/FieldStepper.d.ts +5 -1
  18. package/dist/components/FieldStepper/FieldStepper.js +6 -4
  19. package/dist/components/FieldText/FieldText.d.ts +9 -2
  20. package/dist/components/FieldText/FieldText.js +46 -8
  21. package/dist/components/FieldText/helpers.d.ts +4 -0
  22. package/dist/components/FieldText/helpers.js +9 -0
  23. package/dist/components/FieldTextArea/FieldTextArea.d.ts +1 -1
  24. package/dist/components/FieldTextArea/FieldTextArea.js +3 -3
  25. package/dist/constants.d.ts +6 -0
  26. package/dist/constants.js +6 -0
  27. package/dist/helperComponents/ButtonField/ButtonField.d.ts +18 -0
  28. package/dist/helperComponents/ButtonField/ButtonField.js +10 -0
  29. package/dist/helperComponents/ButtonField/index.d.ts +1 -0
  30. package/dist/helperComponents/ButtonField/index.js +1 -0
  31. package/dist/helperComponents/ButtonField/styles.module.css +96 -0
  32. package/dist/helperComponents/ButtonFieldList/ButtonFieldList.d.ts +4 -0
  33. package/dist/helperComponents/ButtonFieldList/ButtonFieldList.js +27 -0
  34. package/dist/helperComponents/ButtonFieldList/helpers.d.ts +5 -0
  35. package/dist/helperComponents/ButtonFieldList/helpers.js +8 -0
  36. package/dist/helperComponents/ButtonFieldList/index.d.ts +1 -0
  37. package/dist/helperComponents/ButtonFieldList/index.js +1 -0
  38. package/dist/helperComponents/ButtonFieldList/styles.module.css +3 -0
  39. package/dist/helperComponents/FieldContainerPrivate/FieldContainerPrivate.d.ts +5 -4
  40. package/dist/helperComponents/FieldContainerPrivate/FieldContainerPrivate.js +2 -2
  41. package/dist/helperComponents/FieldContainerPrivate/styles.module.css +56 -5
  42. package/dist/helperComponents/index.d.ts +2 -0
  43. package/dist/helperComponents/index.js +2 -0
  44. package/dist/hooks/index.d.ts +4 -0
  45. package/dist/hooks/index.js +4 -0
  46. package/dist/hooks/styles.module.css +13 -0
  47. package/dist/hooks/useCopyButton.d.ts +3 -1
  48. package/dist/hooks/useCopyButton.js +4 -3
  49. package/dist/hooks/useHideButton.js +1 -0
  50. package/dist/hooks/usePostfix.d.ts +6 -0
  51. package/dist/hooks/usePostfix.js +11 -0
  52. package/dist/hooks/usePostfixButton.d.ts +11 -0
  53. package/dist/hooks/usePostfixButton.js +28 -0
  54. package/dist/hooks/usePrefix.d.ts +6 -0
  55. package/dist/hooks/usePrefix.js +11 -0
  56. package/dist/hooks/usePrefixButton.d.ts +11 -0
  57. package/dist/hooks/usePrefixButton.js +28 -0
  58. package/dist/types.d.ts +12 -1
  59. package/package.json +6 -5
  60. package/src/components/FieldColor/FieldColor.tsx +6 -3
  61. package/src/components/FieldDate/FieldDate.tsx +17 -10
  62. package/src/components/FieldSecure/FieldSecure.tsx +3 -3
  63. package/src/components/FieldSelect/FieldSelectMultiple.tsx +17 -4
  64. package/src/components/FieldSelect/FieldSelectSingle.tsx +17 -4
  65. package/src/components/FieldSelect/hooks.ts +3 -3
  66. package/src/components/FieldSelect/types.ts +10 -2
  67. package/src/components/FieldSlider/FieldSlider.tsx +30 -14
  68. package/src/components/FieldStepper/FieldStepper.tsx +40 -23
  69. package/src/components/FieldText/FieldText.tsx +78 -10
  70. package/src/components/FieldText/helpers.tsx +13 -0
  71. package/src/components/FieldTextArea/FieldTextArea.tsx +6 -3
  72. package/src/constants.ts +7 -0
  73. package/src/helperComponents/ButtonField/ButtonField.tsx +73 -0
  74. package/src/helperComponents/ButtonField/index.ts +1 -0
  75. package/src/helperComponents/ButtonField/styles.module.scss +57 -0
  76. package/src/helperComponents/ButtonFieldList/ButtonFieldList.tsx +36 -0
  77. package/src/helperComponents/ButtonFieldList/helpers.tsx +13 -0
  78. package/src/helperComponents/ButtonFieldList/index.ts +1 -0
  79. package/src/helperComponents/ButtonFieldList/styles.module.scss +5 -0
  80. package/src/helperComponents/FieldContainerPrivate/FieldContainerPrivate.tsx +6 -3
  81. package/src/helperComponents/FieldContainerPrivate/styles.module.scss +14 -8
  82. package/src/helperComponents/index.ts +2 -0
  83. package/src/hooks/index.ts +4 -0
  84. package/src/hooks/styles.module.scss +17 -0
  85. package/src/hooks/useCopyButton.tsx +7 -2
  86. package/src/hooks/useHideButton.tsx +1 -0
  87. package/src/hooks/usePostfix.tsx +21 -0
  88. package/src/hooks/usePostfixButton.tsx +74 -0
  89. package/src/hooks/usePrefix.tsx +21 -0
  90. package/src/hooks/usePrefixButton.tsx +74 -0
  91. package/src/types.ts +16 -1
@@ -11,16 +11,17 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import mergeRefs from 'merge-refs';
14
- import { forwardRef, useMemo, useRef } from 'react';
14
+ import { forwardRef, useCallback, useMemo, useRef, useState } from 'react';
15
15
  import { InputPrivate, SIZE, useButtonNavigation, useClearButton } from '@snack-uikit/input-private';
16
16
  import { extractSupportProps } from '@snack-uikit/utils';
17
- import { CONTAINER_VARIANT, VALIDATION_STATE } from '../../constants';
17
+ import { VALIDATION_STATE } from '../../constants';
18
18
  import { FieldContainerPrivate } from '../../helperComponents';
19
- import { useCopyButton, useValueControl } from '../../hooks';
19
+ import { useCopyButton, usePostfix, usePostfixButton, usePrefix, usePrefixButton, useValueControl } from '../../hooks';
20
20
  import { getValidationState } from '../../utils/getValidationState';
21
21
  import { FieldDecorator } from '../FieldDecorator';
22
+ import { getContainerVariant } from './helpers';
22
23
  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, 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
+ 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, error, autoComplete, prefixIcon, prefix, postfix, button: buttonProp } = _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", "error", "autoComplete", "prefixIcon", "prefix", "postfix", "button"]);
24
25
  const [value = '', onChange] = useValueControl({
25
26
  value: valueProp,
26
27
  defaultValue: '',
@@ -33,6 +34,13 @@ export const FieldText = forwardRef((_a, ref) => {
33
34
  const showClearButton = showClearButtonProp && showAdditionalButton && !readonly;
34
35
  const showCopyButton = showCopyButtonProp && showAdditionalButton && readonly;
35
36
  const fieldValidationState = getValidationState({ validationState, error });
37
+ const button = useMemo(() => buttonProp
38
+ ? Object.assign(Object.assign({}, buttonProp), { selection: Object.assign(Object.assign({}, buttonProp.selection), { onChange: value => {
39
+ var _a, _b;
40
+ (_b = (_a = buttonProp.selection) === null || _a === void 0 ? void 0 : _a.onChange) === null || _b === void 0 ? void 0 : _b.call(_a, value);
41
+ setTimeout(() => { var _a; return (_a = localRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, 0);
42
+ } }) }) : undefined, [buttonProp]);
43
+ const containerVariant = getContainerVariant({ button });
36
44
  const onClear = () => {
37
45
  var _a;
38
46
  onChange('');
@@ -41,12 +49,42 @@ export const FieldText = forwardRef((_a, ref) => {
41
49
  }
42
50
  };
43
51
  const clearButtonSettings = useClearButton({ clearButtonRef, showClearButton, size, onClear });
44
- const copyButtonSettings = useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy: value });
45
- const { buttons, inputTabIndex, onInputKeyDown } = useButtonNavigation({
52
+ const copyButtonSettings = useCopyButton({
53
+ copyButtonRef,
54
+ showCopyButton,
55
+ size,
56
+ valueToCopy: value,
57
+ prefix: typeof prefix === 'string' ? prefix : undefined,
58
+ postfix: typeof postfix === 'string' ? postfix : undefined,
59
+ });
60
+ const [isButtonFocused, setIsButtonFocused] = useState(false);
61
+ const onButtonFocus = useCallback(() => setIsButtonFocused(true), []);
62
+ const onButtonBlur = useCallback(() => setIsButtonFocused(false), []);
63
+ const prefixSettings = usePrefix({ prefix, disabled });
64
+ const prefixButtonSettings = usePrefixButton({
65
+ button,
66
+ prefixIcon,
67
+ size,
68
+ disabled,
69
+ readonly,
70
+ onFocus: onButtonFocus,
71
+ onBlur: onButtonBlur,
72
+ });
73
+ const postfixSettings = usePostfix({ postfix, disabled });
74
+ const postfixButtonSettings = usePostfixButton({
75
+ button,
76
+ size,
77
+ disabled,
78
+ readonly,
79
+ onFocus: onButtonFocus,
80
+ onBlur: onButtonBlur,
81
+ });
82
+ const { postfixButtons, prefixButtons, inputTabIndex, onInputKeyDown } = useButtonNavigation({
46
83
  inputRef: localRef,
47
- buttons: useMemo(() => [clearButtonSettings, copyButtonSettings], [clearButtonSettings, copyButtonSettings]),
84
+ postfixButtons: useMemo(() => [clearButtonSettings, copyButtonSettings, postfixSettings, postfixButtonSettings], [clearButtonSettings, copyButtonSettings, postfixSettings, postfixButtonSettings]),
85
+ prefixButtons: useMemo(() => [prefixButtonSettings, prefixSettings], [prefixButtonSettings, prefixSettings]),
48
86
  readonly,
49
87
  submitKeys: ['Enter', 'Space', 'Tab'],
50
88
  });
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' }) }) })));
89
+ 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: containerVariant, inputRef: localRef, prefix: prefixButtons, postfix: postfixButtons, disableFocus: isButtonFocused, 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
90
  });
@@ -0,0 +1,4 @@
1
+ import { Button, ContainerVariant } from '../../types';
2
+ export declare function getContainerVariant({ button }: {
3
+ button?: Button;
4
+ }): ContainerVariant;
@@ -0,0 +1,9 @@
1
+ export function getContainerVariant({ button }) {
2
+ if ((button === null || button === void 0 ? void 0 : button.variant) === 'before') {
3
+ return 'single-line-container-button-before';
4
+ }
5
+ if ((button === null || button === void 0 ? void 0 : button.variant) === 'after') {
6
+ return 'single-line-container-button-after';
7
+ }
8
+ return 'single-line-container';
9
+ }
@@ -26,5 +26,5 @@ type FieldTextAreaOwnProps = {
26
26
  export type FieldTextAreaProps = WithSupportProps<FieldTextAreaOwnProps & InputProps & WrapperProps>;
27
27
  export declare const FieldTextArea: import("react").ForwardRefExoticComponent<{
28
28
  'data-test-id'?: string;
29
- } & import("react").AriaAttributes & FieldTextAreaOwnProps & Pick<Partial<TextAreaProps>, "value"> & Pick<TextAreaProps, "disabled" | "readonly" | "id" | "name" | "onFocus" | "onBlur" | "placeholder" | "maxLength"> & WrapperProps & import("react").RefAttributes<HTMLTextAreaElement>>;
29
+ } & import("react").AriaAttributes & FieldTextAreaOwnProps & Pick<Partial<TextAreaProps>, "value"> & Pick<TextAreaProps, "onFocus" | "onBlur" | "id" | "disabled" | "readonly" | "name" | "placeholder" | "maxLength"> & WrapperProps & import("react").RefAttributes<HTMLTextAreaElement>>;
30
30
  export {};
@@ -44,11 +44,11 @@ export const FieldTextArea = forwardRef((_a, ref) => {
44
44
  };
45
45
  const clearButtonSettings = useClearButton({ clearButtonRef, showClearButton, size, onClear });
46
46
  const copyButtonSettings = useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy: value });
47
- const { buttons, inputTabIndex, onInputKeyDown } = useButtonNavigation({
47
+ const { postfixButtons, inputTabIndex, onInputKeyDown } = useButtonNavigation({
48
48
  inputRef: localRef,
49
- buttons: useMemo(() => [clearButtonSettings, copyButtonSettings], [clearButtonSettings, copyButtonSettings]),
49
+ postfixButtons: useMemo(() => [clearButtonSettings, copyButtonSettings], [clearButtonSettings, copyButtonSettings]),
50
50
  readonly,
51
51
  submitKeys: ['Enter', 'Space', 'Tab'],
52
52
  });
53
- 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, error: error, validationState: fieldValidationState }, extractSupportProps(rest), { children: _jsx(FieldContainerPrivate, { className: styles.container, size: size, validationState: fieldValidationState, disabled: disabled, readonly: readonly, "data-resizable": isResizable || undefined, variant: CONTAINER_VARIANT.MultiLine, style: { '--max-rows': maxRows, '--min-rows': minRows }, inputRef: localRef, postfix: _jsx("span", { className: styles.postfix, children: buttons }), children: _jsx(Scroll, { className: styles.scrollContainer, size: 's', barHideStrategy: 'never', resize: isResizable ? 'vertical' : 'none', "data-test-id": 'field-textarea__scroll-area', children: _jsx(TextArea, { className: styles.textarea, "data-size": size, value: value, onChange: onChange, placeholder: placeholder, disabled: disabled, readonly: readonly, minRows: minRows, id: id, name: name, ref: mergeRefs(ref, localRef), onFocus: onFocus, onBlur: onBlur, onKeyDown: onInputKeyDown, tabIndex: inputTabIndex, maxLength: allowMoreThanMaxLength ? undefined : maxLength || undefined, "data-test-id": 'field-textarea__input' }) }) }) })));
53
+ 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, error: error, validationState: fieldValidationState }, extractSupportProps(rest), { children: _jsx(FieldContainerPrivate, { className: styles.container, size: size, validationState: fieldValidationState, disabled: disabled, readonly: readonly, "data-resizable": isResizable || undefined, variant: CONTAINER_VARIANT.MultiLine, style: { '--max-rows': maxRows, '--min-rows': minRows }, inputRef: localRef, postfix: _jsx("span", { className: styles.postfix, children: postfixButtons }), children: _jsx(Scroll, { className: styles.scrollContainer, size: 's', barHideStrategy: 'never', resize: isResizable ? 'vertical' : 'none', "data-test-id": 'field-textarea__scroll-area', children: _jsx(TextArea, { className: styles.textarea, "data-size": size, value: value, onChange: onChange, placeholder: placeholder, disabled: disabled, readonly: readonly, minRows: minRows, id: id, name: name, ref: mergeRefs(ref, localRef), onFocus: onFocus, onBlur: onBlur, onKeyDown: onInputKeyDown, tabIndex: inputTabIndex, maxLength: allowMoreThanMaxLength ? undefined : maxLength || undefined, "data-test-id": 'field-textarea__input' }) }) }) })));
54
54
  });
@@ -6,5 +6,11 @@ export declare const VALIDATION_STATE: {
6
6
  };
7
7
  export declare const CONTAINER_VARIANT: {
8
8
  readonly SingleLine: "single-line-container";
9
+ readonly SingleLineButtonBefore: "single-line-container-button-before";
10
+ readonly SingleLineButtonAfter: "single-line-container-button-after";
9
11
  readonly MultiLine: "multi-line-container";
10
12
  };
13
+ export declare const BUTTON_VARIANT: {
14
+ readonly Before: "before";
15
+ readonly After: "after";
16
+ };
package/dist/constants.js CHANGED
@@ -6,5 +6,11 @@ export const VALIDATION_STATE = {
6
6
  };
7
7
  export const CONTAINER_VARIANT = {
8
8
  SingleLine: 'single-line-container',
9
+ SingleLineButtonBefore: 'single-line-container-button-before',
10
+ SingleLineButtonAfter: 'single-line-container-button-after',
9
11
  MultiLine: 'multi-line-container',
10
12
  };
13
+ export const BUTTON_VARIANT = {
14
+ Before: 'before',
15
+ After: 'after',
16
+ };
@@ -0,0 +1,18 @@
1
+ import { FocusEventHandler, KeyboardEventHandler, MouseEventHandler, ReactNode } from 'react';
2
+ import { Size } from '@snack-uikit/input-private';
3
+ import { ButtonVariant } from '../../types';
4
+ export type ButtonFieldProps = {
5
+ size: Size;
6
+ onClick?: MouseEventHandler<HTMLButtonElement>;
7
+ onKeyDown?: KeyboardEventHandler<HTMLButtonElement>;
8
+ onFocus?: FocusEventHandler<HTMLButtonElement>;
9
+ onBlur?: FocusEventHandler<HTMLButtonElement>;
10
+ tabIndex?: number;
11
+ disabled?: boolean;
12
+ hasArrow?: boolean;
13
+ arrowOpen?: boolean;
14
+ content?: ReactNode;
15
+ variant: ButtonVariant;
16
+ className?: string;
17
+ };
18
+ export declare const ButtonField: import("react").ForwardRefExoticComponent<ButtonFieldProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import cn from 'classnames';
3
+ import { forwardRef } from 'react';
4
+ import { Divider } from '@snack-uikit/divider';
5
+ import { getArrowIcon } from '../../components/FieldSelect/utils';
6
+ import styles from './styles.module.css';
7
+ export const ButtonField = forwardRef(({ size, tabIndex = 0, onClick, onKeyDown, onFocus, onBlur, disabled, content, hasArrow = false, arrowOpen = false, variant, className, }, ref) => {
8
+ const { ArrowIcon, arrowIconSize } = getArrowIcon({ size, open: arrowOpen });
9
+ return (_jsxs("button", { className: cn(className, styles.buttonField), "data-size": size, "data-variant": variant, "data-arrow-open": arrowOpen || undefined, "data-disabled": disabled || undefined, onClick: disabled ? undefined : onClick, onKeyDown: disabled ? undefined : onKeyDown, onFocus: disabled ? undefined : onFocus, onBlur: disabled ? undefined : onBlur, "data-test-id": 'button-field', ref: ref, tabIndex: tabIndex, type: 'button', disabled: disabled, children: [variant === 'after' && _jsx(Divider, { orientation: 'vertical', className: styles.divider }), _jsx("div", { className: styles.content, children: content }), hasArrow && _jsx(ArrowIcon, { size: arrowIconSize }), variant === 'before' && _jsx(Divider, { orientation: 'vertical', className: styles.divider })] }));
10
+ });
@@ -0,0 +1 @@
1
+ export * from './ButtonField';
@@ -0,0 +1 @@
1
+ export * from './ButtonField';
@@ -0,0 +1,96 @@
1
+ .buttonField{
2
+ display:flex;
3
+ flex-shrink:0;
4
+ align-items:center;
5
+ justify-content:center;
6
+ margin:0;
7
+ padding:0;
8
+ color:var(--sys-neutral-text-support, #6d707f);
9
+ background-color:transparent;
10
+ border:none;
11
+ }
12
+ .buttonField[data-variant=before][data-size=s]{
13
+ border-top-right-radius:var(--dimension-theme-general-0px, 0px);
14
+ border-bottom-right-radius:var(--dimension-theme-general-0px, 0px);
15
+ border-top-left-radius:var(--radius-fields-button-field-s, 10px);
16
+ border-bottom-left-radius:var(--radius-fields-button-field-s, 10px);
17
+ padding-left:var(--space-fields-single-line-container-s-left, 6px);
18
+ padding-right:var(--dimension-theme-general-0px, 0px);
19
+ gap:var(--space-fields-single-line-container-s-gap, 4px);
20
+ min-height:var(--size-fields-button-field-s, 28px);
21
+ }
22
+ .buttonField[data-variant=before][data-size=m]{
23
+ border-top-right-radius:var(--dimension-theme-general-0px, 0px);
24
+ border-bottom-right-radius:var(--dimension-theme-general-0px, 0px);
25
+ border-top-left-radius:var(--radius-fields-button-field-m, 12px);
26
+ border-bottom-left-radius:var(--radius-fields-button-field-m, 12px);
27
+ padding-left:var(--space-fields-single-line-container-m-left, 8px);
28
+ padding-right:var(--dimension-theme-general-0px, 0px);
29
+ gap:var(--space-fields-single-line-container-m-gap, 4px);
30
+ min-height:var(--size-fields-button-field-m, 36px);
31
+ }
32
+ .buttonField[data-variant=before][data-size=l]{
33
+ border-top-right-radius:var(--dimension-theme-general-0px, 0px);
34
+ border-bottom-right-radius:var(--dimension-theme-general-0px, 0px);
35
+ border-top-left-radius:var(--radius-fields-button-field-l, 14px);
36
+ border-bottom-left-radius:var(--radius-fields-button-field-l, 14px);
37
+ padding-left:var(--space-fields-single-line-container-l-left, 10px);
38
+ padding-right:var(--dimension-theme-general-0px, 0px);
39
+ gap:var(--space-fields-single-line-container-l-gap, 8px);
40
+ min-height:var(--size-fields-button-field-l, 44px);
41
+ }
42
+ .buttonField[data-variant=after][data-size=s]{
43
+ border-top-right-radius:var(--radius-fields-button-field-s, 10px);
44
+ border-bottom-right-radius:var(--radius-fields-button-field-s, 10px);
45
+ border-top-left-radius:var(--dimension-theme-general-0px, 0px);
46
+ border-bottom-left-radius:var(--dimension-theme-general-0px, 0px);
47
+ padding-left:var(--dimension-theme-general-0px, 0px);
48
+ padding-right:var(--space-fields-single-line-container-s-right, 6px);
49
+ gap:var(--space-fields-single-line-container-s-gap, 4px);
50
+ min-height:var(--size-fields-button-field-s, 28px);
51
+ }
52
+ .buttonField[data-variant=after][data-size=m]{
53
+ border-top-right-radius:var(--radius-fields-button-field-m, 12px);
54
+ border-bottom-right-radius:var(--radius-fields-button-field-m, 12px);
55
+ border-top-left-radius:var(--dimension-theme-general-0px, 0px);
56
+ border-bottom-left-radius:var(--dimension-theme-general-0px, 0px);
57
+ padding-left:var(--dimension-theme-general-0px, 0px);
58
+ padding-right:var(--space-fields-single-line-container-m-right, 8px);
59
+ gap:var(--space-fields-single-line-container-m-gap, 4px);
60
+ min-height:var(--size-fields-button-field-m, 36px);
61
+ }
62
+ .buttonField[data-variant=after][data-size=l]{
63
+ border-top-right-radius:var(--radius-fields-button-field-l, 14px);
64
+ border-bottom-right-radius:var(--radius-fields-button-field-l, 14px);
65
+ border-top-left-radius:var(--dimension-theme-general-0px, 0px);
66
+ border-bottom-left-radius:var(--dimension-theme-general-0px, 0px);
67
+ padding-left:var(--dimension-theme-general-0px, 0px);
68
+ padding-right:var(--space-fields-single-line-container-l-right, 10px);
69
+ gap:var(--space-fields-single-line-container-l-gap, 8px);
70
+ min-height:var(--size-fields-button-field-l, 44px);
71
+ }
72
+ .buttonField:hover{
73
+ cursor:pointer;
74
+ background:color-mix(in srgb, var(--sys-neutral-accent-default, #787b8a), var(--sys-neutral-background1-level, #fdfdfd) calc((1 - var(--opacity-a008, 0.08)) * 100%));
75
+ }
76
+ .buttonField:focus-visible, .buttonField[data-arrow-open]{
77
+ outline-width:var(--border-state-focus-s-border-width, 2px);
78
+ outline-style:var(--border-state-focus-s-border-style, solid);
79
+ outline-color:var(--border-state-focus-s-border-color, );
80
+ background:color-mix(in srgb, var(--sys-neutral-accent-default, #787b8a), var(--sys-neutral-background1-level, #fdfdfd) calc((1 - var(--opacity-a008, 0.08)) * 100%));
81
+ outline-color:var(--sys-primary-accent-default, #794ed3);
82
+ }
83
+ .buttonField[data-disabled]{
84
+ cursor:not-allowed;
85
+ opacity:var(--opacity-a056, 0.56);
86
+ background-color:transparent;
87
+ }
88
+
89
+ .divider{
90
+ align-self:stretch;
91
+ height:auto;
92
+ }
93
+
94
+ .content{
95
+ display:inline-flex;
96
+ }
@@ -0,0 +1,4 @@
1
+ import { ButtonFieldProps } from '../ButtonField';
2
+ export declare const ButtonFieldList: import("react").ForwardRefExoticComponent<Omit<ButtonFieldProps, "hasArrow" | "arrowOpen"> & Pick<import("@snack-uikit/list").DroplistProps, "open" | "onOpenChange" | "items"> & {
3
+ selection?: Omit<import("@snack-uikit/list").SelectionSingleState, "mode">;
4
+ } & import("react").RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,27 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { forwardRef } from 'react';
14
+ import { useUncontrolledProp } from 'uncontrollable';
15
+ import { Droplist } from '@snack-uikit/list';
16
+ import { ButtonField } from '../ButtonField';
17
+ import { getPlacement } from './helpers';
18
+ import styles from './styles.module.css';
19
+ export const ButtonFieldList = forwardRef((_a, ref) => {
20
+ var { items, selection, open, onOpenChange } = _a, rest = __rest(_a, ["items", "selection", "open", "onOpenChange"]);
21
+ const [isOpen, setIsOpen] = useUncontrolledProp(open, false, onOpenChange);
22
+ const placement = getPlacement(rest);
23
+ return (_jsx(Droplist, { "data-test-id": 'button-field-list', items: items, selection: Object.assign({ mode: 'single' }, selection), open: isOpen, onOpenChange: setIsOpen, closeDroplistOnItemClick: true,
24
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
25
+ // @ts-ignore
26
+ triggerElemRef: ref, size: rest.size, placement: placement, children: _jsx(ButtonField, Object.assign({}, rest, { hasArrow: true, arrowOpen: isOpen, className: styles.triggerClassName })) }));
27
+ });
@@ -0,0 +1,5 @@
1
+ import { DroplistProps } from '@snack-uikit/list';
2
+ import { ButtonVariant } from '../../types';
3
+ export declare function getPlacement({ variant }: {
4
+ variant?: ButtonVariant;
5
+ }): DroplistProps['placement'];
@@ -0,0 +1,8 @@
1
+ export function getPlacement({ variant }) {
2
+ if (variant === 'before') {
3
+ return 'bottom-start';
4
+ }
5
+ if (variant === 'after') {
6
+ return 'bottom-end';
7
+ }
8
+ }
@@ -0,0 +1 @@
1
+ export * from './ButtonFieldList';
@@ -0,0 +1 @@
1
+ export * from './ButtonFieldList';
@@ -0,0 +1,3 @@
1
+ .triggerClassName{
2
+ --offset:var(--space-drop-list-drop-offset, 4px);
3
+ }
@@ -1,4 +1,4 @@
1
- import { CSSProperties, ReactElement, ReactNode, RefObject } from 'react';
1
+ import { CSSProperties, ReactNode, RefObject } from 'react';
2
2
  import { Size } from '@snack-uikit/input-private';
3
3
  import { WithSupportProps } from '@snack-uikit/utils';
4
4
  import { ContainerVariant, ValidationState } from '../../types';
@@ -11,10 +11,11 @@ export type FieldContainerPrivateProps = WithSupportProps<{
11
11
  disabled: boolean;
12
12
  readonly: boolean;
13
13
  focused?: boolean;
14
+ disableFocus?: boolean;
14
15
  selectable?: boolean;
15
16
  style?: CSSProperties;
16
- prefix?: ReactElement;
17
- postfix?: ReactElement;
17
+ prefix?: ReactNode;
18
+ postfix?: ReactNode;
18
19
  inputRef: RefObject<HTMLElement>;
19
20
  }>;
20
- export declare function FieldContainerPrivate({ className, children, size, validationState, variant, disabled, readonly, focused, selectable, style, prefix, postfix, inputRef, ...rest }: FieldContainerPrivateProps): import("react/jsx-runtime").JSX.Element;
21
+ export declare function FieldContainerPrivate({ className, children, size, validationState, variant, disabled, readonly, focused, disableFocus, selectable, style, prefix, postfix, inputRef, ...rest }: FieldContainerPrivateProps): import("react/jsx-runtime").JSX.Element;
@@ -15,7 +15,7 @@ import { extractSupportProps } from '@snack-uikit/utils';
15
15
  import { VALIDATION_STATE } from '../../constants';
16
16
  import styles from './styles.module.css';
17
17
  export function FieldContainerPrivate(_a) {
18
- var { className, children, size, validationState, variant, disabled, readonly, focused, selectable, style, prefix, postfix, inputRef } = _a, rest = __rest(_a, ["className", "children", "size", "validationState", "variant", "disabled", "readonly", "focused", "selectable", "style", "prefix", "postfix", "inputRef"]);
18
+ var { className, children, size, validationState, variant, disabled, readonly, focused, disableFocus, selectable, style, prefix, postfix, inputRef } = _a, rest = __rest(_a, ["className", "children", "size", "validationState", "variant", "disabled", "readonly", "focused", "disableFocus", "selectable", "style", "prefix", "postfix", "inputRef"]);
19
19
  const handleContainerClick = () => {
20
20
  var _a;
21
21
  if (disabled) {
@@ -23,5 +23,5 @@ export function FieldContainerPrivate(_a) {
23
23
  }
24
24
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
25
25
  };
26
- return (_jsxs("div", Object.assign({ className: cn(className, styles.container), style: style, "data-size": size, "data-validation": disabled || readonly ? VALIDATION_STATE.Default : validationState, "data-variant": variant, "data-disabled": disabled || undefined, "data-readonly": readonly || undefined, "data-focused": focused || undefined, "data-selectable": selectable || undefined, "data-test-id": 'field-container-private', onClick: handleContainerClick, role: 'textbox', tabIndex: -1 }, extractSupportProps(rest), { children: [prefix && (_jsx("span", { className: styles.prefix, "data-test-id": 'field-container-private__prefix-icon', children: prefix })), children, postfix && _jsx("span", { className: styles.postfix, children: postfix })] })));
26
+ return (_jsxs("div", Object.assign({ className: cn(className, styles.container), style: style, "data-size": size, "data-validation": disabled || readonly ? VALIDATION_STATE.Default : validationState, "data-variant": variant, "data-disabled": disabled || undefined, "data-readonly": readonly || undefined, "data-focused": focused || undefined, "data-disable-focus": disableFocus || undefined, "data-selectable": selectable || undefined, "data-test-id": 'field-container-private', onClick: handleContainerClick, role: 'textbox', tabIndex: -1 }, extractSupportProps(rest), { children: [prefix && (_jsx("span", { className: styles.prefix, "data-test-id": 'field-container-private__prefix-icon', children: prefix })), children, postfix && _jsx("span", { className: styles.postfix, children: postfix })] })));
27
27
  }
@@ -14,7 +14,7 @@
14
14
  background-color:var(--sys-neutral-background2-level, #ffffff);
15
15
  border-color:var(--sys-primary-decor-hovered, #decdfb);
16
16
  }
17
- .container[data-validation=default]:not([data-readonly]):focus-within:not([data-disabled]), .container[data-validation=default]:not([data-readonly])[data-focused]:not([data-disabled]){
17
+ .container[data-validation=default]:not([data-readonly]):not([data-disable-focus]):focus-within:not([data-disabled]), .container[data-validation=default]:not([data-readonly]):not([data-disable-focus])[data-focused]:not([data-disabled]){
18
18
  outline-width:var(--border-state-focus-m-border-width, 3px);
19
19
  outline-style:var(--border-state-focus-m-border-style, solid);
20
20
  outline-color:var(--border-state-focus-m-border-color, );
@@ -30,7 +30,7 @@
30
30
  background-color:var(--sys-neutral-background2-level, #ffffff);
31
31
  border-color:var(--sys-red-decor-hovered, #fac1b3);
32
32
  }
33
- .container[data-validation=error]:not([data-readonly]):focus-within:not([data-disabled]), .container[data-validation=error]:not([data-readonly])[data-focused]:not([data-disabled]){
33
+ .container[data-validation=error]:not([data-readonly]):not([data-disable-focus]):focus-within:not([data-disabled]), .container[data-validation=error]:not([data-readonly]):not([data-disable-focus])[data-focused]:not([data-disabled]){
34
34
  outline-width:var(--border-state-focus-m-border-width, 3px);
35
35
  outline-style:var(--border-state-focus-m-border-style, solid);
36
36
  outline-color:var(--border-state-focus-m-border-color, );
@@ -46,7 +46,7 @@
46
46
  background-color:var(--sys-neutral-background2-level, #ffffff);
47
47
  border-color:var(--sys-yellow-decor-hovered, #ead49a);
48
48
  }
49
- .container[data-validation=warning]:not([data-readonly]):focus-within:not([data-disabled]), .container[data-validation=warning]:not([data-readonly])[data-focused]:not([data-disabled]){
49
+ .container[data-validation=warning]:not([data-readonly]):not([data-disable-focus]):focus-within:not([data-disabled]), .container[data-validation=warning]:not([data-readonly]):not([data-disable-focus])[data-focused]:not([data-disabled]){
50
50
  outline-width:var(--border-state-focus-m-border-width, 3px);
51
51
  outline-style:var(--border-state-focus-m-border-style, solid);
52
52
  outline-color:var(--border-state-focus-m-border-color, );
@@ -62,7 +62,7 @@
62
62
  background-color:var(--sys-neutral-background2-level, #ffffff);
63
63
  border-color:var(--sys-green-decor-hovered, #c0e1ba);
64
64
  }
65
- .container[data-validation=success]:not([data-readonly]):focus-within:not([data-disabled]), .container[data-validation=success]:not([data-readonly])[data-focused]:not([data-disabled]){
65
+ .container[data-validation=success]:not([data-readonly]):not([data-disable-focus]):focus-within:not([data-disabled]), .container[data-validation=success]:not([data-readonly]):not([data-disable-focus])[data-focused]:not([data-disabled]){
66
66
  outline-width:var(--border-state-focus-m-border-width, 3px);
67
67
  outline-style:var(--border-state-focus-m-border-style, solid);
68
68
  outline-color:var(--border-state-focus-m-border-color, );
@@ -94,6 +94,22 @@
94
94
  padding-right:var(--space-fields-single-line-container-s-right, 6px);
95
95
  height:var(--size-fields-s, 32px);
96
96
  }
97
+ .container[data-size=s][data-variant=single-line-container-button-before]{
98
+ border-radius:var(--radius-fields-s, 12px);
99
+ border-width:var(--border-width-fields-single, 2px);
100
+ padding-left:var(--space-fields-single-line-container-s-button, 0px);
101
+ gap:var(--space-fields-single-line-container-s-gap, 4px);
102
+ padding-right:var(--space-fields-single-line-container-s-right, 6px);
103
+ height:var(--size-fields-s, 32px);
104
+ }
105
+ .container[data-size=s][data-variant=single-line-container-button-after]{
106
+ border-radius:var(--radius-fields-s, 12px);
107
+ border-width:var(--border-width-fields-single, 2px);
108
+ padding-left:var(--space-fields-single-line-container-s-left, 6px);
109
+ gap:var(--space-fields-single-line-container-s-gap, 4px);
110
+ padding-right:var(--space-fields-single-line-container-s-button, 0px);
111
+ height:var(--size-fields-s, 32px);
112
+ }
97
113
  .container[data-size=s][data-variant=multi-line-container]{
98
114
  border-radius:var(--radius-fields-s, 12px);
99
115
  border-width:var(--border-width-fields-single, 2px);
@@ -126,6 +142,22 @@
126
142
  padding-right:var(--space-fields-single-line-container-m-right, 8px);
127
143
  height:var(--size-fields-m, 40px);
128
144
  }
145
+ .container[data-size=m][data-variant=single-line-container-button-before]{
146
+ border-radius:var(--radius-fields-m, 14px);
147
+ border-width:var(--border-width-fields-single, 2px);
148
+ padding-left:var(--space-fields-single-line-container-m-button, 0px);
149
+ gap:var(--space-fields-single-line-container-m-gap, 4px);
150
+ padding-right:var(--space-fields-single-line-container-m-right, 8px);
151
+ height:var(--size-fields-m, 40px);
152
+ }
153
+ .container[data-size=m][data-variant=single-line-container-button-after]{
154
+ border-radius:var(--radius-fields-m, 14px);
155
+ border-width:var(--border-width-fields-single, 2px);
156
+ padding-left:var(--space-fields-single-line-container-m-left, 8px);
157
+ gap:var(--space-fields-single-line-container-m-gap, 4px);
158
+ padding-right:var(--space-fields-single-line-container-m-button, 0px);
159
+ height:var(--size-fields-m, 40px);
160
+ }
129
161
  .container[data-size=m][data-variant=multi-line-container]{
130
162
  border-radius:var(--radius-fields-m, 14px);
131
163
  border-width:var(--border-width-fields-single, 2px);
@@ -158,6 +190,22 @@
158
190
  padding-right:var(--space-fields-single-line-container-l-right, 10px);
159
191
  height:var(--size-fields-l, 48px);
160
192
  }
193
+ .container[data-size=l][data-variant=single-line-container-button-before]{
194
+ border-radius:var(--radius-fields-l, 16px);
195
+ border-width:var(--border-width-fields-single, 2px);
196
+ padding-left:var(--space-fields-single-line-container-l-button, 0px);
197
+ gap:var(--space-fields-single-line-container-l-gap, 8px);
198
+ padding-right:var(--space-fields-single-line-container-l-right, 10px);
199
+ height:var(--size-fields-l, 48px);
200
+ }
201
+ .container[data-size=l][data-variant=single-line-container-button-after]{
202
+ border-radius:var(--radius-fields-l, 16px);
203
+ border-width:var(--border-width-fields-single, 2px);
204
+ padding-left:var(--space-fields-single-line-container-l-left, 10px);
205
+ gap:var(--space-fields-single-line-container-l-gap, 8px);
206
+ padding-right:var(--space-fields-single-line-container-l-button, 0px);
207
+ height:var(--size-fields-l, 48px);
208
+ }
161
209
  .container[data-size=l][data-variant=multi-line-container]{
162
210
  border-radius:var(--radius-fields-l, 16px);
163
211
  border-width:var(--border-width-fields-single, 2px);
@@ -184,7 +232,7 @@
184
232
  background-color:var(--sys-neutral-decor-disabled, #e6e8ef);
185
233
  border-color:var(--sys-neutral-decor-disabled, #e6e8ef);
186
234
  }
187
- .container[data-readonly]:focus-within, .container[data-readonly][data-focused]{
235
+ .container[data-readonly]:not([data-disable-focus]):focus-within, .container[data-readonly]:not([data-disable-focus])[data-focused]{
188
236
  outline-width:var(--border-state-focus-m-border-width, 3px);
189
237
  outline-style:var(--border-state-focus-m-border-style, solid);
190
238
  outline-color:var(--border-state-focus-m-border-color, );
@@ -209,6 +257,8 @@
209
257
  .prefix{
210
258
  display:inline-flex;
211
259
  flex-shrink:0;
260
+ gap:var(--space-fields-postfix-gap, 4px);
261
+ align-items:center;
212
262
  color:var(--sys-neutral-text-disabled, #aaaebd);
213
263
  }
214
264
 
@@ -216,4 +266,5 @@
216
266
  display:inline-flex;
217
267
  flex-shrink:0;
218
268
  gap:var(--space-fields-postfix-gap, 4px);
269
+ align-items:center;
219
270
  }
@@ -1,4 +1,6 @@
1
1
  export * from './ButtonCopyValue';
2
+ export * from './ButtonField';
3
+ export * from './ButtonFieldList';
2
4
  export * from './ButtonHideValue';
3
5
  export * from './FieldContainerPrivate';
4
6
  export * from './TextArea';
@@ -1,4 +1,6 @@
1
1
  export * from './ButtonCopyValue';
2
+ export * from './ButtonField';
3
+ export * from './ButtonFieldList';
2
4
  export * from './ButtonHideValue';
3
5
  export * from './FieldContainerPrivate';
4
6
  export * from './TextArea';
@@ -1,3 +1,7 @@
1
1
  export * from './useCopyButton';
2
2
  export * from './useHideButton';
3
+ export * from './usePostfix';
4
+ export * from './usePostfixButton';
5
+ export * from './usePrefix';
6
+ export * from './usePrefixButton';
3
7
  export * from './useValueControl';
@@ -1,3 +1,7 @@
1
1
  export * from './useCopyButton';
2
2
  export * from './useHideButton';
3
+ export * from './usePostfix';
4
+ export * from './usePostfixButton';
5
+ export * from './usePrefix';
6
+ export * from './usePrefixButton';
3
7
  export * from './useValueControl';
@@ -0,0 +1,13 @@
1
+ .prefix{
2
+ color:var(--sys-neutral-text-support, #6d707f);
3
+ }
4
+ .prefix[data-disabled]{
5
+ opacity:var(--opacity-a056, 0.56);
6
+ }
7
+
8
+ .postfix{
9
+ color:var(--sys-neutral-text-support, #6d707f);
10
+ }
11
+ .postfix[data-disabled]{
12
+ opacity:var(--opacity-a056, 0.56);
13
+ }
@@ -8,6 +8,8 @@ type UseCopyButtonProps = {
8
8
  size: Size;
9
9
  onValueRequest?(): AsyncValueRequest;
10
10
  disabled?: boolean;
11
+ prefix?: string;
12
+ postfix?: string;
11
13
  };
12
- export declare function useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy, onValueRequest, disabled, }: UseCopyButtonProps): ButtonProps;
14
+ export declare function useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy, onValueRequest, disabled, prefix, postfix, }: UseCopyButtonProps): ButtonProps;
13
15
  export {};
@@ -2,11 +2,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useMemo } from 'react';
3
3
  import { BUTTON_SIZE_MAP } from '@snack-uikit/input-private';
4
4
  import { ButtonCopyValue } from '../helperComponents';
5
- export function useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy, onValueRequest, disabled, }) {
5
+ export function useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy, onValueRequest, disabled, prefix, postfix, }) {
6
6
  return useMemo(() => ({
7
7
  id: 'copy',
8
+ active: true,
8
9
  ref: copyButtonRef,
9
10
  show: showCopyButton,
10
- render: props => (_jsx(ButtonCopyValue, Object.assign({}, props, { size: BUTTON_SIZE_MAP[size], valueToCopy: valueToCopy, onValueRequest: onValueRequest, disabled: disabled }))),
11
- }), [copyButtonRef, disabled, onValueRequest, showCopyButton, size, valueToCopy]);
11
+ render: props => (_jsx(ButtonCopyValue, Object.assign({}, props, { size: BUTTON_SIZE_MAP[size], valueToCopy: prefix + valueToCopy + postfix, onValueRequest: onValueRequest, disabled: disabled }))),
12
+ }), [copyButtonRef, disabled, onValueRequest, showCopyButton, size, valueToCopy, prefix, postfix]);
12
13
  }
@@ -7,6 +7,7 @@ export function useHideButton({ hideButtonRef, showHideButton, size, toggleHidde
7
7
  const toggleHiddenEventHandler = useEventHandler(toggleHidden);
8
8
  return useMemo(() => ({
9
9
  id: 'hide',
10
+ active: true,
10
11
  ref: hideButtonRef,
11
12
  show: showHideButton,
12
13
  render: props => {
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from 'react';
2
+ import { InactiveItem } from '@snack-uikit/input-private';
3
+ export declare function usePostfix({ postfix, disabled }: {
4
+ postfix?: ReactNode;
5
+ disabled?: boolean;
6
+ }): InactiveItem;