@snack-uikit/fields 0.33.1-preview-7bafd457.0 → 0.34.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 (59) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +7 -0
  3. package/dist/cjs/components/FieldColor/FieldColor.d.ts +4 -0
  4. package/dist/cjs/components/FieldColor/FieldColor.js +5 -3
  5. package/dist/cjs/components/FieldDate/FieldDate.d.ts +2 -0
  6. package/dist/cjs/components/FieldDate/FieldDate.js +5 -3
  7. package/dist/cjs/components/FieldSecure/FieldSecure.d.ts +2 -0
  8. package/dist/cjs/components/FieldSecure/FieldSecure.js +5 -3
  9. package/dist/cjs/components/FieldSelect/FieldSelectMultiple.d.ts +2 -1
  10. package/dist/cjs/components/FieldSelect/FieldSelectSingle.d.ts +1 -0
  11. package/dist/cjs/components/FieldSelect/FieldSelectSingle.js +4 -2
  12. package/dist/cjs/components/FieldSelect/hooks.d.ts +2 -1
  13. package/dist/cjs/components/FieldSelect/hooks.js +3 -1
  14. package/dist/cjs/components/FieldSelect/types.d.ts +3 -1
  15. package/dist/cjs/components/FieldStepper/FieldStepper.js +68 -80
  16. package/dist/cjs/components/FieldStepper/styles.module.css +0 -12
  17. package/dist/cjs/components/FieldText/FieldText.d.ts +2 -0
  18. package/dist/cjs/components/FieldText/FieldText.js +4 -2
  19. package/dist/cjs/components/FieldTextArea/FieldTextArea.d.ts +2 -0
  20. package/dist/cjs/components/FieldTextArea/FieldTextArea.js +5 -3
  21. package/dist/cjs/components/FieldTime/FieldTime.d.ts +2 -0
  22. package/dist/cjs/components/FieldTime/FieldTime.js +5 -3
  23. package/dist/cjs/hooks/useCopyButton.d.ts +2 -1
  24. package/dist/cjs/hooks/useCopyButton.js +3 -1
  25. package/dist/esm/components/FieldColor/FieldColor.d.ts +4 -0
  26. package/dist/esm/components/FieldColor/FieldColor.js +8 -2
  27. package/dist/esm/components/FieldDate/FieldDate.d.ts +2 -0
  28. package/dist/esm/components/FieldDate/FieldDate.js +2 -2
  29. package/dist/esm/components/FieldSecure/FieldSecure.d.ts +2 -0
  30. package/dist/esm/components/FieldSecure/FieldSecure.js +2 -1
  31. package/dist/esm/components/FieldSelect/FieldSelectMultiple.d.ts +2 -1
  32. package/dist/esm/components/FieldSelect/FieldSelectSingle.d.ts +1 -0
  33. package/dist/esm/components/FieldSelect/FieldSelectSingle.js +2 -1
  34. package/dist/esm/components/FieldSelect/hooks.d.ts +2 -1
  35. package/dist/esm/components/FieldSelect/hooks.js +2 -1
  36. package/dist/esm/components/FieldSelect/types.d.ts +3 -1
  37. package/dist/esm/components/FieldStepper/FieldStepper.js +24 -30
  38. package/dist/esm/components/FieldStepper/styles.module.css +0 -12
  39. package/dist/esm/components/FieldText/FieldText.d.ts +2 -0
  40. package/dist/esm/components/FieldText/FieldText.js +2 -1
  41. package/dist/esm/components/FieldTextArea/FieldTextArea.d.ts +2 -0
  42. package/dist/esm/components/FieldTextArea/FieldTextArea.js +8 -2
  43. package/dist/esm/components/FieldTime/FieldTime.d.ts +2 -0
  44. package/dist/esm/components/FieldTime/FieldTime.js +2 -2
  45. package/dist/esm/hooks/useCopyButton.d.ts +2 -1
  46. package/dist/esm/hooks/useCopyButton.js +3 -3
  47. package/package.json +6 -6
  48. package/src/components/FieldColor/FieldColor.tsx +10 -1
  49. package/src/components/FieldDate/FieldDate.tsx +4 -1
  50. package/src/components/FieldSecure/FieldSecure.tsx +4 -0
  51. package/src/components/FieldSelect/FieldSelectSingle.tsx +2 -0
  52. package/src/components/FieldSelect/hooks.ts +3 -0
  53. package/src/components/FieldSelect/types.ts +3 -1
  54. package/src/components/FieldStepper/FieldStepper.tsx +67 -79
  55. package/src/components/FieldStepper/styles.module.scss +1 -14
  56. package/src/components/FieldText/FieldText.tsx +4 -0
  57. package/src/components/FieldTextArea/FieldTextArea.tsx +10 -1
  58. package/src/components/FieldTime/FieldTime.tsx +4 -1
  59. package/src/hooks/useCopyButton.tsx +4 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 0.34.0 (2024-11-18)
