@alfalab/core-components-slider-input 4.5.0 → 5.0.2

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.
@@ -0,0 +1,167 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { ChangeEvent, FC, ReactNode } from "react";
4
+ import { SliderProps } from "@alfalab/core-components-slider";
5
+ import { InputProps } from "@alfalab/core-components-input";
6
+ type SliderInputProps = Omit<InputProps, 'min' | 'max' | 'step' | 'value' | 'type' | 'onChange' | 'bottomAddons'> & {
7
+ /**
8
+ * Мин. допустимое число
9
+ */
10
+ min?: number;
11
+ /**
12
+ * Макс. допустимое число
13
+ */
14
+ max?: number;
15
+ /**
16
+ * Шаг (должен нацело делить отрезок между мин и макс)
17
+ */
18
+ step?: number;
19
+ /**
20
+ * Отображение подписей
21
+ * https://refreshless.com/nouislider/pips/
22
+ */
23
+ pips?: SliderProps['pips'];
24
+ /**
25
+ * Настройка шагов
26
+ * https://refreshless.com/nouislider/pips/#section-range
27
+ */
28
+ range?: SliderProps['range'];
29
+ /**
30
+ * Значение инпута
31
+ */
32
+ value?: number | string;
33
+ /**
34
+ * Значение слайдера
35
+ */
36
+ sliderValue?: number;
37
+ /**
38
+ * Дополнительная информация в правой части поля
39
+ */
40
+ info?: ReactNode;
41
+ /**
42
+ * Компонент поля ввода
43
+ */
44
+ Input?: FC<Omit<InputProps, 'onChange' | 'value'>>;
45
+ /**
46
+ * Кастомные пропсы для поля ввода
47
+ */
48
+ customInputProps?: Record<string, unknown>;
49
+ /**
50
+ * Класс для инпута
51
+ */
52
+ inputClassName?: string;
53
+ /**
54
+ * Класс для слайдера
55
+ */
56
+ sliderClassName?: string;
57
+ /**
58
+ * Обработчик изменения значения через слайдер или поле ввода
59
+ */
60
+ onChange?: (event: ChangeEvent<HTMLInputElement> | null, payload: {
61
+ value: number | '';
62
+ }) => void;
63
+ /**
64
+ * Обработчик ввода
65
+ */
66
+ onInputChange?: (event: ChangeEvent<HTMLInputElement>, payload: {
67
+ value: number | '';
68
+ }) => void;
69
+ /**
70
+ * Обработчик изменения слайдера
71
+ */
72
+ onSliderChange?: (payload: {
73
+ value: number;
74
+ }) => void;
75
+ /**
76
+ * Идентификатор для систем автоматизированного тестирования
77
+ */
78
+ dataTestId?: string;
79
+ };
80
+ declare const SliderInput: React.ForwardRefExoticComponent<Pick<InputProps, "disabled" | "size" | "className" | "dataTestId" | "form" | "label" | "slot" | "style" | "title" | "pattern" | "children" | "leftAddons" | "rightAddons" | "block" | "colors" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "list" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "fieldClassName" | "labelClassName" | "addonsClassName" | "error" | "hint" | "accept" | "alt" | "autoComplete" | "capture" | "checked" | "crossOrigin" | "height" | "maxLength" | "minLength" | "multiple" | "readOnly" | "required" | "src" | "width" | "clear" | "success" | "inputClassName" | "focusedClassName" | "filledClassName" | "onClear" | "wrapperRef"> & {
81
+ /**
82
+ * Мин. допустимое число
83
+ */
84
+ min?: number | undefined;
85
+ /**
86
+ * Макс. допустимое число
87
+ */
88
+ max?: number | undefined;
89
+ /**
90
+ * Шаг (должен нацело делить отрезок между мин и макс)
91
+ */
92
+ step?: number | undefined;
93
+ /**
94
+ * Отображение подписей
95
+ * https://refreshless.com/nouislider/pips/
96
+ */
97
+ pips?: {
98
+ mode: "range" | "steps" | "positions" | "count" | "values";
99
+ values: number | number[];
100
+ filter?: ((value: number, type: 0 | 1 | 2 | -1) => 0 | 1 | 2 | -1) | undefined; /**
101
+ * Макс. допустимое число
102
+ */
103
+ format?: {
104
+ to: (value: number) => React.ReactText; /**
105
+ * Шаг (должен нацело делить отрезок между мин и макс)
106
+ */
107
+ from?: ((value: string) => number | false) | undefined;
108
+ } | undefined;
109
+ stepped?: boolean | undefined;
110
+ } | undefined;
111
+ /**
112
+ * Настройка шагов
113
+ * https://refreshless.com/nouislider/pips/#section-range
114
+ */
115
+ range?: Range | undefined;
116
+ /**
117
+ * Значение инпута
118
+ */
119
+ value?: string | number | undefined;
120
+ /**
121
+ * Значение слайдера
122
+ */
123
+ sliderValue?: number | undefined;
124
+ /**
125
+ * Дополнительная информация в правой части поля
126
+ */
127
+ info?: React.ReactNode;
128
+ /**
129
+ * Компонент поля ввода
130
+ */
131
+ Input?: React.FC<Pick<InputProps, "min" | "max" | "step" | "disabled" | "size" | "className" | "dataTestId" | "form" | "label" | "slot" | "style" | "title" | "pattern" | "children" | "leftAddons" | "rightAddons" | "block" | "colors" | "type" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "list" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "fieldClassName" | "labelClassName" | "addonsClassName" | "error" | "hint" | "bottomAddons" | "accept" | "alt" | "autoComplete" | "capture" | "checked" | "crossOrigin" | "height" | "maxLength" | "minLength" | "multiple" | "readOnly" | "required" | "src" | "width" | "clear" | "success" | "inputClassName" | "focusedClassName" | "filledClassName" | "onClear" | "wrapperRef">> | undefined;
132
+ /**
133
+ * Кастомные пропсы для поля ввода
134
+ */
135
+ customInputProps?: Record<string, unknown> | undefined;
136
+ /**
137
+ * Класс для инпута
138
+ */
139
+ inputClassName?: string | undefined;
140
+ /**
141
+ * Класс для слайдера
142
+ */
143
+ sliderClassName?: string | undefined;
144
+ /**
145
+ * Обработчик изменения значения через слайдер или поле ввода
146
+ */
147
+ onChange?: ((event: React.ChangeEvent<HTMLInputElement> | null, payload: {
148
+ value: number | "";
149
+ }) => void) | undefined;
150
+ /**
151
+ * Обработчик ввода
152
+ */
153
+ onInputChange?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
154
+ value: number | "";
155
+ }) => void) | undefined;
156
+ /**
157
+ * Обработчик изменения слайдера
158
+ */
159
+ onSliderChange?: ((payload: {
160
+ value: number;
161
+ }) => void) | undefined;
162
+ /**
163
+ * Идентификатор для систем автоматизированного тестирования
164
+ */
165
+ dataTestId?: string | undefined;
166
+ } & React.RefAttributes<HTMLInputElement>>;
167
+ export { SliderInputProps, SliderInput };
@@ -1,21 +1,21 @@
1
- import React, { forwardRef, useCallback, Fragment, isValidElement, cloneElement } from 'react';
1
+ import React, { forwardRef, useCallback, Fragment } from 'react';
2
2
  import cn from 'classnames';
