@salutejs/plasma-new-hope 0.175.2-dev.0 → 0.176.0-canary.1452.11568379583.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Slider/Slider.css +15 -13
- package/cjs/components/Slider/Slider.js +11 -2
- package/cjs/components/Slider/Slider.js.map +1 -1
- package/cjs/components/Slider/Slider.tokens.js +23 -17
- package/cjs/components/Slider/Slider.tokens.js.map +1 -1
- package/cjs/components/Slider/components/Double/Double.css +8 -8
- package/cjs/components/Slider/components/Double/Double.js +58 -23
- package/cjs/components/Slider/components/Double/Double.js.map +1 -1
- package/cjs/components/Slider/components/DoubleUncontrolled/DoubleUncontrolled.css +98 -0
- package/cjs/components/Slider/components/Single/Single.css +14 -14
- package/cjs/components/Slider/components/Single/Single.js +64 -33
- package/cjs/components/Slider/components/Single/Single.js.map +1 -1
- package/cjs/components/Slider/components/Single/Single.styles.js +4 -4
- package/cjs/components/Slider/components/Single/Single.styles.js.map +1 -1
- package/cjs/components/Slider/components/Single/Single.styles_1h7n2s2.css +6 -0
- package/cjs/components/Slider/components/SliderBase/SliderBase.css +5 -5
- package/cjs/components/Slider/components/SliderBase/SliderBase.js +31 -12
- package/cjs/components/Slider/components/SliderBase/SliderBase.js.map +1 -1
- package/cjs/components/Slider/components/SliderBase/SliderBase.styles.js +7 -7
- package/cjs/components/Slider/components/SliderBase/SliderBase.styles.js.map +1 -1
- package/cjs/components/Slider/components/SliderBase/SliderBase.styles_1qt1224.css +5 -0
- package/cjs/components/Slider/ui/Handler/Handler.css +3 -3
- package/cjs/components/Slider/ui/Handler/Handler.js +49 -88
- package/cjs/components/Slider/ui/Handler/Handler.js.map +1 -1
- package/cjs/components/Slider/ui/Handler/Handler.styles.js +17 -7
- package/cjs/components/Slider/ui/Handler/Handler.styles.js.map +1 -1
- package/cjs/components/Slider/ui/Handler/Handler.styles_irtcgm.css +2 -0
- package/cjs/components/Slider/ui/Handler/computeKeyPressData.js +122 -0
- package/cjs/components/Slider/ui/Handler/computeKeyPressData.js.map +1 -0
- package/cjs/components/Slider/ui/Thumb/Thumb.css +1 -1
- package/cjs/components/Slider/ui/Thumb/Thumb.js +3 -2
- package/cjs/components/Slider/ui/Thumb/Thumb.js.map +1 -1
- package/cjs/components/Slider/ui/Thumb/Thumb.styles.js +1 -1
- package/cjs/components/Slider/ui/Thumb/Thumb.styles.js.map +1 -1
- package/cjs/components/Slider/ui/Thumb/Thumb.styles_uyn20e.css +1 -0
- package/cjs/components/Slider/utils/index.js +28 -10
- package/cjs/components/Slider/utils/index.js.map +1 -1
- package/cjs/components/Slider/variations/_view/base.js +1 -1
- package/cjs/components/Slider/variations/_view/base.js.map +1 -1
- package/cjs/components/Slider/variations/_view/base_1s3f6q8.css +1 -0
- package/cjs/index.css +15 -13
- package/cjs/utils/index.js.map +1 -1
- package/emotion/cjs/components/Slider/Slider.js +10 -2
- package/emotion/cjs/components/Slider/Slider.template-doc.mdx +26 -0
- package/emotion/cjs/components/Slider/Slider.tokens.js +23 -17
- package/emotion/cjs/components/Slider/components/Double/Double.js +54 -19
- package/emotion/cjs/components/Slider/components/Single/Single.js +64 -33
- package/emotion/cjs/components/Slider/components/Single/Single.styles.js +18 -9
- package/emotion/cjs/components/Slider/components/SliderBase/SliderBase.js +31 -12
- package/emotion/cjs/components/Slider/components/SliderBase/SliderBase.styles.js +10 -10
- package/emotion/cjs/components/Slider/ui/Handler/Handler.js +52 -88
- package/emotion/cjs/components/Slider/ui/Handler/Handler.styles.js +9 -15
- package/emotion/cjs/components/Slider/ui/Handler/computeKeyPressData.js +121 -0
- package/emotion/cjs/components/Slider/ui/Thumb/Thumb.js +3 -2
- package/emotion/cjs/components/Slider/ui/Thumb/Thumb.styles.js +3 -3
- package/emotion/cjs/components/Slider/utils/index.js +28 -10
- package/emotion/cjs/components/Slider/variations/_view/base.js +2 -1
- package/emotion/cjs/examples/plasma_b2c/components/Slider/Slider.config.js +7 -7
- package/emotion/cjs/examples/plasma_b2c/components/Slider/Slider.stories.tsx +98 -16
- package/emotion/cjs/examples/plasma_web/components/Slider/Slider.config.js +7 -7
- package/emotion/cjs/examples/plasma_web/components/Slider/Slider.stories.tsx +98 -15
- package/emotion/es/components/Slider/Slider.js +11 -2
- package/emotion/es/components/Slider/Slider.template-doc.mdx +26 -0
- package/emotion/es/components/Slider/Slider.tokens.js +23 -17
- package/emotion/es/components/Slider/components/Double/Double.js +54 -19
- package/emotion/es/components/Slider/components/Single/Single.js +65 -34
- package/emotion/es/components/Slider/components/Single/Single.styles.js +17 -8
- package/emotion/es/components/Slider/components/SliderBase/SliderBase.js +31 -12
- package/emotion/es/components/Slider/components/SliderBase/SliderBase.styles.js +11 -11
- package/emotion/es/components/Slider/ui/Handler/Handler.js +51 -86
- package/emotion/es/components/Slider/ui/Handler/Handler.styles.js +10 -16
- package/emotion/es/components/Slider/ui/Handler/computeKeyPressData.js +115 -0
- package/emotion/es/components/Slider/ui/Thumb/Thumb.js +3 -2
- package/emotion/es/components/Slider/ui/Thumb/Thumb.styles.js +3 -3
- package/emotion/es/components/Slider/utils/index.js +28 -10
- package/emotion/es/components/Slider/variations/_view/base.js +2 -1
- package/emotion/es/examples/plasma_b2c/components/Slider/Slider.config.js +7 -7
- package/emotion/es/examples/plasma_b2c/components/Slider/Slider.stories.tsx +98 -16
- package/emotion/es/examples/plasma_web/components/Slider/Slider.config.js +7 -7
- package/emotion/es/examples/plasma_web/components/Slider/Slider.stories.tsx +98 -15
- package/es/components/Slider/Slider.css +15 -13
- package/es/components/Slider/Slider.js +11 -2
- package/es/components/Slider/Slider.js.map +1 -1
- package/es/components/Slider/Slider.tokens.js +23 -17
- package/es/components/Slider/Slider.tokens.js.map +1 -1
- package/es/components/Slider/components/Double/Double.css +8 -8
- package/es/components/Slider/components/Double/Double.js +54 -19
- package/es/components/Slider/components/Double/Double.js.map +1 -1
- package/es/components/Slider/components/DoubleUncontrolled/DoubleUncontrolled.css +98 -0
- package/es/components/Slider/components/Single/Single.css +14 -14
- package/es/components/Slider/components/Single/Single.js +65 -34
- package/es/components/Slider/components/Single/Single.js.map +1 -1
- package/es/components/Slider/components/Single/Single.styles.js +4 -4
- package/es/components/Slider/components/Single/Single.styles.js.map +1 -1
- package/es/components/Slider/components/Single/Single.styles_1h7n2s2.css +6 -0
- package/es/components/Slider/components/SliderBase/SliderBase.css +5 -5
- package/es/components/Slider/components/SliderBase/SliderBase.js +31 -12
- package/es/components/Slider/components/SliderBase/SliderBase.js.map +1 -1
- package/es/components/Slider/components/SliderBase/SliderBase.styles.js +7 -7
- package/es/components/Slider/components/SliderBase/SliderBase.styles.js.map +1 -1
- package/es/components/Slider/components/SliderBase/SliderBase.styles_1qt1224.css +5 -0
- package/es/components/Slider/ui/Handler/Handler.css +3 -3
- package/es/components/Slider/ui/Handler/Handler.js +48 -87
- package/es/components/Slider/ui/Handler/Handler.js.map +1 -1
- package/es/components/Slider/ui/Handler/Handler.styles.js +17 -7
- package/es/components/Slider/ui/Handler/Handler.styles.js.map +1 -1
- package/es/components/Slider/ui/Handler/Handler.styles_irtcgm.css +2 -0
- package/es/components/Slider/ui/Handler/computeKeyPressData.js +118 -0
- package/es/components/Slider/ui/Handler/computeKeyPressData.js.map +1 -0
- package/es/components/Slider/ui/Thumb/Thumb.css +1 -1
- package/es/components/Slider/ui/Thumb/Thumb.js +3 -2
- package/es/components/Slider/ui/Thumb/Thumb.js.map +1 -1
- package/es/components/Slider/ui/Thumb/Thumb.styles.js +1 -1
- package/es/components/Slider/ui/Thumb/Thumb.styles.js.map +1 -1
- package/es/components/Slider/ui/Thumb/Thumb.styles_uyn20e.css +1 -0
- package/es/components/Slider/utils/index.js +28 -10
- package/es/components/Slider/utils/index.js.map +1 -1
- package/es/components/Slider/variations/_view/base.js +1 -1
- package/es/components/Slider/variations/_view/base.js.map +1 -1
- package/es/components/Slider/variations/_view/base_1s3f6q8.css +1 -0
- package/es/index.css +15 -13
- package/es/utils/index.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/components/Slider/Slider.js +10 -2
- package/styled-components/cjs/components/Slider/Slider.template-doc.mdx +26 -0
- package/styled-components/cjs/components/Slider/Slider.tokens.js +23 -17
- package/styled-components/cjs/components/Slider/components/Double/Double.js +54 -19
- package/styled-components/cjs/components/Slider/components/Single/Single.js +64 -33
- package/styled-components/cjs/components/Slider/components/Single/Single.styles.js +6 -6
- package/styled-components/cjs/components/Slider/components/SliderBase/SliderBase.js +31 -12
- package/styled-components/cjs/components/Slider/components/SliderBase/SliderBase.styles.js +6 -6
- package/styled-components/cjs/components/Slider/ui/Handler/Handler.js +52 -88
- package/styled-components/cjs/components/Slider/ui/Handler/Handler.styles.js +7 -4
- package/styled-components/cjs/components/Slider/ui/Handler/computeKeyPressData.js +121 -0
- package/styled-components/cjs/components/Slider/ui/Thumb/Thumb.js +3 -2
- package/styled-components/cjs/components/Slider/ui/Thumb/Thumb.styles.js +2 -2
- package/styled-components/cjs/components/Slider/utils/index.js +28 -10
- package/styled-components/cjs/components/Slider/variations/_view/base.js +2 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Slider/Slider.config.js +3 -3
- package/styled-components/cjs/examples/plasma_b2c/components/Slider/Slider.stories.tsx +98 -16
- package/styled-components/cjs/examples/plasma_web/components/Slider/Slider.config.js +3 -3
- package/styled-components/cjs/examples/plasma_web/components/Slider/Slider.stories.tsx +98 -15
- package/styled-components/es/components/Slider/Slider.js +11 -2
- package/styled-components/es/components/Slider/Slider.template-doc.mdx +26 -0
- package/styled-components/es/components/Slider/Slider.tokens.js +23 -17
- package/styled-components/es/components/Slider/components/Double/Double.js +54 -19
- package/styled-components/es/components/Slider/components/Single/Single.js +65 -34
- package/styled-components/es/components/Slider/components/Single/Single.styles.js +5 -5
- package/styled-components/es/components/Slider/components/SliderBase/SliderBase.js +31 -12
- package/styled-components/es/components/Slider/components/SliderBase/SliderBase.styles.js +7 -7
- package/styled-components/es/components/Slider/ui/Handler/Handler.js +51 -86
- package/styled-components/es/components/Slider/ui/Handler/Handler.styles.js +8 -5
- package/styled-components/es/components/Slider/ui/Handler/computeKeyPressData.js +115 -0
- package/styled-components/es/components/Slider/ui/Thumb/Thumb.js +3 -2
- package/styled-components/es/components/Slider/ui/Thumb/Thumb.styles.js +2 -2
- package/styled-components/es/components/Slider/utils/index.js +28 -10
- package/styled-components/es/components/Slider/variations/_view/base.js +2 -1
- package/styled-components/es/examples/plasma_b2c/components/Slider/Slider.config.js +3 -3
- package/styled-components/es/examples/plasma_b2c/components/Slider/Slider.stories.tsx +98 -16
- package/styled-components/es/examples/plasma_web/components/Slider/Slider.config.js +3 -3
- package/styled-components/es/examples/plasma_web/components/Slider/Slider.stories.tsx +98 -15
- package/types/components/Slider/Slider.d.ts.map +1 -1
- package/types/components/Slider/Slider.tokens.d.ts +22 -16
- package/types/components/Slider/Slider.tokens.d.ts.map +1 -1
- package/types/components/Slider/components/Double/Double.d.ts.map +1 -1
- package/types/components/Slider/components/Double/Double.types.d.ts +1 -0
- package/types/components/Slider/components/Double/Double.types.d.ts.map +1 -1
- package/types/components/Slider/components/Single/Single.d.ts.map +1 -1
- package/types/components/Slider/components/Single/Single.styles.d.ts +1 -1
- package/types/components/Slider/components/Single/Single.styles.d.ts.map +1 -1
- package/types/components/Slider/components/Single/Single.types.d.ts +79 -7
- package/types/components/Slider/components/Single/Single.types.d.ts.map +1 -1
- package/types/components/Slider/components/SliderBase/SliderBase.d.ts.map +1 -1
- package/types/components/Slider/components/SliderBase/SliderBase.styles.d.ts +1 -1
- package/types/components/Slider/components/SliderBase/SliderBase.styles.d.ts.map +1 -1
- package/types/components/Slider/components/SliderBase/SliderBase.types.d.ts +6 -0
- package/types/components/Slider/components/SliderBase/SliderBase.types.d.ts.map +1 -1
- package/types/components/Slider/ui/Handler/Handler.d.ts.map +1 -1
- package/types/components/Slider/ui/Handler/Handler.styles.d.ts +6 -2
- package/types/components/Slider/ui/Handler/Handler.styles.d.ts.map +1 -1
- package/types/components/Slider/ui/Handler/Handler.types.d.ts +5 -1
- package/types/components/Slider/ui/Handler/Handler.types.d.ts.map +1 -1
- package/types/components/Slider/ui/Handler/computeKeyPressData.d.ts +12 -0
- package/types/components/Slider/ui/Handler/computeKeyPressData.d.ts.map +1 -0
- package/types/components/Slider/ui/Thumb/Thumb.d.ts +1 -1
- package/types/components/Slider/ui/Thumb/Thumb.d.ts.map +1 -1
- package/types/components/Slider/ui/Thumb/Thumb.styles.d.ts.map +1 -1
- package/types/components/Slider/ui/Thumb/Thumb.types.d.ts +1 -0
- package/types/components/Slider/ui/Thumb/Thumb.types.d.ts.map +1 -1
- package/types/components/Slider/utils/index.d.ts +26 -8
- package/types/components/Slider/utils/index.d.ts.map +1 -1
- package/types/components/Slider/variations/_view/base.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Slider/Slider.config.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Slider/Slider.d.ts +80 -2
- package/types/examples/plasma_b2c/components/Slider/Slider.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Slider/Slider.config.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Slider/Slider.d.ts +80 -2
- package/types/examples/plasma_web/components/Slider/Slider.d.ts.map +1 -1
- package/types/utils/index.d.ts +1 -1
- package/types/utils/index.d.ts.map +1 -1
- package/cjs/components/Slider/components/Single/Single.styles_1r9f1e0.css +0 -6
- package/cjs/components/Slider/components/SliderBase/SliderBase.styles_9s4eb3.css +0 -5
- package/cjs/components/Slider/ui/Handler/Handler.styles_8crx5z.css +0 -2
- package/cjs/components/Slider/ui/Thumb/Thumb.styles_4w4gzn.css +0 -1
- package/cjs/components/Slider/variations/_view/base_x642ct.css +0 -1
- package/es/components/Slider/components/Single/Single.styles_1r9f1e0.css +0 -6
- package/es/components/Slider/components/SliderBase/SliderBase.styles_9s4eb3.css +0 -5
- package/es/components/Slider/ui/Handler/Handler.styles_8crx5z.css +0 -2
- package/es/components/Slider/ui/Thumb/Thumb.styles_4w4gzn.css +0 -1
- package/es/components/Slider/variations/_view/base_x642ct.css +0 -1
@@ -13,7 +13,7 @@ var _utils2 = /*#__PURE__*/require("../../../../utils");
|
|
13
13
|
var _Slider = /*#__PURE__*/require("../../Slider.tokens");
|
14
14
|
var _SliderBase2 = /*#__PURE__*/require("../SliderBase/SliderBase.styles");
|
15
15
|
var _Single = /*#__PURE__*/require("./Single.styles");
|
16
|
-
var _excluded = ["min", "max", "value", "disabled", "onChangeCommitted", "onChange", "ariaLabel", "label", "labelContentLeft", "showRangeValues", "showCurrentValue", "hideMinValueDiff", "hideMaxValueDiff", "labelPlacement", "rangeValuesPlacement", "multipleStepSize", "defaultValue", "size", "name"];
|
16
|
+
var _excluded = ["min", "max", "value", "disabled", "onChangeCommitted", "onChange", "ariaLabel", "label", "labelContentLeft", "labelContent", "sliderAlign", "showScale", "showRangeValues", "showCurrentValue", "hideMinValueDiff", "hideMaxValueDiff", "labelPlacement", "rangeValuesPlacement", "scaleAlign", "multipleStepSize", "defaultValue", "size", "name", "pointerSize", "orientation", "reversed", "labelReversed"];
|
17
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
18
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
19
19
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
@@ -41,23 +41,35 @@ var SingleSlider = exports.SingleSlider = function SingleSlider(_ref) {
|
|
41
41
|
ariaLabel = _ref.ariaLabel,
|
42
42
|
label = _ref.label,
|
43
43
|
labelContentLeft = _ref.labelContentLeft,
|
44
|
+
labelContent = _ref.labelContent,
|
45
|
+
_ref$sliderAlign = _ref.sliderAlign,
|
46
|
+
sliderAlign = _ref$sliderAlign === void 0 ? 'left' : _ref$sliderAlign,
|
47
|
+
showScale = _ref.showScale,
|
44
48
|
showRangeValues = _ref.showRangeValues,
|
45
49
|
showCurrentValue = _ref.showCurrentValue,
|
46
50
|
hideMinValueDiff = _ref.hideMinValueDiff,
|
47
51
|
hideMaxValueDiff = _ref.hideMaxValueDiff,
|
48
52
|
_ref$labelPlacement = _ref.labelPlacement,
|
49
|
-
labelPlacement = _ref$labelPlacement === void 0 ? '
|
50
|
-
|
51
|
-
|
53
|
+
labelPlacement = _ref$labelPlacement === void 0 ? 'top' : _ref$labelPlacement,
|
54
|
+
rangeValuesPlacementOld = _ref.rangeValuesPlacement,
|
55
|
+
_ref$scaleAlign = _ref.scaleAlign,
|
56
|
+
scaleAlign = _ref$scaleAlign === void 0 ? 'bottom' : _ref$scaleAlign,
|
52
57
|
_ref$multipleStepSize = _ref.multipleStepSize,
|
53
58
|
multipleStepSize = _ref$multipleStepSize === void 0 ? 10 : _ref$multipleStepSize,
|
54
59
|
defaultValue = _ref.defaultValue,
|
55
60
|
_ref$size = _ref.size,
|
56
61
|
size = _ref$size === void 0 ? 'm' : _ref$size,
|
57
62
|
name = _ref.name,
|
63
|
+
_ref$pointerSize = _ref.pointerSize,
|
64
|
+
pointerSize = _ref$pointerSize === void 0 ? 'small' : _ref$pointerSize,
|
65
|
+
_ref$orientation = _ref.orientation,
|
66
|
+
orientation = _ref$orientation === void 0 ? 'horizontal' : _ref$orientation,
|
67
|
+
reversed = _ref.reversed,
|
68
|
+
labelReversed = _ref.labelReversed,
|
58
69
|
rest = _objectWithoutProperties(_ref, _excluded);
|
70
|
+
var isVertical = orientation === 'vertical';
|
59
71
|
var _useState = (0, _react.useState)({
|
60
|
-
|
72
|
+
handlePosition: 0,
|
61
73
|
stepSize: 0,
|
62
74
|
railFillWidth: 0
|
63
75
|
}),
|
@@ -73,23 +85,28 @@ var SingleSlider = exports.SingleSlider = function SingleSlider(_ref) {
|
|
73
85
|
_useState6 = _slicedToArray(_useState5, 2),
|
74
86
|
endOffset = _useState6[0],
|
75
87
|
setEndOffset = _useState6[1];
|
76
|
-
var
|
88
|
+
var innerValue = (_ref2 = value !== null && value !== void 0 ? value : defaultValue) !== null && _ref2 !== void 0 ? _ref2 : min;
|
89
|
+
var _useState7 = (0, _react.useState)(innerValue),
|
77
90
|
_useState8 = _slicedToArray(_useState7, 2),
|
78
91
|
dragValue = _useState8[0],
|
79
92
|
setDragValue = _useState8[1];
|
80
93
|
var stepSize = state.stepSize;
|
81
|
-
var
|
82
|
-
var
|
83
|
-
var
|
94
|
+
var innerShowScale = showRangeValues || showScale;
|
95
|
+
var hasLabelContent = Boolean(label || labelContentLeft || labelContent) && (!isVertical || isVertical && sliderAlign !== 'none');
|
96
|
+
var labelPlacementClass = !isVertical && (labelPlacement === 'outer' || labelPlacement === 'top') ? _Slider.classes.labelPlacementOuter : _Slider.classes.labelPlacementInner;
|
97
|
+
var rangeValuesPlacement = rangeValuesPlacementOld === 'outer' || scaleAlign === 'bottom' ? 'outer' : 'inner';
|
98
|
+
var scaleAlignClass = rangeValuesPlacement === 'outer' ? _Slider.classes.rangeValuesPlacementOuter : _Slider.classes.rangeValuesPlacementInner;
|
84
99
|
var hideMinValueDiffClass = hideMinValueDiff && dragValue - min <= hideMinValueDiff ? _Slider.classes.hideMinValue : '';
|
85
100
|
var hideMaxValueDiffClass = hideMaxValueDiff && max - dragValue <= hideMaxValueDiff ? _Slider.classes.hideMaxValue : '';
|
101
|
+
var verticalOrientationClass = orientation === 'vertical' ? _Slider.classes.verticalOrientation : '';
|
86
102
|
var startLabelRef = (0, _react.useRef)(null);
|
87
103
|
var endLabelRef = (0, _react.useRef)(null);
|
88
104
|
var activeFirstValue = dragValue === min ? _Slider.classes.activeRangeValue : undefined;
|
89
105
|
var activeSecondValue = dragValue === max ? _Slider.classes.activeRangeValue : undefined;
|
90
106
|
(0, _react.useEffect)(function () {
|
91
|
-
var
|
92
|
-
|
107
|
+
var visibleValue = reversed ? max - dragValue + min : dragValue;
|
108
|
+
var localValue = Math.min(Math.max(visibleValue, min), max) - min;
|
109
|
+
if (!isVertical && rangeValuesPlacement === 'outer') {
|
93
110
|
var _startLabelRef$curren, _endLabelRef$current;
|
94
111
|
var startWidth = (_startLabelRef$curren = startLabelRef.current) === null || _startLabelRef$curren === void 0 ? void 0 : _startLabelRef$curren.offsetWidth;
|
95
112
|
if ((0, _utils2.isNumber)(startWidth)) {
|
@@ -99,30 +116,35 @@ var SingleSlider = exports.SingleSlider = function SingleSlider(_ref) {
|
|
99
116
|
if ((0, _utils2.isNumber)(endWidth)) {
|
100
117
|
setEndOffset(Number(endWidth));
|
101
118
|
}
|
119
|
+
} else if (isVertical && innerShowScale && sliderAlign !== 'center') {
|
120
|
+
setStartOffset(12);
|
121
|
+
setEndOffset(12);
|
102
122
|
} else {
|
103
123
|
setStartOffset(1);
|
104
124
|
setEndOffset(1);
|
105
125
|
}
|
106
126
|
setState(function (prevState) {
|
107
127
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
108
|
-
|
128
|
+
handlePosition: stepSize * localValue,
|
109
129
|
railFillWidth: stepSize * localValue
|
110
130
|
});
|
111
131
|
});
|
112
|
-
}, [dragValue, labelPlacement, stepSize, rangeValuesPlacement, min, max,
|
132
|
+
}, [dragValue, innerShowScale, labelPlacement, stepSize, rangeValuesPlacement, min, max, isVertical, reversed,
|
133
|
+
// для перерасчета размеров
|
134
|
+
sliderAlign, size]);
|
113
135
|
var setStepSize = (0, _react.useCallback)(function (newStepSize) {
|
114
136
|
setState(function (prevState) {
|
115
137
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
116
138
|
stepSize: newStepSize
|
117
139
|
});
|
118
140
|
});
|
119
|
-
}, [
|
141
|
+
}, []);
|
120
142
|
var onHandleChange = function onHandleChange(handleValue, data) {
|
121
|
-
var
|
122
|
-
var
|
143
|
+
var newValue = Math.round(reversed ? max - handleValue + min : handleValue);
|
144
|
+
var newHandlePosition = isVertical ? data.y : data.x;
|
123
145
|
setState(function (prevState) {
|
124
146
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
125
|
-
railFillWidth:
|
147
|
+
railFillWidth: newHandlePosition
|
126
148
|
});
|
127
149
|
});
|
128
150
|
if (onChange) {
|
@@ -140,41 +162,49 @@ var SingleSlider = exports.SingleSlider = function SingleSlider(_ref) {
|
|
140
162
|
}
|
141
163
|
setDragValue(newValue);
|
142
164
|
};
|
143
|
-
var onHandleChangeCommitted = function
|
144
|
-
var newValue = Math.round(handleValue);
|
165
|
+
var onHandleChangeCommitted = (0, _react.useCallback)(function (handleValue, data) {
|
166
|
+
var newValue = Math.round(reversed ? max - handleValue + min : handleValue);
|
145
167
|
if (onChangeCommitted) {
|
146
168
|
onChangeCommitted(newValue);
|
147
169
|
}
|
148
170
|
setState(function (prevState) {
|
149
171
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
150
|
-
|
151
|
-
railFillWidth: data.lastX
|
172
|
+
handlePosition: isVertical ? data.lastY : data.lastX,
|
173
|
+
railFillWidth: isVertical ? data.lastY : data.lastX
|
152
174
|
});
|
153
175
|
});
|
154
176
|
setDragValue(newValue);
|
155
|
-
};
|
177
|
+
}, [isVertical, min, max, reversed]);
|
178
|
+
var labelVerticalPlacement = reversed ? 'bottom' : 'top';
|
179
|
+
var valuePlacement = sliderAlign === 'right' ? 'left' : 'right';
|
180
|
+
var settings = _utils.sizeData[size][pointerSize === 'large' ? 'large' : 'small'];
|
156
181
|
return /*#__PURE__*/_react["default"].createElement(_Single.SingleWrapper, {
|
157
|
-
className: labelPlacementClass
|
158
|
-
}, hasLabelContent && /*#__PURE__*/_react["default"].createElement(_Single.LabelWrapper, null, labelContentLeft && /*#__PURE__*/_react["default"].createElement(_Single.
|
159
|
-
className:
|
160
|
-
},
|
182
|
+
className: (0, _utils2.cx)(labelPlacementClass, scaleAlignClass, verticalOrientationClass, sliderAlign === 'right' && _Slider.classes.labelAlignLeft, (sliderAlign === 'center' || sliderAlign === 'none') && _Slider.classes.labelAlignCenter, sliderAlign === 'left' && _Slider.classes.labelAlignRight, labelVerticalPlacement === 'bottom' && _Slider.classes.labelPlacementBottom, labelReversed && _Slider.classes.labelContentReversed)
|
183
|
+
}, hasLabelContent && /*#__PURE__*/_react["default"].createElement(_Single.LabelWrapper, null, (labelContentLeft || labelContent) && /*#__PURE__*/_react["default"].createElement(_Single.LabelContent, null, labelContent), label && /*#__PURE__*/_react["default"].createElement(_Single.Label, null, label)), /*#__PURE__*/_react["default"].createElement(_Single.SliderBaseWrapper, {
|
184
|
+
className: (0, _utils2.cx)(!isVertical && rangeValuesPlacement === 'outer' && _Slider.classes.rangeValuesPlacementOuter, !isVertical && rangeValuesPlacement !== 'outer' && _Slider.classes.rangeValuesPlacementInner, verticalOrientationClass)
|
185
|
+
}, innerShowScale && /*#__PURE__*/_react["default"].createElement(_Single.StyledRangeValue, {
|
161
186
|
ref: startLabelRef,
|
162
187
|
className: (0, _utils2.cx)(hideMinValueDiffClass, activeFirstValue)
|
163
|
-
}, min), /*#__PURE__*/_react["default"].createElement(_SliderBase.SliderBase, _extends({
|
188
|
+
}, reversed ? max : min), /*#__PURE__*/_react["default"].createElement(_SliderBase.SliderBase, _extends({
|
164
189
|
min: min,
|
165
190
|
max: max,
|
166
191
|
disabled: disabled,
|
192
|
+
size: size,
|
193
|
+
sliderAlign: sliderAlign,
|
167
194
|
setStepSize: setStepSize,
|
168
195
|
onChange: onHandleChangeCommitted,
|
169
196
|
railFillWidth: state.railFillWidth,
|
170
|
-
settings:
|
197
|
+
settings: settings,
|
171
198
|
labelPlacement: labelPlacement,
|
172
|
-
rangeValuesPlacement: rangeValuesPlacement
|
199
|
+
rangeValuesPlacement: rangeValuesPlacement,
|
200
|
+
orientation: orientation
|
173
201
|
}, rest), /*#__PURE__*/_react["default"].createElement(_ui.Handler, {
|
202
|
+
size: pointerSize,
|
203
|
+
orientation: orientation,
|
174
204
|
stepSize: state.stepSize,
|
175
205
|
onChangeCommitted: onHandleChangeCommitted,
|
176
206
|
onChange: onHandleChange,
|
177
|
-
|
207
|
+
position: state.handlePosition,
|
178
208
|
min: min,
|
179
209
|
max: max,
|
180
210
|
startOffset: startOffset,
|
@@ -183,11 +213,12 @@ var SingleSlider = exports.SingleSlider = function SingleSlider(_ref) {
|
|
183
213
|
disabled: disabled,
|
184
214
|
ariaLabel: ariaLabel,
|
185
215
|
multipleStepSize: multipleStepSize,
|
186
|
-
showCurrentValue: showCurrentValue
|
187
|
-
|
216
|
+
showCurrentValue: showCurrentValue,
|
217
|
+
valuePlacement: valuePlacement
|
218
|
+
})), innerShowScale && /*#__PURE__*/_react["default"].createElement(_Single.StyledRangeValue, {
|
188
219
|
ref: endLabelRef,
|
189
220
|
className: (0, _utils2.cx)(_Slider.classes.maxRangeValue, hideMaxValueDiffClass, activeSecondValue)
|
190
|
-
}, max)), /*#__PURE__*/_react["default"].createElement(_SliderBase2.InputHidden, _extends({
|
221
|
+
}, reversed ? min : max)), /*#__PURE__*/_react["default"].createElement(_SliderBase2.InputHidden, _extends({
|
191
222
|
name: name,
|
192
223
|
type: "number",
|
193
224
|
datatype: "slider-single",
|
@@ -3,25 +3,25 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.StyledRangeValue = exports.SliderBaseWrapper = exports.SingleWrapper = exports.LabelWrapper = exports.
|
6
|
+
exports.StyledRangeValue = exports.SliderBaseWrapper = exports.SingleWrapper = exports.LabelWrapper = exports.LabelContent = exports.Label = void 0;
|
7
7
|
var _styledComponents = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("styled-components"));
|
8
8
|
var _Slider = /*#__PURE__*/require("../../Slider.tokens");
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
10
10
|
var LabelWrapper = exports.LabelWrapper = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
11
11
|
componentId: "plasma-new-hope__sc-1qm4elt-0"
|
12
12
|
})(["color:var(", ");display:flex;gap:var(", ");"], _Slider.tokens.labelColor, _Slider.tokens.labelWrapperGap);
|
13
|
-
var
|
13
|
+
var LabelContent = exports.LabelContent = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
14
14
|
componentId: "plasma-new-hope__sc-1qm4elt-1"
|
15
|
-
})([""]);
|
15
|
+
})(["display:inline-flex;"]);
|
16
16
|
var Label = exports.Label = /*#__PURE__*/_styledComponents["default"].label.withConfig({
|
17
17
|
componentId: "plasma-new-hope__sc-1qm4elt-2"
|
18
18
|
})(["font-family:var(", ");font-size:var(", ");font-style:var(", ");font-weight:var(", ");letter-spacing:var(", ");line-height:var(", ");"], _Slider.tokens.labelFontFamily, _Slider.tokens.labelFontSize, _Slider.tokens.labelFontStyle, _Slider.tokens.labelFontWeight, _Slider.tokens.labelLetterSpacing, _Slider.tokens.labelLineHeight);
|
19
19
|
var StyledRangeValue = exports.StyledRangeValue = /*#__PURE__*/_styledComponents["default"].span.withConfig({
|
20
20
|
componentId: "plasma-new-hope__sc-1qm4elt-3"
|
21
|
-
})(["color:var(", ");font-family:var(", ");font-size:var(", ");font-style:var(", ");font-weight:var(", ");letter-spacing:var(", ");line-height:var(", ");transition:opacity 0.1s ease-in-out;&.", ",&.", "{opacity:0;}&.", "{color:var(", ");}"], _Slider.tokens.rangeValueColor, _Slider.tokens.
|
21
|
+
})(["color:var(", ");font-family:var(", ");font-size:var(", ");font-style:var(", ");font-weight:var(", ");letter-spacing:var(", ");line-height:var(", ");transition:opacity 0.1s ease-in-out;&.", ",&.", "{opacity:0;}&.", "{color:var(", ");}"], _Slider.tokens.rangeValueColor, _Slider.tokens.valueFontFamily, _Slider.tokens.valueFontSize, _Slider.tokens.valueFontStyle, _Slider.tokens.valueFontWeight, _Slider.tokens.valueLetterSpacing, _Slider.tokens.valueLineHeight, _Slider.classes.hideMinValue, _Slider.classes.hideMaxValue, _Slider.classes.activeRangeValue, _Slider.tokens.labelColor);
|
22
22
|
var SliderBaseWrapper = exports.SliderBaseWrapper = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
23
23
|
componentId: "plasma-new-hope__sc-1qm4elt-4"
|
24
|
-
})(["position:relative;display:flex;flex:1;&.", "{", "{position:absolute;bottom:var(", ");left:0;&.", "{left:unset;right:0;}}}&.", "{align-items:center;", "{margin-right:var(", ");&.", "{margin-right:0;margin-left:var(", ");}}}"], _Slider.classes.rangeValuesPlacementOuter, StyledRangeValue, _Slider.tokens.rangeValueBottomOffset, _Slider.classes.maxRangeValue, _Slider.classes.rangeValuesPlacementInner, StyledRangeValue, _Slider.tokens.
|
24
|
+
})(["position:relative;display:flex;flex:1;&.", "{", "{position:absolute;bottom:calc(var(", ") * -1.5 - var(", "));left:0;&.", "{left:unset;right:0;}}}&.", "{align-items:center;", "{margin-right:var(", ");&.", "{margin-right:0;margin-left:var(", ");}}}"], _Slider.classes.rangeValuesPlacementOuter, StyledRangeValue, _Slider.tokens.railThickness, _Slider.tokens.rangeValueBottomOffset, _Slider.classes.maxRangeValue, _Slider.classes.rangeValuesPlacementInner, StyledRangeValue, _Slider.tokens.rangeValueHorizontalMargin, _Slider.classes.maxRangeValue, _Slider.tokens.rangeValueHorizontalMargin);
|
25
25
|
var SingleWrapper = exports.SingleWrapper = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
26
26
|
componentId: "plasma-new-hope__sc-1qm4elt-5"
|
27
|
-
})(["display:flex;opacity:var(", ");&.", "{flex-direction:column;", "{margin-bottom:var(", ");}}&.", "{", "{margin-right:var(", ");}}"], _Slider.tokens.disabledOpacity, _Slider.classes.labelPlacementOuter, LabelWrapper, _Slider.tokens.labelWrapperMarginBottom, _Slider.classes.labelPlacementInner, LabelWrapper, _Slider.tokens.labelWrapperMarginRight);
|
27
|
+
})(["display:flex;opacity:var(", ");&.", "{flex-direction:column;", "{margin-bottom:var(", ");}}&.", "{", "{margin-right:var(", ");}}&.", "{flex-direction:column;align-items:center;&.", "{", "{flex-direction:column-reverse;}&.", "{", "{flex-direction:column;}&.", "{", "{flex-direction:column-reverse;}}}&.", "{", "{flex-direction:column;}}}", "{align-items:center;}", "{width:var(", ");}&.", "{", "{margin-right:0;margin-bottom:var(", ");}}&.", "{align-items:flex-end;", "{flex-direction:row-reverse;}}&.", "{align-items:flex-start;}&.", "{flex-direction:column-reverse;", "{margin-top:var(", ");margin-right:0;margin-bottom:0;}}}&.", "{flex-direction:column;align-items:center;justify-content:center;", "{flex-direction:column;align-items:center;justify-content:center;}&.", "{", "{position:static;bottom:0;left:0;margin-bottom:var(", ");&.", "{left:0;right:0;bottom:0;margin-top:var(", ");margin-bottom:0;}}}&.", ",&.", "{", "{margin-right:0;margin-bottom:0;position:absolute;top:0;right:calc( var(", ") / 2 + var(", ") / 2 + var(", ") );&.", "{margin-right:0;margin-left:0;top:auto;bottom:0;}}}&.", "{", "{left:calc(var(", ") + var(", "));}}}"], _Slider.tokens.disabledOpacity, _Slider.classes.labelPlacementOuter, LabelWrapper, _Slider.tokens.labelWrapperMarginBottom, _Slider.classes.labelPlacementInner, LabelWrapper, _Slider.tokens.labelWrapperMarginRight, _Slider.classes.verticalOrientation, _Slider.classes.labelAlignCenter, LabelWrapper, _Slider.classes.labelPlacementBottom, LabelWrapper, _Slider.classes.labelContentReversed, LabelWrapper, _Slider.classes.labelContentReversed, LabelWrapper, LabelWrapper, SliderBaseWrapper, _Slider.tokens.size, _Slider.classes.labelPlacementInner, LabelWrapper, _Slider.tokens.labelWrapperVerticalMargin, _Slider.classes.labelAlignLeft, LabelWrapper, _Slider.classes.labelAlignRight, _Slider.classes.labelPlacementBottom, LabelWrapper, _Slider.tokens.labelWrapperVerticalMargin, _Slider.classes.verticalOrientation, SliderBaseWrapper, _Slider.classes.labelAlignCenter, StyledRangeValue, _Slider.tokens.rangeValueVerticalMargin, _Slider.classes.maxRangeValue, _Slider.tokens.rangeValueVerticalMargin, _Slider.classes.labelAlignLeft, _Slider.classes.labelAlignRight, StyledRangeValue, _Slider.tokens.railThickness, _Slider.tokens.size, _Slider.tokens.rangeValueHorizontalOffset, _Slider.classes.maxRangeValue, _Slider.classes.labelAlignRight, StyledRangeValue, _Slider.tokens.size, _Slider.tokens.railThickness);
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
exports.SliderBase = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
9
|
var _hooks = /*#__PURE__*/require("../../../../hooks");
|
10
|
+
var _Slider = /*#__PURE__*/require("../../Slider.tokens");
|
11
|
+
var _utils = /*#__PURE__*/require("../../../../utils");
|
10
12
|
var _SliderBase = /*#__PURE__*/require("./SliderBase.styles");
|
11
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
12
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
@@ -22,6 +24,9 @@ var SliderBase = exports.SliderBase = function SliderBase(_ref) {
|
|
22
24
|
labelPlacement = _ref.labelPlacement,
|
23
25
|
rangeValuesPlacement = _ref.rangeValuesPlacement,
|
24
26
|
onChange = _ref.onChange,
|
27
|
+
orientation = _ref.orientation,
|
28
|
+
size = _ref.size,
|
29
|
+
sliderAlign = _ref.sliderAlign,
|
25
30
|
_ref$settings = _ref.settings,
|
26
31
|
settings = _ref$settings === void 0 ? {} : _ref$settings;
|
27
32
|
var _settings$indent = settings.indent,
|
@@ -30,34 +35,43 @@ var SliderBase = exports.SliderBase = function SliderBase(_ref) {
|
|
30
35
|
fontSizeMultiplier = _settings$fontSizeMul === void 0 ? 16 : _settings$fontSizeMul;
|
31
36
|
var ref = (0, _react.useRef)(null);
|
32
37
|
var gap = indent * fontSizeMultiplier * 2;
|
38
|
+
var isVertical = orientation === 'vertical';
|
33
39
|
(0, _react.useEffect)(function () {
|
34
40
|
var resizeHandler = function resizeHandler() {
|
35
41
|
if (ref.current) {
|
36
|
-
var railSize = ref.current.offsetWidth - gap;
|
42
|
+
var railSize = isVertical ? ref.current.offsetHeight - gap : ref.current.offsetWidth - gap;
|
37
43
|
var totalSteps = max - min;
|
38
44
|
setStepSize(railSize / totalSteps);
|
39
45
|
}
|
40
46
|
};
|
41
47
|
resizeHandler();
|
42
|
-
}, [labelPlacement, rangeValuesPlacement
|
48
|
+
}, [labelPlacement, rangeValuesPlacement, gap, isVertical,
|
49
|
+
// для перерасчета размеров
|
50
|
+
size, sliderAlign]);
|
43
51
|
var onHandleChange = function onHandleChange(e) {
|
44
52
|
if (!onChange || disabled) {
|
45
53
|
return;
|
46
54
|
}
|
47
55
|
var _e$currentTarget$getB = e.currentTarget.getBoundingClientRect(),
|
48
56
|
x = _e$currentTarget$getB.x,
|
49
|
-
width = _e$currentTarget$getB.width
|
50
|
-
|
51
|
-
|
57
|
+
width = _e$currentTarget$getB.width,
|
58
|
+
y = _e$currentTarget$getB.y,
|
59
|
+
height = _e$currentTarget$getB.height;
|
60
|
+
var lastPos = isVertical ? e.clientY - y : e.clientX - x;
|
61
|
+
var sliderWidth = isVertical ? height : width;
|
62
|
+
var position = min + lastPos / (sliderWidth - gap) * (max - min);
|
52
63
|
var result = Math.max(min, Math.min(max, position));
|
53
|
-
|
54
|
-
|
55
|
-
}
|
64
|
+
var data = isVertical ? {
|
65
|
+
lastY: lastPos
|
66
|
+
} : {
|
67
|
+
lastX: lastPos
|
68
|
+
};
|
69
|
+
onChange(result, data);
|
56
70
|
};
|
57
71
|
(0, _hooks.useIsomorphicLayoutEffect)(function () {
|
58
72
|
var resizeHandler = function resizeHandler() {
|
59
73
|
if (ref.current) {
|
60
|
-
var railSize = ref.current.offsetWidth - gap;
|
74
|
+
var railSize = isVertical ? ref.current.offsetHeight - gap : ref.current.offsetWidth - gap;
|
61
75
|
var totalSteps = max - min;
|
62
76
|
setStepSize(railSize / totalSteps);
|
63
77
|
}
|
@@ -67,13 +81,18 @@ var SliderBase = exports.SliderBase = function SliderBase(_ref) {
|
|
67
81
|
return function () {
|
68
82
|
return window.removeEventListener('resize', resizeHandler);
|
69
83
|
};
|
70
|
-
}, [min, max, setStepSize, gap, labelPlacement, rangeValuesPlacement]);
|
71
|
-
var fillStyle = {
|
84
|
+
}, [min, max, setStepSize, gap, labelPlacement, rangeValuesPlacement, isVertical]);
|
85
|
+
var fillStyle = isVertical ? {
|
86
|
+
top: "".concat(railFillXPosition, "px"),
|
87
|
+
height: "".concat(railFillWidth, "px"),
|
88
|
+
width: '100%'
|
89
|
+
} : {
|
72
90
|
left: "".concat(railFillXPosition, "px"),
|
73
91
|
width: "".concat(railFillWidth, "px")
|
74
92
|
};
|
75
93
|
return /*#__PURE__*/_react["default"].createElement(_SliderBase.Slider, {
|
76
|
-
ref: ref
|
94
|
+
ref: ref,
|
95
|
+
className: (0, _utils.cx)(orientation === 'vertical' && _Slider.classes.verticalOrientation)
|
77
96
|
}, /*#__PURE__*/_react["default"].createElement(_SliderBase.RailWrap, {
|
78
97
|
"aria-hidden": "true",
|
79
98
|
onMouseDown: onHandleChange
|
@@ -8,15 +8,15 @@ var _styledComponents = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/requir
|
|
8
8
|
var _mixins = /*#__PURE__*/require("../../../../mixins");
|
9
9
|
var _Slider = /*#__PURE__*/require("../../Slider.tokens");
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
11
|
-
var
|
11
|
+
var Rail = exports.Rail = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
12
12
|
componentId: "plasma-new-hope__sc-ik0bjb-0"
|
13
|
-
})(["
|
14
|
-
var
|
13
|
+
})(["position:relative;top:50%;height:var(", ");border-radius:var(", ");background-color:var(", ");overflow:hidden;transform:translateY(-50%);"], _Slider.tokens.railThickness, _Slider.tokens.railBorderRadius, _Slider.tokens.railBackgroundColor);
|
14
|
+
var Slider = exports.Slider = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
15
15
|
componentId: "plasma-new-hope__sc-ik0bjb-1"
|
16
|
-
})(["height:100%;"]);
|
17
|
-
var
|
16
|
+
})(["flex:1;position:relative;user-select:none;height:var(", ");&.", "{width:var(", ");height:auto;", "{top:0;left:50%;transform:translateX(-50%);width:var(", ");height:100%;}}"], _Slider.tokens.size, _Slider.classes.verticalOrientation, _Slider.tokens.size, Rail, _Slider.tokens.railThickness);
|
17
|
+
var RailWrap = exports.RailWrap = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
18
18
|
componentId: "plasma-new-hope__sc-ik0bjb-2"
|
19
|
-
})(["
|
19
|
+
})(["height:100%;"]);
|
20
20
|
var Fill = exports.Fill = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
21
21
|
componentId: "plasma-new-hope__sc-ik0bjb-3"
|
22
22
|
})(["position:absolute;height:100%;top:0;left:0;background:var(", ");width:0;"], _Slider.tokens.fillColor);
|
@@ -7,14 +7,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
exports.Handler = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
9
|
var _reactDraggable = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("react-draggable"));
|
10
|
-
var _utils = /*#__PURE__*/require("
|
10
|
+
var _utils = /*#__PURE__*/require("../../../../utils");
|
11
|
+
var _utils2 = /*#__PURE__*/require("../../utils");
|
11
12
|
var _Thumb = /*#__PURE__*/require("../Thumb/Thumb");
|
13
|
+
var _Slider = /*#__PURE__*/require("../../Slider.tokens");
|
12
14
|
var _Handler = /*#__PURE__*/require("./Handler.styles");
|
13
|
-
var
|
15
|
+
var _computeKeyPressData = /*#__PURE__*/require("./computeKeyPressData");
|
16
|
+
var _excluded = ["size", "orientation", "stepSize", "onChangeCommitted", "onChange", "position", "min", "max", "bounds", "zIndex", "disabled", "side", "showCurrentValue", "startOffset", "endOffset", "value", "valuePlacement"];
|
14
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
15
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
16
19
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
17
20
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
21
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
22
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
23
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
18
24
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
19
25
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
20
26
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
@@ -25,22 +31,14 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
25
31
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
26
32
|
// TODO: PLASMA-1707
|
27
33
|
|
28
|
-
var KeyboardSupport = {
|
29
|
-
PageUp: 33,
|
30
|
-
PageDown: 34,
|
31
|
-
End: 35,
|
32
|
-
Home: 36,
|
33
|
-
ArrowLeft: 37,
|
34
|
-
ArrowUp: 38,
|
35
|
-
ArrowRight: 39,
|
36
|
-
ArrowDown: 40
|
37
|
-
};
|
38
34
|
var Handler = exports.Handler = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
39
|
-
var
|
35
|
+
var size = _ref.size,
|
36
|
+
orientation = _ref.orientation,
|
37
|
+
stepSize = _ref.stepSize,
|
40
38
|
onChangeCommitted = _ref.onChangeCommitted,
|
41
39
|
onChange = _ref.onChange,
|
42
|
-
_ref$
|
43
|
-
|
40
|
+
_ref$position = _ref.position,
|
41
|
+
position = _ref$position === void 0 ? 0 : _ref$position,
|
44
42
|
min = _ref.min,
|
45
43
|
max = _ref.max,
|
46
44
|
_ref$bounds = _ref.bounds,
|
@@ -55,122 +53,88 @@ var Handler = exports.Handler = /*#__PURE__*/(0, _react.forwardRef)(function (_r
|
|
55
53
|
_ref$endOffset = _ref.endOffset,
|
56
54
|
endOffset = _ref$endOffset === void 0 ? 0 : _ref$endOffset,
|
57
55
|
value = _ref.value,
|
56
|
+
valuePlacement = _ref.valuePlacement,
|
58
57
|
rest = _objectWithoutProperties(_ref, _excluded);
|
58
|
+
var isVertical = orientation === 'vertical';
|
59
59
|
var lastOnChangeValue = (0, _react.useRef)();
|
60
|
-
var _getOffsets = (0,
|
60
|
+
var _getOffsets = (0, _utils2.getOffsets)(ref, side, isVertical),
|
61
61
|
_getOffsets2 = _slicedToArray(_getOffsets, 2),
|
62
|
-
|
63
|
-
|
62
|
+
startClientOffset = _getOffsets2[0],
|
63
|
+
endClientOffset = _getOffsets2[1];
|
64
64
|
var _bounds = _slicedToArray(bounds, 2),
|
65
|
-
|
66
|
-
|
67
|
-
var
|
68
|
-
var
|
69
|
-
var
|
70
|
-
x:
|
71
|
-
y: 0
|
65
|
+
startValueBound = _bounds[0],
|
66
|
+
endValueBound = _bounds[1];
|
67
|
+
var startPositionBound = startValueBound ? (startValueBound - min) * stepSize : null;
|
68
|
+
var endPositionBound = endValueBound ? (endValueBound - min) * stepSize : null;
|
69
|
+
var dragPosition = typeof position === 'number' ? {
|
70
|
+
x: isVertical ? 0 : position,
|
71
|
+
y: isVertical ? position : 0
|
72
72
|
} : undefined;
|
73
73
|
var tabIndex = disabled ? -1 : 0;
|
74
|
-
var computedBounds = {
|
75
|
-
|
76
|
-
right: (rightPositionBound !== null && rightPositionBound !== void 0 ? rightPositionBound : stepSize * (max - min)) - (offsetRight ? stepSize : 0)
|
77
|
-
};
|
78
|
-
var showCurrentValueCondition = showCurrentValue && (xPosition >= startOffset && xPosition <= max * stepSize - endOffset || xPosition === 0 && value !== 0);
|
74
|
+
var computedBounds = _defineProperty(_defineProperty({}, isVertical ? 'top' : 'left', (startPositionBound !== null && startPositionBound !== void 0 ? startPositionBound : 0) - (startClientOffset ? stepSize : 0)), isVertical ? 'bottom' : 'right', (endPositionBound !== null && endPositionBound !== void 0 ? endPositionBound : stepSize * (max - min)) - (endClientOffset ? stepSize : 0));
|
75
|
+
var showCurrentValueCondition = showCurrentValue && (position >= startOffset && position <= max * stepSize - endOffset || position === 0 && value !== 0);
|
79
76
|
var onDrag = function onDrag(_, data) {
|
80
|
-
var newValue = (0,
|
77
|
+
var newValue = (0, _utils2.getSliderThumbValue)(isVertical ? data.y : data.x, stepSize, min, max);
|
81
78
|
if (lastOnChangeValue.current !== newValue) {
|
82
79
|
onChange === null || onChange === void 0 || onChange(newValue, data);
|
83
80
|
lastOnChangeValue.current = newValue;
|
84
81
|
}
|
85
82
|
};
|
86
83
|
var onStop = function onStop(_, data) {
|
87
|
-
var newValue = (0,
|
84
|
+
var newValue = (0, _utils2.getSliderThumbValue)(isVertical ? data.y : data.x, stepSize, min, max);
|
88
85
|
onChangeCommitted && onChangeCommitted(newValue, data);
|
89
86
|
};
|
90
87
|
var onKeyPress = function onKeyPress(event) {
|
91
88
|
event.persist();
|
92
|
-
var keyCode = event.keyCode,
|
93
|
-
target = event.target;
|
94
|
-
if (!Object.values(KeyboardSupport).includes(keyCode)) {
|
95
|
-
return;
|
96
|
-
}
|
97
|
-
var ArrowUp = KeyboardSupport.ArrowUp,
|
98
|
-
ArrowRight = KeyboardSupport.ArrowRight,
|
99
|
-
ArrowDown = KeyboardSupport.ArrowDown,
|
100
|
-
ArrowLeft = KeyboardSupport.ArrowLeft,
|
101
|
-
Home = KeyboardSupport.Home,
|
102
|
-
End = KeyboardSupport.End,
|
103
|
-
PageDown = KeyboardSupport.PageDown,
|
104
|
-
PageUp = KeyboardSupport.PageUp;
|
105
89
|
var computedMultipleSteps = stepSize * (rest.multipleStepSize / 100 * max);
|
106
|
-
var data = {
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
switch (keyCode) {
|
116
|
-
case ArrowUp:
|
117
|
-
case ArrowRight:
|
118
|
-
data.x = xPosition + stepSize;
|
119
|
-
break;
|
120
|
-
case ArrowDown:
|
121
|
-
case ArrowLeft:
|
122
|
-
data.x = xPosition - stepSize;
|
123
|
-
data.deltaX = -stepSize;
|
124
|
-
break;
|
125
|
-
case PageUp:
|
126
|
-
data.x = xPosition + computedMultipleSteps;
|
127
|
-
data.deltaX = computedMultipleSteps;
|
128
|
-
break;
|
129
|
-
case PageDown:
|
130
|
-
data.x = xPosition - computedMultipleSteps;
|
131
|
-
data.deltaX = -computedMultipleSteps;
|
132
|
-
break;
|
133
|
-
case End:
|
134
|
-
data.x = max * stepSize;
|
135
|
-
break;
|
136
|
-
case Home:
|
137
|
-
data.x = 0;
|
138
|
-
break;
|
139
|
-
default:
|
140
|
-
data.x = 0;
|
90
|
+
var data = (0, _computeKeyPressData.computeKeyPressData)(event, {
|
91
|
+
isVertical: isVertical,
|
92
|
+
stepSize: stepSize,
|
93
|
+
position: position,
|
94
|
+
max: max,
|
95
|
+
computedMultipleSteps: computedMultipleSteps
|
96
|
+
});
|
97
|
+
if (!data) {
|
98
|
+
return;
|
141
99
|
}
|
142
100
|
var left = computedBounds.left,
|
143
|
-
right = computedBounds.right
|
101
|
+
right = computedBounds.right,
|
102
|
+
top = computedBounds.top,
|
103
|
+
bottom = computedBounds.bottom;
|
144
104
|
|
145
105
|
/*
|
146
106
|
* INFO: Находим значение в диапазоне между указанными левой и правой границами.
|
107
|
+
* Или между верхней и нижней
|
147
108
|
* Необходимо для правильного расчета положения SliderThumb.
|
148
109
|
* см. функция clamp
|
149
110
|
*/
|
150
|
-
var boundedValue = Math.max(Math.min(right, data.x), left);
|
151
|
-
var computedValue = (0,
|
111
|
+
var boundedValue = isVertical ? Math.max(Math.min(bottom, data.y), top) : Math.max(Math.min(right, data.x), left);
|
112
|
+
var computedValue = (0, _utils2.getSliderThumbValue)(boundedValue, stepSize, min, max);
|
152
113
|
lastOnChangeValue.current = computedValue;
|
153
114
|
onChangeCommitted && onChangeCommitted(computedValue, data);
|
154
115
|
};
|
155
116
|
return /*#__PURE__*/_react["default"].createElement(_reactDraggable["default"], {
|
156
|
-
axis:
|
117
|
+
axis: isVertical ? 'y' : 'x',
|
157
118
|
bounds: computedBounds,
|
158
|
-
grid: [stepSize, 1],
|
119
|
+
grid: isVertical ? [1, stepSize] : [stepSize, 1],
|
159
120
|
onStop: onStop,
|
160
121
|
onDrag: onDrag,
|
161
|
-
position:
|
122
|
+
position: dragPosition,
|
162
123
|
disabled: disabled
|
163
124
|
}, /*#__PURE__*/_react["default"].createElement(_Handler.HandlerStyled, {
|
164
125
|
ref: ref,
|
165
126
|
style: {
|
166
127
|
zIndex: zIndex
|
167
128
|
},
|
129
|
+
className: (0, _utils.cx)(isVertical && _Slider.classes.verticalOrientation, valuePlacement === 'left' && _Slider.classes.valuePlacementLeft),
|
130
|
+
isLarge: size === 'large',
|
168
131
|
onKeyDown: onKeyPress
|
169
|
-
}, /*#__PURE__*/_react["default"].createElement(_Thumb.Thumb, _extends({
|
132
|
+
}, size !== 'none' && /*#__PURE__*/_react["default"].createElement(_Thumb.Thumb, _extends({
|
170
133
|
tabIndex: tabIndex,
|
171
134
|
min: min,
|
172
135
|
max: max,
|
173
136
|
value: value,
|
174
|
-
disabled: disabled
|
137
|
+
disabled: disabled,
|
138
|
+
orientation: orientation
|
175
139
|
}, rest)), showCurrentValueCondition && /*#__PURE__*/_react["default"].createElement(_Handler.StyledValue, null, value)));
|
176
140
|
});
|
@@ -7,9 +7,12 @@ exports.StyledValue = exports.HandlerStyled = void 0;
|
|
7
7
|
var _styledComponents = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("styled-components"));
|
8
8
|
var _Slider = /*#__PURE__*/require("../../Slider.tokens");
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
10
|
-
var HandlerStyled = exports.HandlerStyled = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
11
|
-
componentId: "plasma-new-hope__sc-a1py3c-0"
|
12
|
-
})(["cursor:pointer;position:absolute;z-index:1;top:0;left:0;"]);
|
13
10
|
var StyledValue = exports.StyledValue = /*#__PURE__*/_styledComponents["default"].span.withConfig({
|
11
|
+
componentId: "plasma-new-hope__sc-a1py3c-0"
|
12
|
+
})(["position:absolute;z-index:1;top:var(", ");text-align:center;width:100%;margin-left:-0.125rem;display:flex;justify-content:center;font-family:var(", ");font-size:var(", ");font-style:var(", ");font-weight:var(", ");letter-spacing:var(", ");line-height:var(", ");"], _Slider.tokens.currentValueTopOffset, _Slider.tokens.valueFontFamily, _Slider.tokens.valueFontSize, _Slider.tokens.valueFontStyle, _Slider.tokens.valueFontWeight, _Slider.tokens.valueLetterSpacing, _Slider.tokens.valueLineHeight);
|
13
|
+
var HandlerStyled = exports.HandlerStyled = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
14
14
|
componentId: "plasma-new-hope__sc-a1py3c-1"
|
15
|
-
})(["position:absolute;z-index:1;top:
|
15
|
+
})(["cursor:pointer;position:absolute;z-index:1;top:0;left:0;bottom:0;display:flex;align-items:center;justify-content:center;--thumb-size:", ";&.", "{right:0;bottom:auto;align-items:flex-start;justify-content:center;", "{margin:0;top:0;bottom:0;right:0;left:calc(var(", ") - (var(", ") - var(--thumb-size)) / 2 + 0.25rem);align-items:center;justify-content:flex-start;}}&.", "{", "{left:auto;right:calc(var(", ") - (var(", ") - var(--thumb-size)) / 2 + 0.3125rem);justify-content:flex-end;}}"], function (_ref) {
|
16
|
+
var isLarge = _ref.isLarge;
|
17
|
+
return isLarge ? "var(".concat(_Slider.tokens.thumbSizeLarge, ")") : "var(".concat(_Slider.tokens.thumbSize, ")");
|
18
|
+
}, _Slider.classes.verticalOrientation, StyledValue, _Slider.tokens.size, _Slider.tokens.size, _Slider.classes.valuePlacementLeft, StyledValue, _Slider.tokens.size, _Slider.tokens.size);
|