7
+
8
+
9
+ ### Features
10
+
11
+ * **LK-4944:** added onClickCopy props for copyButton in Fields ([03a5182](https://github.com/cloud-ru-tech/snack-uikit/commit/03a5182cd7c57211aae0e4e9d507eea4c61d9040))
12
+
13
+
14
+
15
+
16
+
6
17
  # 0.33.0 (2024-11-14)
7
18
 
8
19
 
package/README.md CHANGED
@@ -198,6 +198,7 @@ FieldStepper в основном предназначен для работы с
198
198
  | open | `boolean` | - | Открыт color-picker |
199
199
  | onOpenChange | `(value: boolean) => void` | - | Колбек открытия пикера |
200
200
  | showCopyButton | `boolean` | - | Отображение кнопки копирования |
201
+ | onCopyButtonClick | `() => void` | - | Колбек клика по кнопке Копировать для поля |
201
202
  | showClearButton | `boolean` | true | Отображение кнопки Очистки поля |
202
203
  | value | `string` | - | Значение input |
203
204
  | onChange | `(value: string) => void` | - | |
@@ -234,6 +235,7 @@ FieldStepper в основном предназначен для работы с
234
235
  | value | `Date` | - | Значение поля |
235
236
  | onChange | `(value: Date) => void` | - | Колбек смены значения |
236
237
  | showCopyButton | `boolean` | - | Отображение кнопки копирования |
238
+ | onCopyButtonClick | `() => void` | - | Колбек клика по кнопке Копировать для поля |
237
239
  | showClearButton | `boolean` | true | Отображение кнопки Очистки поля |
238
240
  | buildCellProps | `(date: Date, viewMode: ViewMode) => { isDisabled?: boolean; isHoliday?: boolean } ;` | - | Колбек установки свойств ячеек календаря. Вызывается на построение каждой ячейки. Принимает два параметра: <br> `Date` - дата ячейки <br> `ViewMode`: <br> - `month` отображение месяца, каждая ячейка - 1 день <br> - `year` отображение года, каждая ячейка - 1 месяц <br> - `decade` отображение декады, каждая ячейка - 1 год <br><br> Колбек должен возвращать объект с полями, отвечающими за отключение и подкраску ячейки. |
239
241
  | id | `string` | - | Значение html-атрибута id |
@@ -283,6 +285,7 @@ FieldStepper в основном предназначен для работы с
283
285
  | hidden | `boolean` | - | Замаскированно ли значение поля |
284
286
  | onHiddenChange | `(value: boolean) => void` | - | Колбек смены маскирования |
285
287
  | showCopyButton | `boolean` | - | Отображение кнопки копирования |
288
+ | onCopyButtonClick | `() => void` | - | Колбек клика по кнопке Копировать для поля |
286
289
  | allowMoreThanMaxLength | `boolean` | - | Можно ли вводить больше разрешённого кол-ва символов |
287
290
  | prefixIcon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка-префикс для поля |
288
291
  | asyncValueGetter | `() => Promise<string>` | - | Свойство позволяет грузить данные в поле по требованию |
@@ -344,6 +347,7 @@ FieldStepper в основном предназначен для работы с
344
347
  | showClearButton | `boolean` | true | Отображение кнопки очистки поля |
345
348
  | open | `boolean` | - | |
346
349
  | onOpenChange | `(open: boolean) => void` | - | |
350
+ | onCopyButtonClick | `() => void` | - | Колбек клика по кнопке Копировать для поля |
347
351
  | prefixIcon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка-префикс для поля |
348
352
  | widthStrategy | enum PopoverWidthStrategy: `"auto"`, `"gte"`, `"eq"` | - | |
349
353
  | pinTop | `OptionProps[]` | - | |
@@ -438,6 +442,7 @@ FieldStepper в основном предназначен для работы с
438
442
  | name | type | default value | description |
439
443
  |------|------|---------------|-------------|
440
444
  | showCopyButton | `boolean` | - | Отображение кнопки Копировать для поля (актуально только для `readonly = true`) |
445
+ | onCopyButtonClick | `() => void` | - | Колбек клика по кнопке Копировать для поля |
441
446
  | showClearButton | `boolean` | true | Отображение кнопки очистки поля |
442
447
  | allowMoreThanMaxLength | `boolean` | - | Можно ли вводить больше разрешённого кол-ва символов |
443
448
  | prefixIcon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка-префикс для поля |
@@ -477,6 +482,7 @@ FieldStepper в основном предназначен для работы с
477
482
  | resizable | `boolean` | - | Может ли ли пользователь изменять размеры поля (если св-во не включено, поле автоматически меняет свой размер) |
478
483
  | onChange | `(value: string, e?: ChangeEvent<HTMLTextAreaElement>) => void` | - | Колбек смены значения |
479
484
  | showCopyButton | `boolean` | - | Отображение кнопки Копировать для поля (актуально только для `readonly = true`) |
485
+ | onCopyButtonClick | `() => void` | - | Колбек клика по кнопке Копировать для поля |
480
486
  | showClearButton | `boolean` | true | Отображение кнопки очистки поля |
481
487
  | allowMoreThanMaxLength | `boolean` | true | Можно ли вводить больше разрешённого кол-ва символов |
482
488
  | value | `string` | - | HTML-аттрибут value |
@@ -510,6 +516,7 @@ FieldStepper в основном предназначен для работы с
510
516
  | value | `TimeValue` | - | Значение поля |
511
517
  | onChange | `(value?: TimeValue) => void` | - | Колбек смены значения |
512
518
  | showCopyButton | `boolean` | - | Отображение кнопки копирования |
519
+ | onCopyButtonClick | `() => void` | - | Колбек клика по кнопке Копировать для поля |
513
520
  | showSeconds | `boolean` | true | Показывать ли секунды |
514
521
  | showClearButton | `boolean` | true | Отображение кнопки Очистки поля |
515
522
  | id | `string` | - | Значение html-атрибута id |
@@ -11,6 +11,8 @@ type FieldDateOwnProps = {
11
11
  onOpenChange?(value: boolean): void;
12
12
  /** Отображение кнопки копирования */
13
13
  showCopyButton?: boolean;
14
+ /** Колбек клика по кнопке Копировать для поля */
15
+ onCopyButtonClick?(): void;
14
16
  /**
15
17
  * Отображение кнопки Очистки поля
16
18
  * @default true
@@ -29,6 +31,8 @@ export declare const FieldColor: import("react").ForwardRefExoticComponent<{
29
31
  onOpenChange?(value: boolean): void;
30
32
  /** Отображение кнопки копирования */
31
33
  showCopyButton?: boolean;
34
+ /** Колбек клика по кнопке Копировать для поля */
35
+ onCopyButtonClick?(): void;
32
36
  /**
33
37
  * Отображение кнопки Очистки поля
34
38
  * @default true
@@ -58,9 +58,10 @@ exports.FieldColor = (0, react_1.forwardRef)((_a, ref) => {
58
58
  autoApply,
59
59
  placeholder,
60
60
  onFocus,
61
- onBlur
61
+ onBlur,
62
+ onCopyButtonClick
62
63
  } = _a,
63
- rest = __rest(_a, ["id", "name", "value", "disabled", "readonly", "showCopyButton", "showClearButton", "open", "onChange", "onOpenChange", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "error", "withAlpha", "autoApply", "placeholder", "onFocus", "onBlur"]);
64
+ rest = __rest(_a, ["id", "name", "value", "disabled", "readonly", "showCopyButton", "showClearButton", "open", "onChange", "onOpenChange", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "error", "withAlpha", "autoApply", "placeholder", "onFocus", "onBlur", "onCopyButtonClick"]);
64
65
  const [isOpen, setIsOpen] = (0, uncontrollable_1.useUncontrolledProp)(open, false, onOpenChange);
65
66
  const localRef = (0, react_1.useRef)(null);
66
67
  const showDropList = isOpen && !readonly && !disabled;
@@ -94,7 +95,8 @@ exports.FieldColor = (0, react_1.forwardRef)((_a, ref) => {
94
95
  copyButtonRef,
95
96
  showCopyButton,
96
97
  size,
97
- valueToCopy: value
98
+ valueToCopy: value,
99
+ onCopyButtonClick
98
100
  });
99
101
  const {
100
102
  postfixButtons,
@@ -21,6 +21,8 @@ type FieldDateOwnProps = {
21
21
  onChange?(value: Date | undefined): void;
22
22
  /** Отображение кнопки копирования */
23
23
  showCopyButton?: boolean;
24
+ /** Колбек клика по кнопке Копировать для поля */
25
+ onCopyButtonClick?(): void;
24
26
  /**
25
27
  * Отображение кнопки Очистки поля
26
28
  * @default true
@@ -59,9 +59,10 @@ exports.FieldDate = (0, react_1.forwardRef)((_a, ref) => {
59
59
  validationState = constants_1.VALIDATION_STATE.Default,
60
60
  buildCellProps,
61
61
  error,
62
- mode
62
+ mode,
63
+ onCopyButtonClick
63
64
  } = _a,
64
- rest = __rest(_a, ["id", "name", "value", "disabled", "readonly", "showCopyButton", "showClearButton", "open", "onOpenChange", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "buildCellProps", "error", "mode"]);
65
+ rest = __rest(_a, ["id", "name", "value", "disabled", "readonly", "showCopyButton", "showClearButton", "open", "onOpenChange", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "buildCellProps", "error", "mode", "onCopyButtonClick"]);
65
66
  const [isOpen, setIsOpen] = (0, uncontrollable_1.useUncontrolledProp)(open, false, onOpenChange);
66
67
  const localRef = (0, react_1.useRef)(null);
67
68
  const clearButtonRef = (0, react_1.useRef)(null);
@@ -125,7 +126,8 @@ exports.FieldDate = (0, react_1.forwardRef)((_a, ref) => {
125
126
  copyButtonRef,
126
127
  showCopyButton,
127
128
  size,
128
- valueToCopy
129
+ valueToCopy,
130
+ onCopyButtonClick
129
131
  });
130
132
  const calendarIcon = (0, react_1.useMemo)(() => ({
131
133
  active: false,
@@ -11,6 +11,8 @@ type FieldSecureOwnProps = {
11
11
  onHiddenChange?(value: boolean): void;
12
12
  /** Отображение кнопки копирования */
13
13
  showCopyButton?: boolean;
14
+ /** Колбек клика по кнопке Копировать для поля */
15
+ onCopyButtonClick?(): void;
14
16
  /** Можно ли вводить больше разрешённого кол-ва символов */
15
17
  allowMoreThanMaxLength?: boolean;
16
18
  /** Иконка-префикс для поля */
@@ -84,9 +84,10 @@ exports.FieldSecure = (0, react_1.forwardRef)((_a, ref) => {
84
84
  prefixIcon,
85
85
  error,
86
86
  asyncValueGetter,
87
- autoComplete
87
+ autoComplete,
88
+ onCopyButtonClick
88
89
  } = _a,
89
- rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "disabled", "readonly", "showCopyButton", "allowMoreThanMaxLength", "hidden", "onHiddenChange", "showHintIcon", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "size", "validationState", "prefixIcon", "error", "asyncValueGetter", "autoComplete"]);
90
+ rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "disabled", "readonly", "showCopyButton", "allowMoreThanMaxLength", "hidden", "onHiddenChange", "showHintIcon", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "size", "validationState", "prefixIcon", "error", "asyncValueGetter", "autoComplete", "onCopyButtonClick"]);
90
91
  const localRef = (0, react_1.useRef)(null);
