@alfalab/core-components-switch 2.1.0 → 2.2.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.2.1](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-switch@2.2.0...@alfalab/core-components-switch@2.2.1) (2021-12-08)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * актуализируем @alfalab/utils ([#897](https://github.com/alfa-laboratory/core-components/issues/897)) ([30fb88e](https://github.com/alfa-laboratory/core-components/commit/30fb88eee36f68cabf80069e5125d911fabde4a5))
12
+
13
+
14
+
15
+
16
+
17
+ # [2.2.0](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-switch@2.1.0...@alfalab/core-components-switch@2.2.0) (2021-08-03)
18
+
19
+
20
+ ### Features
21
+
22
+ * add inactive controls (PDS-266) ([#765](https://github.com/alfa-laboratory/core-components/issues/765)) ([ec02c89](https://github.com/alfa-laboratory/core-components/commit/ec02c89ab6bf038c026ca0a72b3185525334840a))
23
+
24
+
25
+
26
+
27
+
6
28
  # [2.1.0](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-switch@2.0.1...@alfalab/core-components-switch@2.1.0) (2021-07-23)
7
29
 
8
30
 
@@ -2,7 +2,7 @@
2
2
  import React from 'react';
3
3
  import { InputHTMLAttributes, ChangeEvent, ReactNode } from "react";
4
4
  type Align = 'start' | 'center';
5
- type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' | 'onChange'> & {
5
+ type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' | 'onChange' | 'disabled'> & {
6
6
  /**
7
7
  * Управление состоянием вкл/выкл компонента
8
8
  */
@@ -31,6 +31,14 @@ type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' |
31
31
  * Растягивать ли компонент на всю ширину
32
32
  */
33
33
  block?: boolean;
34
+ /**
35
+ * Управление состоянием включен / выключен
36
+ */
37
+ disabled?: boolean;
38
+ /**
39
+ * Управление состоянием активен / неактивен
40
+ */
41
+ inactive?: boolean;
34
42
  /**
35
43
  * Обработчик переключения компонента
36
44
  */
@@ -43,7 +51,7 @@ type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' |
43
51
  */
44
52
  dataTestId?: string;
45
53
  };
46
- declare const Switch: React.ForwardRefExoticComponent<Pick<React.InputHTMLAttributes<HTMLInputElement>, "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "disabled" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "list" | "max" | "maxLength" | "min" | "minLength" | "multiple" | "name" | "pattern" | "placeholder" | "readOnly" | "required" | "size" | "src" | "step" | "value" | "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"> & {
54
+ declare const Switch: React.ForwardRefExoticComponent<Pick<React.InputHTMLAttributes<HTMLInputElement>, "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "list" | "max" | "maxLength" | "min" | "minLength" | "multiple" | "name" | "pattern" | "placeholder" | "readOnly" | "required" | "size" | "src" | "step" | "value" | "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"> & {
47
55
  /**
48
56
  * Управление состоянием вкл/выкл компонента
49
57
  */
@@ -72,6 +80,14 @@ declare const Switch: React.ForwardRefExoticComponent<Pick<React.InputHTMLAttrib
72
80
  * Растягивать ли компонент на всю ширину
73
81
  */
74
82
  block?: boolean | undefined;
83
+ /**
84
+ * Управление состоянием включен / выключен
85
+ */
86
+ disabled?: boolean | undefined;
87
+ /**
88
+ * Управление состоянием активен / неактивен
89
+ */
90
+ inactive?: boolean | undefined;
75
91
  /**
76
92
  * Обработчик переключения компонента
77
93
  */
package/dist/Component.js CHANGED
@@ -52,12 +52,12 @@ function __rest(s, e) {
52
52
  return t;
53
53
  }
54
54
 
55
- var styles = {"component":"switch__component_16a5o","start":"switch__start_16a5o","center":"switch__center_16a5o","addons":"switch__addons_16a5o","block":"switch__block_16a5o","switch":"switch__switch_16a5o","content":"switch__content_16a5o","label":"switch__label_16a5o","hint":"switch__hint_16a5o","reversed":"switch__reversed_16a5o","checked":"switch__checked_16a5o","disabled":"switch__disabled_16a5o","focused":"switch__focused_16a5o"};
55
+ var styles = {"component":"switch__component_qfjsc","start":"switch__start_qfjsc","center":"switch__center_qfjsc","addons":"switch__addons_qfjsc","block":"switch__block_qfjsc","switch":"switch__switch_qfjsc","content":"switch__content_qfjsc","label":"switch__label_qfjsc","hint":"switch__hint_qfjsc","reversed":"switch__reversed_qfjsc","checked":"switch__checked_qfjsc","disabled":"switch__disabled_qfjsc","inactive":"switch__inactive_qfjsc","focused":"switch__focused_qfjsc"};
56
56
  require('./index.css')
57
57
 
58
58
  var Switch = React.forwardRef(function (_a, ref) {
59
59
  var _b;
60
- var _c = _a.reversed, reversed = _c === void 0 ? false : _c, _d = _a.checked, checked = _d === void 0 ? false : _d, _e = _a.align, align = _e === void 0 ? 'start' : _e, addons = _a.addons, block = _a.block, disabled = _a.disabled, label = _a.label, hint = _a.hint, name = _a.name, value = _a.value, className = _a.className, onChange = _a.onChange, dataTestId = _a.dataTestId, restProps = __rest(_a, ["reversed", "checked", "align", "addons", "block", "disabled", "label", "hint", "name", "value", "className", "onChange", "dataTestId"]);
60
+ var _c = _a.reversed, reversed = _c === void 0 ? false : _c, _d = _a.checked, checked = _d === void 0 ? false : _d, _e = _a.align, align = _e === void 0 ? 'start' : _e, addons = _a.addons, block = _a.block, disabled = _a.disabled, inactive = _a.inactive, label = _a.label, hint = _a.hint, name = _a.name, value = _a.value, className = _a.className, onChange = _a.onChange, dataTestId = _a.dataTestId, restProps = __rest(_a, ["reversed", "checked", "align", "addons", "block", "disabled", "inactive", "label", "hint", "name", "value", "className", "onChange", "dataTestId"]);
61
61
  var labelRef = React.useRef(null);
62
62
  var focused = hooks.useFocus(labelRef, 'keyboard')[0];
63
63
  var handleChange = React.useCallback(function (e) {
@@ -69,12 +69,13 @@ var Switch = React.forwardRef(function (_a, ref) {
69
69
  // eslint-disable-next-line jsx-a11y/label-has-associated-control
70
70
  React__default['default'].createElement("label", { className: cn__default['default'](styles.component, styles[align], className, (_b = {},
71
71
  _b[styles.disabled] = disabled,
72
+ _b[styles.inactive] = inactive,
72
73
  _b[styles.checked] = checked,
73
74
  _b[styles.reversed] = reversed,
74
75
  _b[styles.focused] = focused,
75
76
  _b[styles.block] = block,
76
77
  _b)), ref: mergeRefs__default['default']([labelRef, ref]) },
77
- React__default['default'].createElement("input", __assign({ type: 'checkbox', onChange: handleChange, disabled: disabled, checked: checked, name: name, value: value, "data-test-id": dataTestId }, restProps)),
78
+ React__default['default'].createElement("input", __assign({ type: 'checkbox', onChange: handleChange, disabled: disabled || inactive, checked: checked, name: name, value: value, "data-test-id": dataTestId }, restProps)),
78
79
  React__default['default'].createElement("span", { className: styles.switch }),
79
80
  (label || hint) && (React__default['default'].createElement("span", { className: styles.content },
80
81
  label && React__default['default'].createElement("span", { className: styles.label }, label),
@@ -2,7 +2,7 @@
2
2
  import React from 'react';
3
3
  import { InputHTMLAttributes, ChangeEvent, ReactNode } from "react";
4
4
  type Align = 'start' | 'center';
5
- type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' | 'onChange'> & {
5
+ type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' | 'onChange' | 'disabled'> & {
6
6
  /**
7
7
  * Управление состоянием вкл/выкл компонента
8
8
  */
@@ -31,6 +31,14 @@ type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' |
31
31
  * Растягивать ли компонент на всю ширину
32
32
  */
33
33
  block?: boolean;
34
+ /**
35
+ * Управление состоянием включен / выключен
36
+ */
37
+ disabled?: boolean;
38
+ /**
39
+ * Управление состоянием активен / неактивен
40
+ */
41
+ inactive?: boolean;
34
42
  /**
35
43
  * Обработчик переключения компонента
36
44
  */
@@ -43,7 +51,7 @@ type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' |
43
51
  */
44
52
  dataTestId?: string;
45
53
  };
46
- declare const Switch: React.ForwardRefExoticComponent<Pick<React.InputHTMLAttributes<HTMLInputElement>, "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "disabled" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "list" | "max" | "maxLength" | "min" | "minLength" | "multiple" | "name" | "pattern" | "placeholder" | "readOnly" | "required" | "size" | "src" | "step" | "value" | "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"> & {
54
+ declare const Switch: React.ForwardRefExoticComponent<Pick<React.InputHTMLAttributes<HTMLInputElement>, "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "list" | "max" | "maxLength" | "min" | "minLength" | "multiple" | "name" | "pattern" | "placeholder" | "readOnly" | "required" | "size" | "src" | "step" | "value" | "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"> & {
47
55
  /**
48
56
  * Управление состоянием вкл/выкл компонента
49
57
  */
@@ -72,6 +80,14 @@ declare const Switch: React.ForwardRefExoticComponent<Pick<React.InputHTMLAttrib
72
80
  * Растягивать ли компонент на всю ширину
73
81
  */
74
82
  block?: boolean | undefined;
83
+ /**
84
+ * Управление состоянием включен / выключен
85
+ */
86
+ disabled?: boolean | undefined;
87
+ /**
88
+ * Управление состоянием активен / неактивен
89
+ */
90
+ inactive?: boolean | undefined;
75
91
  /**
76
92
  * Обработчик переключения компонента
77
93
  */
@@ -56,7 +56,7 @@ function __rest(s, e) {
56
56
 
57
57
  var Switch = React.forwardRef(function (_a, ref) {
58
58
  var _b;
59
- var _c = _a.reversed, reversed = _c === void 0 ? false : _c, _d = _a.checked, checked = _d === void 0 ? false : _d, _e = _a.align, align = _e === void 0 ? 'start' : _e, addons = _a.addons, block = _a.block, disabled = _a.disabled, label = _a.label, hint = _a.hint, name = _a.name, value = _a.value, className = _a.className, onChange = _a.onChange, dataTestId = _a.dataTestId, restProps = __rest(_a, ["reversed", "checked", "align", "addons", "block", "disabled", "label", "hint", "name", "value", "className", "onChange", "dataTestId"]);
59
+ var _c = _a.reversed, reversed = _c === void 0 ? false : _c, _d = _a.checked, checked = _d === void 0 ? false : _d, _e = _a.align, align = _e === void 0 ? 'start' : _e, addons = _a.addons, block = _a.block, disabled = _a.disabled, inactive = _a.inactive, label = _a.label, hint = _a.hint, name = _a.name, value = _a.value, className = _a.className, onChange = _a.onChange, dataTestId = _a.dataTestId, restProps = __rest(_a, ["reversed", "checked", "align", "addons", "block", "disabled", "inactive", "label", "hint", "name", "value", "className", "onChange", "dataTestId"]);
60
60
  var labelRef = React.useRef(null);
61
61
  var focused = hooks.useFocus(labelRef, 'keyboard')[0];
62
62
  var handleChange = React.useCallback(function (e) {
@@ -68,12 +68,13 @@ var Switch = React.forwardRef(function (_a, ref) {
68
68
  // eslint-disable-next-line jsx-a11y/label-has-associated-control
69
69
  React__default['default'].createElement("label", { className: cn__default['default'](styles__default['default'].component, styles__default['default'][align], className, (_b = {},
70
70
  _b[styles__default['default'].disabled] = disabled,
71
+ _b[styles__default['default'].inactive] = inactive,
71
72
  _b[styles__default['default'].checked] = checked,
72
73
  _b[styles__default['default'].reversed] = reversed,
73
74
  _b[styles__default['default'].focused] = focused,
74
75
  _b[styles__default['default'].block] = block,
75
76
  _b)), ref: mergeRefs__default['default']([labelRef, ref]) },
76
- React__default['default'].createElement("input", __assign({ type: 'checkbox', onChange: handleChange, disabled: disabled, checked: checked, name: name, value: value, "data-test-id": dataTestId }, restProps)),
77
+ React__default['default'].createElement("input", __assign({ type: 'checkbox', onChange: handleChange, disabled: disabled || inactive, checked: checked, name: name, value: value, "data-test-id": dataTestId }, restProps)),
77
78
  React__default['default'].createElement("span", { className: styles__default['default'].switch }),
78
79
  (label || hint) && (React__default['default'].createElement("span", { className: styles__default['default'].content },
79
80
  label && React__default['default'].createElement("span", { className: styles__default['default'].label }, label),
@@ -1,5 +1,6 @@
1
1
  :root {
2
2
  --color-light-border-link: #007aff;
3
+ --color-light-border-secondary-inverted: #b6bcc3;
3
4
  --color-light-graphic-accent: #ef3124;
4
5
  --color-light-graphic-neutral: #dbdee1;
5
6
  --color-light-graphic-primary-inverted: #fff;
@@ -43,6 +44,9 @@
43
44
  --switch-disabled-color: var(--color-light-text-secondary);
44
45
  --switch-disabled-bg-color: var(--color-light-graphic-neutral);
45
46
  --switch-disabled-border-color: var(--color-light-graphic-neutral);
47
+
48
+ /* inactive */
49
+ --switch-inactive-color: var(--color-light-border-secondary-inverted);
46
50
  }
47
51
  .component {
48
52
  display: inline-flex;
@@ -154,6 +158,17 @@
154
158
  .disabled .hint {
155
159
  color: var(--switch-disabled-color);
156
160
  }
161
+ /* Inactive */
162
+ .inactive {
163
+ cursor: var(--disabled-cursor);
164
+ }
165
+ .inactive .switch {
166
+ background-color: var(--switch-disabled-bg-color);
167
+ border-color: var(--switch-disabled-border-color)
168
+ }
169
+ .inactive .switch:before {
170
+ background-color: var(--switch-inactive-color);
171
+ }
157
172
  /* Focused state */
158
173
  .focused .switch {
159
174
  outline: 2px solid var(--focus-color);
@@ -2,7 +2,7 @@
2
2
  import React from 'react';
3
3
  import { InputHTMLAttributes, ChangeEvent, ReactNode } from "react";
4
4
  type Align = 'start' | 'center';
5
- type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' | 'onChange'> & {
5
+ type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' | 'onChange' | 'disabled'> & {
6
6
  /**
7
7
  * Управление состоянием вкл/выкл компонента
8
8
  */
@@ -31,6 +31,14 @@ type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' |
31
31
  * Растягивать ли компонент на всю ширину
32
32
  */
33
33
  block?: boolean;
34
+ /**
35
+ * Управление состоянием включен / выключен
36
+ */
37
+ disabled?: boolean;
38
+ /**
39
+ * Управление состоянием активен / неактивен
40
+ */
41
+ inactive?: boolean;
34
42
  /**
35
43
  * Обработчик переключения компонента
36
44
  */
@@ -43,7 +51,7 @@ type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' |
43
51
  */
44
52
  dataTestId?: string;
45
53
  };
46
- declare const Switch: React.ForwardRefExoticComponent<Pick<React.InputHTMLAttributes<HTMLInputElement>, "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "disabled" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "list" | "max" | "maxLength" | "min" | "minLength" | "multiple" | "name" | "pattern" | "placeholder" | "readOnly" | "required" | "size" | "src" | "step" | "value" | "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"> & {
54
+ declare const Switch: React.ForwardRefExoticComponent<Pick<React.InputHTMLAttributes<HTMLInputElement>, "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "list" | "max" | "maxLength" | "min" | "minLength" | "multiple" | "name" | "pattern" | "placeholder" | "readOnly" | "required" | "size" | "src" | "step" | "value" | "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"> & {
47
55
  /**
48
56
  * Управление состоянием вкл/выкл компонента
49
57
  */
@@ -72,6 +80,14 @@ declare const Switch: React.ForwardRefExoticComponent<Pick<React.InputHTMLAttrib
72
80
  * Растягивать ли компонент на всю ширину
73
81
  */
74
82
  block?: boolean | undefined;
83
+ /**
84
+ * Управление состоянием включен / выключен
85
+ */
86
+ disabled?: boolean | undefined;
87
+ /**
88
+ * Управление состоянием активен / неактивен
89
+ */
90
+ inactive?: boolean | undefined;
75
91
  /**
76
92
  * Обработчик переключения компонента
77
93
  */
@@ -42,12 +42,12 @@ function __rest(s, e) {
42
42
  return t;
43
43
  }
44
44
 
45
- var styles = {"component":"switch__component_16a5o","start":"switch__start_16a5o","center":"switch__center_16a5o","addons":"switch__addons_16a5o","block":"switch__block_16a5o","switch":"switch__switch_16a5o","content":"switch__content_16a5o","label":"switch__label_16a5o","hint":"switch__hint_16a5o","reversed":"switch__reversed_16a5o","checked":"switch__checked_16a5o","disabled":"switch__disabled_16a5o","focused":"switch__focused_16a5o"};
45
+ var styles = {"component":"switch__component_qfjsc","start":"switch__start_qfjsc","center":"switch__center_qfjsc","addons":"switch__addons_qfjsc","block":"switch__block_qfjsc","switch":"switch__switch_qfjsc","content":"switch__content_qfjsc","label":"switch__label_qfjsc","hint":"switch__hint_qfjsc","reversed":"switch__reversed_qfjsc","checked":"switch__checked_qfjsc","disabled":"switch__disabled_qfjsc","inactive":"switch__inactive_qfjsc","focused":"switch__focused_qfjsc"};
46
46
  require('./index.css')
47
47
 
48
48
  var Switch = forwardRef(function (_a, ref) {
49
49
  var _b;
50
- var _c = _a.reversed, reversed = _c === void 0 ? false : _c, _d = _a.checked, checked = _d === void 0 ? false : _d, _e = _a.align, align = _e === void 0 ? 'start' : _e, addons = _a.addons, block = _a.block, disabled = _a.disabled, label = _a.label, hint = _a.hint, name = _a.name, value = _a.value, className = _a.className, onChange = _a.onChange, dataTestId = _a.dataTestId, restProps = __rest(_a, ["reversed", "checked", "align", "addons", "block", "disabled", "label", "hint", "name", "value", "className", "onChange", "dataTestId"]);
50
+ var _c = _a.reversed, reversed = _c === void 0 ? false : _c, _d = _a.checked, checked = _d === void 0 ? false : _d, _e = _a.align, align = _e === void 0 ? 'start' : _e, addons = _a.addons, block = _a.block, disabled = _a.disabled, inactive = _a.inactive, label = _a.label, hint = _a.hint, name = _a.name, value = _a.value, className = _a.className, onChange = _a.onChange, dataTestId = _a.dataTestId, restProps = __rest(_a, ["reversed", "checked", "align", "addons", "block", "disabled", "inactive", "label", "hint", "name", "value", "className", "onChange", "dataTestId"]);
51
51
  var labelRef = useRef(null);
52
52
  var focused = useFocus(labelRef, 'keyboard')[0];
53
53
  var handleChange = useCallback(function (e) {
@@ -59,12 +59,13 @@ var Switch = forwardRef(function (_a, ref) {
59
59
  // eslint-disable-next-line jsx-a11y/label-has-associated-control
60
60
  React.createElement("label", { className: cn(styles.component, styles[align], className, (_b = {},
61
61
  _b[styles.disabled] = disabled,
62
+ _b[styles.inactive] = inactive,
62
63
  _b[styles.checked] = checked,
63
64
  _b[styles.reversed] = reversed,
64
65
  _b[styles.focused] = focused,
65
66
  _b[styles.block] = block,
66
67
  _b)), ref: mergeRefs([labelRef, ref]) },
67
- React.createElement("input", __assign({ type: 'checkbox', onChange: handleChange, disabled: disabled, checked: checked, name: name, value: value, "data-test-id": dataTestId }, restProps)),
68
+ React.createElement("input", __assign({ type: 'checkbox', onChange: handleChange, disabled: disabled || inactive, checked: checked, name: name, value: value, "data-test-id": dataTestId }, restProps)),
68
69
  React.createElement("span", { className: styles.switch }),
69
70
  (label || hint) && (React.createElement("span", { className: styles.content },
70
71
  label && React.createElement("span", { className: styles.label }, label),
@@ -1,6 +1,7 @@
1
- /* hash: 16a5o */
1
+ /* hash: tx7lo */
2
2
  :root {
3
3
  --color-light-border-link: #007aff;
4
+ --color-light-border-secondary-inverted: #b6bcc3;
4
5
  --color-light-graphic-accent: #ef3124;
5
6
  --color-light-graphic-neutral: #dbdee1;
6
7
  --color-light-graphic-primary-inverted: #fff;
@@ -44,8 +45,11 @@
44
45
  --switch-disabled-color: var(--color-light-text-secondary);
45
46
  --switch-disabled-bg-color: var(--color-light-graphic-neutral);
46
47
  --switch-disabled-border-color: var(--color-light-graphic-neutral);
48
+
49
+ /* inactive */
50
+ --switch-inactive-color: var(--color-light-border-secondary-inverted);
47
51
  }
48
- .switch__component_16a5o {
52
+ .switch__component_qfjsc {
49
53
  display: inline-flex;
50
54
  align-items: flex-start;
51
55
  margin: 0;
@@ -54,25 +58,25 @@
54
58
  cursor: pointer;
55
59
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
56
60
  }
57
- .switch__component_16a5o input {
61
+ .switch__component_qfjsc input {
58
62
  opacity: 0;
59
63
  position: absolute;
60
64
  }
61
- .switch__start_16a5o {
65
+ .switch__start_qfjsc {
62
66
  align-items: flex-start;
63
67
  }
64
- .switch__center_16a5o {
68
+ .switch__center_qfjsc {
65
69
  align-items: center;
66
70
  }
67
- .switch__addons_16a5o {
71
+ .switch__addons_qfjsc {
68
72
  margin-left: auto;
69
73
  padding-left: var(--gap-m);
70
74
  line-height: 24px;
71
75
  }
72
- .switch__block_16a5o {
76
+ .switch__block_qfjsc {
73
77
  width: 100%;
74
78
  }
75
- .switch__switch_16a5o {
79
+ .switch__switch_qfjsc {
76
80
  position: relative;
77
81
  border-radius: var(--border-radius-xl);
78
82
  width: 36px;
@@ -84,7 +88,7 @@
84
88
  transition: background-color 0.2s ease, border-color 0.2s ease;
85
89
  box-sizing: border-box;
86
90
  }
87
- .switch__switch_16a5o:before {
91
+ .switch__switch_qfjsc:before {
88
92
  content: '';
89
93
  position: absolute;
90
94
  top: 0;
@@ -97,21 +101,21 @@
97
101
  box-sizing: border-box;
98
102
  transition: transform 0.2s ease;
99
103
  }
100
- .switch__content_16a5o {
104
+ .switch__content_qfjsc {
101
105
  margin-left: var(--gap-s);
102
106
  flex-grow: 1;
103
107
  }
104
- .switch__label_16a5o {
108
+ .switch__label_qfjsc {
105
109
  font-size: 16px;
106
110
  line-height: 24px;
107
111
  font-weight: 400;
108
112
  display: block;
109
113
  color: var(--switch-label-color);
110
114
  }
111
- .switch__label_16a5o:not(:only-child) {
115
+ .switch__label_qfjsc:not(:only-child) {
112
116
  margin-bottom: var(--gap-2xs);
113
117
  }
114
- .switch__hint_16a5o {
118
+ .switch__hint_qfjsc {
115
119
  font-size: 14px;
116
120
  line-height: 18px;
117
121
  font-weight: 400;
@@ -119,44 +123,55 @@
119
123
  color: var(--switch-hint-color);
120
124
  }
121
125
  /* Reversed state */
122
- .switch__component_16a5o.switch__reversed_16a5o {
126
+ .switch__component_qfjsc.switch__reversed_qfjsc {
123
127
  flex-direction: row-reverse;
124
128
  }
125
- .switch__reversed_16a5o .switch__content_16a5o {
129
+ .switch__reversed_qfjsc .switch__content_qfjsc {
126
130
  margin-right: var(--gap-m);
127
131
  margin-left: 0;
128
132
  }
129
- .switch__reversed_16a5o .switch__addons_16a5o {
133
+ .switch__reversed_qfjsc .switch__addons_qfjsc {
130
134
  margin-left: 0;
131
135
  padding-left: 0;
132
136
  margin-right: auto;
133
137
  padding-right: var(--gap-m);
134
138
  }
135
139
  /* Checked state */
136
- .switch__checked_16a5o .switch__switch_16a5o {
140
+ .switch__checked_qfjsc .switch__switch_qfjsc {
137
141
  background-color: var(--switch-checked-bg-color);
138
142
  border-color: var(--switch-checked-border-color);
139
143
  }
140
- .switch__checked_16a5o .switch__switch_16a5o:before {
144
+ .switch__checked_qfjsc .switch__switch_qfjsc:before {
141
145
  /* ширина компонента(36px + 2*2px) - отступы(2 * 2px) - размер кружка(20px) */
142
146
  transform: translateX(16px);
143
147
  }
144
148
  /* Disabled state */
145
- .switch__disabled_16a5o {
149
+ .switch__disabled_qfjsc {
146
150
  cursor: var(--disabled-cursor);
147
151
  }
148
- .switch__disabled_16a5o .switch__switch_16a5o {
152
+ .switch__disabled_qfjsc .switch__switch_qfjsc {
149
153
  background-color: var(--switch-disabled-bg-color);
150
154
  border-color: var(--switch-disabled-border-color);
151
155
  }
152
- .switch__disabled_16a5o .switch__label_16a5o {
156
+ .switch__disabled_qfjsc .switch__label_qfjsc {
153
157
  color: var(--switch-disabled-color);
154
158
  }
155
- .switch__disabled_16a5o .switch__hint_16a5o {
159
+ .switch__disabled_qfjsc .switch__hint_qfjsc {
156
160
  color: var(--switch-disabled-color);
157
161
  }
162
+ /* Inactive */
163
+ .switch__inactive_qfjsc {
164
+ cursor: var(--disabled-cursor);
165
+ }
166
+ .switch__inactive_qfjsc .switch__switch_qfjsc {
167
+ background-color: var(--switch-disabled-bg-color);
168
+ border-color: var(--switch-disabled-border-color)
169
+ }
170
+ .switch__inactive_qfjsc .switch__switch_qfjsc:before {
171
+ background-color: var(--switch-inactive-color);
172
+ }
158
173
  /* Focused state */
159
- .switch__focused_16a5o .switch__switch_16a5o {
174
+ .switch__focused_qfjsc .switch__switch_qfjsc {
160
175
  outline: 2px solid var(--focus-color);
161
176
  outline-offset: 2px;
162
177
  }
package/dist/index.css CHANGED
@@ -1,6 +1,7 @@
1
- /* hash: 16a5o */
1
+ /* hash: tx7lo */
2
2
  :root {
3
3
  --color-light-border-link: #007aff;
4
+ --color-light-border-secondary-inverted: #b6bcc3;
4
5
  --color-light-graphic-accent: #ef3124;
5
6
  --color-light-graphic-neutral: #dbdee1;
6
7
  --color-light-graphic-primary-inverted: #fff;
@@ -44,8 +45,11 @@
44
45
  --switch-disabled-color: var(--color-light-text-secondary);
45
46
  --switch-disabled-bg-color: var(--color-light-graphic-neutral);
46
47
  --switch-disabled-border-color: var(--color-light-graphic-neutral);
48
+
49
+ /* inactive */
50
+ --switch-inactive-color: var(--color-light-border-secondary-inverted);
47
51
  }
48
- .switch__component_16a5o {
52
+ .switch__component_qfjsc {
49
53
  display: inline-flex;
50
54
  align-items: flex-start;
51
55
  margin: 0;
@@ -54,25 +58,25 @@
54
58
  cursor: pointer;
55
59
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
56
60
  }
57
- .switch__component_16a5o input {
61
+ .switch__component_qfjsc input {
58
62
  opacity: 0;
59
63
  position: absolute;
60
64
  }
61
- .switch__start_16a5o {
65
+ .switch__start_qfjsc {
62
66
  align-items: flex-start;
63
67
  }
64
- .switch__center_16a5o {
68
+ .switch__center_qfjsc {
65
69
  align-items: center;
66
70
  }
67
- .switch__addons_16a5o {
71
+ .switch__addons_qfjsc {
68
72
  margin-left: auto;
69
73
  padding-left: var(--gap-m);
70
74
  line-height: 24px;
71
75
  }
72
- .switch__block_16a5o {
76
+ .switch__block_qfjsc {
73
77
  width: 100%;
74
78
  }
75
- .switch__switch_16a5o {
79
+ .switch__switch_qfjsc {
76
80
  position: relative;
77
81
  border-radius: var(--border-radius-xl);
78
82
  width: 36px;
@@ -84,7 +88,7 @@
84
88
  transition: background-color 0.2s ease, border-color 0.2s ease;
85
89
  box-sizing: border-box;
86
90
  }
87
- .switch__switch_16a5o:before {
91
+ .switch__switch_qfjsc:before {
88
92
  content: '';
89
93
  position: absolute;
90
94
  top: 0;
@@ -97,21 +101,21 @@
97
101
  box-sizing: border-box;
98
102
  transition: transform 0.2s ease;
99
103
  }
100
- .switch__content_16a5o {
104
+ .switch__content_qfjsc {
101
105
  margin-left: var(--gap-s);
102
106
  flex-grow: 1;
103
107
  }
104
- .switch__label_16a5o {
108
+ .switch__label_qfjsc {
105
109
  font-size: 16px;
106
110
  line-height: 24px;
107
111
  font-weight: 400;
108
112
  display: block;
109
113
  color: var(--switch-label-color);
110
114
  }
111
- .switch__label_16a5o:not(:only-child) {
115
+ .switch__label_qfjsc:not(:only-child) {
112
116
  margin-bottom: var(--gap-2xs);
113
117
  }
114
- .switch__hint_16a5o {
118
+ .switch__hint_qfjsc {
115
119
  font-size: 14px;
116
120
  line-height: 18px;
117
121
  font-weight: 400;
@@ -119,44 +123,55 @@
119
123
  color: var(--switch-hint-color);
120
124
  }
121
125
  /* Reversed state */
122
- .switch__component_16a5o.switch__reversed_16a5o {
126
+ .switch__component_qfjsc.switch__reversed_qfjsc {
123
127
  flex-direction: row-reverse;
124
128
  }
125
- .switch__reversed_16a5o .switch__content_16a5o {
129
+ .switch__reversed_qfjsc .switch__content_qfjsc {
126
130
  margin-right: var(--gap-m);
127
131
  margin-left: 0;
128
132
  }
129
- .switch__reversed_16a5o .switch__addons_16a5o {
133
+ .switch__reversed_qfjsc .switch__addons_qfjsc {
130
134
  margin-left: 0;
131
135
  padding-left: 0;
132
136
  margin-right: auto;
133
137
  padding-right: var(--gap-m);
134
138
  }
135
139
  /* Checked state */
136
- .switch__checked_16a5o .switch__switch_16a5o {
140
+ .switch__checked_qfjsc .switch__switch_qfjsc {
137
141
  background-color: var(--switch-checked-bg-color);
138
142
  border-color: var(--switch-checked-border-color);
139
143
  }
140
- .switch__checked_16a5o .switch__switch_16a5o:before {
144
+ .switch__checked_qfjsc .switch__switch_qfjsc:before {
141
145
  /* ширина компонента(36px + 2*2px) - отступы(2 * 2px) - размер кружка(20px) */
142
146
  transform: translateX(16px);
143
147
  }
144
148
  /* Disabled state */
145
- .switch__disabled_16a5o {
149
+ .switch__disabled_qfjsc {
146
150
  cursor: var(--disabled-cursor);
147
151
  }
148
- .switch__disabled_16a5o .switch__switch_16a5o {
152
+ .switch__disabled_qfjsc .switch__switch_qfjsc {
149
153
  background-color: var(--switch-disabled-bg-color);
150
154
  border-color: var(--switch-disabled-border-color);
151
155
  }
152
- .switch__disabled_16a5o .switch__label_16a5o {
156
+ .switch__disabled_qfjsc .switch__label_qfjsc {
153
157
  color: var(--switch-disabled-color);
154
158
  }
155
- .switch__disabled_16a5o .switch__hint_16a5o {
159
+ .switch__disabled_qfjsc .switch__hint_qfjsc {
156
160
  color: var(--switch-disabled-color);
157
161
  }
162
+ /* Inactive */
163
+ .switch__inactive_qfjsc {
164
+ cursor: var(--disabled-cursor);
165
+ }
166
+ .switch__inactive_qfjsc .switch__switch_qfjsc {
167
+ background-color: var(--switch-disabled-bg-color);
168
+ border-color: var(--switch-disabled-border-color)
169
+ }
170
+ .switch__inactive_qfjsc .switch__switch_qfjsc:before {
171
+ background-color: var(--switch-inactive-color);
172
+ }
158
173
  /* Focused state */
159
- .switch__focused_16a5o .switch__switch_16a5o {
174
+ .switch__focused_qfjsc .switch__switch_qfjsc {
160
175
  outline: 2px solid var(--focus-color);
161
176
  outline-offset: 2px;
162
177
  }
@@ -2,7 +2,7 @@
2
2
  import React from 'react';
3
3
  import { InputHTMLAttributes, ChangeEvent, ReactNode } from "react";
4
4
  type Align = 'start' | 'center';
5
- type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' | 'onChange'> & {
5
+ type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' | 'onChange' | 'disabled'> & {
6
6
  /**
7
7
  * Управление состоянием вкл/выкл компонента
8
8
  */
@@ -31,6 +31,14 @@ type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' |
31
31
  * Растягивать ли компонент на всю ширину
32
32
  */
33
33
  block?: boolean;
34
+ /**
35
+ * Управление состоянием включен / выключен
36
+ */
37
+ disabled?: boolean;
38
+ /**
39
+ * Управление состоянием активен / неактивен
40
+ */
41
+ inactive?: boolean;
34
42
  /**
35
43
  * Обработчик переключения компонента
36
44
  */
@@ -43,7 +51,7 @@ type SwitchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'hint' |
43
51
  */
44
52
  dataTestId?: string;
45
53
  };
46
- declare const Switch: React.ForwardRefExoticComponent<Pick<React.InputHTMLAttributes<HTMLInputElement>, "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "disabled" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "list" | "max" | "maxLength" | "min" | "minLength" | "multiple" | "name" | "pattern" | "placeholder" | "readOnly" | "required" | "size" | "src" | "step" | "value" | "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"> & {
54
+ declare const Switch: React.ForwardRefExoticComponent<Pick<React.InputHTMLAttributes<HTMLInputElement>, "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "list" | "max" | "maxLength" | "min" | "minLength" | "multiple" | "name" | "pattern" | "placeholder" | "readOnly" | "required" | "size" | "src" | "step" | "value" | "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"> & {
47
55
  /**
48
56
  * Управление состоянием вкл/выкл компонента
49
57
  */
@@ -72,6 +80,14 @@ declare const Switch: React.ForwardRefExoticComponent<Pick<React.InputHTMLAttrib
72
80
  * Растягивать ли компонент на всю ширину
73
81
  */
74
82
  block?: boolean | undefined;
83
+ /**
84
+ * Управление состоянием включен / выключен
85
+ */
86
+ disabled?: boolean | undefined;
87
+ /**
88
+ * Управление состоянием активен / неактивен
89
+ */
90
+ inactive?: boolean | undefined;
75
91
  /**
76
92
  * Обработчик переключения компонента
77
93
  */
@@ -3,10 +3,10 @@ import cn from 'classnames';
3
3
  import mergeRefs from 'react-merge-refs';
4
4
  import { useFocus } from '@alfalab/hooks';
5
5
 
6
- var styles = {"component":"switch__component_16a5o","start":"switch__start_16a5o","center":"switch__center_16a5o","addons":"switch__addons_16a5o","block":"switch__block_16a5o","switch":"switch__switch_16a5o","content":"switch__content_16a5o","label":"switch__label_16a5o","hint":"switch__hint_16a5o","reversed":"switch__reversed_16a5o","checked":"switch__checked_16a5o","disabled":"switch__disabled_16a5o","focused":"switch__focused_16a5o"};
6
+ var styles = {"component":"switch__component_qfjsc","start":"switch__start_qfjsc","center":"switch__center_qfjsc","addons":"switch__addons_qfjsc","block":"switch__block_qfjsc","switch":"switch__switch_qfjsc","content":"switch__content_qfjsc","label":"switch__label_qfjsc","hint":"switch__hint_qfjsc","reversed":"switch__reversed_qfjsc","checked":"switch__checked_qfjsc","disabled":"switch__disabled_qfjsc","inactive":"switch__inactive_qfjsc","focused":"switch__focused_qfjsc"};
7
7
  require('./index.css')
8
8
 
9
- const Switch = forwardRef(({ reversed = false, checked = false, align = 'start', addons, block, disabled, label, hint, name, value, className, onChange, dataTestId, ...restProps }, ref) => {
9
+ const Switch = forwardRef(({ reversed = false, checked = false, align = 'start', addons, block, disabled, inactive, label, hint, name, value, className, onChange, dataTestId, ...restProps }, ref) => {
10
10
  const labelRef = useRef(null);
11
11
  const [focused] = useFocus(labelRef, 'keyboard');
12
12
  const handleChange = useCallback((e) => {
@@ -18,12 +18,13 @@ const Switch = forwardRef(({ reversed = false, checked = false, align = 'start',
18
18
  // eslint-disable-next-line jsx-a11y/label-has-associated-control
19
19
  React.createElement("label", { className: cn(styles.component, styles[align], className, {
20
20
  [styles.disabled]: disabled,
21
+ [styles.inactive]: inactive,
21
22
  [styles.checked]: checked,
22
23
  [styles.reversed]: reversed,
23
24
  [styles.focused]: focused,
24
25
  [styles.block]: block,
25
26
  }), ref: mergeRefs([labelRef, ref]) },
26
- React.createElement("input", Object.assign({ type: 'checkbox', onChange: handleChange, disabled: disabled, checked: checked, name: name, value: value, "data-test-id": dataTestId }, restProps)),
27
+ React.createElement("input", Object.assign({ type: 'checkbox', onChange: handleChange, disabled: disabled || inactive, checked: checked, name: name, value: value, "data-test-id": dataTestId }, restProps)),
27
28
  React.createElement("span", { className: styles.switch }),
28
29
  (label || hint) && (React.createElement("span", { className: styles.content },
29
30
  label && React.createElement("span", { className: styles.label }, label),
@@ -1,6 +1,7 @@
1
- /* hash: 16a5o */
1
+ /* hash: tx7lo */
2
2
  :root {
3
3
  --color-light-border-link: #007aff;
4
+ --color-light-border-secondary-inverted: #b6bcc3;
4
5
  --color-light-graphic-accent: #ef3124;
5
6
  --color-light-graphic-neutral: #dbdee1;
6
7
  --color-light-graphic-primary-inverted: #fff;
@@ -44,8 +45,11 @@
44
45
  --switch-disabled-color: var(--color-light-text-secondary);
45
46
  --switch-disabled-bg-color: var(--color-light-graphic-neutral);
46
47
  --switch-disabled-border-color: var(--color-light-graphic-neutral);
48
+
49
+ /* inactive */
50
+ --switch-inactive-color: var(--color-light-border-secondary-inverted);
47
51
  }
48
- .switch__component_16a5o {
52
+ .switch__component_qfjsc {
49
53
  display: inline-flex;
50
54
  align-items: flex-start;
51
55
  margin: 0;
@@ -54,25 +58,25 @@
54
58
  cursor: pointer;
55
59
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
56
60
  }
57
- .switch__component_16a5o input {
61
+ .switch__component_qfjsc input {
58
62
  opacity: 0;
59
63
  position: absolute;
60
64
  }
61
- .switch__start_16a5o {
65
+ .switch__start_qfjsc {
62
66
  align-items: flex-start;
63
67
  }
64
- .switch__center_16a5o {
68
+ .switch__center_qfjsc {
65
69
  align-items: center;
66
70
  }
67
- .switch__addons_16a5o {
71
+ .switch__addons_qfjsc {
68
72
  margin-left: auto;
69
73
  padding-left: var(--gap-m);
70
74
  line-height: 24px;
71
75
  }
72
- .switch__block_16a5o {
76
+ .switch__block_qfjsc {
73
77
  width: 100%;
74
78
  }
75
- .switch__switch_16a5o {
79
+ .switch__switch_qfjsc {
76
80
  position: relative;
77
81
  border-radius: var(--border-radius-xl);
78
82
  width: 36px;
@@ -84,7 +88,7 @@
84
88
  transition: background-color 0.2s ease, border-color 0.2s ease;
85
89
  box-sizing: border-box;
86
90
  }
87
- .switch__switch_16a5o:before {
91
+ .switch__switch_qfjsc:before {
88
92
  content: '';
89
93
  position: absolute;
90
94
  top: 0;
@@ -97,21 +101,21 @@
97
101
  box-sizing: border-box;
98
102
  transition: transform 0.2s ease;
99
103
  }
100
- .switch__content_16a5o {
104
+ .switch__content_qfjsc {
101
105
  margin-left: var(--gap-s);
102
106
  flex-grow: 1;
103
107
  }
104
- .switch__label_16a5o {
108
+ .switch__label_qfjsc {
105
109
  font-size: 16px;
106
110
  line-height: 24px;
107
111
  font-weight: 400;
108
112
  display: block;
109
113
  color: var(--switch-label-color);
110
114
  }
111
- .switch__label_16a5o:not(:only-child) {
115
+ .switch__label_qfjsc:not(:only-child) {
112
116
  margin-bottom: var(--gap-2xs);
113
117
  }
114
- .switch__hint_16a5o {
118
+ .switch__hint_qfjsc {
115
119
  font-size: 14px;
116
120
  line-height: 18px;
117
121
  font-weight: 400;
@@ -119,44 +123,55 @@
119
123
  color: var(--switch-hint-color);
120
124
  }
121
125
  /* Reversed state */
122
- .switch__component_16a5o.switch__reversed_16a5o {
126
+ .switch__component_qfjsc.switch__reversed_qfjsc {
123
127
  flex-direction: row-reverse;
124
128
  }
125
- .switch__reversed_16a5o .switch__content_16a5o {
129
+ .switch__reversed_qfjsc .switch__content_qfjsc {
126
130
  margin-right: var(--gap-m);
127
131
  margin-left: 0;
128
132
  }
129
- .switch__reversed_16a5o .switch__addons_16a5o {
133
+ .switch__reversed_qfjsc .switch__addons_qfjsc {
130
134
  margin-left: 0;
131
135
  padding-left: 0;
132
136
  margin-right: auto;
133
137
  padding-right: var(--gap-m);
134
138
  }
135
139
  /* Checked state */
136
- .switch__checked_16a5o .switch__switch_16a5o {
140
+ .switch__checked_qfjsc .switch__switch_qfjsc {
137
141
  background-color: var(--switch-checked-bg-color);
138
142
  border-color: var(--switch-checked-border-color);
139
143
  }
140
- .switch__checked_16a5o .switch__switch_16a5o:before {
144
+ .switch__checked_qfjsc .switch__switch_qfjsc:before {
141
145
  /* ширина компонента(36px + 2*2px) - отступы(2 * 2px) - размер кружка(20px) */
142
146
  transform: translateX(16px);
143
147
  }
144
148
  /* Disabled state */
145
- .switch__disabled_16a5o {
149
+ .switch__disabled_qfjsc {
146
150
  cursor: var(--disabled-cursor);
147
151
  }
148
- .switch__disabled_16a5o .switch__switch_16a5o {
152
+ .switch__disabled_qfjsc .switch__switch_qfjsc {
149
153
  background-color: var(--switch-disabled-bg-color);
150
154
  border-color: var(--switch-disabled-border-color);
151
155
  }
152
- .switch__disabled_16a5o .switch__label_16a5o {
156
+ .switch__disabled_qfjsc .switch__label_qfjsc {
153
157
  color: var(--switch-disabled-color);
154
158
  }
155
- .switch__disabled_16a5o .switch__hint_16a5o {
159
+ .switch__disabled_qfjsc .switch__hint_qfjsc {
156
160
  color: var(--switch-disabled-color);
157
161
  }
162
+ /* Inactive */
163
+ .switch__inactive_qfjsc {
164
+ cursor: var(--disabled-cursor);
165
+ }
166
+ .switch__inactive_qfjsc .switch__switch_qfjsc {
167
+ background-color: var(--switch-disabled-bg-color);
168
+ border-color: var(--switch-disabled-border-color)
169
+ }
170
+ .switch__inactive_qfjsc .switch__switch_qfjsc:before {
171
+ background-color: var(--switch-inactive-color);
172
+ }
158
173
  /* Focused state */
159
- .switch__focused_16a5o .switch__switch_16a5o {
174
+ .switch__focused_qfjsc .switch__switch_qfjsc {
160
175
  outline: 2px solid var(--focus-color);
161
176
  outline-offset: 2px;
162
177
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-switch",
3
- "version": "2.1.0",
3
+ "version": "2.2.2",
4
4
  "description": "",
5
- "gitHead": "b0ac874c516285023648e00c68eb234e1fca38d6",
5
+ "gitHead": "0363f194b7d8e6d2949795b8f0570262d7028aff",
6
6
  "keywords": [],
7
7
  "license": "MIT",
8
8
  "main": "dist/index.js",
@@ -20,8 +20,8 @@
20
20
  "react": "^16.9.0 || ^17.0.1"
21
21
  },
22
22
  "dependencies": {
23
- "@alfalab/hooks": "^1.0.0",
24
- "classnames": "^2.2.6",
25
- "react-merge-refs": "^1.1.0"
23
+ "@alfalab/hooks": "^1.4.1",
24
+ "classnames": "2.2.6",
25
+ "react-merge-refs": "1.1.0"
26
26
  }
27
27
  }