@snack-uikit/fields 0.51.8 → 0.51.10-preview-e119b7ab.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
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
+ ## <small>0.51.9 (2025-11-14)</small>
7
+
8
+ ### Only dependencies have been changed
9
+ * [@snack-uikit/calendar@0.13.8](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/calendar/CHANGELOG.md)
10
+ * [@snack-uikit/color-picker@0.3.47](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/color-picker/CHANGELOG.md)
11
+ * [@snack-uikit/list@0.32.7](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/list/CHANGELOG.md)
12
+ * [@snack-uikit/truncate-string@0.7.4](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/truncate-string/CHANGELOG.md)
13
+
14
+
15
+
16
+
17
+
6
18
  ## <small>0.51.8 (2025-11-06)</small>
7
19
 
8
20
  * feat(PDS-1292): presets for calendar range mode ([45929bd](https://github.com/cloud-ru-tech/snack-uikit/commit/45929bd))
package/README.md CHANGED
@@ -473,6 +473,7 @@ FieldStepper в основном предназначен для работы с
473
473
  | showCopyButton | `boolean` | - | Отображение кнопки Копировать для поля (актуально только для `readonly = true`) |
474
474
  | onCopyButtonClick | `() => void` | - | Колбек клика по кнопке Копировать для поля |
475
475
  | showClearButton | `boolean` | true | Отображение кнопки очистки поля |
476
+ | onClearButtonClick | `() => void` | - | Колбек клика по кнопке очистки поля |
476
477
  | allowMoreThanMaxLength | `boolean` | - | Можно ли вводить больше разрешённого кол-ва символов |
477
478
  | prefixIcon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка-префикс для поля |
478
479
  | prefix | `ReactNode` | - | Произвольный префикс для поля |
@@ -15,6 +15,8 @@ type FieldTextOwnProps = {
15
15
  * @default true
16
16
  */
17
17
  showClearButton?: boolean;
18
+ /** Колбек клика по кнопке очистки поля */
19
+ onClearButtonClick?(): void;
18
20
  /** Можно ли вводить больше разрешённого кол-ва символов */
19
21
  allowMoreThanMaxLength?: boolean;
20
22
  /** Иконка-префикс для поля */
@@ -44,6 +44,7 @@ exports.FieldText = (0, react_1.forwardRef)((_a, ref) => {
44
44
  onFocus,
45
45
  onBlur,
46
46
  onCopyButtonClick,
47
+ onClearButtonClick,
47
48
  className,
48
49
  label,
49
50
  labelTooltip,
@@ -67,7 +68,7 @@ exports.FieldText = (0, react_1.forwardRef)((_a, ref) => {
67
68
  inputMode,
68
69
  spellCheck
69
70
  } = _a,
70
- 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", "autoFocus", "prefixIcon", "prefix", "postfix", "button", "onPaste", "onKeyDown", "type", "inputMode", "spellCheck"]);
71
+ rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "disabled", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "onChange", "onFocus", "onBlur", "onCopyButtonClick", "onClearButtonClick", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "error", "autoComplete", "autoFocus", "prefixIcon", "prefix", "postfix", "button", "onPaste", "onKeyDown", "type", "inputMode", "spellCheck"]);
71
72
  const [value = '', onChange] = (0, hooks_1.useValueControl)({
72
73
  value: valueProp,
73
74
  defaultValue: '',
@@ -98,10 +99,14 @@ exports.FieldText = (0, react_1.forwardRef)((_a, ref) => {
98
99
  const containerVariant = (0, helpers_1.getContainerVariant)({
99
100
  button
100
101
  });
102
+ const [isButtonFocused, setIsButtonFocused] = (0, react_1.useState)(false);
103
+ const onButtonFocus = (0, react_1.useCallback)(() => setIsButtonFocused(true), []);
104
+ const onButtonBlur = (0, react_1.useCallback)(() => setIsButtonFocused(false), []);
101
105
  const onClear = () => {
102
106
  var _a;
103
107
  onChange('');
104
- if (required) {
108
+ onClearButtonClick === null || onClearButtonClick === void 0 ? void 0 : onClearButtonClick();
109
+ if (isButtonFocused) {
105
110
  (_a = localRef.current) === null || _a === void 0 ? void 0 : _a.focus();
106
111
  }
107
112
  };
@@ -120,9 +125,6 @@ exports.FieldText = (0, react_1.forwardRef)((_a, ref) => {
120
125
  postfix: typeof postfix === 'string' ? postfix : undefined,
121
126
  onCopyButtonClick
122
127
  });
123
- const [isButtonFocused, setIsButtonFocused] = (0, react_1.useState)(false);
124
- const onButtonFocus = (0, react_1.useCallback)(() => setIsButtonFocused(true), []);
125
- const onButtonBlur = (0, react_1.useCallback)(() => setIsButtonFocused(false), []);
126
128
  const prefixSettings = (0, hooks_1.usePrefix)({
127
129
  prefix,
128
130
  disabled
@@ -15,6 +15,8 @@ type FieldTextOwnProps = {
15
15
  * @default true
16
16
  */
17
17
  showClearButton?: boolean;
18
+ /** Колбек клика по кнопке очистки поля */
19
+ onClearButtonClick?(): void;
18
20
  /** Можно ли вводить больше разрешённого кол-ва символов */
19
21
  allowMoreThanMaxLength?: boolean;
20
22
  /** Иконка-префикс для поля */
@@ -21,7 +21,7 @@ import { getValidationState } from '../../utils/getValidationState';
21
21
  import { FieldDecorator } from '../FieldDecorator';
22
22
  import { getContainerVariant } from './helpers';
23
23
  export const FieldText = forwardRef((_a, ref) => {
24
- var { id, name, value: valueProp, placeholder, maxLength, disabled = false, readonly = false, showCopyButton: showCopyButtonProp = true, showClearButton: showClearButtonProp = true, allowMoreThanMaxLength = false, onChange: onChangeProp, onFocus, onBlur, onCopyButtonClick, className, label, labelTooltip, labelTooltipPlacement, required = false, caption, hint, showHintIcon, size = SIZE.S, validationState = VALIDATION_STATE.Default, error, autoComplete, autoFocus, prefixIcon, prefix, postfix, button: buttonProp, onPaste, onKeyDown, type = 'text', inputMode, spellCheck } = _a, 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", "autoFocus", "prefixIcon", "prefix", "postfix", "button", "onPaste", "onKeyDown", "type", "inputMode", "spellCheck"]);
24
+ var { id, name, value: valueProp, placeholder, maxLength, disabled = false, readonly = false, showCopyButton: showCopyButtonProp = true, showClearButton: showClearButtonProp = true, allowMoreThanMaxLength = false, onChange: onChangeProp, onFocus, onBlur, onCopyButtonClick, onClearButtonClick, className, label, labelTooltip, labelTooltipPlacement, required = false, caption, hint, showHintIcon, size = SIZE.S, validationState = VALIDATION_STATE.Default, error, autoComplete, autoFocus, prefixIcon, prefix, postfix, button: buttonProp, onPaste, onKeyDown, type = 'text', inputMode, spellCheck } = _a, rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "disabled", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "onChange", "onFocus", "onBlur", "onCopyButtonClick", "onClearButtonClick", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "error", "autoComplete", "autoFocus", "prefixIcon", "prefix", "postfix", "button", "onPaste", "onKeyDown", "type", "inputMode", "spellCheck"]);
25
25
  const [value = '', onChange] = useValueControl({
26
26
  value: valueProp,
27
27
  defaultValue: '',
@@ -41,10 +41,14 @@ export const FieldText = forwardRef((_a, ref) => {
41
41
  setTimeout(() => { var _a; return (_a = localRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, 0);
42
42
  } }) }) : undefined, [buttonProp]);
43
43
  const containerVariant = getContainerVariant({ button });
44
+ const [isButtonFocused, setIsButtonFocused] = useState(false);
45
+ const onButtonFocus = useCallback(() => setIsButtonFocused(true), []);
46
+ const onButtonBlur = useCallback(() => setIsButtonFocused(false), []);
44
47
  const onClear = () => {
45
48
  var _a;
46
49
  onChange('');
47
- if (required) {
50
+ onClearButtonClick === null || onClearButtonClick === void 0 ? void 0 : onClearButtonClick();
51
+ if (isButtonFocused) {
48
52
  (_a = localRef.current) === null || _a === void 0 ? void 0 : _a.focus();
49
53
  }
50
54
  };
@@ -58,9 +62,6 @@ export const FieldText = forwardRef((_a, ref) => {
58
62
  postfix: typeof postfix === 'string' ? postfix : undefined,
59
63
  onCopyButtonClick,
60
64
  });
61
- const [isButtonFocused, setIsButtonFocused] = useState(false);
62
- const onButtonFocus = useCallback(() => setIsButtonFocused(true), []);
63
- const onButtonBlur = useCallback(() => setIsButtonFocused(false), []);
64
65
  const prefixSettings = usePrefix({ prefix, disabled });
65
66
  const prefixButtonSettings = usePrefixButton({
66
67
  button,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Fields",
7
- "version": "0.51.8",
7
+ "version": "0.51.10-preview-e119b7ab.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -37,19 +37,19 @@
37
37
  "scripts": {},
38
38
  "dependencies": {
39
39
  "@snack-uikit/button": "0.19.16",
40
- "@snack-uikit/calendar": "0.13.7",
41
- "@snack-uikit/color-picker": "0.3.46",
40
+ "@snack-uikit/calendar": "0.13.8",
41
+ "@snack-uikit/color-picker": "0.3.47",
42
42
  "@snack-uikit/divider": "3.2.10",
43
43
  "@snack-uikit/dropdown": "0.5.3",
44
44
  "@snack-uikit/icons": "0.27.3",
45
45
  "@snack-uikit/input-private": "4.8.3",
46
- "@snack-uikit/list": "0.32.6",
46
+ "@snack-uikit/list": "0.32.7",
47
47
  "@snack-uikit/scroll": "0.10.5",
48
48
  "@snack-uikit/skeleton": "0.6.9",
49
49
  "@snack-uikit/slider": "0.3.28",
50
50
  "@snack-uikit/tag": "0.15.10",
51
51
  "@snack-uikit/tooltip": "0.18.5",
52
- "@snack-uikit/truncate-string": "0.7.3",
52
+ "@snack-uikit/truncate-string": "0.7.4",
53
53
  "@snack-uikit/utils": "4.0.0",
54
54
  "classnames": "2.5.1",
55
55
  "copy-to-clipboard": "3.3.3",
@@ -66,5 +66,5 @@
66
66
  "peerDependencies": {
67
67
  "@snack-uikit/locale": "*"
68
68
  },
69
- "gitHead": "6b989b5fe57383ddf2bd6c1186bf4e1652633da7"
69
+ "gitHead": "72d6584968fb939451725d0615b726479da0706a"
70
70
  }
@@ -66,6 +66,8 @@ type FieldTextOwnProps = {
66
66
  * @default true
67
67
  */
68
68
  showClearButton?: boolean;
69
+ /** Колбек клика по кнопке очистки поля */
70
+ onClearButtonClick?(): void;
69
71
  /** Можно ли вводить больше разрешённого кол-ва символов */
70
72
  allowMoreThanMaxLength?: boolean;
71
73
  /** Иконка-префикс для поля */
@@ -100,6 +102,7 @@ export const FieldText = forwardRef<HTMLInputElement, FieldTextProps>(
100
102
  onFocus,
101
103
  onBlur,
102
104
  onCopyButtonClick,
105
+ onClearButtonClick,
103
106
  className,
104
107
  label,
105
108
  labelTooltip,
@@ -158,10 +161,15 @@ export const FieldText = forwardRef<HTMLInputElement, FieldTextProps>(
158
161
 
159
162
  const containerVariant = getContainerVariant({ button });
160
163
 
164
+ const [isButtonFocused, setIsButtonFocused] = useState(false);
165
+ const onButtonFocus = useCallback(() => setIsButtonFocused(true), []);
166
+ const onButtonBlur = useCallback(() => setIsButtonFocused(false), []);
167
+
161
168
  const onClear = () => {
162
169
  onChange('');
170
+ onClearButtonClick?.();
163
171
 
164
- if (required) {
172
+ if (isButtonFocused) {
165
173
  localRef.current?.focus();
166
174
  }
167
175
  };
@@ -177,10 +185,6 @@ export const FieldText = forwardRef<HTMLInputElement, FieldTextProps>(
177
185
  onCopyButtonClick,
178
186
  });
179
187
 
180
- const [isButtonFocused, setIsButtonFocused] = useState(false);
181
- const onButtonFocus = useCallback(() => setIsButtonFocused(true), []);
182
- const onButtonBlur = useCallback(() => setIsButtonFocused(false), []);
183
-
184
188
  const prefixSettings = usePrefix({ prefix, disabled });
185
189
  const prefixButtonSettings = usePrefixButton({
186
190
  button,