91
92
  const copyButtonRef = (0, react_1.useRef)(null);
92
93
  const hideButtonRef = (0, react_1.useRef)(null);
@@ -154,7 +155,8 @@ exports.FieldSecure = (0, react_1.forwardRef)((_a, ref) => {
154
155
  size,
155
156
  valueToCopy: value,
156
157
  onValueRequest: getAsyncValue,
157
- disabled: isLoading
158
+ disabled: isLoading,
159
+ onCopyButtonClick
158
160
  });
159
161
  const hideButtonSettings = (0, hooks_1.useHideButton)({
160
162
  hideButtonRef,
@@ -14,6 +14,7 @@ export declare const FieldSelectMultiple: import("react").ForwardRefExoticCompon
14
14
  pinBottom?: import("./types").OptionProps[];
15
15
  searchable?: boolean;
16
16
  showCopyButton?: boolean;
17
+ onCopyButtonClick?(): void;
17
18
  showClearButton?: boolean;
18
19
  readonly?: boolean;
19
20
  prefixIcon?: import("react").ReactElement;
@@ -27,4 +28,4 @@ export declare const FieldSelectMultiple: import("react").ForwardRefExoticCompon
27
28
  resetSearchOnOptionSelection?: boolean;
28
29
  onOpenChange?(open: boolean): void;
29
30
  selectedOptionFormatter?: SelectedOptionFormatter;
30
- } & Pick<import("@snack-uikit/list").DroplistProps, "scrollToSelectedItem" | "untouchableScrollbars" | "dataFiltered" | "dataError" | "noDataState" | "noResultsState" | "errorDataState">, "showCopyButton"> & import("react").RefAttributes<HTMLInputElement>>;
31
+ } & Pick<import("@snack-uikit/list").DroplistProps, "scrollToSelectedItem" | "untouchableScrollbars" | "dataFiltered" | "dataError" | "noDataState" | "noResultsState" | "errorDataState">, "showCopyButton" | "onCopyButtonClick"> & import("react").RefAttributes<HTMLInputElement>>;
@@ -12,6 +12,7 @@ export declare const FieldSelectSingle: import("react").ForwardRefExoticComponen
12
12
  pinBottom?: import("./types").OptionProps[];
