@alfalab/core-components-with-suffix 4.0.32 → 4.1.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/Component.d.ts CHANGED
@@ -13,38 +13,9 @@ type withSuffixProps = InputProps & {
13
13
  */
14
14
  suffixContainerClassName?: string;
15
15
  };
16
- declare const withSuffix: (Input: FC<InputProps & RefAttributes<HTMLInputElement>>) => React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "type" | "defaultValue" | "onChange" | "onClick" | "onMouseDown" | "value" | "enterKeyHint"> & {
17
- value?: string | undefined;
18
- defaultValue?: string | undefined;
19
- block?: boolean | undefined;
20
- clear?: boolean | undefined;
21
- size?: "s" | "m" | "l" | "xl" | undefined;
22
- colors?: "default" | "inverted" | undefined;
23
- error?: React.ReactNode;
24
- success?: boolean | undefined;
25
- hint?: React.ReactNode;
26
- label?: React.ReactNode;
27
- labelView?: "inner" | "outer" | undefined;
28
- type?: "number" | "text" | "tel" | "email" | "card" | "money" | "password" | undefined;
29
- wrapperRef?: React.Ref<HTMLDivElement> | undefined;
30
- leftAddons?: React.ReactNode;
31
- rightAddons?: React.ReactNode;
32
- bottomAddons?: React.ReactNode;
33
- className?: string | undefined;
34
- fieldClassName?: string | undefined;
35
- inputClassName?: string | undefined;
36
- labelClassName?: string | undefined;
37
- addonsClassName?: string | undefined;
38
- focusedClassName?: string | undefined;
39
- filledClassName?: string | undefined;
40
- onChange?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
41
- value: string;
42
- }) => void) | undefined;
43
- onClear?: ((event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void) | undefined;
44
- onClick?: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
45
- onMouseDown?: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
46
- onMouseUp?: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
47
- dataTestId?: string | undefined;
16
+ declare const withSuffix: (Input: FC<InputProps & RefAttributes<HTMLInputElement>>) => React.ForwardRefExoticComponent<Omit<import("packages/input/src/components/base-input").BaseInputProps, "FormControlComponent" | "colorStyles"> & {
17
+ breakpoint?: number | undefined;
18
+ defaultMatchMediaValue?: boolean | (() => boolean) | undefined;
48
19
  } & {
49
20
  /**
50
21
  * Дополнительный закрепленный текст справа от основного значения.
package/Component.js CHANGED
@@ -14,7 +14,7 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
14
14
  var mergeRefs__default = /*#__PURE__*/_interopDefaultCompat(mergeRefs);
15
15
  var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
16
16
 
17
- var styles = {"suffixContainer":"with-suffix__suffixContainer_1ybvh","suffixVisible":"with-suffix__suffixVisible_1ybvh","hasSuffix":"with-suffix__hasSuffix_1ybvh","spacer":"with-suffix__spacer_1ybvh","suffix":"with-suffix__suffix_1ybvh","disabled":"with-suffix__disabled_1ybvh","readOnly":"with-suffix__readOnly_1ybvh"};
17
+ var styles = {"suffixContainer":"with-suffix__suffixContainer_b4nsz","suffixVisible":"with-suffix__suffixVisible_b4nsz","hasSuffix":"with-suffix__hasSuffix_b4nsz","spacer":"with-suffix__spacer_b4nsz","suffix":"with-suffix__suffix_b4nsz","disabled":"with-suffix__disabled_b4nsz","readOnly":"with-suffix__readOnly_b4nsz"};
18
18
  require('./index.css')
19
19
 
20
20
  var withSuffix = function (Input) {
@@ -22,8 +22,8 @@ var withSuffix = function (Input) {
22
22
  var _b, _c;
23
23
  var value = _a.value, defaultValue = _a.defaultValue, onChange = _a.onChange, onClear = _a.onClear, _d = _a.suffix, suffix = _d === void 0 ? '' : _d, placeholder = _a.placeholder, className = _a.className, disabled = _a.disabled, readOnly = _a.readOnly, suffixContainerClassName = _a.suffixContainerClassName, restProps = tslib.__rest(_a, ["value", "defaultValue", "onChange", "onClear", "suffix", "placeholder", "className", "disabled", "readOnly", "suffixContainerClassName"]);
24
24
  var uncontrolled = value === undefined;
25
- var inputRef = React.useRef(null);
26
- var _e = React.useState(defaultValue || ''), stateValue = _e[0], setStateValue = _e[1];
25
+ var _e = React.useState(null), inputNode = _e[0], setInputNode = _e[1];
26
+ var _f = React.useState(defaultValue || ''), stateValue = _f[0], setStateValue = _f[1];
27
27
  var handleInputChange = React.useCallback(function (event, payload) {
28
28
  if (onChange) {
29
29
  onChange(event, payload);
@@ -42,10 +42,10 @@ var withSuffix = function (Input) {
42
42
  }, [onClear, uncontrolled]);
43
43
  var getPortalContainer = React.useCallback(
44
44
  // TODO: Изменить сигнатуру getPortalContainer в Portal
45
- function () { return inputRef.current.parentElement; }, []);
45
+ function () { return inputNode === null || inputNode === void 0 ? void 0 : inputNode.parentElement; }, [inputNode]);
46
46
  var visibleValue = uncontrolled ? stateValue : value;
47
47
  return (React__default.default.createElement(React.Fragment, null,
48
- React__default.default.createElement(Input, tslib.__assign({ ref: mergeRefs__default.default([ref, inputRef]), value: visibleValue, disabled: disabled, readOnly: readOnly, onChange: handleInputChange, onClear: handleClear, placeholder: placeholder, className: cn__default.default(className, (_b = {},
48
+ React__default.default.createElement(Input, tslib.__assign({ ref: mergeRefs__default.default([ref, setInputNode]), value: visibleValue, disabled: disabled, readOnly: readOnly, onChange: handleInputChange, onClear: handleClear, placeholder: placeholder, className: cn__default.default(className, (_b = {},
49
49
  _b[styles.suffixVisible] = Boolean(visibleValue),
50
50
  _b[styles.hasSuffix] = suffix,
51
51
  _b)) }, restProps)),
@@ -13,38 +13,9 @@ type withSuffixProps = InputProps & {
13
13
  */
14
14
  suffixContainerClassName?: string;
15
15
  };
16
- declare const withSuffix: (Input: FC<InputProps & RefAttributes<HTMLInputElement>>) => React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "type" | "defaultValue" | "onChange" | "onClick" | "onMouseDown" | "value" | "enterKeyHint"> & {
17
- value?: string | undefined;
18
- defaultValue?: string | undefined;
19
- block?: boolean | undefined;
20
- clear?: boolean | undefined;
21
- size?: "s" | "m" | "l" | "xl" | undefined;
22
- colors?: "default" | "inverted" | undefined;
23
- error?: React.ReactNode;
24
- success?: boolean | undefined;
25
- hint?: React.ReactNode;
26
- label?: React.ReactNode;
27
- labelView?: "inner" | "outer" | undefined;
28
- type?: "number" | "text" | "tel" | "email" | "card" | "money" | "password" | undefined;
29
- wrapperRef?: React.Ref<HTMLDivElement> | undefined;
30
- leftAddons?: React.ReactNode;
31
- rightAddons?: React.ReactNode;
32
- bottomAddons?: React.ReactNode;
33
- className?: string | undefined;
34
- fieldClassName?: string | undefined;
35
- inputClassName?: string | undefined;
36
- labelClassName?: string | undefined;
37
- addonsClassName?: string | undefined;
38
- focusedClassName?: string | undefined;
39
- filledClassName?: string | undefined;
40
- onChange?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
41
- value: string;
42
- }) => void) | undefined;
43
- onClear?: ((event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void) | undefined;
44
- onClick?: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
45
- onMouseDown?: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
46
- onMouseUp?: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
47
- dataTestId?: string | undefined;
16
+ declare const withSuffix: (Input: FC<InputProps & RefAttributes<HTMLInputElement>>) => React.ForwardRefExoticComponent<Omit<import("packages/input/src/components/base-input").BaseInputProps, "FormControlComponent" | "colorStyles"> & {
17
+ breakpoint?: number | undefined;
18
+ defaultMatchMediaValue?: boolean | (() => boolean) | undefined;
48
19
  } & {
49
20
  /**
50
21
  * Дополнительный закрепленный текст справа от основного значения.
package/cssm/Component.js CHANGED
@@ -21,8 +21,8 @@ var withSuffix = function (Input) {
21
21
  var _b, _c;
22
22
  var value = _a.value, defaultValue = _a.defaultValue, onChange = _a.onChange, onClear = _a.onClear, _d = _a.suffix, suffix = _d === void 0 ? '' : _d, placeholder = _a.placeholder, className = _a.className, disabled = _a.disabled, readOnly = _a.readOnly, suffixContainerClassName = _a.suffixContainerClassName, restProps = tslib.__rest(_a, ["value", "defaultValue", "onChange", "onClear", "suffix", "placeholder", "className", "disabled", "readOnly", "suffixContainerClassName"]);
23
23
  var uncontrolled = value === undefined;
24
- var inputRef = React.useRef(null);
25
- var _e = React.useState(defaultValue || ''), stateValue = _e[0], setStateValue = _e[1];
24
+ var _e = React.useState(null), inputNode = _e[0], setInputNode = _e[1];
25
+ var _f = React.useState(defaultValue || ''), stateValue = _f[0], setStateValue = _f[1];
26
26
  var handleInputChange = React.useCallback(function (event, payload) {
27
27
  if (onChange) {
28
28
  onChange(event, payload);
@@ -41,10 +41,10 @@ var withSuffix = function (Input) {
41
41
  }, [onClear, uncontrolled]);
42
42
  var getPortalContainer = React.useCallback(
43
43
  // TODO: Изменить сигнатуру getPortalContainer в Portal
44
- function () { return inputRef.current.parentElement; }, []);
44
+ function () { return inputNode === null || inputNode === void 0 ? void 0 : inputNode.parentElement; }, [inputNode]);
45
45
  var visibleValue = uncontrolled ? stateValue : value;
46
46
  return (React__default.default.createElement(React.Fragment, null,
47
- React__default.default.createElement(Input, tslib.__assign({ ref: mergeRefs__default.default([ref, inputRef]), value: visibleValue, disabled: disabled, readOnly: readOnly, onChange: handleInputChange, onClear: handleClear, placeholder: placeholder, className: cn__default.default(className, (_b = {},
47
+ React__default.default.createElement(Input, tslib.__assign({ ref: mergeRefs__default.default([ref, setInputNode]), value: visibleValue, disabled: disabled, readOnly: readOnly, onChange: handleInputChange, onClear: handleClear, placeholder: placeholder, className: cn__default.default(className, (_b = {},
48
48
  _b[styles__default.default.suffixVisible] = Boolean(visibleValue),
49
49
  _b[styles__default.default.hasSuffix] = suffix,
50
50
  _b)) }, restProps)),
@@ -27,6 +27,8 @@
27
27
  /* display */
28
28
 
29
29
  /* управляет видимостью иконки ошибки, если она стоит рядом с другой иконкой */
30
+
31
+ /* mobile */
30
32
  } .suffixContainer {
31
33
  font-size: 16px;
32
34
  line-height: 20px;
@@ -13,38 +13,9 @@ type withSuffixProps = InputProps & {
13
13
  */
14
14
  suffixContainerClassName?: string;
15
15
  };
16
- declare const withSuffix: (Input: FC<InputProps & RefAttributes<HTMLInputElement>>) => React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "type" | "defaultValue" | "onChange" | "onClick" | "onMouseDown" | "value" | "enterKeyHint"> & {
17
- value?: string | undefined;
18
- defaultValue?: string | undefined;
19
- block?: boolean | undefined;
20
- clear?: boolean | undefined;
21
- size?: "s" | "m" | "l" | "xl" | undefined;
22
- colors?: "default" | "inverted" | undefined;
23
- error?: React.ReactNode;
24
- success?: boolean | undefined;
25
- hint?: React.ReactNode;
26
- label?: React.ReactNode;
27
- labelView?: "inner" | "outer" | undefined;
28
- type?: "number" | "text" | "tel" | "email" | "card" | "money" | "password" | undefined;
29
- wrapperRef?: React.Ref<HTMLDivElement> | undefined;
30
- leftAddons?: React.ReactNode;
31
- rightAddons?: React.ReactNode;
32
- bottomAddons?: React.ReactNode;
33
- className?: string | undefined;
34
- fieldClassName?: string | undefined;
35
- inputClassName?: string | undefined;
36
- labelClassName?: string | undefined;
37
- addonsClassName?: string | undefined;
38
- focusedClassName?: string | undefined;
39
- filledClassName?: string | undefined;
40
- onChange?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
41
- value: string;
42
- }) => void) | undefined;
43
- onClear?: ((event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void) | undefined;
44
- onClick?: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
45
- onMouseDown?: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
46
- onMouseUp?: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
47
- dataTestId?: string | undefined;
16
+ declare const withSuffix: (Input: FC<InputProps & RefAttributes<HTMLInputElement>>) => React.ForwardRefExoticComponent<Omit<import("packages/input/src/components/base-input").BaseInputProps, "FormControlComponent" | "colorStyles"> & {
17
+ breakpoint?: number | undefined;
18
+ defaultMatchMediaValue?: boolean | (() => boolean) | undefined;
48
19
  } & {
49
20
  /**
50
21
  * Дополнительный закрепленный текст справа от основного значения.
package/esm/Component.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { __rest, __assign } from 'tslib';
2
- import React, { forwardRef, useRef, useState, useCallback, Fragment } from 'react';
2
+ import React, { forwardRef, useState, useCallback, Fragment } from 'react';
3
3
  import mergeRefs from 'react-merge-refs';
4
4
  import cn from 'classnames';
5
5
  import { Portal } from '@alfalab/core-components-portal/esm';
6
6
 
7
- var styles = {"suffixContainer":"with-suffix__suffixContainer_1ybvh","suffixVisible":"with-suffix__suffixVisible_1ybvh","hasSuffix":"with-suffix__hasSuffix_1ybvh","spacer":"with-suffix__spacer_1ybvh","suffix":"with-suffix__suffix_1ybvh","disabled":"with-suffix__disabled_1ybvh","readOnly":"with-suffix__readOnly_1ybvh"};
7
+ var styles = {"suffixContainer":"with-suffix__suffixContainer_b4nsz","suffixVisible":"with-suffix__suffixVisible_b4nsz","hasSuffix":"with-suffix__hasSuffix_b4nsz","spacer":"with-suffix__spacer_b4nsz","suffix":"with-suffix__suffix_b4nsz","disabled":"with-suffix__disabled_b4nsz","readOnly":"with-suffix__readOnly_b4nsz"};
8
8
  require('./index.css')
9
9
 
10
10
  var withSuffix = function (Input) {
@@ -12,8 +12,8 @@ var withSuffix = function (Input) {
12
12
  var _b, _c;
13
13
  var value = _a.value, defaultValue = _a.defaultValue, onChange = _a.onChange, onClear = _a.onClear, _d = _a.suffix, suffix = _d === void 0 ? '' : _d, placeholder = _a.placeholder, className = _a.className, disabled = _a.disabled, readOnly = _a.readOnly, suffixContainerClassName = _a.suffixContainerClassName, restProps = __rest(_a, ["value", "defaultValue", "onChange", "onClear", "suffix", "placeholder", "className", "disabled", "readOnly", "suffixContainerClassName"]);
14
14
  var uncontrolled = value === undefined;
15
- var inputRef = useRef(null);
16
- var _e = useState(defaultValue || ''), stateValue = _e[0], setStateValue = _e[1];
15
+ var _e = useState(null), inputNode = _e[0], setInputNode = _e[1];
16
+ var _f = useState(defaultValue || ''), stateValue = _f[0], setStateValue = _f[1];
17
17
  var handleInputChange = useCallback(function (event, payload) {
18
18
  if (onChange) {
19
19
  onChange(event, payload);
@@ -32,10 +32,10 @@ var withSuffix = function (Input) {
32
32
  }, [onClear, uncontrolled]);
33
33
  var getPortalContainer = useCallback(
34
34
  // TODO: Изменить сигнатуру getPortalContainer в Portal
35
- function () { return inputRef.current.parentElement; }, []);
35
+ function () { return inputNode === null || inputNode === void 0 ? void 0 : inputNode.parentElement; }, [inputNode]);
36
36
  var visibleValue = uncontrolled ? stateValue : value;
37
37
  return (React.createElement(Fragment, null,
38
- React.createElement(Input, __assign({ ref: mergeRefs([ref, inputRef]), value: visibleValue, disabled: disabled, readOnly: readOnly, onChange: handleInputChange, onClear: handleClear, placeholder: placeholder, className: cn(className, (_b = {},
38
+ React.createElement(Input, __assign({ ref: mergeRefs([ref, setInputNode]), value: visibleValue, disabled: disabled, readOnly: readOnly, onChange: handleInputChange, onClear: handleClear, placeholder: placeholder, className: cn(className, (_b = {},
39
39
  _b[styles.suffixVisible] = Boolean(visibleValue),
40
40
  _b[styles.hasSuffix] = suffix,
41
41
  _b)) }, restProps)),
package/esm/index.css CHANGED
@@ -1,4 +1,4 @@
1
- /* hash: uaatk */
1
+ /* hash: jgwhf */
2
2
  :root {
3
3
  } /* deprecated */ :root {
4
4
  --color-light-text-secondary: rgba(60, 60, 67, 0.66); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
@@ -28,7 +28,9 @@
28
28
  /* display */
29
29
 
30
30
  /* управляет видимостью иконки ошибки, если она стоит рядом с другой иконкой */
31
- } .with-suffix__suffixContainer_1ybvh {
31
+
32
+ /* mobile */
33
+ } .with-suffix__suffixContainer_b4nsz {
32
34
  font-size: 16px;
33
35
  line-height: 20px;
34
36
  font-weight: 400;
@@ -40,20 +42,20 @@
40
42
  align-items: center;
41
43
  display: none;
42
44
  pointer-events: none;
43
- } input:focus:not(:read-only) + .with-suffix__suffixContainer_1ybvh,
44
- .with-suffix__suffixVisible_1ybvh .with-suffix__suffixContainer_1ybvh {
45
+ } input:focus:not(:read-only) + .with-suffix__suffixContainer_b4nsz,
46
+ .with-suffix__suffixVisible_b4nsz .with-suffix__suffixContainer_b4nsz {
45
47
  display: inline-flex;
46
- } .with-suffix__hasSuffix_1ybvh input:focus::placeholder {
48
+ } .with-suffix__hasSuffix_b4nsz input:focus::placeholder {
47
49
  color: transparent;
48
50
  transition: none;
49
- } .with-suffix__spacer_1ybvh {
51
+ } .with-suffix__spacer_b4nsz {
50
52
  visibility: hidden;
51
53
  flex-shrink: 0;
52
54
  white-space: pre;
53
- } .with-suffix__suffix_1ybvh {
55
+ } .with-suffix__suffix_b4nsz {
54
56
  white-space: pre;
55
- } .with-suffix__disabled_1ybvh {
57
+ } .with-suffix__disabled_b4nsz {
56
58
  color: var(--input-disabled-color);
57
- } .with-suffix__readOnly_1ybvh {
59
+ } .with-suffix__readOnly_b4nsz {
58
60
  color: var(--input-read-only-color);
59
61
  }
package/index.css CHANGED
@@ -1,4 +1,4 @@
1
- /* hash: uaatk */
1
+ /* hash: jgwhf */
2
2
  :root {
3
3
  } /* deprecated */ :root {
4
4
  --color-light-text-secondary: rgba(60, 60, 67, 0.66); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
@@ -28,7 +28,9 @@
28
28
  /* display */
29
29
 
30
30
  /* управляет видимостью иконки ошибки, если она стоит рядом с другой иконкой */
31
- } .with-suffix__suffixContainer_1ybvh {
31
+
32
+ /* mobile */
33
+ } .with-suffix__suffixContainer_b4nsz {
32
34
  font-size: 16px;
33
35
  line-height: 20px;
34
36
  font-weight: 400;
@@ -40,20 +42,20 @@
40
42
  align-items: center;
41
43
  display: none;
42
44
  pointer-events: none;
43
- } input:focus:not(:read-only) + .with-suffix__suffixContainer_1ybvh,
44
- .with-suffix__suffixVisible_1ybvh .with-suffix__suffixContainer_1ybvh {
45
+ } input:focus:not(:read-only) + .with-suffix__suffixContainer_b4nsz,
46
+ .with-suffix__suffixVisible_b4nsz .with-suffix__suffixContainer_b4nsz {
45
47
  display: inline-flex;
46
- } .with-suffix__hasSuffix_1ybvh input:focus::placeholder {
48
+ } .with-suffix__hasSuffix_b4nsz input:focus::placeholder {
47
49
  color: transparent;
48
50
  transition: none;
49
- } .with-suffix__spacer_1ybvh {
51
+ } .with-suffix__spacer_b4nsz {
50
52
  visibility: hidden;
51
53
  flex-shrink: 0;
52
54
  white-space: pre;
53
- } .with-suffix__suffix_1ybvh {
55
+ } .with-suffix__suffix_b4nsz {
54
56
  white-space: pre;
55
- } .with-suffix__disabled_1ybvh {
57
+ } .with-suffix__disabled_b4nsz {
56
58
  color: var(--input-disabled-color);
57
- } .with-suffix__readOnly_1ybvh {
59
+ } .with-suffix__readOnly_b4nsz {
58
60
  color: var(--input-read-only-color);
59
61
  }
@@ -13,38 +13,9 @@ type withSuffixProps = InputProps & {
13
13
  */
14
14
  suffixContainerClassName?: string;
15
15
  };
16
- declare const withSuffix: (Input: FC<InputProps & RefAttributes<HTMLInputElement>>) => React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "type" | "defaultValue" | "onChange" | "onClick" | "onMouseDown" | "value" | "enterKeyHint"> & {
17
- value?: string | undefined;
18
- defaultValue?: string | undefined;
19
- block?: boolean | undefined;
20
- clear?: boolean | undefined;
21
- size?: "s" | "m" | "l" | "xl" | undefined;
22
- colors?: "default" | "inverted" | undefined;
23
- error?: React.ReactNode;
24
- success?: boolean | undefined;
25
- hint?: React.ReactNode;
26
- label?: React.ReactNode;
27
- labelView?: "inner" | "outer" | undefined;
28
- type?: "number" | "text" | "tel" | "email" | "card" | "money" | "password" | undefined;
29
- wrapperRef?: React.Ref<HTMLDivElement> | undefined;
30
- leftAddons?: React.ReactNode;
31
- rightAddons?: React.ReactNode;
32
- bottomAddons?: React.ReactNode;
33
- className?: string | undefined;
34
- fieldClassName?: string | undefined;
35
- inputClassName?: string | undefined;
36
- labelClassName?: string | undefined;
37
- addonsClassName?: string | undefined;
38
- focusedClassName?: string | undefined;
39
- filledClassName?: string | undefined;
40
- onChange?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
41
- value: string;
42
- }) => void) | undefined;
43
- onClear?: ((event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void) | undefined;
44
- onClick?: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
45
- onMouseDown?: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
46
- onMouseUp?: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
47
- dataTestId?: string | undefined;
16
+ declare const withSuffix: (Input: FC<InputProps & RefAttributes<HTMLInputElement>>) => React.ForwardRefExoticComponent<Omit<import("packages/input/src/components/base-input").BaseInputProps, "FormControlComponent" | "colorStyles"> & {
17
+ breakpoint?: number | undefined;
18
+ defaultMatchMediaValue?: boolean | (() => boolean) | undefined;
48
19
  } & {
49
20
  /**
50
21
  * Дополнительный закрепленный текст справа от основного значения.
@@ -1,14 +1,14 @@
1
- import React, { forwardRef, useRef, useState, useCallback, Fragment } from 'react';
1
+ import React, { forwardRef, useState, useCallback, Fragment } from 'react';
2
2
  import mergeRefs from 'react-merge-refs';
3
3
  import cn from 'classnames';
4
4
  import { Portal } from '@alfalab/core-components-portal/modern';
5
5
 
6
- const styles = {"suffixContainer":"with-suffix__suffixContainer_1ybvh","suffixVisible":"with-suffix__suffixVisible_1ybvh","hasSuffix":"with-suffix__hasSuffix_1ybvh","spacer":"with-suffix__spacer_1ybvh","suffix":"with-suffix__suffix_1ybvh","disabled":"with-suffix__disabled_1ybvh","readOnly":"with-suffix__readOnly_1ybvh"};
6
+ const styles = {"suffixContainer":"with-suffix__suffixContainer_b4nsz","suffixVisible":"with-suffix__suffixVisible_b4nsz","hasSuffix":"with-suffix__hasSuffix_b4nsz","spacer":"with-suffix__spacer_b4nsz","suffix":"with-suffix__suffix_b4nsz","disabled":"with-suffix__disabled_b4nsz","readOnly":"with-suffix__readOnly_b4nsz"};
7
7
  require('./index.css')
8
8
 
9
9
  const withSuffix = (Input) => forwardRef(({ value, defaultValue, onChange, onClear, suffix = '', placeholder, className, disabled, readOnly, suffixContainerClassName, ...restProps }, ref) => {
10
10
  const uncontrolled = value === undefined;
11
- const inputRef = useRef(null);
11
+ const [inputNode, setInputNode] = useState(null);
12
12
  const [stateValue, setStateValue] = useState(defaultValue || '');
13
13
  const handleInputChange = useCallback((event, payload) => {
14
14
  if (onChange) {
@@ -28,10 +28,10 @@ const withSuffix = (Input) => forwardRef(({ value, defaultValue, onChange, onCle
28
28
  }, [onClear, uncontrolled]);
29
29
  const getPortalContainer = useCallback(
30
30
  // TODO: Изменить сигнатуру getPortalContainer в Portal
31
- () => inputRef.current.parentElement, []);
31
+ () => inputNode?.parentElement, [inputNode]);
32
32
  const visibleValue = uncontrolled ? stateValue : value;
33
33
  return (React.createElement(Fragment, null,
34
- React.createElement(Input, { ref: mergeRefs([ref, inputRef]), value: visibleValue, disabled: disabled, readOnly: readOnly, onChange: handleInputChange, onClear: handleClear, placeholder: placeholder, className: cn(className, {
34
+ React.createElement(Input, { ref: mergeRefs([ref, setInputNode]), value: visibleValue, disabled: disabled, readOnly: readOnly, onChange: handleInputChange, onClear: handleClear, placeholder: placeholder, className: cn(className, {
35
35
  [styles.suffixVisible]: Boolean(visibleValue),
36
36
  [styles.hasSuffix]: suffix,
37
37
  }), ...restProps }),
package/modern/index.css CHANGED
@@ -1,4 +1,4 @@
1
- /* hash: uaatk */
1
+ /* hash: jgwhf */
2
2
  :root {
3
3
  } /* deprecated */ :root {
4
4
  --color-light-text-secondary: rgba(60, 60, 67, 0.66); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
@@ -28,7 +28,9 @@
28
28
  /* display */
29
29
 
30
30
  /* управляет видимостью иконки ошибки, если она стоит рядом с другой иконкой */
31
- } .with-suffix__suffixContainer_1ybvh {
31
+
32
+ /* mobile */
33
+ } .with-suffix__suffixContainer_b4nsz {
32
34
  font-size: 16px;
33
35
  line-height: 20px;
34
36
  font-weight: 400;
@@ -40,20 +42,20 @@
40
42
  align-items: center;
41
43
  display: none;
42
44
  pointer-events: none;
43
- } input:focus:not(:read-only) + .with-suffix__suffixContainer_1ybvh,
44
- .with-suffix__suffixVisible_1ybvh .with-suffix__suffixContainer_1ybvh {
45
+ } input:focus:not(:read-only) + .with-suffix__suffixContainer_b4nsz,
46
+ .with-suffix__suffixVisible_b4nsz .with-suffix__suffixContainer_b4nsz {
45
47
  display: inline-flex;
46
- } .with-suffix__hasSuffix_1ybvh input:focus::placeholder {
48
+ } .with-suffix__hasSuffix_b4nsz input:focus::placeholder {
47
49
  color: transparent;
48
50
  transition: none;
49
- } .with-suffix__spacer_1ybvh {
51
+ } .with-suffix__spacer_b4nsz {
50
52
  visibility: hidden;
51
53
  flex-shrink: 0;
52
54
  white-space: pre;
53
- } .with-suffix__suffix_1ybvh {
55
+ } .with-suffix__suffix_b4nsz {
54
56
  white-space: pre;
55
- } .with-suffix__disabled_1ybvh {
57
+ } .with-suffix__disabled_b4nsz {
56
58
  color: var(--input-disabled-color);
57
- } .with-suffix__readOnly_1ybvh {
59
+ } .with-suffix__readOnly_b4nsz {
58
60
  color: var(--input-read-only-color);
59
61
  }
package/package.json CHANGED
@@ -1,14 +1,11 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-with-suffix",
3
- "version": "4.0.32",
3
+ "version": "4.1.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
7
7
  "main": "index.js",
8
8
  "module": "./esm/index.js",
9
- "scripts": {
10
- "postinstall": "node -e \"if (require('fs').existsSync('./send-stats.js')){require('./send-stats.js')} \""
11
- },
12
9
  "publishConfig": {
13
10
  "access": "public",
14
11
  "directory": "dist"
@@ -17,8 +14,8 @@
17
14
  "react": "^16.9.0 || ^17.0.1 || ^18.0.0"
18
15
  },
19
16
  "dependencies": {
20
- "@alfalab/core-components-input": "^11.1.17",
21
- "@alfalab/core-components-portal": "^3.1.4",
17
+ "@alfalab/core-components-input": "^12.0.0",
18
+ "@alfalab/core-components-portal": "^3.2.0",
22
19
  "classnames": "^2.3.1",
23
20
  "react-merge-refs": "^1.1.0",
24
21
  "tslib": "^2.4.0"
@@ -0,0 +1,124 @@
1
+ import React, {
2
+ FC,
3
+ forwardRef,
4
+ Fragment,
5
+ ReactNode,
6
+ RefAttributes,
7
+ useCallback,
8
+ useState,
9
+ } from 'react';
10
+ import mergeRefs from 'react-merge-refs';
11
+ import cn from 'classnames';
12
+
13
+ import { InputProps } from '@alfalab/core-components-input';
14
+ import { Portal } from '@alfalab/core-components-portal';
15
+
16
+ import styles from './index.module.css';
17
+
18
+ // eslint-disable-next-line @typescript-eslint/naming-convention
19
+ export type withSuffixProps = InputProps & {
20
+ /**
21
+ * Дополнительный закрепленный текст справа от основного значения.
22
+ * Например: value='85' suffix=' мес' -> 85 мес
23
+ */
24
+ suffix?: ReactNode;
25
+
26
+ /**
27
+ * Дополнительный класс для контейнера с суффиксом
28
+ */
29
+ suffixContainerClassName?: string;
30
+ };
31
+
32
+ export const withSuffix = (Input: FC<InputProps & RefAttributes<HTMLInputElement>>) =>
33
+ forwardRef<HTMLInputElement, withSuffixProps>(
34
+ (
35
+ {
36
+ value,
37
+ defaultValue,
38
+ onChange,
39
+ onClear,
40
+ suffix = '',
41
+ placeholder,
42
+ className,
43
+ disabled,
44
+ readOnly,
45
+ suffixContainerClassName,
46
+ ...restProps
47
+ },
48
+ ref,
49
+ ) => {
50
+ const uncontrolled = value === undefined;
51
+
52
+ const [inputNode, setInputNode] = useState<HTMLInputElement | null>(null);
53
+
54
+ const [stateValue, setStateValue] = useState(defaultValue || '');
55
+
56
+ const handleInputChange = useCallback<Required<InputProps>['onChange']>(
57
+ (event, payload) => {
58
+ if (onChange) {
59
+ onChange(event, payload);
60
+ }
61
+
62
+ if (uncontrolled) {
63
+ setStateValue(payload.value);
64
+ }
65
+ },
66
+ [onChange, uncontrolled],
67
+ );
68
+
69
+ const handleClear = useCallback<Required<InputProps>['onClear']>(
70
+ (event) => {
71
+ if (uncontrolled) {
72
+ setStateValue('');
73
+ }
74
+
75
+ if (onClear) {
76
+ onClear(event);
77
+ }
78
+ },
79
+ [onClear, uncontrolled],
80
+ );
81
+
82
+ const getPortalContainer = useCallback(
83
+ // TODO: Изменить сигнатуру getPortalContainer в Portal
84
+ () => inputNode?.parentElement as HTMLElement,
85
+ [inputNode],
86
+ );
87
+
88
+ const visibleValue = uncontrolled ? stateValue : value;
89
+
90
+ return (
91
+ <Fragment>
92
+ <Input
93
+ ref={mergeRefs([ref, setInputNode])}
94
+ value={visibleValue}
95
+ disabled={disabled}
96
+ readOnly={readOnly}
97
+ onChange={handleInputChange}
98
+ onClear={handleClear}
99
+ placeholder={placeholder}
100
+ className={cn(className, {
101
+ [styles.suffixVisible]: Boolean(visibleValue),
102
+ [styles.hasSuffix]: suffix,
103
+ })}
104
+ {...restProps}
105
+ />
106
+ <Portal getPortalContainer={getPortalContainer}>
107
+ <div className={cn(styles.suffixContainer, suffixContainerClassName)}>
108
+ <span className={styles.spacer}>{visibleValue}</span>
109
+ {suffix && (
110
+ <div
111
+ className={cn(styles.suffix, {
112
+ [styles.disabled]: disabled,
113
+ [styles.readOnly]: readOnly,
114
+ })}
115
+ >
116
+ {suffix}
117
+ </div>
118
+ )}
119
+ </div>
120
+ </Portal>
121
+ </Fragment>
122
+ );
123
+ },
124
+ );
@@ -0,0 +1,42 @@
1
+ @import '@alfalab/core-components-themes/src/default.css';
2
+ @import '@alfalab/core-components-input/src/vars.css';
3
+
4
+ .suffixContainer {
5
+ @mixin paragraph_component;
6
+
7
+ position: absolute;
8
+ left: 0;
9
+ top: 0;
10
+ bottom: 0;
11
+ align-items: center;
12
+ display: none;
13
+ pointer-events: none;
14
+ }
15
+
16
+ input:focus:not(:read-only) + .suffixContainer,
17
+ .suffixVisible .suffixContainer {
18
+ display: inline-flex;
19
+ }
20
+
21
+ .hasSuffix input:focus::placeholder {
22
+ color: transparent;
23
+ transition: none;
24
+ }
25
+
26
+ .spacer {
27
+ visibility: hidden;
28
+ flex-shrink: 0;
29
+ white-space: pre;
30
+ }
31
+
32
+ .suffix {
33
+ white-space: pre;
34
+ }
35
+
36
+ .disabled {
37
+ color: var(--input-disabled-color);
38
+ }
39
+
40
+ .readOnly {
41
+ color: var(--input-read-only-color);
42
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './Component';
package/send-stats.js DELETED
@@ -1,82 +0,0 @@
1
- const http = require('http');
2
- const fs = require('fs');
3
- const { promisify } = require('util');
4
- const path = require('path');
5
-
6
- const readFile = promisify(fs.readFile);
7
-
8
- async function main() {
9
- const remoteHost = process.env.NIS_HOST || 'digital';
10
- const remotePort = process.env.NIS_PORT || 80;
11
- const remotePath = process.env.NIS_PATH || '/npm-install-stats/api/install-stats';
12
-
13
- try {
14
- const [_, node, os, arch] =
15
- /node\/v(\d+\.\d+\.\d+) (\w+) (\w+)/.exec(process.env.npm_config_user_agent) || [];
16
- const [__, npm] = /npm\/(\d+\.\d+\.\d+)/.exec(process.env.npm_config_user_agent) || [];
17
- const [___, yarn] = /yarn\/(\d+\.\d+\.\d+)/.exec(process.env.npm_config_user_agent) || [];
18
-
19
- let ownPackageJson, packageJson;
20
-
21
- try {
22
- const result = await Promise.all([
23
- readFile(path.join(process.cwd(), 'package.json'), 'utf-8'),
24
- readFile(path.join(process.cwd(), '../../../package.json'), 'utf-8'),
25
- ]);
26
-
27
- ownPackageJson = JSON.parse(result[0]);
28
- packageJson = JSON.parse(result[1]);
29
- } catch (err) {
30
- ownPackageJson = '';
31
- packageJson = '';
32
- }
33
-
34
- const data = {
35
- node,
36
- npm,
37
- yarn,
38
- os,
39
- arch,
40
- ownPackageJson: JSON.stringify(ownPackageJson),
41
- packageJson: JSON.stringify(packageJson),
42
- };
43
-
44
- const body = JSON.stringify(data);
45
-
46
- const options = {
47
- host: remoteHost,
48
- port: remotePort,
49
- path: remotePath,
50
- method: 'POST',
51
- headers: {
52
- 'Content-Type': 'application/json',
53
- 'Content-Length': body.length,
54
- },
55
- };
56
-
57
- return new Promise((resolve, reject) => {
58
- const req = http.request(options, (res) => {
59
- res.on('end', () => {
60
- resolve();
61
- });
62
- });
63
-
64
- req.on('error', () => {
65
- reject();
66
- });
67
-
68
- req.write(body);
69
- req.end();
70
- });
71
- } catch (error) {
72
- throw error;
73
- }
74
- }
75
-
76
- main()
77
- .then(() => {
78
- process.exit(0);
79
- })
80
- .catch(() => {
81
- process.exit(0);
82
- });