@alfalab/core-components-with-suffix 4.1.37 → 4.2.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.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_b3bhw","suffixVisible":"with-suffix__suffixVisible_b3bhw","hasSuffix":"with-suffix__hasSuffix_b3bhw","spacer":"with-suffix__spacer_b3bhw","suffix":"with-suffix__suffix_b3bhw","disabled":"with-suffix__disabled_b3bhw","inverted":"with-suffix__inverted_b3bhw","readOnly":"with-suffix__readOnly_b3bhw"};
17
+ var styles = {"suffixContainer":"with-suffix__suffixContainer_br4tn","suffixVisible":"with-suffix__suffixVisible_br4tn","hasSuffix":"with-suffix__hasSuffix_br4tn","spacer":"with-suffix__spacer_br4tn","suffix":"with-suffix__suffix_br4tn","disabled":"with-suffix__disabled_br4tn","inverted":"with-suffix__inverted_br4tn","readOnly":"with-suffix__readOnly_br4tn"};
18
18
  require('./index.css')
19
19
 
20
20
  var withSuffix = function (Input) {
package/esm/Component.js CHANGED
@@ -4,7 +4,7 @@ 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_b3bhw","suffixVisible":"with-suffix__suffixVisible_b3bhw","hasSuffix":"with-suffix__hasSuffix_b3bhw","spacer":"with-suffix__spacer_b3bhw","suffix":"with-suffix__suffix_b3bhw","disabled":"with-suffix__disabled_b3bhw","inverted":"with-suffix__inverted_b3bhw","readOnly":"with-suffix__readOnly_b3bhw"};
7
+ var styles = {"suffixContainer":"with-suffix__suffixContainer_br4tn","suffixVisible":"with-suffix__suffixVisible_br4tn","hasSuffix":"with-suffix__hasSuffix_br4tn","spacer":"with-suffix__spacer_br4tn","suffix":"with-suffix__suffix_br4tn","disabled":"with-suffix__disabled_br4tn","inverted":"with-suffix__inverted_br4tn","readOnly":"with-suffix__readOnly_br4tn"};
8
8
  require('./index.css')
9
9
 
10
10
  var withSuffix = function (Input) {
package/esm/index.css CHANGED
@@ -1,4 +1,4 @@
1
- /* hash: 1jarm */
1
+ /* hash: 46dz2 */
2
2
  :root { /* 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 */ /* 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 */
3
3
  } /* deprecated */ :root {
4
4
  --color-light-text-tertiary: rgba(5, 8, 29, 0.38);
@@ -35,7 +35,7 @@
35
35
  /* display */
36
36
 
37
37
  /* управляет видимостью иконки ошибки, если она стоит рядом с другой иконкой */
38
- } .with-suffix__suffixContainer_b3bhw {
38
+ } .with-suffix__suffixContainer_br4tn {
39
39
  font-size: 16px;
40
40
  line-height: 20px;
41
41
  font-weight: 400;
@@ -47,24 +47,24 @@
47
47
  align-items: center;
48
48
  display: none;
49
49
  pointer-events: none;
50
- } input:focus:not(:read-only) + .with-suffix__suffixContainer_b3bhw,
51
- .with-suffix__suffixVisible_b3bhw .with-suffix__suffixContainer_b3bhw {
50
+ } input:focus:not(:read-only) + .with-suffix__suffixContainer_br4tn,
51
+ .with-suffix__suffixVisible_br4tn .with-suffix__suffixContainer_br4tn {
52
52
  display: inline-flex;
53
- } .with-suffix__hasSuffix_b3bhw input:focus::placeholder {
53
+ } .with-suffix__hasSuffix_br4tn input:focus::placeholder {
54
54
  color: transparent;
55
55
  transition: none;
56
- } .with-suffix__spacer_b3bhw {
56
+ } .with-suffix__spacer_br4tn {
57
57
  visibility: hidden;
58
58
  flex-shrink: 0;
59
59
  white-space: pre;
60
- } .with-suffix__suffix_b3bhw {
60
+ } .with-suffix__suffix_br4tn {
61
61
  white-space: pre;
62
- } .with-suffix__disabled_b3bhw {
62
+ } .with-suffix__disabled_br4tn {
63
63
  color: var(--input-disabled-color)
64
- } .with-suffix__disabled_b3bhw.with-suffix__inverted_b3bhw {
64
+ } .with-suffix__disabled_br4tn.with-suffix__inverted_br4tn {
65
65
  color: var(--input-inverted-disabled-color);
66
- } .with-suffix__readOnly_b3bhw {
66
+ } .with-suffix__readOnly_br4tn {
67
67
  color: var(--input-read-only-color)
68
- } .with-suffix__readOnly_b3bhw.with-suffix__inverted_b3bhw {
68
+ } .with-suffix__readOnly_br4tn.with-suffix__inverted_br4tn {
69
69
  color: var(--input-inverted-read-only-color);
70
70
  }
package/index.css CHANGED
@@ -1,4 +1,4 @@
1
- /* hash: 1jarm */
1
+ /* hash: 46dz2 */
2
2
  :root { /* 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 */ /* 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 */
3
3
  } /* deprecated */ :root {
4
4
  --color-light-text-tertiary: rgba(5, 8, 29, 0.38);
@@ -35,7 +35,7 @@
35
35
  /* display */
36
36
 
37
37
  /* управляет видимостью иконки ошибки, если она стоит рядом с другой иконкой */
38
- } .with-suffix__suffixContainer_b3bhw {
38
+ } .with-suffix__suffixContainer_br4tn {
39
39
  font-size: 16px;
40
40
  line-height: 20px;
41
41
  font-weight: 400;
@@ -47,24 +47,24 @@
47
47
  align-items: center;
48
48
  display: none;
49
49
  pointer-events: none;
50
- } input:focus:not(:read-only) + .with-suffix__suffixContainer_b3bhw,
51
- .with-suffix__suffixVisible_b3bhw .with-suffix__suffixContainer_b3bhw {
50
+ } input:focus:not(:read-only) + .with-suffix__suffixContainer_br4tn,
51
+ .with-suffix__suffixVisible_br4tn .with-suffix__suffixContainer_br4tn {
52
52
  display: inline-flex;
53
- } .with-suffix__hasSuffix_b3bhw input:focus::placeholder {
53
+ } .with-suffix__hasSuffix_br4tn input:focus::placeholder {
54
54
  color: transparent;
55
55
  transition: none;
56
- } .with-suffix__spacer_b3bhw {
56
+ } .with-suffix__spacer_br4tn {
57
57
  visibility: hidden;
58
58
  flex-shrink: 0;
59
59
  white-space: pre;
60
- } .with-suffix__suffix_b3bhw {
60
+ } .with-suffix__suffix_br4tn {
61
61
  white-space: pre;
62
- } .with-suffix__disabled_b3bhw {
62
+ } .with-suffix__disabled_br4tn {
63
63
  color: var(--input-disabled-color)
64
- } .with-suffix__disabled_b3bhw.with-suffix__inverted_b3bhw {
64
+ } .with-suffix__disabled_br4tn.with-suffix__inverted_br4tn {
65
65
  color: var(--input-inverted-disabled-color);
66
- } .with-suffix__readOnly_b3bhw {
66
+ } .with-suffix__readOnly_br4tn {
67
67
  color: var(--input-read-only-color)
68
- } .with-suffix__readOnly_b3bhw.with-suffix__inverted_b3bhw {
68
+ } .with-suffix__readOnly_br4tn.with-suffix__inverted_br4tn {
69
69
  color: var(--input-inverted-read-only-color);
70
70
  }
@@ -3,7 +3,7 @@ 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_b3bhw","suffixVisible":"with-suffix__suffixVisible_b3bhw","hasSuffix":"with-suffix__hasSuffix_b3bhw","spacer":"with-suffix__spacer_b3bhw","suffix":"with-suffix__suffix_b3bhw","disabled":"with-suffix__disabled_b3bhw","inverted":"with-suffix__inverted_b3bhw","readOnly":"with-suffix__readOnly_b3bhw"};
6
+ const styles = {"suffixContainer":"with-suffix__suffixContainer_br4tn","suffixVisible":"with-suffix__suffixVisible_br4tn","hasSuffix":"with-suffix__hasSuffix_br4tn","spacer":"with-suffix__spacer_br4tn","suffix":"with-suffix__suffix_br4tn","disabled":"with-suffix__disabled_br4tn","inverted":"with-suffix__inverted_br4tn","readOnly":"with-suffix__readOnly_br4tn"};
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) => {
package/modern/index.css CHANGED
@@ -1,4 +1,4 @@
1
- /* hash: 1jarm */
1
+ /* hash: 46dz2 */
2
2
  :root { /* 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 */ /* 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 */
3
3
  } /* deprecated */ :root {
4
4
  --color-light-text-tertiary: rgba(5, 8, 29, 0.38);
@@ -35,7 +35,7 @@
35
35
  /* display */
36
36
 
37
37
  /* управляет видимостью иконки ошибки, если она стоит рядом с другой иконкой */
38
- } .with-suffix__suffixContainer_b3bhw {
38
+ } .with-suffix__suffixContainer_br4tn {
39
39
  font-size: 16px;
40
40
  line-height: 20px;
41
41
  font-weight: 400;
@@ -47,24 +47,24 @@
47
47
  align-items: center;
48
48
  display: none;
49
49
  pointer-events: none;
50
- } input:focus:not(:read-only) + .with-suffix__suffixContainer_b3bhw,
51
- .with-suffix__suffixVisible_b3bhw .with-suffix__suffixContainer_b3bhw {
50
+ } input:focus:not(:read-only) + .with-suffix__suffixContainer_br4tn,
51
+ .with-suffix__suffixVisible_br4tn .with-suffix__suffixContainer_br4tn {
52
52
  display: inline-flex;
53
- } .with-suffix__hasSuffix_b3bhw input:focus::placeholder {
53
+ } .with-suffix__hasSuffix_br4tn input:focus::placeholder {
54
54
  color: transparent;
55
55
  transition: none;
56
- } .with-suffix__spacer_b3bhw {
56
+ } .with-suffix__spacer_br4tn {
57
57
  visibility: hidden;
58
58
  flex-shrink: 0;
59
59
  white-space: pre;
60
- } .with-suffix__suffix_b3bhw {
60
+ } .with-suffix__suffix_br4tn {
61
61
  white-space: pre;
62
- } .with-suffix__disabled_b3bhw {
62
+ } .with-suffix__disabled_br4tn {
63
63
  color: var(--input-disabled-color)
64
- } .with-suffix__disabled_b3bhw.with-suffix__inverted_b3bhw {
64
+ } .with-suffix__disabled_br4tn.with-suffix__inverted_br4tn {
65
65
  color: var(--input-inverted-disabled-color);
66
- } .with-suffix__readOnly_b3bhw {
66
+ } .with-suffix__readOnly_br4tn {
67
67
  color: var(--input-read-only-color)
68
- } .with-suffix__readOnly_b3bhw.with-suffix__inverted_b3bhw {
68
+ } .with-suffix__readOnly_br4tn.with-suffix__inverted_br4tn {
69
69
  color: var(--input-inverted-read-only-color);
70
70
  }
@@ -0,0 +1,30 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { FC, ReactNode, RefAttributes } from "react";
4
+ import { InputProps } from "@alfalab/core-components-input";
5
+ type withSuffixProps = InputProps & {
6
+ /**
7
+ * Дополнительный закрепленный текст справа от основного значения.
8
+ * Например: value='85' suffix=' мес' -> 85 мес
9
+ */
10
+ suffix?: ReactNode;
11
+ /**
12
+ * Дополнительный класс для контейнера с суффиксом
13
+ */
14
+ suffixContainerClassName?: string;
15
+ };
16
+ declare const withSuffix: (Input: FC<InputProps & RefAttributes<HTMLInputElement>>) => React.ForwardRefExoticComponent<Omit<import("@alfalab/core-components-input/components/base-input").BaseInputProps, "FormControlComponent"> & {
17
+ breakpoint?: number | undefined;
18
+ defaultMatchMediaValue?: boolean | (() => boolean) | undefined;
19
+ } & {
20
+ /**
21
+ * Дополнительный закрепленный текст справа от основного значения.
22
+ * Например: value='85' suffix=' мес' -> 85 мес
23
+ */
24
+ suffix?: ReactNode;
25
+ /**
26
+ * Дополнительный класс для контейнера с суффиксом
27
+ */
28
+ suffixContainerClassName?: string | undefined;
29
+ } & React.RefAttributes<HTMLInputElement>>;
30
+ export { withSuffixProps, withSuffix };
@@ -0,0 +1,47 @@
1
+ import React, { forwardRef, useState, useCallback, Fragment } from 'react';
2
+ import mergeRefs from 'react-merge-refs';
3
+ import cn from 'classnames';
4
+ import { Portal } from '@alfalab/core-components-portal/moderncssm';
5
+ import styles from './index.module.css';
6
+
7
+ const withSuffix = (Input) => forwardRef(({ value, defaultValue, onChange, onClear, suffix = '', placeholder, className, disabled, readOnly, suffixContainerClassName, ...restProps }, ref) => {
8
+ const uncontrolled = value === undefined;
9
+ const [inputNode, setInputNode] = useState(null);
10
+ const [stateValue, setStateValue] = useState(defaultValue || '');
11
+ const handleInputChange = useCallback((event, payload) => {
12
+ if (onChange) {
13
+ onChange(event, payload);
14
+ }
15
+ if (uncontrolled) {
16
+ setStateValue(payload.value);
17
+ }
18
+ }, [onChange, uncontrolled]);
19
+ const handleClear = useCallback((event) => {
20
+ if (uncontrolled) {
21
+ setStateValue('');
22
+ }
23
+ if (onClear) {
24
+ onClear(event);
25
+ }
26
+ }, [onClear, uncontrolled]);
27
+ const getPortalContainer = useCallback(
28
+ // TODO: Изменить сигнатуру getPortalContainer в Portal
29
+ () => (inputNode?.parentElement || null), [inputNode]);
30
+ const visibleValue = uncontrolled ? stateValue : value;
31
+ const isInverted = restProps.colors === 'inverted';
32
+ return (React.createElement(Fragment, null,
33
+ React.createElement(Input, { ref: mergeRefs([ref, setInputNode]), value: visibleValue, disabled: disabled, readOnly: readOnly, onChange: handleInputChange, onClear: handleClear, placeholder: placeholder, className: cn(className, {
34
+ [styles.suffixVisible]: Boolean(visibleValue),
35
+ [styles.hasSuffix]: suffix,
36
+ }), ...restProps }),
37
+ React.createElement(Portal, { getPortalContainer: getPortalContainer },
38
+ React.createElement("div", { translate: 'no', className: cn(styles.suffixContainer, suffixContainerClassName) },
39
+ React.createElement("span", { className: styles.spacer }, visibleValue),
40
+ suffix && (React.createElement("div", { className: cn(styles.suffix, {
41
+ [styles.disabled]: disabled,
42
+ [styles.readOnly]: readOnly,
43
+ [styles.inverted]: isInverted,
44
+ }) }, suffix))))));
45
+ });
46
+
47
+ export { withSuffix };
@@ -0,0 +1 @@
1
+ export * from "./Component";
@@ -0,0 +1 @@
1
+ export { withSuffix } from './Component.js';
@@ -0,0 +1,58 @@
1
+ /* */
2
+ :root {
3
+
4
+ /* disabled */
5
+ --input-disabled-color: var(--color-light-text-tertiary);
6
+ --input-inverted-disabled-color: var(--color-light-text-tertiary-inverted);
7
+
8
+ /* read-only */
9
+ --input-read-only-color: var(--color-light-text-tertiary);
10
+ --input-inverted-read-only-color: var(--color-light-text-tertiary-inverted);
11
+
12
+ /* error */
13
+
14
+ /* display */
15
+
16
+ /* управляет видимостью иконки ошибки, если она стоит рядом с другой иконкой */
17
+ }
18
+ .suffixContainer {
19
+ font-size: 16px;
20
+ line-height: 20px;
21
+ font-weight: 400;
22
+
23
+ position: absolute;
24
+ left: 0;
25
+ top: 0;
26
+ bottom: 0;
27
+ align-items: center;
28
+ display: none;
29
+ pointer-events: none;
30
+ }
31
+ input:focus:not(:read-only) + .suffixContainer,
32
+ .suffixVisible .suffixContainer {
33
+ display: inline-flex;
34
+ }
35
+ .hasSuffix input:focus::placeholder {
36
+ color: transparent;
37
+ transition: none;
38
+ }
39
+ .spacer {
40
+ visibility: hidden;
41
+ flex-shrink: 0;
42
+ white-space: pre;
43
+ }
44
+ .suffix {
45
+ white-space: pre;
46
+ }
47
+ .disabled {
48
+ color: var(--input-disabled-color)
49
+ }
50
+ .disabled.inverted {
51
+ color: var(--input-inverted-disabled-color);
52
+ }
53
+ .readOnly {
54
+ color: var(--input-read-only-color)
55
+ }
56
+ .readOnly.inverted {
57
+ color: var(--input-inverted-read-only-color);
58
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-with-suffix",
3
- "version": "4.1.37",
3
+ "version": "4.2.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -14,12 +14,12 @@
14
14
  "react": "^16.9.0 || ^17.0.1 || ^18.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@alfalab/core-components-input": "^15.0.5",
17
+ "@alfalab/core-components-input": "^15.1.0",
18
18
  "@alfalab/core-components-portal": "^3.3.1",
19
19
  "classnames": "^2.3.1",
20
20
  "react-merge-refs": "^1.1.0",
21
21
  "tslib": "^2.4.0"
22
22
  },
23
- "themesVersion": "13.0.2",
24
- "varsVersion": "9.11.1"
23
+ "themesVersion": "13.1.0",
24
+ "varsVersion": "9.12.0"
25
25
  }
@@ -1,4 +1,4 @@
1
- @import '@alfalab/core-components-themes/src/default.css';
1
+ @import '@alfalab/core-components-vars/src/index.css';
2
2
  @import '@alfalab/core-components-input/src/vars.css';
3
3
 
4
4
  .suffixContainer {