@spaced-out/ui-design-system 0.1.120 → 0.1.122
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 +16 -0
- package/lib/components/Button/Button.js +6 -1
- package/lib/components/Button/Button.js.flow +7 -1
- package/lib/components/Button/index.js +6 -0
- package/lib/components/Button/index.js.flow +2 -0
- package/lib/components/Input/Input.js +4 -2
- package/lib/components/Input/Input.js.flow +12 -4
- package/lib/components/Input/Input.module.css +12 -0
- package/lib/components/RangeSlider/RangeSlider.js +63 -32
- package/lib/components/RangeSlider/RangeSlider.js.flow +90 -43
- package/lib/components/RangeSlider/RangeSlider.module.css +19 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.122](https://github.com/spaced-out/ui-design-system/compare/v0.1.121...v0.1.122) (2024-08-22)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* ↕️ added option to hide spinner for number input, exposes wrapper classname for input ([05267ee](https://github.com/spaced-out/ui-design-system/commit/05267eeef9dd984d5e6d6030f778ed197d518cf0))
|
|
11
|
+
* 🛝 slider enhancements to add value input in the right slot, min max range indicators as config ([eecd31a](https://github.com/spaced-out/ui-design-system/commit/eecd31ae53dd460f08d7c31ea648d0aa20d3ca1d))
|
|
12
|
+
|
|
13
|
+
### [0.1.121](https://github.com/spaced-out/ui-design-system/compare/v0.1.120...v0.1.121) (2024-08-20)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* 👻 added ghost buttons for range slider instead of clickable buttons ([ddff85a](https://github.com/spaced-out/ui-design-system/commit/ddff85a2202363132a530f8ed288279d182d1d2b))
|
|
19
|
+
* accessibility fixes for range slider ([67d4f94](https://github.com/spaced-out/ui-design-system/commit/67d4f9450e687a46162c1c3a8fa8c6ee7c8e5115))
|
|
20
|
+
|
|
5
21
|
### [0.1.120](https://github.com/spaced-out/ui-design-system/compare/v0.1.119...v0.1.120) (2024-08-19)
|
|
6
22
|
|
|
7
23
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.UnstyledButton = exports.Button = exports.BUTTON_TYPES = exports.BUTTON_ACTION_TYPE = void 0;
|
|
6
|
+
exports.UnstyledButton = exports.Button = exports.BUTTON_TYPES = exports.BUTTON_SIZE = exports.BUTTON_ACTION_TYPE = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _classify = require("../../utils/classify");
|
|
9
9
|
var _CircularLoader = require("../CircularLoader");
|
|
@@ -38,6 +38,11 @@ const BUTTON_ACTION_TYPE = Object.freeze({
|
|
|
38
38
|
reset: 'reset'
|
|
39
39
|
});
|
|
40
40
|
exports.BUTTON_ACTION_TYPE = BUTTON_ACTION_TYPE;
|
|
41
|
+
const BUTTON_SIZE = Object.freeze({
|
|
42
|
+
small: 'small',
|
|
43
|
+
medium: 'medium'
|
|
44
|
+
});
|
|
45
|
+
exports.BUTTON_SIZE = BUTTON_SIZE;
|
|
41
46
|
const ButtonTypeToIconColorMap = {
|
|
42
47
|
primary: 'inversePrimary',
|
|
43
48
|
secondary: 'clickable',
|
|
@@ -37,8 +37,14 @@ export const BUTTON_ACTION_TYPE = Object.freeze({
|
|
|
37
37
|
reset: 'reset',
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
+
export const BUTTON_SIZE = Object.freeze({
|
|
41
|
+
small: 'small',
|
|
42
|
+
medium: 'medium',
|
|
43
|
+
});
|
|
44
|
+
|
|
40
45
|
export type ButtonType = $Values<typeof BUTTON_TYPES>;
|
|
41
46
|
export type ButtonActionType = $Values<typeof BUTTON_ACTION_TYPE>;
|
|
47
|
+
export type ButtonSize = $Keys<typeof BUTTON_SIZE>;
|
|
42
48
|
|
|
43
49
|
export type BaseButtonProps = {
|
|
44
50
|
children?: React.Node,
|
|
@@ -66,7 +72,7 @@ export type ButtonProps = {
|
|
|
66
72
|
iconRightType?: IconType,
|
|
67
73
|
type?: ButtonType,
|
|
68
74
|
isFluid?: boolean,
|
|
69
|
-
size?:
|
|
75
|
+
size?: ButtonSize,
|
|
70
76
|
...
|
|
71
77
|
};
|
|
72
78
|
|
|
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "BUTTON_ACTION_TYPE", {
|
|
|
9
9
|
return _Button.BUTTON_ACTION_TYPE;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "BUTTON_SIZE", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _Button.BUTTON_SIZE;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
Object.defineProperty(exports, "BUTTON_TYPES", {
|
|
13
19
|
enumerable: true,
|
|
14
20
|
get: function () {
|
|
@@ -59,6 +59,7 @@ const Input_ = (props, ref) => {
|
|
|
59
59
|
boxRef,
|
|
60
60
|
onKeyDown,
|
|
61
61
|
disallowExponents,
|
|
62
|
+
hideNumberSpinner,
|
|
62
63
|
...inputProps
|
|
63
64
|
} = props;
|
|
64
65
|
const [showPassword, setShowPassword] = React.useState(false);
|
|
@@ -84,7 +85,7 @@ const Input_ = (props, ref) => {
|
|
|
84
85
|
className: (0, _classify.classify)(_InputModule.default.wrapper, {
|
|
85
86
|
[_InputModule.default.filled]: controlledInputFilled ?? false,
|
|
86
87
|
[_InputModule.default.withError]: error ?? false
|
|
87
|
-
})
|
|
88
|
+
}, classNames?.wrapper)
|
|
88
89
|
}, Boolean(label) && /*#__PURE__*/React.createElement("div", {
|
|
89
90
|
className: _InputModule.default.info
|
|
90
91
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -99,7 +100,8 @@ const Input_ = (props, ref) => {
|
|
|
99
100
|
[_InputModule.default.medium]: size === 'medium',
|
|
100
101
|
[_InputModule.default.small]: size === 'small',
|
|
101
102
|
[_InputModule.default.locked]: locked,
|
|
102
|
-
[_InputModule.default.color]: type === 'color'
|
|
103
|
+
[_InputModule.default.color]: type === 'color',
|
|
104
|
+
[_InputModule.default.hideNumberSpinner]: hideNumberSpinner
|
|
103
105
|
}, classNames?.box),
|
|
104
106
|
onClick: !(disabled || locked) ? onContainerClick : null,
|
|
105
107
|
ref: boxRef
|
|
@@ -13,6 +13,7 @@ type ClassNames = $ReadOnly<{
|
|
|
13
13
|
box?: string,
|
|
14
14
|
iconLeft?: string,
|
|
15
15
|
iconRight?: string,
|
|
16
|
+
wrapper?: string,
|
|
16
17
|
}>;
|
|
17
18
|
|
|
18
19
|
export const EXPONENT_CHARACTER_LIST = ['E', 'e'];
|
|
@@ -80,6 +81,7 @@ export type InputProps = {
|
|
|
80
81
|
* Only values which are equal to the basis for stepping (min if specified, value otherwise, and an
|
|
81
82
|
* appropriate default value if neither of those is provided) are valid. */
|
|
82
83
|
step?: string,
|
|
84
|
+
hideNumberSpinner?: boolean,
|
|
83
85
|
...
|
|
84
86
|
};
|
|
85
87
|
|
|
@@ -111,6 +113,7 @@ const Input_ = (props: InputProps, ref): React.Node => {
|
|
|
111
113
|
boxRef,
|
|
112
114
|
onKeyDown,
|
|
113
115
|
disallowExponents,
|
|
116
|
+
hideNumberSpinner,
|
|
114
117
|
...inputProps
|
|
115
118
|
} = props;
|
|
116
119
|
|
|
@@ -142,10 +145,14 @@ const Input_ = (props: InputProps, ref): React.Node => {
|
|
|
142
145
|
|
|
143
146
|
return (
|
|
144
147
|
<div
|
|
145
|
-
className={classify(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
className={classify(
|
|
149
|
+
css.wrapper,
|
|
150
|
+
{
|
|
151
|
+
[css.filled]: controlledInputFilled ?? false,
|
|
152
|
+
[css.withError]: error ?? false,
|
|
153
|
+
},
|
|
154
|
+
classNames?.wrapper,
|
|
155
|
+
)}
|
|
149
156
|
>
|
|
150
157
|
{Boolean(label) && (
|
|
151
158
|
<div className={css.info}>
|
|
@@ -165,6 +172,7 @@ const Input_ = (props: InputProps, ref): React.Node => {
|
|
|
165
172
|
[css.small]: size === 'small',
|
|
166
173
|
[css.locked]: locked,
|
|
167
174
|
[css.color]: type === 'color',
|
|
175
|
+
[css.hideNumberSpinner]: hideNumberSpinner,
|
|
168
176
|
},
|
|
169
177
|
classNames?.box,
|
|
170
178
|
)}
|
|
@@ -172,3 +172,15 @@ input::placeholder {
|
|
|
172
172
|
min-height: size18;
|
|
173
173
|
border-radius: borderRadiusXSmall;
|
|
174
174
|
}
|
|
175
|
+
|
|
176
|
+
.hideNumberSpinner input[type='number']::-webkit-outer-spin-button,
|
|
177
|
+
.hideNumberSpinner input[type='number']::-webkit-inner-spin-button {
|
|
178
|
+
-webkit-appearance: none;
|
|
179
|
+
margin: 0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/* Hide spinner in Firefox */
|
|
183
|
+
.hideNumberSpinner input[type='number'] {
|
|
184
|
+
appearance: textfield;
|
|
185
|
+
-moz-appearance: textfield;
|
|
186
|
+
}
|
|
@@ -7,7 +7,9 @@ exports.RangeSlider = void 0;
|
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _color = require("../../styles/variables/_color");
|
|
9
9
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
10
|
-
var
|
|
10
|
+
var _Button = require("../Button");
|
|
11
|
+
var _Input = require("../Input");
|
|
12
|
+
var _Text = require("../Text");
|
|
11
13
|
var _RangeSliderModule = _interopRequireDefault(require("./RangeSlider.module.css"));
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -24,27 +26,35 @@ const RangeSlider = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
24
26
|
onChange,
|
|
25
27
|
showTicks,
|
|
26
28
|
iconLeftName = 'minus',
|
|
27
|
-
|
|
28
|
-
iconLeftType,
|
|
29
|
+
btnLeftSize = _Button.BUTTON_SIZE.small,
|
|
29
30
|
iconRightName = 'plus',
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
btnRightSize = _Button.BUTTON_SIZE.small,
|
|
32
|
+
hideLeftBtn,
|
|
33
|
+
hideRightBtn,
|
|
34
|
+
ariaLabel = 'Slider',
|
|
35
|
+
showRange,
|
|
36
|
+
hideValueInput,
|
|
34
37
|
...restInputProps
|
|
35
38
|
} = _ref;
|
|
36
39
|
const progress = (value - min) / (max - min) * 100;
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Note(Nishant): This needs to be done because the Clickable Icon
|
|
42
|
-
* does not support disable prop currently. This can become a refactor
|
|
43
|
-
* task once we bake in disable support to Clickable Icon variation
|
|
44
|
-
*/
|
|
45
|
-
const LeftIconComponent = iconLeftDisabled ? _Icon.Icon : _Icon.ClickableIcon;
|
|
46
|
-
const RightIconComponent = iconRightDisabled ? _Icon.Icon : _Icon.ClickableIcon;
|
|
40
|
+
const btnLeftDisabled = disabled || value <= min;
|
|
41
|
+
const btnRightDisabled = disabled || value >= max;
|
|
47
42
|
const progressColor = disabled ? _color.colorTextDisabled : _color.colorFillPrimary;
|
|
43
|
+
const handleInputChange = e => {
|
|
44
|
+
let inputValue = parseFloat(e.currentTarget.value);
|
|
45
|
+
|
|
46
|
+
// Validate and adjust the value
|
|
47
|
+
if (isNaN(inputValue) || inputValue < min) {
|
|
48
|
+
inputValue = min;
|
|
49
|
+
} else if (inputValue > max) {
|
|
50
|
+
inputValue = max;
|
|
51
|
+
} else if (step > 0) {
|
|
52
|
+
const nearestStep = Math.round(inputValue / step) * step;
|
|
53
|
+
inputValue = Math.round(nearestStep * 100) / 100; // Adjust to nearest valid step
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
onChange?.(inputValue);
|
|
57
|
+
};
|
|
48
58
|
const handleChange = e => {
|
|
49
59
|
emitRoundedValue(e.currentTarget.value);
|
|
50
60
|
};
|
|
@@ -59,14 +69,17 @@ const RangeSlider = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
59
69
|
className: (0, _classify.default)(_RangeSliderModule.default.wrapper, {
|
|
60
70
|
[_RangeSliderModule.default.disabled]: disabled
|
|
61
71
|
}, classNames?.wrapper)
|
|
62
|
-
}, !
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
}, !hideLeftBtn && !showRange && /*#__PURE__*/React.createElement(_Button.Button, {
|
|
73
|
+
type: "ghost",
|
|
74
|
+
iconLeftName: iconLeftName,
|
|
75
|
+
size: btnLeftSize,
|
|
76
|
+
ariaLabel: "Decrease Value",
|
|
77
|
+
disabled: btnLeftDisabled,
|
|
68
78
|
onClick: () => emitRoundedValue(value - step)
|
|
69
|
-
})
|
|
79
|
+
}), showRange && /*#__PURE__*/React.createElement(_Text.BodySmall, {
|
|
80
|
+
className: _RangeSliderModule.default.rangeText,
|
|
81
|
+
color: disabled ? 'disabled' : 'primary'
|
|
82
|
+
}, min), /*#__PURE__*/React.createElement("div", {
|
|
70
83
|
className: _RangeSliderModule.default.sliderContainer
|
|
71
84
|
}, /*#__PURE__*/React.createElement("input", _extends({}, restInputProps, {
|
|
72
85
|
type: "range",
|
|
@@ -78,6 +91,7 @@ const RangeSlider = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
78
91
|
className: _RangeSliderModule.default.slider,
|
|
79
92
|
list: showTicks ? 'ticks' : undefined,
|
|
80
93
|
disabled: disabled,
|
|
94
|
+
"aria-label": ariaLabel,
|
|
81
95
|
style: {
|
|
82
96
|
background: `linear-gradient(to right, ${progressColor} ${progress}%, ${_color.colorGrayLightest} ${progress}%)`
|
|
83
97
|
}
|
|
@@ -88,14 +102,31 @@ const RangeSlider = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
88
102
|
length: (max - min) / step + 1
|
|
89
103
|
}, (_, index) => /*#__PURE__*/React.createElement("option", {
|
|
90
104
|
key: index,
|
|
91
|
-
value: min + index * step
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
105
|
+
value: min + index * step,
|
|
106
|
+
className: (0, _classify.default)({
|
|
107
|
+
[_RangeSliderModule.default.disabled]: disabled
|
|
108
|
+
})
|
|
109
|
+
})))), showRange && /*#__PURE__*/React.createElement(_Text.BodySmall, {
|
|
110
|
+
className: _RangeSliderModule.default.rangeText,
|
|
111
|
+
color: disabled ? 'disabled' : 'primary'
|
|
112
|
+
}, max), !hideRightBtn && !showRange && /*#__PURE__*/React.createElement(_Button.Button, {
|
|
113
|
+
type: "ghost",
|
|
114
|
+
iconRightName: iconRightName,
|
|
115
|
+
size: btnRightSize,
|
|
116
|
+
ariaLabel: "Increase Value",
|
|
117
|
+
disabled: btnRightDisabled,
|
|
98
118
|
onClick: () => emitRoundedValue(value + step)
|
|
99
|
-
})
|
|
119
|
+
}), !hideValueInput && /*#__PURE__*/React.createElement(_Input.Input, {
|
|
120
|
+
size: "small",
|
|
121
|
+
type: "number",
|
|
122
|
+
value: String(value),
|
|
123
|
+
classNames: {
|
|
124
|
+
wrapper: _RangeSliderModule.default.valueInputWrapper
|
|
125
|
+
},
|
|
126
|
+
disabled: disabled,
|
|
127
|
+
onChange: handleInputChange,
|
|
128
|
+
disallowExponents: true,
|
|
129
|
+
hideNumberSpinner: true
|
|
130
|
+
}));
|
|
100
131
|
});
|
|
101
132
|
exports.RangeSlider = RangeSlider;
|
|
@@ -8,8 +8,10 @@ import {
|
|
|
8
8
|
colorTextDisabled,
|
|
9
9
|
} from '../../styles/variables/_color';
|
|
10
10
|
import classify from '../../utils/classify';
|
|
11
|
-
import type {
|
|
12
|
-
import {
|
|
11
|
+
import type {ButtonSize} from '../Button';
|
|
12
|
+
import {Button, BUTTON_SIZE} from '../Button';
|
|
13
|
+
import {Input} from '../Input';
|
|
14
|
+
import {BodySmall} from '../Text';
|
|
13
15
|
|
|
14
16
|
import css from './RangeSlider.module.css';
|
|
15
17
|
|
|
@@ -24,15 +26,16 @@ export type RangeSliderProps = {
|
|
|
24
26
|
onChange?: (value: number) => void, // We don't want to send in the event because the icon buttons also modify the value
|
|
25
27
|
showTicks?: boolean,
|
|
26
28
|
iconLeftName?: string,
|
|
27
|
-
|
|
28
|
-
iconLeftSize?: IconSize,
|
|
29
|
+
btnLeftSize?: ButtonSize,
|
|
29
30
|
iconRightName?: string,
|
|
30
|
-
|
|
31
|
-
iconRightSize?: IconSize,
|
|
31
|
+
btnRightSize?: ButtonSize,
|
|
32
32
|
disabled?: boolean,
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
hideLeftBtn?: boolean,
|
|
34
|
+
hideRightBtn?: boolean,
|
|
35
35
|
classNames?: ClassNames,
|
|
36
|
+
ariaLabel?: string,
|
|
37
|
+
showRange?: boolean,
|
|
38
|
+
hideValueInput?: boolean,
|
|
36
39
|
...
|
|
37
40
|
};
|
|
38
41
|
|
|
@@ -51,32 +54,41 @@ export const RangeSlider: React$AbstractComponent<
|
|
|
51
54
|
onChange,
|
|
52
55
|
showTicks,
|
|
53
56
|
iconLeftName = 'minus',
|
|
54
|
-
|
|
55
|
-
iconLeftType,
|
|
57
|
+
btnLeftSize = BUTTON_SIZE.small,
|
|
56
58
|
iconRightName = 'plus',
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
btnRightSize = BUTTON_SIZE.small,
|
|
60
|
+
hideLeftBtn,
|
|
61
|
+
hideRightBtn,
|
|
62
|
+
ariaLabel = 'Slider',
|
|
63
|
+
showRange,
|
|
64
|
+
hideValueInput,
|
|
61
65
|
...restInputProps
|
|
62
66
|
}: RangeSliderProps,
|
|
63
67
|
ref,
|
|
64
68
|
) => {
|
|
65
69
|
const progress = ((value - min) / (max - min)) * 100;
|
|
66
70
|
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Note(Nishant): This needs to be done because the Clickable Icon
|
|
72
|
-
* does not support disable prop currently. This can become a refactor
|
|
73
|
-
* task once we bake in disable support to Clickable Icon variation
|
|
74
|
-
*/
|
|
75
|
-
const LeftIconComponent = iconLeftDisabled ? Icon : ClickableIcon;
|
|
76
|
-
const RightIconComponent = iconRightDisabled ? Icon : ClickableIcon;
|
|
71
|
+
const btnLeftDisabled = disabled || value <= min;
|
|
72
|
+
const btnRightDisabled = disabled || value >= max;
|
|
77
73
|
|
|
78
74
|
const progressColor = disabled ? colorTextDisabled : colorFillPrimary;
|
|
79
75
|
|
|
76
|
+
const handleInputChange = (e: SyntheticEvent<HTMLInputElement>) => {
|
|
77
|
+
let inputValue = parseFloat(e.currentTarget.value);
|
|
78
|
+
|
|
79
|
+
// Validate and adjust the value
|
|
80
|
+
if (isNaN(inputValue) || inputValue < min) {
|
|
81
|
+
inputValue = min;
|
|
82
|
+
} else if (inputValue > max) {
|
|
83
|
+
inputValue = max;
|
|
84
|
+
} else if (step > 0) {
|
|
85
|
+
const nearestStep = Math.round(inputValue / step) * step;
|
|
86
|
+
inputValue = Math.round(nearestStep * 100) / 100; // Adjust to nearest valid step
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
onChange?.(inputValue);
|
|
90
|
+
};
|
|
91
|
+
|
|
80
92
|
const handleChange = (e: SyntheticEvent<HTMLInputElement>) => {
|
|
81
93
|
emitRoundedValue(e.currentTarget.value);
|
|
82
94
|
};
|
|
@@ -97,18 +109,26 @@ export const RangeSlider: React$AbstractComponent<
|
|
|
97
109
|
classNames?.wrapper,
|
|
98
110
|
)}
|
|
99
111
|
>
|
|
100
|
-
{!
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
})}
|
|
112
|
+
{!hideLeftBtn && !showRange && (
|
|
113
|
+
<Button
|
|
114
|
+
type="ghost"
|
|
115
|
+
iconLeftName={iconLeftName}
|
|
116
|
+
size={btnLeftSize}
|
|
117
|
+
ariaLabel="Decrease Value"
|
|
118
|
+
disabled={btnLeftDisabled}
|
|
119
|
+
onClick={() => emitRoundedValue(value - step)}
|
|
109
120
|
/>
|
|
110
121
|
)}
|
|
111
122
|
|
|
123
|
+
{showRange && (
|
|
124
|
+
<BodySmall
|
|
125
|
+
className={css.rangeText}
|
|
126
|
+
color={disabled ? 'disabled' : 'primary'}
|
|
127
|
+
>
|
|
128
|
+
{min}
|
|
129
|
+
</BodySmall>
|
|
130
|
+
)}
|
|
131
|
+
|
|
112
132
|
<div className={css.sliderContainer}>
|
|
113
133
|
<input
|
|
114
134
|
{...restInputProps}
|
|
@@ -121,6 +141,7 @@ export const RangeSlider: React$AbstractComponent<
|
|
|
121
141
|
className={css.slider}
|
|
122
142
|
list={showTicks ? 'ticks' : undefined}
|
|
123
143
|
disabled={disabled}
|
|
144
|
+
aria-label={ariaLabel}
|
|
124
145
|
style={{
|
|
125
146
|
background: `linear-gradient(to right, ${progressColor} ${progress}%, ${colorGrayLightest} ${progress}%)`,
|
|
126
147
|
}}
|
|
@@ -133,20 +154,46 @@ export const RangeSlider: React$AbstractComponent<
|
|
|
133
154
|
by allowing user-defined brackets or ranges for tick marks.
|
|
134
155
|
*/}
|
|
135
156
|
{Array.from({length: (max - min) / step + 1}, (_, index) => (
|
|
136
|
-
<option
|
|
157
|
+
<option
|
|
158
|
+
key={index}
|
|
159
|
+
value={min + index * step}
|
|
160
|
+
className={classify({[css.disabled]: disabled})}
|
|
161
|
+
/>
|
|
137
162
|
))}
|
|
138
163
|
</datalist>
|
|
139
164
|
)}
|
|
140
165
|
</div>
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
{
|
|
148
|
-
|
|
149
|
-
|
|
166
|
+
|
|
167
|
+
{showRange && (
|
|
168
|
+
<BodySmall
|
|
169
|
+
className={css.rangeText}
|
|
170
|
+
color={disabled ? 'disabled' : 'primary'}
|
|
171
|
+
>
|
|
172
|
+
{max}
|
|
173
|
+
</BodySmall>
|
|
174
|
+
)}
|
|
175
|
+
|
|
176
|
+
{!hideRightBtn && !showRange && (
|
|
177
|
+
<Button
|
|
178
|
+
type="ghost"
|
|
179
|
+
iconRightName={iconRightName}
|
|
180
|
+
size={btnRightSize}
|
|
181
|
+
ariaLabel="Increase Value"
|
|
182
|
+
disabled={btnRightDisabled}
|
|
183
|
+
onClick={() => emitRoundedValue(value + step)}
|
|
184
|
+
/>
|
|
185
|
+
)}
|
|
186
|
+
|
|
187
|
+
{!hideValueInput && (
|
|
188
|
+
<Input
|
|
189
|
+
size="small"
|
|
190
|
+
type="number"
|
|
191
|
+
value={String(value)}
|
|
192
|
+
classNames={{wrapper: css.valueInputWrapper}}
|
|
193
|
+
disabled={disabled}
|
|
194
|
+
onChange={handleInputChange}
|
|
195
|
+
disallowExponents
|
|
196
|
+
hideNumberSpinner
|
|
150
197
|
/>
|
|
151
198
|
)}
|
|
152
199
|
</div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@value (colorFillPrimary, colorGrayLightest, colorBackgroundTertiary, colorFocusPrimary, colorTextDisabled) from '../../styles/variables/_color.css';
|
|
2
|
-
@value (sizeFluid, size4, size20, size2) from '../../styles/variables/_size.css';
|
|
3
|
-
@value (
|
|
2
|
+
@value (sizeFluid, size4, size20, size2, size34) from '../../styles/variables/_size.css';
|
|
3
|
+
@value (spaceXXSmall, spaceNone) from '../../styles/variables/_space.css';
|
|
4
4
|
@value (borderRadiusLarge, borderRadiusCircle, borderWidthTertiary, borderWidthNone) from '../../styles/variables/_border.css';
|
|
5
5
|
|
|
6
6
|
@value thumbSize: size20;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
display: flex;
|
|
11
11
|
align-items: center;
|
|
12
12
|
width: sizeFluid;
|
|
13
|
-
gap:
|
|
13
|
+
gap: spaceXXSmall;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.sliderContainer {
|
|
@@ -119,3 +119,19 @@ input[type='range']:focus::-moz-range-thumb {
|
|
|
119
119
|
padding-inline: spaceNone;
|
|
120
120
|
white-space: nowrap;
|
|
121
121
|
}
|
|
122
|
+
|
|
123
|
+
.sliderTicks option.disabled {
|
|
124
|
+
background-color: colorTextDisabled;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.rangeText {
|
|
128
|
+
display: flex;
|
|
129
|
+
min-width: size34;
|
|
130
|
+
min-height: size34;
|
|
131
|
+
justify-content: center;
|
|
132
|
+
align-items: center;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.valueInputWrapper {
|
|
136
|
+
max-width: 58px;
|
|
137
|
+
}
|