3
3
  import { Slider } from '@alfalab/core-components-slider/dist/modern';
4
4
  import { Input } from '@alfalab/core-components-input/dist/modern';
5
5
 
6
- var styles = {"component":"slider-input__component_14e1l","block":"slider-input__block_14e1l","slider":"slider-input__slider_14e1l","field":"slider-input__field_14e1l","input":"slider-input__input_14e1l","steps":"slider-input__steps_14e1l","info":"slider-input__info_14e1l","s":"slider-input__s_14e1l","hasLabel":"slider-input__hasLabel_14e1l","m":"slider-input__m_14e1l","l":"slider-input__l_14e1l","xl":"slider-input__xl_14e1l","focused":"slider-input__focused_14e1l","filled":"slider-input__filled_14e1l"};
6
+ var styles = {"component":"slider-input__component_1acxm","block":"slider-input__block_1acxm","slider":"slider-input__slider_1acxm","field":"slider-input__field_1acxm","input":"slider-input__input_1acxm","steps":"slider-input__steps_1acxm","info":"slider-input__info_1acxm","s":"slider-input__s_1acxm","hasLabel":"slider-input__hasLabel_1acxm","m":"slider-input__m_1acxm","l":"slider-input__l_1acxm","xl":"slider-input__xl_1acxm","focused":"slider-input__focused_1acxm","filled":"slider-input__filled_1acxm"};
7
7
  require('./index.css')