13
13
  searchable?: boolean;
14
14
  showCopyButton?: boolean;
15
+ onCopyButtonClick?(): void;
15
16
  showClearButton?: boolean;
16
17
  readonly?: boolean;
17
18
  prefixIcon?: import("react").ReactElement;
@@ -64,9 +64,10 @@ exports.FieldSelectSingle = (0, react_1.forwardRef)((props, ref) => {
64
64
  open: openProp,
65
65
  onOpenChange,
66
66
  selectedOptionFormatter = defaultSelectedOptionFormatter,
67
- enableFuzzySearch = true
67
+ enableFuzzySearch = true,
68
+ onCopyButtonClick
68
69
  } = props,
69
- rest = __rest(props, ["id", "name", "placeholder", "size", "options", "value", "defaultValue", "onChange", "disabled", "readonly", "searchable", "showCopyButton", "showClearButton", "onKeyDown", "required", "validationState", "search", "autocomplete", "prefixIcon", "prefix", "postfix", "addOptionByEnter", "untouchableScrollbars", "open", "onOpenChange", "selectedOptionFormatter", "enableFuzzySearch"]);
70
+ rest = __rest(props, ["id", "name", "placeholder", "size", "options", "value", "defaultValue", "onChange", "disabled", "readonly", "searchable", "showCopyButton", "showClearButton", "onKeyDown", "required", "validationState", "search", "autocomplete", "prefixIcon", "prefix", "postfix", "addOptionByEnter", "untouchableScrollbars", "open", "onOpenChange", "selectedOptionFormatter", "enableFuzzySearch", "onCopyButtonClick"]);
70
71
  const localRef = (0, react_1.useRef)(null);
71
72
  const [open = false, setOpen] = (0, hooks_1.useValueControl)({
72
73
  value: openProp,
@@ -153,6 +154,7 @@ exports.FieldSelectSingle = (0, react_1.forwardRef)((props, ref) => {
153
154
  showCopyButton,
154
155
  inputRef: localRef,
155
156
  onClear,
157
+ onCopyButtonClick,
156
158
  valueToCopy: selectedOptionFormatter(selectedItem)
157
159
  });
158
160
  const handleBlur = e => {
@@ -14,10 +14,11 @@ type UseButtonsProps = {
14
14
  showCopyButton: boolean;
15
15
  size: 's' | 'm' | 'l';
16
16
  onClear(): void;
17
+ onCopyButtonClick?(): void;
17
18
  inputRef: RefObject<HTMLInputElement>;
18
19
  valueToCopy?: string;
19
20
  };
20
- export declare function useButtons({ readonly, showClearButton, showCopyButton, size, onClear, inputRef, valueToCopy, }: UseButtonsProps): {
21
+ export declare function useButtons({ readonly, showClearButton, showCopyButton, size, onClear, onCopyButtonClick, inputRef, valueToCopy, }: UseButtonsProps): {
21
22
  postfixButtons: import("react/jsx-runtime").JSX.Element | undefined;
22
23
  inputKeyDownNavigationHandler: KeyboardEventHandler<HTMLInputElement>;
23
24
  buttonsRefs: (Element | null)[];
@@ -52,6 +52,7 @@ function useButtons(_ref2) {
52
52
  showCopyButton,
53
53
  size,
54
54
  onClear,
55
+ onCopyButtonClick,
55
56
  inputRef,
56
57
  valueToCopy = ''
57
58
  } = _ref2;
@@ -68,7 +69,8 @@ function useButtons(_ref2) {
68
69
  copyButtonRef,
69
70
  showCopyButton: readonly && showCopyButton,
70
71
  size,
71
- valueToCopy
72
+ valueToCopy,
73
+ onCopyButtonClick
72
74
  });
73
75
  const {
74
76
  onInputKeyDown: inputKeyDownNavigationHandler,
@@ -46,6 +46,8 @@ type FiledSelectCommonProps = WithSupportProps<{
46
46
  searchable?: boolean;
47
47
  /** Отображение кнопки Копировать для поля (актуально только для `readonly = true`) */
48
48
  showCopyButton?: boolean;
49
+ /** Колбек клика по кнопке Копировать для поля */
50
+ onCopyButtonClick?(): void;
49
51
  /**
50
52
  * Отображение кнопки очистки поля
51
53
  * @default true
@@ -74,7 +76,7 @@ type FiledSelectCommonProps = WithSupportProps<{
74
76
  export type FieldSelectSingleProps = FieldSelectPrivateProps & Omit<SelectionSingleState, 'mode'> & WrapperProps & Omit<FiledSelectCommonProps, 'resetSearchOnOptionSelection'>;
75
77
  export type FieldSelectMultipleProps = FieldSelectPrivateProps & {
76
78
  removeByBackspace?: boolean;
77
- } & Omit<SelectionMultipleState, 'mode'> & Omit<FiledSelectCommonProps, 'showCopyButton'>;
79
+ } & Omit<SelectionMultipleState, 'mode'> & Omit<FiledSelectCommonProps, 'showCopyButton' | 'onCopyButtonClick'>;
78
80
  export type FieldSelectProps = (FieldSelectSingleProps & {
79
81
  selection?: 'single';
80
82
  }) | (FieldSelectMultipleProps & {
@@ -42,11 +42,6 @@ const getDefaultValue = (min, max) => {
42
42
  }
43
43
  return 0;
44
44
  };
45
- const SymbolWidth = {
46
- s: 8,
47
- m: 9,
48
- l: 10
49
- };
50
45
  exports.FieldStepper = (0, react_1.forwardRef)((_a, ref) => {
51
46
  var {
52
47
  id,
@@ -88,8 +83,8 @@ exports.FieldStepper = (0, react_1.forwardRef)((_a, ref) => {
88
83
  const [tooltip, setTooltip] = (0, react_1.useState)('');
89
84
  const timerRef = (0, react_1.useRef)();
90
85
  const inputRef = (0, react_1.useRef)(null);
91
- // const minusButtonRef = useRef<HTMLButtonElement>(null);
92
- // const plusButtonRef = useRef<HTMLButtonElement>(null);
86
+ const minusButtonRef = (0, react_1.useRef)(null);
87
+ const plusButtonRef = (0, react_1.useRef)(null);
93
88
  const isMinusButtonDisabled = typeof min === 'number' && value <= min || readonly || disabled;
94
89
  const isPlusButtonDisabled = typeof max === 'number' && value >= max || readonly || disabled;
95
90
  const prefixSettings = (0, hooks_1.usePrefix)({
@@ -135,16 +130,17 @@ exports.FieldStepper = (0, react_1.forwardRef)((_a, ref) => {
135
130
  onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
136
131
  };
137
132
  const handleInputChange = (value, event) => setValue(Number(value), event);
138
- const handleInputKeyDown = () => {
133
+ const handleInputKeyDown = event => {
134
+ var _a, _b;
139
135
  if (readonly || disabled) {
140
136
  return;
141
137
  }
142
- // if (event.key === 'ArrowRight' && !isPlusButtonDisabled) {
143
- // plusButtonRef.current?.focus();
144
- // }
145
- // if (event.key === 'ArrowLeft' && !isMinusButtonDisabled) {
146
- // minusButtonRef.current?.focus();
147
- // }
138
+ if (event.key === 'ArrowRight' && !isPlusButtonDisabled) {
139
+ (_a = plusButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
140
+ }
141
+ if (event.key === 'ArrowLeft' && !isMinusButtonDisabled) {
142
+ (_b = minusButtonRef.current) === null || _b === void 0 ? void 0 : _b.focus();
143
+ }
148
144
  };
149
145
  const handleMinusButtonClick = e => {
150
146
  e.preventDefault();
@@ -156,23 +152,25 @@ exports.FieldStepper = (0, react_1.forwardRef)((_a, ref) => {
156
152
  e.stopPropagation();
157
153
  setValue(Math.max(Math.min(max, value + step), min));
158
154
  };
159
- const handleMinusButtonKeyDown = () => {
155
+ const handleMinusButtonKeyDown = event => {
156
+ var _a;
160
157
  if (readonly || disabled) {
161
158
  return;
162
159
  }
163
- // if (event.key === 'ArrowRight') {
164
- // event.preventDefault();
165
- // inputRef.current?.focus();
166
- // }
160
+ if (event.key === 'ArrowRight') {
161
+ event.preventDefault();
162
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
163
+ }
167
164
  };
168
- const handlePlusButtonKeyDown = () => {
165
+ const handlePlusButtonKeyDown = event => {
166
+ var _a;
169
167
  if (readonly || disabled) {
170
168
  return;
171
169
  }
172
- // if (event.key === 'ArrowLeft') {
173
- // event.preventDefault();
174
- // inputRef.current?.focus();
175
- // }
170
+ if (event.key === 'ArrowLeft') {
171
+ event.preventDefault();
172
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
173
+ }
176
174
  };
177
175
  return (0, jsx_runtime_1.jsx)(FieldDecorator_1.FieldDecorator, Object.assign({
178
176
  className: className,
@@ -194,7 +192,6 @@ exports.FieldStepper = (0, react_1.forwardRef)((_a, ref) => {
194
192
  tip: tooltip,
195
193
  open: allowMoreThanLimits ? false : tooltipOpen,
196
194
  "data-test-id": 'field-stepper__limit-tooltip',
197
- triggerClassName: styles_module_scss_1.default.trigger,
198
195
  children: (0, jsx_runtime_1.jsx)(helperComponents_1.FieldContainerPrivate, {
199
196
  size: size,
200
197
  validationState: fieldValidationState,
@@ -202,63 +199,54 @@ exports.FieldStepper = (0, react_1.forwardRef)((_a, ref) => {
202
199
  readonly: readonly,
203
200
  variant: constants_1.CONTAINER_VARIANT.SingleLine,
204
201
  inputRef: inputRef,
205
- prefix: (0, jsx_runtime_1.jsx)(button_1.ButtonFunction, {
206
- tabIndex: -1,
207
- size: 'xs',
208
- className: styles_module_scss_1.default.button,
209
- icon: (0, jsx_runtime_1.jsx)(icons_1.MinusSVG, {}),
210
- onClick: handleMinusButtonClick,
211
- onKeyDown: handleMinusButtonKeyDown,
212
- disabled: isMinusButtonDisabled,
213
- "data-test-id": 'field-stepper__minus-button'
214
- }),
215
- postfix: (0, jsx_runtime_1.jsx)(button_1.ButtonFunction, {
216
- tabIndex: -1,
217
- size: 'xs',
218
- className: styles_module_scss_1.default.button,
219
- icon: (0, jsx_runtime_1.jsx)(icons_1.PlusSVG, {}),
220
- onClick: handlePlusButtonClick,
221
- onKeyDown: handlePlusButtonKeyDown,
222
- disabled: isPlusButtonDisabled,
223
- "data-test-id": 'field-stepper__plus-button'
202
+ prefix: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, {
203
+ children: [(0, jsx_runtime_1.jsx)(button_1.ButtonFunction, {
204
+ tabIndex: -1,
205
+ ref: minusButtonRef,
206
+ size: 'xs',
207
+ className: styles_module_scss_1.default.button,
208
+ icon: (0, jsx_runtime_1.jsx)(icons_1.MinusSVG, {}),
209
+ onClick: handleMinusButtonClick,
210
+ onKeyDown: handleMinusButtonKeyDown,
211
+ disabled: isMinusButtonDisabled,
212
+ "data-test-id": 'field-stepper__minus-button'
213
+ }), prefixSettings.show && prefixSettings.render({
214
+ key: prefixSettings.id
215
+ })]
224
216
  }),
225
- children: (0, jsx_runtime_1.jsxs)("div", {
226
- className: styles_module_scss_1.default.wrap,
227
- children: [(0, jsx_runtime_1.jsx)("div", {
228
- children: prefixSettings.show && prefixSettings.render({
229
- key: prefixSettings.id
230
- })
231
- }), (0, jsx_runtime_1.jsx)("div", {
232
- style: {
233
- width: String(value).length * SymbolWidth[size],
234
- maxWidth: '100%',
235
- minWidth: SymbolWidth[size] * 2
236
- },
237
- children: (0, jsx_runtime_1.jsx)(input_private_1.InputPrivate, {
238
- ref: (0, merge_refs_1.default)(ref, inputRef),
239
- className: styles_module_scss_1.default.stepper,
240
- "data-size": size,
241
- value: String(value),
242
- tabIndex: 0,
243
- onKeyDown: handleInputKeyDown,
244
- onChange: handleInputChange,
245
- onBlur: handleInputBlur,
246
- onFocus: handleInputFocus,
247
- disabled: disabled,
248
- readonly: readonly,
249
- type: 'number',
250
- id: id,
251
- step: step,
252
- name: name,
253
- min: min,
254
- max: max,
255
- "data-test-id": 'field-stepper__input'
256
- })
257
- }), (0, jsx_runtime_1.jsx)("div", {
258
- children: postfixSettings.show && postfixSettings.render({
259
- key: postfixSettings.id
260
- })
217
+ postfix: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, {
218
+ children: [postfixSettings.show && postfixSettings.render({
219
+ key: postfixSettings.id
220
+ }), (0, jsx_runtime_1.jsx)(button_1.ButtonFunction, {
221
+ ref: plusButtonRef,
222
+ tabIndex: -1,
223
+ size: 'xs',
224
+ className: styles_module_scss_1.default.button,
225
+ icon: (0, jsx_runtime_1.jsx)(icons_1.PlusSVG, {}),
226
+ onClick: handlePlusButtonClick,
227
+ onKeyDown: handlePlusButtonKeyDown,
228
+ disabled: isPlusButtonDisabled,
229
+ "data-test-id": 'field-stepper__plus-button'
261
230
  })]
231
+ }),
232
+ children: (0, jsx_runtime_1.jsx)(input_private_1.InputPrivate, {
233
+ ref: (0, merge_refs_1.default)(ref, inputRef),
234
+ className: styles_module_scss_1.default.stepper,
235
+ "data-size": size,
236
+ value: String(value),
237
+ tabIndex: 0,
238
+ onKeyDown: handleInputKeyDown,
239
+ onChange: handleInputChange,
240
+ onBlur: handleInputBlur,
241
+ onFocus: handleInputFocus,
242
+ disabled: disabled,
243
+ readonly: readonly,
244
+ type: 'number',
245
+ id: id,
246
+ name: name,
247
+ min: min,
248
+ max: max,
249
+ "data-test-id": 'field-stepper__input'
262
250
  })
263
251
  })
264
252
  })
@@ -7,16 +7,4 @@
7
7
  }
8
8
  .button[data-disabled] *{
9
9
  cursor:not-allowed;
10
- }
11
-
12
- .trigger{
13
- min-width:auto;
14
- }
15
-
16
- .wrap{
17
- overflow:hidden;
18
- display:flex;
19
- gap:4px;
20
- justify-content:center;
21
- max-width:100%;
22
10
  }
@@ -8,6 +8,8 @@ type WrapperProps = Pick<FieldDecoratorProps, 'className' | 'label' | 'labelTool
8
8
  type FieldTextOwnProps = {
9
9
  /** Отображение кнопки Копировать для поля (актуально только для `readonly = true`) */
10
10
  showCopyButton?: boolean;
11
+ /** Колбек клика по кнопке Копировать для поля */
12
+ onCopyButtonClick?(): void;
11
13
  /**
12
14
  * Отображение кнопки очистки поля
13
15
  * @default true
@@ -43,6 +43,7 @@ exports.FieldText = (0, react_1.forwardRef)((_a, ref) => {
43
43
  onChange: onChangeProp,
44
44
  onFocus,
45
45
  onBlur,
46
+ onCopyButtonClick,
46
47
  className,
47
48
  label,
48
49
  labelTooltip,
@@ -60,7 +61,7 @@ exports.FieldText = (0, react_1.forwardRef)((_a, ref) => {
60
61
  postfix,
61
62
  button: buttonProp
62
63
  } = _a,
63
- 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"]);
64
+ rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "disabled", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "onChange", "onFocus", "onBlur", "onCopyButtonClick", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "error", "autoComplete", "prefixIcon", "prefix", "postfix", "button"]);
64
65
  const [value = '', onChange] = (0, hooks_1.useValueControl)({
65
66
  value: valueProp,
66
67
  defaultValue: '',
@@ -110,7 +111,8 @@ exports.FieldText = (0, react_1.forwardRef)((_a, ref) => {
110
111
  size,
111
112
  valueToCopy: value,
112
113
  prefix: typeof prefix === 'string' ? prefix : undefined,
113
- postfix: typeof postfix === 'string' ? postfix : undefined
114
+ postfix: typeof postfix === 'string' ? postfix : undefined,
115
+ onCopyButtonClick
114
116
  });
115
117
  const [isButtonFocused, setIsButtonFocused] = (0, react_1.useState)(false);
116
118
  const onButtonFocus = (0, react_1.useCallback)(() => setIsButtonFocused(true), []);
@@ -15,6 +15,8 @@ type FieldTextAreaOwnProps = {
15
15
  onChange?(value: string, e?: ChangeEvent<HTMLTextAreaElement>): void;
16
16
  /** Отображение кнопки Копировать для поля (актуально только для `readonly = true`) */
17
17
  showCopyButton?: boolean;
18
+ /** Колбек клика по кнопке Копировать для поля */
19
+ onCopyButtonClick?(): void;
18
20
  /**
19
21
  * Отображение кнопки очистки поля
20
22
  * @default true
@@ -57,9 +57,10 @@ exports.FieldTextArea = (0, react_1.forwardRef)((_a, ref) => {
57
57
  hint,
58
58
  error,
59
59
  size = input_private_1.SIZE.S,
60
- validationState = constants_1.VALIDATION_STATE.Default
60
+ validationState = constants_1.VALIDATION_STATE.Default,
61
+ onCopyButtonClick
61
62
  } = _a,
62
- rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "minRows", "maxRows", "disabled", "resizable", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "showHintIcon", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "error", "size", "validationState"]);
63
+ rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "minRows", "maxRows", "disabled", "resizable", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "showHintIcon", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "error", "size", "validationState", "onCopyButtonClick"]);
63
64
  const localRef = (0, react_1.useRef)(null);
64
65
  const clearButtonRef = (0, react_1.useRef)(null);
65
66
  const copyButtonRef = (0, react_1.useRef)(null);
@@ -92,7 +93,8 @@ exports.FieldTextArea = (0, react_1.forwardRef)((_a, ref) => {
92
93
  copyButtonRef,
93
94
  showCopyButton,
94
95
  size,
95
- valueToCopy: value
96
+ valueToCopy: value,
97
+ onCopyButtonClick
96
98
  });
97
99
  const {
98
100
  postfixButtons,
@@ -15,6 +15,8 @@ type FieldTimeOwnProps = {
15
15
  onChange?: TimePickerProps['onChangeValue'];
16
16
  /** Отображение кнопки копирования */
17
17
  showCopyButton?: boolean;
18
+ /** Колбек клика по кнопке Копировать для поля */
19
+ onCopyButtonClick?(): void;
18
20
  /** Показывать ли секунды */
19
21
  showSeconds?: boolean;
20
22
  /**
@@ -76,9 +76,10 @@ exports.FieldTime = (0, react_1.forwardRef)((_a, ref) => {
76
76
  showSeconds = true,
77
77
  size = input_private_1.SIZE.S,
78
78
  validationState = constants_1.VALIDATION_STATE.Default,
79
- error
79
+ error,
80
+ onCopyButtonClick
80
81
  } = _a,
81
- rest = __rest(_a, ["id", "name", "value", "disabled", "readonly", "showCopyButton", "showClearButton", "open", "onOpenChange", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "showSeconds", "size", "validationState", "error"]);
82
+ rest = __rest(_a, ["id", "name", "value", "disabled", "readonly", "showCopyButton", "showClearButton", "open", "onOpenChange", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "showSeconds", "size", "validationState", "error", "onCopyButtonClick"]);
82
83
  const [isOpen, setIsOpen] = (0, uncontrollable_1.useUncontrolledProp)(open, false, onOpenChange);
83
84
  const localRef = (0, react_1.useRef)(null);
84
85
  const clearButtonRef = (0, react_1.useRef)(null);
@@ -130,7 +131,8 @@ exports.FieldTime = (0, react_1.forwardRef)((_a, ref) => {
130
131
  copyButtonRef,
131
132
  showCopyButton,
132
133
  size,
133
- valueToCopy
134
+ valueToCopy,
135
+ onCopyButtonClick
134
136
  });
135
137
  const calendarIcon = (0, react_1.useMemo)(() => ({
136
138
  active: false,
@@ -7,9 +7,10 @@ type UseCopyButtonProps = {
7
7
  valueToCopy: string;
8
8
  size: Size;
9
9
  onValueRequest?(): AsyncValueRequest;
10
+ onCopyButtonClick?(): void;
10
11
  disabled?: boolean;
11
12
  prefix?: string;
12
13
  postfix?: string;
13
14
  };
14
- export declare function useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy, onValueRequest, disabled, prefix, postfix, }: UseCopyButtonProps): ButtonProps;
15
+ export declare function useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy, onValueRequest, onCopyButtonClick, disabled, prefix, postfix, }: UseCopyButtonProps): ButtonProps;
15
16
  export {};