@rescui/switcher 0.3.5 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.css CHANGED
@@ -1,4 +1,4 @@
1
- ._switcher_f27dmz_4{
1
+ ._switcher_1h7wmbn_4{
2
2
  position:relative;
3
3
 
4
4
  display:-webkit-inline-box;
@@ -15,21 +15,21 @@
15
15
 
16
16
  background:transparent;
17
17
  }
18
- ._themeLight_f27dmz_16{
18
+ ._themeLight_1h7wmbn_16{
19
19
  -webkit-box-shadow:inset rgba(25,25,28,0.4) 0 0 0 1px;
20
20
  box-shadow:inset rgba(25,25,28,0.4) 0 0 0 1px;
21
21
  }
22
- ._themeDark_f27dmz_20{
22
+ ._themeDark_1h7wmbn_20{
23
23
  -webkit-box-shadow:inset rgba(255,255,255,0.5) 0 0 0 1px;
24
24
  box-shadow:inset rgba(255,255,255,0.5) 0 0 0 1px;
25
25
  }
26
- ._sizeL_f27dmz_24{
26
+ ._sizeL_1h7wmbn_24{
27
27
  border-radius:36px;
28
28
  }
29
- ._sizeXS_f27dmz_28{
29
+ ._sizeXS_1h7wmbn_28{
30
30
  border-radius:4px;
31
31
  }
32
- ._option_f27dmz_32{
32
+ ._option_1h7wmbn_32{
33
33
  position:relative;
34
34
  -webkit-appearance:none;
35
35
  -moz-appearance:none;
@@ -49,7 +49,7 @@
49
49
 
50
50
  background:transparent;
51
51
  }
52
- ._sizeL_f27dmz_24 ._option_f27dmz_32{
52
+ ._sizeL_1h7wmbn_24 ._option_1h7wmbn_32{
53
53
  padding:12px 32px;
54
54
  font-family:'JetBrains Sans', Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Droid Sans', 'Helvetica Neue', Arial, sans-serif;
55
55
  font-family:var(--rs-font-family-ui, var(--rs-font-family-jb-sans, 'JetBrains Sans', Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Droid Sans', 'Helvetica Neue', Arial, sans-serif));
@@ -62,7 +62,7 @@
62
62
  line-height:var(--rs-text-1-line-height, 28px);
63
63
  border-radius:36px;
64
64
  }
65
- ._sizeM_f27dmz_55 ._option_f27dmz_32{
65
+ ._sizeM_1h7wmbn_55 ._option_1h7wmbn_32{
66
66
  padding:8px 24px;
67
67
  letter-spacing:0.0015em;
68
68
  font-family:'JetBrains Sans', Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Droid Sans', 'Helvetica Neue', Arial, sans-serif;
@@ -75,26 +75,25 @@
75
75
  line-height:24px;
76
76
  line-height:var(--rs-text-2-line-height, 24px);
77
77
  }
78
- ._rs-reset-letter-spacing_f27dmz_1 ._sizeM_f27dmz_55 ._option_f27dmz_32{
78
+ ._rs-reset-letter-spacing_1h7wmbn_1 ._sizeM_1h7wmbn_55 ._option_1h7wmbn_32{
79
79
  letter-spacing:normal;
80
80
  }
81
- ._sizeS_f27dmz_60 ._option_f27dmz_32{
81
+ ._sizeS_1h7wmbn_60 ._option_1h7wmbn_32{
82
82
  padding:6px 16px;
83
- letter-spacing:0.0015em;
83
+ letter-spacing:0.0045em;
84
84
  font-family:'JetBrains Sans', Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Droid Sans', 'Helvetica Neue', Arial, sans-serif;
85
85
  font-family:var(--rs-font-family-ui, var(--rs-font-family-jb-sans, 'JetBrains Sans', Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Droid Sans', 'Helvetica Neue', Arial, sans-serif));
86
86
  -webkit-font-feature-settings:"kern", "liga", "calt";
87
87
  font-feature-settings:"kern", "liga", "calt";
88
- font-size:16px;
89
- font-size:var(--rs-text-2-font-size, 16px);
90
- font-weight:400;
91
- line-height:24px;
92
- line-height:var(--rs-text-2-line-height, 24px);
88
+ font-size:13px;
89
+ font-size:var(--rs-text-3-font-size, 13px);
90
+ line-height:20px;
91
+ line-height:var(--rs-text-3-line-height, 20px);
93
92
  }
94
- ._rs-reset-letter-spacing_f27dmz_1 ._sizeS_f27dmz_60 ._option_f27dmz_32{
93
+ ._rs-reset-letter-spacing_1h7wmbn_1 ._sizeS_1h7wmbn_60 ._option_1h7wmbn_32{
95
94
  letter-spacing:normal;
96
95
  }
97
- ._sizeXS_f27dmz_28 ._option_f27dmz_32{
96
+ ._sizeXS_1h7wmbn_28 ._option_1h7wmbn_32{
98
97
  padding:2px 12px;
99
98
  letter-spacing:0.0045em;
100
99
  font-family:'JetBrains Sans', Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Droid Sans', 'Helvetica Neue', Arial, sans-serif;
@@ -106,68 +105,68 @@
106
105
  line-height:20px;
107
106
  line-height:var(--rs-text-3-line-height, 20px);
108
107
  }
109
- ._rs-reset-letter-spacing_f27dmz_1 ._sizeXS_f27dmz_28 ._option_f27dmz_32{
108
+ ._rs-reset-letter-spacing_1h7wmbn_1 ._sizeXS_1h7wmbn_28 ._option_1h7wmbn_32{
110
109
  letter-spacing:normal;
111
110
  }
112
- ._sizeXS_f27dmz_28 ._option_f27dmz_32 {
111
+ ._sizeXS_1h7wmbn_28 ._option_1h7wmbn_32 {
113
112
  border-radius:4px;
114
113
  }
115
- ._disabled_f27dmz_71 ._option_f27dmz_32{
114
+ ._disabled_1h7wmbn_71 ._option_1h7wmbn_32{
116
115
  cursor:not-allowed;
117
116
  pointer-events:none;
118
117
  }
119
- ._themeLight_f27dmz_16 ._option_f27dmz_32{
118
+ ._themeLight_1h7wmbn_16 ._option_1h7wmbn_32{
120
119
  color:#19191C;
121
120
  }
122
- ._themeLight_f27dmz_16 ._option_f27dmz_32:focus[data-focus-method='key']{
121
+ ._themeLight_1h7wmbn_16 ._option_1h7wmbn_32:focus[data-focus-method='key']{
123
122
  -webkit-box-shadow:rgba(107, 87, 255, 0.8) 0 0 0 4px;
124
123
  -webkit-box-shadow:var(--rs-color-primary-t-dim-light-theme, rgba(107, 87, 255, 0.8)) 0 0 0 4px;
125
124
  box-shadow:rgba(107, 87, 255, 0.8) 0 0 0 4px;
126
125
  box-shadow:var(--rs-color-primary-t-dim-light-theme, rgba(107, 87, 255, 0.8)) 0 0 0 4px;
127
126
  }
128
- ._themeLight_f27dmz_16 ._option_f27dmz_32._selected_f27dmz_84:hover, ._themeLight_f27dmz_16 ._option_f27dmz_32._selected_f27dmz_84:active{
127
+ ._themeLight_1h7wmbn_16 ._option_1h7wmbn_32._selected_1h7wmbn_84:hover, ._themeLight_1h7wmbn_16 ._option_1h7wmbn_32._selected_1h7wmbn_84:active{
129
128
  background:transparent;
130
129
  cursor:default;
131
130
  }
132
- ._themeLight_f27dmz_16._modeClassic_f27dmz_92 ._option_f27dmz_32:hover{
131
+ ._themeLight_1h7wmbn_16._modeClassic_1h7wmbn_92 ._option_1h7wmbn_32:hover{
133
132
  background:rgba(107, 87, 255,0.2);
134
133
  background:var(--rs-color-primary-t-fog-light-theme, rgba(107, 87, 255,0.2));
135
134
  }
136
- ._themeLight_f27dmz_16._modeRock_f27dmz_98 ._option_f27dmz_32:hover{
135
+ ._themeLight_1h7wmbn_16._modeRock_1h7wmbn_98 ._option_1h7wmbn_32:hover{
137
136
  background:rgba(25,25,28,0.1);
138
137
  }
139
- ._disabled_f27dmz_71._themeLight_f27dmz_16 ._option_f27dmz_32,
140
- ._disabled_f27dmz_71._themeLight_f27dmz_16 ._option_f27dmz_32._selected_f27dmz_84{
138
+ ._disabled_1h7wmbn_71._themeLight_1h7wmbn_16 ._option_1h7wmbn_32,
139
+ ._disabled_1h7wmbn_71._themeLight_1h7wmbn_16 ._option_1h7wmbn_32._selected_1h7wmbn_84{
141
140
  color:rgba(25,25,28,0.4);
142
141
  }
143
- ._themeDark_f27dmz_20 ._option_f27dmz_32{
142
+ ._themeDark_1h7wmbn_20 ._option_1h7wmbn_32{
144
143
  color:#FFFFFF;
145
144
  }
146
- ._themeDark_f27dmz_20 ._option_f27dmz_32:hover{
145
+ ._themeDark_1h7wmbn_20 ._option_1h7wmbn_32:hover{
147
146
  background:rgba(255,255,255,0.1);
148
147
  }
149
- ._themeDark_f27dmz_20 ._option_f27dmz_32:focus[data-focus-method='key']{
148
+ ._themeDark_1h7wmbn_20 ._option_1h7wmbn_32:focus[data-focus-method='key']{
150
149
  -webkit-box-shadow:rgba(132, 115, 255,0.8) 0 0 0 4px;
151
150
  -webkit-box-shadow:var(--rs-color-primary-t-dim-dark-theme, rgba(132, 115, 255,0.8)) 0 0 0 4px;
152
151
  box-shadow:rgba(132, 115, 255,0.8) 0 0 0 4px;
153
152
  box-shadow:var(--rs-color-primary-t-dim-dark-theme, rgba(132, 115, 255,0.8)) 0 0 0 4px;
154
153
  }
155
- ._themeDark_f27dmz_20 ._option_f27dmz_32._selected_f27dmz_84:hover, ._themeDark_f27dmz_20 ._option_f27dmz_32._selected_f27dmz_84:active{
154
+ ._themeDark_1h7wmbn_20 ._option_1h7wmbn_32._selected_1h7wmbn_84:hover, ._themeDark_1h7wmbn_20 ._option_1h7wmbn_32._selected_1h7wmbn_84:active{
156
155
  background:transparent;
157
156
  cursor:default;
158
157
  }
159
- ._themeDark_f27dmz_20._modeClassic_f27dmz_92 ._option_f27dmz_32:hover{
158
+ ._themeDark_1h7wmbn_20._modeClassic_1h7wmbn_92 ._option_1h7wmbn_32:hover{
160
159
  background:rgba(132, 115, 255,0.3);
161
160
  background:var(--rs-color-primary-t-fog-dark-theme, rgba(132, 115, 255,0.3));
162
161
  }
163
- ._themeDark_f27dmz_20._modeRock_f27dmz_98 ._option_f27dmz_32:hover{
162
+ ._themeDark_1h7wmbn_20._modeRock_1h7wmbn_98 ._option_1h7wmbn_32:hover{
164
163
  background:rgba(255,255,255,0.1);
165
164
  }
166
- ._disabled_f27dmz_71._themeDark_f27dmz_20 ._option_f27dmz_32,
167
- ._disabled_f27dmz_71._themeDark_f27dmz_20 ._option_f27dmz_32._selected_f27dmz_84{
165
+ ._disabled_1h7wmbn_71._themeDark_1h7wmbn_20 ._option_1h7wmbn_32,
166
+ ._disabled_1h7wmbn_71._themeDark_1h7wmbn_20 ._option_1h7wmbn_32._selected_1h7wmbn_84{
168
167
  color:rgba(255,255,255,0.2);
169
168
  }
170
- ._mark_f27dmz_145{
169
+ ._mark_1h7wmbn_145{
171
170
  position:absolute;
172
171
  top:0;
173
172
  bottom:0;
@@ -175,32 +174,32 @@
175
174
  -webkit-box-sizing:border-box;
176
175
  box-sizing:border-box;
177
176
  border-radius:24px;
178
- -webkit-transition:all 0.3s;
179
- transition:all 0.3s;
177
+ -webkit-transition:all 0.2s;
178
+ transition:all 0.2s;
180
179
  }
181
- ._themeLight_f27dmz_16._modeClassic_f27dmz_92 ._mark_f27dmz_145{
180
+ ._themeLight_1h7wmbn_16._modeClassic_1h7wmbn_92 ._mark_1h7wmbn_145{
182
181
  border:solid 2px #6B57FF;
183
182
  border:solid 2px var(--rs-color-primary-light-theme, #6B57FF);
184
183
  }
185
- ._themeDark_f27dmz_20._modeClassic_f27dmz_92 ._mark_f27dmz_145{
184
+ ._themeDark_1h7wmbn_20._modeClassic_1h7wmbn_92 ._mark_1h7wmbn_145{
186
185
  border:solid 2px #8473FF;
187
186
  border:solid 2px var(--rs-color-primary-dark-theme, #8473FF);
188
187
  }
189
- ._themeLight_f27dmz_16._modeRock_f27dmz_98 ._mark_f27dmz_145{
188
+ ._themeLight_1h7wmbn_16._modeRock_1h7wmbn_98 ._mark_1h7wmbn_145{
190
189
  border:solid 2px #19191C;
191
190
  }
192
- ._themeDark_f27dmz_20._modeRock_f27dmz_98 ._mark_f27dmz_145{
191
+ ._themeDark_1h7wmbn_20._modeRock_1h7wmbn_98 ._mark_1h7wmbn_145{
193
192
  border:solid 2px #FFFFFF;
194
193
  }
195
- ._sizeL_f27dmz_24 ._mark_f27dmz_145{
194
+ ._sizeL_1h7wmbn_24 ._mark_1h7wmbn_145{
196
195
  border-radius:36px;
197
196
  }
198
- ._sizeXS_f27dmz_28 ._mark_f27dmz_145{
197
+ ._sizeXS_1h7wmbn_28 ._mark_1h7wmbn_145{
199
198
  border-radius:4px;
200
199
  }
201
- ._themeLight_f27dmz_16._disabled_f27dmz_71 ._mark_f27dmz_145{
200
+ ._themeLight_1h7wmbn_16._disabled_1h7wmbn_71 ._mark_1h7wmbn_145{
202
201
  border:solid 2px rgba(25,25,28,0.4);
203
202
  }
204
- ._themeDark_f27dmz_20._disabled_f27dmz_71 ._mark_f27dmz_145{
203
+ ._themeDark_1h7wmbn_20._disabled_1h7wmbn_71 ._mark_1h7wmbn_145{
205
204
  border:solid 2px rgba(255,255,255,0.2);
206
205
  }
package/lib/index.d.ts CHANGED
@@ -1 +1,2 @@
1
- export { default } from './switcher';
1
+ export { default, Switcher } from './switcher';
2
+ export type { SwitcherProps } from './switcher';
package/lib/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import './index.css';
2
- export { Switcher as default } from './switcher.js';
2
+ export { Switcher, Switcher as default } from './switcher.js';
@@ -1,17 +1,17 @@
1
1
  var styles = {
2
- "switcher": "_switcher_f27dmz_4",
3
- "themeLight": "_themeLight_f27dmz_16",
4
- "themeDark": "_themeDark_f27dmz_20",
5
- "sizeL": "_sizeL_f27dmz_24",
6
- "sizeXS": "_sizeXS_f27dmz_28",
7
- "option": "_option_f27dmz_32",
8
- "sizeM": "_sizeM_f27dmz_55",
9
- "rs-reset-letter-spacing": "_rs-reset-letter-spacing_f27dmz_1",
10
- "sizeS": "_sizeS_f27dmz_60",
11
- "disabled": "_disabled_f27dmz_71",
12
- "selected": "_selected_f27dmz_84",
13
- "modeClassic": "_modeClassic_f27dmz_92",
14
- "modeRock": "_modeRock_f27dmz_98",
15
- "mark": "_mark_f27dmz_145"
2
+ "switcher": "_switcher_1h7wmbn_4",
3
+ "themeLight": "_themeLight_1h7wmbn_16",
4
+ "themeDark": "_themeDark_1h7wmbn_20",
5
+ "sizeL": "_sizeL_1h7wmbn_24",
6
+ "sizeXS": "_sizeXS_1h7wmbn_28",
7
+ "option": "_option_1h7wmbn_32",
8
+ "sizeM": "_sizeM_1h7wmbn_55",
9
+ "rs-reset-letter-spacing": "_rs-reset-letter-spacing_1h7wmbn_1",
10
+ "sizeS": "_sizeS_1h7wmbn_60",
11
+ "disabled": "_disabled_1h7wmbn_71",
12
+ "selected": "_selected_1h7wmbn_84",
13
+ "modeClassic": "_modeClassic_1h7wmbn_92",
14
+ "modeRock": "_modeRock_1h7wmbn_98",
15
+ "mark": "_mark_1h7wmbn_145"
16
16
  };
17
17
  export { styles as default };
package/lib/switcher.d.ts CHANGED
@@ -1,22 +1,28 @@
1
1
  import React from 'react';
2
- export declare type SwitcherValue = string | number | null | symbol | boolean;
3
- export interface SwitcherOption<ValueType extends SwitcherValue> {
2
+ export interface SwitcherOption<OptionsValueType> {
4
3
  label: React.ReactNode;
5
- value: ValueType;
4
+ value: OptionsValueType;
6
5
  }
7
6
  export declare type SwitcherSize = 'l' | 'm' | 's' | 'xs';
8
7
  export declare type SwitcherTheme = 'light' | 'dark';
9
8
  export declare type SwitcherMode = 'rock' | 'classic';
10
- export interface SwitcherProps<ValueType extends SwitcherValue> {
11
- options: SwitcherOption<ValueType>[];
9
+ export interface SwitcherProps<ValueType, OptionsValueType extends ValueType> {
10
+ /** Current selected value */
12
11
  value: ValueType;
13
- onChange: (value: ValueType) => any;
12
+ /** Array of options */
13
+ options?: SwitcherOption<OptionsValueType>[];
14
+ onChange: (value: OptionsValueType) => void;
14
15
  className?: string;
15
16
  theme?: SwitcherTheme;
16
17
  size?: SwitcherSize;
18
+ /** Appearance mode */
17
19
  mode?: SwitcherMode;
18
20
  disabled?: boolean;
21
+ /** Identifier for e2e tests */
19
22
  'data-e2e'?: string;
20
23
  }
21
- export declare const Switcher: React.FC<SwitcherProps<SwitcherValue>>;
24
+ export declare function Switcher<ValueType, OptionsValueType extends ValueType = ValueType>({ className, theme: themeFromProps, size, disabled, ['data-e2e']: e2eId, options, value: switcherValue, mode, onChange }: SwitcherProps<ValueType, OptionsValueType>): JSX.Element;
25
+ export declare namespace Switcher {
26
+ var propTypes: {};
27
+ }
22
28
  export default Switcher;
package/lib/switcher.js CHANGED
@@ -3,11 +3,11 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
3
3
  import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
4
4
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
5
5
  import "core-js/modules/es.object.to-string.js";
6
- import React, { useState, useRef, useMemo, useCallback } from 'react';
6
+ import React, { useRef, useMemo, useCallback, useState, useEffect } from 'react';
7
7
  import PropTypes from 'prop-types';
8
- import { useResizeDetector } from 'react-resize-detector';
9
8
  import cn from 'classnames';
10
9
  import { useTheme } from '@rescui/ui-contexts';
10
+ import { useResizeObserver } from '@rescui/use-resize-observer';
11
11
  import styles from './index.p.module.css.js';
12
12
  var sizeToClass = {
13
13
  l: styles.sizeL,
@@ -58,7 +58,7 @@ var optionRenderer = function optionRenderer(_ref, ref) {
58
58
 
59
59
  var Option = /*#__PURE__*/React.forwardRef(optionRenderer);
60
60
 
61
- var Switcher = function Switcher(_ref2) {
61
+ function Switcher(_ref2) {
62
62
  var className = _ref2.className,
63
63
  themeFromProps = _ref2.theme,
64
64
  _ref2$size = _ref2.size,
@@ -70,20 +70,11 @@ var Switcher = function Switcher(_ref2) {
70
70
  _ref2$mode = _ref2.mode,
71
71
  mode = _ref2$mode === void 0 ? 'classic' : _ref2$mode,
72
72
  onChange = _ref2.onChange;
73
-
74
- var _useState = useState(false),
75
- _useState2 = _slicedToArray(_useState, 2),
76
- setDummyState = _useState2[1];
77
-
78
73
  var refsArray = useRef([]);
74
+ var containerRef = useRef(null);
79
75
  var theme = useTheme(themeFromProps);
76
+ var optionsHash = hashOptions(options); // eslint-disable-next-line react-hooks/exhaustive-deps
80
77
 
81
- var _useResizeDetector = useResizeDetector({
82
- handleHeight: false
83
- }),
84
- resizeDetectorRef = _useResizeDetector.ref;
85
-
86
- var optionsHash = hashOptions(options);
87
78
  var memoizedOptions = useMemo(function () {
88
79
  return options;
89
80
  }, [optionsHash]);
@@ -94,28 +85,45 @@ var Switcher = function Switcher(_ref2) {
94
85
  }
95
86
 
96
87
  if (refsArray.current[index] !== ref) {
97
- refsArray.current[index] = ref; // force rerender
98
-
99
- setDummyState(function (s) {
100
- return !s;
101
- });
88
+ refsArray.current[index] = ref;
102
89
  }
103
90
  };
104
91
  }, []);
105
92
  var activeIndex = findIndexByValue(memoizedOptions, switcherValue);
106
- var activeRef = refsArray.current[activeIndex];
107
- var markOffset = 0;
108
- var markWidth = 0;
109
93
 
110
- if (activeRef) {
111
- markOffset = activeRef.offsetLeft;
112
- markWidth = activeRef.getBoundingClientRect().width;
113
- }
94
+ var _useState = useState({
95
+ offset: 0,
96
+ width: 0
97
+ }),
98
+ _useState2 = _slicedToArray(_useState, 2),
99
+ mark = _useState2[0],
100
+ setMark = _useState2[1];
101
+
102
+ var onResize = function onResize() {
103
+ var activeEl = refsArray.current[activeIndex];
104
+
105
+ if (!activeEl) {
106
+ return;
107
+ }
108
+
109
+ var activeElBox = activeEl.getBoundingClientRect();
110
+ var parentBox = activeEl.parentElement.getBoundingClientRect();
111
+ setMark({
112
+ // standard activeEl.offsetLeft always return rounded value, so it does not suit us
113
+ offset: activeElBox.left - parentBox.left,
114
+ width: activeElBox.width
115
+ });
116
+ }; // eslint-disable-next-line react-hooks/exhaustive-deps
117
+
114
118
 
119
+ useEffect(function () {
120
+ return onResize();
121
+ }, [activeIndex]);
122
+ useResizeObserver(containerRef, onResize);
115
123
  return /*#__PURE__*/React.createElement("span", {
116
- ref: resizeDetectorRef,
117
124
  className: cn(className, styles.switcher, sizeToClass[size], themeToClass[theme], modeToClass[mode], disabled && styles.disabled),
118
125
  "data-e2e": e2eId,
126
+ ref: containerRef,
119
127
  "data-test": "switcher".concat(disabled ? '-disabled' : '')
120
128
  }, _mapInstanceProperty(memoizedOptions).call(memoizedOptions, function (_ref3, index) {
121
129
  var value = _ref3.value,
@@ -134,29 +142,24 @@ var Switcher = function Switcher(_ref2) {
134
142
  }), /*#__PURE__*/React.createElement("span", {
135
143
  className: cn(styles.mark),
136
144
  style: {
137
- left: markOffset,
138
- width: markWidth
145
+ left: mark.offset,
146
+ width: mark.width
139
147
  }
140
148
  }));
141
- };
149
+ }
142
150
 
143
- var switcherValuePropType = PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.symbol, PropTypes.bool]);
144
151
  var optionPropType = PropTypes.shape({
145
152
  label: PropTypes.node.isRequired,
146
- value: switcherValuePropType.isRequired
153
+ value: PropTypes.any.isRequired
147
154
  });
148
155
  Switcher.propTypes = {
149
156
  options: PropTypes.arrayOf(optionPropType).isRequired,
150
- value: switcherValuePropType.isRequired,
151
157
  onChange: PropTypes.func.isRequired,
158
+ value: PropTypes.any.isRequired,
152
159
  className: PropTypes.string,
153
160
  size: PropTypes.oneOf(['l', 'm', 's', 'xs']),
154
161
  theme: PropTypes.oneOf(['light', 'dark']),
155
162
  disabled: PropTypes.bool,
156
-
157
- /**
158
- * Identifier for e2e tests
159
- * */
160
163
  'data-e2e': PropTypes.string
161
164
  };
162
165
  export { Switcher, Switcher as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rescui/switcher",
3
- "version": "0.3.5",
3
+ "version": "0.4.0",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "author": "JetBrains",
@@ -16,9 +16,9 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@babel/runtime-corejs3": "^7.14.0",
19
+ "@rescui/use-resize-observer": "^0.1.0",
19
20
  "classnames": "^2.2.6",
20
- "core-js": "^3.9.1",
21
- "react-resize-detector": "^6.7.3"
21
+ "core-js": "^3.9.1"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@rescui/ui-contexts": "<0.4.0",
@@ -26,12 +26,12 @@
26
26
  "react": ">=16.8.0 <18"
27
27
  },
28
28
  "devDependencies": {
29
- "@rescui/colors": "^0.1.4",
29
+ "@rescui/colors": "^0.1.5",
30
30
  "@rescui/scripts": "^0.1.7",
31
- "@rescui/typography": "^0.8.2"
31
+ "@rescui/typography": "^0.8.3"
32
32
  },
33
33
  "scripts": {
34
34
  "build": "rescui-scripts build"
35
35
  },
36
- "gitHead": "399d5bcaf892b517a4b5d8108d509ed6549629f2"
36
+ "gitHead": "341ecc94b9a50ccb3b10d07a16162fbc350c2135"
37
37
  }