8
8
 
9
- const SliderInput = forwardRef(({ className, inputClassName, sliderClassName, stepsClassName, focusedClassName, fieldClassName, value = '', min = 0, max = 100, step = 1, block, sliderValue = +value, steps = [], size = 's', label, info, disabled, readOnly, onChange, onInputChange, onSliderChange, rightAddons, Input: Input$1 = Input, customInputProps = {}, dataTestId, error, ...restProps }, ref) => {
9
+ const SliderInput = forwardRef(({ className, inputClassName, sliderClassName, focusedClassName, fieldClassName, value = '', min = 0, max = 100, step = 1, block, sliderValue = +value, size = 's', label, info, disabled, readOnly, onChange, onInputChange, onSliderChange, rightAddons, Input: Input$1 = Input, customInputProps = {}, error, hint, pips, range, dataTestId, ...restProps }, ref) => {
10
10
  const getValidInputValue = useCallback((inputValue) => {
11
11
  const number = parseInt(inputValue, 10);
12
12
  return inputValue === '' || Number.isNaN(number) ? '' : Math.abs(number);
13
13
  }, []);
14
- const handleSliderChange = useCallback((event, payload) => {
14
+ const handleSliderChange = useCallback(payload => {
15
15
  if (onChange)
16
- onChange(event, payload);
16
+ onChange(null, payload);
17
17
  if (onSliderChange)
18
- onSliderChange(event, payload);
18
+ onSliderChange(payload);
19
19
  }, [onChange, onSliderChange]);
20
20
  const handleInputChange = useCallback((event, payload) => {
21
21
  if (onChange)
@@ -29,12 +29,9 @@ const SliderInput = forwardRef(({ className, inputClassName, sliderClassName, st
29
29
  [styles.hasLabel]: label,
30
30
  [styles.hasError]: Boolean(error),
31
31
  }, styles[size], className), "data-test-id": dataTestId },
32
- React.createElement(Input$1, Object.assign({}, restProps, customInputProps, { ref: ref, value: value.toString(), onChange: handleInputChange, block: true, size: size, label: label, disabled: disabled, readOnly: readOnly, className: cn(inputClassName, styles.input), focusedClassName: cn(focusedClassName, styles.focused), fieldClassName: cn(fieldClassName, styles.field), inputMode: 'numeric', pattern: '[0-9]*', error: error, bottomAddons: !disabled && (React.createElement(Slider, { min: min, max: max, step: step, onChange: handleSliderChange, ref: ref, value: Number.isNaN(sliderValue) ? 0 : sliderValue, disabled: disabled || readOnly, className: cn(styles.slider, sliderClassName) })), rightAddons: (info || rightAddons) && (React.createElement(Fragment, null,
32
+ React.createElement(Input$1, Object.assign({}, restProps, customInputProps, { ref: ref, value: value.toString(), onChange: handleInputChange, block: true, size: size, label: label, disabled: disabled, readOnly: readOnly, className: cn(inputClassName, styles.input), focusedClassName: cn(focusedClassName, styles.focused), fieldClassName: cn(fieldClassName, styles.field), inputMode: 'numeric', pattern: '[0-9]*', error: error, hint: hint, bottomAddons: !disabled && (React.createElement(Slider, { min: min, max: max, step: step, onChange: handleSliderChange, value: Number.isNaN(sliderValue) || !sliderValue ? min : sliderValue, disabled: disabled || readOnly, className: cn(styles.slider, sliderClassName), pips: !error && !hint ? pips : undefined, range: range })), rightAddons: (info || rightAddons) && (React.createElement(Fragment, null,
33
33
  info && React.createElement("span", { className: styles.info }, info),
34
- rightAddons)) })),
35
- steps.length > 0 && !error && (React.createElement("div", { className: cn(styles.steps, stepsClassName) }, steps.map((stepLabel, i) => isValidElement(stepLabel) ? (cloneElement(stepLabel, { key: i })) : (
36
- // eslint-disable-next-line react/no-array-index-key
37
- React.createElement("span", { key: i }, stepLabel)))))));
34
+ rightAddons)) }))));
38
35
  });
39
36
  /**
40
37
  * Для отображения в сторибуке
@@ -44,7 +41,6 @@ SliderInput.defaultProps = {
44
41
  min: 0,
45
42
  max: 100,
46
43
  step: 1,
47
- steps: [],
48
44
  size: 's',
49
45
  Input: Input,
50
46
  customInputProps: {},
@@ -1,4 +1,4 @@
1
- /* hash: t8u37 */
1
+ /* hash: fi4ed */
2
2
  :root {
3
3
  --color-light-text-secondary: #546272;
4
4
  }
@@ -13,40 +13,44 @@
13
13
  :root {
14
14
  --gap-xs: 8px;
15
15
  }
16
+ :root {
17
+ --slider-progress-s-height: 2px;
18
+
19
+ /* Отступы по бокам — на мобилке thumb не должен заходить за края контрола */
20
+ }
16
21
  :root {
17
22
  --slider-input-steps-color: var(--color-light-text-secondary);
18
23
  --slider-input-info-color: var(--color-light-text-secondary);
19
24
  --slider-input-font-weight: 700;
20
25
  }
21
- .slider-input__component_14e1l {
26
+ .slider-input__component_1acxm {
22
27
  position: relative;
23
28
  display: inline-block;
24
29
  }
25
- .slider-input__block_14e1l {
30
+ .slider-input__block_1acxm {
26
31
  display: block;
27
32
  }
28
- .slider-input__slider_14e1l {
29
- position: absolute;
30
- margin-top: -1px;
31
- transform: translateY(-50%)
33
+ .slider-input__slider_1acxm {
34
+ margin-top: calc(var(--slider-progress-s-height) / -2);
35
+ transform: translateY(-1px)
32
36
  }
33
- .slider-input__slider_14e1l + * {
37
+ .slider-input__slider_1acxm + * {
34
38
  margin-top: var(--gap-xs);
35
39
  }
36
- .slider-input__field_14e1l {
40
+ .slider-input__field_1acxm {
37
41
  border-bottom-left-radius: 0;
38
42
  border-bottom-right-radius: 0;
39
43
  }
40
- .slider-input__input_14e1l input,
41
- .slider-input__input_14e1l input + div {
44
+ .slider-input__input_1acxm input,
45
+ .slider-input__input_1acxm input + div {
42
46
  font-weight: var(--slider-input-font-weight);
43
47
  font-feature-settings: "tnum";
44
48
  font-variant-numeric: tabular-nums;
45
49
  }
46
- .slider-input__input_14e1l input::placeholder {
50
+ .slider-input__input_1acxm input::placeholder {
47
51
  font-weight: 400;
48
52
  }
49
- .slider-input__steps_14e1l {
53
+ .slider-input__steps_1acxm {
50
54
  font-size: 14px;
51
55
  line-height: 18px;
52
56
  font-weight: 400;
@@ -56,7 +60,7 @@
56
60
  margin-top: var(--gap-xs);
57
61
  color: var(--slider-input-steps-color);
58
62
  }
59
- .slider-input__info_14e1l {
63
+ .slider-input__info_1acxm {
60
64
  font-size: 16px;
61
65
  line-height: 20px;
62
66
  font-weight: 400;
@@ -67,28 +71,28 @@
67
71
  transition: 0.2s ease;
68
72
  visibility: hidden;
69
73
  }
70
- .slider-input__s_14e1l.slider-input__hasLabel_14e1l .slider-input__info_14e1l:first-child {
74
+ .slider-input__s_1acxm.slider-input__hasLabel_1acxm .slider-input__info_1acxm:first-child {
71
75
  padding: var(--form-control-labeled-s-paddings);
72
76
  padding-left: 0;
73
77
  padding-right: 0;
74
78
  }
75
- .slider-input__m_14e1l.slider-input__hasLabel_14e1l .slider-input__info_14e1l:first-child {
79
+ .slider-input__m_1acxm.slider-input__hasLabel_1acxm .slider-input__info_1acxm:first-child {
76
80
  padding: var(--form-control-labeled-m-paddings);
77
81
  padding-left: 0;
78
82
  padding-right: 0;
79
83
  }
80
- .slider-input__l_14e1l.slider-input__hasLabel_14e1l .slider-input__info_14e1l:first-child {
84
+ .slider-input__l_1acxm.slider-input__hasLabel_1acxm .slider-input__info_1acxm:first-child {
81
85
  padding: var(--form-control-labeled-l-paddings);
82
86
  padding-left: 0;
83
87
  padding-right: 0;
84
88
  }
85
- .slider-input__xl_14e1l.slider-input__hasLabel_14e1l .slider-input__info_14e1l:first-child {
89
+ .slider-input__xl_1acxm.slider-input__hasLabel_1acxm .slider-input__info_1acxm:first-child {
86
90
  padding: var(--form-control-labeled-xl-paddings);
87
91
  padding-left: 0;
88
92
  padding-right: 0;
89
93
  }
90
- .slider-input__focused_14e1l .slider-input__info_14e1l,
91
- .slider-input__filled_14e1l .slider-input__info_14e1l {
94
+ .slider-input__focused_1acxm .slider-input__info_1acxm,
95
+ .slider-input__filled_1acxm .slider-input__info_1acxm {
92
96
  visibility: visible;
93
97
  opacity: 1;
94
98
  }
File without changes
File without changes
package/package.json CHANGED
@@ -1,29 +1,26 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-slider-input",
3
- "version": "4.5.0",
3
+ "version": "5.0.2",
4
4
  "description": "Slider input component",
5
5
  "keywords": [],
6
6
  "license": "MIT",
7
- "main": "dist/index.js",
8
- "module": "./dist/esm/index.js",
9
- "files": [
10
- "dist"
11
- ],
7
+ "main": "index.js",
8
+ "module": "./esm/index.js",
12
9
  "scripts": {
13
- "postinstall": "node ./dist/send-stats.js > /dev/null 2>&1 || exit 0"
10
+ "postinstall": "node ./send-stats.js > /dev/null 2>&1 || exit 0"
14
11
  },
15
12
  "publishConfig": {
16
- "access": "public"
13
+ "access": "public",
14
+ "directory": "dist"
17
15
  },
18
16
  "peerDependencies": {
19
17
  "react": "^16.9.0 || ^17.0.1",
20
18
  "react-dom": "^16.9.0 || ^17.0.1"
21
19
  },
22
20
  "dependencies": {
23
- "@alfalab/core-components-input": "^8.2.0",
24
- "@alfalab/core-components-slider": "^2.4.0",
21
+ "@alfalab/core-components-input": "^8.2.1",
22
+ "@alfalab/core-components-slider": "^3.0.2",
25
23
  "classnames": "^2.2.6",
26
24
  "react-merge-refs": "^1.1.0"
27
- },
28
- "gitHead": "dcd5c0c8e25b7c374ff9311505ccf738a82e22c0"
25
+ }
29
26
  }
File without changes
@@ -1,149 +0,0 @@
1
- /// <reference types="react" />
2
- import React from 'react';
3
- import { ChangeEvent, FC, ReactNode } from "react";
4
- import { InputProps } from "@alfalab/core-components-input";
5
- type SliderInputProps = Omit<InputProps, 'min' | 'max' | 'step' | 'value' | 'type' | 'onChange' | 'bottomAddons'> & {
6
- /**
7
- * Мин. допустимое число
8
- */
9
- min?: number;
10
- /**
11
- * Макс. допустимое число
12
- */
13
- max?: number;
14
- /**
15
- * Шаг (должен нацело делить отрезок между мин и макс)
16
- */
17
- step?: number;
18
- /**
19
- * Массив подписей к слайдеру
20
- */
21
- steps?: ReactNode[];
22
- /**
23
- * Значение инпута
24
- */
25
- value?: number | string;
26
- /**
27
- * Значение слайдера
28
- */
29
- sliderValue?: number;
30
- /**
31
- * Дополнительная информация в правой части поля
32
- */
33
- info?: ReactNode;
34
- /**
35
- * Компонент поля ввода
36
- */
37
- Input?: FC<Omit<InputProps, 'onChange' | 'value'>>;
38
- /**
39
- * Кастомные пропсы для поля ввода
40
- */
41
- customInputProps?: Record<string, unknown>;
42
- /**
43
- * Класс для инпута
44
- */
45
- inputClassName?: string;
46
- /**
47
- * Класс для слайдера
48
- */
49
- sliderClassName?: string;
50
- /**
51
- * Класс для шагов
52
- */
53
- stepsClassName?: string;
54
- /**
55
- * Обработчик изменения значения через слайдер или поле ввода
56
- */
57
- onChange?: (event: ChangeEvent<HTMLInputElement>, payload: {
58
- value: number | '';
59
- }) => void;
60
- /**
61
- * Обработчик ввода
62
- */
63
- onInputChange?: (event: ChangeEvent<HTMLInputElement>, payload: {
64
- value: number | '';
65
- }) => void;
66
- /**
67
- * Обработчик изменения слайдера
68
- */
69
- onSliderChange?: (event: ChangeEvent<HTMLInputElement>, payload: {
70
- value: number;
71
- }) => void;
72
- /**
73
- * Идентификатор для систем автоматизированного тестирования
74
- */
75
- dataTestId?: string;
76
- };
77
- declare const SliderInput: React.ForwardRefExoticComponent<Pick<InputProps, "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "disabled" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "list" | "maxLength" | "minLength" | "multiple" | "name" | "pattern" | "placeholder" | "readOnly" | "required" | "size" | "src" | "width" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "dataTestId" | "label" | "leftAddons" | "rightAddons" | "block" | "colors" | "fieldClassName" | "labelClassName" | "addonsClassName" | "error" | "hint" | "clear" | "success" | "inputClassName" | "focusedClassName" | "filledClassName" | "onClear" | "wrapperRef"> & {
78
- /**
79
- * Мин. допустимое число
80
- */
81
- min?: number | undefined;
82
- /**
83
- * Макс. допустимое число
84
- */
85
- max?: number | undefined;
86
- /**
87
- * Шаг (должен нацело делить отрезок между мин и макс)
88
- */
89
- step?: number | undefined;
90
- /**
91
- * Массив подписей к слайдеру
92
- */
93
- steps?: React.ReactNode[] | undefined;
94
- /**
95
- * Значение инпута
96
- */
97
- value?: string | number | undefined;
98
- /**
99
- * Значение слайдера
100
- */
101
- sliderValue?: number | undefined;
102
- /**
103
- * Дополнительная информация в правой части поля
104
- */
105
- info?: React.ReactNode;
106
- /**
107
- * Компонент поля ввода
108
- */
109
- Input?: React.FC<Pick<InputProps, "min" | "max" | "step" | "type" | "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "disabled" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "list" | "maxLength" | "minLength" | "multiple" | "name" | "pattern" | "placeholder" | "readOnly" | "required" | "size" | "src" | "width" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "dataTestId" | "label" | "leftAddons" | "rightAddons" | "block" | "colors" | "fieldClassName" | "labelClassName" | "addonsClassName" | "error" | "hint" | "bottomAddons" | "clear" | "success" | "inputClassName" | "focusedClassName" | "filledClassName" | "onClear" | "wrapperRef">> | undefined;
110
- /**
111
- * Кастомные пропсы для поля ввода
112
- */
113
- customInputProps?: Record<string, unknown> | undefined;
114
- /**
115
- * Класс для инпута
116
- */
117
- inputClassName?: string | undefined;
118
- /**
119
- * Класс для слайдера
120
- */
121
- sliderClassName?: string | undefined;
122
- /**
123
- * Класс для шагов
124
- */
125
- stepsClassName?: string | undefined;
126
- /**
127
- * Обработчик изменения значения через слайдер или поле ввода
128
- */
129
- onChange?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
130
- value: number | "";
131
- }) => void) | undefined;
132
- /**
133
- * Обработчик ввода
134
- */
135
- onInputChange?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
136
- value: number | "";
137
- }) => void) | undefined;
138
- /**
139
- * Обработчик изменения слайдера
140
- */
141
- onSliderChange?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
142
- value: number;
143
- }) => void) | undefined;
144
- /**
145
- * Идентификатор для систем автоматизированного тестирования
146
- */
147
- dataTestId?: string | undefined;
148
- } & React.RefAttributes<HTMLInputElement>>;
149
- export { SliderInputProps, SliderInput };