@snack-uikit/fields 0.9.2 → 0.10.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 (61) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +32 -32
  3. package/dist/components/FieldDate/FieldDate.d.ts +2 -8
  4. package/dist/components/FieldDate/FieldDate.js +11 -16
  5. package/dist/components/FieldDecorator/FieldDecorator.d.ts +0 -6
  6. package/dist/components/FieldDecorator/FieldDecorator.js +4 -6
  7. package/dist/components/FieldDecorator/Footer.d.ts +1 -1
  8. package/dist/components/FieldDecorator/Footer.js +6 -6
  9. package/dist/components/FieldDecorator/Header.d.ts +1 -1
  10. package/dist/components/FieldDecorator/Header.js +1 -1
  11. package/dist/components/FieldSecure/FieldSecure.d.ts +2 -8
  12. package/dist/components/FieldSecure/FieldSecure.js +5 -10
  13. package/dist/components/FieldSelect/FieldSelect.d.ts +5 -12
  14. package/dist/components/FieldSelect/FieldSelect.js +5 -13
  15. package/dist/components/FieldSelect/FieldSelectBase.d.ts +5 -4
  16. package/dist/components/FieldSelect/FieldSelectBase.js +6 -6
  17. package/dist/components/FieldSelect/FieldSelectMulti.d.ts +2 -2
  18. package/dist/components/FieldSelect/FieldSelectMulti.js +2 -3
  19. package/dist/components/FieldSelect/FieldSelectSingle.d.ts +2 -2
  20. package/dist/components/FieldSelect/FieldSelectSingle.js +2 -3
  21. package/dist/components/FieldSelect/constants.d.ts +4 -0
  22. package/dist/components/FieldSelect/constants.js +4 -0
  23. package/dist/components/FieldSelect/helpers/getArrowIcon.d.ts +2 -2
  24. package/dist/components/FieldSelect/helpers/getArrowIcon.js +5 -2
  25. package/dist/components/FieldSelect/helpers/getDisplayedValue.d.ts +4 -3
  26. package/dist/components/FieldSelect/helpers/getDisplayedValue.js +2 -2
  27. package/dist/components/FieldSelect/types.d.ts +0 -4
  28. package/dist/components/FieldSelect/types.js +1 -5
  29. package/dist/components/FieldText/FieldText.d.ts +2 -8
  30. package/dist/components/FieldText/FieldText.js +5 -10
  31. package/dist/components/FieldTextArea/FieldTextArea.d.ts +1 -8
  32. package/dist/components/FieldTextArea/FieldTextArea.js +5 -10
  33. package/dist/constants.d.ts +10 -10
  34. package/dist/constants.js +10 -12
  35. package/dist/helperComponents/ButtonCopyValue/helpers.js +3 -3
  36. package/dist/helperComponents/ButtonHideValue/ButtonHideValue.js +2 -2
  37. package/dist/helperComponents/FieldContainerPrivate/FieldContainerPrivate.d.ts +1 -1
  38. package/dist/helperComponents/FieldContainerPrivate/FieldContainerPrivate.js +2 -2
  39. package/dist/types.d.ts +4 -0
  40. package/dist/types.js +1 -0
  41. package/package.json +9 -9
  42. package/src/components/FieldDate/FieldDate.tsx +16 -26
  43. package/src/components/FieldDecorator/FieldDecorator.tsx +5 -8
  44. package/src/components/FieldDecorator/Footer.tsx +7 -6
  45. package/src/components/FieldDecorator/Header.tsx +2 -2
  46. package/src/components/FieldSecure/FieldSecure.tsx +7 -18
  47. package/src/components/FieldSelect/FieldSelect.tsx +8 -23
  48. package/src/components/FieldSelect/FieldSelectBase.tsx +14 -13
  49. package/src/components/FieldSelect/FieldSelectMulti.tsx +3 -3
  50. package/src/components/FieldSelect/FieldSelectSingle.tsx +3 -3
  51. package/src/components/FieldSelect/constants.ts +5 -0
  52. package/src/components/FieldSelect/helpers/getArrowIcon.ts +5 -2
  53. package/src/components/FieldSelect/helpers/getDisplayedValue.ts +5 -4
  54. package/src/components/FieldSelect/types.ts +0 -5
  55. package/src/components/FieldText/FieldText.tsx +7 -18
  56. package/src/components/FieldTextArea/FieldTextArea.tsx +9 -20
  57. package/src/constants.ts +10 -10
  58. package/src/helperComponents/ButtonCopyValue/helpers.tsx +3 -3
  59. package/src/helperComponents/ButtonHideValue/ButtonHideValue.tsx +5 -5
  60. package/src/helperComponents/FieldContainerPrivate/FieldContainerPrivate.tsx +3 -2
  61. package/src/types.ts +7 -0
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.10.0 (2023-12-14)
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+
12
+ * **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275))
13
+
14
+
15
+
16
+
6
17
  ## 0.9.2 (2023-12-07)
7
18
 
8
19
  ### Only dependencies have been changed
package/README.md CHANGED
@@ -38,11 +38,11 @@ const [isOpen, setIsOpen] = useState(false);
38
38
  labelTooltip='You can choose any date'
39
39
  required={true}
40
40
  hint='You have entered wrong date'
41
- size={FieldDate.sizes.S}
42
- validationState={FieldDate.validationStates.Default}
41
+ size='s'
42
+ validationState='default'
43
43
  />
44
44
 
45
- ...
45
+ // ...
46
46
 
47
47
  const [value, setValue] = useState('1234');
48
48
  const [isHidden, setIsHidden] = useState(false);
@@ -66,12 +66,12 @@ const [isHidden, setIsHidden] = useState(false);
66
66
  labelTooltip='You can enter password here'
67
67
  required={true}
68
68
  hint='You have entered wrong password'
69
- size={FieldSecure.sizes.S}
70
- validationState={FieldSecure.validationStates.Error}
69
+ size='s'
70
+ validationState='error'
71
71
  prefixIcon={<PlaceholderSVG/>}
72
72
  />
73
73
 
74
- ...
74
+ // ...
75
75
 
76
76
  const [value, setValue] = useState('abc');
77
77
 
@@ -92,12 +92,12 @@ const [value, setValue] = useState('abc');
92
92
  labelTooltip='You can input any text'
93
93
  required={true}
94
94
  hint='You have entered wrong answer'
95
- size={FieldText.sizes.S}
96
- validationState={FieldText.validationStates.Error}
95
+ size='s'
96
+ validationState='error'
97
97
  prefixIcon={<PlaceholderSVG/>}
98
98
  />
99
99
 
100
- ...
100
+ // ...
101
101
 
102
102
  const [value, setValue] = useState('abc');
103
103
 
@@ -120,17 +120,17 @@ const [value, setValue] = useState('abc');
120
120
  labelTooltip='You can input any text'
121
121
  required={true}
