@nutui/nutui-react-taro 1.4.4 → 1.4.5
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 +15 -0
- package/dist/esm/Address.js +5 -5
- package/dist/esm/Audio.js +5 -5
- package/dist/esm/AvatarContext-7153ad2b.js +3 -1
- package/dist/esm/AvatarGroup.js +4 -4
- package/dist/esm/Calendar.js +5 -5
- package/dist/esm/CalendarItem.js +4 -4
- package/dist/esm/Card.js +4 -3
- package/dist/esm/Cell.js +2 -2
- package/dist/esm/ConfigProvider.js +3 -3
- package/dist/esm/CountDown.js +4 -4
- package/dist/esm/DatePicker.js +5 -5
- package/dist/esm/Dialog.js +4 -4
- package/dist/esm/Ellipsis.js +4 -4
- package/dist/esm/Empty.js +4 -4
- package/dist/esm/FixedNav.js +4 -4
- package/dist/esm/Form.js +4 -4
- package/dist/esm/FormItem.js +3 -3
- package/dist/esm/Grid.js +4 -4
- package/dist/esm/GridItem.js +4 -4
- package/dist/esm/Image.js +4 -4
- package/dist/esm/Infiniteloading.js +4 -4
- package/dist/esm/Input.js +4 -4
- package/dist/esm/MenuItem.js +4 -4
- package/dist/esm/NoticeBar.js +2 -2
- package/dist/esm/NumberKeyboard.js +4 -4
- package/dist/esm/Pagination.js +4 -4
- package/dist/esm/Picker.js +4 -4
- package/dist/esm/PullToRefresh.js +4 -4
- package/dist/esm/Range.js +4 -4
- package/dist/esm/SearchBar.js +4 -4
- package/dist/esm/ShortPassword.js +4 -4
- package/dist/esm/SideNavBar.js +4 -4
- package/dist/esm/Signature.js +4 -4
- package/dist/esm/Sticky.js +4 -4
- package/dist/esm/Table.js +4 -4
- package/dist/esm/Tag.js +3 -2
- package/dist/esm/TextArea.js +4 -4
- package/dist/esm/TimeDetail.js +4 -4
- package/dist/esm/TimePannel.js +4 -4
- package/dist/esm/TimeSelect.js +6 -6
- package/dist/esm/Uploader.js +4 -4
- package/dist/esm/UserContext-68f62e66.js +3 -1
- package/dist/esm/UserContext-b4181162.js +3 -1
- package/dist/esm/UserContext-be8097d2.js +3 -1
- package/dist/esm/VirtualList.js +6 -4
- package/dist/esm/WaterMark.js +4 -4
- package/dist/esm/actionsheet.taro-a58d3d12.js +45 -83
- package/dist/esm/address.taro-79cc7c96.js +461 -0
- package/dist/esm/animate.taro-b0e83dd5.js +32 -46
- package/dist/esm/animatingnumbers.taro-6f40a2e9.js +93 -134
- package/dist/esm/audio.taro-4fadc583.js +161 -0
- package/dist/esm/avatar.taro-85ced995.js +93 -119
- package/dist/esm/avatargroup-1d900174.js +34 -0
- package/dist/esm/backtop.taro-99107c30.js +39 -62
- package/dist/esm/badge.taro-fe9171ec.js +40 -58
- package/dist/esm/barrage.taro-0e157b5e.js +61 -91
- package/dist/esm/bem-893ad28d.js +3 -6
- package/dist/esm/button.taro-4ce133b9.js +87 -98
- package/dist/esm/calendar.taro-4ed72058.js +38 -0
- package/dist/esm/calendaritem.taro-1ebe428d.js +571 -0
- package/dist/esm/card.taro-39055e82.js +32 -0
- package/dist/esm/cascader.taro-d8cb1c3e.js +397 -636
- package/dist/esm/cell.taro-9a04a92e.js +64 -0
- package/dist/esm/cellgroup.taro-e094471c.js +18 -27
- package/dist/esm/checkbox.taro-0bda9796.js +160 -232
- package/dist/esm/circleprogress.taro-47db537c.js +99 -120
- package/dist/esm/col.taro-b61c7cba.js +33 -50
- package/dist/esm/collapse.taro-af58206c.js +73 -86
- package/dist/esm/collapseitem-ce1849d2.js +75 -139
- package/dist/esm/configprovider-5eea4f5d.js +19 -0
- package/dist/esm/configprovider.taro-26882dd2.js +42 -0
- package/dist/esm/countdown.taro-9e40de9c.js +225 -0
- package/dist/esm/datepicker.taro-7220e495.js +270 -0
- package/dist/esm/dialog.taro-1c03960e.js +123 -0
- package/dist/esm/divider.taro-5236fe6a.js +27 -27
- package/dist/esm/drag.taro-82b6b27a.js +99 -138
- package/dist/esm/elevator.taro-d7d65470.js +185 -259
- package/dist/esm/ellipsis.taro-49b6db0c.js +232 -0
- package/dist/esm/empty.taro-7bd813f9.js +62 -0
- package/dist/esm/fixednav.taro-5ad15202.js +53 -0
- package/dist/esm/form.taro-71d32671.js +179 -0
- package/dist/esm/formitem.taro-3089489b.js +89 -0
- package/dist/esm/grid.taro-e6decfce.js +58 -0
- package/dist/esm/grid.taro.context-39636af9.js +4 -2
- package/dist/esm/griditem.taro-4cade72e.js +90 -0
- package/dist/esm/icon-8dc4de10.js +43 -51
- package/dist/esm/icon.taro-1d0d4fb7.js +43 -51
- package/dist/esm/image.taro-e6dc5867.js +64 -0
- package/dist/esm/imagepreview.taro-3400ea03.js +158 -205
- package/dist/esm/index.taro-a36f96fb.js +149 -210
- package/dist/esm/indicator.taro-183ea169.js +29 -43
- package/dist/esm/infiniteloading.taro-6c2a2e95.js +142 -0
- package/dist/esm/input.taro-fd566407.js +243 -0
- package/dist/esm/inputnumber.taro-dc39b853.js +129 -177
- package/dist/esm/layout.taro-358f014f.js +6 -9
- package/dist/esm/menu.taro-4abed328.js +89 -132
- package/dist/esm/menuitem.taro-6e8b27c3.js +130 -0
- package/dist/esm/navbar.taro-c931c078.js +69 -105
- package/dist/esm/noticebar.taro-69ea7673.js +450 -0
- package/dist/esm/notify.taro-308e5892.js +66 -97
- package/dist/esm/numberkeyboard.taro-194519e4.js +158 -0
- package/dist/esm/nutui-react.es.js +44 -44
- package/dist/esm/offsetContext-bfb02c25.js +3 -1
- package/dist/esm/overlay.taro-98367bc1.js +59 -74
- package/dist/esm/pagination.taro-bb490de9.js +124 -0
- package/dist/esm/picker.taro-2a8ded7c.js +420 -0
- package/dist/esm/popover.taro-46d813e8.js +132 -222
- package/dist/esm/popup.taro-cb777e09.js +125 -178
- package/dist/esm/price.taro-8801462e.js +75 -86
- package/dist/esm/progress.taro-623bc807.js +84 -118
- package/dist/esm/pulltorefresh.taro-cab7b51c.js +221 -0
- package/dist/esm/range.taro-5d6ff217.js +332 -0
- package/dist/esm/rate.taro-10197384.js +64 -111
- package/dist/esm/row.taro-37a895de.js +38 -42
- package/dist/esm/searchbar.taro-839dd622.js +148 -0
- package/dist/esm/shortpassword.taro-182d46f7.js +111 -0
- package/dist/esm/sidenavbar.taro-006cf38b.js +35 -0
- package/dist/esm/sidenavbaritem.taro-fee11d26.js +9 -22
- package/dist/esm/signature.taro-33632585.js +143 -0
- package/dist/esm/skeleton.taro-853ce460.js +51 -88
- package/dist/esm/step.taro-1c94e067.js +49 -78
- package/dist/esm/steps.taro-acf205a0.js +21 -30
- package/dist/esm/sticky.taro-d0553f48.js +13 -0
- package/dist/esm/subsidenavbar.taro-f46b4c73.js +58 -75
- package/dist/esm/swipe.taro-83bc248f.js +164 -254
- package/dist/esm/swiper.taro-852f6615.js +424 -505
- package/dist/esm/swiperitem-86a3578a.js +20 -28
- package/dist/esm/switch.taro-bae2dca0.js +43 -64
- package/dist/esm/tabbar.taro-86cece39.js +47 -57
- package/dist/esm/tabbaritem.taro-8dfb8055.js +51 -79
- package/dist/esm/table.taro-cb4dd2c3.js +92 -0
- package/dist/esm/tabpane.taro-91cd6cf4.js +17 -22
- package/dist/esm/tabs.taro-e71875fa.js +121 -165
- package/dist/esm/tag.taro-00fe554d.js +89 -0
- package/dist/esm/textarea.taro-42600f8c.js +74 -0
- package/dist/esm/timedetail.taro-c5f564fd.js +44 -0
- package/dist/esm/timepannel.taro-29f9dd86.js +22 -0
- package/dist/esm/timeselect.taro-3ecce65d.js +133 -0
- package/dist/esm/toast.taro-0804b6b4.js +99 -137
- package/dist/esm/trendarrow.taro-5a7153e4.js +63 -90
- package/dist/esm/types/src/packages/cell/cell.taro.d.ts +0 -1
- package/dist/esm/types/src/packages/noticebar/noticebar.d.ts +5 -4
- package/dist/esm/types/src/packages/noticebar/noticebar.taro.d.ts +5 -4
- package/dist/esm/types/src/packages/uploader/uploader.d.ts +1 -1
- package/dist/esm/types/src/packages/virtuallist/virtuallist.taro.d.ts +13 -2
- package/dist/esm/typings-1c5f2628.js +7 -6
- package/dist/esm/uploader.taro-f80d76d9.js +392 -0
- package/dist/esm/useClientRect-bf69d7b3.js +5 -25
- package/dist/esm/useTouch-a2ea68c6.js +63 -93
- package/dist/esm/video-8a3518c5.js +59 -83
- package/dist/esm/virtuallist.taro-e3345ced.js +215 -0
- package/dist/esm/watermark.taro-cd9db98a.js +114 -0
- package/dist/esm/zh-CN-dfc384d0.js +128 -133
- 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.es.js +634 -5664
- package/dist/nutui.react.umd.js +634 -5664
- package/dist/packages/noticebar/noticebar.scss +17 -0
- package/dist/packages/radio/radio.scss +3 -1
- package/dist/packages/row/row.scss +2 -0
- package/dist/packages/searchbar/searchbar.scss +1 -1
- package/dist/packages/tag/tag.scss +13 -5
- package/dist/packages/virtuallist/virtuallist.scss +24 -0
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/temp.scss +2340 -0
- package/dist/styles/theme-dark.scss +7 -0
- package/dist/styles/theme-default.scss +11 -0
- package/dist/styles/variables.scss +1945 -710
- package/dist/types/index.d.ts +16 -23
- package/package.json +9 -4
- package/dist/esm/address.taro-1e2aea24.js +0 -615
- package/dist/esm/audio.taro-fddcdfc0.js +0 -228
- package/dist/esm/avatargroup-f7f600ff.js +0 -42
- package/dist/esm/calendar.taro-72974415.js +0 -83
- package/dist/esm/calendaritem.taro-84e889eb.js +0 -580
- package/dist/esm/card.taro-a530dfb3.js +0 -61
- package/dist/esm/cell.taro-cf50c4f2.js +0 -109
- package/dist/esm/configprovider-c7d60e20.js +0 -18
- package/dist/esm/configprovider.taro-8bdb3a28.js +0 -50
- package/dist/esm/countdown.taro-d7dc8681.js +0 -246
- package/dist/esm/datepicker.taro-7199f521.js +0 -304
- package/dist/esm/dialog.taro-f54cfbf0.js +0 -187
- package/dist/esm/ellipsis.taro-c0de6ff4.js +0 -309
- package/dist/esm/empty.taro-dbc66496.js +0 -81
- package/dist/esm/fixednav.taro-9e759320.js +0 -97
- package/dist/esm/form.taro-880014b1.js +0 -181
- package/dist/esm/formitem.taro-3695f4a7.js +0 -136
- package/dist/esm/grid.taro-c2cc12d6.js +0 -81
- package/dist/esm/griditem.taro-892153cd.js +0 -122
- package/dist/esm/image.taro-c30973d5.js +0 -105
- package/dist/esm/infiniteloading.taro-b5ddf3cc.js +0 -188
- package/dist/esm/input.taro-104130c1.js +0 -361
- package/dist/esm/menuitem.taro-216e9f7d.js +0 -193
- package/dist/esm/noticebar.taro-94002898.js +0 -368
- package/dist/esm/numberkeyboard.taro-5e8f0ddf.js +0 -245
- package/dist/esm/pagination.taro-9925ffab.js +0 -169
- package/dist/esm/picker.taro-3b5cc054.js +0 -540
- package/dist/esm/pulltorefresh.taro-f26a20dd.js +0 -302
- package/dist/esm/range.taro-c41e9b90.js +0 -469
- package/dist/esm/searchbar.taro-01ed4ea4.js +0 -236
- package/dist/esm/shortpassword.taro-3a3bf412.js +0 -190
- package/dist/esm/sidenavbar.taro-06026f31.js +0 -66
- package/dist/esm/signature.taro-17648cac.js +0 -192
- package/dist/esm/sticky.taro-36013e97.js +0 -16
- package/dist/esm/table.taro-adda6622.js +0 -139
- package/dist/esm/tag.taro-bd900990.js +0 -104
- package/dist/esm/textarea.taro-83d5fe73.js +0 -102
- package/dist/esm/timedetail.taro-105f5380.js +0 -68
- package/dist/esm/timepannel.taro-c66c63dd.js +0 -30
- package/dist/esm/timeselect.taro-fc7ec6ee.js +0 -172
- package/dist/esm/uploader.taro-a1edf38f.js +0 -529
- package/dist/esm/virtuallist.taro-4add61c3.js +0 -315
- package/dist/esm/watermark.taro-323d1cf3.js +0 -132
|
@@ -1,469 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
-
import React__default, { useState, useRef, useEffect, useCallback } from 'react';
|
|
8
|
-
import { u as useTouch } from './useTouch-a2ea68c6.js';
|
|
9
|
-
import { g as getRectByTaro } from './useClientRect-bf69d7b3.js';
|
|
10
|
-
import { T as Toast } from './toast.taro-0804b6b4.js';
|
|
11
|
-
import { u as useConfig } from './configprovider.taro-8bdb3a28.js';
|
|
12
|
-
var defaultProps = {
|
|
13
|
-
range: false,
|
|
14
|
-
hiddenRange: false,
|
|
15
|
-
hiddenTag: false,
|
|
16
|
-
min: 0,
|
|
17
|
-
max: 100,
|
|
18
|
-
step: 1,
|
|
19
|
-
modelValue: 0,
|
|
20
|
-
vertical: false,
|
|
21
|
-
marks: {}
|
|
22
|
-
};
|
|
23
|
-
var startValue;
|
|
24
|
-
var currentValue;
|
|
25
|
-
var Range = function Range(props) {
|
|
26
|
-
var _useConfig = useConfig(),
|
|
27
|
-
locale = _useConfig.locale;
|
|
28
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
29
|
-
className = _defaultProps$props.className,
|
|
30
|
-
range = _defaultProps$props.range,
|
|
31
|
-
disabled = _defaultProps$props.disabled,
|
|
32
|
-
activeColor = _defaultProps$props.activeColor,
|
|
33
|
-
inactiveColor = _defaultProps$props.inactiveColor,
|
|
34
|
-
buttonColor = _defaultProps$props.buttonColor,
|
|
35
|
-
hiddenRange = _defaultProps$props.hiddenRange,
|
|
36
|
-
hiddenTag = _defaultProps$props.hiddenTag,
|
|
37
|
-
modelValue = _defaultProps$props.modelValue,
|
|
38
|
-
button = _defaultProps$props.button,
|
|
39
|
-
vertical = _defaultProps$props.vertical,
|
|
40
|
-
marks = _defaultProps$props.marks,
|
|
41
|
-
dragStart = _defaultProps$props.dragStart,
|
|
42
|
-
dragEnd = _defaultProps$props.dragEnd,
|
|
43
|
-
onChange = _defaultProps$props.onChange,
|
|
44
|
-
onDragStart = _defaultProps$props.onDragStart,
|
|
45
|
-
onDragEnd = _defaultProps$props.onDragEnd,
|
|
46
|
-
minDesc = _defaultProps$props.minDesc,
|
|
47
|
-
maxDesc = _defaultProps$props.maxDesc,
|
|
48
|
-
curValueDesc = _defaultProps$props.curValueDesc;
|
|
49
|
-
var _defaultProps$props2 = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
50
|
-
min = _defaultProps$props2.min,
|
|
51
|
-
max = _defaultProps$props2.max,
|
|
52
|
-
step = _defaultProps$props2.step;
|
|
53
|
-
min = Number(min);
|
|
54
|
-
max = Number(max);
|
|
55
|
-
step = Number(step);
|
|
56
|
-
var _useState = useState(0),
|
|
57
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
58
|
-
buttonIndex = _useState2[0],
|
|
59
|
-
SetButtonIndex = _useState2[1];
|
|
60
|
-
var _useState3 = useState(),
|
|
61
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
62
|
-
initValue = _useState4[0],
|
|
63
|
-
SetInitValue = _useState4[1];
|
|
64
|
-
var _useState5 = useState('start'),
|
|
65
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
66
|
-
dragStatus = _useState6[0],
|
|
67
|
-
SetDragStatus = _useState6[1];
|
|
68
|
-
var touch = useTouch();
|
|
69
|
-
var root = useRef(null);
|
|
70
|
-
var _useState7 = useState([]),
|
|
71
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
72
|
-
marksList = _useState8[0],
|
|
73
|
-
SetMarksList = _useState8[1];
|
|
74
|
-
var _useState9 = useState(false),
|
|
75
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
76
|
-
show = _useState10[0],
|
|
77
|
-
SetShow = _useState10[1];
|
|
78
|
-
var _useState11 = useState(''),
|
|
79
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
80
|
-
toastMsg = _useState12[0],
|
|
81
|
-
SetToastMsg = _useState12[1];
|
|
82
|
-
var toastShow = function toastShow(msg) {
|
|
83
|
-
SetToastMsg(msg);
|
|
84
|
-
SetShow(true);
|
|
85
|
-
};
|
|
86
|
-
useEffect(function () {
|
|
87
|
-
if (typeof modelValue === 'number') {
|
|
88
|
-
if (!range && (modelValue < min || modelValue > max)) {
|
|
89
|
-
SetInitValue(0);
|
|
90
|
-
toastShow("".concat(modelValue, " ").concat(locale.range.rangeText));
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
SetInitValue(modelValue);
|
|
94
|
-
}
|
|
95
|
-
}, [modelValue]);
|
|
96
|
-
useEffect(function () {
|
|
97
|
-
if (marks) {
|
|
98
|
-
var marksKeys = Object.keys(marks);
|
|
99
|
-
var list = marksKeys.map(parseFloat).sort(function (a, b) {
|
|
100
|
-
return a - b;
|
|
101
|
-
}).filter(function (point) {
|
|
102
|
-
return point >= min && point <= max;
|
|
103
|
-
});
|
|
104
|
-
SetMarksList(list);
|
|
105
|
-
}
|
|
106
|
-
}, [marks]);
|
|
107
|
-
var scope = function scope() {
|
|
108
|
-
return Number(max) - Number(min);
|
|
109
|
-
};
|
|
110
|
-
var classes = useCallback(function () {
|
|
111
|
-
var prefixCls = 'nut-range';
|
|
112
|
-
return [prefixCls, "".concat(disabled ? "".concat(prefixCls, "-disabled") : ''), "".concat(vertical ? "".concat(prefixCls, "-vertical") : ''), "".concat(!hiddenRange ? "".concat(prefixCls, "-show-number") : '')].filter(Boolean).join(' ');
|
|
113
|
-
}, [disabled, vertical, hiddenRange]);
|
|
114
|
-
var containerClasses = useCallback(function () {
|
|
115
|
-
var prefixCls = 'nut-range-container';
|
|
116
|
-
return [prefixCls, "".concat(vertical ? "".concat(prefixCls, "-vertical") : ''), className].filter(Boolean).join(' ');
|
|
117
|
-
}, [vertical, className]);
|
|
118
|
-
var markClassName = useCallback(function (mark) {
|
|
119
|
-
var classPrefix = 'nut-range-mark';
|
|
120
|
-
var lowerBound = Number(min);
|
|
121
|
-
var upperBound = Number(max);
|
|
122
|
-
if (range) {
|
|
123
|
-
var _modelValue = _slicedToArray(modelValue, 2),
|
|
124
|
-
left = _modelValue[0],
|
|
125
|
-
right = _modelValue[1];
|
|
126
|
-
lowerBound = left;
|
|
127
|
-
upperBound = right;
|
|
128
|
-
} else {
|
|
129
|
-
upperBound = modelValue;
|
|
130
|
-
}
|
|
131
|
-
var isActive = mark <= upperBound && mark >= lowerBound;
|
|
132
|
-
return ["".concat(classPrefix, "-text"), "".concat(isActive ? "".concat(classPrefix, "-text-active") : '')].filter(Boolean).join(' ');
|
|
133
|
-
}, [range, modelValue, min, max]);
|
|
134
|
-
var _useState13 = useState(classes()),
|
|
135
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
136
|
-
rangeName = _useState14[0],
|
|
137
|
-
setRangeName = _useState14[1];
|
|
138
|
-
var _useState15 = useState(containerClasses()),
|
|
139
|
-
_useState16 = _slicedToArray(_useState15, 2),
|
|
140
|
-
containerName = _useState16[0],
|
|
141
|
-
setContainerName = _useState16[1];
|
|
142
|
-
useEffect(function () {
|
|
143
|
-
setRangeName(classes());
|
|
144
|
-
setContainerName(containerClasses());
|
|
145
|
-
}, [classes, containerClasses]);
|
|
146
|
-
var wrapperStyle = function wrapperStyle() {
|
|
147
|
-
return {
|
|
148
|
-
background: inactiveColor
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
var buttonStyle = function buttonStyle() {
|
|
152
|
-
return {
|
|
153
|
-
borderColor: buttonColor
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
var isRange = function isRange(val) {
|
|
157
|
-
return !!range && Array.isArray(val);
|
|
158
|
-
};
|
|
159
|
-
var calcMainAxis = function calcMainAxis() {
|
|
160
|
-
var modelVal = initValue || initValue === 0 ? initValue : modelValue;
|
|
161
|
-
if (isRange(modelVal)) {
|
|
162
|
-
return "".concat((modelVal[1] - modelVal[0]) * 100 / scope(), "%");
|
|
163
|
-
}
|
|
164
|
-
return "".concat((modelVal - Number(min)) * 100 / scope(), "%");
|
|
165
|
-
};
|
|
166
|
-
var calcOffset = function calcOffset() {
|
|
167
|
-
var modelVal = initValue || initValue === 0 ? initValue : modelValue;
|
|
168
|
-
if (isRange(modelVal)) {
|
|
169
|
-
return "".concat((modelVal[0] - Number(min)) * 100 / scope(), "%");
|
|
170
|
-
}
|
|
171
|
-
return "0%";
|
|
172
|
-
};
|
|
173
|
-
var barStyle = function barStyle() {
|
|
174
|
-
if (vertical) {
|
|
175
|
-
return {
|
|
176
|
-
height: calcMainAxis(),
|
|
177
|
-
top: calcOffset(),
|
|
178
|
-
background: activeColor,
|
|
179
|
-
transition: dragStatus ? 'none' : undefined
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
width: calcMainAxis(),
|
|
184
|
-
left: calcOffset(),
|
|
185
|
-
background: activeColor,
|
|
186
|
-
transition: dragStatus ? 'none' : undefined
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
var marksStyle = function marksStyle(mark) {
|
|
190
|
-
var style = {
|
|
191
|
-
left: "".concat((mark - Number(min)) / scope() * 100, "%")
|
|
192
|
-
};
|
|
193
|
-
if (vertical) {
|
|
194
|
-
style = {
|
|
195
|
-
top: "".concat((mark - Number(min)) / scope() * 100, "%")
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
return style;
|
|
199
|
-
};
|
|
200
|
-
var tickStyle = function tickStyle(mark) {
|
|
201
|
-
var lowerBound = Number(min);
|
|
202
|
-
var upperBound = Number(max);
|
|
203
|
-
if (range) {
|
|
204
|
-
var _modelValue2 = _slicedToArray(modelValue, 2),
|
|
205
|
-
left = _modelValue2[0],
|
|
206
|
-
right = _modelValue2[1];
|
|
207
|
-
lowerBound = left;
|
|
208
|
-
upperBound = right;
|
|
209
|
-
}
|
|
210
|
-
var isActive = mark <= upperBound && mark >= lowerBound;
|
|
211
|
-
var style = {
|
|
212
|
-
background: !isActive ? inactiveColor : activeColor
|
|
213
|
-
};
|
|
214
|
-
return style;
|
|
215
|
-
};
|
|
216
|
-
var format = function format(value) {
|
|
217
|
-
value = Math.max(+min, Math.min(value, +max));
|
|
218
|
-
return Math.round(value / +step) * +step;
|
|
219
|
-
};
|
|
220
|
-
var isSameValue = function isSameValue(newValue, oldValue) {
|
|
221
|
-
return JSON.stringify(newValue) === JSON.stringify(oldValue);
|
|
222
|
-
};
|
|
223
|
-
var handleOverlap = function handleOverlap(value) {
|
|
224
|
-
if (value[0] > value[1]) {
|
|
225
|
-
return value.slice(0).reverse();
|
|
226
|
-
}
|
|
227
|
-
return value;
|
|
228
|
-
};
|
|
229
|
-
var updateValue = function updateValue(value, end) {
|
|
230
|
-
if (isRange(value)) {
|
|
231
|
-
value = handleOverlap(value).map(format);
|
|
232
|
-
} else {
|
|
233
|
-
value = format(value);
|
|
234
|
-
}
|
|
235
|
-
var modelVal = initValue || initValue === 0 ? initValue : modelValue;
|
|
236
|
-
if (!isSameValue(value, modelVal)) {
|
|
237
|
-
SetInitValue(value);
|
|
238
|
-
}
|
|
239
|
-
if ((marks || end) && !isSameValue(value, startValue)) {
|
|
240
|
-
onChange && onChange(value);
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
var click = /*#__PURE__*/function () {
|
|
244
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
|
|
245
|
-
var rect, delta, total, value, _currentValue, _currentValue2, left, right, middle;
|
|
246
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
247
|
-
while (1) {
|
|
248
|
-
switch (_context.prev = _context.next) {
|
|
249
|
-
case 0:
|
|
250
|
-
if (!(disabled || !root.current)) {
|
|
251
|
-
_context.next = 2;
|
|
252
|
-
break;
|
|
253
|
-
}
|
|
254
|
-
return _context.abrupt("return");
|
|
255
|
-
case 2:
|
|
256
|
-
SetDragStatus('');
|
|
257
|
-
_context.next = 5;
|
|
258
|
-
return getRectByTaro(root.current);
|
|
259
|
-
case 5:
|
|
260
|
-
rect = _context.sent;
|
|
261
|
-
delta = (event.detail.x ? event.detail.x : event.clientX) - rect.left;
|
|
262
|
-
total = rect.width;
|
|
263
|
-
if (vertical) {
|
|
264
|
-
delta = (event.detail.y ? event.detail.y : event.clientY) - rect.top;
|
|
265
|
-
total = rect.height;
|
|
266
|
-
}
|
|
267
|
-
value = Number(min) + delta / total * scope();
|
|
268
|
-
currentValue = initValue || initValue === 0 ? initValue : modelValue;
|
|
269
|
-
if (isRange(currentValue)) {
|
|
270
|
-
_currentValue = currentValue, _currentValue2 = _slicedToArray(_currentValue, 2), left = _currentValue2[0], right = _currentValue2[1];
|
|
271
|
-
middle = (left + right) / 2;
|
|
272
|
-
if (value <= middle) {
|
|
273
|
-
updateValue([value, right], true);
|
|
274
|
-
} else {
|
|
275
|
-
updateValue([left, value], true);
|
|
276
|
-
}
|
|
277
|
-
} else {
|
|
278
|
-
updateValue(value, true);
|
|
279
|
-
}
|
|
280
|
-
case 12:
|
|
281
|
-
case "end":
|
|
282
|
-
return _context.stop();
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}, _callee);
|
|
286
|
-
}));
|
|
287
|
-
return function click(_x) {
|
|
288
|
-
return _ref.apply(this, arguments);
|
|
289
|
-
};
|
|
290
|
-
}();
|
|
291
|
-
var _onTouchStart = function onTouchStart(event) {
|
|
292
|
-
if (disabled) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
touch.start(event);
|
|
296
|
-
currentValue = initValue || initValue === 0 ? initValue : modelValue;
|
|
297
|
-
if (isRange(currentValue)) {
|
|
298
|
-
startValue = currentValue.map(format);
|
|
299
|
-
} else {
|
|
300
|
-
startValue = format(currentValue);
|
|
301
|
-
}
|
|
302
|
-
SetDragStatus('start');
|
|
303
|
-
};
|
|
304
|
-
var _onTouchMove = /*#__PURE__*/function () {
|
|
305
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(event) {
|
|
306
|
-
var rect, delta, total, diff;
|
|
307
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
308
|
-
while (1) {
|
|
309
|
-
switch (_context2.prev = _context2.next) {
|
|
310
|
-
case 0:
|
|
311
|
-
if (!(disabled || !root.current)) {
|
|
312
|
-
_context2.next = 2;
|
|
313
|
-
break;
|
|
314
|
-
}
|
|
315
|
-
return _context2.abrupt("return");
|
|
316
|
-
case 2:
|
|
317
|
-
if (dragStatus === 'start') {
|
|
318
|
-
dragStart && dragStart();
|
|
319
|
-
onDragStart && onDragStart();
|
|
320
|
-
}
|
|
321
|
-
touch.move(event);
|
|
322
|
-
SetDragStatus('draging');
|
|
323
|
-
_context2.next = 7;
|
|
324
|
-
return getRectByTaro(root.current);
|
|
325
|
-
case 7:
|
|
326
|
-
rect = _context2.sent;
|
|
327
|
-
delta = touch.deltaX;
|
|
328
|
-
total = rect.width;
|
|
329
|
-
diff = delta / total * scope();
|
|
330
|
-
if (vertical) {
|
|
331
|
-
delta = touch.deltaY;
|
|
332
|
-
total = rect.height;
|
|
333
|
-
diff = delta / total * scope();
|
|
334
|
-
}
|
|
335
|
-
if (isRange(startValue)) {
|
|
336
|
-
currentValue[buttonIndex] = startValue[buttonIndex] + diff;
|
|
337
|
-
} else {
|
|
338
|
-
currentValue = startValue + diff;
|
|
339
|
-
}
|
|
340
|
-
updateValue(currentValue);
|
|
341
|
-
case 14:
|
|
342
|
-
case "end":
|
|
343
|
-
return _context2.stop();
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}, _callee2);
|
|
347
|
-
}));
|
|
348
|
-
return function onTouchMove(_x2) {
|
|
349
|
-
return _ref2.apply(this, arguments);
|
|
350
|
-
};
|
|
351
|
-
}();
|
|
352
|
-
var _onTouchEnd = function onTouchEnd(event) {
|
|
353
|
-
if (disabled) {
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
if (dragStatus === 'draging') {
|
|
357
|
-
updateValue(currentValue, true);
|
|
358
|
-
dragEnd && dragEnd();
|
|
359
|
-
onDragEnd && onDragEnd();
|
|
360
|
-
}
|
|
361
|
-
SetDragStatus('');
|
|
362
|
-
};
|
|
363
|
-
var curValue = function curValue(idx) {
|
|
364
|
-
var modelVal = initValue || initValue === 0 ? initValue : modelValue;
|
|
365
|
-
var value = typeof idx === 'number' ? modelVal[idx] : modelVal;
|
|
366
|
-
return value;
|
|
367
|
-
};
|
|
368
|
-
return React__default.createElement("div", {
|
|
369
|
-
className: "".concat(containerName)
|
|
370
|
-
}, !hiddenRange ? React__default.createElement("div", {
|
|
371
|
-
className: "min"
|
|
372
|
-
}, minDesc || +min) : null, React__default.createElement("div", {
|
|
373
|
-
ref: root,
|
|
374
|
-
style: wrapperStyle(),
|
|
375
|
-
className: "".concat(rangeName),
|
|
376
|
-
onClick: function onClick(e) {
|
|
377
|
-
click(e);
|
|
378
|
-
}
|
|
379
|
-
}, marksList.length > 0 ? React__default.createElement("div", {
|
|
380
|
-
className: "nut-range-mark"
|
|
381
|
-
}, marksList.map(function (marks) {
|
|
382
|
-
return React__default.createElement("span", {
|
|
383
|
-
key: marks,
|
|
384
|
-
className: markClassName(marks),
|
|
385
|
-
style: marksStyle(marks)
|
|
386
|
-
}, marks, React__default.createElement("span", {
|
|
387
|
-
className: "nut-range-tick",
|
|
388
|
-
style: tickStyle(marks)
|
|
389
|
-
}));
|
|
390
|
-
})) : null, React__default.createElement("div", {
|
|
391
|
-
className: "nut-range-bar",
|
|
392
|
-
style: barStyle()
|
|
393
|
-
}, range ? [0, 1].map(function (item, index) {
|
|
394
|
-
return React__default.createElement("div", {
|
|
395
|
-
role: "slider",
|
|
396
|
-
key: index,
|
|
397
|
-
className: "".concat(index === 0 ? 'nut-range-button-wrapper-left' : '', "\n ").concat(index === 1 ? 'nut-range-button-wrapper-right' : ''),
|
|
398
|
-
tabIndex: disabled ? -1 : 0,
|
|
399
|
-
"aria-valuemin": +min,
|
|
400
|
-
"aria-valuenow": curValue(index),
|
|
401
|
-
"aria-valuemax": +max,
|
|
402
|
-
"aria-orientation": "horizontal",
|
|
403
|
-
onTouchStart: function onTouchStart(e) {
|
|
404
|
-
if (typeof index === 'number') {
|
|
405
|
-
// 实时更新当前拖动的按钮索引
|
|
406
|
-
SetButtonIndex(index);
|
|
407
|
-
}
|
|
408
|
-
_onTouchStart(e);
|
|
409
|
-
},
|
|
410
|
-
onTouchMove: function onTouchMove(e) {
|
|
411
|
-
_onTouchMove(e);
|
|
412
|
-
},
|
|
413
|
-
onTouchEnd: function onTouchEnd(e) {
|
|
414
|
-
_onTouchEnd();
|
|
415
|
-
},
|
|
416
|
-
onTouchCancel: function onTouchCancel(e) {
|
|
417
|
-
_onTouchEnd();
|
|
418
|
-
},
|
|
419
|
-
onClick: function onClick(e) {
|
|
420
|
-
e.stopPropagation();
|
|
421
|
-
}
|
|
422
|
-
}, button || React__default.createElement("div", {
|
|
423
|
-
className: "nut-range-button",
|
|
424
|
-
style: buttonStyle()
|
|
425
|
-
}, !hiddenTag ? React__default.createElement("div", {
|
|
426
|
-
className: "number"
|
|
427
|
-
}, curValueDesc || curValue(index)) : null));
|
|
428
|
-
}) : React__default.createElement("div", {
|
|
429
|
-
role: "slider",
|
|
430
|
-
className: "nut-range-button-wrapper",
|
|
431
|
-
tabIndex: disabled ? -1 : 0,
|
|
432
|
-
"aria-valuemin": +min,
|
|
433
|
-
"aria-valuenow": curValue(),
|
|
434
|
-
"aria-valuemax": +max,
|
|
435
|
-
"aria-orientation": "horizontal",
|
|
436
|
-
onTouchStart: function onTouchStart(e) {
|
|
437
|
-
_onTouchStart(e);
|
|
438
|
-
},
|
|
439
|
-
onTouchMove: function onTouchMove(e) {
|
|
440
|
-
_onTouchMove(e);
|
|
441
|
-
},
|
|
442
|
-
onTouchEnd: function onTouchEnd(e) {
|
|
443
|
-
_onTouchEnd();
|
|
444
|
-
},
|
|
445
|
-
onTouchCancel: function onTouchCancel(e) {
|
|
446
|
-
_onTouchEnd();
|
|
447
|
-
},
|
|
448
|
-
onClick: function onClick(e) {
|
|
449
|
-
e.stopPropagation();
|
|
450
|
-
}
|
|
451
|
-
}, button || React__default.createElement("div", {
|
|
452
|
-
className: "nut-range-button",
|
|
453
|
-
style: buttonStyle()
|
|
454
|
-
}, !hiddenTag ? React__default.createElement("div", {
|
|
455
|
-
className: "number"
|
|
456
|
-
}, curValueDesc || curValue()) : null)))), !hiddenRange ? React__default.createElement("div", {
|
|
457
|
-
className: "max"
|
|
458
|
-
}, maxDesc || +max) : null, React__default.createElement(Toast, {
|
|
459
|
-
type: "text",
|
|
460
|
-
visible: show,
|
|
461
|
-
msg: toastMsg,
|
|
462
|
-
onClose: function onClose() {
|
|
463
|
-
SetShow(false);
|
|
464
|
-
}
|
|
465
|
-
}));
|
|
466
|
-
};
|
|
467
|
-
Range.defaultProps = defaultProps;
|
|
468
|
-
Range.displayName = 'NutRange';
|
|
469
|
-
export { Range as R };
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
-
import React__default, { useRef, useState, useEffect } from 'react';
|
|
6
|
-
import Taro from '@tarojs/taro';
|
|
7
|
-
import { c as cn } from './bem-893ad28d.js';
|
|
8
|
-
import { u as useConfig } from './configprovider.taro-8bdb3a28.js';
|
|
9
|
-
import { I as Icon } from './icon.taro-1d0d4fb7.js';
|
|
10
|
-
import { C as ComponentDefaults } from './typings-1c5f2628.js';
|
|
11
|
-
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
12
|
-
placeholder: '',
|
|
13
|
-
shape: 'square',
|
|
14
|
-
disabled: false,
|
|
15
|
-
maxLength: 9999,
|
|
16
|
-
clearable: true,
|
|
17
|
-
align: 'left',
|
|
18
|
-
readonly: true,
|
|
19
|
-
autoFocus: false,
|
|
20
|
-
label: '',
|
|
21
|
-
leftinIcon: React__default.createElement(Icon, {
|
|
22
|
-
name: "search",
|
|
23
|
-
size: "12"
|
|
24
|
-
})
|
|
25
|
-
});
|
|
26
|
-
var SearchBar = function SearchBar(props) {
|
|
27
|
-
var searchbarBem = cn('searchbar');
|
|
28
|
-
var _useConfig = useConfig(),
|
|
29
|
-
locale = _useConfig.locale;
|
|
30
|
-
var searchRef = useRef(null);
|
|
31
|
-
var _useState = useState(function () {
|
|
32
|
-
return props.value;
|
|
33
|
-
}),
|
|
34
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
-
value = _useState2[0],
|
|
36
|
-
setValue = _useState2[1];
|
|
37
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
38
|
-
placeholder = _defaultProps$props.placeholder,
|
|
39
|
-
shape = _defaultProps$props.shape,
|
|
40
|
-
className = _defaultProps$props.className,
|
|
41
|
-
disabled = _defaultProps$props.disabled,
|
|
42
|
-
maxLength = _defaultProps$props.maxLength,
|
|
43
|
-
clearable = _defaultProps$props.clearable,
|
|
44
|
-
align = _defaultProps$props.align,
|
|
45
|
-
readOnly = _defaultProps$props.readOnly,
|
|
46
|
-
autoFocus = _defaultProps$props.autoFocus,
|
|
47
|
-
label = _defaultProps$props.label,
|
|
48
|
-
actionText = _defaultProps$props.actionText,
|
|
49
|
-
leftinIcon = _defaultProps$props.leftinIcon,
|
|
50
|
-
rightinIcon = _defaultProps$props.rightinIcon,
|
|
51
|
-
leftoutIcon = _defaultProps$props.leftoutIcon,
|
|
52
|
-
rightoutIcon = _defaultProps$props.rightoutIcon,
|
|
53
|
-
onChange = _defaultProps$props.onChange,
|
|
54
|
-
onFocus = _defaultProps$props.onFocus,
|
|
55
|
-
onBlur = _defaultProps$props.onBlur,
|
|
56
|
-
onClear = _defaultProps$props.onClear,
|
|
57
|
-
onCancel = _defaultProps$props.onCancel,
|
|
58
|
-
onSearch = _defaultProps$props.onSearch,
|
|
59
|
-
onClickInput = _defaultProps$props.onClickInput,
|
|
60
|
-
onClickLeftinIcon = _defaultProps$props.onClickLeftinIcon,
|
|
61
|
-
onClickLeftoutIcon = _defaultProps$props.onClickLeftoutIcon,
|
|
62
|
-
onClickRightinIcon = _defaultProps$props.onClickRightinIcon,
|
|
63
|
-
onClickRightoutIcon = _defaultProps$props.onClickRightoutIcon,
|
|
64
|
-
iconClassPrefix = _defaultProps$props.iconClassPrefix,
|
|
65
|
-
iconFontClassName = _defaultProps$props.iconFontClassName;
|
|
66
|
-
var alignClass = "".concat(align);
|
|
67
|
-
var change = function change(event) {
|
|
68
|
-
var value = event.target.value;
|
|
69
|
-
onChange && (onChange === null || onChange === void 0 ? void 0 : onChange(value, event));
|
|
70
|
-
setValue(value);
|
|
71
|
-
};
|
|
72
|
-
var focus = function focus(event) {
|
|
73
|
-
var value = event.target.value;
|
|
74
|
-
onFocus && (onFocus === null || onFocus === void 0 ? void 0 : onFocus(value, event));
|
|
75
|
-
};
|
|
76
|
-
var blur = function blur(event) {
|
|
77
|
-
var searchSelf = searchRef.current;
|
|
78
|
-
searchSelf && searchSelf.blur();
|
|
79
|
-
var value = event.target.value;
|
|
80
|
-
onBlur && (onBlur === null || onBlur === void 0 ? void 0 : onBlur(value, event));
|
|
81
|
-
};
|
|
82
|
-
useEffect(function () {
|
|
83
|
-
setValue(props.value);
|
|
84
|
-
}, [props.value]);
|
|
85
|
-
useEffect(function () {
|
|
86
|
-
if (autoFocus) {
|
|
87
|
-
var searchSelf = searchRef.current;
|
|
88
|
-
searchSelf && searchSelf.focus();
|
|
89
|
-
}
|
|
90
|
-
}, [autoFocus]);
|
|
91
|
-
var renderField = function renderField() {
|
|
92
|
-
return React__default.createElement("input", {
|
|
93
|
-
className: "".concat(searchbarBem('input'), " ").concat(searchbarBem(alignClass), " ").concat(shape === 'round' ? searchbarBem('round') : '', " ").concat(clearable ? searchbarBem('input-clear') : ''),
|
|
94
|
-
ref: searchRef,
|
|
95
|
-
style: _objectSpread(_objectSpread({}, props.style), {}, {
|
|
96
|
-
background: props.inputBackground
|
|
97
|
-
}),
|
|
98
|
-
value: value || '',
|
|
99
|
-
placeholder: placeholder || locale.placeholder,
|
|
100
|
-
disabled: disabled,
|
|
101
|
-
readOnly: readOnly,
|
|
102
|
-
maxLength: maxLength,
|
|
103
|
-
onKeyPress: onKeypress,
|
|
104
|
-
onChange: function onChange(e) {
|
|
105
|
-
return change(e);
|
|
106
|
-
},
|
|
107
|
-
onFocus: function onFocus(e) {
|
|
108
|
-
return focus(e);
|
|
109
|
-
},
|
|
110
|
-
onBlur: function onBlur(e) {
|
|
111
|
-
return blur(e);
|
|
112
|
-
},
|
|
113
|
-
onClick: function onClick(e) {
|
|
114
|
-
return clickInput(e);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
var clickInput = function clickInput(e) {
|
|
119
|
-
onClickInput && onClickInput(e);
|
|
120
|
-
};
|
|
121
|
-
var renderLeftinIcon = function renderLeftinIcon() {
|
|
122
|
-
if (!leftinIcon) return null;
|
|
123
|
-
return React__default.createElement("div", {
|
|
124
|
-
className: "".concat(searchbarBem('leftin-icon'), " ").concat(searchbarBem('icon')),
|
|
125
|
-
onClick: function onClick(e) {
|
|
126
|
-
return clickLeftIcon('in-left', e);
|
|
127
|
-
}
|
|
128
|
-
}, leftinIcon);
|
|
129
|
-
};
|
|
130
|
-
var renderLeftoutIcon = function renderLeftoutIcon() {
|
|
131
|
-
if (!leftoutIcon) return null;
|
|
132
|
-
return React__default.createElement("div", {
|
|
133
|
-
className: "".concat(searchbarBem('leftout-icon')),
|
|
134
|
-
onClick: function onClick(e) {
|
|
135
|
-
return clickLeftIcon('out-left', e);
|
|
136
|
-
}
|
|
137
|
-
}, leftoutIcon);
|
|
138
|
-
};
|
|
139
|
-
var clickLeftIcon = function clickLeftIcon(flag, event) {
|
|
140
|
-
if (flag === 'in-left') {
|
|
141
|
-
onClickLeftinIcon && onClickLeftinIcon(value, event);
|
|
142
|
-
} else {
|
|
143
|
-
onClickLeftoutIcon && onClickLeftoutIcon(value, event);
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
var renderRightinIcon = function renderRightinIcon() {
|
|
147
|
-
if (!rightinIcon) return null;
|
|
148
|
-
return React__default.createElement("div", {
|
|
149
|
-
className: "".concat(searchbarBem('rightin-icon'), " ").concat(searchbarBem('icon')),
|
|
150
|
-
onClick: function onClick(e) {
|
|
151
|
-
return clickRightIcon('in-right', e);
|
|
152
|
-
}
|
|
153
|
-
}, rightinIcon);
|
|
154
|
-
};
|
|
155
|
-
var renderRightoutIcon = function renderRightoutIcon() {
|
|
156
|
-
if (!rightoutIcon) return null;
|
|
157
|
-
return React__default.createElement("div", {
|
|
158
|
-
className: "".concat(searchbarBem('rightout-icon')),
|
|
159
|
-
onClick: function onClick(e) {
|
|
160
|
-
return clickRightIcon('out-right', e);
|
|
161
|
-
}
|
|
162
|
-
}, rightoutIcon);
|
|
163
|
-
};
|
|
164
|
-
var clickRightIcon = function clickRightIcon(flag, event) {
|
|
165
|
-
if (flag === 'in-left') {
|
|
166
|
-
onClickRightinIcon && onClickRightinIcon(value, event);
|
|
167
|
-
} else {
|
|
168
|
-
onClickRightoutIcon && onClickRightoutIcon(value, event);
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
var handleClear = function handleClear() {
|
|
172
|
-
return React__default.createElement("div", {
|
|
173
|
-
className: "".concat(searchbarBem('clear'), " ").concat(rightinIcon ? 'pos-right' : ''),
|
|
174
|
-
onClick: function onClick(e) {
|
|
175
|
-
return clearaVal(e);
|
|
176
|
-
}
|
|
177
|
-
}, React__default.createElement(Icon, {
|
|
178
|
-
classPrefix: iconClassPrefix,
|
|
179
|
-
fontClassName: iconFontClassName,
|
|
180
|
-
name: "circle-close",
|
|
181
|
-
size: "12",
|
|
182
|
-
color: "#555"
|
|
183
|
-
}));
|
|
184
|
-
};
|
|
185
|
-
var clearaVal = function clearaVal(event) {
|
|
186
|
-
if (disabled || readOnly) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
setValue('');
|
|
190
|
-
onClear && onClear(event);
|
|
191
|
-
};
|
|
192
|
-
var renderRightLabel = function renderRightLabel() {
|
|
193
|
-
if (actionText) {
|
|
194
|
-
return React__default.createElement("div", {
|
|
195
|
-
className: searchbarBem('action-text'),
|
|
196
|
-
onClick: search
|
|
197
|
-
}, actionText);
|
|
198
|
-
}
|
|
199
|
-
return null;
|
|
200
|
-
};
|
|
201
|
-
var onKeypress = function onKeypress(e) {
|
|
202
|
-
if (e.keyCode === 13) {
|
|
203
|
-
if (typeof e.cancelable !== 'boolean' || e.cancelable) {
|
|
204
|
-
e.preventDefault();
|
|
205
|
-
}
|
|
206
|
-
onSearch && onSearch(value);
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
var search = function search() {
|
|
210
|
-
onSearch && onSearch(value);
|
|
211
|
-
};
|
|
212
|
-
var renderLabel = function renderLabel() {
|
|
213
|
-
if (label) {
|
|
214
|
-
return React__default.createElement("div", {
|
|
215
|
-
className: searchbarBem('label')
|
|
216
|
-
}, label);
|
|
217
|
-
}
|
|
218
|
-
return null;
|
|
219
|
-
};
|
|
220
|
-
var envClass = function envClass() {
|
|
221
|
-
return Taro.getEnv() === 'WEB' ? 'nut-searchbar-taro' : '';
|
|
222
|
-
};
|
|
223
|
-
return React__default.createElement("div", {
|
|
224
|
-
className: "".concat(searchbarBem(), " ").concat(envClass(), " ").concat(disabled ? searchbarBem('disabled') : '', " ").concat(className || ''),
|
|
225
|
-
style: _objectSpread(_objectSpread({}, props.style), {}, {
|
|
226
|
-
background: props.background
|
|
227
|
-
})
|
|
228
|
-
}, renderLeftoutIcon(), renderLabel(), React__default.createElement("div", {
|
|
229
|
-
className: "".concat(searchbarBem('content'))
|
|
230
|
-
}, renderLeftinIcon(), React__default.createElement("div", {
|
|
231
|
-
className: "nut-searchbar__input-box"
|
|
232
|
-
}, renderField()), renderRightinIcon(), clearable && value && handleClear()), renderRightoutIcon(), renderRightLabel());
|
|
233
|
-
};
|
|
234
|
-
SearchBar.defaultProps = defaultProps;
|
|
235
|
-
SearchBar.displayName = 'NutSearchBar';
|
|
236
|
-
export { SearchBar as S };
|