@nutui/nutui-react 2.0.0-alpha.7 → 2.0.0-alpha.8
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 +6 -0
- package/dist/esm/Audio.js +7 -3
- package/dist/esm/Cascader.js +20 -12
- package/dist/esm/Range/style/index.js +1 -1
- package/dist/esm/Range.js +119 -174
- package/dist/esm/tabs2.js +19 -8
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/id-ID.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/locales/zh-UG.js +1 -1
- package/dist/nutui.react.mjs +553 -609
- package/dist/nutui.react.umd.js +553 -609
- package/dist/packages/range/range.scss +24 -49
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/variables-jmapp.scss +11 -17
- package/dist/styles/variables.scss +11 -14
- package/dist/types/index.d.ts +20 -26
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# v2.0.0-alpha.8
|
|
2
|
+
`2023-05-12`
|
|
3
|
+
* :sparkles:feat: cascader支持受控 (#1000) @xiaoyatong
|
|
4
|
+
* :bug: fix: tabs children 变更后需要展示新的 title (#999) @oasis-cloud
|
|
5
|
+
* 🛠 refactor: Range (#991) @Eiinu
|
|
6
|
+
|
|
1
7
|
# v2.0.0-alpha.7
|
|
2
8
|
`2023-05-12`
|
|
3
9
|
* :bug: fix: tabs children 变化需要更新选中状态 @oasis-cloud
|
package/dist/esm/Audio.js
CHANGED
|
@@ -154,9 +154,13 @@ var Audio = function Audio2(props) {
|
|
|
154
154
|
}, currentDuration), React__default.createElement("div", {
|
|
155
155
|
className: "".concat(classPrefix, "__progress-bar-wrapper")
|
|
156
156
|
}, React__default.createElement(Range, {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
value: percent,
|
|
158
|
+
onChange: function onChange(val) {
|
|
159
|
+
return setPercent(val);
|
|
160
|
+
},
|
|
161
|
+
currentDescription: null,
|
|
162
|
+
maxDescription: null,
|
|
163
|
+
minDescription: null,
|
|
160
164
|
"inactive-color": "#cccccc",
|
|
161
165
|
"active-color": "#fa2c19"
|
|
162
166
|
})), React__default.createElement("div", {
|
package/dist/esm/Cascader.js
CHANGED
|
@@ -49,9 +49,9 @@ import Popup from "./Popup.js";
|
|
|
49
49
|
import { T as Tabs } from "./tabs2.js";
|
|
50
50
|
import { Loading, Checklist } from "@nutui/icons-react";
|
|
51
51
|
import { C as ComponentDefaults } from "./typings.js";
|
|
52
|
+
import { u as usePropsValue } from "./use-props-value.js";
|
|
52
53
|
import "./TabPane.js";
|
|
53
54
|
import "./raf.js";
|
|
54
|
-
import "./use-props-value.js";
|
|
55
55
|
var defaultProps$1 = {
|
|
56
56
|
data: {
|
|
57
57
|
text: "",
|
|
@@ -247,7 +247,6 @@ var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
|
247
247
|
popup: true,
|
|
248
248
|
visible: false,
|
|
249
249
|
options: [],
|
|
250
|
-
value: [],
|
|
251
250
|
title: "",
|
|
252
251
|
optionKey: {
|
|
253
252
|
textKey: "text",
|
|
@@ -267,14 +266,23 @@ var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
|
267
266
|
},
|
|
268
267
|
onPathChange: function onPathChange() {
|
|
269
268
|
}
|
|
270
|
-
}
|
|
269
|
+
});
|
|
271
270
|
var InternalCascader = function InternalCascader2(props, ref) {
|
|
272
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), className = _defaultProps$props.className, style = _defaultProps$props.style, popup = _defaultProps$props.popup, visible = _defaultProps$props.visible, options = _defaultProps$props.options, value = _defaultProps$props.value, title = _defaultProps$props.title, optionKey = _defaultProps$props.optionKey, format = _defaultProps$props.format, closeable = _defaultProps$props.closeable, closeIconPosition = _defaultProps$props.closeIconPosition, closeIcon = _defaultProps$props.closeIcon, lazy = _defaultProps$props.lazy, onLoad2 = _defaultProps$props.onLoad, onClose2 = _defaultProps$props.onClose, onChange2 = _defaultProps$props.onChange, onPathChange2 = _defaultProps$props.onPathChange;
|
|
271
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), className = _defaultProps$props.className, style = _defaultProps$props.style, popup = _defaultProps$props.popup, visible = _defaultProps$props.visible, options = _defaultProps$props.options, value = _defaultProps$props.value, defaultValue = _defaultProps$props.defaultValue, title = _defaultProps$props.title, optionKey = _defaultProps$props.optionKey, format = _defaultProps$props.format, closeable = _defaultProps$props.closeable, closeIconPosition = _defaultProps$props.closeIconPosition, closeIcon = _defaultProps$props.closeIcon, lazy = _defaultProps$props.lazy, onLoad2 = _defaultProps$props.onLoad, onClose2 = _defaultProps$props.onClose, onChange2 = _defaultProps$props.onChange, onPathChange2 = _defaultProps$props.onPathChange;
|
|
273
272
|
var _useState = useState("c1"), _useState2 = _slicedToArray(_useState, 2), tabvalue = _useState2[0], setTabvalue = _useState2[1];
|
|
274
273
|
var _useState3 = useState([]), _useState4 = _slicedToArray(_useState3, 2), optionsData = _useState4[0], setOptionsData = _useState4[1];
|
|
275
274
|
var isLazy = function isLazy2() {
|
|
276
275
|
return state.configs.lazy && Boolean(state.configs.onLoad);
|
|
277
276
|
};
|
|
277
|
+
var _usePropsValue = usePropsValue({
|
|
278
|
+
value,
|
|
279
|
+
defaultValue,
|
|
280
|
+
finalValue: defaultValue,
|
|
281
|
+
onChange: function onChange3(val) {
|
|
282
|
+
var _props$onChange;
|
|
283
|
+
(_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, val);
|
|
284
|
+
}
|
|
285
|
+
}), _usePropsValue2 = _slicedToArray(_usePropsValue, 2), innerValue = _usePropsValue2[0], setInnerValue = _usePropsValue2[1];
|
|
278
286
|
var _useState5 = useState({
|
|
279
287
|
optionsData: [],
|
|
280
288
|
panes: [{
|
|
@@ -282,7 +290,6 @@ var InternalCascader = function InternalCascader2(props, ref) {
|
|
|
282
290
|
selectedNode: [],
|
|
283
291
|
paneKey: ""
|
|
284
292
|
}],
|
|
285
|
-
innerValue: value,
|
|
286
293
|
tree: new Tree$1([], {}),
|
|
287
294
|
tabsCursor: 0,
|
|
288
295
|
initLoading: false,
|
|
@@ -299,12 +306,12 @@ var InternalCascader = function InternalCascader2(props, ref) {
|
|
|
299
306
|
var classesPane = classNames(_defineProperty({}, "".concat(classPrefix, "-pane"), true));
|
|
300
307
|
useEffect(function() {
|
|
301
308
|
initData();
|
|
302
|
-
}, [options]);
|
|
309
|
+
}, [options, format]);
|
|
303
310
|
useEffect(function() {
|
|
304
|
-
if (
|
|
305
|
-
|
|
311
|
+
if (defaultValue && defaultValue !== innerValue) {
|
|
312
|
+
setInnerValue(defaultValue);
|
|
306
313
|
}
|
|
307
|
-
}, [
|
|
314
|
+
}, [defaultValue]);
|
|
308
315
|
var initData = /* @__PURE__ */ function() {
|
|
309
316
|
var _ref = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime.mark(function _callee() {
|
|
310
317
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
@@ -358,8 +365,8 @@ var InternalCascader = function InternalCascader2(props, ref) {
|
|
|
358
365
|
while (1)
|
|
359
366
|
switch (_context3.prev = _context3.next) {
|
|
360
367
|
case 0:
|
|
361
|
-
currentValue =
|
|
362
|
-
if (!(currentValue === void 0 || !state.tree.nodes.length)) {
|
|
368
|
+
currentValue = innerValue;
|
|
369
|
+
if (!(currentValue === void 0 || currentValue !== defaultValue || !state.tree.nodes.length)) {
|
|
363
370
|
_context3.next = 3;
|
|
364
371
|
break;
|
|
365
372
|
}
|
|
@@ -427,7 +434,7 @@ var InternalCascader = function InternalCascader2(props, ref) {
|
|
|
427
434
|
case 18:
|
|
428
435
|
state.initLoading = false;
|
|
429
436
|
case 19:
|
|
430
|
-
if (needToSync.length && currentValue ===
|
|
437
|
+
if (needToSync.length && currentValue === defaultValue) {
|
|
431
438
|
pathNodes = state.tree.getPathNodesByValue(needToSync);
|
|
432
439
|
pathNodes.forEach(function(node, index) {
|
|
433
440
|
state.tabsCursor = index;
|
|
@@ -536,6 +543,7 @@ var InternalCascader = function InternalCascader2(props, ref) {
|
|
|
536
543
|
});
|
|
537
544
|
onChange2(optionParams, pathNodes);
|
|
538
545
|
onPathChange2(optionParams, pathNodes);
|
|
546
|
+
setInnerValue(optionParams);
|
|
539
547
|
}
|
|
540
548
|
setOptionsData(state.panes);
|
|
541
549
|
close();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import '../../../packages/range/range.scss'
|
package/dist/esm/Range.js
CHANGED
|
@@ -22,46 +22,41 @@ function _objectSpread(target) {
|
|
|
22
22
|
return target;
|
|
23
23
|
}
|
|
24
24
|
import React__default, { useState, useRef, useEffect, useCallback } from "react";
|
|
25
|
+
import classNames from "classnames";
|
|
25
26
|
import { u as useTouch } from "./use-touch.js";
|
|
26
27
|
import { g as getRect } from "./use-client-rect.js";
|
|
27
|
-
import
|
|
28
|
-
import {
|
|
29
|
-
var defaultProps = {
|
|
28
|
+
import { C as ComponentDefaults } from "./typings.js";
|
|
29
|
+
import { u as usePropsValue } from "./use-props-value.js";
|
|
30
|
+
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
30
31
|
range: false,
|
|
31
|
-
hiddenRange: false,
|
|
32
|
-
hiddenTag: false,
|
|
33
32
|
min: 0,
|
|
34
33
|
max: 100,
|
|
35
34
|
step: 1,
|
|
36
|
-
modelValue: 0,
|
|
37
35
|
vertical: false,
|
|
38
36
|
marks: {}
|
|
39
|
-
};
|
|
40
|
-
var startValue;
|
|
41
|
-
var currentValue;
|
|
37
|
+
});
|
|
42
38
|
var Range = function Range2(props) {
|
|
43
|
-
var
|
|
44
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), className = _defaultProps$props.className, range = _defaultProps$props.range, disabled = _defaultProps$props.disabled,
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
step = Number(step);
|
|
49
|
-
var _useState = useState(0), _useState2 = _slicedToArray(_useState, 2), buttonIndex = _useState2[0], SetButtonIndex = _useState2[1];
|
|
50
|
-
var _useState3 = useState(), _useState4 = _slicedToArray(_useState3, 2), initValue = _useState4[0], SetInitValue = _useState4[1];
|
|
51
|
-
var _useState5 = useState("start"), _useState6 = _slicedToArray(_useState5, 2), dragStatus = _useState6[0], SetDragStatus = _useState6[1];
|
|
39
|
+
var _classNames;
|
|
40
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), className = _defaultProps$props.className, range = _defaultProps$props.range, disabled = _defaultProps$props.disabled, button = _defaultProps$props.button, vertical = _defaultProps$props.vertical, marks = _defaultProps$props.marks, onChange = _defaultProps$props.onChange, onStart = _defaultProps$props.onStart, onEnd = _defaultProps$props.onEnd, minDescription = _defaultProps$props.minDescription, maxDescription = _defaultProps$props.maxDescription, currentDescription = _defaultProps$props.currentDescription, min = _defaultProps$props.min, max = _defaultProps$props.max, step = _defaultProps$props.step, value = _defaultProps$props.value, defaultValue = _defaultProps$props.defaultValue;
|
|
41
|
+
var classPrefix = "nut-range";
|
|
42
|
+
var _useState = useState(0), _useState2 = _slicedToArray(_useState, 2), buttonIndex = _useState2[0], setButtonIndex = _useState2[1];
|
|
43
|
+
var _useState3 = useState("start"), _useState4 = _slicedToArray(_useState3, 2), dragStatus = _useState4[0], setDragStatus = _useState4[1];
|
|
52
44
|
var touch = useTouch();
|
|
53
45
|
var root = useRef(null);
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}, [
|
|
46
|
+
var _useState5 = useState([]), _useState6 = _slicedToArray(_useState5, 2), marksList = _useState6[0], setMarksList = _useState6[1];
|
|
47
|
+
var _useState7 = useState(0), _useState8 = _slicedToArray(_useState7, 2), startValue = _useState8[0], setStartValue = _useState8[1];
|
|
48
|
+
var handleChange = function handleChange2(value2) {
|
|
49
|
+
onChange && onChange(value2);
|
|
50
|
+
};
|
|
51
|
+
var _usePropsValue = usePropsValue({
|
|
52
|
+
value,
|
|
53
|
+
defaultValue,
|
|
54
|
+
finalValue: 0,
|
|
55
|
+
onChange: handleChange
|
|
56
|
+
}), _usePropsValue2 = _slicedToArray(_usePropsValue, 2), current = _usePropsValue2[0], setCurrent = _usePropsValue2[1];
|
|
57
|
+
var _useState9 = useState(function() {
|
|
58
|
+
return value || defaultValue || 0;
|
|
59
|
+
}), _useState10 = _slicedToArray(_useState9, 2), exactValue = _useState10[0], setEaxctValue = _useState10[1];
|
|
65
60
|
useEffect(function() {
|
|
66
61
|
if (marks) {
|
|
67
62
|
var marksKeys = Object.keys(marks);
|
|
@@ -70,64 +65,41 @@ var Range = function Range2(props) {
|
|
|
70
65
|
}).filter(function(point) {
|
|
71
66
|
return point >= min && point <= max;
|
|
72
67
|
});
|
|
73
|
-
|
|
68
|
+
setMarksList(list);
|
|
74
69
|
}
|
|
75
70
|
}, [marks]);
|
|
76
71
|
var scope = function scope2() {
|
|
77
|
-
return
|
|
72
|
+
return max - min;
|
|
78
73
|
};
|
|
79
|
-
var classes =
|
|
80
|
-
|
|
81
|
-
return [prefixCls, "".concat(disabled ? "".concat(prefixCls, "-disabled") : ""), "".concat(vertical ? "".concat(prefixCls, "-vertical") : ""), "".concat(!hiddenRange ? "".concat(prefixCls, "-show-number") : "")].filter(Boolean).join(" ");
|
|
82
|
-
}, [disabled, vertical, hiddenRange]);
|
|
83
|
-
var containerClasses = useCallback(function() {
|
|
84
|
-
var prefixCls = "nut-range-container";
|
|
85
|
-
return [prefixCls, "".concat(vertical ? "".concat(prefixCls, "-vertical") : ""), className].filter(Boolean).join(" ");
|
|
86
|
-
}, [vertical, className]);
|
|
74
|
+
var classes = classNames(classPrefix, (_classNames = {}, _defineProperty(_classNames, "".concat(classPrefix, "-disabled"), disabled), _defineProperty(_classNames, "".concat(classPrefix, "-vertical"), vertical), _classNames));
|
|
75
|
+
var containerClasses = classNames("".concat(classPrefix, "-container"), className, _defineProperty({}, "".concat(classPrefix, "-container-vertical"), vertical));
|
|
87
76
|
var markClassName = useCallback(function(mark) {
|
|
88
|
-
var
|
|
89
|
-
var lowerBound =
|
|
90
|
-
var upperBound =
|
|
91
|
-
if (range) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
upperBound = right;
|
|
77
|
+
var classPrefix2 = "nut-range-mark";
|
|
78
|
+
var lowerBound = min;
|
|
79
|
+
var upperBound = max;
|
|
80
|
+
if (range && Array.isArray(current)) {
|
|
81
|
+
lowerBound = current[0];
|
|
82
|
+
upperBound = current[1];
|
|
95
83
|
} else {
|
|
96
|
-
upperBound =
|
|
84
|
+
upperBound = current;
|
|
97
85
|
}
|
|
98
86
|
var isActive = mark <= upperBound && mark >= lowerBound;
|
|
99
|
-
return ["".concat(
|
|
100
|
-
}, [range,
|
|
101
|
-
var _useState9 = useState(classes()), _useState10 = _slicedToArray(_useState9, 2), rangeName = _useState10[0], setRangeName = _useState10[1];
|
|
102
|
-
var _useState11 = useState(containerClasses()), _useState12 = _slicedToArray(_useState11, 2), containerName = _useState12[0], setContainerName = _useState12[1];
|
|
103
|
-
useEffect(function() {
|
|
104
|
-
setRangeName(classes());
|
|
105
|
-
setContainerName(containerClasses());
|
|
106
|
-
}, [classes, containerClasses]);
|
|
107
|
-
var wrapperStyle = function wrapperStyle2() {
|
|
108
|
-
return {
|
|
109
|
-
background: inactiveColor
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
var buttonStyle = function buttonStyle2() {
|
|
113
|
-
return {
|
|
114
|
-
borderColor: buttonColor
|
|
115
|
-
};
|
|
116
|
-
};
|
|
87
|
+
return ["".concat(classPrefix2, "-text"), "".concat(isActive ? "".concat(classPrefix2, "-text-active") : "")].join(" ");
|
|
88
|
+
}, [range, current, min, max]);
|
|
117
89
|
var isRange = function isRange2(val) {
|
|
118
90
|
return !!range && Array.isArray(val);
|
|
119
91
|
};
|
|
120
92
|
var calcMainAxis = function calcMainAxis2() {
|
|
121
|
-
var modelVal =
|
|
93
|
+
var modelVal = current;
|
|
122
94
|
if (isRange(modelVal)) {
|
|
123
95
|
return "".concat((modelVal[1] - modelVal[0]) * 100 / scope(), "%");
|
|
124
96
|
}
|
|
125
|
-
return "".concat((modelVal -
|
|
97
|
+
return "".concat((modelVal - min) * 100 / scope(), "%");
|
|
126
98
|
};
|
|
127
99
|
var calcOffset = function calcOffset2() {
|
|
128
|
-
var modelVal =
|
|
100
|
+
var modelVal = current;
|
|
129
101
|
if (isRange(modelVal)) {
|
|
130
|
-
return "".concat((modelVal[0] -
|
|
102
|
+
return "".concat((modelVal[0] - min) * 100 / scope(), "%");
|
|
131
103
|
}
|
|
132
104
|
return "0%";
|
|
133
105
|
};
|
|
@@ -136,74 +108,61 @@ var Range = function Range2(props) {
|
|
|
136
108
|
return {
|
|
137
109
|
height: calcMainAxis(),
|
|
138
110
|
top: calcOffset(),
|
|
139
|
-
background: activeColor,
|
|
140
111
|
transition: dragStatus ? "none" : void 0
|
|
141
112
|
};
|
|
142
113
|
}
|
|
143
114
|
return {
|
|
144
115
|
width: calcMainAxis(),
|
|
145
116
|
left: calcOffset(),
|
|
146
|
-
background: activeColor,
|
|
147
117
|
transition: dragStatus ? "none" : void 0
|
|
148
118
|
};
|
|
149
119
|
};
|
|
150
120
|
var marksStyle = function marksStyle2(mark) {
|
|
151
121
|
var style = {
|
|
152
|
-
left: "".concat((mark -
|
|
122
|
+
left: "".concat((mark - min) / scope() * 100, "%")
|
|
153
123
|
};
|
|
154
124
|
if (vertical) {
|
|
155
125
|
style = {
|
|
156
|
-
top: "".concat((mark -
|
|
126
|
+
top: "".concat((mark - min) / scope() * 100, "%")
|
|
157
127
|
};
|
|
158
128
|
}
|
|
159
129
|
return style;
|
|
160
130
|
};
|
|
161
|
-
var
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (range) {
|
|
165
|
-
var _modelValue2 = _slicedToArray(modelValue, 2), left = _modelValue2[0], right = _modelValue2[1];
|
|
166
|
-
lowerBound = left;
|
|
167
|
-
upperBound = right;
|
|
131
|
+
var tickClass = function tickClass2(mark) {
|
|
132
|
+
if (range && Array.isArray(current)) {
|
|
133
|
+
return mark <= current[1] && mark >= current[0];
|
|
168
134
|
}
|
|
169
|
-
|
|
170
|
-
var style = {
|
|
171
|
-
background: !isActive ? inactiveColor : activeColor
|
|
172
|
-
};
|
|
173
|
-
return style;
|
|
135
|
+
return mark <= current;
|
|
174
136
|
};
|
|
175
|
-
var format = function format2(
|
|
176
|
-
|
|
177
|
-
return Math.round(
|
|
137
|
+
var format = function format2(value2) {
|
|
138
|
+
value2 = Math.max(+min, Math.min(value2, +max));
|
|
139
|
+
return Math.round(value2 / +step) * +step;
|
|
178
140
|
};
|
|
179
141
|
var isSameValue = function isSameValue2(newValue, oldValue) {
|
|
180
142
|
return JSON.stringify(newValue) === JSON.stringify(oldValue);
|
|
181
143
|
};
|
|
182
|
-
var handleOverlap = function handleOverlap2(
|
|
183
|
-
if (
|
|
184
|
-
return
|
|
144
|
+
var handleOverlap = function handleOverlap2(value2) {
|
|
145
|
+
if (value2[0] > value2[1]) {
|
|
146
|
+
return value2.slice(0).reverse();
|
|
185
147
|
}
|
|
186
|
-
return
|
|
148
|
+
return value2;
|
|
187
149
|
};
|
|
188
|
-
var updateValue = function updateValue2(
|
|
189
|
-
if (isRange(
|
|
190
|
-
|
|
150
|
+
var updateValue = function updateValue2(value2, end) {
|
|
151
|
+
if (isRange(value2)) {
|
|
152
|
+
value2 = handleOverlap(value2).map(format);
|
|
191
153
|
} else {
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
var modelVal = initValue || initValue === 0 ? initValue : modelValue;
|
|
195
|
-
if (!isSameValue(value, modelVal)) {
|
|
196
|
-
SetInitValue(value);
|
|
154
|
+
value2 = format(value2);
|
|
197
155
|
}
|
|
198
|
-
if (
|
|
199
|
-
|
|
156
|
+
if (!isSameValue(value2, current)) {
|
|
157
|
+
setCurrent(value2);
|
|
200
158
|
}
|
|
159
|
+
end && onEnd && onEnd(value2);
|
|
201
160
|
};
|
|
202
161
|
var click = function click2(event) {
|
|
203
162
|
if (disabled || !root.current) {
|
|
204
163
|
return;
|
|
205
164
|
}
|
|
206
|
-
|
|
165
|
+
setDragStatus("");
|
|
207
166
|
var rect = getRect(root.current);
|
|
208
167
|
var delta = event.clientX - rect.left;
|
|
209
168
|
var total = rect.width;
|
|
@@ -211,18 +170,18 @@ var Range = function Range2(props) {
|
|
|
211
170
|
delta = event.clientY - rect.top;
|
|
212
171
|
total = rect.height;
|
|
213
172
|
}
|
|
214
|
-
var
|
|
215
|
-
|
|
216
|
-
if (isRange(
|
|
217
|
-
var
|
|
173
|
+
var value2 = min + delta / total * scope();
|
|
174
|
+
setEaxctValue(current);
|
|
175
|
+
if (isRange(current)) {
|
|
176
|
+
var _current = _slicedToArray(current, 2), left = _current[0], right = _current[1];
|
|
218
177
|
var middle = (left + right) / 2;
|
|
219
|
-
if (
|
|
220
|
-
updateValue([
|
|
178
|
+
if (value2 <= middle) {
|
|
179
|
+
updateValue([value2, right], true);
|
|
221
180
|
} else {
|
|
222
|
-
updateValue([left,
|
|
181
|
+
updateValue([left, value2], true);
|
|
223
182
|
}
|
|
224
183
|
} else {
|
|
225
|
-
updateValue(
|
|
184
|
+
updateValue(value2, true);
|
|
226
185
|
}
|
|
227
186
|
};
|
|
228
187
|
var _onTouchStart = function onTouchStart(event) {
|
|
@@ -230,24 +189,24 @@ var Range = function Range2(props) {
|
|
|
230
189
|
return;
|
|
231
190
|
}
|
|
232
191
|
touch.start(event);
|
|
233
|
-
|
|
234
|
-
if (isRange(
|
|
235
|
-
|
|
192
|
+
setEaxctValue(current);
|
|
193
|
+
if (isRange(current)) {
|
|
194
|
+
setStartValue(current.map(format));
|
|
236
195
|
} else {
|
|
237
|
-
|
|
196
|
+
setStartValue(format(current));
|
|
238
197
|
}
|
|
239
|
-
|
|
198
|
+
setDragStatus("start");
|
|
240
199
|
};
|
|
241
200
|
var _onTouchMove = function onTouchMove(event) {
|
|
201
|
+
event.stopPropagation();
|
|
242
202
|
if (disabled || !root.current) {
|
|
243
203
|
return;
|
|
244
204
|
}
|
|
245
205
|
if (dragStatus === "start") {
|
|
246
|
-
|
|
247
|
-
onDragStart && onDragStart();
|
|
206
|
+
onStart && onStart();
|
|
248
207
|
}
|
|
249
208
|
touch.move(event);
|
|
250
|
-
|
|
209
|
+
setDragStatus("draging");
|
|
251
210
|
var rect = getRect(root.current);
|
|
252
211
|
var delta = touch.deltaX;
|
|
253
212
|
var total = rect.width;
|
|
@@ -257,41 +216,48 @@ var Range = function Range2(props) {
|
|
|
257
216
|
total = rect.height;
|
|
258
217
|
diff = delta / total * scope();
|
|
259
218
|
}
|
|
219
|
+
var newValue;
|
|
260
220
|
if (isRange(startValue)) {
|
|
261
|
-
|
|
221
|
+
newValue = exactValue.slice();
|
|
222
|
+
newValue[buttonIndex] = startValue[buttonIndex] + diff;
|
|
262
223
|
} else {
|
|
263
|
-
|
|
224
|
+
newValue = startValue + diff;
|
|
264
225
|
}
|
|
265
|
-
|
|
226
|
+
setEaxctValue(newValue);
|
|
227
|
+
updateValue(newValue);
|
|
266
228
|
};
|
|
267
229
|
var _onTouchEnd = function onTouchEnd(event) {
|
|
268
230
|
if (disabled) {
|
|
269
231
|
return;
|
|
270
232
|
}
|
|
271
233
|
if (dragStatus === "draging") {
|
|
272
|
-
updateValue(
|
|
273
|
-
dragEnd && dragEnd();
|
|
274
|
-
onDragEnd && onDragEnd();
|
|
234
|
+
updateValue(current, true);
|
|
275
235
|
}
|
|
276
|
-
|
|
236
|
+
setDragStatus("");
|
|
277
237
|
};
|
|
278
238
|
var curValue = function curValue2(idx) {
|
|
279
|
-
var modelVal =
|
|
280
|
-
var
|
|
281
|
-
return
|
|
239
|
+
var modelVal = current;
|
|
240
|
+
var value2 = typeof idx === "number" ? modelVal[idx] : modelVal;
|
|
241
|
+
return value2;
|
|
242
|
+
};
|
|
243
|
+
var renderButton = function renderButton2(index) {
|
|
244
|
+
return React__default.createElement(React__default.Fragment, null, button || React__default.createElement("div", {
|
|
245
|
+
className: "nut-range-button"
|
|
246
|
+
}, currentDescription !== null && React__default.createElement("div", {
|
|
247
|
+
className: "number"
|
|
248
|
+
}, currentDescription ? currentDescription(curValue(index)) : curValue(index))));
|
|
282
249
|
};
|
|
283
250
|
return React__default.createElement("div", {
|
|
284
|
-
className:
|
|
285
|
-
},
|
|
251
|
+
className: containerClasses
|
|
252
|
+
}, minDescription !== null && React__default.createElement("div", {
|
|
286
253
|
className: "min"
|
|
287
|
-
},
|
|
254
|
+
}, minDescription || min), React__default.createElement("div", {
|
|
288
255
|
ref: root,
|
|
289
|
-
|
|
290
|
-
className: "".concat(rangeName),
|
|
256
|
+
className: classes,
|
|
291
257
|
onClick: function onClick(e) {
|
|
292
|
-
click(e);
|
|
258
|
+
return click(e);
|
|
293
259
|
}
|
|
294
|
-
}, marksList.length > 0
|
|
260
|
+
}, marksList.length > 0 && React__default.createElement("div", {
|
|
295
261
|
className: "nut-range-mark"
|
|
296
262
|
}, marksList.map(function(marks2) {
|
|
297
263
|
return React__default.createElement("span", {
|
|
@@ -299,77 +265,56 @@ var Range = function Range2(props) {
|
|
|
299
265
|
className: markClassName(marks2),
|
|
300
266
|
style: marksStyle(marks2)
|
|
301
267
|
}, marks2, React__default.createElement("span", {
|
|
302
|
-
className: "nut-range-tick",
|
|
303
|
-
|
|
268
|
+
className: classNames("nut-range-tick", {
|
|
269
|
+
active: tickClass(marks2)
|
|
270
|
+
})
|
|
304
271
|
}));
|
|
305
|
-
}))
|
|
272
|
+
})), React__default.createElement("div", {
|
|
306
273
|
className: "nut-range-bar",
|
|
307
274
|
style: barStyle()
|
|
308
275
|
}, range ? [0, 1].map(function(item, index) {
|
|
309
276
|
return React__default.createElement("div", {
|
|
310
|
-
role: "slider",
|
|
311
277
|
key: index,
|
|
312
278
|
className: "".concat(index === 0 ? "nut-range-button-wrapper-left" : "", "\n ").concat(index === 1 ? "nut-range-button-wrapper-right" : ""),
|
|
313
|
-
tabIndex: disabled ? -1 : 0,
|
|
314
|
-
"aria-valuemin": +min,
|
|
315
|
-
"aria-valuenow": curValue(index),
|
|
316
|
-
"aria-valuemax": +max,
|
|
317
|
-
"aria-orientation": vertical ? "vertical" : "horizontal",
|
|
318
279
|
onTouchStart: function onTouchStart(e) {
|
|
319
280
|
if (typeof index === "number") {
|
|
320
|
-
|
|
281
|
+
setButtonIndex(index);
|
|
321
282
|
}
|
|
322
283
|
_onTouchStart(e);
|
|
323
284
|
},
|
|
324
285
|
onTouchMove: function onTouchMove(e) {
|
|
325
|
-
_onTouchMove(e);
|
|
286
|
+
return _onTouchMove(e);
|
|
326
287
|
},
|
|
327
288
|
onTouchEnd: function onTouchEnd(e) {
|
|
328
|
-
_onTouchEnd();
|
|
289
|
+
return _onTouchEnd();
|
|
329
290
|
},
|
|
330
291
|
onTouchCancel: function onTouchCancel(e) {
|
|
331
|
-
_onTouchEnd();
|
|
292
|
+
return _onTouchEnd();
|
|
332
293
|
},
|
|
333
294
|
onClick: function onClick(e) {
|
|
334
|
-
e.stopPropagation();
|
|
295
|
+
return e.stopPropagation();
|
|
335
296
|
}
|
|
336
|
-
},
|
|
337
|
-
className: "nut-range-button",
|
|
338
|
-
style: buttonStyle()
|
|
339
|
-
}, !hiddenTag ? React__default.createElement("div", {
|
|
340
|
-
className: "number"
|
|
341
|
-
}, curValueDesc || curValue(index)) : null));
|
|
297
|
+
}, renderButton(index));
|
|
342
298
|
}) : React__default.createElement("div", {
|
|
343
|
-
role: "slider",
|
|
344
299
|
className: "nut-range-button-wrapper",
|
|
345
|
-
tabIndex: disabled ? -1 : 0,
|
|
346
|
-
"aria-valuemin": +min,
|
|
347
|
-
"aria-valuenow": curValue(),
|
|
348
|
-
"aria-valuemax": +max,
|
|
349
|
-
"aria-orientation": vertical ? "vertical" : "horizontal",
|
|
350
300
|
onTouchStart: function onTouchStart(e) {
|
|
351
|
-
_onTouchStart(e);
|
|
301
|
+
return _onTouchStart(e);
|
|
352
302
|
},
|
|
353
303
|
onTouchMove: function onTouchMove(e) {
|
|
354
|
-
_onTouchMove(e);
|
|
304
|
+
return _onTouchMove(e);
|
|
355
305
|
},
|
|
356
306
|
onTouchEnd: function onTouchEnd(e) {
|
|
357
|
-
_onTouchEnd();
|
|
307
|
+
return _onTouchEnd();
|
|
358
308
|
},
|
|
359
309
|
onTouchCancel: function onTouchCancel(e) {
|
|
360
|
-
_onTouchEnd();
|
|
310
|
+
return _onTouchEnd();
|
|
361
311
|
},
|
|
362
312
|
onClick: function onClick(e) {
|
|
363
|
-
e.stopPropagation();
|
|
313
|
+
return e.stopPropagation();
|
|
364
314
|
}
|
|
365
|
-
},
|
|
366
|
-
className: "nut-range-button",
|
|
367
|
-
style: buttonStyle()
|
|
368
|
-
}, !hiddenTag ? React__default.createElement("div", {
|
|
369
|
-
className: "number"
|
|
370
|
-
}, curValueDesc || curValue()) : null)))), !hiddenRange ? React__default.createElement("div", {
|
|
315
|
+
}, renderButton()))), maxDescription !== null && React__default.createElement("div", {
|
|
371
316
|
className: "max"
|
|
372
|
-
},
|
|
317
|
+
}, maxDescription || max));
|
|
373
318
|
};
|
|
374
319
|
Range.defaultProps = defaultProps;
|
|
375
320
|
Range.displayName = "NutRange";
|