122
122
  hint='You have entered wrong answer'
123
- size={FieldTextArea.sizes.S}
124
- validationState={FieldTextArea.validationStates.Error}
123
+ size='s'
124
+ validationState='error'
125
125
  />
126
126
 
127
- ...
127
+ // ...
128
128
 
129
129
  const [value, setValue] = useState('1234');
130
130
  const [isOpen, setIsOpen] = useState(false);
131
131
 
132
132
  <FieldSelect
133
- mode={FieldSelect.selectionModes.Single}
133
+ mode='single'
134
134
  value={value}
135
135
  onChange={setValue}
136
136
  options={[{value: 'op1', label: 'Option 1'}, {value: 'op2', label: 'Option 2'}]}
@@ -150,8 +150,8 @@ const [isOpen, setIsOpen] = useState(false);
150
150
  labelTooltip='You can choose any option'
151
151
  required={true}
152
152
  hint='You have chosen wrong item'
153
- size={FieldSelect.sizes.S}
154
- validationState={FieldSelect.validationStates.Error}
153
+ size='s'
154
+ validationState='error'
155
155
  prefixIcon={<PlaceholderSVG/>}
156
156
  />
157
157
  ```
@@ -170,11 +170,11 @@ const [isOpen, setIsOpen] = useState(false);
170
170
  | labelTooltip | `string` | - | Всплывающая подсказка лейбла |
171
171
  | labelFor | `string` | - | Аттрибут for |
172
172
  | required | `boolean` | - | Является ли поле обязательным |
173
- | size | enum Size: `"s"`, `"m"`, `"l"` | Size.S | Размер |
174
- | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | Tooltip.placements.Top | Расположение подсказки лейбла |
173
+ | size | enum Size: `"s"`, `"m"`, `"l"` | SIZE.S | Размер |
174
+ | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | top | Расположение подсказки лейбла |
175
175
  | length | `{ current: number; max?: number; }` | - | Допустимая длинна текста |
176
176
  | hint | `string` | - | Подсказка внизу |
177
- | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | ValidationState.Default | Состояние валидации |
177
+ | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | default | Состояние валидации |
178
178
  | showHintIcon | `boolean` | - | Отображать иконку подсказки |
179
179
  ## FieldText
180
180
  ### Props
@@ -197,10 +197,10 @@ const [isOpen, setIsOpen] = useState(false);
197
197
  | label | `string` | - | Лейбл |
198
198
  | labelTooltip | `string` | - | Всплывающая подсказка лейбла |
199
199
  | required | `boolean` | - | Является ли поле обязательным |
200
- | size | enum Size: `"s"`, `"m"`, `"l"` | Size.S | Размер |
201
- | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | Tooltip.placements.Top | Расположение подсказки лейбла |
200
+ | size | enum Size: `"s"`, `"m"`, `"l"` | SIZE.S | Размер |
201
+ | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | top | Расположение подсказки лейбла |
202
202
  | hint | `string` | - | Подсказка внизу |
203
- | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | ValidationState.Default | Состояние валидации |
203
+ | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | default | Состояние валидации |
204
204
  | showHintIcon | `boolean` | - | Отображать иконку подсказки |
205
205
  | ref | `Ref<HTMLInputElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom |
206
206
  | key | `Key` | - | |
@@ -226,10 +226,10 @@ const [isOpen, setIsOpen] = useState(false);
226
226
  | label | `string` | - | Лейбл |
227
227
  | labelTooltip | `string` | - | Всплывающая подсказка лейбла |
228
228
  | required | `boolean` | - | Является ли поле обязательным |
229
- | size | enum Size: `"s"`, `"m"`, `"l"` | Size.S | Размер |
230
- | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | Tooltip.placements.Top | Расположение подсказки лейбла |
229
+ | size | enum Size: `"s"`, `"m"`, `"l"` | SIZE.S | Размер |
230
+ | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | top | Расположение подсказки лейбла |
231
231
  | hint | `string` | - | Подсказка внизу |
232
- | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | ValidationState.Default | Состояние валидации |
232
+ | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | default | Состояние валидации |
233
233
  | showHintIcon | `boolean` | - | Отображать иконку подсказки |
234
234
  | ref | `Ref<HTMLTextAreaElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom |
235
235
  | key | `Key` | - | |
@@ -256,10 +256,10 @@ const [isOpen, setIsOpen] = useState(false);
256
256
  | label | `string` | - | Лейбл |
257
257
  | labelTooltip | `string` | - | Всплывающая подсказка лейбла |
258
258
  | required | `boolean` | - | Является ли поле обязательным |
259
- | size | enum Size: `"s"`, `"m"`, `"l"` | Size.S | Размер |
260
- | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | Tooltip.placements.Top | Расположение подсказки лейбла |
259
+ | size | enum Size: `"s"`, `"m"`, `"l"` | SIZE.S | Размер |
260
+ | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | top | Расположение подсказки лейбла |
261
261
  | hint | `string` | - | Подсказка внизу |
262
- | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | ValidationState.Default | Состояние валидации |
262
+ | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | default | Состояние валидации |
263
263
  | showHintIcon | `boolean` | - | Отображать иконку подсказки |
264
264
  | ref | `Ref<HTMLInputElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom |
265
265
  | key | `Key` | - | |
@@ -283,10 +283,10 @@ const [isOpen, setIsOpen] = useState(false);
283
283
  | label | `string` | - | Лейбл |
284
284
  | labelTooltip | `string` | - | Всплывающая подсказка лейбла |
285
285
  | required | `boolean` | - | Является ли поле обязательным |
286
- | size | enum Size: `"s"`, `"m"`, `"l"` | Size.S | Размер |
287
- | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | Tooltip.placements.Top | Расположение подсказки лейбла |
286
+ | size | enum Size: `"s"`, `"m"`, `"l"` | SIZE.S | Размер |
287
+ | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | top | Расположение подсказки лейбла |
288
288
  | hint | `string` | - | Подсказка внизу |
289
- | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | ValidationState.Default | Состояние валидации |
289
+ | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | default | Состояние валидации |
290
290
  | showHintIcon | `boolean` | - | Отображать иконку подсказки |
291
291
  | ref | `Ref<HTMLInputElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom |
292
292
  | key | `Key` | - | |
@@ -295,7 +295,7 @@ const [isOpen, setIsOpen] = useState(false);
295
295
  | name | type | default value | description |
296
296
  |------|------|---------------|-------------|
297
297
  | options* | `Option[]` | - | Массив опций выпадающего списка |
298
- | selectionMode | enum SelectionMode: `"single"`, `"multi"` | SelectionMode.Single | |
298
+ | selectionMode | "single" \| "multi" | single | |
299
299
  | open | `boolean` | - | Открыт ли выпадающий список |
300
300
  | onOpenChange | `(value: boolean) => void` | - | Колбек открытия выпадающего списка |
301
301
  | searchable | `boolean` | - | Можно ли искать опции внутри списка |
@@ -315,7 +315,7 @@ const [isOpen, setIsOpen] = useState(false);
315
315
  | labelTooltip | `string` | - | Всплывающая подсказка лейбла |
316
316
  | required | `boolean` | - | Является ли поле обязательным |
317
317
  | size | enum Size: `"s"`, `"m"`, `"l"` | - | Размер |
318
- | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | Tooltip.placements.Top | Расположение подсказки лейбла |
318
+ | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | top | Расположение подсказки лейбла |
319
319
  | hint | `string` | - | Подсказка внизу |
320
320
  | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | - | Состояние валидации |
321
321
  | showHintIcon | `boolean` | - | Отображать иконку подсказки |
@@ -1,8 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { InputPrivateProps, Size } from '@snack-uikit/input-private';
3
- import { Tooltip } from '@snack-uikit/tooltip';
2
+ import { InputPrivateProps } from '@snack-uikit/input-private';
4
3
  import { WithSupportProps } from '@snack-uikit/utils';
5
- import { ValidationState } from '../../constants';
6
4
  import { FieldDecoratorProps } from '../FieldDecorator';
7
5
  type InputProps = Pick<InputPrivateProps, 'id' | 'name' | 'value' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur'>;
8
6
  type WrapperProps = Pick<FieldDecoratorProps, 'className' | 'label' | 'labelTooltip' | 'required' | 'hint' | 'showHintIcon' | 'size' | 'validationState' | 'labelTooltipPlacement'>;
@@ -21,9 +19,5 @@ type FieldDateOwnProps = {
21
19
  export type FieldDateProps = WithSupportProps<FieldDateOwnProps & InputProps & WrapperProps>;
22
20
  export declare const FieldDate: import("react").ForwardRefExoticComponent<{
23
21
  'data-test-id'?: string | undefined;
24
- } & import("react").AriaAttributes & FieldDateOwnProps & InputProps & WrapperProps & import("react").RefAttributes<HTMLInputElement>> & {
25
- sizes: typeof Size;
26
- validationStates: typeof ValidationState;
27
- labelTooltipPlacements: typeof Tooltip.placements;
28
- };
22
+ } & import("react").AriaAttributes & FieldDateOwnProps & InputProps & WrapperProps & import("react").RefAttributes<HTMLInputElement>>;
29
23
  export {};
@@ -16,10 +16,9 @@ import { useUncontrolledProp } from 'uncontrollable';
16
16
  import { Calendar } from '@snack-uikit/calendar';
17
17
  import { Dropdown } from '@snack-uikit/droplist';
18
18
  import { CalendarSVG } from '@snack-uikit/icons';
19
- import { IconSize, InputPrivate, runAfterRerender, Size, useButtonNavigation, useClearButton, } from '@snack-uikit/input-private';
20
- import { Tooltip } from '@snack-uikit/tooltip';
19
+ import { ICON_SIZE, InputPrivate, runAfterRerender, SIZE, useButtonNavigation, useClearButton, } from '@snack-uikit/input-private';
21
20
  import { extractSupportProps } from '@snack-uikit/utils';
22
- import { ContainerVariant, ValidationState } from '../../constants';
21
+ import { CONTAINER_VARIANT, VALIDATION_STATE } from '../../constants';
23
22
  import { FieldContainerPrivate } from '../../helperComponents';
24
23
  import { useCopyButton } from '../../hooks';
25
24
  import { FieldDecorator } from '../FieldDecorator';
@@ -30,18 +29,18 @@ import { useHandlers } from './hooks/useHandlers';
30
29
  import styles from './styles.module.css';
31
30
  import { parseDate } from './utils';
32
31
  const CALENDAR_SIZE_MAP = {
33
- [Size.S]: Calendar.sizes.S,
34
- [Size.M]: Calendar.sizes.M,
35
- [Size.L]: Calendar.sizes.M,
32
+ [SIZE.S]: 's',
33
+ [SIZE.M]: 'm',
34
+ [SIZE.L]: 'm',
36
35
  };
37
- const ForwardedFieldDate = forwardRef((_a, ref) => {
38
- var { id, name, value: valueProp, disabled = false, readonly = false, showCopyButton: showCopyButtonProp = true, open, onOpenChange, onChange, onFocus, onBlur: onBlurProp, className, label, labelTooltip, labelTooltipPlacement, required = false, hint, showHintIcon, size = Size.S, validationState = ValidationState.Default, locale = DEFAULT_LOCALE } = _a, rest = __rest(_a, ["id", "name", "value", "disabled", "readonly", "showCopyButton", "open", "onOpenChange", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "hint", "showHintIcon", "size", "validationState", "locale"]);
36
+ export const FieldDate = forwardRef((_a, ref) => {
37
+ var { id, name, value: valueProp, disabled = false, readonly = false, showCopyButton: showCopyButtonProp = true, open, onOpenChange, onChange, onFocus, onBlur: onBlurProp, className, label, labelTooltip, labelTooltipPlacement, required = false, hint, showHintIcon, size = SIZE.S, validationState = VALIDATION_STATE.Default, locale = DEFAULT_LOCALE } = _a, rest = __rest(_a, ["id", "name", "value", "disabled", "readonly", "showCopyButton", "open", "onOpenChange", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "hint", "showHintIcon", "size", "validationState", "locale"]);
39
38
  const [isOpen, setIsOpen] = useUncontrolledProp(open, false, onOpenChange);
40
39
  const [pickerAutofocus, setPickerAutofocus] = useState(false);
41
40
  const localRef = useRef(null);
42
41
  const clearButtonRef = useRef(null);
43
42
  const copyButtonRef = useRef(null);
44
- const calendarIconSize = size === Size.S ? IconSize.Xs : IconSize.S;
43
+ const calendarIconSize = size === SIZE.S ? ICON_SIZE.Xs : ICON_SIZE.S;
45
44
  const showDropList = isOpen && !readonly && !disabled;
46
45
  const showAdditionalButton = Boolean(valueProp && !disabled);
47
46
  const showClearButton = showAdditionalButton && !readonly;
@@ -134,19 +133,15 @@ const ForwardedFieldDate = forwardRef((_a, ref) => {
134
133
  e.stopPropagation();
135
134
  }
136
135
  }, [dateInputClickHandler, isOpen]);
137
- return (_jsx(FieldDecorator, Object.assign({ className: className, label: label, labelTooltip: labelTooltip, labelTooltipPlacement: labelTooltipPlacement, labelFor: id, required: required, hint: hint, disabled: disabled, readonly: readonly, showHintIcon: showHintIcon, size: size, validationState: validationState }, extractSupportProps(rest), { children: _jsx(Dropdown, Object.assign({ trigger: Dropdown.triggers.Click, triggerClassName: styles.triggerClassName, widthStrategy: Dropdown.widthStrategies.Gte }, (readonly || disabled
136
+ return (_jsx(FieldDecorator, Object.assign({ className: className, label: label, labelTooltip: labelTooltip, labelTooltipPlacement: labelTooltipPlacement, labelFor: id, required: required, hint: hint, disabled: disabled, readonly: readonly, showHintIcon: showHintIcon, size: size, validationState: validationState }, extractSupportProps(rest), { children: _jsx(Dropdown, Object.assign({ trigger: 'click', triggerClassName: styles.triggerClassName, widthStrategy: 'gte' }, (readonly || disabled
138
137
  ? { open: false }
139
138
  : {
140
139
  open: showDropList,
141
140
  onOpenChange: setIsOpen,
142
- }), { content: _jsx("div", Object.assign({ className: styles.calendarWrapper, "data-size": size }, { children: _jsx(Calendar, { mode: Calendar.modes.Date, size: CALENDAR_SIZE_MAP[size], value: valueProp ? parseDate(valueProp) : undefined, onChangeValue: handleSelectDate, navigationStartRef: element => {
141
+ }), { content: _jsx("div", Object.assign({ className: styles.calendarWrapper, "data-size": size }, { children: _jsx(Calendar, { mode: 'date', size: CALENDAR_SIZE_MAP[size], value: valueProp ? parseDate(valueProp) : undefined, onChangeValue: handleSelectDate, navigationStartRef: element => {
143
142
  if (pickerAutofocus) {
144
143
  element === null || element === void 0 ? void 0 : element.focus();
145
144
  setPickerAutofocus(false);
146
145
  }
147
- }, onFocusLeave: handleCalendarFocusLeave, locale: locale, "data-test-id": 'field-date__calendar' }) })) }, { children: _jsx(FieldContainerPrivate, Object.assign({ className: styles.container, size: size, validationState: validationState, disabled: disabled, readonly: readonly, variant: ContainerVariant.SingleLine, focused: showDropList, inputRef: localRef, postfix: _jsxs(_Fragment, { children: [buttons, _jsx(CalendarSVG, { size: calendarIconSize, className: styles.calendarIcon, "data-size": size })] }) }, { children: _jsx(InputPrivate, { ref: mergeRefs(ref, localRef), "data-size": size, value: value || '', placeholder: mask, onChange: handleChange, onFocus: inputHandlers.onFocus, onMouseDown: inputHandlers.onMouseDown, onBlur: onBlur, onKeyDown: handleInputKeyDown, onClick: onClick, disabled: disabled, readonly: readonly, tabIndex: inputTabIndex, type: InputPrivate.types.Text, id: id, name: name, "data-test-id": 'field-date__input' }) })) })) })));
146
+ }, onFocusLeave: handleCalendarFocusLeave, locale: locale, "data-test-id": 'field-date__calendar' }) })) }, { children: _jsx(FieldContainerPrivate, Object.assign({ className: styles.container, size: size, validationState: validationState, disabled: disabled, readonly: readonly, variant: CONTAINER_VARIANT.SingleLine, focused: showDropList, inputRef: localRef, postfix: _jsxs(_Fragment, { children: [buttons, _jsx(CalendarSVG, { size: calendarIconSize, className: styles.calendarIcon, "data-size": size })] }) }, { children: _jsx(InputPrivate, { ref: mergeRefs(ref, localRef), "data-size": size, value: value || '', placeholder: mask, onChange: handleChange, onFocus: inputHandlers.onFocus, onMouseDown: inputHandlers.onMouseDown, onBlur: onBlur, onKeyDown: handleInputKeyDown, onClick: onClick, disabled: disabled, readonly: readonly, tabIndex: inputTabIndex, type: 'text', id: id, name: name, "data-test-id": 'field-date__input' }) })) })) })));
148
147
  });
149
- export const FieldDate = ForwardedFieldDate;
150
- FieldDate.sizes = Size;
151
- FieldDate.validationStates = ValidationState;
152
- FieldDate.labelTooltipPlacements = Tooltip.placements;
@@ -1,7 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { Size } from '@snack-uikit/input-private';
3
2
  import { WithSupportProps } from '@snack-uikit/utils';
4
- import { ValidationState } from '../../constants';
5
3
  import { FooterProps } from './Footer';
6
4
  import { HeaderProps } from './Header';
7
5
  export type FieldDecoratorProps = WithSupportProps<{
@@ -14,7 +12,3 @@ export type FieldDecoratorProps = WithSupportProps<{
14
12
  readonly?: boolean;
15
13
  } & HeaderProps & FooterProps>;
16
14
  export declare function FieldDecorator({ children, className, label, labelTooltip, required, labelFor, length, hint, disabled, readonly, showHintIcon, labelTooltipPlacement, size, validationState, ...rest }: FieldDecoratorProps): import("react/jsx-runtime").JSX.Element;
17
- export declare namespace FieldDecorator {
18
- var validationStates: typeof ValidationState;
19
- var sizes: typeof Size;
20
- }
@@ -11,16 +11,14 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import cn from 'classnames';
14
- import { Size } from '@snack-uikit/input-private';
14
+ import { SIZE } from '@snack-uikit/input-private';
15
15
  import { extractSupportProps } from '@snack-uikit/utils';
16
- import { ValidationState } from '../../constants';
16
+ import { VALIDATION_STATE } from '../../constants';
17
17
  import { Footer } from './Footer';
18
18
  import { Header } from './Header';
19
19
  import styles from './styles.module.css';
20
20
  export function FieldDecorator(_a) {
21
- var { children, className, label, labelTooltip, required, labelFor, length, hint, disabled, readonly, showHintIcon, labelTooltipPlacement, size = Size.S, validationState = ValidationState.Default } = _a, rest = __rest(_a, ["children", "className", "label", "labelTooltip", "required", "labelFor", "length", "hint", "disabled", "readonly", "showHintIcon", "labelTooltipPlacement", "size", "validationState"]);
21
+ var { children, className, label, labelTooltip, required, labelFor, length, hint, disabled, readonly, showHintIcon, labelTooltipPlacement, size = SIZE.S, validationState = VALIDATION_STATE.Default } = _a, rest = __rest(_a, ["children", "className", "label", "labelTooltip", "required", "labelFor", "length", "hint", "disabled", "readonly", "showHintIcon", "labelTooltipPlacement", "size", "validationState"]);
22
22
  const isFieldActive = !disabled && !readonly;
23
- return (_jsxs("div", Object.assign({ className: cn(styles.decorator, className) }, extractSupportProps(rest), { "data-size": size }, { children: [label && (_jsx(Header, { labelTooltipPlacement: labelTooltipPlacement, required: required, label: label, labelTooltip: labelTooltip, labelFor: labelFor, size: size })), children, _jsx(Footer, { length: isFieldActive ? length : undefined, hint: hint, showHintIcon: showHintIcon, size: size, validationState: isFieldActive ? validationState : ValidationState.Default })] })));
23
+ return (_jsxs("div", Object.assign({ className: cn(styles.decorator, className) }, extractSupportProps(rest), { "data-size": size }, { children: [label && (_jsx(Header, { labelTooltipPlacement: labelTooltipPlacement, required: required, label: label, labelTooltip: labelTooltip, labelFor: labelFor, size: size })), children, _jsx(Footer, { length: isFieldActive ? length : undefined, hint: hint, showHintIcon: showHintIcon, size: size, validationState: isFieldActive ? validationState : VALIDATION_STATE.Default })] })));
24
24
  }
25
- FieldDecorator.validationStates = ValidationState;
26
- FieldDecorator.sizes = Size;
@@ -1,5 +1,5 @@
1
1
  import { Size } from '@snack-uikit/input-private';
2
- import { ValidationState } from '../../constants';
2
+ import { ValidationState } from '../../types';
3
3
  export type FooterProps = {
4
4
  /** Допустимая длинна текста */
5
5
  length?: {
@@ -1,26 +1,26 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useMemo } from 'react';
3
3
  import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG, InfoFilledSVG } from '@snack-uikit/icons';
4
- import { ValidationState } from '../../constants';
4
+ import { VALIDATION_STATE } from '../../constants';
5
5
  import styles from './styles.module.css';
6
6
  function getValidationIcon(props) {
7
7
  var _a;
8
8
  let Component;
9
9
  let showIcon;
10
10
  switch (props.validationState) {
11
- case ValidationState.Success:
11
+ case VALIDATION_STATE.Success:
12
12
  Component = CheckFilledSVG;
13
13
  showIcon = true;
14
14
  break;
15
- case ValidationState.Error:
15
+ case VALIDATION_STATE.Error:
16
16
  Component = CrossFilledSVG;
17
17
  showIcon = true;
18
18
  break;
19
- case ValidationState.Warning:
19
+ case VALIDATION_STATE.Warning:
20
20
  Component = AlarmFilledSVG;
21
21
  showIcon = true;
22
22
  break;
23
- case ValidationState.Default:
23
+ case VALIDATION_STATE.Default:
24
24
  default:
25
25
  Component = InfoFilledSVG;
26
26
  showIcon = false;
@@ -28,7 +28,7 @@ function getValidationIcon(props) {
28
28
  }
29
29
  return ((_a = props.showHintIcon) !== null && _a !== void 0 ? _a : showIcon) ? (_jsx(Component, { size: 16, "data-validation": props.validationState, className: styles.hintIcon })) : null;
30
30
  }
31
- export function Footer({ length, hint, size, validationState = ValidationState.Default, showHintIcon }) {
31
+ export function Footer({ length, hint, size, validationState = VALIDATION_STATE.Default, showHintIcon }) {
32
32
  const isReverseContainer = !hint && length;
33
33
  const limitExceeded = length && length.max && length.current > length.max;
34
34
  const icon = useMemo(() => getValidationIcon({ validationState, showHintIcon }), [showHintIcon, validationState]);
@@ -13,7 +13,7 @@ export type HeaderProps = {
13
13
  size?: Size;
14
14
  /**
15
15
  * Расположение подсказки лейбла
16
- * @default Tooltip.placements.Top
16
+ * @default top
17
17
  */
18
18
  labelTooltipPlacement?: TooltipProps['placement'];
19
19
  };
@@ -3,6 +3,6 @@ import { QuestionSVG } from '@snack-uikit/icons';
3
3
  import { Tooltip } from '@snack-uikit/tooltip';
4
4
  import { TruncateString } from '@snack-uikit/truncate-string';
5
5
  import styles from './styles.module.css';
6
- export function Header({ label = '', labelTooltip, labelFor, size, required = false, labelTooltipPlacement = Tooltip.placements.Top, }) {
6
+ export function Header({ label = '', labelTooltip, labelFor, size, required = false, labelTooltipPlacement = 'top', }) {
7
7
  return (_jsx("span", Object.assign({ className: styles.header, "data-size": size }, { children: label && (_jsxs("span", Object.assign({ className: styles.labelLayout }, { children: [_jsx("label", Object.assign({ className: styles.label, htmlFor: labelFor, "data-test-id": 'field-decorator__label' }, { children: _jsx(TruncateString, { text: label }) })), required && _jsx("span", Object.assign({ "data-test-id": 'field-decorator__required-sign' }, { children: "*" })), labelTooltip && (_jsx(Tooltip, Object.assign({ tip: labelTooltip, placement: labelTooltipPlacement, "data-test-id": 'field-decorator__label-tooltip' }, { children: _jsx(QuestionSVG, { size: 16, className: styles.icon, "data-test-id": 'field-decorator__label-tooltip-trigger' }) })))] }))) })));
8
8
  }
@@ -1,8 +1,6 @@
1
1
  import { ReactElement } from 'react';
2
- import { InputPrivateProps, Size } from '@snack-uikit/input-private';
3
- import { Tooltip } from '@snack-uikit/tooltip';
2
+ import { InputPrivateProps } from '@snack-uikit/input-private';
4
3
  import { WithSupportProps } from '@snack-uikit/utils';
5
- import { ValidationState } from '../../constants';
6
4
  import { FieldDecoratorProps } from '../FieldDecorator';
7
5
  type InputProps = Pick<Partial<InputPrivateProps>, 'value' | 'onChange'> & Pick<InputPrivateProps, 'id' | 'name' | 'placeholder' | 'maxLength' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur'>;
8
6
  type WrapperProps = Pick<FieldDecoratorProps, 'className' | 'label' | 'labelTooltip' | 'required' | 'hint' | 'size' | 'validationState' | 'showHintIcon' | 'labelTooltipPlacement'>;
@@ -21,9 +19,5 @@ type FieldSecureOwnProps = {
21
19
  export type FieldSecureProps = WithSupportProps<FieldSecureOwnProps & InputProps & WrapperProps>;
22
20
  export declare const FieldSecure: import("react").ForwardRefExoticComponent<{
23
21
  'data-test-id'?: string | undefined;
24
- } & import("react").AriaAttributes & FieldSecureOwnProps & Pick<Partial<InputPrivateProps>, "value" | "onChange"> & Pick<InputPrivateProps, "disabled" | "readonly" | "name" | "placeholder" | "id" | "maxLength" | "onFocus" | "onBlur"> & WrapperProps & import("react").RefAttributes<HTMLInputElement>> & {
25
- sizes: typeof Size;
26
- validationStates: typeof ValidationState;
27
- labelTooltipPlacements: typeof Tooltip.placements;
28
- };
22
+ } & import("react").AriaAttributes & FieldSecureOwnProps & Pick<Partial<InputPrivateProps>, "value" | "onChange"> & Pick<InputPrivateProps, "disabled" | "readonly" | "name" | "placeholder" | "id" | "maxLength" | "onFocus" | "onBlur"> & WrapperProps & import("react").RefAttributes<HTMLInputElement>>;
29
23
  export {};
@@ -13,15 +13,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import mergeRefs from 'merge-refs';
14
14
  import { forwardRef, useMemo, useRef } from 'react';
15
15
  import { useUncontrolledProp } from 'uncontrollable';
16
- import { InputPrivate, moveCursorToEnd, runAfterRerender, Size, useButtonNavigation, } from '@snack-uikit/input-private';
17
- import { Tooltip } from '@snack-uikit/tooltip';
16
+ import { InputPrivate, moveCursorToEnd, runAfterRerender, SIZE, useButtonNavigation, } from '@snack-uikit/input-private';
18
17
  import { extractSupportProps } from '@snack-uikit/utils';
19
- import { ContainerVariant, ValidationState } from '../../constants';
18
+ import { CONTAINER_VARIANT, VALIDATION_STATE } from '../../constants';
20
19
  import { FieldContainerPrivate } from '../../helperComponents';
21
20
  import { useCopyButton, useHideButton } from '../../hooks';
22
21
  import { FieldDecorator } from '../FieldDecorator';
23
- const ForwardedFieldSecure = forwardRef((_a, ref) => {
24
- var { id, name, value: valueProp, placeholder, maxLength, disabled = false, readonly = false, showCopyButton: showCopyButtonProp = true, allowMoreThanMaxLength = false, hidden: hiddenProp, onHiddenChange, showHintIcon, onChange: onChangeProp, onFocus, onBlur, className, label, labelTooltip, labelTooltipPlacement, required = false, hint, size = Size.S, validationState = ValidationState.Default, prefixIcon } = _a, rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "disabled", "readonly", "showCopyButton", "allowMoreThanMaxLength", "hidden", "onHiddenChange", "showHintIcon", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "hint", "size", "validationState", "prefixIcon"]);
22
+ export const FieldSecure = forwardRef((_a, ref) => {
23
+ var { id, name, value: valueProp, placeholder, maxLength, disabled = false, readonly = false, showCopyButton: showCopyButtonProp = true, allowMoreThanMaxLength = false, hidden: hiddenProp, onHiddenChange, showHintIcon, onChange: onChangeProp, onFocus, onBlur, className, label, labelTooltip, labelTooltipPlacement, required = false, hint, size = SIZE.S, validationState = VALIDATION_STATE.Default, prefixIcon } = _a, rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "disabled", "readonly", "showCopyButton", "allowMoreThanMaxLength", "hidden", "onHiddenChange", "showHintIcon", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "hint", "size", "validationState", "prefixIcon"]);
25
24
  const localRef = useRef(null);
26
25
  const copyButtonRef = useRef(null);
27
26
  const hideButtonRef = useRef(null);
@@ -47,9 +46,5 @@ const ForwardedFieldSecure = forwardRef((_a, ref) => {
47
46
  readonly,
48
47
  submitKeys: ['Enter', 'Space', 'Tab'],
49
48
  });
50
- return (_jsx(FieldDecorator, Object.assign({ className: className, label: label, labelTooltip: labelTooltip, labelTooltipPlacement: labelTooltipPlacement, labelFor: id, required: required, length: maxLength ? { max: maxLength, current: value.length } : undefined, hint: hint, disabled: disabled, readonly: readonly, showHintIcon: showHintIcon, size: size, validationState: validationState }, extractSupportProps(rest), { children: _jsx(FieldContainerPrivate, Object.assign({ size: size, validationState: validationState, disabled: disabled, readonly: readonly, variant: ContainerVariant.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, onKeyDown: onInputKeyDown, tabIndex: inputTabIndex, placeholder: placeholder, disabled: disabled, readonly: readonly, type: hidden ? InputPrivate.types.Password : InputPrivate.types.Text, maxLength: allowMoreThanMaxLength ? undefined : maxLength || undefined, id: id, name: name, "data-test-id": 'field-secure__input' }) })) })));
49
+ return (_jsx(FieldDecorator, Object.assign({ className: className, label: label, labelTooltip: labelTooltip, labelTooltipPlacement: labelTooltipPlacement, labelFor: id, required: required, length: maxLength ? { max: maxLength, current: value.length } : undefined, hint: hint, disabled: disabled, readonly: readonly, showHintIcon: showHintIcon, size: size, validationState: validationState }, extractSupportProps(rest), { children: _jsx(FieldContainerPrivate, Object.assign({ size: size, validationState: validationState, 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, onKeyDown: onInputKeyDown, tabIndex: inputTabIndex, placeholder: placeholder, disabled: disabled, readonly: readonly, type: hidden ? 'password' : 'text', maxLength: allowMoreThanMaxLength ? undefined : maxLength || undefined, id: id, name: name, "data-test-id": 'field-secure__input' }) })) })));
51
50
  });
52
- export const FieldSecure = ForwardedFieldSecure;
53
- FieldSecure.sizes = Size;
54
- FieldSecure.validationStates = ValidationState;
55
- FieldSecure.labelTooltipPlacements = Tooltip.placements;
@@ -1,16 +1,9 @@
1
1
  /// <reference types="react" />
2
- import { Size } from '@snack-uikit/input-private';
3
- import { Tooltip } from '@snack-uikit/tooltip';
4
- import { ValidationState } from '../../constants';
5
- import { FieldSelectMultiProps, FieldSelectSingleProps, SelectionMode } from './types';
2
+ import { SELECTION_MODE } from './constants';
3
+ import { FieldSelectMultiProps, FieldSelectSingleProps } from './types';
6
4
  export type FieldSelectProps = ({
7
- selectionMode?: SelectionMode.Single;
5
+ selectionMode?: typeof SELECTION_MODE.Single;
8
6
  } & FieldSelectSingleProps) | ({
9
- selectionMode: SelectionMode.Multi;
7
+ selectionMode: typeof SELECTION_MODE.Multi;
10
8
  } & FieldSelectMultiProps);
11
- export declare const FieldSelect: import("react").ForwardRefExoticComponent<FieldSelectProps & import("react").RefAttributes<HTMLInputElement>> & {
12
- sizes: typeof Size;
13
- validationStates: typeof ValidationState;
14
- selectionModes: typeof SelectionMode;
15
- labelTooltipPlacements: typeof Tooltip.placements;
16
- };
9
+ export declare const FieldSelect: import("react").ForwardRefExoticComponent<FieldSelectProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -11,24 +11,16 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { forwardRef } from 'react';
14
- import { Size } from '@snack-uikit/input-private';
15
- import { Tooltip } from '@snack-uikit/tooltip';
16
- import { ValidationState } from '../../constants';
14
+ import { SELECTION_MODE } from './constants';
17
15
  import { FieldSelectMulti } from './FieldSelectMulti';
18
16
  import { FieldSelectSingle } from './FieldSelectSingle';
19
- import { SelectionMode } from './types';
20
- const ForwardedFieldSelect = forwardRef((_a, ref) => {
21
- var { selectionMode = SelectionMode.Single } = _a, props = __rest(_a, ["selectionMode"]);
17
+ export const FieldSelect = forwardRef((_a, ref) => {
18
+ var { selectionMode = SELECTION_MODE.Single } = _a, props = __rest(_a, ["selectionMode"]);
22
19
  switch (selectionMode) {
23
- case SelectionMode.Multi:
20
+ case SELECTION_MODE.Multi:
24
21
  return _jsx(FieldSelectMulti, Object.assign({}, props, { ref: ref }));
25
- case SelectionMode.Single:
22
+ case SELECTION_MODE.Single:
26
23
  default:
27
24
  return _jsx(FieldSelectSingle, Object.assign({}, props, { ref: ref }));
28
25
  }
29
26
  });
30
- export const FieldSelect = ForwardedFieldSelect;
31
- FieldSelect.sizes = Size;
32
- FieldSelect.validationStates = ValidationState;
33
- FieldSelect.selectionModes = SelectionMode;
34
- FieldSelect.labelTooltipPlacements = Tooltip.placements;
@@ -1,5 +1,6 @@
1
1
  import { KeyboardEventHandler, MouseEventHandler, RefCallback, RefObject } from 'react';
2
- import { ExtendedOption, FieldSelectBaseProps, Option, SelectionMode } from './types';
2
+ import { SELECTION_MODE } from './constants';
3
+ import { ExtendedOption, FieldSelectBaseProps, Option } from './types';
3
4
  type BaseProps = Omit<FieldSelectBaseProps, 'open' | 'onOpenChange' | 'options'> & Required<Pick<FieldSelectBaseProps, 'open' | 'onOpenChange'>> & {
4
5
  localRef: RefObject<HTMLInputElement>;
5
6
  options: ExtendedOption[];
@@ -16,14 +17,14 @@ type BaseProps = Omit<FieldSelectBaseProps, 'open' | 'onOpenChange' | 'options'>
16
17
  copyButtonRef: RefObject<HTMLButtonElement>;
17
18
  onClick?: MouseEventHandler<HTMLElement>;
18
19
  onContainerPrivateMouseDown?: MouseEventHandler<HTMLElement>;
19
- onDroplistFocusLeave: (direction: string) => void;
20
+ onDroplistFocusLeave(direction: string): void;
20
21
  firstDroplistItemRefCallback: RefCallback<HTMLButtonElement>;
21
22
  };
22
23
  type Props = ({
23
- selectionMode: SelectionMode.Single;
24
+ selectionMode: typeof SELECTION_MODE.Single;
24
25
  selected: Option;
25
26
  } & BaseProps) | ({
26
- selectionMode: SelectionMode.Multi;
27
+ selectionMode: typeof SELECTION_MODE.Multi;
27
28
  selected: Option[];
28
29
  } & BaseProps);
29
30
  export declare const FieldSelectBase: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<HTMLInputElement>>;
@@ -13,20 +13,20 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
13
13
  import mergeRefs from 'merge-refs';
14
14
  import { forwardRef, useMemo, } from 'react';
15
15
  import { Droplist } from '@snack-uikit/droplist';
16
- import { InputPrivate, Size, useButtonNavigation, useClearButton } from '@snack-uikit/input-private';
16
+ import { InputPrivate, SIZE, useButtonNavigation, useClearButton } from '@snack-uikit/input-private';
17
17
  import { extractSupportProps } from '@snack-uikit/utils';
18
- import { ContainerVariant, ValidationState } from '../../constants';
18
+ import { CONTAINER_VARIANT, VALIDATION_STATE } from '../../constants';
19
19
  import { FieldContainerPrivate } from '../../helperComponents';
20
20
  import { useCopyButton } from '../../hooks';
21
21
  import { useHandlers } from '../FieldDate/hooks/useHandlers';
22
22
  import { FieldDecorator } from '../FieldDecorator';
23
+ import { SELECTION_MODE } from './constants';
23
24
  import { getArrowIcon } from './helpers';
24
25
  import styles from './styles.module.css';
25
- import { SelectionMode } from './types';
26
26
  export const FieldSelectBase = forwardRef((_a, ref) => {
27
- var { selectionMode, onClear, showClearButton, clearButtonRef, copyButtonRef, onChange, inputValue, onInputValueChange, displayedValue, valueToCopy, localRef, onInputKeyDown: onInputKeyDownProp, onButtonKeyDown: onButtonKeyDownProp, id, name, placeholder, options, disabled = false, readonly = false, searchable = true, showCopyButton = true, open, onOpenChange, onFocus, onBlur, onContainerPrivateMouseDown, className, label, labelTooltip, labelTooltipPlacement, required = false, hint, showHintIcon, size = Size.S, validationState = ValidationState.Default, prefixIcon, locale, noDataText = (locale === null || locale === void 0 ? void 0 : locale.language) === 'ru' ? 'Нет данных' : 'No data', firstDroplistItemRefCallback, onDroplistFocusLeave } = _a, rest = __rest(_a, ["selectionMode", "onClear", "showClearButton", "clearButtonRef", "copyButtonRef", "onChange", "inputValue", "onInputValueChange", "displayedValue", "valueToCopy", "localRef", "onInputKeyDown", "onButtonKeyDown", "id", "name", "placeholder", "options", "disabled", "readonly", "searchable", "showCopyButton", "open", "onOpenChange", "onFocus", "onBlur", "onContainerPrivateMouseDown", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "hint", "showHintIcon", "size", "validationState", "prefixIcon", "locale", "noDataText", "firstDroplistItemRefCallback", "onDroplistFocusLeave"]);
27
+ var { selectionMode, onClear, showClearButton, clearButtonRef, copyButtonRef, onChange, inputValue, onInputValueChange, displayedValue, valueToCopy, localRef, onInputKeyDown: onInputKeyDownProp, onButtonKeyDown: onButtonKeyDownProp, id, name, placeholder, options, disabled = false, readonly = false, searchable = true, showCopyButton = true, open, onOpenChange, onFocus, onBlur, onContainerPrivateMouseDown, className, label, labelTooltip, labelTooltipPlacement, required = false, hint, showHintIcon, size = SIZE.S, validationState = VALIDATION_STATE.Default, prefixIcon, locale, noDataText = (locale === null || locale === void 0 ? void 0 : locale.language) === 'ru' ? 'Нет данных' : 'No data', firstDroplistItemRefCallback, onDroplistFocusLeave } = _a, rest = __rest(_a, ["selectionMode", "onClear", "showClearButton", "clearButtonRef", "copyButtonRef", "onChange", "inputValue", "onInputValueChange", "displayedValue", "valueToCopy", "localRef", "onInputKeyDown", "onButtonKeyDown", "id", "name", "placeholder", "options", "disabled", "readonly", "searchable", "showCopyButton", "open", "onOpenChange", "onFocus", "onBlur", "onContainerPrivateMouseDown", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "hint", "showHintIcon", "size", "validationState", "prefixIcon", "locale", "noDataText", "firstDroplistItemRefCallback", "onDroplistFocusLeave"]);
28
28
  const { ArrowIcon, arrowIconSize } = getArrowIcon({ size, open });
29
- const Item = selectionMode === SelectionMode.Single ? Droplist.ItemSingle : Droplist.ItemMultiple;
29
+ const Item = selectionMode === SELECTION_MODE.Single ? Droplist.ItemSingle : Droplist.ItemMultiple;
30
30
  const clearButtonSettings = useClearButton({ clearButtonRef, showClearButton, size, onClear });
31
31
  const copyButtonSettings = useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy });
32
32
  const { onInputKeyDown: inputKeyDownNavigationHandler, inputTabIndex, setInitialTabIndices, buttons, } = useButtonNavigation({
@@ -47,5 +47,5 @@ export const FieldSelectBase = forwardRef((_a, ref) => {
47
47
  },
48
48
  onDroplistFocusLeave,
49
49
  ]);
50
- return (_jsx(FieldDecorator, Object.assign({ className: className, label: label, labelTooltip: labelTooltip, labelTooltipPlacement: labelTooltipPlacement, labelFor: id, required: required, hint: hint, disabled: disabled, readonly: readonly, showHintIcon: showHintIcon, size: size, validationState: validationState }, extractSupportProps(rest), { children: _jsx(Droplist, Object.assign({ trigger: Droplist.triggers.Click, triggerClassName: styles.triggerClassName, triggerClickByKeys: !searchable, placement: Droplist.placements.Bottom, onFocusLeave: onFocusLeaveHandler, firstElementRefCallback: firstDroplistItemRefCallback, "data-test-id": 'field-select__list' }, (readonly || disabled ? { open: false } : { open, onOpenChange }), { triggerElement: _jsxs(FieldContainerPrivate, Object.assign({ className: styles.container, size: size, validationState: validationState, disabled: disabled, readonly: readonly, variant: ContainerVariant.SingleLine, focused: open, selectable: !searchable, inputRef: localRef, prefix: prefixIcon, onMouseDown: onContainerPrivateMouseDown, postfix: _jsxs(_Fragment, { children: [buttons, _jsx(ArrowIcon, { size: arrowIconSize, className: styles.arrowIcon })] }) }, { children: [_jsx(InputPrivate, { id: id, name: name, type: InputPrivate.types.Text, placeholder: placeholder, ref: mergeRefs(ref, localRef), onFocus: onFocus, onBlur: onBlur, disabled: disabled, "data-size": size, "data-test-id": 'field-select__input', onKeyDown: onInputKeyDownHandler, onChange: searchable ? onInputValueChange : undefined, readonly: !searchable || readonly, value: inputValue, tabIndex: inputTabIndex }), displayedValue && (_jsx("span", Object.assign({ className: styles.displayValue, "data-test-id": 'field-select__displayed-value' }, { children: displayedValue })))] })) }, { children: options.length === 0 ? (_jsx(Droplist.NoData, { size: size, label: noDataText, "data-test-id": 'field-select__no-data' })) : (options.map(option => (_jsx(Item, Object.assign({ onChange: onChange(option), "data-test-id": 'field-select__list-option-' + option.value }, option, { option: option.label }), option.value)))) })) })));
50
+ return (_jsx(FieldDecorator, Object.assign({ className: className, label: label, labelTooltip: labelTooltip, labelTooltipPlacement: labelTooltipPlacement, labelFor: id, required: required, hint: hint, disabled: disabled, readonly: readonly, showHintIcon: showHintIcon, size: size, validationState: validationState }, extractSupportProps(rest), { children: _jsx(Droplist, Object.assign({ trigger: 'click', triggerClassName: styles.triggerClassName, triggerClickByKeys: !searchable, placement: 'bottom', onFocusLeave: onFocusLeaveHandler, firstElementRefCallback: firstDroplistItemRefCallback, "data-test-id": 'field-select__list' }, (readonly || disabled ? { open: false } : { open, onOpenChange }), { triggerElement: _jsxs(FieldContainerPrivate, Object.assign({ className: styles.container, size: size, validationState: validationState, disabled: disabled, readonly: readonly, variant: CONTAINER_VARIANT.SingleLine, focused: open, selectable: !searchable, inputRef: localRef, prefix: prefixIcon, onMouseDown: onContainerPrivateMouseDown, postfix: _jsxs(_Fragment, { children: [buttons, _jsx(ArrowIcon, { size: arrowIconSize, className: styles.arrowIcon })] }) }, { children: [_jsx(InputPrivate, { id: id, name: name, type: 'text', placeholder: placeholder, ref: mergeRefs(ref, localRef), onFocus: onFocus, onBlur: onBlur, disabled: disabled, "data-size": size, "data-test-id": 'field-select__input', onKeyDown: onInputKeyDownHandler, onChange: searchable ? onInputValueChange : undefined, readonly: !searchable || readonly, value: inputValue, tabIndex: inputTabIndex }), displayedValue && (_jsx("span", Object.assign({ className: styles.displayValue, "data-test-id": 'field-select__displayed-value' }, { children: displayedValue })))] })) }, { children: options.length === 0 ? (_jsx(Droplist.NoData, { size: size, label: noDataText, "data-test-id": 'field-select__no-data' })) : (options.map(option => (_jsx(Item, Object.assign({ onChange: onChange(option), "data-test-id": 'field-select__list-option-' + option.value }, option, { option: option.label }), option.value)))) })) })));
51
51
  });
@@ -21,14 +21,14 @@ export declare const FieldSelectMulti: import("react").ForwardRefExoticComponent
21
21
  onBlur?: FocusEventHandler<HTMLInputElement> | undefined;
22
22
  } & {
23
23
  showHintIcon?: boolean | undefined;
24
- validationState?: import("../../constants").ValidationState | undefined;
24
+ validationState?: import("../../types").ValidationState | undefined;
25
25
  hint?: string | undefined;
26
26
  size?: import("@snack-uikit/input-private").Size | undefined;
27
27
  label?: string | undefined;
28
28
  className?: string | undefined;
29
29
  labelTooltip?: string | undefined;
30
30
  required?: boolean | undefined;
31
- labelTooltipPlacement?: import("@snack-uikit/popover-private/dist/constants").Placement | undefined;
31
+ labelTooltipPlacement?: import("@snack-uikit/popover-private/dist/types").Placement | undefined;
32
32
  } & {
33
33
  value?: string[] | undefined;
34
34
  onChange?(value: string[]): void;